PDA

View Full Version : Mist's Random Banner Hack


Dean C
12 Jan 2003, 16:42
Mist's Random Banner Hack

What does this hack do?

This allows you to have a random banner in your header.

Latest Version: 1.0

+++++++++++++++++++++++++++++++++++++++++++
If you install this hack then please click the INSTALL (http://www.vbulletin.org/forum/misc.php?s=&action=install&threadid=45344) button.
+++++++++++++++++++++++++++++++++++++++++++

Regards

- miSt

N9ne
12 Jan 2003, 16:45
Where's the file? :p

Dean C
12 Jan 2003, 16:48
Hehe this happens everytime i post a hack.

I don't attach the file straight away because i like to add the thread link and install link to the attachment :p

It's in there now :)

- miSt

kikosho
12 Jan 2003, 16:58
screen shot?

Dean C
12 Jan 2003, 17:06
Why do you need to a see a screenshot ^ :)

All this does is generate a random banner :)

- miSt

Chris M
12 Jan 2003, 17:48
Still...

A screenshot would be good;):)

Satan

Dean C
12 Jan 2003, 18:24
I don't see why - all it would be is the the images changing :p

- miSt

N9ne
12 Jan 2003, 21:10
Just post a screenshot will ya! So we know where it goes and how it looks etc...

Link14716
13 Jan 2003, 01:49
/me runs to help out Mist.

Hard to make a screenshot, when it'd just show images of your choosing, and a screenshot won't change everytime you click it, so :p.

;)

I might install this one :)

mx3
13 Jan 2003, 03:21
how about demo, instead of screenshot?

Dean C
13 Jan 2003, 16:22
Hmmm well if someone installs this can they link me and i'll put it in their post (obviously with their permission :p)

- miSt

DrkFusion
13 Jan 2003, 20:06
I would install this, but the fact that it is manually edited (to change banners and stuff) that is the con in my view of this hack, the rest looks good.

Floris
14 Jan 2003, 19:38
PPN made an advert manager .. isn't this the same?

setsykid
15 Jan 2003, 04:17
Hello, I'd like to ask where I can put the url for the banners?
I know I can put more banners creating my own variable, they are just images but the url for them?

thx

NanoEntity
15 Jan 2003, 07:59
nice one Mist!

Mist! I would just forget about global.php, why not just insert this code to the phpinclude, it will be easy to mod if you need to add a new banner.

Also why list them as
$banner[1]="banner1.gif";
$banner[2]="newthread.gif";

Why not make an Array.
$banners=array('banner1', 'banner2');

Here is a simple way to do it, only takes 3 lines

//©hololith.com(NanoEntity)
$banners=array('banner1', 'banner2'); //images names
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle images
$adbanner="<img src=\"http://www.vbulletin.org/forum/greentek/adbanners/$shuffle.gif\" border=\"0\" alt=\"\">\n"; //images output
//END ©hololith.com(NanoEntity)


Was that easy :)

DEMO:
http://artwork.hololith.com/sigs.php - random
http://artwork.hololith.com/sigs.php?show=draco v1 - static
http://artwork.hololith.com/sigs.php?show=magal v1 - static
http://artwork.hololith.com/sigs.php?show=kinght v1 - static

This generates random signature, same way it would a banner ad, but its more advanced when it comes to code, about 13 lines.

--------------------------
EDIT - Addon

I am geting PMs from people that want diffrent urls to diffrent banners, here is the code

This was tested and it works.

//©hololith.com(NanoEntity)
$banner1="<a href=\"http://url1\"><img src=\"{ imagesfolder }/adbanners/banner1.gif\" border=\"0\" alt=\"\"></a>";
$banner2="<a href=\"http://url2\"><img src=\"{ imagesfolder }/adbanners/banner2.gif\" border=\"0\" alt=\"\"></a>";

$banners=array($banner1,$banner2); //banner array
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle banners
$adbanner="$shuffle\n"; //banners output
//END ©hololith.com(NanoEntity)


Enjoy.

NanoEntity
15 Jan 2003, 08:14
Your joking?

Just put this in <a href=\"http://url\"><img src=...........></a>

And theres your code...

