增加新常量 __TYPECHO_IP_SOURCE__

用来指定从哪个项里读取IP地址,比如HTTP_X_REAL_IP
This commit is contained in:
祁宁 2014-09-01 23:52:41 +08:00
parent 3041d50461
commit 07f93cb76b

View File

@ -621,8 +621,8 @@ class Typecho_Request
$this->_ip = $ip;
} else {
switch (true) {
case NULL !== $this->getServer('HTTP_X_FORWARDED_FOR'):
list($this->_ip) = array_map('trim', explode(',', $this->getServer('HTTP_X_FORWARDED_FOR')));
case defined('__TYPECHO_IP_SOURCE__') && NULL !== $this->getServer(__TYPECHO_IP_SOURCE__):
list($this->_ip) = array_map('trim', explode(',', $this->getServer(__TYPECHO_IP_SOURCE__)));
break;
case NULL !== $this->getServer('HTTP_CLIENT_IP'):
$this->_ip = $this->getServer('HTTP_CLIENT_IP');