<?php
//LolRotator
$images = array();
//set allowed images
$allowed = array('image/jpg', 'image/png', 'image/gif', 'image/tiff');
//choose directory. set to current.
$dirPath = '.';
if ($handle = opendir($dirPath)) {
//read all the files
// keep reading the directory entries 'til the end
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != 'Thumbs.db' && $file != '.htaccess' && $file != 'image.php') {
//make sure it's a file, not directory
if(is_dir($file) == false) {
//get info
$get = getimagesize($file);
//get mime type from above
$mimetype = $get['mime'];
//'tis allowed?
if(in_array($mimetype, $allowed)) {
//add to array
$images[] = $file;
}
}
}
}
//close
closedir($handle);
}
//which one?
$show = mt_rand(0, (count($images)-1));
//turn stuff into images.
header('Content-Type: image/png');
//display
$image = imagecreatefrompng($images[$show]);
imagepng($image);
imagedestroy($image);
?>