oxmailvalidator.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxMailValidator
00007 {
00008 
00012     private $_sMailValidationRule = null;
00013 
00019     public function getMailValidationRule()
00020     {
00021         if (is_null($this->_sMailValidationRule)) {
00022             $this->_sMailValidationRule = "/^([\w+\-.])+\@([\w\-.])+\.([A-Za-z]{2,64})$/i";
00023         }
00024 
00025         return $this->_sMailValidationRule;
00026     }
00027 
00033     public function setMailValidationRule($sMailValidationRule)
00034     {
00035         $this->_sMailValidationRule = $sMailValidationRule;
00036     }
00037 
00042     public function __construct()
00043     {
00044         $oConfig = oxRegistry::getConfig();
00045         $sEmailValidationRule = $oConfig->getConfigParam('sEmailValidationRule');
00046         if (!empty($sEmailValidationRule)) {
00047             $this->_sMailValidationRule = $sEmailValidationRule;
00048         }
00049     }
00050 
00059     public function isValidEmail($sEmail)
00060     {
00061         $sEmailRule = $this->getMailValidationRule();
00062         $blValid = (getStr()->preg_match($sEmailRule, $sEmail) != 0);
00063 
00064         return $blValid;
00065     }
00066 }