php - I want to get the public ip, but apache2 get the private ip -
i want public ip adress of users code private ip... know what's problem ?
my code:
function get_ip() { $ips = ""; if(isset($_server["http_client_ip"])) $ips .= ';'.$_server["http_client_ip"]; if(isset($_server["http_x_forwarded_for"])) $ips .= ';'.$_server["http_x_forwarded_for"]; if(isset($_server["http_x_forwarded"])) $ips .= ';'.$_server["http_x_forwarded"]; if(isset($_server["http_forwarded_for"])) $ips .= ';'.$_server["http_forwarded_for"]; if(isset($_server["http_forwarded"])) $ips .= ';'.$_server["http_forwarded"]; if(isset($_server["remote_addr"])) $ips .= ';'.$_server["remote_addr"]; return $ips; }
sometimes function return ip "10.46.40.246"... what's best way public ip ? !
it's possible anomalies you're seeing people behind proxy in office environment. if want public ip, you'll have take remote_addr
. suppose use function , fall on remote_addr
if returns in private ip block.
Comments
Post a Comment