<?php
  $list_file = "/var/wwwdata/downloads.txt";
  function printList($list_file)
  {
    if(!($fd = fopen($list_file, "r"))){
      return;
    }
    echo "<ul>";
    while (!feof ($fd)){
      $line = trim(fgets($fd));
      $arr = explode(";", $line);
      if(count($arr) == 4){
        echo "<li><a href='download.php?fileid=$arr[0]" .
             "'>$arr[3] ($arr[1])</a> </li>\n";
      }
    }
    echo "</ul>";
  }
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Moja strona WWW</title>
  </head>
  <body>
    <div>
      <?php
        printList($list_file);
      ?>
    </div>
  </body>
</html>
