HeiDoc.net: The Technology Treasure Chest

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 

The PHP counter script introduced here doesn't need any database, but depends simply on a single text file in which all relevant information is stored. All you need is some webspace with PHP support, the possibility to make the text files on the webspace writable, and of course some basic HTML knowledge to integrate the counter properly into your own website.

The counter can be used free of charge on personal websites.

PHP Counter Version 2.0

The counter consists of a PHP file named counter.php, as well as a text file counter.txt and a backup file counter_neu.txt. Before I start explaining the parameters, have a look at some examples of the counter:

100x30; topcol=orange; botcol=black; fontcol=green
100x30; topcol=orange; botcol=black; fontcol=green
88x31; topcol=white; botcol=white; fontcol=black
88x31; topcol=white; botcol=white; fontcol=black
88x31; topcol=yellow; botcol=white; fontcol=black
88x31; topcol=yellow; botcol=white; fontcol=black
100x30; topcol=white; botcol=blue; fontcol=red; style=1
100x30; topcol=white; botcol=blue; fontcol=red; style=1
88x31; topcol=black; botcol=black; fontcol=grey; style=1
88x31; topcol=black; botcol=black; fontcol=grey; style=1
120x60; topcol=blue; botcol=violet; fontcol=yellow
120x60; topcol=blue; botcol=violet; fontcol=yellow

As you can see, the font size varies to a certain degree, depending on the image size and the style. To use the new Version 2.0 style, the horizontal dimension of the counter graphic needs to be at least 80 pixels.

The counter takes up to six parameters:

x = the width of the counter image (from 74 to 250; default is 88)
y = the height of the counter image (from 20 to 250; default is 31)
topcol = the top colour of the gradient (default is white)
botcol = the bottom colour of the gradient (default is white)
fontcol = the font colour (default is black)
style = version 1.0 or version 2.0 counter style (default is 2)

So a counter can be integrated into HTML by the following line for example:

<img
 src="counter.php?topcol=blue&botcol=violet&fontcol=yellow&style=2"
 alt="Website Counter" title=" Website Counter"
 style="border: none; width: 88px; height: 31px;" />

Possible colours are white, grey, black, red, green, blue, cyan, magenta, yellow, brown, violet, orange, as well as their German translations weiss, grau, schwarz, rot, gruen, blau, cyan, magenta, gelb, braun, violet and orange.

Download and integration of the counter

First thing to be done is to download the file counter.zip and unpack it to your webspace.

Now configure the two files called counter.txt and counter_neu.txt as writable. To accomplish this, you must set the read/write pemissions to 666. Both files contain just two lines:

1
1|0|0|

The 1 in the second line can be replaced by the current counter reading.

Features and limitations of the counter

In the text files, the IP addresses of the past 24 hours are remembered, so they don't create any double hits. The counter will only create a hit when it's called from the same domain on which the php file is stored. Bots and spiders are also not able to create any hits.

Although the counter data is backed up, since there's no database behind it, there's still a minimal chance that the file counter.txt could somehow become damaged. If this happens, the file can be repaired by editing and setting counter.txt and counter_neu.txt back to the lines mentioned above.

Sites with very many visitors might become difficult to handle for the counter script. I don't know how much exactly it can manage, but if you encounter problems with more than say 1000 daily visitors, you should consider using a database counter script instead.

Update Newsletter and Feed

All updates and bugfixes to this script will be announced on this feed. You can also have the feed updates sent to you by email using Google Feedburner. Future ideas for improvement include a new four line style.

License and copyright issues

The counter can be used on personal websites free of charge. However, a backlink to heidoc.net or vic-fontaine.com would be very much appreciated. On commercial websites (including non profit, governmental and educational organisations), a backlink is mandatory. Alternatively, a license fee of 30 US Dollars per company or organisation applies, payable by SEPA bank transfer or PayPal. Please contact me for details.

The actual source code of the counter may not be distributed in any form.