IP Addresses : A better understanding..

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
Kev
Forum Newbie
Posts: 21
Joined: Tue Aug 25, 2009 9:11 pm

IP Addresses : A better understanding..

Post by Kev »

I'm coding a "click counter" jump script in PHP and wish to prevent counting of "double clicks" or people that click one link a whole bunch of times in a short period.

One way I was thinking to achieve this was by seeing if that particular visitor's IP address had clicked on the same link earlier (within like a 2-minute window).

My question is...

Can two web surfers on the Internet share the same IP Address? I'd hate to not count a click because someone who clicked a link for the first time has the same IP address as someone else they don't know who clicked a couple seconds before.

Any suggestions or guidance on this? Thanks.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: IP Addresses : A better understanding..

Post by AbraCadaver »

Many users share an IP address, especially if they are behind a router or proxy such as at work, at school or even at home behind a linsys/dlink router, etc.

There is no fool-proof way to accomplish this, but in general I would probably set a cookie. Check if cookie is set, if not, record the click and set the cookie. If set, don't record the click. This will work if the user accepts cookies and if they don't clear their cookies. If you want it timed, then you can insert the time in the cookie.

Like I said, there's really no guaranteed way of doing this.

-Shawn
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
volomike
Forum Regular
Posts: 633
Joined: Wed Jan 16, 2008 9:04 am
Location: Myrtle Beach, South Carolina, USA

Re: IP Addresses : A better understanding..

Post by volomike »

Within a two minute window, odds are pretty good that no two people will have an IP address at the same time.

Now, if the window is larger, say, 1 hour, the odds get worse against you.

That's why I combine $_SERVER['HTTP_USER_AGENT'] and $_SERVER['REMOTE_ADDR'] in a table (two columns), cached up to 1 day, to try and increase the odds of uniqueness. It's not perfect, but it's better than nothing. You can also combine with a cookie that you drop and check, or session variables.

And any time you can reduce that cache to under an hour -- if that will work in the context of your site -- then I suggest that. In some contexts, however, that's not suitable and you may need an hour, a couple hours, a day, etc., depending on what you want to do.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: IP Addresses : A better understanding..

Post by josh »

There was this guy who I traded traffic with that claimed to have access to a "top 100 alexa site". He would, upon our request, send us 10s of thousands of hits in a very short window, so much it would crash our web server. What we think he was doing was using a proxy list or sending forged TCP/IP packets because all the traffic would hit one page and we would have 0 requests for our javascript or image files. That is one way to thwart it, but as far as proxies you're pretty much out of luck too. No reliable ways to detect them.

The best thing to do is keep track of the bounce rates of said clicks, if the bounce rate is high or close to 100% you're getting forced or bad traffic (example someone embeds your referral link as a hidden iframe on some random websites)
Post Reply