<?php
class PHPAdsModule{
// Global variable Declarations
var $ads; // Array variable to Store The Ads
var $bannerID; // Array variable to Store the Ad ID
var $MaxTry;
var $URL;
var $campaignID;
var $target;
var $MaxAds;
function PHPAdsModule($DocumentURL,$CampaignID,$target,$MaxAds){
//Assign the values to the Global variables
$this->URL=$DocumentURL;
$this->MaxTry= $MaxAds * 3;
$this->target=$target;
$this->campaignID=$CampaignID;
$this->ads = array();
$this->MaxAds = $MaxAds;
$this->bannerID = array();
}
function GetBanner(){
// Purpose : Get the Banner from the table and store it in An Array
$NewAdsArray = array();
if (@include(getenv('DOCUMENT_ROOT').$this->URL)) {
if (!isset($phpAds_context)) $phpAds_context = array();
for($i=0;$i<$this->MaxTry;$i++){
$phpAds_raw = view_raw ('', $this->campaignID, "'".$this->target."'", '', '0', $phpAds_context);
array_push($NewAdsArray,$phpAds_raw);
array_push($this->bannerID,$phpAds_raw['bannerid']);
}
}
$tmpArray=array_unique($this->bannerID);
$arraykeys=array_keys($tmpArray);
for($i=0;$i<=count($arraykeys);$i++){
$key=$arraykeys[$i];
array_push($this->ads,$NewAdsArray[$key]);
}
}
function DisplayAds($Style){
// Purpose : Display the Ads
for($i=0;$i<$this->MaxAds;$i++){
echo $Style.$this->ads[$i]['html'].$Style;
}
}
} // Class Ends Here
?>