You are here

function recaptcha_captcha_validation in reCAPTCHA 6

Same name and namespace in other branches
  1. 8.3 recaptcha.module \recaptcha_captcha_validation()
  2. 8 recaptcha.module \recaptcha_captcha_validation()
  3. 8.2 recaptcha.module \recaptcha_captcha_validation()
  4. 6.2 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 220
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', '');
  $ip_address = ip_address();
  if (!empty($recaptcha_private_key) && $ip_address && $response === 'reCAPTCHA' && !empty($_POST['recaptcha_challenge_field']) && !empty($_POST['recaptcha_response_field']) && _recaptcha_server_is_up()) {
    $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;
}