Hi,
I used to run my script on a php3 machine, and the random image script that reads from a folder (I'll paste the script below) works perfectly. But ever since my files are transferred to a php4 machine, it doesnt work anymore. I have tried all the image random scripts i could find, but non of them works.
What might be the problem?
file name is imgrandom.php3
<?php
#This script has been developped by Francesco D'Alesio [francesco@piuchegratis.com]
#Please feel free to contact me for any reason
#All you have to do is to change this two variables. Remember to use the absolute path for the first variable, starting with a slash
$absolute = "../pics/";
$url = "http://www.domain.com/pics/";
#You my now add in the img html tag the url of this script
#<IMG SRC="http://yourdomain.com/whatever/imgrandom.php3">
DO NOT CHANGE ANYTHING BELOW THIS LINE
$randir = dir("$absolute");
$num = 0;
while($read = readdir($randir))
{
$tmp = split(".", $read, 2);
if ($tmp[1] == "jpg" || $tmp[1] == "JPG")
{
$imgsrc[] = $read;
$num++;
}
if ($tmp[1] == "gif" || $tmp[1] == "GIF")
{
$imgsrc[] = $read;
$num++;
}
}
srand((double)microtime()*1000000);
$imgrandom = rand(0,($num-1));
header("location: $url/$imgsrc[$imgrandom]");
?>