BBCodeEmailAddressValidator

The bbPress BBCodeEmailAddressValidator class.

Defined (1)

The class is defined in the following location(s).

/includes/admin/parser.php  
  1. class BBCodeEmailAddressValidator { 
  2. function check_email_address($strEmailAddress) { 
  3. if (preg_match('/[\x00-\x1F\x7F-\xFF]/', $strEmailAddress)) { 
  4. return false; 
  5. $intAtSymbol = strrpos($strEmailAddress, '@'); 
  6. if ($intAtSymbol === false) { 
  7. return false; 
  8. $arrEmailAddress[0] = substr($strEmailAddress, 0, $intAtSymbol); 
  9. $arrEmailAddress[1] = substr($strEmailAddress, $intAtSymbol + 1); 
  10. $arrTempAddress[0] = preg_replace('/"[^"]+"/' 
  11. , '' 
  12. , $arrEmailAddress[0]); 
  13. $arrTempAddress[1] = $arrEmailAddress[1]; 
  14. $strTempAddress = $arrTempAddress[0] . $arrTempAddress[1]; 
  15. if (strrpos($strTempAddress, '@') !== false) { 
  16. return false; 
  17. if (!$this->check_local_portion($arrEmailAddress[0])) { 
  18. return false; 
  19. if (!$this->check_domain_portion($arrEmailAddress[1])) { 
  20. return false; 
  21. return true; 
  22. function check_local_portion($strLocalPortion) { 
  23. if (!$this->check_text_length($strLocalPortion, 1, 64)) { 
  24. return false; 
  25. $arrLocalPortion = explode('.', $strLocalPortion); 
  26. for ($i = 0, $max = sizeof($arrLocalPortion); $i < $max; $i++) { 
  27. if (!preg_match('.^(' 
  28. . '([A-Za-z0-9!#$%&\'*+/=?^_`{|}~-]' 
  29. . '[A-Za-z0-9!#$%&\'*+/=?^_`{|}~-]{0, 63})' 
  30. .'|' 
  31. . '("[^\\\"]{0, 62}")' 
  32. .')$.' 
  33. , $arrLocalPortion[$i])) { 
  34. return false; 
  35. return true; 
  36. function check_domain_portion($strDomainPortion) { 
  37. if (!$this->check_text_length($strDomainPortion, 1, 255)) { 
  38. return false; 
  39. if (preg_match('/^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])' 
  40. .'(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])) {3}$/' 
  41. , $strDomainPortion) || 
  42. preg_match('/^\[(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])' 
  43. .'(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])) {3}\]$/' 
  44. , $strDomainPortion)) { 
  45. return true; 
  46. } else { 
  47. $arrDomainPortion = explode('.', $strDomainPortion); 
  48. if (sizeof($arrDomainPortion) < 2) { 
  49. return false; 
  50. for ($i = 0, $max = sizeof($arrDomainPortion); $i < $max; $i++) { 
  51. if (!$this->check_text_length($arrDomainPortion[$i], 1, 63)) { 
  52. return false; 
  53. if (!preg_match('/^(([A-Za-z0-9][A-Za-z0-9-]{0, 61}[A-Za-z0-9])|' 
  54. .'([A-Za-z0-9]+))$/', $arrDomainPortion[$i])) { 
  55. return false; 
  56. return true; 
  57. function check_text_length($strText, $intMinimum, $intMaximum) { 
  58. $intTextLength = strlen($strText); 
  59. if (($intTextLength < $intMinimum) || ($intTextLength > $intMaximum)) { 
  60. return false; 
  61. } else { 
  62. return true;