Getting IPAddress via a proxy with PHP?
I run security checks on a number of AJAX calls to see if the same IP requested that I have on record. I used the following set of class functions to establish the IP (which can come via load balancers, hence the lengthly methodology. private function IPMask_Match ($network, $ip) { $ip_arr = explode('/', $network); if (count($ip_arr) < 2) { $ip_arr = array($ip_arr[0], null); } $network_long = ip2long($ip_arr[0]); $x = ip2long($ip_arr[1]); $mask = long2ip($x) == $ip_arr[1] ? $x : 0xffffffff << (32 - $ip_arr[1]); $ip_long = ip2long($ip); return ($ip_long & $mask) == ($network_long & $mask); }