<?

// Index for php sources.
// PJ Waskiewicz, 8/05/2001
// index.php

$source_directory "/home/waskiewicz.org/www/php_sources/";
$filename "/home/waskiewicz.org/www/scripts/php_sources_index.html";

$fp fopen($filename"r");
$content fread($fpfilesize($filename));
fclose($fp);

// The idea is to grab all .phps files in the current directory and
// then output the list to the page.  This way I can add files to the
// directory later without having to update anything.  :-)
// Push them into an array so I can sort them alphabetically...

$list_array = array();
$content_replace "";
$dir opendir($source_directory);
while(
$file readdir($dir)) {
  if(
preg_match("/.*\.phps/"$file)) {
    
array_push($list_array$file);
  }
}
closedir($dir);

// Sort the array
rsort($list_array);
reset($list_array);

while(
$file array_pop($list_array)) {
   
preg_match("/(.*)\.phps/"$file$matches);
   
$content_replace $content_replace "<tr><td><a href=\"/php_sources/$file\">$file</a></td>\n";
   
// Now grab the desc file and add it to the table for a brief description
   // of what that code does.
   
$desc_file $source_directory $matches[1] . ".desc";
   
$fp fopen($desc_file"r");
   
$file_desc fread($fpfilesize($desc_file));
   
fclose($fp);
   
clearstatcache();
   
$mtime filemtime($file);
   
$modified date("d F Y h:i:s A"$mtime);
   
$content_replace $content_replace "<td>$file_desc</td>\n" .
    
"<td><font size=-2>Last modified: $modified</font></td></tr>\n";
}

$content preg_replace("/CONTENT/"$content_replace$content);
print 
$content;

// Get the last modified time for this file
clearstatcache();
$mtime filemtime($filename);
$modified date("d F Y h:i:s A"$mtime);

// Finish the index page with some php to give the last
// time this page was modified (overkill...)
print "<div align=right><font color=\"#999999\"><font size=-2>Modified Last: $modified</font></font></div></body></html>";

?>