just put this in a php file, you'll know what to do next,won't work on a windows server though
PHP Code:
<?php
# folder from the document_root you want to include and all sub dirs
$folder = "images";
function createimagearray($newdir){
global $folder,$newarray,$DOCUMENT_ROOT;
$dir_subdirs = array();
chdir($newdir);
$handle = opendir($newdir);
while($entry = readdir($handle)){
$dirtitle = str_replace($DOCUMENT_ROOT,"",$newdir);
$last4 = substr(strtolower($entry),-4);
if(is_dir($entry) && $entry != ".." && $entry != "."){
$dir_subdirs[] = $entry;
} elseif($entry != ".." && $entry != "." && ($last4 == ".gif" || $last4 == ".jpg" || $last4 == ".png" || $last4 == ".bmp")){
$newarray .= "$dirtitle$entry||";
}
}
sort($dir_subdirs);
for($i=0; $i<count($dir_subdirs); $i++){
$array = createimagearray("$newdir$dir_subdirs[$i]/");
}
closedir($handle);
return $newarray;
}
$array = createimagearray($DOCUMENT_ROOT."/".$folder."/");
$array = substr($array, 0,-2);
$array = explode("||",$array);
function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
$view = $array[rand(0,(count($array))-1)];
echo "<img src=\"$view\">";
?>
tell me if it doesn't work though, cause i want to use it for other things as well, and my localhost isn't working at the moment, plus i'm quite a php n00b, this wasn't made for forum use though, just a seperate script, but i'm sure you can get it to work