I tried every codes and read all posts with this topic, but none resolved my problem.
The code doesnt get the real IP when the browser option "use proxy for intranet sites" is on.
It shows me the PROXY IP...
Code:
function get_ip_address()
{
$aa = array ( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', // 'HTTP_HOST', 'REMOTE_ADDR');
foreach ($aa as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
return $ip;
}
}
}
}
}
#endfunc
echo get_ip_address();
Well, that's the purpose of proxies. You cannot reliably obtain the IP address of your user and, even if you could, do you mean their WAN address? Or one of any number of LAN addresses? It's an intractible problem in the general case.