private function validate(Gpf_Rpc_Form $form) {
require_once('../include/Pap/Features/ReCaptcha/recaptchalib.php');
if ((is_null($form->getFieldValue("recaptcha_challenge_field")) || $form->getFieldValue("recaptcha_challenge_field") == '') &&
(is_null($form->getFieldValue("recaptcha_response_field")) || $form->getFieldValue("recaptcha_response_field") == '')) {
$form->setErrorMessage($this->_("The reCAPTCHA isn't configured correctly") . ': ' . $this->_("wrong public key or check template 'signup_fields.tpl' if contains: {widget id=\"recaptcha\"}"));
return;
}
if (is_null($form->getFieldValue("recaptcha_response_field")) || $form->getFieldValue("recaptcha_response_field") == '') {
$form->setErrorMessage($this->_("The reCAPTCHA wasn't entered correctly"));
return;
}
$resp = recaptcha_check_answer (Gpf_Settings::get(Pap_Settings::RECAPTCHA_PRIVATE_KEY),
$_SERVER["REMOTE_ADDR"],
$form->getFieldValue("recaptcha_challenge_field"),
$form->getFieldValue("recaptcha_response_field"));
if (!$resp->is_valid && $resp->error == 'incorrect-captcha-sol') {
$form->setErrorMessage($this->_("The reCAPTCHA wasn't entered correctly"));
return;
}
if (!$resp->is_valid && $resp->error == 'invalid-site-private-key') {
$form->setErrorMessage($this->_("The reCAPTCHA isn't configured correctly") . ': ' . $this->_("wrong private key"));
return;
}
if (!$resp->is_valid) {
$form->setErrorMessage($this->_("The reCAPTCHA isn't configured correctly") . " Error: " . $resp->error);
return;
}
}