NCCU News Story
Archives
$handle=opendir('./archives');
//I can plug in the appropriate *server's* (sub-)directory name.
echo " ";
//Meaningless validity check because dir./file handling errors were giving me problems
//echo "Directory handle: $handle ";
//echo "Files: ";
//echo " ";
while (false !== ($file = readdir($handle)))
{
//exclude the parent directory, and the current directory from the forthcoming array ("." and "..")
if (($file!=".")&&($file!=".."))
{
//choose the appropriate file extensions (in this case, .html and .htm)
$name_array = explode(".", $file);
$extension = $name_array[1];
if (($extension=="html")||($extension=="htm"))
{
//echo "$file"." ";
//open the file for reading
$fp = fopen("./archives/$file", "r");
$contents = fread($fp, filesize ("./archives/$file"));
fclose($fp);
//change everything to lower case to (making it easier to find the title tags, later)
$contents2 = strtolower($contents);
//find the position of the and tags... I hate pointer-counting, but sometimes there's no other way
$pos1 = strpos($contents2, "") + 7; // the +7 gets rid of the tag itself
$pos2 = strpos($contents2, "");
$len = $pos2 - $pos1;
//pull the title
$title = substr($contents, $pos1, $len);
//Extract the creation (formerly, modification) date - Note to self: Find the UNIX command to *alter* said dates
//PREVIOUS (successfully tested) code line: $date = filemtime("./archives/$file");
$date = filectime("./archives/$file");
//Drop it all in the array
//echo "$date _ $file _ $title"." ";
$file_list[] = "$title _ $file";
//$file_list[] = "$date _ $file _ $title";
}
}
}
closedir($handle);
//sort the array
//sort ($file_list); //commented by Bo
rsort($file_list,SORT_NUMERIC);
//loop through the array
for ($a=0; $a";
//Make the date more humanity-friendly
//PREVIOUS (successfully tested) code line: $date = date("F d Y H:i:s", $date);
///$date = date("F d Y", $date);
//echo " ";
//display the data
//PREVIOUS (successfully tested) code line: echo "$name $date $title ";
//echo '$title date
';
echo "".$title."";
//echo $name." ";
}
?>
|