[pLog-svn] r4946 - plog/branches/lifetype-1.2/class/data/validator
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Sat Mar 3 08:23:02 EST 2007
Author: jondaley
Date: 2007-03-03 08:23:02 -0500 (Sat, 03 Mar 2007)
New Revision: 4946
Modified:
plog/branches/lifetype-1.2/class/data/validator/httpurlvalidator.class.php
Log:
we should be using our fancy urlformat rule rather than writing our own
Modified: plog/branches/lifetype-1.2/class/data/validator/httpurlvalidator.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/validator/httpurlvalidator.class.php 2007-03-03 13:13:33 UTC (rev 4945)
+++ plog/branches/lifetype-1.2/class/data/validator/httpurlvalidator.class.php 2007-03-03 13:23:02 UTC (rev 4946)
@@ -1,40 +1,20 @@
<?php
lt_include( PLOG_CLASS_PATH."class/data/validator/validator.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/validator/rules/regexprule.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/validator/rules/nonemptyrule.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/rules/urlformatrule.class.php" );
/**
* \ingroup Validator
*
* Checks whether the string is a valid http/https url
*
- * @see NonEmptyRule
*/
class HttpUrlValidator extends Validator
{
function HttpUrlValidator()
{
- // trying to be RFC 1736 compatible, except where common
- // usage goes against it, such as allowing unencoded
- // '~', '^', ' ', etc.
-
- $prefix = "^([[:alnum:]\-\+\.]+)\://";
- $ftp_login = "([[:alnum:]\.\-]+(\:[[:alnum:]\.&%\$\-]+)*@)*";
- $ip_num = "(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]?)";
- $ip_address = "($ip_num\.($ip_num|0)\.($ip_num|0)\.$ip_num)";
- $tld = "(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|([[:alpha:]]{2}))";
- $port = "(\:[[:digit:]]+)*";
- $path = "(/($|[[:alnum:] \.\,\?\'\"\\\+^&%\$#\=~_\-]+))*";
-
- // allow underscores, even though we shouldn't
- $domain_part = "([[:alnum:]_\-]+\.)+";
-
$this->Validator();
- $this->addRule( new NonEmptyRule());
- $this->addRule( new RegExpRule("(" . $prefix . $ftp_login . "(" . $ip_address . "|localhost|(" .
- $domain_part . $tld . "))" . $port . ")?" . $path . "$",
- false ));
+ $this->addRule( new UrlFormatRule());
}
}
?>
More information about the pLog-svn
mailing list