PHP : Ad Rotator

3 Mar

<?
srand ((double) microtime() * 1000000);
/*

PLEASE KEEP THE CREDITS INTACT WHEN DISTRIBUTING THIS SCRIPT
USE AT YOUR OWN RISK WITH NO SUPPORT OR GUARANTEES
USE IT FOR PUBLIC, PRIVATE, PROFIT AT NO CHARGE

AD_ROTATOR IN PHP3
BY: MARK DONCHEK
E: MARK@MARKDONLINE.COM
W: WWW.MARKDONLINE.COM

This script is ideal for rotating a few ads on a small site without comittiing to an elaborate
database system. Since each ad is stored in its own include file,
it can contain HTML, quotes, semicolons, etc which may throw other scripts off.

1. Simply cut and paste all of this code in a php doc where you want your ad to appear.
2. create an include file for each ad.
3. copy all necessary code for the ad into its respective include.
4. change the var $randomnumber to accomodate the number of ads you have.
where ‘x’ = one less than the number of ads you have:
*/

$randomnumber = rand(0,x); // change the second number if need be (see number 4 above)

/*
5. change “your_path/any_ad.inc” for each ad you have
6. alter the number of elseifs to accomodate the number of includes if necessary (ads).
*/

$include0 = “your_path/any_ad.inc”;
$include1 = “your_path/any_ad.inc”;
$include2 = “your_path/any_ad.inc”;
$include3 = “your_path/any_ad.inc”;
$include4 = “your_path/any_ad.inc”;

if ($randomnumber== “0”) {
include (“$include0”);

} else if ($randomnumber== “1”) {
include(“$include1”);

} else if ($randomnumber== “2”) {
include(“$include2”);

} else if ($randomnumber== “3”) {
include(“$include3”);

} else if ($randomnumber== “4”) {
include(“$include4”);

} else {

echo (“ERROR: A random num is being generated out of range, or not at all “);
}
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: