class dsad {
function Dsad($from) {
//return;
global $dsadFrom;
$dsadFrom = $from;
include("php/config.php");
switch($from) {
case 'cuip':
$switch = true;
break;
default:
include("../cuip/php/cuipDB.php");
global $cuipDB;
$cuipDB = new cuipDB(MySQLServer, MySQLUser, MySQLPass, MySQLDB);
break;
}
include("php/adresults.php");
global $DSADresults;
$DSADresults = new DSADResults();
if($switch) {
$DSADresults->changeRealDatabase(adSQLDB);
}
}
function showAd($from, $width, $height) {
//return;
global $DSADresults;
switch($from) {
case 'images':
$fromDB = false;
//$fromDB = ImageDB;
break;
case 'downloads':
$fromDB = 'phoib_download';
break;
default:
/*Forums, or sites who use that DB*/
$fromDB = MySQLDB;
break;
}
$ads = $DSADresults->loadRunningAds();
while(count($ads) >0) {
$chosenAd = rand(0, (count($ads)-1));
$views = $DSADresults->checkViewsToday($ads[$chosenAd]['id']);
if($views['cnt']<=$ads[$chosenAd]['max_views_day']) {
$DSADresults->insertView($ads[$chosenAd]['id'], $from);
$DSADresults->changeRealDatabase($fromDB);
//$DSADresults->endResultsObject(MySQLServer, MySQLUser, MySQLPass, $fromDB);
return $this->printAd($ads[$chosenAd], $height, $width);
} else{
unset($ads[$chosenAd]);
sort($ads);
}
}
//$DSADresults->endResultsObject(MySQLServer, MySQLUser, MySQLPass, $fromDB);
if($fromDB) {
$DSADresults->changeRealDatabase($fromDB);
}
return $this->printGoogleAd($from, $width, $height);
}
function printAd($ad, $height, $width) {
$imageName = sprintf("%s%dx%d.%s", $ad['imageBaseName'], $width, $height, $ad['imageType']);
return sprintf("
",
SITE, CLICKPAGE, $ad['id'], SITE, IMAGEDIR, $imageName);
}
function printGoogleAd($where, $width, $height) {
switch($where) {
case 'forums':
case 'site' :
case 'downloads':
//case 'images':
if($width==768 && $height == 90) {
//LeaderBord
return "
";
} else if($width==120&&$height==600) {
//Skyscraper
return "
";
} else{
return "
";
}
break;
case 'oldblitzsite':
return "
";
break;
case 'images':
if($width==120&&$height==600) {
//Skyscraper
return "
";
}
break;
}
}
function testDsad() {
return '
Hello. This shows DSAD is working.
';
}
}
?>