Loading ...

show_ads function rewrite

Board index / General Chat / Other Products / Ultimate Regnow Affiliate (Deprecated)

Run your own software site...automatically!

Postby Bilderback on Dec 22, 2010 5 am


Id like to have more control over my advertising when it comes to specific sizes.
The default script is set to a maximum size of 300x250.
At first, I simply rewrote the [b]show_ads()[/b] function to allow for ID input as shown below.

The current function for show_ads() is listed below:
[code]
function show_ads(){
if( _ADS ) {
$ret = "";
$sql = "SELECT * FROM ura_ads ORDER BY RAND() LIMIT 1";
$result = @mysql_query($sql);
$row = @mysql_fetch_assoc($result);
$ret = stripslashes(decodeHTML($row['html']));
@mysql_free_result($result);
return $ret;
}
return false;
}
[/code]

I rewrote the function slightly, as follows.
[code]
function show_ads($ad = 0){
if( _ADS ) {
$ret = "";
if( $ad != 0 && is_numeric($ad) ) {
$sql = "SELECT * FROM ura_ads WHERE id= ".$ad." LIMIT 1";
}else{
$sql = "SELECT * FROM ura_ads ORDER BY RAND() LIMIT 1";
}
$result = @mysql_query($sql);
$row = @mysql_fetch_assoc($result);
$ret = stripslashes(decodeHTML($row['html']));
@mysql_free_result($result);
return $ret;
}
return false;
}
[/code]

What happens now is that if I input a specific ID, such as ID 3 for an ad, I use [b]show_ads(3)[/b]
but found when using show_ads() as a RANDOM, my special sizes are also grabbed.
This would require me to use an ID in each show_ads() instance, therefore killing ad rotation.

In order to keep ad rotation [u]and[/u] use more sizes other than default, I thought of adding
a size field to the ads table within the database and rewriting the function to grab sizes rather than IDs.
What I need to figure out now is how to utilize that field.
Should it allow admin input as text?
ie., ura_ads.size = '468x60'
Or should it be specific checkboxes of predefined sizes for selection?
Once we get the extra database field, we can call it similar to the following:
function: [b]function show_ads($size = 0) {}[/b]
query: [b]SELECT * FROM ura_ads WHERE size = ".$size." ORDER BY RAND() LIMIT 1[/b]
use: [b]show_ads(468x60)[/b]

This is such an easy task but Im making it difficult due to lack of sleep. :)
So I thought I would ask the forum for any input on the matter in hopes to get a better from of ads written.
User avatar
Bilderback
Verified Customer
Verified Customer
 
Posts: 133
Joined: Dec 03, 2010 12 am
Reputation points: 100

Who is online

Users browsing this forum: No registered users and 0 guests

cron