PDA

View Full Version : Mod for banner impression script


tigerincanada
6th July 2006, 05:54 AM
This is a mod for /scripts/sb.php to ensure that a banner impression always returns a real image if the affiliate or banner isn't found, and when tracking impressions for text ads.


...

// Use an output buffer to detect whether or not we have found an image
ob_start();

$bannerViewer = QUnit_Global::newObj('Affiliate_Scripts_Bl_BannerV iewer');

$bannerViewer->setExtraData($data1);

// check if this affiliate and banner exist
// IMPORTANT! we have to check for affiliate first
if(!$bannerViewer->checkUserExists($affiliateID))
{
$errorMsg = "Show banner: Affiliate with ID '$affiliateID' doesn't exist";
LogError($errorMsg, __FILE__, __LINE__);
}
elseif(!$bannerViewer->checkBannerExists($bannerID))
{
$errorMsg = "Show banner: Banner with ID '$bannerID' doesn't exist";
LogError($errorMsg, __FILE__, __LINE__);
}
else
{
// redirect to destination page
$bannerViewer->redirect();
}

// If there isn't an image in the buffer yet, send the blank GIF
if(ob_get_length() < 1) {
header("content-type: image/gif");
@readfile("blank.gif");
}

tigerincanada
6th July 2006, 08:33 PM
I should add that this is for 2.0.6 ... time to start playing with version 3

anuska
7th July 2006, 03:10 PM
Hi,

tracking impressions in new version has changed very slightly, so this code should work in new version too.

Regards,
Anuska