// Random number generator for our opening image. // PJ Waskiewicz, 4/10/2001 // rand_index.php // Updated 10/2/2001 // The news is now in its own table in MySQL. // Pretty sweet, huh?? :-) $filename = "/home/waskiewicz.org/www/scripts/index.html"; $image_dir = "/home/waskiewicz.org/www/images/index/"; $dir = opendir($image_dir); $image_array = array(); while($file = readdir($dir)) { if(!preg_match("/^\.\.?$/", $file)) { // We aren't playing with one of the // standard filesystem .'s. array_push($image_array, $file); } } closedir($dir); $image_array_size = sizeof($image_array); // Seed the randomizer srand((double)microtime() * 1000000); // Get a random value $image_num = rand(0, $image_array_size - 1); $image = "/images/index/" . $image_array[$image_num]; // Now import HTML $fp = fopen($filename, "r"); $content = fread($fp, filesize($filename)); fclose($fp); // Time to get the news!! $news_content = get_news(); // Go Go regex replacement!! $content = preg_replace("/FRONT_IMAGE/", $image, $content); $content = preg_replace("/NEWS/", $news_content, $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 "