<?PHP
//////////////////////////////////////////////////////////////////
// Your Own Personal "RandoSig"
// Done for the Daily Post: Your authoritative QnF paper!
// Code by Jakob (Jakobo). Public Domain.
//////////////////////////////////////////////////////////////////
$files = Array()
if (is_dir("./")) {
if ($dh = opendir("./")) {
while (($file = readdir($dh)) !== false) {
if($file != "." &&
$file != ".." &&
$file != "" &&
$file != "rand.php") { $files[] = $file; }
}
closedir($dh)
}
}
$random_file = (rand()&#xsi;zeof($files))
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT")
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT")
header("Cache-Control: no-store, no-cache, must-revalidate")
header("Cache-Control: post-check=0, pre-check=0", false)
header("Pragma: no-cache")
if(substr($files[$random_file], -3) == "jpg") {
header("Content-type: image/jpeg")
} elseif(substr($files[$random_file], -3) == "gif") {
header("Content-type: image/gif")
} elseif(substr($files[$random_file], -3) == "png") {
header("Content-type: image/png")
} else { header("Content-type: text/plain")
echo "Image Error, could not load (".$random_file.")".
$files[$random_file] print_r($files) }
@readfile($files[$random_file])
?>
Something to add:
Make sure your images are named ".jpg", ".gif", or ".png" - the code provided here does NOT understand that they're the same thing if it's capitalized! It won't understand it if you have them named (example) "example.PNG"; but it will if it's "example.png".
Also, MAKE SURE YOU NAME THE .PHP FILE "rand.php", otherwise it will try to load the random-image generator as an image, making a broken image pop up in your sig!