<?php

$with_tables = TRUE;
//$with_tables = FALSE;

echo "
<html>
<body bgcolor='white'>";

echo "
<STYLE TYPE='text/css'>
BODY 
{scrollbar-face-color: #0069B3; 
 scrollbar-shadow-color: #000000;
 scrollbar-highlight-color: #FFFFFF;
 scrollbar-3dlight-color: #000000; 
 scrollbar-darkshadow-color: #000000; 
 scrollbar-track-color: #0069B3; 
 scrollbar-arrow-color: #FFCC00;}
TD.a {color:blue;
       background-color:#FFFFFF;
       font-color:blue;
       font-size:11px;
       font-family:verdana;}
A.a {color:#FFCC00;
       background-color:#000000;
       foreground-color:#ffcc00;
       font-color:#FFCC00;
       font-size:11px;
       font-family:verdana;}
A.b {color:#FFCC00;
       background-color:#0069b3;
       foreground-color:#ffcc00;
       text-decoration:none;
       font-color:#FFCC00;
       font-size:11px;
       font-family:verdana;}
A {
color:#FFFFFF;
text-decoration:none;
}
A:hover {
color:#FFCC00;
text-decoration:underline;
}
A.menu {
color:#000000; 
text-decoration:underline;
}
A:hover.menu {
color:#FFFF00;
text-decoration:underline;
}
A.esp {
color:#FF3333; 
text-decoration:underline;
}
A:hover.esp {
color:#33FFFF;
text-decoration:none;
}

A.div {
color:#FFCC00; 
text-decoration:none;
}
A:hover.div {
color:#FF3333;
text-decoration:none;
}
TD.b {color:black;
       background-color:white;
       font-size:11px;
       font-family:verdana;}
TD.c {color:red;
       background-color:white;
       font-size:11px;
       font-family:verdana;}
P.a {
       background-color:$res_couleur_fond_entête;
       color:$res_couleur_texte_entête;}
P.c {color:#FFCC00;
       background-color:#000000;
       font-size:11px;
       font-family:verdana;
}
INPUT {color:#FFCC00;
       background-color:#0069B3;
       font-size:11px;
       font-family:verdana;}
SELECT {color:#FFCC00;background-color:#0069D2;font-size:12px;font-family:verdana;}
TEXTAREA {color:#FFCC00;background-color:#0069B3;font-size:11px;font-family:verdana;}
</STYLE>";

if (with_tables)
{
  echo "
<table border width=100%>
  <tr>
    <td width=70 nowrap class='a'><i><center>date</center></i></td>
    <td width=50% class='b'><i><center>file</center></i></td>
    <td class='c'><i><center>comment</center></i></td>
  </tr>";
}

$started = FALSE;

$fcontents = file ('ChangeLog');

$date = "";

while (list ($n, $line) = each ($fcontents))
{
  $line = str_replace ("\t", " ", $line);
  $c = substr ($line, 0, 1);

  $line = trim ($line);
  if ($line == "") continue;
  
  $words = explode (" ", $line);
  $NF = count ($words) - 1;

  //echo "|<font color=red>$line</font>|". $words[0] . "|". $words[1] . "|". $words[2] . "|<br>";

  $marker = strpos ("." . $line, "):");
  if ($marker >= 1)
    {
    }
  else
    {
      $marker = 0;
    }

  //echo "<br>date: $date<br> ladate: $ladate<br>";

  if ($c != " ")
    {
      // <date> <who> <number>

      $has_number = (strcspn ($words[$NF], "0123456789") == 0);

      if ($has_number)
        {
          $last = $NF - 1;
          $number = $words[$NF];
        }
      else
        {
          $last = $NF;
          $number = "";
        }

      $who = "";

      for ($i = 1; $i <= $last; $i++)
        {
          $who .= " ";
          $who .= $words[$i];
        }


      $date = $words[0];
      if ($date != $ladate)
        {
          $ladate = $date;
        }
      else
        {
          $date = "&nbsp;";
        }

      //echo "date:[" . $date . "] ladate:[" . $ladate . "] who:" . $who . " #:" . $number . " [$line]<br>" ;

    }
  else if (($words[0] == "*") || ($marker >= 1))
    {
      if ($started)
        {
          if ($with_tables) echo "</td></tr>";

          $started = FALSE;
        }

      if ($marker == 0)
        {
          $marker = strpos ("." . $line, ":");
        }
      else
        {
          $marker++;
        }

      //echo "  ...Starting an entry... marker=$marker date=$date<br>";

      if ($marker > 0)
        {
          $head = substr ($line, 0, $marker);
          $line = substr ($line, $marker);
        }
      else
        {
          $head = $line;
          $line = "";
        }

      $head = trim ($head);
      $line = trim ($line);

      //echo "[$head] [$line]<br>";

      $par = strpos ("." . $head, "(");
      if ($par > 0)
        {
          if ($par > 1) $file = substr ($head, 0, $par-1);
          $info = substr ($head, $par);
          $info = str_replace ("(", "", $info);
          $info = str_replace (")", "", $info);
          $info = str_replace (":", "", $info);
        }
      else
        {
          $file = $head;
          $info = "";
        }

      $file = str_replace ("*", "", $file);
      $file = str_replace ("(", "", $file);
      $file = str_replace (")", "", $file);
      $file = str_replace (":", "", $file);
      $file = str_replace ("\\", "/", $file);

      if ($with_tables) echo "<tr><td class='a' valign='top'> ";

      echo "$date";

      if ($with_tables) echo "</td><td class='b' valign='top'>";

      echo "$file";

      if (!empty ($info)) echo " (<font color='green'>$info</font>)";

      //echo "</tt>";

      if ($with_tables) echo "</td><td class='c' valign='top'>";

      $date = "&nbsp;";

      $line = trim ($line);

      if (empty ($line)) $line="&nbsp;";

      echo "$line";
      if (!$with_tables) echo "<br>";

      $started = TRUE;
      $was_empty = FALSE;
      $was_not_empty = FALSE;

    }
  else if ($started)
    {
      $line = trim ($line);
      if (empty ($line))
        {
          if ($was_not_empty) 
            {
              $was_not_empty = FALSE;
              $was_empty = TRUE;
            }
          $line = "&nbsp;";
        }
      else
        {
          if ($was_empty)
            {
              $was_empty = TRUE;
              echo "<br>";
            }
          $was_not_empty = TRUE;
        }
      echo "$line";
      if (!$with_tables) echo "<br>";
    }
}

if ($with_tables) echo "</table>";

echo "
</body>
</html>";


?>

