You are here

function recaptcha_captcha_validation in reCAPTCHA 8

Same name and namespace in other branches
  1. 8.3 recaptcha.module \recaptcha_captcha_validation()
  2. 8.2 recaptcha.module \recaptcha_captcha_validation()
  3. 6.2 recaptcha.module \recaptcha_captcha_validation()
  4. 6 recaptcha.module \recaptcha_captcha_validation()
  5. 7.2 recaptcha.module \recaptcha_captcha_validation()
  6. 7 recaptcha.module \recaptcha_captcha_validation()

CAPTCHA Callback; Validates the reCAPTCHA code.

1 string reference to 'recaptcha_captcha_validation'
recaptcha_captcha in ./recaptcha.module
Implements hook_captcha().

File

./recaptcha.module, line 201
Uses the reCAPTCHA web service to improve the CAPTCHA system.

Code

function recaptcha_captcha_validation($solution = NULL, $response = NULL) {
  global $user;
  $recaptcha_private_key = variable_get('recaptcha_private_key', FALSE);
  $ip_address = ip_address();
  if ($recaptcha_private_key && $ip_address && $response === 'reCAPTCHA' && !empty($_POST['recaptcha_challenge_field']) && !empty($_POST['recaptcha_response_field']) && _recaptcha_test_recaptcha_server()) {
    $resp = recaptcha_check_answer($recaptcha_private_key, $ip_address, check_plain($_POST['recaptcha_challenge_field']), check_plain($_POST['recaptcha_response_field']));
    return $resp->is_valid;
  }
  return FALSE;
}