From: Roland Haeder Date: Fri, 17 Apr 2015 18:50:53 +0000 (+0200) Subject: Added checks for 'command' and 'form' and check if CAPTCHA is enabled. X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=ca6e07fa5a4112a968891e3331a771fea7cebd4d Added checks for 'command' and 'form' and check if CAPTCHA is enabled. Signed-off-by: Roland Häder --- diff --git a/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php b/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php index dc6e19b5..5dc0f575 100644 --- a/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php @@ -54,6 +54,29 @@ class GraphicalCodeCaptchaVerifierFilter extends BaseFilter implements Filterabl * @throws FilterChainException If this filter fails to operate */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Is the form set? + if (($requestInstance->getRequestElement('command') !== 'do_form') || (!$requestInstance->isRequestElementSet('form'))) { + // Required field not set + $requestInstance->requestIsValid(FALSE); + + // Add fatal message + $responseInstance->addFatalMessage('command_form_invalid'); + + // Skip further processing + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + + // Create config entry + $configKey = sprintf('%s_captcha_secured', + $requestInstance->getRequestElement('form') + ); + + // Is the CAPTCHA enabled? + if ($this->getConfigInstance()->getConfigEntry($configKey) != 'Y') { + // Not enabled, so don't check + return; + } // END - if + // Get the captcha code $captchaCode = $requestInstance->getRequestElement('c_code');