Originally posted by setsykid
Hello, I'd like to ask where I can put the url for the banners?
I know I can put more banners creating my own variable, they are just images but the url for them?

thx

Dean C
15 Jan 2003, 16:38
Originally posted by xiphoid
PPN made an advert manager .. isn't this the same?

I must say i have lots of plans for this with admin cp intigration soon but again i chose to be a manual edit hack because i'm not confident enough with using mysql to store the banners - i haven't even got to the mysql part in my php book so bare with me for a while hehe :)

Also PPN's hack doesn't currently work :p

- miSt

Dean C
15 Jan 2003, 16:39
Originally posted by NanoEntity
nice one Mist!

Mist! I would just forget about global.php, why not just insert this code to the phpinclude, it will be easy to mod if you need to add a new banner.

Also why list them as
$banner[1]="banner1.gif";
$banner[2]="newthread.gif";

Why not make an Array.
$banners=array('banner1', 'banner2');

Here is a simple way to do it, only takes 3 lines

$banners=array('banner1', 'banner2'); //images names
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle images
$adbanner="<img src=\"http://www.vbulletin.org/forum/greentek/adbanners/$shuffle.gif\" border=\"0\" alt=\"\">\n"; //images output


Was that easy :)

DEMO:
http://artwork.hololith.com/sigs.php - random
http://artwork.hololith.com/sigs.php?show=draco v1 - static
http://artwork.hololith.com/sigs.php?show=magal v1 - static
http://artwork.hololith.com/sigs.php?show=kinght v1 - static

This generates random signature, same way it would a banner ad, but its more advanced when it comes to code, about 13 lines.

The reason i decided to have the variables as an array is to make it easier for newbies to add more banners :) - simple as that !

- miSt

Mike Gaidin
18 Jan 2003, 09:07
Will this only work in the header?

Dean C
18 Jan 2003, 09:26
No you can put the $banner variable in any template you wish :)

- miSt

Mike Gaidin
19 Jan 2003, 00:24
Excellent! Will install!

Dean C
19 Jan 2003, 10:50
Thankyou :)

- miSt

NanoEntity
20 Jan 2003, 12:19
I am geting PMs from people that want diffrent urls to diffrent banners, here is the code

This was tested and it works.
//©hololith.com(NanoEntity)
$banner1="<a href=\"http://url1\"><img src=\"{ imagesfolder }/adbanners/banner1.gif\" border=\"0\" alt=\"\"></a>";
$banner2="<a href=\"http://url2\"><img src=\"{ imagesfolder }/adbanners/banner2.gif\" border=\"0\" alt=\"\"></a>";

$banners=array($banner1,$banner2); //banner array
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle banners
$adbanner="$shuffle\n"; //banners output
//END ©hololith.com(NanoEntity)

Enjoy.

Dean C
20 Jan 2003, 16:44
Instructions on how to add more more banners is outlined in my instructions...

- miSt

Floris
20 Jan 2003, 21:19
Originally posted by NanoEntity
I am geting PMs from people that want diffrent urls to diffrent banners, here is the code

This was tested and it works.
//©hololith.com(NanoEntity)
$banner1="<a href=\"http://url1\"><img src=\"{ imagesfolder }/adbanners/banner1.gif\" border=\"0\" alt=\"\"></a>";
$banner2="<a href=\"http://url2\"><img src=\"{ imagesfolder }/adbanners/banner2.gif\" border=\"0\" alt=\"\"></a>";

$banners=array($banner1,$banner2); //banner array
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle banners
$adbanner="$shuffle\n"; //banners output
//END ©hololith.com(NanoEntity)

Enjoy.

They don't rotate :/

NanoEntity
21 Jan 2003, 10:59
it dose rotate, I just checked it, click refresh few times.

Floris
21 Jan 2003, 11:08
Originally posted by NanoEntity
it dose rotate, I just checked it, click refresh few times.

Bwah!

I set $banner and ofcourse in your code it is $adbanner :) FIXED :P hehe.

ScottRoberts
02 Feb 2003, 04:38
//©hololith.com(NanoEntity)
$banner1="<a href=\"http://url1\"><img src=\"{ imagesfolder }/adbanners/banner1.gif\" border=\"0\" alt=\"\"></a>";
$banner2="<a href=\"http://url2\"><img src=\"{ imagesfolder }/adbanners/banner2.gif\" border=\"0\" alt=\"\"></a>";

