From 83a9e5c76fad3771c12ca955c673c49c52d81e24 Mon Sep 17 00:00:00 2001 From: Comsenz <10433182@qq.com> Date: Mon, 4 Jun 2018 18:16:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E8=80=83=E8=99=91=20filte?= =?UTF-8?q?r=5Fvar=20=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upload/source/function/function_filesock.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/upload/source/function/function_filesock.php b/upload/source/function/function_filesock.php index 2a2eb8e..c45251d 100644 --- a/upload/source/function/function_filesock.php +++ b/upload/source/function/function_filesock.php @@ -20,12 +20,20 @@ function _isLocalip($ip) { ($iplong >= 150994944 && $iplong <= 167772159); } +function _isip($host) { + if(function_exists('filter_var')) { + return filter_var($host, FILTER_VALIDATE_IP) !== false; + } else { + return preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $host); + } +} + function _dfsockopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE, $encodetype = 'URLENCODE', $allowcurl = TRUE, $position = 0, $files = array()) { $return = ''; $matches = parse_url($url); $scheme = $matches['scheme']; $host = $matches['host']; - if(filter_var($host, FILTER_VALIDATE_IP) && _isLocalip($host) || $ip && _isLocalip($ip)) { + if(_isip($host) && _isLocalip($host) || $ip && _isLocalip($ip)) { return ''; } $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';