- fixed validateUrl-function to work with buggy php-5.2.13 and php-5.3.2 (filter_var-bug)
This commit is contained in:
@@ -34,12 +34,24 @@ function validateUrl($url)
|
||||
$url = 'http://' . $url;
|
||||
}
|
||||
|
||||
if(version_compare("5.2.13", PHP_VERSION, "=")
|
||||
|| version_compare("5.3.2", PHP_VERSION, "="))
|
||||
{
|
||||
$pattern = '/^https?:\/\/([a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?\.)+[a-z]{2,6}$/i';
|
||||
if(preg_match($pattern, $url))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) !== false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
// not an fqdn
|
||||
if(strtolower(substr($url, 0, 7)) == "http://"
|
||||
|| strtolower(substr($url, 0, 8)) == "https://")
|
||||
{
|
||||
@@ -69,4 +81,4 @@ function validateUrl($url)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user