$banners=array($banner1,$banner2); //banner array
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle banners
$adbanner="$shuffle\n"; //banners output
//END ©hololith.com(NanoEntity)


NanoEntity,

I used your script and it worked great. I have about 8 or 9 banner ads running now, and after a few modifications to the header template, I was able to get my header to look just right. Thanks. If anyone wants to see a sample, you can take a look at http://forums.cultfree.org.

Thanks again!

Scott

Dean C
02 Feb 2003, 11:30
Hey nano i just realised what you did. The original intention of this hack was to just rotate images but i'll change the text file to allow url's :)

Regards

- miSt

Chris M
02 Feb 2003, 11:37
PPN's hack may not work, but mine does;):p

Perhaps you could try and make a size limiter bit to the image;)

Satan

Dean C
02 Feb 2003, 14:11
That quite easy just another variable but i plan to have this admin cp intigrated once i reach the mysql part of my book :)

- miSt

mrderanged
08 Feb 2003, 16:01
Hey all,

First of all, thanks for this hack. I have it installed and it's working fine.

I am however wondering, would there be a way to change it so that it rotates the banners after a set time as opposed to each time the page is refreshed. It seems that the randomness keeps pulling up the same banners time after time and it's not an even enough mix......

Thanks in advance...

Scott

Dean C
08 Feb 2003, 16:10
Sorry buddy. My php isn't advanced enough for that. This is the best randomness that i can do :)

- miSt

Koss
09 Feb 2003, 08:30
could you make it do that its not on forumhome?

Dean C
09 Feb 2003, 11:11
This does it in the header and not forumhome...

Just insert the $banner variable in any template to call the random banner :)

- miSt

Koss
09 Feb 2003, 19:40
Originally posted by NanoEntity
nice one Mist!

Mist! I would just forget about global.php, why not just insert this code to the phpinclude, it will be easy to mod if you need to add a new banner.

Also why list them as
$banner[1]="banner1.gif";
$banner[2]="newthread.gif";

Why not make an Array.
$banners=array('banner1', 'banner2');

Here is a simple way to do it, only takes 3 lines

//©hololith.com(NanoEntity)
$banners=array('banner1', 'banner2'); //images names
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle images
$adbanner="<img src=\"http://www.vbulletin.org/forum/greentek/adbanners/$shuffle.gif\" border=\"0\" alt=\"\">\n"; //images output
//END ©hololith.com(NanoEntity)


Was that easy :)

DEMO:
http://artwork.hololith.com/sigs.php - random
http://artwork.hololith.com/sigs.php?show=draco v1 - static
http://artwork.hololith.com/sigs.php?show=magal v1 - static
http://artwork.hololith.com/sigs.php?show=kinght v1 - static

This generates random signature, same way it would a banner ad, but its more advanced when it comes to code, about 13 lines.

--------------------------
EDIT - Addon

I am geting PMs from people that want diffrent urls to diffrent banners, here is the code

This was tested and it works.

//©hololith.com(NanoEntity)
$banner1="<a href=\"http://url1\"><img src=\"{ imagesfolder }/adbanners/banner1.gif\" border=\"0\" alt=\"\"></a>";
$banner2="<a href=\"http://url2\"><img src=\"{ imagesfolder }/adbanners/banner2.gif\" border=\"0\" alt=\"\"></a>";

$banners=array($banner1,$banner2); //banner array
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle banners
$adbanner="$shuffle\n"; //banners output
//END ©hololith.com(NanoEntity)


Enjoy.

NanoEntity, could you please explain how one would add a flash banner (*.swf)

thanks Mist :)

mrderanged
10 Feb 2003, 13:20
Hey All,

My PHP is pretty much nonexistant, but I was wondering if the following is possible:

I'd like to have one banner in the header, and one in the footer. I've done this by putting the "$adbanner" variable in the spot where I want them. My problem is that they are both showing the same banner and I would like to have them showing different banners. If I were to add the following line to the end of this hack:


