Revision: 33237
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 7, 2010 04:41 by bjarniolsen
Initial Code
<?php
Header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
Header("Pragma: no-cache");
Header("Content-Type: image/gif");
$dir = "img/backgrounds";
//$imglist = "";
srand((double)microtime()*1000000);
$i = 0;
if(is_dir($dir)){
if($dh = opendir($dir)){
while(($file = readdir($dh)) !== false){
if($file != '..' && $file != '.'){
$image[$i] = $file;
$i++;
}
}
closedir($dh);
}
}
$n = rand(0,(count($image)-1));
if(!readfile($dir."/".$image[$n])) // Read the image
readfile($dir."error/error.gif"); // If the script can't find the directory, display this image
?>
Initial URL
Initial Description
Change $dir to image folder
Initial Title
Show random image in PHP
Initial Tags
php
Initial Language
PHP