| 1 |
<?php |
<?php |
| 2 |
/* $Id: recaptcha.module,v 1.13.2.4.2.11.2.9 2009/07/28 15:50:18 robloach Exp $ */ |
/* $Id: recaptcha.module,v 1.13.2.4.2.11.2.10 2009/08/10 17:50:02 robloach Exp $ */ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 125 |
$captcha['solution'] = TRUE; |
$captcha['solution'] = TRUE; |
| 126 |
$captcha['captcha_validate'] = 'recaptcha_captcha_validation'; |
$captcha['captcha_validate'] = 'recaptcha_captcha_validation'; |
| 127 |
$html = recaptcha_get_html($recaptcha_public_key, NULL, $recaptcha_secure_connection); |
$html = recaptcha_get_html($recaptcha_public_key, NULL, $recaptcha_secure_connection); |
| 128 |
$captcha['form'] = array( |
$captcha['form']['captcha_response'] = array( |
| 129 |
|
'#type' => 'hidden', |
| 130 |
|
'#value' => 'reCAPTCHA', |
| 131 |
|
); |
| 132 |
|
$captcha['form']['captcha_form'] = array( |
| 133 |
'#type' => 'item', |
'#type' => 'item', |
| 134 |
'#value' => ($recaptcha_form_value ? '<div id="recaptcha_custom_theme_widget">'. $recaptcha_form_value .'</div>' : '') . $html, |
'#value' => ($recaptcha_form_value ? '<div id="recaptcha_custom_theme_widget">'. $recaptcha_form_value .'</div>' : '') . $html, |
| 135 |
); |
); |
| 142 |
* CAPTCHA Callback; Validates the reCAPTCHA code. |
* CAPTCHA Callback; Validates the reCAPTCHA code. |
| 143 |
*/ |
*/ |
| 144 |
function recaptcha_captcha_validation($solution = NULL, $response = NULL) { |
function recaptcha_captcha_validation($solution = NULL, $response = NULL) { |
| 145 |
if (isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field'])) { |
if ($response == 'reCAPTCHA' && isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field'])) { |
| 146 |
$resp = recaptcha_check_answer( |
$resp = recaptcha_check_answer( |
| 147 |
variable_get('recaptcha_private_key', ''), |
variable_get('recaptcha_private_key', ''), |
| 148 |
$_SERVER['REMOTE_ADDR'], |
$_SERVER['REMOTE_ADDR'], |