成长值: 255 签到天数: 4710 天 [LV.Master]伴坛终老
|
发表于 2015/7/27 03:53
|
显示全部楼层
|阅读模式
|Google Chrome 44.0.2403.107 |Windows 8.1
/includes/function/global.func.php
搜索
- function get_ip(){
- if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
- $onlineip = getenv('HTTP_CLIENT_IP');
- } elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
- $onlineip = getenv('HTTP_X_FORWARDED_FOR');
- } elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
- $onlineip = getenv('REMOTE_ADDR');
- } elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
- $onlineip = $_SERVER['REMOTE_ADDR'];
- }
- $onlineip = addslashes($onlineip);
- @preg_match("/[\d\.]{7,15}/", $onlineip, $onlineipmatches);
- $onlineip = $onlineipmatches[0] ? $onlineipmatches[0] : 'unknown';
- unset($onlineipmatches);
- return $onlineip;
- }
复制代码
替换
- function get_ip(){
- if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches)) {
- foreach ($matches[0] AS $xip) {if (!preg_match('#^(10|172\.16|192\.168)\.#', $xip)) {$onlineip = $xip;break;}}
- } elseif(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
- $onlineip = getenv('HTTP_CLIENT_IP');
- } elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
- $onlineip = getenv('REMOTE_ADDR');
- } elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
- $onlineip = $_SERVER['REMOTE_ADDR'];
- }
- $onlineip = addslashes($onlineip);
- @preg_match("/[\d\.]{7,15}/", $onlineip, $onlineipmatches);
- $onlineip = $onlineipmatches[0] ? $onlineipmatches[0] : 'unknown';
- unset($onlineipmatches);
- return $onlineip;
- }
复制代码
|
|