//©hololith.com(NanoEntity)
$banner1="<a href=\"http://url1\"><img src=\"{ imagesfolder }/adbanners/banner1.gif\" border=\"0\" alt=\"\"></a>";
$banner2="<a href=\"http://url2\"><img src=\"{ imagesfolder }/adbanners/banner2.gif\" border=\"0\" alt=\"\"></a>";

$banners=array($banner1,$banner2); //banner array
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle banners
$adbanner="$shuffle\n"; //banners output
$adbanner1="$shuffle\n"; //banners output


and add "$adbanner1" to my footer instead of "$adbanner" would this give me a different banner than the one in the header?

Sorry for the newbie question....

Scott

Dean C
10 Feb 2003, 16:41
Simple just duplicate the code like so and use this instead:


///////// Start Random Banner Hack for header /////////////

//Define Variables //
$bannerh[1]="banner1.gif";
$bannerh[2]="newthread.gif";
$numbanners = count($bannerh);

// Generate ranodomness
$num = rand(1,$numbanners);

//output banner
$bannerh = "<img src=\"{imagesfolder}/bannerh$num\" border=\"0\" alt=\"\" />";

////////// End Random banner Hack for header///////////////

///////// Start Random Banner Hack for footer /////////////

//Define Variables //
$bannerf[1]="banner1.gif";
$bannerf[2]="newthread.gif";
$numbanners = count($bannerf);

// Generate ranodomness
$num = rand(1,$numbanners);

//output banner
$bannerf = "<img src=\"{imagesfolder}/bannerf$num\" border=\"0\" alt=\"\" />";

////////// End Random banner Hack for footer///////////////


Use $bannerh for your header and $bannerf for your footer :)

Regards

- miSt

Koss
11 Feb 2003, 05:09
alright I got the code for the flash banners....but when I put the code for the flash banner, like this


$bannerh[2]="<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" ID=popup_06 WIDTH=250 HEIGHT=250>
<PARAM NAME=movie VALUE="http://www.yourdomain.com/banner.swf?url=[AffiliateWizTargetURL]http://www.yourdomain.com"> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="http://www.yourdomain.com/banner.swf?url=[AffiliateWizTargetURL]http://www.yourdomain.com" menu=false quality=high bgcolor=#FFFFFF swLiveConnect=FALSE WIDTH=250 HEIGHT=250 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</EMBED>
</OBJECT>";


