修复 考虑 filter_var 不存在的情况
This commit is contained in:
parent
bec08dac93
commit
83a9e5c76f
|
@ -20,12 +20,20 @@ function _isLocalip($ip) {
|
||||||
($iplong >= 150994944 && $iplong <= 167772159);
|
($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()) {
|
function _dfsockopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE, $encodetype = 'URLENCODE', $allowcurl = TRUE, $position = 0, $files = array()) {
|
||||||
$return = '';
|
$return = '';
|
||||||
$matches = parse_url($url);
|
$matches = parse_url($url);
|
||||||
$scheme = $matches['scheme'];
|
$scheme = $matches['scheme'];
|
||||||
$host = $matches['host'];
|
$host = $matches['host'];
|
||||||
if(filter_var($host, FILTER_VALIDATE_IP) && _isLocalip($host) || $ip && _isLocalip($ip)) {
|
if(_isip($host) && _isLocalip($host) || $ip && _isLocalip($ip)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
|
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
|
||||||
|
|
Loading…
Reference in New Issue