Displaying page
of
pages;
Items to
Title |
Test
Details
URI Validation
|
Expression |
if(!isValidURL($_POST['url']){ echo "do something"; }
|
Description |
function isValidURL($url) {
$protocol = "((http|ftp|https):\/\/)?";
$domain = "([[:alpha:]][-[:alnum:]]*[[:alnum:]])(\.[[:alpha:]][-[:alnum:]]*[[:alpha:]])+";
$dir = "(/[[:alpha:]][-[:alnum:]]*[[:alnum:]])*";
$page = "(/[[:alpha:]][-[:alnum:]]*\.[[:alpha:]]{3,5})?";
$getstring = "(\?([[:alnum:]][-_%[:alnum:]]*=[-_%[:alnum:]]+)(&([[:alnum:]][-_%[:alnum:]]*=[-_%[:alnum:]]+))*)?";
$pattern = "^".$protocol.$domain.$dir.$page.$getstring."$";
return eregi($pattern, $url);
}
//-----------------
Be sure to put each variable ($protocol, $domain, $dir, $page, $getstring, $pattern, and 'return') on separate line!
|
Matches |
www.google.co.uk | www9.g-88gle.co.uk | http://path1/to-page | http://phpinfo.php
|
Non-Matches |
9ww.google.3o.uk | www.google4.co.uk3 | http://path1-/2-page | http://phpinfo.php4
|
Author |
Rating:
Ardjuna Pandu
|
Displaying page
of
pages;
Items to