php - Showing link of which random swf was opened -


i'm new php , seems i'm asking code in reality want know how implement link along random selector.

my code:

<?php $imglist=''; //$img_folder variable holds path swf files. // see dont forget "/" @ end $img_folder = "../files/flash/"; mt_srand((double)microtime()*1000); //use directory class $imgs = dir($img_folder); //read files directory, ad them list while ($file = $imgs->read()) { if (preg_match("/\.swf$/i", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put images array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate random number between 0 , number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display random swf echo '<embed src="'.$img_folder.$image.'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="650" height="450"></embed>'; ?> 

this grabs random flash file site's directory. since won't affect url bar, won't able send (which unintentional security feature). want them able send link or possibly direct click download.

also, thinking of random generator, make left , right arrow can scroll through .swf's in chosen directory, if possible.

the site www.nsgaming.us , it's 'random' button under text logo.

what asking reading parameters url people can link friends swf embed, can using $_get

look @ example coded.

    $swfs = array(); $swf_location = '../files/flash/';  if($handle = opendir($swf_location)) {     while(false !== ($entry = readdir($handle))) {         if(strtolower(pathinfo($path, pathinfo_extension)) == 'swf') {             $swfs[] = $entry;         }     }     closedir($handle); }  if(isset($_get['swf']) && in_array($_get['swf'], $swfs)) {     $swf = $_get['swf']; } else {     $swf = $swfs[rand(0, count($swfs))]; }  echo '<embed src="' . $swf_location . $swf . '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="650" height="450"></embed><br />send friend: <input type="text" value="http://yourwebsite.com/thisfilesname.php?swf=' . $swf . '" length="55">'; 

you're previous script messy , did lot of useless stuff, secure , faster


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -