Ack!!! :đŸ˜›ulling Out Hair:: I can't seem to get the below code to work! What is wrong with me!!! Please help:
//FILE NAME: random.php
<?php
/* Random flash file
kvack.inc [[url]http://kvack.euphemize.net[/url]] of euphemize.net (c)MMIII
Please leave this header intact if you wish to use
*/
$directory = 'swf/'; //Directory relative to the file
$flashfiles = list_images($directory);
srand ((float) microtime() * 10000000);
$flash = array_rand($flashfiles);
$flash = $directory.$flash;
function list_images($path)
{
//declares $flashlist as an array. good practice.
$flashlist = array();
//$dh points to the directory object for $path.
$dh = opendir($path);
//cycle through the files/directorys in the directory object
while (false !== ($file = readdir($dh)))
//for each file/directory, if *.swf, add it to the $flashlist[] array
if (preg_match('/.(?:swf)$/i', $file))
{
$flashlist[] = $file;
}
//sort the list
sort($flashlist, SORT_STRING);
//returns the array.
return $flashlist;
}
function echo_result($flash)
{
echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="770" height="128">';
echo ' <param name="movie" value="'.$flash.'"><param name="quality" value="high">';
echo ' <embed src="'.$flash.'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="770" height="128">';
echo ' </embed>';
echo '</object>';
}
?>
I am including the above PHP script into my main page like so:
<?php include_once('inc/random.php'); ?>
And then on that same page I am calling this function:
<?php list_images($directory);?>
Unfortunately, I do not get anything to display on my main page? Can anyone test out the above code, or give me any hints as to what I am doing wrong?
Does anyone know of any other PHP script(s) that will randomly display a .swf on page refresh?
Any code/links/help is appreciated
Thanks in advance,
Cheers!
Micky