- * This source file is subject to the New BSD license, That is bundled
- * with this package in the file LICENSE, and is available through
- * the world-wide-web at
- * http://www.opensource.org/licenses/bsd-license.php
- * If you did not receive a copy of the new BSDlicense and are unable
- * to obtain it through the world-wide-web, please send a note to
- * pajoye@php.net so we can mail you a copy immediately.
+ * This source file is subject to the New BSD license, That is bundled
+ * with this package in the file LICENSE, and is available through
+ * the world-wide-web at
+ * http://www.opensource.org/licenses/bsd-license.php
+ * If you did not receive a copy of the new BSDlicense and are unable
+ * to obtain it through the world-wide-web, please send a note to
+ * pajoye@php.net so we can mail you a copy immediately.
- * Author: Tomas V.V.Cox <cox@idecnet.com>
- * Pierre-Alain Joye <pajoye@php.net>
- * Amir Mohammad Saied <amir@php.net>
+ * Author: Tomas V.V.Cox <cox@idecnet.com>
+ * Pierre-Alain Joye <pajoye@php.net>
+ * Amir Mohammad Saied <amir@php.net>
* @author Amir Mohammad Saied <amir@php.net>
* @copyright 1997-2006 Pierre-Alain Joye,Tomas V.V.Cox,Amir Mohammad Saied
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Amir Mohammad Saied <amir@php.net>
* @copyright 1997-2006 Pierre-Alain Joye,Tomas V.V.Cox,Amir Mohammad Saied
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
define('VALIDATE_ALPHA_LOWER', 'a-z');
define('VALIDATE_ALPHA_UPPER', 'A-Z');
define('VALIDATE_ALPHA', VALIDATE_ALPHA_LOWER . VALIDATE_ALPHA_UPPER);
define('VALIDATE_ALPHA_LOWER', 'a-z');
define('VALIDATE_ALPHA_UPPER', 'A-Z');
define('VALIDATE_ALPHA', VALIDATE_ALPHA_LOWER . VALIDATE_ALPHA_UPPER);
-define('VALIDATE_EALPHA_LOWER', VALIDATE_ALPHA_LOWER . 'áéíóúýàèìòùäëïöüÿâêîôûãñõ¨åæç½ðøþß');
-define('VALIDATE_EALPHA_UPPER', VALIDATE_ALPHA_UPPER . 'ÁÉÍÓÚÝÀÈÌÒÙÄËÏÖܾÂÊÎÔÛÃÑÕ¦ÅÆǼÐØÞ');
+define('VALIDATE_EALPHA_LOWER', VALIDATE_ALPHA_LOWER . 'áéíóúýàèìòùäëïöüÿâêîôûãñõ¨åæç½ðøþß');
+define('VALIDATE_EALPHA_UPPER', VALIDATE_ALPHA_UPPER . 'ÁÉÍÓÚÝÀÈÌÒÙÄËÏÖܾÂÊÎÔÛÃÑÕ¦ÅÆǼÐØÞ');
define('VALIDATE_EALPHA', VALIDATE_EALPHA_LOWER . VALIDATE_EALPHA_UPPER);
define('VALIDATE_PUNCTUATION', VALIDATE_SPACE . '\.,;\:&"\'\?\!\(\)');
define('VALIDATE_EALPHA', VALIDATE_EALPHA_LOWER . VALIDATE_EALPHA_UPPER);
define('VALIDATE_PUNCTUATION', VALIDATE_SPACE . '\.,;\:&"\'\?\!\(\)');
-define('VALIDATE_NAME', VALIDATE_EALPHA . VALIDATE_SPACE . "'" . "-");
-define('VALIDATE_STREET', VALIDATE_NUM . VALIDATE_NAME . "/\\ºª\.");
+define('VALIDATE_NAME', VALIDATE_EALPHA . VALIDATE_SPACE . "'" . '\-');
+define('VALIDATE_STREET', VALIDATE_NUM . VALIDATE_NAME . "/\\ºª\.");
define('VALIDATE_ITLD_EMAILS', 1);
define('VALIDATE_GTLD_EMAILS', 2);
define('VALIDATE_CCTLD_EMAILS', 4);
define('VALIDATE_ALL_EMAILS', 8);
define('VALIDATE_ITLD_EMAILS', 1);
define('VALIDATE_GTLD_EMAILS', 2);
define('VALIDATE_CCTLD_EMAILS', 4);
define('VALIDATE_ALL_EMAILS', 8);
if(!empty($options["VALIDATE_GTLD_EMAILS"])) array_push($validate, 'gtld');
if(!empty($options["VALIDATE_CCTLD_EMAILS"])) array_push($validate, 'cctld');
if(!empty($options["VALIDATE_GTLD_EMAILS"])) array_push($validate, 'gtld');
if(!empty($options["VALIDATE_CCTLD_EMAILS"])) array_push($validate, 'cctld');
* 'use_rfc822' => 'true',
* 'VALIDATE_GTLD_EMAILS' => 'true',
* 'VALIDATE_CCTLD_EMAILS' => 'true',
* 'use_rfc822' => 'true',
* 'VALIDATE_GTLD_EMAILS' => 'true',
* 'VALIDATE_CCTLD_EMAILS' => 'true',
- list($name, $domain) = explode('@', $email, 2);
+ $tmpEmail = explode('@', $email);
+ $domain = array_pop($tmpEmail);
// it's an idn domain name.
$chars = count_chars($domain, 1);
if (!empty($chars) && max(array_keys($chars)) > 127) {
// it's an idn domain name.
$chars = count_chars($domain, 1);
if (!empty($chars) && max(array_keys($chars)) > 127) {
/**
* @todo Fix bug here.. even if it passes this, it won't be passing
* The regular expression below
/**
* @todo Fix bug here.. even if it passes this, it won't be passing
* The regular expression below
(?:(?:(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))\.){3}
(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))))(?(5)\])|
((?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)*[a-z0-9](?:[-a-z0-9]*[a-z0-9])?) #6 domain as hostname
(?:(?:(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))\.){3}
(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))))(?(5)\])|
((?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)*[a-z0-9](?:[-a-z0-9]*[a-z0-9])?) #6 domain as hostname
$&xi';
//checks if exists the domain (MX or A)
if ($use_rfc822? Validate::__emailRFC822($email, $options) :
preg_match($regex, $email)) {
if ($check_domain && function_exists('checkdnsrr')) {
$&xi';
//checks if exists the domain (MX or A)
if ($use_rfc822? Validate::__emailRFC822($email, $options) :
preg_match($regex, $email)) {
if ($check_domain && function_exists('checkdnsrr')) {
- list ($account, $domain) = explode('@', $email);
+ $domain = preg_replace('/[^-a-z.0-9]/i', '', array_pop(explode('@', $email)));
$class = implode('_', $validateType);
$classPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
$class = 'Validate_' . $class;
$class = implode('_', $validateType);
$classPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
$class = 'Validate_' . $class;
- if (!@include_once "Validate/$classPath.php") {
- trigger_error("$class isn't installed or you may have some permissoin issues", E_USER_ERROR);
+ if (Validate::_includePathFileExists("Validate/$classPath.php")) {
+ include_once "Validate/$classPath.php";
+ } else {
+ trigger_error("$class isn't installed or you may have some permission issues", E_USER_ERROR);
+
+ /**
+ * Determine whether specified file exists along the include path.
+ *
+ * @param string $filename file to search for
+ *
+ * @access private
+ *
+ * @return bool true if file exists
+ */
+ function _includePathFileExists($filename)
+ {
+ $paths = explode(":", ini_get("include_path"));
+ $result = false;
+
+ while ((!($result)) && (list($key,$val) = each($paths))) {
+ $result = file_exists($val . "/" . $filename);
+ }
+ return $result;
+ }