667 | | $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i"; |
668 | | if (strpos($user_email, '@') !== false && strpos($user_email, '.') !== false) { |
669 | | if (preg_match($chars, $user_email)) { |
670 | | return true; |
671 | | } else { |
672 | | return false; |
673 | | } |
674 | | } else { |
675 | | return false; |
| 667 | // regex from http://iamcal.com/publish/articles/php/parsing_email/ |
| 668 | $no_ws_ctl = "[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]"; |
| 669 | $alpha = "[\\x41-\\x5a\\x61-\\x7a]"; |
| 670 | $digit = "[\\x30-\\x39]"; |
| 671 | $cr = "\\x0d"; |
| 672 | $lf = "\\x0a"; |
| 673 | $crlf = "($cr$lf)"; |
| 674 | $obs_char = "[\\x00-\\x09\\x0b\\x0c\\x0e-\\x7f]"; |
| 675 | $obs_text = "($lf*$cr*($obs_char$lf*$cr*)*)"; |
| 676 | $text = "([\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f]|$obs_text)"; |
| 677 | $obs_qp = "(\\x5c[\\x00-\\x7f])"; |
| 678 | $quoted_pair = "(\\x5c$text|$obs_qp)"; |
| 679 | $wsp = "[\\x20\\x09]"; |
| 680 | $obs_fws = "($wsp+($crlf$wsp+)*)"; |
| 681 | $fws = "((($wsp*$crlf)?$wsp+)|$obs_fws)"; |
| 682 | $ctext = "($no_ws_ctl|[\\x21-\\x27\\x2A-\\x5b\\x5d-\\x7e])"; |
| 683 | $ccontent = "($ctext|$quoted_pair)"; |
| 684 | $comment = "(\\x28($fws?$ccontent)*$fws?\\x29)"; |
| 685 | $cfws = "(($fws?$comment)*($fws?$comment|$fws))"; |
| 686 | $cfws = "$fws*"; |
| 687 | $atext = "($alpha|$digit|[\\x21\\x23-\\x27\\x2a\\x2b\\x2d\\x2e\\x3d\\x3f\\x5e\\x5f\\x60\\x7b-\\x7e])"; |
| 688 | $atom = "($cfws?$atext+$cfws?)"; |
| 689 | $qtext = "($no_ws_ctl|[\\x21\\x23-\\x5b\\x5d-\\x7e])"; |
| 690 | $qcontent = "($qtext|$quoted_pair)"; |
| 691 | $quoted_string = "($cfws?\\x22($fws?$qcontent)*$fws?\\x22$cfws?)"; |
| 692 | $word = "($atom|$quoted_string)"; |
| 693 | $obs_local_part = "($word(\\x2e$word)*)"; |
| 694 | $obs_domain = "($atom(\\x2e$atom)*)"; |
| 695 | $dot_atom_text = "($atext+(\\x2e$atext+)*)"; |
| 696 | $dot_atom = "($cfws?$dot_atom_text$cfws?)"; |
| 697 | $dtext = "($no_ws_ctl|[\\x21-\\x5a\\x5e-\\x7e])"; |
| 698 | $dcontent = "($dtext|$quoted_pair)"; |
| 699 | $domain_literal = "($cfws?\\x5b($fws?$dcontent)*$fws?\\x5d$cfws?)"; |
| 700 | $local_part = "($dot_atom|$quoted_string|$obs_local_part)"; |
| 701 | $domain = "($dot_atom|$domain_literal|$obs_domain)"; |
| 702 | $addr_spec = "($local_part\\x40$domain)"; |
| 703 | |
| 704 | // we need to strip comments first (repeat until we can't find any more) |
| 705 | $done = 0; |
| 706 | while(! $done ) { |
| 707 | $new = preg_replace( "!$comment!", '', $user_email ); |
| 708 | if (strlen($new) == strlen($user_email)) |
| 709 | $done = 1; |
| 710 | $user_email = $new; |