"image/bmp", "gif" => "image/gif", "jpg" => "image/jpeg", "jpeg" => "image/jpeg", "png" => "image/png", "tif" => "image/tiff", "tiff" => "image/tiff", ); # Find the images in the current directory while (false !== ($file = readdir($handle))) { if (eregi('.(jpg|png|gif|tif|tiff|jpeg|bmp)',$file)) { $imgs[] = $file; } } closedir($handle); # If there are no images, display a suitable page. if (count($imgs) == 0) { header( 'Location: http://camvine.com/files/no_images.png') ; return; } # Pick a random image and return it shuffle($imgs); $img = $imgs[0]; $bits = explode(".",$img); $ext = $bits[count($bits) - 1]; header( 'Content-type: ' . $mimetypes[$ext] ) ; readfile($img); } ?>