uh i thought i would share this, but i have a diff way from doing that. Its almost like your favorite one but a little different.
<?php
$file = getRandomImage('./')
header('Content-Type: image/.gif')
header('Pragma: no-cache')
header('Expires: 0')
readfile($file)
function getRandomImage($dir,$type='random')
{
global $errors;
if (is_dir($dir)) {
$fd = opendir($dir)
$images = array()
while (($part = @readdir($fd)) == true) {
clearstatcache()
if ( eregi("(gif|jpg|png|jpeg)$",$part) ) {
$images[] = $part;
}
}
// adding this in case you want to return the image array
if ($type == 'all') { return $images; }
// Be sure to call srand() once per script
srand ((double) microtime() * 1000000)
$key = rand (0,sizeof($images)-1)
return $dir . $images[$key]
} else {
$errors[] = $dir.' is not a directory';
return false;
}
}
?>
picked it up a long time ago in the C&T don't have to change anything. All the pic just have to be in the same directory.
Enjoy.
P.S. if you already have this sorry
sweatdrop