Hello ppl,
I have a problem with a script which can display an random image or a swf from a directory.
I must tell from the start that if somebody has an script whih can do that and it's working properly, pls send it to me 'cause this script drive me CRAZYYYYYYY 🙁
The problem is :
1.if I insert a new swf in the directory I will see that the movie is not loaded.
2. If I rename one of the movies which are displaied properly I will see the same thing (the movie will not be loaded).
3.If I copy a movie which is well displaied and paste in the same directory but with other name I will find that the movie will be not loaded (the new one).
4. and this error i'm not sure if is because the random script. If I will overwrite a movie with a new one, the new movie will not be loaded.
* All the movies are the same dimensions W415 H60 and same version of flash, Flash5
If somebody can give me a better script I'll be verry glad. if not maybe you can look at the "problem script" 🙂
<?php
//read folder
$folder=opendir("random_banner");
while ($file = readdir($folder))
$names[count($names)] = $file;
closedir($folder);
//sort file names in array
sort($names);
//remove any non-images from array
$tempvar=0;
for ($i=0;$names[$i];$i++){
$ext=strtolower(substr($names[$i],-4));
if ($ext==".jpg"||$ext==".gif"||$ext=="jpeg"||$ext==".png"||$ext==".swf"){$names1[$tempvar]=$names[$i];$tempvar++;}
}
//random
srand ((double) microtime() * 10000000);
$rand_keys = array_rand ($names1, 2);
//random image from array
$slika=$names1[$rand_keys[0]];
//image dimensions
//$dimensions = GetImageSize($slika);
if (isset($pic)){header ("Location: $slika");}
else {echo "<embed src=\"$slika\" width=\"415\" height=\"60\" type=\"application/x-shockwave-flash\" swliveconnect=\"false\" menu=\"false\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>";}
?>