cvs: phpweb /include email-validation.inc

From: Date: Sat, 09 Aug 2003 12:16:08 +0000
Subject: cvs: phpweb /include email-validation.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-20054@lists.php.net to get a copy of this message
goba Sat Aug 9 08:16:08 2003 EDT Modified files: /phpweb/include email-validation.inc Log: Use pregs instead of eregs for consistency and make the code more readable Index: phpweb/include/email-validation.inc diff -u phpweb/include/email-validation.inc:1.7 phpweb/include/email-validation.inc:1.8 --- phpweb/include/email-validation.inc:1.7 Wed Jan 30 13:33:56 2002 +++ phpweb/include/email-validation.inc Sat Aug 9 08:16:08 2003 @@ -1,25 +1,31 @@ <?php -/* - * email_validation.inc - * $Id: email-validation.inc,v 1.7 2002/01/30 18:33:56 jimw Exp $ - */ +// $Id: email-validation.inc,v 1.8 2003/08/09 12:16:08 goba Exp $ -// checks that is an *outside* host, and tries to remove anti-SPAM bits -function clean_AntiSPAM ($email) { - $remove_spam = "[-_]?(NO|I[-_]?HATE|DELETE|REMOVE)[-_]?(THIS)?(ME|SPAM)?[-_]?"; - return eregi_replace($remove_spam,"",trim($email)); +// Try to remove anti-SPAM bits +function clean_AntiSPAM($email) +{ + $remove_spam = "![-_]?(NO|I[-_]?HATE|DELETE|REMOVE)[-_]?(THIS)?(ME|SPAM)?[-_]?!i"; + return preg_replace($remove_spam, "", trim($email)); } -function is_emailable_address( $email) { - $hosts_regex="lists\.php\.net|chek.*\.com"; - $excluded_hosts = ereg($hosts_regex,$email); - $email_regex="^([-!#\$%&'*+./0-9=?A-Z^_a-z{|}~ ])+@([-!#\$%&'*+/0-9=?A-Z^_a-z{|}~ ]+\\.)+[a-zA-Z]{2,6}\$"; - if (!$excluded_hosts && $email != "") { - return eregi($email_regex, $email); +// Try to check that this email address is valid +function is_emailable_address($email) +{ + // Exclude our mailing list hosting servers + $hosts_regex = "!(lists\.php\.net|chek[^\.*]\.com)!i"; + $excluded_hosts = preg_match($hosts_regex, $email); + + // Email addresses need to match this pattern + $email_regex = ":^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~ ])+" . + "@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~ ]+\\.)+" . + "[a-zA-Z]{2,6}\$:i"; + + // If address is not under excluded hosts, and fits the regex, + // then we belive that it is a good email address + if (!$excluded_hosts && !empty($email)) { + return preg_match($email_regex, $email); } else { - return false; + return FALSE; } } - -?>

« previous php.mirrors (#20054) next »