31-08-2006, 18:24
|
|
|
|
חבר מתאריך: 17.09.05
הודעות: 6,023
|
|
זה כמה קבצים ... אבל זה העיקרי אם בא לך לראות ..
את הקטע שמציג את הפלאש בניתי בעצמי .. זה מוסיף פלאש ע"י טעינת קובץ JS חיצוני שמטפל בהצגת הפלאש (ומוריד את המסגרת [למבינים])
קוד PHP:
<?
require "banner_conf.inc";
$banners=array(); //array of the banners (initializes with an empty array) $banners_total_prior=0; //the total priority of all the banners (initializes with 0) $banner_index=0; //the selected index banner $banner_dir=""; //the directory where the images and the data file are stored (the script will find it, do not set any value to it, should be empty string "")
$banner_fl=@file($banner_file); //reads the file lines into an array if (!$banner_fl) //if couldn't read the file for any reason echo "<B>ERROR:</B> cannot access or read the banners data file.<BR>\n"; else { $banner_dir=dirname($banner_file)."/"; //gets the directory name of the data file foreach ($banner_fl as $banner_ban) //getting over all the lines { if (($banner_ban=trim($banner_ban))=="") //if empty line continue; //continue the loop (skip the line) list($banner_href,$banner_src,$banner_alt,$banner_ prior)=explode("|",$banner_ban); //seperate the data fields from the line $banner_prior=(integer)$banner_prior; //converting $banner_prior to integer $banner_prior=($banner_prior>0)? $banner_prior:0; //set the default banner priority if ($banner_prior==0) //if the priority of the banner is 0 continue; //it will never be displayed and therefor we don't need to put it in the banners array $banner_index=count($banners); //$index is the new index to add to the array $banners[$banner_index]['href']=trim($banner_href); //removing the white spaces from begining and end of the strings $banners[$banner_index]['src']=trim($banner_src); $banners[$banner_index]['alt']=trim($banner_alt); $banners[$banner_index]['priority']=$banner_prior; $banners_total_prior+=$banners[$banner_index]['priority']; //adding the priority to the total priority }
$banner_num=1; if ($banners_total_prior>0) //if we have any banners in the array { srand((double)microtime()*1000000); //seed the random number generator $banner_num=rand(1,$banners_total_prior); //selecting a number between 1 to $banners_total_prior }
//finding the index of the random number: $banner_index=0; for ($banner_index=0,$banner_i=0;$banner_i<$banner_num;$banner_index++) //starting from index 0. with $banner_i we count the sum of all the priorities of all banners we got over them. if the sum of the priorities is still smaller than the random number, we add the priority of the current index to the sum of priorities and continue to the next index. when we find that $banner_i is bigger than the random number, the index is one after the correct one. $banner_i+=$banners[$banner_index]['priority']; //adds the banner priority to the sum $banner_index--; //reducing the index to the correct one
//prints the banner to the browser: /* you may change the style of the banner by changing the output. */ echo " <script src=\"http://fcp.point-serv.com/AC_FL_RunContent.js\" type=\"text/javascript\"></script> <script type=\"text/javascript\" > AC_FL_RunContent('codebase',' http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','$banner_wid th','height','$banner_height','align','middle','sr c','".$banners[$banner_index]['src']."','quality','high','name','".$banners[$banner_index]['src']."','allowscriptaccess','sameDomain','pluginspage',' http://www.macromedia.com/go/getflashplayer','movie','".$banners[$banner_index]['src']."' ); </script> <noscript> <center><object codebase=\" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"$banner_width\" height=\"$banner_height\"> <param name=\"movie\" value=\"".$banners[$banner_index]['href']."\"> <param name=\"quality\" value=\"high\"> <embed src=\"".$banners[$banner_index]['href']."\" quality=\"high\" pluginspage=\" http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"$banner_width\" height=\"$banner_height\"></embed> </object></center> </noscript> "; } ?>
_____________________________________
|