\n". " | \n". " | \n". " | |||
\n". " | \n". " | \n". " | |||
\n". " | \n". " | \n". " | |||
\n". " | \n". " | \n". " | \n". " | \n". " |
// get all images in current directory, store them in the array called $images function get_all_available_images() { // open current dir if ($dir = @opendir(".")) { // loop through all files while (($file = readdir($dir)) !== false) { // is it a jpeg file (does it have the extension 'jpg'?) if (strtolower(substr($file, strlen($file)-3)) == "jpg") { // it's a jpeg file. put it in $images. $images[] = $file; } } // close directory handle closedir($dir); } // return $images return($images); } // get 12 random images from the array function get_random_images($images) { for ($i = 0; $i < 12; $i++) { // if the $images array is empty (in case of not enough images), set default image if (count($images) == 0) $randomimages[$i] = "jeroen.jpg"; // (hehehehehe) else { // get a random number between zero and the number of images left in the array $randomnumber = rand(0, count($images)-1); // set name of randomimages[$i] to the name of the selected image in $images $randomimages[$i] = $images[$randomnumber]; // remove the selected image from $images, so it cannot be selected a second time array_splice($images, $randomnumber, 1); } } // return $randomimages return($randomimages); } // MAIN // initialize random number generator srand((double)microtime()*1000000); // get 12 random images out of the available images in the current dir $randomimages = get_random_images(get_all_available_images()); // build some HTML $content = "\n\n" . "\n". "
\n". "sitemap \n". "
\n". " | \n". " | \n". " | |||
\n". " | \n". " | \n". " | |||
\n". " | \n". " | \n". " | |||
\n". " | \n". " | \n". " | \n". " | \n". " |