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.
 
	
	
	
		
Please find the php code file attached.
 
Here is the iFrame code
 
	
	
	
		
								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>';
?>
	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
- 
		
			
		
		
		2.5 KB Views: 4
 
				
 now lets convert this to a plugin for kicks.  I'll be back in a few hours after I get some work done