Hit & IP Counter
This script cant count hits and last visit time for all the pages of your site. It can also log the ip address of the visitors of your site and their visiting time and what browser did they used to visit your site. You don't need you to add each page url to log manually, you need just to add a small javascript in your pages and it will do all the others! It's logs doesn't make jam in your MySQL database. It uses flat files to store logs.
Installation:
-
Upload the "counter.php" and "view.php" to your server in a directory named something like mylogs or counter etc.
-
Create or upload the two blank folders named "counts" and "logs" to the same directory where you uploaded the php files. Note that the folder names are case sensitive. You should make the folders names exactly same as I mentioned above.
- Change the CHMOD of the two folders to 777.
That's all installation. Now the thing that you need to do is to add a java script in each of your web pages to count hits and logs.
Adding java script
Add the script below in all of your pages that you need to count hits or logs. Paste it in the place where you want to show the counts. Because this script will only show your hit counts in your pages not logs.
| <SCRIPT LANGUAGE="Javascript" SRC="http://dscripts.awadrspace.com/my_counts/counter.php?id=test"><!--//--></SCRIPT> |
Change the url of http://dscripts.awadrspace.com/my_counts/counter.php from the above line to the absolute url of your counter.php file.
Setting up id
Look at the script there is an id (marked blue) after the url of counter.php file. Make it different for each of your pages. This sends unique id for each of your page with which the script identifies different pages.
Formatting hit counter text
Of course you can show the hit counter the way you like. Just insert the code inside any html tags. Such as...
| <p align="Center"><b>This page has been visited total <font color="#FF0000"><SCRIPT LANGUAGE="Javascript" SRC="http://www.yourwebsite/counts/counter.php?id=test"><!--//--></SCRIPT></font> since 1 January 2006</b></p> |
This would show this...
|
This page has been visited total 420 (;P) times since 1 January 2006 |
Viewing logs
To view logs you need to go to the view.php file. Go to view.php file with your browser. And after the url of your view.php file type
http://www.yourwebsite.com/counter/view.php?id=your_page_id
To view logs of an exact file you need to change your_page_id to your page id
How the id would be?
This is an important matter. Please note that you should not use any space or special character to make id.
Use only A-Z, a-z, 0-9 and _ (underscore)
How to turn off ip logging?
Incase you want to use only counter not want to log visitors ip address then you can remove the code for logging marked with /// Code for creating logs // and end with //====== from the counter.php file. I recommend to keep it inside a comments block so that you can use it whenever like.
Troubleshoot:
Please while installing this script please check these matters below to avoid failures
-
You should make the folder names exactly to "counts" and "logs" neither "CoUnts" nor "LOgS"
-
You should change CHMOD of these two folders to 777
-
While adding JavaScript in your pages, you should mention unique id for each pages.
-
While viewing logs, you also should type the id of the page (that you want to view logs) at the address bar of browser. And also make sure that the id exist.
-
You should name your page ids with only characters with A-Z, a-z, 0-9 and _ (Underscore)
If you followed the steps mentioned above the script should run fine

