我看到很多疯狂的软件在网站上运行,工具在PHP网站上发现了远程访问者(本地路由器地址)的网关地址..
这怎么可能?我搜索了很多关于这个,但没有什么解释肯定.. 有谁知道这些代码是如何工作的?
谢谢, (对不起,EN。)
答案 0 :(得分:0)
参考How to get the client IP address in PHP?
//获取用户IP地址的功能
function getUserIP() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED']))
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
答案 1 :(得分:0)
我在野外发现了一段代码,仅适用于Internet Explorer ... 但有些人可以绕过这个,我不知道..