GraphicalCodeCaptchaVerifierFilter.execute ( Requestable requestInstance,
Responseable responseInstance 
)

Executes the filter with given request and response objects.

Parameters:
$requestInstance An instance of a class with an Requestable interface
$responseInstance An instance of a class with an Responseable interface
Returns:
void

Implements Filterable.

Definition at line 55 of file class_GraphicalCodeCaptchaVerifierFilter.php.

References Responseable.addFatalMessage(), ObjectFactory.createObjectByConfiguredName(), Requestable.getRequestElement(), and Requestable.requestIsValid().

00055                                                                                                {
00056                 // Get the captcha code
00057                 $captchaCode = $requestInstance->getRequestElement('c_code');
00058 
00059                 // Is this set?
00060                 if (is_null($captchaCode)) {
00061                         // Not set so request is invalid
00062                         $requestInstance->requestIsValid(false);
00063 
00064                         // Add fatal message
00065                         $responseInstance->addFatalMessage('captcha_code_unset');
00066 
00067                         // Skip further processing
00068                         return false;
00069                 } elseif (empty($captchaCode)) {
00070                         // Empty value so request is invalid
00071                         $requestInstance->requestIsValid(false);
00072 
00073                         // Add fatal message
00074                         $responseInstance->addFatalMessage('captcha_code_empty');
00075 
00076                         // Skip further processing
00077                         return false;
00078                 }
00079 
00080                 // Get the hash as well
00081                 $captchaHash = $requestInstance->getRequestElement('hash');
00082 
00083                 // Is this set?
00084                 if (is_null($captchaHash)) {
00085                         // Not set so request is invalid
00086                         $requestInstance->requestIsValid(false);
00087 
00088                         // Add fatal message
00089                         $responseInstance->addFatalMessage('captcha_hash_unset');
00090 
00091                         // Skip further processing
00092                         return false;
00093                 } elseif (empty($captchaHash)) {
00094                         // Empty value so request is invalid
00095                         $requestInstance->requestIsValid(false);
00096 
00097                         // Add fatal message
00098                         $responseInstance->addFatalMessage('captcha_hash_empty');
00099 
00100                         // Skip further processing
00101                         return false;
00102                 }
00103 
00104                 // Now, both are set hash the given one. First get a crypto instance
00105                 $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
00106 
00107                 // Then hash the code
00108                 $hashedCode = $cryptoInstance->hashString($captchaCode, $captchaHash);
00109 
00110                 // Is this CAPTCHA valid?
00111                 if ($hashedCode != $captchaHash) {
00112                         // Not the same so request is invalid
00113                         $requestInstance->requestIsValid(false);
00114 
00115                         // Add fatal message
00116                         $responseInstance->addFatalMessage('captcha_hash_mismatch');
00117                 } // END - not the same!
00118         }

Here is the call graph for this function:


Generated on Mon Dec 8 01:12:39 2008 for Ship-Simulator by  doxygen 1.5.6