/*
using
echo $display;
*/
$date = date("d");$myFile = "record.dat";$fh = fopen($myFile, 'r');$theData = fread($fh, 5);fclose($fh);
if($theData==$date){$myFile = "imgrecord.dat";$fh = fopen($myFile, 'r');$theData = fgets($fh);fclose($fh);//display image$display = '.$theData.'" alt="*" border=0 width="281"/>';
}else{$imglist='';//$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/
// see that you don't forget about the "/" at the end$img_folder = "imgrandom/";mt_srand((double)microtime()*1000);//use the directory class$imgs = dir($img_folder);//read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)while ($file = $imgs->read()) {
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))$imglist .= "$file ";
} closedir($imgs->handle);//put all images into an array$imglist = explode(" ", $imglist);$no = sizeof($imglist)-2;//generate a random number between 0 and the number of images$random = mt_rand(0, $no);$image = $imglist[$random];$myFile = "record.dat";$fh = fopen($myFile, 'w') or die("can't open file");$stringData = $date;fwrite($fh, $stringData);fclose($fh);$myFile = "imgrecord.dat";$fh = fopen($myFile, 'w') or die("can't open file");$stringData = $img_folder.$image;fwrite($fh, $stringData);fclose($fh);
}
dont forget to create this file
record.dat [CHMOD 777]
imgrecord.dat [CHMOD 777]
imgrandom [FOLDER]
No comments:
Post a Comment