Forum Moderators: open

Message Too Old, No Replies

Flash Banner Ads

banner ad rotator using flash files

         

murrayboy

8:44 am on Apr 21, 2004 (gmt 0)

10+ Year Member



Anyone got any experience of using some form of ad rotator when using multiple flash banner ads?

I'm looking to use something similar to the MSWC.adrotator component in an ASP site where I can weight the ads and track click-thrus...

OSUsammy13

11:14 am on Apr 22, 2004 (gmt 0)

10+ Year Member


This code will rotate jpg and gif images with PHP, i am guessing that it can be easily modified to rotate the name of the swf file in the code.

It is easiest to place this in the same folder as the files you want to rotate randomly.
Call it as if it was an image. (here assume you name the php file rotate.php)
<img src="rotate/rotate.php">
<?php
$folder = "/full path here/";

$fileList = array();
$handle = opendir($folder);
while (false!== ($file = readdir($handle) ) ) {
if ( substr($file, -4) == ".gif" ¦¦ substr($file, -4) == ".jpg" ) {
$fileList[count($fileList)] = $file;
}
}
closedir($handle);
$randNum = rand( 0, (sizeOf($fileList) -1) );
if ( substr($fileList[$randNum], -4) == ".gif" ) {
header ("Content-type: image/gif");
} elseif ( substr($fileList[$randNum], -4) == ".jpg" ) {
header ("Content-type: image/jpeg");
}
readfile($fileList[$randNum]);
?>