Network Notices

Alphabetical"; print ''; } else { print "

Chronological

"; print '
TitleDate
'; } $files = array(); if ($handle = opendir('.')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != ".." && $entry != "index.html" && strtolower(substr($entry, strrpos($entry, '.') + 1)) == 'html') { $files[$entry] = $entry; } } closedir($handle); $modificationArray = array(); $titleArray = array(); $monthArray = array("January" => "01", "February" => "02", "March" => "03", "April" => "04", "May" => "05", "June" => "06", "July" => "07", "August" => "08", "September" => "09", "October" => "10", "November" => "11", "December" => "12"); #Find the title/date of the file, use it to create an associative array of webpage=>title, webpage=>date foreach($files as $entry) { $lastModified = date('Y/m/d',filemtime($entry)); #$newEntry = array("$entry"=>"$lastModified"); #$modificationArray = array_merge((array)$modificationArray, (array)$newEntry); #Loop through the entire contents of a file line by line $titleline = "

"; $titleend = "

"; $postedLine = "

"; $postedEnd = "

"; #Open the file for reading ("r") $fileHandle = fopen($entry,"r"); #If the file opened, then proceed if($fileHandle) { #Loop until there are no more lines in the file. while(($line = fgets($fileHandle))!==false) { #Get the Title of the article $pos = strpos($line,$titleline); if ($pos !== false) { $pos2 = strpos($line,$titleend,$pos); $title = substr($line,$pos+4,$pos2-$pos-4); } #Get the date of the article $posted = strpos($line,$postedLine); if ($posted !== false) { $posted2 = strpos($line,$postedEnd,$posted); $dateString = substr($line,$posted+4,$posted2-$posted-4); $dateSections = explode(" ",$dateString); #Format the month, date, and year $dateSections[1] = $monthArray[$dateSections[1]]; $dateSections[2] = rtrim($dateSections[2], ","); if ($dateSections[2] < 10) $dateSections[2] = "0$dateSections[2]"; $dateSections[3] = rtrim($dateSections[3], "\n"); #If there is no date, set there to be no date if(strcmp($dateSections[1],"")==0|| strcmp($dateSections[2],"")==0 || strcmp($dateSections[3],"")==0) $newEntry = array($entry => ""); else $newEntry = array("$entry"=>"$dateSections[3]/$dateSections[1]/$dateSections[2]"); $modificationArray = array_merge((array)$modificationArray, (array)$newEntry); break; } } fclose($fileHandle); } else { print "Search Failed:Could not open the file"; } #add the new entry to the associative Array $newEntry = array("$entry"=>"$title"); $titleArray = array_merge((array)$titleArray, (array)$newEntry); } if($alphabetical == 1) { #Sort based on the article titles asort($titleArray); foreach($titleArray as $entry=>$value) { print ""; } } else #Chronological { arsort($modificationArray); foreach($modificationArray as $entry=>$value) { print ""; } } print "
DateTitle
$value$modificationArray[$entry]
$value$titleArray[$entry]
"; } ?>