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'))) . '
' . t('You can also head over to the input format settings and add the reCAPTCHA Mailhide input filter to hide posted emails.', array('@inputformats' => url('admin/settings/filters'), '@url' => url('http://mailhide.recaptcha.net'))) . '
'; 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() /** * Let the user know that the reCAPTCHA PHP library is not installed */ function _recaptcha_library_not_found() { global $calledalready; if(!$calledalready) { $calledalready = TRUE; drupal_set_message(t('The reCAPTCHA PHP library was not found. Please install it into %recaptchadir.', array('@url' => 'http://recaptcha.net/plugins/php', '%recaptchadir' => drupal_get_path('module', 'recaptcha') . '/recaptcha')), 'error'); if(!function_exists('recaptcha_get_signup_url')) { function recaptcha_get_signup_url($domain, $appname) { return 'http://recaptcha.net/api/getkey?domain=' . urlencode($domain) . '&appname=' . urlencode($appname); } } if(!function_exists('recaptcha_get_html')) { function recaptcha_get_html($pubkey, $error = null, $use_ssl = false) { return NULL; } } if(!function_exists('recaptcha_check_answer')) { function recaptcha_check_answer($privkey, $remoteip, $challenge, $response) { return NULL; } } if(!function_exists('recaptcha_mailhide_html')) { function recaptcha_mailhide_html($mailhide_pubkey, $mailhide_privkey, $email) { return $email; } } } } // function _recaptcha_library_not_found() /** * 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.'), ); 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") { global $recaptcha_api_server, $recaptcha_api_secure_server, $recaptcha_verify_server; @(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'); $result['preprocess'] = TRUE; $result['value'] = TRUE; $result['form']['captcha_challenge'] = array ( '#type' => 'item', '#description' => recaptcha_get_html(variable_get('recaptcha_public_key', ''), NULL, variable_get('recaptcha_secure_connection', FALSE)), '#weight' => 0, '#required' => TRUE, ); } return $result; case 'process': @(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_answer', t('The reCAPTCHA code you entered was incorrect.')); return FALSE; } break; } } // function recaptcha_captcha /** * reCAPTCHA implementation of hook_filter */ function recaptcha_filter($op, $delta = 0, $format = -1, $text = '') { switch ($op) { case 'list': return array(0 => t('reCAPTCHA Mailhide')); case 'description': return recaptcha_filter_tips($delta, $format); case 'settings': @(include_once('recaptcha/recaptchalib.php')) or _recaptcha_library_not_found(); $form['filter_recaptcha'] = array('#type' => 'fieldset', '#title' => t('reCAPTCHA Mailhide Keys'), '#collapsible' => TRUE, '#collapsed' => FALSE); $form['filter_recaptcha']["recaptcha_mailhide_public_key_$format"] = array( '#type' => 'textfield', '#title' => t('Public Key'), '#default_value' => variable_get("recaptcha_mailhide_public_key_$format", ''), '#maxlength' => 50, '#description' => t('Your public Mailhide key obtained from reCAPTCHA.', array('@url' => 'http://mailhide.recaptcha.net/apikey')), ); $form['filter_recaptcha']["recaptcha_mailhide_private_key_$format"] = array( '#type' => 'textfield', '#title' => t('Private Key'), '#default_value' => variable_get("recaptcha_mailhide_private_key_$format", ''), '#maxlength' => 50, '#description' => t('Your private Mailhide key obtained from reCAPTCHA.', array('@url' => 'http://mailhide.recaptcha.net/apikey')), ); return $form; break; case 'process': global $recaptcha_mailhide_public_key, $recaptcha_mailhide_private_key; @(include_once('recaptcha/recaptchalib.php')) or _recaptcha_library_not_found(); $recaptcha_mailhide_public_key = variable_get("recaptcha_mailhide_public_key_$format", ''); $recaptcha_mailhide_private_key = variable_get("recaptcha_mailhide_private_key_$format", ''); $text = ' ' . $text . ' '; $text = preg_replace_callback("!(|