- fixed validateUrl-function to work with buggy php-5.2.13 and php-5.3.2 (filter_var-bug)

This commit is contained in:
Michael Kaufmann (d00p)
2010-04-21 10:40:58 +00:00
parent 4cf8e2f2ea
commit 31231a5f60

View File

@@ -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;
}
}
}