quote:
Originally posted by traxor
Hobbes, I don't want to take credit for the php script, it was made by Madman and edited a little bit by fluffy lobster (because of a security issue).
Thanks, i wasnt going to mention it but...
oh and ive updated the script so it lets the browser cache the images. Meaning less loading times.
code:
<?php
$dir = "imgs"; //The folder where all the images are kept
$dh = opendir($dir);
$files = array();
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
array_splice($files, 0, 2);
$filesnum = count($files);
srand( (double) microtime()*1000000 );
$randnum = rand(0, $filesnum - 1);
header("Location: " . $dir . "/" . $files[$randnum]); //redirects the browser to a random file, allowing it to cache
?>