Make rand file from dir, use a url

Hello,

I was using a random image script and modified it to be a random flash movie script, it worked alright but found my home server isn’t quite fast enough. My friend is allowing me to store the files on his server…but his doesn’t support php right now…so i want to make it instead of trying to load from the root or subfolder, load from a url directory

[php]

<?php $file = getRandomImage('./'); header('Content-Type: application/x-shockwave-flash/.swf'); header('Pragma: no-cache'); header('Expires: 0'); readfile($file); function getRandomImage($dir,$type='random') { global $errors; if (is_dir($dir)) { $fd = opendir($dir); $images = array(); while (($part = @readdir($fd)) == true) { clearstatcache(); if ( eregi("(swf)$",$part) ) { $images[] = $part; } } // adding this in case you want to return the image array if ($type == 'all') { return $images; } // Be sure to call srand() once per script srand ((double) microtime() * 1000000); $key = rand (0,sizeof($images)-1); return $dir . $images[$key]; } else { $errors[] = $dir.' is not a directory'; return false; } } ?> [/php]

basically i want ./ to become http://www.whatever.com/
Any help is much appreciated

Edit-- Nevermind…I should have known not to test it with AOL…normally it will display everything (since i host myself at home, and aol gets a unique ip) but i guess calling a flash file from a php function is too much for it lol, works in Ie tho. Oh well ;x

Sponsor our Newsletter | Privacy Policy | Terms of Service