There’s lots of well meaning advice out there on how to add an Adbrite Zone to the footer of proxified pages but I’ve spent a whole evening getting it to work on a phpproxy 0.5 based proxy server.
The often repeated advice out there is flawed and/or out of date - but we do have a solution for you. Let’s step back a bit first.
We’re running an Adbrite Zone on our YouTube Proxy as an alternative to Adsense and have been doing so for a week. With it being the Christmas period and traffic being so low, but I’m busy at work and this was the only chance I’ve had to give it a try. So far the clickthru’s are better but the payout is awful - less than Adsense even!!
Anyway, one advantage of Adbrite is that you can place the ads on proxified pages without breaking their terms of service.
Great, so I set up a Zone with a 780×90 zone and tried pasting the code as recommended previously in Web Proxy forums and on other sites. All I got on index.php was a blank page.
The advice given was;
If you wann put ads at the bottom of your proxy pages use this code:
Code:
$pattern = "#</body>#i";
preg_match($pattern,$_response_body, $matches);
$_response_body = preg_replace($pattern, '
<center>
<!-- BEGIN STANDARD TAG - 728 x 90 - ROS: Run-of-site - DO NOT MODIFY -->
<!-- END TAG -->
</center></body>', $_response_body); //the replace functionthis code goes in your index.php file (phproxy) & after this line $_response_keys['content-length'] = ‘Content-Length’;
When I tried this with my Adsense code inserted I got a blank page.
Firstly, the advice didn’t mention that there were two instances $_response_keys['content-length'] = ‘Content-Length’; code - you have to paste the code after the second instance of the code in your index.php file.
The second problem is that Adbrite are no longer using plain text for their Ads, but are using more complex code that features quotes eg ‘
That causes a problem in php code because single quotes or apostrophes are programming variables, or reserved characters if you like, so that they need to be escaped with a slash or \
In other words if you want to add the HTML code;
var AdBrite_Title_Color = ‘0000FF’;
you have to insert it in php as;
var AdBrite_Title_Color = \’0000FF\’;
Simply, escape all quotes and the code (see below) will work! We’ll report back on earnings in a month or so.
Working code to insert Adbrite banner ads on the footer or proxified pages (phpproxy 0.5);
// Mod starts
$pattern = “#</body>#i”;
preg_match($pattern,$_response_body, $matches);
$_response_body = preg_replace($pattern, ‘<center><!– BEGIN STANDARD TAG - 728 x 90 - ROS: Run-of-site - DO NOT MODIFY –>
<!– Begin: AdBrite, Generated: 2008-12-29 15:01:14 –>
<script type=”text/javascript”>
var AdBrite_Title_Color = \’0000FF\’;
var AdBrite_Text_Color = \’000000\’;
var AdBrite_Background_Color = \’FFFFFF\’;
var AdBrite_Border_Color = \’CCCCCC\’;
var AdBrite_URL_Color = \’008000\’;
try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==\’\'?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);}catch(e){var AdBrite_Iframe=\’\';var AdBrite_Referrer=\’\';}
</script>
<span style=”white-space:nowrap;”><script type=”text/javascript”>document.write(String.fromCharCode(60,83,67,82,73,80,84));document.write(\’ src=”http://ads.adbrite.com/mb/text_group.php?sid=979382&zs=3732385f3930&ifr=\’+AdBrite_Iframe+\’&ref=\’+AdBrite_Referrer+\’” type=”text/javascript”>\’);document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));</script>
<a target=”_top” href=”http://www.adbrite.com/mb/commerce/purchase_form.php?opid=979382&afsid=1″><img src=”http://files.adbrite.com/mb/images/adbrite-your-ad-here-leaderboard.gif” style=”background-color:#CCCCCC;border:none;padding:0;margin:0;” alt=”Your Ad Here” width=”14″ height=”90″ border=”0″ /></a></span>
<!– End: AdBrite –>
</center></body>’, $_response_body);
// the replace function
//mod ends
