Stories
You May Have Missed
$handle=opendir('http://web.nccu.edu/publicrelations/archives/');
// replace the above with the appropriate *server's* (sub-)directory name. For example: "http://web.nccu.edu/support/employee/archives/"
echo "
";
echo "Directory handle: $handle
";
echo "Files:
";
echo "
";
while (false !== ($file = readdir($handle)))
{
//get rid of the parent directory, and the current directory ("." and "..")
if (($file!=".")&&($file!=".."))
{
//Only allow reading for file extensions of .html and .htm
$name_array = explode(".", $file);
$extension = $name_array[1];
if (($extension=="html")||($extension=="htm"))
{
//open the file for reading
$fp = fopen("http://web.nccu.edu/support/employee/archives/$file", "r");
$contents = fread($fp, filesize ($file));
fclose($fp);
//make the contents of the file lower case to make it easier to find the title tags
$contents2 = strtolower($contents);
//find the position of the
and tags
$pos1 = strpos($contents2, "
") + 7; // the +7 gets rid of the tag itself
$pos2 = strpos($contents2, "");
$len = $pos2 - $pos1;
//get the title
$title = substr($contents, $pos1, $len);
//get the modification date
$date = filemtime($file);
//add everything to an array
$file_list[] = "$date _ $file _ $title";
}
}
}
closedir($handle);
//sort the array
sort ($file_list);
//loop through the array
for ($a=0; $a
";
}
?>