01-17-2010, 04:21 PM
|
#2 (permalink)
|
|
The Wanderer
Join Date: Aug 2008
Posts: 21
Thanks: 1
|
Well, your code isn't really great.
Your showHitCounter function prints a div but nothing in the div.
The function never counts the amount of lines in the file and never prints this, so that you see nothing is normal.
Your hit function has the variable $T which is never used and you check a hit with a cookie, which will never be the nice way for a hitcounter.
Why is a cookie bad ? Because a user can simply unset the cookie and visit again.
There are loads of hitcounters on the web that you can use, if your really want to code one yourself, then I suggest you first choose what you want to count.
Every page view ?
Every unique page view ?
A user can view a page once per day ?
If you simply want every page view, then you can simply save the number of hits and add 1 to it every view.
For every unique page view, you will have to save the IP off a viewer and you can select all lines from a file to count the amount of unique views.
And if you want a user to view a page once every x hours or days, you will have to save the IP with the Date of the view and check if the date is before the x hours or days.
|
|
|
|