Forum Moderators: coopster

Message Too Old, No Replies

filter by ip location?

         

jake66

12:29 am on Nov 19, 2006 (gmt 0)

10+ Year Member



what i need to do is simple.

i want to hide a button from people visiting the website from toronto.
i realize this is not foolproof, but it's not needed to be.

is there a special code i would use for something like

if ($remote_addr == "toronto"){
//don't show the button
}

i am not familiar with the many uses for remote host or addr, but i do know many ips use the customer's city in the string somewhere (i see it in my server logs).

if this won't work, are there any other suggestions?

mcavic

2:49 am on Nov 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you want to do is called geolocation [google.com]. There are databases available, but I don't know if there are any free ones.

jake66

2:58 am on Nov 19, 2006 (gmt 0)

10+ Year Member



for what i want to do, using any database mechanisms is overkill and could slow the page down significantly, just for the sake of hiding a button :)

thanks for the suggestion though!

encyclo

2:59 am on Nov 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



many ips use the customer's city in the string somewhere (i see it in my server logs)

You can't depend on this data, though - a case in point, my own IP address always shows up as Toronto, but I don't even live in the same province.

There are several IP address databases out there. There is a good free one available from here:

[ip-to-country.webhosting.info...]

However it is difficult to filter for a particular city without blocking a much larger region.

mcavic

3:09 am on Nov 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



using any database mechanisms is overkill and could slow the page down significantly

I agree, but it's the only way.

Just for discussion, ip2location looks pretty good, and their city/state database is only $200/year, but when I did 5 queries, it only had city/state for 2 of them (though those two were very accurate).