reCAPTCHA web service to improve the CAPTCHA system and protect email addresses.', array('@url' => url('http://www.recaptcha.net'))); break; case 'admin/help#recaptcha': $output .= '
'. t('Uses the reCAPTCHA web service to improve the CAPTCHA module and protect email addresses. For more information on what reCAPTCHA is, visit the official website.', array('@url' => url('http://www.recaptcha.net'))) . '
'. t('The settings associated with reCAPTCHA can be found in the reCAPTCHA tab, in the CAPTCHA settings. You must set your public and private reCAPTCHA keys in order to use the module. Once the public and private keys are set, visit the CAPTCHA settings, where you can choose where reCAPTCHA should be displayed.', array('@recaptchatab' => url('admin/user/captcha/recaptcha'), '@captchasettings' => url('admin/user/captcha'))) . '
'; break; } return $output; } /** * Implementation of hook_menu(). */ function recaptcha_menu() { $items = array(); $items['admin/user/captcha/recaptcha'] = array( 'title' => 'reCAPTCHA', 'description' => 'Administer the reCAPTCHA web service.', 'page callback' => 'drupal_get_form', 'page arguments' => array('recaptcha_admin_settings'), 'access arguments' => array('administer recaptcha'), 'type' => MENU_LOCAL_TASK, 'file' => 'recaptcha.admin.inc', ); return $items; } /** * Implementation of hook_perm(). */ function recaptcha_perm() { return array('administer recaptcha'); } /** * Implementation of hook_captcha(). */ function recaptcha_captcha() { $args = func_get_args(); $op = array_shift($args); switch ($op) { case 'list': return array('reCAPTCHA'); case 'generate': $captcha_type = array_shift($args); $captcha = array(); if ($captcha_type == 'reCAPTCHA') { // Load the recaptcha library. _recaptcha_load_library(); // Check if reCAPTCHA is available and show Math if not. $connect = @fsockopen(RECAPTCHA_VERIFY_SERVER, 80); if (!$connect) { return captcha_captcha('generate', 'Math', $args); } fclose($connect); // Retrieve configuration variables from database. $recaptcha_secure_connection = variable_get('recaptcha_secure_connection', FALSE); $recaptcha_theme = variable_get('recaptcha_theme', 'red'); $recaptcha_tabindex = variable_get('recaptcha_tabindex', NULL); $recaptcha_public_key = variable_get('recaptcha_public_key', ''); $recaptcha_form_value = NULL; // Construct the Javascript, but only display it once. static $_recaptcha_jsadded = FALSE; if ($_recaptcha_jsadded == FALSE) { $_recaptcha_jsadded = TRUE; $recaptcha_options = array( 'theme' => $recaptcha_theme, ); // Localization support. global $language; if (isset($language->language)) { // reCAPTCHA uses two-character language codes, so 'pt-br' must be // passed as 'pt' (cf. http://wiki.recaptcha.net/index.php/I18n). $recaptcha_options['lang'] = substr($language->language, 0, 2); } // Add support to display the custom theme. if ($recaptcha_theme == 'custom') { $recaptcha_options['custom_theme_widget'] = 'recaptcha_custom_theme_widget'; $recaptcha_form_value = theme('recaptcha_custom_widget'); } // Set the default tab index. if (!empty($recaptcha_tabindex)) { $recaptcha_options['tabindex'] = $recaptcha_tabindex; } drupal_add_js('var RecaptchaOptions = '. drupal_to_js($recaptcha_options) .';', 'inline'); } // Create the form. Captcha requires TRUE to be returned in solution. $captcha['solution'] = TRUE; $captcha['captcha_validate'] = 'recaptcha_captcha_validation'; $html = recaptcha_get_html($recaptcha_public_key, NULL, $recaptcha_secure_connection); $captcha['form']['captcha_response'] = array( '#type' => 'hidden', '#value' => 'reCAPTCHA', ); $captcha['form']['captcha_form'] = array( '#type' => 'item', '#value' => ($recaptcha_form_value ? '