URL: http://snipplr.com/extras/
Are you using $SERVER['REMOTEADDR'] to find the the client's IP address? Well dude, you might be amazed to know that it may not return the true IP address of the client at all time. If your client is connected to the Internet through Proxy Server then $SERVER['REMOTEADDR'] just returns the the IP address of the proxy server not of the client's machine. So here is a simple function in PHP to find the real IP address of the client's machine.
Comments
Subscribe to comments
You need to login to post a comment.

This is not a secure way of getting the real ip address. This is how IP forgery can happen because the first 2 are passed in a users headers.
One line alternative: $ip = !empty($SERVER['HTTPCLIENTIP'])?$SERVER['HTTPCLIENTIP']:(!empty($SERVER['HTTPXFORWARDEDFOR'])?$SERVER['HTTPXFORWARDEDFOR']:$SERVER['REMOTEADDR']);
Agreed, it's very rare that you need to get their forwarded ip.
Wrong, in South Africa all ISP's send their clients via a transparent proxies due to the high cost of bandwidth. (A transparent proxy mean the user never have to set up the proxy server settings in their browser, all traffic is forwarded to the proxy server and then to the internet)
I presume that a lot of ISP's in smaller countries do the same