Re: ip2country

From: Date: Wed, 17 Sep 2003 16:45:48 +0000
Subject: Re: ip2country
References: 1  Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-21058@lists.php.net to get a copy of this message
I was recently looking to your website source code and I think you have made a small error in the ip2country module. I think you should only use the 'REMOTE_ADDR' var, instead of trying to find the real user's ip using 'HTTP_X_FORWARDED_FOR', because you don't really want to know the country of the client, you just want to know the ip of the machine you are serving the website to. For example, I'm in Portugal, but I can be using a proxy server in USA. It would be faster if I had been redirected to a USA mirror. If you really want to know the client's ip, you may want to check for the following var: $_SERVER['HTTP_CLIENT_IP']. I've noticed the use of that var in my server (some proxy servers use it!).
There were a very small number of complaints on the country detection, and mostly because of errors of the DB itself. We do website redirections based on this data, so it would turn out if it would do it's work in the bad way. As far as I can see, we would confuse our users if we would redirect people browsing from Portugal to a US mirror. First of all, you can override the automatic mirror selection in My PHP.net (not the country detection!). Second we also use the country detection to emphasize local events on the homepage, and would like to use this stuff for more possible features in the future. Thanks for your suggestion anyway, Goba

« previous php.mirrors (#21058) next »