Jump to content

- - - - -

Adsense Php Random Ad Block

  • Please log in to reply
No replies to this topic

#1 glen



  • Admin
  • PipPipPipPip
  • 895 posts

Posted 06 July 2005 - 08:59 AM

Hi everyone,

I am currently exploring ways of randomizing the ads sense colors and types and position.

We all know you can have up to 4 random colors using the google admin panel.

However, wouldn't it be cool if you could actually change the position and type of ad each time your pages loaded? Well this is quite easy with HTML pages using server side includes. Here is one such example -


And it is generally easy enough inserting via PHP includes using a script such as Random Text - Version 1.0 -

In both of the above examples, the scripts (Perl or PHP) use a text file to store the ad codes. They will be seprated by a special set of characters. For example, "random text 1.0" uses a separator that looks like this "--NEXT--" See the text file layout below as an example -

Ad code no.1 (for a blue rectangle)
Ad code no.2 (for a green banner)
Ad code no. 3 (for a purple skyscraper)

If you wanted to, you could add additional HTML tags to achieve positioning -

<center>Ad code no.1</center>
<div align="right">Ad code no.2</div>
Ad code no. 3

You could also have a different channel for each random ad type -


There are some very powerful possibilities here.


In my case, I wanted to insert the "Random Text" script in my invision forum however I had some difficulties because it does not appear to be possible to include a "php include" statement within the IPB skin. There is a mod to allow include statements to be made in the banner/header area but that is not where I wanted to place my random ads.

If you are interested, the script for the php include hack of invision power board is located here -

IPB Includes for 2.0.3

If anyone can help me to figure out how to get php includes working in the forum HTML/Skin (rather than in the board header) it would be appreciated.

Cheers, Glen
  • 0

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users