Let's simplify even further:
random.php
<?php
/**
* Set default values
*/
$dir = 'clocks/';
$files = array();
/**
* Get all SWF files into an array
*/
$d = dir($dir);
while(FALSE != ($entry=$d->read()))
{
if($entry != '.' && $entry != '..')
{
if(substr($entry, strrpos('.', $entry)+1)=='swf')
{
$files[] = $entry;
}
}
}
$d->close();
/**
* Get a random swf file:
*/
$swf_file = $files[rand(0, count($files)-1)];
/**
* Echo out the object tag
*/
?>
<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="400" height="400">
<param name="movie" value="<?php echo $swf_file; ?>">
<param name="quality" value="high">
<param name="bgcolor" value="#000000">
<param name="wmode" value="transparent">
<embed src="<?php echo $swf_file; ?>" quality="high" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="400" height="400" wmode="transparent"></embed>
</object>
access1.php
<?php
$clock = file_get_contents('random.php');
echo $clock;
?>
That should give you the proper HTML to insert... at least it does for me...
Here's a quick thing i used: it returns the proper HTML, but I can't get the clock to show up:
<?php
$contents = file_get_contents('http://www.12oclockmidnight.com/random.php');
$contents = preg_replace("@<param name=\"movie\" value=\"([\w\/\.]*)\">@", "<param name=\"movie\" value=\"http://www.12oclockmidnight.com/$1\">", $contents);
?>
<html>
<head>
<title>my Random Clock:</title>
</head>
<body>
<?php echo $contents; ?>
</body>
</html>
~Brett