What is a paycounter, well anyone who has built Adult sites will know that a paycounter is a counter which displays small images, these images are about 120x60 in size. These are basically advertisements. There used to be a number of Adult counters that allowed people to sign up and you placed there code on your site and when someone clicked on the counter you generated some income, usually a few cents per click.
This was great for adult sites but not really suitable for mainstream sites due to the nature of the advertised images, well you can easily roll your own basic example which will serve the purpose of a counter and also offer some advertising revenue if anyone clicks on the links.
The system is split into 2 basic parts the first is the generation of an ad and the storing of the visitor count in a seperate file and the second which would be used by the webmaster is a system to display the stats.
Firsly create a file called paycounter.txt and put whatever the count you wish to display in it. Next create the script in part 1 and call it paycounter.php. This consists of various functions and features the first
<strong>Part 1 : The counter</strong>
$counter_file = ("paycounter.txt"); //counter file we are using
$visits = file($counter_file); //open file and read in data
$visits++; //increment the visits variable by 1
$fp = fopen($counter_file , "w"); //open the file and store the new value
fputs($fp , "$visits"); //write the new value to the text file
fclose($fp); //tidy up
//part 2 the banner display part
//some sample banners , use your own here these are just nonsense urls for the purpose of this example
$url = array("http://www.urlno1inhere.com",
//the urls for the images , replace these also
$imgsrc = array("http://www.urlno1inhere.com/image1.gif",
//this is alt tags for the links
$alt = array("about link 1 ",
"about link 2 ",
"about link 3 ",
"about link 4 ");
//generate a random number the number in $rn = (rand()%4); has to be changed
//depending on the amount of advertisers you have
srand((double)microtime() * 1000000); //random number generation
$rn = (rand()%4);
//display the banner and link . This opens in a new window
echo ("<img src =$imgsrc[$rn] alt =$alt[$rn]>"); //displays image with url link and alt text opens in new window
echo ("paycounter example"); //text underneath the image
<strong>Part 2 : Show stats</strong>
This is a small script that can be put on a page called paystats.php for example. This also could be shown on a seperate page only viewable by the admin
We basically open up the paycounter file that we used in the first script and read in the value in it, then we display this on the screen.
$counter_file1 = ("paycounter.txt"); //open the counter file
$visits1 = file($counter_file1);
$fp1 = fopen($counter_file , "r");
fclose($fp1); //close file handle
echo $visits1; //display count on screen
Upload all files to your website ensuring that the paycounter text file is the same folder as the php files.
To use the paycounter part this is the code you would use say on a page on your site
<?php include("paycounter.php") ?>
For the stats you would use the following code
<?php include("paystats.php") ?>
An example can be found on the following site address, paste into your favourite browser or you can use Internet Explorer. http://www.beginnersphp.co.uk/statspay.php
Here are some improvements that could be made for all of the people with additional programming skills
MySQL backend for storing of stats and also for displaying of advertisements.
Multiple pages with stats.
owner and founder of Programmers help and maxidirectory to name just a few of the many sites.