I'm looking for a PHP script that I had a while back, and now don't remember. What it did, every time you refreshed a page, it was a different banner. As seen here:
http://www.katbox.net/laslindas/
Anyone know how to do this?
I'm looking for a PHP script that I had a while back, and now don't remember. What it did, every time you refreshed a page, it was a different banner. As seen here:
http://www.katbox.net/laslindas/
Anyone know how to do this?
Like this ;) (the script gets all images from folder it is in and randomly displays one of them):Originally Posted by Woraug
PHP Code:<?
if ($dir = opendir("."))
{
$list = buildimagearray($dir);
displayrandomimage($list);
}
function buildimagearray($dir)
{
while (false !== ($file = readdir($dir)))
{
if (!is_dir($file) && getimagesize($file))
{
$list[] = $file;
}
}
array_shift($list);
return $list;
}
function displayrandomimage($list)
{
srand ((double) microtime() * 10000000);
$sig = array_rand ($list);
$size = getimagesize ($list[$sig]);
$fp = fopen($list[$sig], "rb");
if ($size && $fp)
{
header("Content-type: {$size['mime']}");
fpassthru($fp);
exit;
}
}
?>
Tysil Chronicles (redesigning)SigChat Service (in development)Torch's PHP Functions Library (not finished)
How would I get it to read from a specific directory, instead of the one the script in put in?
i beleive u just change the opendir code...make itCode:<? if ($dir = opendir(".")) { $list = buildimagearray($dir); displayrandomimage($list); }
Code:<? if ($dir = opendir("blah/blahblah")) { $list = buildimagearray($dir); displayrandomimage($list); }
Last edited by swirly; 07-15-2006 at 12:51 AM.
Don't go to bed angry, stay awake and plot revenge.
Very cool. One final question (which I didn't think to ask before) How would I implement this into my forum? I'm not sure what I would edit to make this work. Invision v1.3.1
(BTW, thanks much for the help so far guys, you rock! :biggthump)
You just have to use this where ever you want your images to show:
Code:<img src="path/to/dir/where/script/is/script.php" border="0" />
Tysil Chronicles (redesigning)SigChat Service (in development)Torch's PHP Functions Library (not finished)
Right on! You guys have reached previously unheard of levels of badass.
Glad to be of help ;)
If you need any more personalized help/scripts, check this topic out: http://www.x10hosting.com/forums/showthread.php?t=17453![]()
Last edited by Torch; 07-15-2006 at 06:24 PM.
Tysil Chronicles (redesigning)SigChat Service (in development)Torch's PHP Functions Library (not finished)