include/main.inc.php文件,这部分
if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
  $_SGLOBAL['onlineip'] = getenv('HTTP_CLIENT_IP');
} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
  $_SGLOBAL['onlineip'] = getenv('HTTP_X_FORWARDED_FOR');
} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
  $_SGLOBAL['onlineip'] = getenv('REMOTE_ADDR');
} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
  $_SGLOBAL['onlineip'] = $_SERVER['REMOTE_ADDR'];
}


替换成
function get_real_ip()
{
       $ip=false;
       if(!empty($_SERVER["HTTP_CLIENT_IP"]))
       {
            $ip = $_SERVER["HTTP_CLIENT_IP"];
       }
       if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
       {
            $ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
            if ($ip)
            {
                     array_unshift($ips, $ip); $ip = FALSE;
            }
            for ($i = 0; $i < count($ips); $i++)
            {
                     if (!eregi ("^(10|172\.16|192\.168)\.", $ips[$i]))
                     {
                               $ip = $ips[$i];
                               break;
                     }
            }
       }
       return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
}
$_SGLOBAL['onlineip'] = get_real_ip();


个人 | 评论(0) | 引用(0) | 阅读(2464)
发表评论
昵称

网址

电邮
打开HTML 打开UBB 表情 打开表情 隐藏 记住我 [注册]