What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP Random Avatar Cache

PHP Random Avatar Cache
Author: Message:
user27089
Disabled Account


Posts: 6321
Joined: Nov 2003
Status: Away
O.P. PHP Random Avatar Cache
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
?>


the images automatically go to the cache, I don't want this to happen... Can somebody edit the code accordingly please? So that it doesn't cache...

:$Not good with PHP:$.
03-23-2005 08:07 AM
Profile PM Find Quote Report
fluffy_lobster
Veteran Member
*****

Avatar
Posts: -2

Posts: 1391
Reputation: 23
36 / Male / Flag
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.
03-23-2005 11:44 AM
Profile E-Mail PM Web Find Quote Report
.Roy
Veteran Member
*****

Avatar

Posts: 1526
Reputation: 11
20 / Male / –
Joined: Aug 2004
RE: PHP Random Avatar Cache
flufffy what script should i rather use?
I am looking for one that makes my images go one my one by their order. Basically so i can go through all the images without going through  one image twice....
Which one is good for what i need Fluffy

This:

<?php
$dir = "imgs";
$dh = opendir($dir);
$files = array();
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
array_splice($files, 0, 2);
srand( (double) microtime()*1000000 );
$key = array_rand($files);
readfile($dir . "/" . $files[$key]);
?>

Or the one u just posted which is this:

<?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
?>
03-23-2005 11:58 AM
Profile PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: PHP Random Avatar Cache
neither will work because they both do random , how are your images laid out are they like

"comic1.png"
"comic2.png"
"comic2.png"

because if they are I can write a nice script for it but basicly just need to tell me or someone else how each file is stored
[Image: dt2.0v2.png]      Happy Birthday, WDZ
03-23-2005 12:05 PM
Profile PM Web Find Quote Report
.Roy
Veteran Member
*****

Avatar

Posts: 1526
Reputation: 11
20 / Male / –
Joined: Aug 2004
RE: PHP Random Avatar Cache
no.. Its

strip.1.gif
strip2.gif
strip3.gif


So on..
03-23-2005 12:09 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On