成长值: 354 签到天数: 4743 天 [LV.Master]伴坛终老
|
发表于 2015/7/27 03:14
|
显示全部楼层
|阅读模式
|Google Chrome 44.0.2403.107 |Windows 8.1
找到这个文件:\source\class\discuz\discuz_application.php
搜索,在378行左右
- private function _get_client_ip() {
- $ip = $_SERVER['REMOTE_ADDR'];
- if (isset($_SERVER['HTTP_CLIENT_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_CLIENT_IP'])) {
- $ip = $_SERVER['HTTP_CLIENT_IP'];
- } elseif(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)) {
- $ip = $xip;
- break;
- }
- }
- }
- return $ip;
- }
复制代码
这一段替换
- private function _get_client_ip() {
- $ip = $_SERVER['REMOTE_ADDR'];
- 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)) {
- $ip = $xip;
- break;
- }
- }
- } elseif(isset($_SERVER['HTTP_CLIENT_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_CLIENT_IP'])) {
- $ip = $_SERVER['HTTP_CLIENT_IP'];
- }
- return $ip;
- }
复制代码
如果不经过cdn的话 用户容易伪造ip 所以不用cdn就别这么改
比如说伪造8.8.8.8访问
|
|