Jan. 20, 2006
Hi all, this post regards a small script PHP that allows to visualize randomly a Flash movie between those present ones in one directory. The operation mechanism is this: page PHP does not make other that to load an Array the files .swf present in the directory, do a shuffle of the Array and sendes, using the opportune ones header, to browser the content of element 0 of the Array. From the part of page HTML, he is sufficient to modify the references to single swf file relatively to tag OBJECT and EMBED so that pointing to page PHP.
<?phpdefine("LOCALDIR",getcwd());$files = array();if ($dir = opendir(LOCALDIR)) {while (($file = readdir($dir)) !== false) {$fileinfo = pathinfo(LOCALDIR."\\".$file);if ($file != "." && $file != ".." && $fileinfo["extension"] == "swf") {$finfo = stat(LOCALDIR."\\".$file);$files[] = $file;}}closedir($dir);}shuffle($files);$swf = $files[0];header("Pragma: public");header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");header("Cache-Control: must-revalidate");header("Content-type: application/x-shockwave-flash");header("Content-Length: ".filesize($swf));header("Content-disposition: inline; filename=$swf");header("Accept-Ranges: ".filesize($swf));readfile($swf);exit();?>- Download this code: swfproducer.txt





3 Responses to “Random visualization of Flash movies”
non riesco a afar funzionare questo script
By davide on 2008-02-29
Che problema hai?
By mcalamel on 2008-03-03
Per prima cosa grazie per aver messo lo script online. Ho qualche problema a configurarlo.
Mi spiego: ho una file php di nome header dove al suo interno fino a poco tempo fa girava un solo file swf. Ora non capisco come configurare il tutto in maniera tale che punti alla pagina PHP.
Grazie
By Christian on 2009-02-28