Version: 1.00, by Scott MacVicar
Developer Last Online: Mar 2016
Version: 2.2.x
Rating:
Released: 05-25-2002
Last Update: Never
Installs: 47
No support by the author.
This is a script to allow you to manage the adverts on your forums, you can have any sort of advert you can imagine there is no actual limit with this hack to what it can be, javascript, flash, image, text and images.
You add adverts to a category or a forum or the whole board. If the category has child forums they will inherit the adverts as well as their own adverts if they have any.
Adverts can have a set exposure such as 10,000 views and once it has reached that it will stop.
It fills a variable called $advert which you just place in any template, such as the header, you can also use variables and replacements within the adverts, such as $bbuserinfo[userid] for the persons userid in a link within an advert.
Updated June 9th at 19:44 GMT
Added date limits and options for unlimited exposures.
To upgrade from an older version, reapply code in global.php, upload ads.php and run this sql query to alter the ads table you made.
[sql]ALTER TABLE `ads` ADD `time` INT(10) DEFAULT '0' NOT NULL;[/sql]
[sql]ALTER TABLE `ads` ADD `wholeforum` SMALLINT(1) DEFAULT '0' NOT NULL;[/sql]
If you already run that query though are still experiencing problems with the time always being January 1st run
New features include showing the advert on the entire forum by using a radio button, some highlighting in the admin panel, italic name indicates the time period has ended and a bold name means the advert has met its quota for exposures.
You must chance RAND() to RAND(NOW()) if you have mysql 3.23.52 or above
Scott
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
To ad more than one ad to a forum, use this code in the "Code to be shown as advert" box. Works like a charm.
PHP Code:
<SCRIPT LANGUAGE="JavaScript">
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="Ad Name";
url="http://youradsite.com";
alt="Alt Message";
banner="http://www.yoursite/banner.jpg";
width="460";
height="80";
}
if (ad==2) {
txt="Ad Name";
url="http://youradsite.com";
alt="Alt Message";
banner="http://www.yoursite/banner.jpg";
width="468";
height="60";
}
if (ad==3) {
txt="Ad Name";
url="http://youradsite.com";
alt="Alt Message";
banner="http://www.yoursite/banner.jpg";
width="468";
height="60";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_new\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
</SCRIPT><br>
If you have more ads, just change the number variable in line 2., copy and paste a new section and rename the if statement to ad==4 and so on. This works like a charm for me, I've got in running different sets of banners on 60 some odd forums. This hack is a master stroke.
The only thing I'd like to do is get the subs to work independently of the parent forum, other than that this hack is the best!
I fixed the problem .. it is wierd .. I had to run the database query twice!! So instead of this portion of code in global.php
mysql Ver 11.18 Distrib 3.23.53, for sun-solaris2.9 (sparc)
PHP 4.3.1 (cli) (built: Mar 25 2003 16:03:01)
PHP Code:
if(isset($advert_forumid)) {
$foruminfo = getforuminfo($advert_forumid);
$advert=$DB_site->query_first("SELECT * FROM ads WHERE LOCATE(CONCAT(',',forumid,','),',$foruminfo[parentlist],')>0 AND time>=".time()." AND (exposed<=exposures OR exposures=0) ORDER BY RAND()");
} else {
$advert=$DB_site->query_first("SELECT * FROM ads WHERE wholeforum='1' AND time>=".time()." AND (exposed<=exposures OR exposures=0) ORDER BY RAND()");
}
I had to use
PHP Code:
if(isset($advert_forumid)) {
$foruminfo = getforuminfo($advert_forumid);
$advert=$DB_site->query_first("SELECT * FROM ads WHERE LOCATE(CONCAT(',',forumid,','),',$foruminfo[parentlist],')>0 AND time>=".time()." AND (exposed<=exposures OR exposures=0) ORDER BY RAND()");
$advert=$DB_site->query_first("SELECT * FROM ads WHERE LOCATE(CONCAT(',',forumid,','),',$foruminfo[parentlist],')>0 AND time>=".time()." AND (exposed<=exposures OR exposures=0) ORDER BY RAND()");
} else {
$advert=$DB_site->query_first("SELECT * FROM ads WHERE wholeforum='1' AND time>=".time()." AND (exposed<=exposures OR exposures=0) ORDER BY RAND()");
$advert=$DB_site->query_first("SELECT * FROM ads WHERE wholeforum='1' AND time>=".time()." AND (exposed<=exposures OR exposures=0) ORDER BY RAND()");
}
Also just a quick note .. it does not work very well with only 2 adverts. If you only have 2 adverts make 3 copies of each and the randomization will work alot better.
I have that as an ad in the "Code to be shown as advert" and now when I try to quote someone in a post I am unable to highlight using the left button on the mouse. Any ideas why.
There appears to be a problem with the following portion of code in global.php
PHP Code:
if (isset($postid)) {
// viewing post
$postid=verifyid('post',$postid,0);
if ($postid!=0) {
$advert_forumid=$postid['forumid'];
}
}
$advert_forumid appears to be incorrect. If post id is say 92355 and the post is in thread 23352 in forum 24. advert_forumid is set to 9 ... this is wrong and it should be 24.
I got around it for the time being by changing it to the following.
PHP Code:
if (isset($postid) and isset($threadid)) {
// viewing post
$thread=verifyid("thread",$threadid,0,1);
$advert_forumid=$thread['forumid'];
}
This works and the advert_forumid is set to 24 for the above example.
I don't think this fix is correct though, is there a scenaro where postid is set but threadid is not ?