修改位置:thinkphp\common\funcitons.php->get_client_ip()function get_client_ip($type = 0) {
$type = $type ? 1 : 0;
static $ip = null;
if ($ip !== null) return $ip[$type];
if($_server['http_x_real_ip']){//nginx 代理模式下,获取客户端真实ip
$ip=$_server['http_x_real_ip'];
}elseif (isset($_server['http_client_ip'])) {//客户端的ip
$ip = $_server['http_client_ip'];
}elseif (isset($_server['http_x_forwarded_for'])) {//浏览当前页面的用户计算机的网关
$arr = explode(',', $_server['http_x_forwarded_for']);
$pos = array_search('unknown',$arr);
if(false !== $pos) unset($arr[$pos]);
$ip = trim($arr[0]);
}elseif (isset($_server['remote_addr'])) {
$ip = $_server['remote_addr'];//浏览当前页面的用户计算机的ip地址
}else{
$ip=$_server['remote_addr'];
}
// ip地址合法验证
$long = sprintf(%u,ip2long($ip));
$ip = $long ? array($ip, $long) : array('0.0.0.0', 0);
return $ip[$type];
}
ad:真正免费,域名+虚机+企业邮箱=0元
