改进Request类ip方法 支持代理设置

This commit is contained in:
thinkphp
2018-03-30 16:07:15 +08:00
parent c10d4a8931
commit 158aa43028

View File

@@ -1273,7 +1273,11 @@ class Request
return $ip[$type];
}
if ($adv) {
$httpAgentIp = Config::get('http_agent_ip');
if ($httpAgentIp && isset($_SERVER[$httpAgentIp])) {
$ip = $_SERVER[$httpAgentIp];
} elseif ($adv) {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$pos = array_search('unknown', $arr);