cvs: php-master-web /include email-validation.inc
| From: | Gabor Hojtsy | Date: | Sun, 10 Aug 2003 11:01:29 +0000 |
| Subject: | cvs: php-master-web /include email-validation.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-20110@lists.php.net to get a copy of this message | ||
goba Sun Aug 10 07:01:29 2003 EDT
Modified files:
/php-master-web/include email-validation.inc
Log:
Port email validation code updates from phpweb
Index: php-master-web/include/email-validation.inc
diff -u php-master-web/include/email-validation.inc:1.1
php-master-web/include/email-validation.inc:1.2
--- php-master-web/include/email-validation.inc:1.1 Sat Sep 22 19:52:50 2001
+++ php-master-web/include/email-validation.inc Sun Aug 10 07:01:29 2003
@@ -1,25 +1,31 @@
<?php
-/*
- * email_validation.inc
- * $Id: email-validation.inc,v 1.1 2001/09/22 23:52:50 jimw Exp $
- */
+// $Id: email-validation.inc,v 1.2 2003/08/10 11:01:29 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,4}\$";
- 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;
}
}
-
-?>