Jump to content

Hit Counting.


sepoto

Recommended Posts

I have seen code out there for basic hit counters that simply log each hit into a text file. What I want to do is take things a step further and block hits that come from my so that I don't pollute my data. I'm really not quite sure how to accomplish something like this. Any ideas?

Link to comment
Share on other sites

1. If you always access the page from the same computer, and it has a fixed IP address, you can simply bypass the process if $_SERVER['REMOTE_ADDR'] matches your IP.2. More of a hassle. You could add a query string to the url whenever you access your stuff. Test for the presence of the correct $_GET value and bypass the process if there is a match.

Link to comment
Share on other sites

or assigning a session to admininstrator (you) when user login (if you have login system). then check against that session if match dont make entry to file else make a entry.and if you dont have login i think checking ip will be good as dierder's dad stated. if you have static ip then there is no issue but if its dial up then its changes the situation..dial up user's ip changes but only the last two tuple. so you can also check using preg_match() to match the first two tuple. 123.56.***.**

Link to comment
Share on other sites

Many ISPs change subscribers' IP addresses around in a dynamic fashion - the practice isn't limited to dial-up. The first two octets may change as well.

Link to comment
Share on other sites

Given all the comments I think i am envisioning a system that uses $_SERVER['REMOTE_ADDR'] and then checks the first two octets of my IP which never seem to change very much at my ISP. Thanks for the all the advice.

Link to comment
Share on other sites

Given all the comments I think i am envisioning a system that uses $_SERVER['REMOTE_ADDR'] and then checks the first two octets of my IP which never seem to change very much at my ISP. Thanks for the all the advice.
If you do that, anyone that's in your ISP's network is also not going to be logged. Your ISP uses ALL of its IPs... it's just that the IP that was once yours may no longer be used by you, but from a fellow ISP user.Adding a custom query string (a.k.a. GET) parameter is a better approach, since you're only doing this for statistical purposes (if it was for security, that's not exactly a good idea).I mean, if you just add to your requests for example
?noLog

you can make PHP avoid the log. Better yet, if the system is well enough designed, you can automatically append the same parameter to all of your links in the output, so that you can have a full unlogged browsing experience over your site.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...