Random Banner Display and Impression Tracker

Andrew

New Member
I built this so we can show customer banners randomly in unfilled ad space. It calls the random_banner.php via iframe which we embedded into the ad_break.html

We added a integer column to the sites table called bannerimpressions to track the total number of impressions a free banner gets. We also only pull banners for active records.

Code:
<?php
 
// Help prevent register_globals injection
define('VISIOLIST', 1);
$CONF = array();
$FORM = array();
$TMPL = array();
 
 
// Change the path to your full path if necessary
$CONF['path'] = '.';
 
 
 
// Connect to the database
require_once("{$CONF['path']}/settings_sql.php");
require_once("{$CONF['path']}/sources/sql/{$CONF['sql']}.php");
$DB = "sql_{$CONF['sql']}";
$DB = new $DB;
$DB->connect($CONF['sql_host'], $CONF['sql_username'], $CONF['sql_password'], $CONF['sql_database']);
 
// Settings
$settings = $DB->fetch("SELECT * FROM {$CONF['sql_prefix']}_settings", __FILE__, __LINE__);
$CONF = array_merge($CONF, $settings);
 
 
 
//Pull Banner and User info
list($banner_url,$url,$username) = $DB->fetch("SELECT banner_url, url, username FROM {$CONF['sql_prefix']}_sites WHERE active = 1 AND (banner_url IS NOT NULL AND banner_url NOT LIKE '') ORDER BY RAND() LIMIT 1", __FILE__, __LINE__);
 
//Update BannerImpression column
$DB->query("UPDATE {$CONF['sql_prefix']}_sites SET bannerimpressions = bannerimpressions + 1 WHERE username = '{$username}'", __FILE__, __LINE__);
 
 
$DB->close();
 
echo '<a href="'.$url.'" target="_blank"><img src="'.$banner_url.'" border="0"></a>';
?>
Please find the php code file attached.

Here is the iFrame code

Code:
<iframe style="width: 470px; height: 62px; border: none;" 
src="YOURURLHERE/randombanner.php" 
frameborder="0" scrolling="no" width="470" height="62"></iframe>
 

Attachments

Basti

Administrator
Staff member
Why not use the integrated ad manager? ;)
It has impression tracking, limit impressions, enable, disable
To be found at admin -> tools menu dropdown -> manage banners

Features 4 zones, which are already in the template
{$zone_a} - header
{$zone_b} - sidebar
{$zone_c} - under content
{$zone_d} - stats

you can move the template tags around however you want, also into the ad_breaks

EDIT:: Oh, this about all your members to rotate
 

Andrew

New Member
Yeah, it is just value add for being apart of the site to have free banner impressions for active members. You can also tweak the sql to display premium members only.
 

cajkan

Active Member
Yes that is avalible too
Upload premium banners
i think zone D was for it but im not sure since i use custom
 

Mark

Administrator
Staff member
nice job, a good way to spread around some out clicks to other members :) now lets convert this to a plugin for kicks. I'll be back in a few hours after I get some work done
 

somayehbayat

New Member
hi
in my site get this error
Fatal error: Database error in "/home/peyvan/domains/peyvandham.ir/public_html/random_banner.php" on line 48please help me
thank you
 

Basti

Administrator
Staff member
On a first guess you didnt do this.
We added a integer column to the sites table called bannerimpressions to track the total number of impressions a free banner gets. We also only pull banners for active records.
 

somayehbayat

New Member
hi
in my site get this error
Fatal error: Database error in "/home/peyvan/domains/peyvandham.ir/public_html/random_banner.php" on line 48please help me
thank you
 

Basti

Administrator
Staff member
It is explained in his post. Create a new database field in the sites table from within phpmyadmin
 
Top