show_ads function rewrite
Board index / General Chat / Other Products / Ultimate Regnow Affiliate (Deprecated)
1 post • Page 1 of 1
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 show_ads() function to allow for ID input as shown below.
The current function for show_ads() is listed below:
I rewrote the function slightly, as follows.
What happens now is that if I input a specific ID, such as ID 3 for an ad, I use show_ads(3)
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 and 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: function show_ads($size = 0) {}
query: SELECT * FROM ura_ads WHERE size = ".$size." ORDER BY RAND() LIMIT 1
use: show_ads(468x60)
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.
The default script is set to a maximum size of 300x250.
At first, I simply rewrote the show_ads() function to allow for ID input as shown below.
The current function for show_ads() is listed below:
- Code: Select all
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;
}
I rewrote the function slightly, as follows.
- Code: Select all
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;
}
What happens now is that if I input a specific ID, such as ID 3 for an ad, I use show_ads(3)
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 and 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: function show_ads($size = 0) {}
query: SELECT * FROM ura_ads WHERE size = ".$size." ORDER BY RAND() LIMIT 1
use: show_ads(468x60)
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.
-
Bilderback - Verified Customer
- Posts: 133
- Joined: Dec 03, 2010 12 am
- Reputation points: 100
1 post • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests