Reputation: 23
Format for some of the ips are in this form
2600:646:8381:b627:71c1:bdf8:d
Code im using to retrieve ip
function get_ip_address(){
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key){
if (array_key_exists($key, $_SERVER) === true){
foreach (explode(',', $_SERVER[$key]) as $ip){
$ip = trim($ip); // just to be safe
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false){
return $ip;
}
}
}
}
}
Getting same values if I just use $_SERVER['REMOTE_ADDR']
. Dont know why it does this for some ips or what format this is. It wont matter if client returns same value in this format because I just need a unique identifier. Thanks.
Upvotes: 0
Views: 68