php file based hit counter script

There are tons of free counters available on the internet. But unfortunately, most of them require you to register in their website and want a link back to their website. Also, you don’t get the full freedom to modify your image. Here is a small script using which you can easily integrate a counter in your website. You can edit the image to any type you like. You can use any font you like, use any font color you like and start the counter from any value you like. Also, you can count different pages in your website differently if you like. The script will store the visitor count in a file in your web server in any directory you want.

Three fonts, one regular English font, one Devanagari font, and one digital font are included in the zip package. You can download any ttf font and use it with your counter.  You can specify text color and background color inside your script. The script uses text file to store the counter data.  The default file name is counter.txt . You can change it inside the script. Suppose you have two pages, one “index page” and one “about page”. If you want to count the visitors of two pages separately then just specify the “page” get variable in the image url. Like, if the url of script is then you can add the hit counter to the index page as

and the about page as as

You can put all the data in a separate directory. Create a new directory “counterdata” in the same directory as the script  and set the $directory variable in the script to”counterdata/” . All the counter data will be stored in the directory.

Here are some samples of hit counter for this page:

Digital Hit counter with different background
Devanagari Hit counter
Normal Hit counter

You can view and download the project files at it’s github page.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x