Monday, December 13, 2010

CJ Ad Banner Rotator Using Simple PHP Script

The contents of "CJ Ad Rotator" ........

1. adrotate.php

2. displayad.inc

3. linkcode.inc

4. Example Include.php

5. Readme.txt

6. Copying.txt (GPL)

7. and just incase you forgot where it came from.... an Internet Shortcut :D

Files Required

~~~~~~~~

1. adrotate.php

2. displayad.inc

3. linkcode.inc

4. A php page to display the adrotate.php



» note: the page must be renamed to something.php for this counter to work, to do this open the file in » notepad and save it as "whatever.php" (some servers require .php3 or .php4 extensions)

Installation Help

~~~~~~~~~~

please note » additional help is included in the editable files.

1. Open up linkcode.inc and replace what is in there with as many links as you like, remember to save them in the format:

<a href="http://www.advertising.com/link0001"><img src="http://www.advertising.com/image00001.jpg"></a>

<a href="http://www.advertising.com/link0002"><img src="http://www.advertising.com/image00002.jpg"></a>

etc...

2. Open up adrotate.php an edit the variables if you want to:

$directory = "/enter/your/website/root/"; // Webserver path to your adrotator files

$linkfile = "linkcode.inc"; // The Link Code file

$adcountfile = "displayad.inc"; // The Ad Display file

$pos = "left"; // Postion of banner tag (left, center or right)

$help_msg = "no"; // Display a "Help Message" - "Yes" to enable!

$help_message = "Please support this site by clicking on the banner below"; // Enter "Help Message" here

3. Add the following code to within your webpage where you want the banner adverts to appear (see Example Include)

<? include("adrotate.php"); ?>

Note: if you have put the files in a seperate folder you will need to link to them eg. <? include("ads/adrotate.php"); ?>

4. Upload the files: adrotate.php, linkcode.inc, displayad.inc (to a suitable directory) and your webpage.php

5. CHMOD the file displayad.inc to 777

6. Surf to your webpage and a banner should be displayed that changes when you click refresh (if you have more than one banner in linkcode.inc!)

7. Note: Because you declared the server path to your files, you can insert the banner ads on any page. Just remember to <? include ?> the correct file!

Linkcode.inc

<a href="http://www.advertising.com" target="_blank" ><img src="http://www.advertising.com/image-1240896-02020202" width="468" height="60" alt="Support Our Website!" border="0"></a>
<a href="http://www.advertising.com" target="_blank" ><img src="http://www.advertising.com/image-1240896-02020202" width="468" height="60" alt="Support Our Website!" border="0"></a>
<a href="http://www.advertising.com" target="_blank" ><img src="http://www.advertising.com/image-1240896-02020202" width="468" height="60" alt="Support Our Website!" border="0"></a>

adrotate.php

<?
/* Config Part --------------------------------------------------------------------------------------------------------------*/

$directory = "/enter/your/website/root/"; // Webserver path to your adrotator files
$linkfile = "linkcode.inc"; // The Link Code file
$adcountfile = "displayad.inc"; // The Ad Display file
$pos = "left"; // Postion of banner tag (left, center or right)
$help_msg = "no"; // Display a "Help Message" - "Yes" to enable!
$help_message = "Please support this site by clicking on the banner below"; // Enter "Help Message" here

/* End of Config Part -------------------------------------------------------------------------------------------------------*/

// Leave below this line alone - If you modify anything below I can assure you it will mess up!

// the file holding the advert number to view next
$num = file($directory.$adcountfile);

// the file holding the link codes
$adverts = file($directory.$linkfile);

// tells the script to look at the next item in the array
$num = $num[0]+1;

// counting the number of adverts - using function count()
$number = count($adverts);

// If ran out of adverts, start again!
if($num>$number-1){
$num=0;
}

// write the current number to the file
if (file_exists($directory.$adcountfile)) {
$nu = fopen ($directory.$adcountfile, "w");
fputs($nu,$num);
}
else {
die("<h1>Can't find file</h1><br>Check ad-count file ($adcountfile) exists<BR>Check file with links ($linkfile) exists<BR>Check directory ($directory) is correct");
}

// display the link on the page

if($help_msg == "yes"){
echo "{$pos_statag}<small>$help_message</small>{$pos_endtag}";
}
echo "<div align=\"$pos\">$adverts[$num]</div>";
?>

include.php

<html>
<head>
<title>Advert</title>
<body>
Advert:
<br><br>

<?
include('adrotate.php');
?>

 

</body>
</html>

 

By PHP with No comments

0 comments:

Post a Comment

    • Popular
    • Categories
    • Archives