fluffy_lobster
Veteran Member
Posts: -2
Posts: 1391 Reputation: 23
36 / /
Joined: Nov 2002
|
RE: PHP Random Avatar Cache
Try:
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("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Location: " . $dir . "/" . $files[$randnum]); //redirects the browser to a random file, allowing it to cache
?>
This post was edited on 03-23-2005 at 11:45 AM by fluffy_lobster.
|
|