00001 <?php 00025 class PasswordValidatorFilter extends BaseFilter implements Filterable { 00031 protected function __construct () { 00032 // Call parent constructor 00033 parent::__construct(__CLASS__); 00034 } 00035 00041 public final static function createPasswordValidatorFilter () { 00042 // Get a new instance 00043 $filterInstance = new PasswordValidatorFilter(); 00044 00045 // Return the instance 00046 return $filterInstance; 00047 } 00048 00056 public function execute (Requestable $requestInstance, Responseable $responseInstance) { 00057 // Get passwords 00058 $password1 = $requestInstance->getRequestElement('pass1'); 00059 $password2 = $requestInstance->getRequestElement('pass2'); 00060 00061 // Is the password still not set? 00062 if ((is_null($password1)) || (is_null($password2))) { 00063 // Not found in form so stop the filtering process 00064 $requestInstance->requestIsValid(false); 00065 00066 // Add a message to the response 00067 $responseInstance->addFatalMessage('password_unset'); 00068 00069 // Abort here 00070 return false; 00071 } elseif ((empty($password1)) || (empty($password2))) { 00072 // Password is empty 00073 $requestInstance->requestIsValid(false); 00074 00075 // Is the password empty? 00076 if (empty($password1)) { 00077 // Add a message to the response 00078 $responseInstance->addFatalMessage('pass1_empty'); 00079 } // END - if 00080 00081 // Is the confirmation empty? 00082 if (empty($password2)) { 00083 // Add a message to the response 00084 $responseInstance->addFatalMessage('pass2_empty'); 00085 } // END - if 00086 00087 // Abort here 00088 return false; 00089 } elseif ($password1 != $password2) { 00090 // Passwords didn't match 00091 $requestInstance->requestIsValid(false); 00092 00093 // Add a message to the response 00094 $responseInstance->addFatalMessage('pass_mismatch'); 00095 00096 // Abort here 00097 return false; 00098 } // END - elseif 00099 } 00100 } 00101 00102 // [EOF] 00103 ?>
1.5.6