提交 3b9f6e79 编写于 作者: 李光春's avatar 李光春

- 修复获取请求IP

上级 3b772d3b
......@@ -58,19 +58,13 @@ if (!function_exists('get_ip')) {
*/
function get_ip()
{
$ip = '0.0.0.0';
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
//为了兼容百度的CDN,所以转成数组
$arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$pos = array_search('unknown', $arr);
if (false !== $pos) unset($arr[$pos]);
$ip = trim($arr[0]);
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
return $arr[0];
} else {
return $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册