Zend - The PHP Company




Miscellaneous

Add Code


Xenolth's Unique Ad Rotator  

Type: application
Added by: xenolth
Entered: 11/12/2003
Last modified: 02/11/2002
Rating: - (fewer than 3 votes)
Views: 4346
If your site uses a third-party adserver that pays you for unique impressions, your site may be displaying ads that you are not getting paid for. Xenolth's Unique Ad Rotator is a PHP script that will rotate your banner/pop-up ads to make sure that you get the maximum profit from your ads, and it will also make sure that your website only displays ads when you're getting paid for them.


<?php
/*************************************************************************
**************************************************************************
**************************** UNIQUE AD ROTATOR ***************************
**************************************************************************
*********** Copyright (c) 2003 by Xenolth Web Design Resources
*********** http://www.xenolth.biz
*********** 
*********** You must leave this copyright notice entact in order to use this script legally.
***********
*********** This script is open-source. If you add any features to it, you must email the edited version to:
*********** scripts@xenolth.biz
***********
*********** If you like using unique Ad Rotator, please pu a link back to http://www.xenolth.biz on your website.
***********
*********** Enjoy using Unique Ad Rotator!
**************************************************************************/

/********** ########## PART 1: POP-UP/POP UNDER CODE ########## **********/

/********** Fill the following variables with your code for POP-UPS or POP-UNDERS.
*********** This is the code that your adservers provided you with.
*********** Create extra variables if you need them. Delete any variables you do not use. But leave at least one variable even if you don't use it.
***********/

$uniquepop[0] = "<SCRIPT LANGUAGE="JavaScript" src="http://www.popuptraffic.com/assign.php?l=cwp61"></script>";
$uniquepop[1] = "<SCRIPT LANGUAGE="JavaScript" src="http://www.popuptraffic.com/assign.php?l=cwp61&mode=behind"> </script>";
$uniquepop[2] = "";
$uniquepop[3] = "";
$uniquepop[4] = "";
$uniquepop[5] = "";

/********** Fill the following variable with the GREATEST array item used.
*********** For example, if you used $uniquebanner[0], $uniquebanner[1], and $uniquebanner[2], enter "2"
***********/
$popnums "1";

/********** Fill the following variables with the number of HOURS that your ads must be unique for.
*********** e.g., You are paid for impressions on a xxx hour unique basis.
*********** NOTE: $poptime[1] must hold the value of the unique basis time for the code you placed under $uniquepop[1], etc.
***********/

$poptime[0] = "12";
$poptime[1] = "12";
$poptime[2] = "";
$poptime[3] = "";
$poptime[4] = "";
$poptime[5] = "";


/********** Replace the following ad code with the code for your DEFAULT POP-UP or POP-UNDER code.
*********** That is, code for pop-ups for wich the adserver has no limit for unique impressions.
*********** If you do not have a default pop-up code, leave this variable blank.
**********/

