From: Web Access Date: Tue, 27 Jan 2015 14:13:17 +0000 (+0530) Subject: CRM-15853 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3c275f0d154cde1b2a5c17c5e3c444f17cf65ab1;p=civicrm-core.git CRM-15853 --- diff --git a/CRM/Utils/ReCAPTCHA.php b/CRM/Utils/ReCAPTCHA.php index 2d48759f59..c04a181c9d 100644 --- a/CRM/Utils/ReCAPTCHA.php +++ b/CRM/Utils/ReCAPTCHA.php @@ -89,41 +89,18 @@ class CRM_Utils_ReCAPTCHA { $form->assign('recaptchaOptions', $config->recaptchaOptions); $form->add( 'text', - 'recaptcha_challenge_field', - NULL, + 'g-recaptcha-response', + 'reCaptcha', NULL, TRUE ); - $form->add( - 'hidden', - 'recaptcha_response_field', - 'manual_challenge' - ); - $form->registerRule('recaptcha', 'callback', 'validate', 'CRM_Utils_ReCAPTCHA'); - $form->addRule( - 'recaptcha_challenge_field', - ts('Input text must match the phrase in the image. Please review the image and re-enter matching text.'), - 'recaptcha', - $form - ); - } - - /** - * @param $value - * @param CRM_Core_Form $form - * - * @return mixed - */ - public static function validate($value, $form) { - $config = CRM_Core_Config::singleton(); - - $resp = recaptcha_check_answer($config->recaptchaPrivateKey, - $_SERVER['REMOTE_ADDR'], - $_POST["recaptcha_challenge_field"], - $_POST["recaptcha_response_field"] - ); - return $resp->is_valid; + if ($form->isSubmitted() && empty($form->_submitValues['g-recaptcha-response'])) { + $form->setElementError( + 'g-recaptcha-response', + ts('Input text must match the phrase in the image. Please review the image and re-enter matching text.') + ); + } } }