it doesnt seem to work
someone please help :(

Dean C
11 Feb 2003, 16:29
Any double quotes in php have to have a " \ " before them...

- miSt

Koss
12 Feb 2003, 19:56
im sorry im not sure if I understand what you mean?

do you mean like this:

$bannerh[2]=\"<OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" ID=popup_06 WIDTH=250 HEIGHT=250>
<PARAM NAME=movie VALUE="http://www.yourdomain.com/banner.swf?url=[AffiliateWizTargetURL]http://www.yourdomain.com"> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="http://www.yourdomain.com/banner.swf?url=[AffiliateWizTargetURL]http://www.yourdomain.com" menu=false quality=high bgcolor=#FFFFFF swLiveConnect=FALSE WIDTH=250 HEIGHT=250 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</EMBED>
</OBJECT>";

Dean C
13 Feb 2003, 16:26
No only in the html code

Like this:


$bannerh[2]= "<OBJECT classid=\"clsid27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0\" ID=popup_06 WIDTH=250 HEIGHT=250>
<PARAM NAME=movie VALUE=\"http://www.yourdomain.com/banner.swf?url=[AffiliateWizTargetURL]http://www.yourdomain.com\"> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src=\"http://www.yourdomain.com/banner.swf?url=[AffiliateWizTargetURL]http://www.yourdomain.com" menu=false quality=high bgcolor=#FFFFFF swLiveConnect=FALSE WIDTH=250 HEIGHT=250 TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\">
</EMBED>
</OBJECT>";


I think i managed to find all the double quotes hehe

- miSt

Koss
15 Feb 2003, 18:06
thanks but that didnt work....guess its back to PPN's one banner hack

oh well thanks for helping out

maoz440
12 Mar 2003, 13:44
nano - works perfectly! Thanks :D

klunderj
12 Mar 2003, 16:33
This is my first real hack of a hack

I really wanted to have the banner have a clickable url... so I modified the hack inphpinclude as follows...

//©hololith.com(NanoEntity)
$banners=array('image1', 'image2'); //images names
$bannerhref=array('url1.com','url2.com'); //url names
$randomnum=rand(0,count($banners)-1); //generate random num
$bannerimg=$banners[$randomnum]; //random image
$bannerurl=$bannerhref[$randomnum]; //corresponding random url


$adbannerurl="<a href=\"http://$bannerurl\">\n";
$adbanner="<img src=\"/images/banner/$bannerimg.jpg\" border=\"0\" alt=\"\">\n"; //images output

//END ©hololith.com(NanoEntity)


In my header I simpy call $addbanner, and $addbannerurl
Hope this is useful...

engquist
21 Jul 2003, 01:30
hey mist, wanted to let you know that the code doesn't work unless you change this part:


//output banner
$banner = "<img src=\"http://www.vbulletin.org/forum/images/banner$num\" border=\"0\" alt=\"\" />";


to:

//output banner
$banner = "<img src=\"http://www.vbulletin.org/forum/images/$banner[$num]\" border=\"0\" alt=\"\" />";


notice the difference?

but then it works fine, thanks MIST!

Zedd
08 Feb 2004, 13:45
nice one Mist!

Mist! I would just forget about global.php, why not just insert this code to the phpinclude, it will be easy to mod if you need to add a new banner.

Also why list them as
$banner[1]="banner1.gif";
$banner[2]="newthread.gif";

Why not make an Array.
$banners=array('banner1', 'banner2');

Here is a simple way to do it, only takes 3 lines

//©hololith.com(NanoEntity)
$banners=array('banner1', 'banner2'); //images names
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle images
$adbanner="<img src=\"http://www.vbulletin.org/forum/greentek/adbanners/$shuffle.gif\" border=\"0\" alt=\"\">\n"; //images output
//END ©hololith.com(NanoEntity)


Was that easy :)

DEMO:
http://artwork.hololith.com/sigs.php - random
http://artwork.hololith.com/sigs.php?show=draco v1 - static
http://artwork.hololith.com/sigs.php?show=magal v1 - static
http://artwork.hololith.com/sigs.php?show=kinght v1 - static

This generates random signature, same way it would a banner ad, but its more advanced when it comes to code, about 13 lines.

--------------------------
EDIT - Addon

I am geting PMs from people that want diffrent urls to diffrent banners, here is the code

This was tested and it works.

//©hololith.com(NanoEntity)
$banner1="<a href=\"http://url1\"><img src=\"{ imagesfolder }/adbanners/banner1.gif\" border=\"0\" alt=\"\"></a>";
$banner2="<a href=\"http://url2\"><img src=\"{ imagesfolder }/adbanners/banner2.gif\" border=\"0\" alt=\"\"></a>";

$banners=array($banner1,$banner2); //banner array
$shuffle=$banners[rand(0,count($banners)-1)]; //shuffle banners
$adbanner="$shuffle\n"; //banners output
//END ©hololith.com(NanoEntity)


Enjoy.
Thanx Nanoentity, you code for the phpinclude template did the trick. IT was exactly what I wanted with no file hacks.

Dave Rosteck
03 Feb 2005, 04:20
hey mist, wanted to let you know that the code doesn't work unless you change this part:


//output banner
$banner = "<img src=\"http://www.vbulletin.org/forum/images/banner$num\" border=\"0\" alt=\"\" />";


to:

//output banner
$banner = "<img src=\"http://www.vbulletin.org/forum/images/$banner[$num]\" border=\"0\" alt=\"\" />";


notice the difference?

but then it works fine, thanks MIST!I hate to bump but you're right, it won't work without this fix. I also wanted to point out that this hack works with vB3 as well.

Simply place the revised banner code under
eval('$headinclude = "' . fetch_template('headinclude') . '";'); in global.php.

ReZ
11 Sep 2005, 17:05
By any chance would this work with 3.0.7 also?

Marco van Herwaarden
11 Sep 2005, 18:42
vB2 hacks will not work with vB3.

ReZ
13 Sep 2005, 10:44
Ok ^ my bad, thanks for replying though.