$defaultpop "<script language="JavaScript">
<!--
   var now = new Date();
   var uaid = now.getTime() % Math.floor(8640000 - Math.random()*1000);
   document.write('<scr'+'ipt src="
http://focusin.ads.targetnet.com//ad/id=cwp61&opt=hpj&cv=210&uid=' + uaid + '"></scr'+'ipt>');
//-->
</script>";


/********** ########## PART 2: POP-UP/POP UNDER ON-EXIT CODE ########## **********/

/********** Fill the following variables with your code for ON-EXIT POP-UPS or POP-UNDERS.
*********** Create extra variables if you need them. Delete any variables you do not use. But leave at least one variable even if you don't use it.
***********/

$uniqueexit[0] = "<SCRIPT LANGUAGE="JavaScript" src="http://www.popuptraffic.com/assign.php?l=cwp61&mode=exit"> </script>";
$uniqueexit[1] = "";
$uniqueexit[2] = "";
$uniqueexit[3] = "";
$uniqueexit[4] = "";
$uniqueexit[5] = "";

/********** Fill the following variable with the GREATEST array item used.***********/
$exitnums = 0;

/********** Fill the following variables with the number of HOURS that your ads must be unique for.***********/
$exittime[0] = "12";
$exittime[1] = "";
$exittime[2] = "";
$exittime[3] = "";
$exittime[4] = "";
$exittime[5] = "";

/********** If your adserver told you to place something like this in your <body> tag:
*********** onUnload="xxxx" 
*********** Fill the Following Variables with the "xxxx". Leave blank any variables you don't use. DON'T DELETE THEM.
*********** If you added extra variables to the "uniqueexit" array, add the same amount of variables to the below array, even if you'll just leave them blank.
***********/

$unload[0] = "ptExit();";
$unload[1] = "";
$unload[2] = "";
$unload[3] = "";
$unload[4] = "";
$unload[5] = "";

/********** Replace the following ad code with the code for your DEFAULT ON-EXIT code.
*********** If you do not have a default on-exit code, leave this variable blank.
**********/

$defaultexit = "";


/********** ########## PART 3: BANNER CODE ########## **********/

/********** Fill the following variables with your code for BANNER ADS.
*********** Create extra variables if you need them. Delete any variables you do not use. But leave at least one variable even if you don't use it.
***********/

$uniquebanner[0] = "<center>
<script language="JavaScript">
<!--
   var now = new Date();
   var uaid = now.getTime() % Math.floor(8640000 - Math.random()*1000);
   document.write('<iframe src="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=hhj&rw=468&rh=60&cv=210&uid=' + uaid + '" width=468 height=60 frameborder=0 marginheight=0 marginwidth=0 scrolling="no">');
   document.write('<a href="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=cij&rw=468&rh=60&cv=210&uid=' + uaid + '" target="_top">');
   document.write('    <img src="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=hij&rw=468&rh=60&cv=210&uid=' + uaid + '" alt="Click here to visit our sponsor" width=468 height=60 border=0>');
   document.write('</a><br><font face="arial" size="1"><a href="http://www.focusin.com/">focusIN Ad Network</a></font></iframe>');
//-->
</script>
<noscript>
   <iframe src="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=hhn&rw=468&rh=60&cv=210&uid=1" width=468 height=60 frameborder=0 marginheight=0 marginwidth=0 scrolling="no">
   <a href="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=cin&rw=468&rh=60&cv=210&uid=1" target="_top"><br>
   <img src="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=hin&rw=468&rh=60&cv=210&uid=1" alt="Click here to visit our sponsor" width=468 height=60 border=0>
   </a><br><font face="arial" size="1"><a href="http://www.focusin.com/">focusIN Ad Network</a></font></iframe>
</noscript>
</center>
";
$uniquebanner[1] = "";
$uniquebanner[2] = "";
$uniquebanner[3] = "";
$uniquebanner[4] = "";
$uniquebanner[5] = "";

/********** Fill the following variable with the GREATEST array item used. ***********/

$bannernums = 0;

/********** Fill the following variables with the number of HOURS that your ads must be unique for. ***********/

$bannertime[0] = "0";
$bannertime[1] = "";
$bannertime[2] = "";
$bannertime[3] = "";
$bannertime[4] = "";
$bannertime[5] = "";


/********** Replace the following ad code with the code for your DEFAULT BANNER code.
*********** If you do not have a default banner code, leave this variable blank.
**********/

$defaultbanner = "<center>
<script language="JavaScript">
<!--
   var now = new Date();
   var uaid = now.getTime() % Math.floor(8640000 - Math.random()*1000);
   document.write('<iframe src="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=hhj&rw=468&rh=60&cv=210&uid=' + uaid + '" width=468 height=60 frameborder=0 marginheight=0 marginwidth=0 scrolling="no">');
   document.write('<a href="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=cij&rw=468&rh=60&cv=210&uid=' + uaid + '" target="_top">');
   document.write('    <img src="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=hij&rw=468&rh=60&cv=210&uid=' + uaid + '" alt="Click here to visit our sponsor" width=468 height=60 border=0>');
   document.write('</a><br><font face="arial" size="1"><a href="http://www.focusin.com/">focusIN Ad Network</a></font></iframe>');
//-->
</script>
<noscript>
   <iframe src="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=hhn&rw=468&rh=60&cv=210&uid=1" width=468 height=60 frameborder=0 marginheight=0 marginwidth=0 scrolling="no">
   <a href="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=cin&rw=468&rh=60&cv=210&uid=1" target="_top"><br>
   <img src="http://focusin.ads.targetnet.com//ad/id=cwp61&opt=hin&rw=468&rh=60&cv=210&uid=1" alt="Click here to visit our sponsor" width=468 height=60 border=0>
   </a><br><font face="arial" size="1"><a href="http://www.focusin.com/">focusIN Ad Network</a></font></iframe>
</noscript>
</center>
";

/*****************#################### Don't modify anything beyond this point ####################*****************/
/********************#################### Unless you know what you're doing ####################********************/
/* Remeber: If you add any new features to this script, you must email the edited version to: scripts@xenolth.biz */

$i = 0;

while ($i<=$popnums) {
    $popexpr = time()+($poptime[$i]*60*60);

    $ip=$_SERVER["REMOTE_ADDR"];
    $filename = "popup".$i."-".$ip.".txt";

    if(file_exists($filename)) {
        $ipfile = fopen($filename, "r");
        $ifexpr = fread($ipfile, filesize($filename));
        fclose($ipfile);

        if(time()>$ifexpr) {
            echo($uniquepop[$i]);

            $ipfile = fopen($filename, "w");
            fwrite($ipfile, $popexpr);
            fclose($ipfile);

            $break="true";
            break;
        }

    } else {
        echo($uniquepop[$i]);

        $ipfile = fopen($filename, "w");
        fwrite($ipfile, $popexpr);
        fclose($ipfile);

        $break="true";
        break;
    }
    $i++;
}

if($break!="true") {
    echo($defaultpop);
}

$i = 0;

while ($i<=$exitnums) {
    $exitexpr = time()+($exittime[$i]*60*60);

    $ip=$_SERVER["REMOTE_ADDR"];
    $filename = "exit".$i."-".$ip.".txt";

    if(file_exists($filename)) {
        $ipfile = fopen($filename, "r");
        $ifexpr = fread($ipfile, filesize($filename));
        fclose($ipfile);

        if(time()>$ifexpr) {
            echo($uniqueexit[$i]);
?>
            <script language="javascript">
            function exitcode() {
                <?php echo($unload[$i]); ?>
            }
            </script>
<?php
            $ipfile 
fopen($filename"w");
            
fwrite($ipfile$exitexpr);
            
fclose($ipfile);

            
$break="true";
            break;
        }

    } else {
        echo(
$uniqueexit[$i]);

?>
        <script language="javascript">
        function exitcode() {
            <?php echo($unload[$i]);?>
        }
        </script>
<?php
        $ipfile 
fopen($filename"w");
        
fwrite($ipfile$exitexpr);
        
fclose($ipfile); 

        
$break="true";
        break;
    }
    
$i++;
}

if(
$break!="true") {
    echo(
$defaultexit);
}

$i 0;

while (
$i<=$bannernums) {
    
$bannerexpr time()+($bannertime[$i]*60*60);
    
$cookiename $bannername[$i];

    
$ip=$_SERVER["REMOTE_ADDR"];
    
$filename "banner".$i."-".$ip.".txt";

    if(
file_exists($filename)) {
        
$ipfile fopen($filename"r");
        
$ifexpr fread($ipfilefilesize($filename));
        
fclose($ipfile);

        if(
time()>$ifexpr) {
            echo(
$uniquebanner[$i]);

            
$ipfile fopen($filename"w");
            
fwrite($ipfile$bannerexpr);
            
fclose($ipfile);

            
$break="true";
            break;
        }

    } else {
        echo(
$uniquebanner[$i]);

        
$ipfile fopen($filename"w");
        
fwrite($ipfile$bannerexpr);
        
fclose($ipfile);

        
$break="true";
        break;
    }
    
$i++;
}

if(
$break!="true") {
    echo(
$defaultbanner);
}
?>

<body onunload="exitcode()">
</body>


Usage Example


See the example


Rate This Script





Search



This Category All Categories