Problem getting real IP in php

Posted by leda on Stack Overflow See other posts from Stack Overflow or by leda
Published on 2010-06-17T15:41:21Z Indexed on 2010/06/17 15:43 UTC
Read the original article Hit count: 200

Filed under:

I am using this to get real IP but i take empty from $_SERVER['HTTP_CLIENT_IP'],i take not empty only from $_SERVER['REMOTE_ADDR'].But i dont need the IP of proxy,i need the real ip of computers using some intranet.Can i get it?when $_SERVER['HTTP_CLIENT_IP'] does not return empty?

function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; }

© Stack Overflow or respective owner

Related posts about php