<?php header("Content-type: image/png"); $imgtypes = "png"; $imgtypes = explode(",", $imgtypes); $imgpattern = "(.+."; $imgpattern .= implode(")|(.+.", $imgtypes); $imgpattern .= ")"; $thisdir = opendir("."); $images = array(); while($fn = readdir($thisdir)) { if (filetype($fn) == "file") { if (eregi($imgpattern, $fn)) { $images[] = $fn; } } } $nimages = count($images) - 1; $rimage = rand(0, $nimages); echo file_get_contents($images[$rimage]); closedir($thisdir); clearstatcache(); ?>