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; } // function recaptcha_help /** * Implementation of hook_menu(). */ function recaptcha_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( 'path' => 'admin/user/captcha/recaptcha', 'title' => t('reCAPTCHA'), 'description' => t('Administer the reCAPTCHA web service.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('recaptcha_admin_settings'), 'access' => user_access('administer recaptcha'), 'type' => MENU_LOCAL_TASK, ); } return $items; } // function recaptcha_menu /** * Valid permissions for this module * @return array An array of valid permissions for the onthisdate module */ function recaptcha_perm() { return array('administer recaptcha'); } // function recaptcha_perm() /** * Implementation of admin settings(). */ function recaptcha_admin_settings() { global $recaptcha_api_server, $recaptcha_api_secure_server, $recaptcha_verify_server; @(include_once('recaptcha/recaptchalib.php')) or _recaptcha_library_not_found(); $form = array(); $form['recaptcha_public_key'] = array( '#type' => 'textfield', '#title' => t('Public Key'), '#default_value' => variable_get('recaptcha_public_key', ''), '#maxlength' => 40, '#description' => t('The public key given to you when you registered at reCAPTCHA.net.', array('@url' => url(recaptcha_get_signup_url($_SERVER['SERVER_NAME'], variable_get('site_name', ''))))), ); $form['recaptcha_private_key'] = array( '#type' => 'textfield', '#title' => t('Private Key'), '#default_value' => variable_get('recaptcha_private_key', ''), '#maxlength' => 40, '#description' => t('The private key given to you when you registered at reCAPTCHA.net.', array('@url' => url(recaptcha_get_signup_url($_SERVER['SERVER_NAME'], variable_get('site_name', ''))))), ); $form['recaptcha_server_settings'] = array( '#type' => 'fieldset', '#title' => t('Server Settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); $form['recaptcha_server_settings']['recaptcha_api_server'] = array( '#type' => 'textfield', '#title' => t('API Server'), '#default_value' => variable_get('recaptcha_api_server', isset($recaptcha_api_server) ? $recaptcha_api_server : 'http://api.recaptcha.net'), '#description' => t('The reCAPTCHA API Server to connect to.'), ); $form['recaptcha_server_settings']['recaptcha_secure_connection'] = array( '#type' => 'checkbox', '#title' => t('Secure Connection'), '#default_value' => variable_get('recaptcha_secure_connection', FALSE), '#description' => t('Connect to the reCAPTCHA server using a secure connection.'), ); $form['recaptcha_server_settings']['recaptcha_api_secure_server'] = array( '#type' => 'textfield', '#title' => t('API Secure Server'), '#default_value' => variable_get('recaptcha_api_secure_server', isset($recaptcha_api_secure_server) ? $recaptcha_api_secure_server : 'https://api-secure.recaptcha.net'), '#description' => t('The secure reCAPTCHA API Server to connect to when using a secure connection.'), ); $form['recaptcha_server_settings']['recaptcha_verify_server'] = array( '#type' => 'textfield', '#title' => t('Verify Server'), '#default_value' => variable_get('recaptcha_verify_server', isset($recaptcha_verify_server) ? $recaptcha_verify_server : 'api-verify.recaptcha.net'), '#description' => t('The server to use to verify the information.'), ); $form['recaptcha_theme_settings'] = array( '#type' => 'fieldset', '#title' => t('Theme Settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); $form['recaptcha_theme_settings']['recaptcha_theme'] = array( '#type' => 'select', '#title' => t('Theme'), '#description' => t('Defines which theme to use for reCAPTCHA.'), '#options' => array( 'red' => t('Red'), 'white' => t('White'), 'blackglass' => t('Black Glass'), ), '#default_value' => variable_get('recaptcha_theme', 'red'), '#required' => TRUE, ); $form['recaptcha_theme_settings']['recaptcha_tabindex'] = array( '#type' => 'textfield', '#title' => t('Tab Index'), '#description' => t('Sets a tabindex for the reCAPTCHA text box. If other elements in the form use a tabindex, this should be set so that navigation is easier for the user.', array('@tabindex' => 'http://www.w3.org/TR/html4/interact/forms.html#adef-tabindex')), '#default_value' => variable_get('recaptcha_tabindex', 0), '#required' => TRUE, '#size' => 4, ); return system_settings_form($form); } // function recaptcha_admin_settings /** * 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); $result = array(); if($captcha_type == "reCAPTCHA") { require_once('recaptcha.inc'); global $recaptcha_api_server, $recaptcha_api_secure_server, $recaptcha_verify_server, $jsadded; @(include_once('recaptcha/recaptchalib.php')) or _recaptcha_library_not_found(); drupal_add_css(drupal_get_path('module', 'recaptcha') . '/recaptcha.css'); $recaptcha_api_server = variable_get('recaptcha_api_server', isset($recaptcha_api_server) ? $recaptcha_api_server : 'http://api.recaptcha.net'); $recaptcha_api_secure_server = variable_get('recaptcha_api_secure_server', isset($recaptcha_api_secure_server) ? $recaptcha_api_secure_server : 'https://api-secure.recaptcha.net'); $recaptcha_verify_server = variable_get('recaptcha_verify_server', isset($recaptcha_verify_server) ? $recaptcha_verify_server : 'api-verify.recaptcha.net'); $recaptcha_theme = variable_get('recaptcha_theme', 'red'); $recaptcha_tabindex = variable_get('recaptcha_tabindex', 0); if(!isset($jsadded)) { $jsadded = TRUE; drupal_add_js("var RecaptchaOptions = {theme : '$recaptcha_theme', tabindex : $recaptcha_tabindex};", 'inline'); } $result['preprocess'] = TRUE; $result['solution'] = TRUE; $result['form']['captcha_challenge'] = array ( '#type' => 'item', '#description' => recaptcha_get_html(variable_get('recaptcha_public_key', ''), NULL, variable_get('recaptcha_secure_connection', FALSE)), ); } return $result; case 'preprocess': require_once('recaptcha.inc'); @(include_once('recaptcha/recaptchalib.php')) or _recaptcha_library_not_found(); $resp = recaptcha_check_answer( variable_get('recaptcha_private_key', ''), $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']); if($resp->is_valid) { return TRUE; } else { form_set_error('captcha_response', t('The reCAPTCHA code you entered was incorrect.')); return FALSE; } break; } } // function recaptcha_captcha