Index: captcha.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/captcha.info,v retrieving revision 1.3.2.2 diff -u -r1.3.2.2 captcha.info --- captcha.info 10 Jul 2007 22:02:33 -0000 1.3.2.2 +++ captcha.info 26 Sep 2007 09:44:53 -0000 @@ -1,5 +1,4 @@ ; $Id: captcha.info,v 1.3.2.2 2007/07/10 22:02:33 robloach Exp $ -name = Captcha -description = "Base captcha module for adding captcha challenges to registration, comment and contact forms for example." +name = CAPTCHA +description = "Base CAPTCHA module for adding challenges to arbitrary forms." package = "Spam control" -version = "$Name: $" Index: captcha.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/Attic/captcha.install,v retrieving revision 1.1.4.5 diff -u -r1.1.4.5 captcha.install --- captcha.install 20 Sep 2007 01:37:07 -0000 1.1.4.5 +++ captcha.install 26 Sep 2007 09:03:55 -0000 @@ -41,7 +41,7 @@ drupal_set_message(t('The installation of the captcha_points table and some default entries was successful'), 'status'); } else { - drupal_set_message(t('The installation of the captcha module failed'), 'error'); + drupal_set_message(t('The installation of the CAPTCHA module failed'), 'error'); } } Index: captcha.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/captcha.module,v retrieving revision 1.42.2.33 diff -u -r1.42.2.33 captcha.module --- captcha.module 20 Sep 2007 01:37:07 -0000 1.42.2.33 +++ captcha.module 26 Sep 2007 09:48:53 -0000 @@ -3,9 +3,11 @@ /** * @file - * This module enables basic captcha functionality: - * adminstrators can add a captcha to desired forms that users without - * the 'skip captcha' permission (typically anonymous visitors) have to solve. + * This module enables basic CAPTCHA functionality: + * adminstrators can add a CAPTCHA to desired forms that users without + * the 'skip CAPTCHA' permission (typically anonymous visitors) have + * to solve. + * */ define('CAPTCHA_UNSOLVED_CHALLENGES_MAX', 20); @@ -20,8 +22,8 @@ function captcha_help($section = 'admin/help#captcha') { switch ($section) { case 'admin/help#captcha': - $output = '

'. t('A CAPTCHA is a tool to fight automated spam submission of forms (e.g. user registration forms, comment forms, guestbook forms, etc.) by malicious users. A CAPTCHA is an extra field (or several fields) on a form presented to the user. It represents a challenge, which should be easy for a normal human to solve (e.g. a simple math problem), but hard enough to keep automated scripts and spam bots out.') .'

'; - $output .= '

'. t('Note that CAPTCHA interacts with page caching (see performance settings). Because a CAPTCHA should be a unique challenge for each generated form, the caching of the page it appears on is prevented. Make sure that the CAPTCHA enabled forms do not appear on too many pages or you will lose much caching efficiency. For example, if you put a CAPTCHA on the user login block, which typically appears on each page for anonymous visitors, caching will practically be disabled. Another example are the comment submission forms. If untrusted users can post comments (with CAPTCHA protection), you should set the "%commentlocation" to "%separatepage" in the comment settings. for better caching efficiency.' , + $output = '

'. t('"CAPTCHA" is an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart". It is typically a challenge-response test to determine whether the user is human. The CAPTCHA module is a tool to fight automated submission by malicious users (spamming) of for example comments forms, user registration forms, guestbook forms, etc. You can extend the desired forms with an additional challenge, which should be easy for a human to solve correctly, but hard enough to keep automated scripts and spam bots out.') .'

'; + $output .= '

'. t('Note that the CAPTCHA module interacts with page caching (see performance settings). Because the challenge should be unique for each generated form, the caching of the page it appears on is prevented. Make sure that these forms do not appear on too many pages or you will lose much caching efficiency. For example, if you put a CAPTCHA on the user login block, which typically appears on each page for anonymous visitors, caching will practically be disabled. The comment submission forms are another example. In this case you should set the "%commentlocation" to "%separatepage" in the comment settings for better caching efficiency.' , array( '!performancesettings' => url('admin/settings/performance'), '%commentlocation' => t('Location of comment submission form'), @@ -29,18 +31,18 @@ '!commentsettings' => url('admin/content/comment/settings'), ) ) .'

'; + $output .= '

'. t('CAPTCHA is a trademark of Carnegie Mellon University.') .'

'; return $output; case 'admin/user/captcha': case 'admin/user/captcha/captcha': case 'admin/user/captcha/captcha/settings': - return t('

A captcha can be added to virtually each drupal form (which is identified by a form_id). The captcha module comes with some default forms to add a captcha to, but arbitrary forms can be easily added and managed when the option "%adminlinks" is enabled.

Users with the "%skipcaptcha" permission won\'t be offered a captcha. Be sure to grant this permission to the trusted users (e.g. site administrators). If you want to test the captcha challenges, be sure to do it as a user without the "%skipcaptcha" permission (e.g. as unauthenticated user).

', + return t('

A CAPTCHA can be added to virtually each Drupal form. Some default forms are already provided in the form list, but arbitrary forms can be easily added and managed when the option "%adminlinks" is enabled.

Users with the "%skipcaptcha" permission won\'t be offered a challenge. Be sure to grant this permission to the trusted users (e.g. site administrators). If you want to test a protected form, be sure to do it as a user without the "%skipcaptcha" permission (e.g. as anonymous user).

', array( '@perm' => url('admin/user/access'), - '%adminlinks' => t('Add captcha adminstration links to forms'), - '%skipcaptcha' => 'skip captcha challenges', + '%adminlinks' => t('Add CAPTCHA adminstration links to forms'), + '%skipcaptcha' => 'skip CAPTCHA', )); } - return $output; } /** @@ -49,20 +51,20 @@ function captcha_menu($may_cache) { $items = array(); if ($may_cache) { - // main configuration page of the basic captcha module + // main configuration page of the basic CAPTCHA module $items[] = array( 'path' => 'admin/user/captcha', - 'title' => t('Captcha'), - 'description' => t('Administer how and where Captchas are used.'), + 'title' => t('CAPTCHA'), + 'description' => t('Administer how and where CAPTCHAs are used.'), 'callback' => 'captcha_admin', - 'access' => user_access('administer captcha'), + 'access' => user_access('administer CAPTCHA settings'), 'type' => MENU_NORMAL_ITEM, ); - // the default local task (needed when other modules want to offer alternative - // captcha challenges and their own configuration page as local task) + // the default local task (needed when other modules want to offer + // alternative CAPTCHA types and their own configuration page as local task) $items[] = array( 'path' => 'admin/user/captcha/captcha', - 'title' => t('Captcha'), + 'title' => t('CAPTCHA'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -20, ); @@ -75,7 +77,7 @@ $items[] = array( 'path' => 'admin/user/captcha/captcha/examples', 'title' => t('Examples'), - 'description' => t('An overview of the available captcha types with examples.'), + 'description' => t('An overview of the available challenge types with examples.'), 'callback' => 'captcha_examples', 'type' => MENU_LOCAL_TASK, 'weight' => 5, @@ -88,32 +90,32 @@ * Implementation of hook_perm(). */ function captcha_perm() { - return array('administer captcha', 'skip captcha challenges'); + return array('administer captcha', 'skip captcha'); } /** - * Return an array with the available captcha types, for use as options array + * Return an array with the available CAPTCHA types, for use as options array * for a select form elements. - * The array is an associative array mapping "$module/$challenge" to - * "$module/$challenge" with $module the module name implementing the captcha - * challenge and $challenge the name of the challenge type. + * The array is an associative array mapping "$module/$type" to + * "$module/$type" with $module the module name implementing the CAPTCHA + * and $type the name of the CAPTCHA type. * (It also includes a 'none' => 'none' option) */ function _captcha_available_challenge_types() { - $captcha_challenges['none'] = 'none'; + $captcha_types['none'] = 'none'; foreach (module_implements('captcha') as $module) { $result = call_user_func_array($module .'_captcha', 'list'); if (is_array($result)) { - foreach ($result as $challenge) { - $captcha_challenges["$module/$challenge"] = "$challenge ($module)"; + foreach ($result as $type) { + $captcha_types["$module/$type"] = "$type ($module)"; } } } - return $captcha_challenges; + return $captcha_types; } /** - * Get the description which appears above the captcha in forms. + * Get the description which appears above the CAPTCHA in forms. * If the locale module is enabled, an optional language code can be given */ function _captcha_get_description($lang_code=NULL) { @@ -131,80 +133,80 @@ } /** - * General Captcha settings handler. Main entry point for captcha management + * General CAPTCHA settings handler. Main entry point for CAPTCHA management. * * If arguments are given: first argument is used as form_id, the second one * is interpreted as action (such as disable, delete and enable) to execute on * the form_id. - * Otherwise: returns the general captcha configuration form. + * Otherwise: returns the general CAPTCHA configuration form. */ function captcha_admin($form_id='', $op='') { // if $form_id and action $op given: do the action if ($form_id) { switch ($op) { case 'disable': - // disable the captcha for the form: set the module and type to NULL + // disable the CAPTCHA for the form: set the module and type to NULL db_query("UPDATE {captcha_points} SET module = NULL, type = NULL WHERE form_id = '%s'", $form_id); - drupal_set_message(t('Disabled captcha for form %form_id.', array('%form_id' => $form_id))); - // goto the captcha adminstration or alternative destination if present in URI + drupal_set_message(t('Disabled CAPTCHA for form %form_id.', array('%form_id' => $form_id))); + // goto the CAPTCHA adminstration or alternative destination if present in URI drupal_goto('admin/user/captcha'); break; case 'delete': db_query("DELETE FROM {captcha_points} WHERE form_id = '%s'", $form_id); - drupal_set_message(t('Deleted captcha for form %form_id.', array('%form_id' => $form_id))); - // goto the captcha adminstration or alternative destination if present in URI + drupal_set_message(t('Deleted CAPTCHA for form %form_id.', array('%form_id' => $form_id))); + // goto the CAPTCHA adminstration or alternative destination if present in URI drupal_goto('admin/user/captcha'); break; case 'enable': db_query("DELETE FROM {captcha_points} WHERE form_id = '%s'", $form_id); db_query("INSERT INTO {captcha_points} (form_id, module, type) VALUES ('%s', NULL, NULL)", $form_id); - // No drupal_goto() call because we have to go to the captcha adminstration + // No drupal_goto() call because we have to go to the CAPTCHA adminstration // form and not a different destination if that would be present in the // URI. So we call this form explicitly. The destination will be preserved // so after completing the form, the user will still be redirected. return drupal_get_form('captcha_captcha_point_settings_form', $form_id); break; } - // return edit form for individual form (aka captcha point) + // return edit form for individual form (aka CAPTCHA point) return drupal_get_form('captcha_captcha_point_settings_form', $form_id); } - // no $form_id or legal action given: generate general captcha settings form + // no $form_id or legal action given: generate general CAPTCHA settings form return drupal_get_form('captcha_admin_settings'); } /** - * Form builder function for the general captcha configuration + * Form builder function for the general CAPTCHA configuration */ function captcha_admin_settings() { - // field for the captcha adminstration mode + // field for the CAPTCHA adminstration mode $form['captcha_administration_mode'] = array( '#type' => 'checkbox', - '#title' => t('Add captcha adminstration links to forms'), + '#title' => t('Add CAPTCHA adminstration links to forms'), '#default_value' => variable_get('captcha_administration_mode', FALSE), - '#description' => t('This option is very helpful to enable/disable captchas on forms. When enabled, users with the "%admincaptcha" permission will see captcha administration links on all forms (except on administrative pages, which shouldn\'t be accessible to untrusted users in the first place).', array('%admincaptcha' => 'administer captcha')), + '#description' => t('This option is very helpful to enable/disable challenges on forms. When enabled, users with the "%admincaptcha" permission will see CAPTCHA administration links on all forms (except on administrative pages, which shouldn\'t be accessible to untrusted users in the first place). These links make it possible to enable a challenge of the desired type or disable it.', array('%admincaptcha' => 'administer captcha')), ); - // field set with form_id -> captcha type configuration + // field set with form_id -> CAPTCHA type configuration $form['captcha_types'] = array( '#type' => 'fieldset', - '#title' => t('Select captcha types'), - '#description' => t('Select what kind of captcha challenge you want for each form.'), + '#title' => t('Challenge type per form'), + '#description' => t('Select the challenge type you want for each of the listed forms (identified by their so called form_id\'s). You can easily add arbitrary forms with the help of the \'%CAPTCHA_admin_links\' option.', array('%CAPTCHA_admin_links'=>t('Add CAPTCHA adminstration links to forms'))), '#tree' => TRUE, '#collapsible' => TRUE, '#collapsed' => FALSE, '#theme' => 'captcha_admin_settings_captcha_points', ); // list all possible form_id's - $captcha_challenges = _captcha_available_challenge_types(); + $captcha_types = _captcha_available_challenge_types(); $result = db_query("SELECT * FROM {captcha_points} ORDER BY form_id"); while ($captcha_point = db_fetch_object($result)) { $form['captcha_types'][$captcha_point->form_id]['form_id'] = array( '#value' => $captcha_point->form_id, ); - // select widget for captcha type + // select widget for CAPTCHA type $form['captcha_types'][$captcha_point->form_id]['captcha_type'] = array( '#type' => 'select', '#default_value' => "{$captcha_point->module}/{$captcha_point->type}", - '#options' => $captcha_challenges, + '#options' => $captcha_types, ); // additional operations $form['captcha_types'][$captcha_point->form_id]['operations'] = array( @@ -213,19 +215,19 @@ )) ); } - // field(s) for setting the additional captcha description + // field(s) for setting the additional CAPTCHA description if (module_exists('locale')) { global $locale; $langs = locale_supported_languages(); $form['captcha_descriptions'] = array( '#type' => 'fieldset', - '#title' => t('Captcha description'), - '#description' => t('With this description you can explain the purpose of the captcha challenge to the user.'), + '#title' => t('Challenge description'), + '#description' => t('With this description you can explain the purpose of the challenge to the user.'), ); foreach ($langs['name'] as $lang_code => $lang_name) { $form['captcha_descriptions']["captcha_description_$lang_code"] = array( '#type' => 'textfield', - '#title' => t('Captcha description for %lang_name (locale %lang_code)', array('%lang_name' => $lang_name, '%lang_code' => $lang_code)), + '#title' => t('For language %lang_name (code %lang_code)', array('%lang_name' => $lang_name, '%lang_code' => $lang_code)), '#default_value' => _captcha_get_description($lang_code), '#maxlength' => 256, ); @@ -233,24 +235,24 @@ } else { $form['captcha_description'] = array( - '#type' => 'textfield', - '#title' => t('Captcha description'), - '#description' => t('With this description you can explain the purpose of the captcha challenge to the user.'), - '#default_value' => _captcha_get_description(), - '#maxlength' => 256, - ); + '#type' => 'textfield', + '#title' => t('Challenge description'), + '#description' => t('With this description you can explain the purpose of the challenge to the user.'), + '#default_value' => _captcha_get_description(), + '#maxlength' => 256, + ); } - // field for captcha persistence + // field for CAPTCHA persistence $form['captcha_persistence'] = array( '#type' => 'radios', - '#title' => t('CAPTCHA persistence'), + '#title' => t('Persistence'), '#default_value' => variable_get('captcha_persistence', CAPTCHA_PERSISTENCE_SHOW_ALWAYS), '#options' => array( - CAPTCHA_PERSISTENCE_SHOW_ALWAYS => t('Always add a CAPTCHA.'), - CAPTCHA_PERSISTENCE_SKIP_ONCE_SUCCESSFUL_PER_FORM => t('Omit CAPTCHA for a form once the user has successfully answered a CAPTCHA for that form.'), - CAPTCHA_PERSISTENCE_SKIP_ONCE_SUCCESSFUL => t('Omit CAPTCHA for all forms once the user has successfully answered a CAPTCHA.'), + CAPTCHA_PERSISTENCE_SHOW_ALWAYS => t('Always add a challenge.'), + CAPTCHA_PERSISTENCE_SKIP_ONCE_SUCCESSFUL_PER_FORM => t('Omit challenges for a form once the user has successfully responded to a challenge for that form.'), + CAPTCHA_PERSISTENCE_SKIP_ONCE_SUCCESSFUL => t('Omit challenges for all forms once the user has successfully responded to a challenge.'), ), - '#description' => t('Define if CAPTCHAs should be omitted during the rest of a session once the user successfully answers a CAPTCHA.'), + '#description' => t('Define if challenges should be omitted during the rest of a session once the user successfully responses to a challenge.'), ); // submit button $form['submit'] = array( @@ -261,7 +263,7 @@ } /** - * Custom theme function for a table of (form_id -> captcha type) settings + * Custom theme function for a table of (form_id -> CAPTCHA type) settings */ function theme_captcha_admin_settings_captcha_points($form) { foreach (element_children($form) as $key) { @@ -271,7 +273,7 @@ $row[] = drupal_render($form[$key]['operations']); $rows[] = $row; } - $header = array('form_id', t('Captcha type (module)'), t('Operations')); + $header = array('form_id', t('Challenge type (module)'), t('Operations')); $output = theme('table', $header, $rows); return $output; } @@ -302,12 +304,12 @@ variable_set('captcha_description', $form_values['captcha_description']); } variable_set('captcha_persistence', $form_values['captcha_persistence']); - drupal_set_message(t('Your captcha settings were saved.'), 'status'); + drupal_set_message(t('The CAPTCHA settings were saved.'), 'status'); } } /** - * form generating function for captcha point settings + * form generating function for CAPTCHA point settings */ function captcha_captcha_point_settings_form($form_id) { $result = db_query("SELECT * FROM {captcha_points} WHERE form_id = '%s'", $form_id); @@ -318,10 +320,10 @@ '#type' => 'hidden', '#value' => $captcha_point->form_id, ); - // select widget for captcha type + // select widget for CAPTCHA type $form['captcha_type'] = array( '#type' => 'select', - '#title' => t('Select the CAPTCHA for @form_id', array('@form_id' => $form_id)), + '#title' => t('Select the challenge for @form_id', array('@form_id' => $form_id)), '#default_value' => "{$captcha_point->module}/{$captcha_point->type}", '#options' => _captcha_available_challenge_types(), ); @@ -340,7 +342,7 @@ else { // illegal form_id drupal_set_message(t('Unavailable form_id %form_id ', array('%form_id' => $form_id)), 'error'); - // goto the captcha adminstration or alternative destination if present in URI + // goto the CAPTCHA adminstration or alternative destination if present in URI drupal_goto('admin/user/captcha'); } } @@ -377,14 +379,15 @@ /** * Implementation of hook_form_alter(). * - * This function adds a captcha to forms for untrusted users if needed and adds - * captcha adminstration links for site adminstrators if this option is enabled. + * This function adds a CAPTCHA to forms for untrusted users if needed and adds + * CAPTCHA adminstration links for site adminstrators if this option is enabled. */ function captcha_form_alter($form_id, &$form) { - if (!user_access('skip captcha challenges')) { - // Visitor does not have permission to skip the captcha challenge - // Get captcha type and module for this form. Return if no captcha was set. + if (!user_access('skip captcha')) { + // Visitor does not have permission to skip the CAPTCHA + + // Get CAPTCHA type and module for this form. Return if no CAPTCHA was set. $result = db_query("SELECT module, type FROM {captcha_points} WHERE form_id = '%s'", $form_id); if (!$result) { return; @@ -401,45 +404,45 @@ global $conf; $conf['cache'] = FALSE; - // Do not present captcha if not captcha-persistent and user has already solved a captcha for this form + // Do not present CAPTCHA if not CAPTCHA-persistent and user has already solved a CAPTCHA for this form if (_captcha_persistence_skip($form_id)) { return; } - // Generate a captcha challenge and its solution + // Generate a CAPTCHA and its solution $captcha = module_invoke($captcha_point->module, 'captcha', 'generate', $captcha_point->type); if (!$captcha) { //The selected module returned nothing, maybe it is disabled or it's wrong, we should watchdog that and then quit. - watchdog('captcha', - t('Captcha problem: hook_captcha() of module %module returned nothing when trying to retrieve captcha type %type for form %form_id.', + watchdog('CAPTCHA', + t('CAPTCHA problem: hook_captcha() of module %module returned nothing when trying to retrieve challenge type %type for form %form_id.', array('%type' => $captcha_point->type, '%module' => $captcha_point->module, '%form_id' => $form_id)), WATCHDOG_ERROR); return; } - // Add a captcha part to the form (depends on value of captcha_description) + // Add a CAPTCHA part to the form (depends on value of captcha_description) $captcha_description = _captcha_get_description(); if ($captcha_description) { - // $captcha_description is not empty: captcha part is a fieldset with description + // $captcha_description is not empty: CAPTCHA part is a fieldset with description $form['captcha'] = array( '#type' => 'fieldset', - '#title' => t('Captcha'), + '#title' => t('CAPTCHA'), '#description' => $captcha_description, ); } else { - // $captcha_description is empty: captcha part is an empty markup form element + // $captcha_description is empty: CAPTCHA part is an empty markup form element $form['captcha'] = array(); } - // Add the form elements of the generated captcha challenge to the form + // Add the form elements of the generated CAPTCHA to the form $form['captcha'] = array_merge($form['captcha'], $captcha['form']); - // Store the solution of the generated captcha challenge as an internal form value. + // Store the solution of the generated CAPTCHA as an internal form value. // This will be stored later in $_SESSION during the pre_render phase. // It can't be saved at this point because hook_form_alter is not only run // before form rendering, but also before form validation (which happens - // in a new (POST) request. Consequently the right captcha solution would be + // in a new (POST) request. Consequently the right CAPTCHA solution would be // overwritten just before validation. The pre_render functions are not run // before validation and are the right place to store the solution in $_SESSION. $form['captcha']['captcha_solution'] = array( @@ -447,9 +450,9 @@ '#value' => $captcha['solution'], ); - // The captcha token is used to differentiate between different instances + // The CAPTCHA token is used to differentiate between different instances // of the same form. This makes it possible to request the same form a - // couple of times before submitting them. The solution of the captcha of + // couple of times before submitting them. The solution of the CAPTCHA of // each of these form instances will be stored at the pre_render phase in // $_SESSION['captcha'][$form_id][$captcha_token] $form['captcha']['captcha_token'] = array( @@ -471,12 +474,12 @@ // handle the pre_render functions $form['#pre_render'] = ((array) $form['#pre_render']) + array('captcha_pre_render', 'captcha_pre_render_place_captcha'); - // Add a validation function for the captcha part of the form + // Add a validation function for the CAPTCHA part of the form $form['captcha']['#validate'] = ((array) $form['captcha']['#validate']) + array('captcha_validate' => array()); } elseif (user_access('administer captcha') && variable_get('captcha_administration_mode', FALSE) && arg(0) != 'admin') { - // For administrators: show captcha info and offer link to configure it + // For administrators: show CAPTCHA info and offer link to configure it $result = db_query("SELECT module, type FROM {captcha_points} WHERE form_id = '%s'", $form_id); if (!$result) { return; @@ -485,24 +488,24 @@ if ($captcha_point->type) { $form['captcha'] = array( '#type' => 'item', - '#title' => t('Captcha administration'), - '#description' => t('The captcha "@type" (by module "@module") is enabled here for untrusted users: !edit, !disable or !general.', array( + '#title' => t('CAPTCHA administration'), + '#description' => t('The challenge "@type" (by module "@module") is enabled here for untrusted users: !edit, !disable or !general.', array( '@type' => $captcha_point->type, '@module' => $captcha_point->module, - '!edit' => l(t('edit captcha type'), "admin/user/captcha/$form_id", array(), drupal_get_destination()), - '!disable' => l(t('disable captcha'), "admin/user/captcha/$form_id/disable", array(), drupal_get_destination()), - '!general' => l(t('general captcha settings'), "admin/user/captcha"), + '!edit' => l(t('edit challenge type'), "admin/user/captcha/$form_id", array(), drupal_get_destination()), + '!disable' => l(t('disable challenge'), "admin/user/captcha/$form_id/disable", array(), drupal_get_destination()), + '!general' => l(t('edit general challenge settings'), "admin/user/captcha"), )) ); } else { $form['captcha'] = array( '#type' => 'item', - '#title' => t('Captcha administration'), - '#description' => l(t('Place a captcha challenge here for untrusted users.'), "admin/user/captcha/$form_id/enable", array(), drupal_get_destination()), + '#title' => t('CAPTCHA administration'), + '#description' => l(t('Place a challenge here for untrusted users.'), "admin/user/captcha/$form_id/enable", array(), drupal_get_destination()), ); } - // Add pre_render function for placing the captcha just above the submit button + // Add pre_render function for placing the CAPTCHA just above the submit button $form['#pre_render'] = ((array) $form['#pre_render']) + array('captcha_pre_render_place_captcha'); } } @@ -521,7 +524,7 @@ $captcha_token = $form_values['#post']['captcha_token']; // Check if captcha_token exists if (!isset($_SESSION['captcha'][$form_id][$captcha_token])) { - form_set_error('captcha_token', t('Invalid captcha token.')); + form_set_error('captcha_token', t('Invalid CAPTCHA token.')); } // Check answer if ($captcha_response === $_SESSION['captcha'][$form_id][$captcha_token]) { @@ -529,7 +532,7 @@ $_SESSION['captcha']['success'] = TRUE; } else { - form_set_error('captcha_response', t('The answer you entered for the captcha challenge was not correct.')); + form_set_error('captcha_response', t('The answer you entered for the CAPTCHA was not correct.')); // If CAPTCHA was on a login form: stop validating, quit the current request // and forward to the current page (like a reload) to prevent loging in. // We do that because the log in procedure, which happens after @@ -540,9 +543,9 @@ } } - // Unset the solution to prevent reuse of the same captcha solution + // Unset the solution to prevent reuse of the same CAPTCHA solution // by a spammer that repeats posting a form without requesting - // (and thus rendering) a new form. Note that a new captcha solution is only + // (and thus rendering) a new form. Note that a new CAPTCHA solution is only // set at the pre_render phase. unset($_SESSION['captcha'][$form_id][$captcha_token]); } @@ -550,35 +553,35 @@ /** * Implementation of form #pre_render. * - * The main purpose of this function is to store the solution of the captcha - * challenge in the $_SESSION variable. + * The main purpose of this function is to store the solution of the CAPTCHA + * in the $_SESSION variable. */ function captcha_pre_render($form_id, &$form) { - // Unset the captcha challenge if non-captcha persistent and the captcha has + // Unset the CAPTCHA if non-CAPTCHA persistent and the CAPTCHA has // already been successfully solved for this form. // This needs to be done in this pre_render phase when previewing for example // nodes and comments before submission. // On submission of such a forms for preview, captcha_form_alter() is called - // *before* the captcha validation function (which sets + // *before* the CAPTCHA validation function (which sets // $_SESSION['captcha'][$form_id]['success'] to TRUE on a correctly answered - // captcha). After this the form_values are entered in the generated form + // CAPTCHA). After this the form_values are entered in the generated form // and this form is presented with the preview. - // This means that captcha_form_alter() can't know if the captcha was - // correctly answered and consequently adds a captcha challenge to the form. + // This means that captcha_form_alter() can't know if the CAPTCHA was + // correctly answered and consequently adds a CAPTCHA to the form. // The pre_render phase happens after the validation phase and makes it - // possible to remove the captcha from the form after all. + // possible to remove the CAPTCHA from the form after all. if (_captcha_persistence_skip($form_id)) { unset($form['captcha']); return; } - // count the number of unsolved captcha challenges and flush those if too many + // count the number of unsolved CAPTCHAs and flush those if too many // minus 1 is needed because 'success' is also an item of $_SESSION['captcha'][$form_id] if (count($_SESSION['captcha'][$form_id]) - 1 > CAPTCHA_UNSOLVED_CHALLENGES_MAX) { unset($_SESSION['captcha'][$form_id]); - drupal_set_message(t('You can\'t request more than @num captcha challenges without solving them. Your previous captcha challenges were flushed.', array('@num' => CAPTCHA_UNSOLVED_CHALLENGES_MAX))); + drupal_set_message(t('You can\'t request more than @num challenges without solving them. Your previous challenges were flushed.', array('@num' => CAPTCHA_UNSOLVED_CHALLENGES_MAX))); } - // store the current captcha solution in $_SESSION + // store the current CAPTCHA solution in $_SESSION $captcha_token = $form['captcha']['captcha_token']['#value']; $_SESSION['captcha'][$form_id][$captcha_token] = $form['captcha']['captcha_solution']['#value']; $_SESSION['captcha'][$form_id]['success'] = FALSE; @@ -587,7 +590,7 @@ } /** - * Pre_render function to place the captcha form element just above the last submit button + * Pre_render function to place the CAPTCHA form element just above the last submit button */ function captcha_pre_render_place_captcha($form_id, &$form) { // search the weights of the buttons in the form @@ -598,7 +601,7 @@ } } if ($button_weights) { - // set the weight of the captcha element a tiny bit smaller than the lightest button weight + // set the weight of the CAPTCHA element a tiny bit smaller than the lightest button weight // (note that the default resolution of #weight values is 1/1000 (see drupal/includes/form.inc)) $first_button_weight = min($button_weights); $form['captcha']['#weight'] = $first_button_weight - 0.5/1000.0; @@ -608,18 +611,18 @@ } /** - * Funtion for generating a page with captcha challenge examples + * Funtion for generating a page with CAPTCHA examples * If the arguments $module and $challenge are not set, generate a list with - * examples of the available captcha challenge types. + * examples of the available CAPTCHA types. * If $module and $challenge are set, generate 10 examples of the concerning - * challenge. + * CAPTCHA. */ function captcha_examples($module=NULL, $challenge=NULL) { if ($module && $challenge) { // generate 10 examples $output = ''; for ($i=0; $i<10; $i++) { - // generate captcha challenge + // generate CAPTCHA $captcha = call_user_func_array($module .'_captcha', array('generate', $challenge)); $form = $captcha['form']; $id = "captcha_examples_$module_$challenge_$i"; @@ -628,13 +631,13 @@ } } else { - // generate a list with examples of the available challenges - $output = t('This page gives an overview of all available captcha types, generated with their current settings.'); + // generate a list with examples of the available CAPTCHA types + $output = t('This page gives an overview of all available challenge types, generated with their current settings.'); foreach (module_implements('captcha') as $module) { $challenges = call_user_func_array($module .'_captcha', 'list'); if ($challenges) { foreach ($challenges as $challenge) { - // generate captcha challenge + // generate CAPTCHA $captcha = call_user_func_array($module .'_captcha', array('generate', $challenge)); // build form $form = array(); @@ -645,7 +648,7 @@ $form['captcha'] = array_merge($form['captcha'], $captcha['form']); $form['captcha']['more_examples'] = array( '#type' => 'markup', - '#value' => l(t('10 more examples of this captcha type.'), "admin/user/captcha/captcha/examples/$module/$challenge"), + '#value' => l(t('10 more examples of this challenge.'), "admin/user/captcha/captcha/examples/$module/$challenge"), ); // return rendered form $id = "captcha_examples_$module_$challenge"; Index: captcha_api.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/Attic/captcha_api.txt,v retrieving revision 1.1.4.6 diff -u -r1.1.4.6 captcha_api.txt --- captcha_api.txt 20 Sep 2007 01:37:07 -0000 1.1.4.6 +++ captcha_api.txt 26 Sep 2007 09:03:55 -0000 @@ -1,26 +1,26 @@ -This documentation is for developers that want to implement their own captcha -challenge and integrate it with the base captcha module. +This documentation is for developers that want to implement their own CAPTCHA +and integrate it with the base CAPTCHA module. === Required: hook_captcha($op, $captcha_type='') === The hook_captcha() hook is the only required function if you want to integrate -with the base captcha module. +with the base CAPTCHA module. Functionality depends on the first argument $op: - * 'list': you should return an array of possible captcha type names that your + * 'list': you should return an array of possible CAPTCHA type names that your module implements. - * 'generate': generate a captcha challenge. + * 'generate': generate a CAPTCHA. You should return an array that offers form elements and the solution - of your captcha challenge, defined by the second argument $captcha_type. + of your CAPTCHA, defined by the second argument $captcha_type. The returned array $captcha should have the following items: - $captcha['solution']: this is the solution of your captcha challenge + $captcha['solution']: this is the solution of your CAPTCHA $captcha['form']: an array of the form elements you want to add to the form. There should be a key 'captcha_response' in this array, which points to the form element where the user enters his answer. Let's give a simple example to make this more clear. -We create the captcha challenge 'Foo captcha', which requires the user to +We create the CAPTCHA type 'Foo CAPTCHA', which requires the user to enter "foo" in a textfield. """ @@ -30,9 +30,9 @@ function foo_captcha_captcha($op, $captcha_type='') { switch ($op) { case 'list': - return array("Foo captcha"); + return array('Foo CAPTCHA'); case 'generate': - if ($captcha_type == "Foo captcha") { + if ($captcha_type == 'Foo CAPTCHA') { $captcha = array(); $captcha['solution'] = 'foo'; $captcha['form']['captcha_response'] = array( @@ -47,22 +47,22 @@ """ Validation of the answer against the solution and other stuff is done by the -base captcha module. +base CAPTCHA module. === Required: the .info file === -You should specify that your module depends on the base captcha module. +You should specify that your module depends on the base CAPTCHA module. Optionally you could put your module in the "Spam control" package. -For our simple foo captcha module this would mean the following lines in the +For our simple foo CAPTCHA module this would mean the following lines in the file foo_captcha.info: """ -name = "Foo captcha" -description = "The foo captcha requires the user to enter the word 'foo'." +name = "Foo CAPTCHA" +description = "The foo CAPTCHA requires the user to enter the word 'foo'." package = "Spam control" dependencies = captcha """ @@ -72,11 +72,11 @@ === Recommended: hook_menu($may_cache) === -More advanced captcha modules probably want some configuration page. To integrate -nicely with the captcha module you should offer your configuration page as a +More advanced CAPTCHA modules probably want some configuration page. To integrate +nicely with the CAPTCHA module you should offer your configuration page as a MENU_LOCAL_TASK menu entry under 'admin/user/captcha/'. -For our simple foo captcha module this would mean: +For our simple foo CAPTCHA module this would mean: """ /** @@ -87,7 +87,7 @@ if ($may_cache) { $items[] = array( 'path' => 'admin/user/captcha/foo_captcha', - 'title' => t('Foo captcha'), + 'title' => t('Foo CAPTCHA'), 'callback' => 'drupal_get_form', 'callback arguments' => array('foo_captcha_settings_form'), 'type' => MENU_LOCAL_TASK, @@ -104,10 +104,10 @@ === Optional: hook_help($section) === -To offer a description/explanation of your captcha challenge, you can use the +To offer a description/explanation of your CAPTCHA, you can use the normal hook_help() system. -For our simple foo captcha module this would mean: +For our simple foo CAPTCHA module this would mean: """ /** @@ -116,16 +116,15 @@ function foo_captcha_help($section) { switch ($section) { case 'admin/user/captcha/foo_captcha': - return '

'. t('This is a very simple captcha, which requires users to enter "foo" in a textfield.') .'

'; + return '

'. t('This is a very simple CAPTCHA, which requires users to enter "foo" in a textfield.') .'

'; } - return $output; } """ === Optional: preprocess the response === In some situations it could be necessary to preprocess the response before -letting the captcha module validate it. For example: if you want the validation +letting the CAPTCHA module validate it. For example: if you want the validation to be case insensitive, you could convert the reponse to lower case. To enable response preprocessing: @@ -137,7 +136,7 @@ switch($op) { ... case 'generate': - if ($captcha_type == "Foo captcha") { + if ($captcha_type == 'Foo CAPTCHA') { ... $captcha['preprocess'] = TRUE, ... @@ -151,7 +150,7 @@ switch($op) { ... case 'preprocess': - if ($captcha_type == "Foo captcha") { + if ($captcha_type == 'Foo CAPTCHA') { return strtolower($response); } break; Index: image_captcha/image_captcha.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/image_captcha/Attic/image_captcha.info,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 image_captcha.info --- image_captcha/image_captcha.info 10 Jul 2007 22:02:34 -0000 1.1.4.2 +++ image_captcha/image_captcha.info 26 Sep 2007 09:44:54 -0000 @@ -1,6 +1,5 @@ ; $Id: image_captcha.info,v 1.1.4.2 2007/07/10 22:02:34 robloach Exp $ -name = "Image captcha" -description = "Captcha module that implements image based captchas." +name = "Image CAPTCHA" +description = "Provides an image based CAPTCHA." package = "Spam control" dependencies = captcha -version = "$Name: $" Index: image_captcha/image_captcha.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/image_captcha/Attic/image_captcha.module,v retrieving revision 1.1.4.18 diff -u -r1.1.4.18 image_captcha.module --- image_captcha/image_captcha.module 18 Sep 2007 13:18:55 -0000 1.1.4.18 +++ image_captcha/image_captcha.module 26 Sep 2007 09:03:55 -0000 @@ -2,7 +2,7 @@ // $Id: image_captcha.module,v 1.1.4.18 2007/09/18 13:18:55 robloach Exp $ /** - * Implementation of image captcha challenge for use with the captcha module + * Implementation of image CAPTCHA for use with the CAPTCHA module * * Loosely Based on MyCaptcha by Heine Deelstra * (http://heine.familiedeelstra.com/mycaptcha-download) @@ -17,11 +17,11 @@ function image_captcha_help($section) { switch ($section) { case 'admin/user/captcha/image_captcha': - $output = '

'. t('The image captcha is a popular type of captcha challenge where a random textual code is obfuscated in an image. The image is generated on the fly for each request, which is rather CPU intensive for the server. Be carefull with the size and computation related settings.') .'

'; + $output = '

'. t('The image CAPTCHA is a popular challenge where a random textual code is obfuscated in an image. The image is generated on the fly for each request, which is rather CPU intensive for the server. Be carefull with the size and computation related settings.') .'

'; if (in_array('Image', image_captcha_captcha('list'))) { $result = image_captcha_captcha('generate', 'Image'); $img = $result['form']['captcha_image']['#value']; - $output .= t('

Example captcha image, generated with the current settings:

!img', array('!img' => $img)); + $output .= t('

Example image, generated with the current settings:

!img', array('!img' => $img)); } return $output; } @@ -36,10 +36,9 @@ // add an administration tab for image_captcha $items[] = array( 'path' => 'admin/user/captcha/image_captcha', - 'title' => t('Image captcha'), + 'title' => t('Image CAPTCHA'), 'callback' => 'drupal_get_form', 'callback arguments' => array('image_captcha_settings_form'), - 'access' => user_access('administer captcha'), 'type' => MENU_LOCAL_TASK, ); // callback for generating an image @@ -55,7 +54,7 @@ /** * Returns: - * - the path to the image captcha font or FALSE when an error occured + * - the path to the image CAPTCHA font or FALSE when an error occured * - error message */ @@ -68,7 +67,7 @@ } elseif (!is_file($font) || !is_readable($font)) { $font = FALSE; - $errmsg = t('Could not find or read the configured font "%font" for the image captcha.', array('%font' => $font)); + $errmsg = t('Could not find or read the configured font "%font" for the image CAPTCHA.', array('%font' => $font)); } return array($font, $errmsg); } @@ -95,7 +94,7 @@ */ function image_captcha_settings_form() { if (!function_exists('imagejpeg')) { - drupal_set_message(t('Image captchas cannot be generated, because your PHP installation\'s GD library has no JPEG support.'), 'error'); + drupal_set_message(t('Images cannot be generated, because your PHP installation\'s GD library has no JPEG support.'), 'error'); } $form = array(); $form['image_captcha_image_allowed_chars'] = array( @@ -114,7 +113,7 @@ // font related stuff $available_fonts = _image_captcha_available_fonts(); if (empty($available_fonts)) { - drupal_set_message(t('The image captcha module requires a TrueType font file (.ttf) for generating the images, but because of licencing issues it is not allowed to package fonts with the module. You can install fonts yourself however, by putting them in the fonts directory of the image captcha module (directory "%fontsdir") or by uploading them to your Drupal file system (directory "%filesdir") with for example the upload module.', array('%fontsdir' => drupal_get_path('module', 'image_captcha') .'/fonts', '%filesdir' => file_directory_path())), 'error'); + drupal_set_message(t('A TrueType font file (.ttf) is required for generating the images, but because of licencing issues it is not allowed to package fonts with the module. You can install fonts yourself however, by putting them in the fonts directory of the image CAPTCHA module (directory "%fontsdir") or by uploading them to your Drupal file system (directory "%filesdir") with for example the upload module.', array('%fontsdir' => drupal_get_path('module', 'image_captcha') .'/fonts', '%filesdir' => file_directory_path())), 'error'); return array(); } else { @@ -128,7 +127,7 @@ '#type' => 'select', '#title' => t('Font'), '#default_value' => $default_font, - '#description' => t('The TrueType font (.ttf) to use for the text in the image captcha.'), + '#description' => t('Select the TrueType font (.ttf) to use.'), '#options' => $available_fonts, ); } @@ -278,7 +277,7 @@ function image_captcha_captcha($op, $captcha_type='') { switch ($op) { case 'list': - // only offer image captcha if possible to generate an image captcha + // only offer image CAPTCHA if possible to generate an image CAPTCHA list($font, $errmsg) = _image_captcha_get_font(); if (function_exists('imagejpeg') && $font) { return array('Image'); @@ -290,12 +289,12 @@ if ($captcha_type == 'Image') { // In offline mode, the image CAPTCHA does not work because the request // for the image itself won't succeed (only ?q=user is permitted for - // unauthenticated users). We fall back to the Math Captcha in that case. + // unauthenticated users). We fall back to the Math CAPTCHA in that case. global $user; if (variable_get('site_offline', FALSE) && $user->uid == 0) { return captcha_captcha('generate', 'Math'); } - // generate a captcha code + // generate a CAPTCHA code $allowed_chars = _image_captcha_utf8_split(variable_get('image_captcha_image_allowed_chars', IMAGE_CAPTCHA_ALLOWED_CHARACTERS)); $code_length = (int)variable_get('image_captcha_code_length', 5); $code = ''; @@ -328,7 +327,7 @@ } /** - * menu callback function that generates the captcha image + * menu callback function that generates the CAPTCHA image */ function image_captcha_image($seed=NULL) { if (!$seed) { @@ -336,7 +335,7 @@ } // get the code to draw from $_SESSION $code = $_SESSION['image_captcha'][$seed]; - // unset the code from $_SESSION to prevent rerendering the captcha + // unset the code from $_SESSION to prevent rerendering the CAPTCHA unset($_SESSION['image_captcha'][$seed]); // only generate an image if there is an code if ($code) { Index: text_captcha/text_captcha.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/text_captcha/Attic/text_captcha.info,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 text_captcha.info --- text_captcha/text_captcha.info 10 Jul 2007 22:02:35 -0000 1.1.4.2 +++ text_captcha/text_captcha.info 26 Sep 2007 09:44:55 -0000 @@ -1,6 +1,5 @@ ; $Id: text_captcha.info,v 1.1.4.2 2007/07/10 22:02:35 robloach Exp $ -name = "Text captcha" -description = "Captcha module that implements a simple text based captcha." +name = "Text CAPTCHA" +description = "Provides a simple text based CAPTCHA." package = "Spam control" dependencies = captcha -version = "$Name: $" Index: text_captcha/text_captcha.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/text_captcha/Attic/text_captcha.module,v retrieving revision 1.1.4.10 diff -u -r1.1.4.10 text_captcha.module --- text_captcha/text_captcha.module 19 Sep 2007 15:42:39 -0000 1.1.4.10 +++ text_captcha/text_captcha.module 26 Sep 2007 09:03:55 -0000 @@ -3,7 +3,7 @@ /** - * Implementation of a simple text based captcha, for use with the captcha module + * Implementation of a simple text based CAPTCHA, for use with the CAPTCHA module */ define('TEXT_CAPTCHA_GENERATE_NONSENSE_WORDS', 0); @@ -16,7 +16,7 @@ function text_captcha_help($section) { switch ($section) { case 'admin/user/captcha/text_captcha': - return '

'. t('This text based captcha presents a captcha phrase of a given number of words and the visitor is asked to enter the n\'th word.') .'

'; + return '

'. t('In this challenge the visitor is asked for the nth word of a given phrase.') .'

'; } return $output; } @@ -30,10 +30,9 @@ // add an administration tab for text_captcha $items[] = array( 'path' => 'admin/user/captcha/text_captcha', - 'title' => t('Text captcha'), + 'title' => t('Text CAPTCHA'), 'callback' => 'drupal_get_form', 'callback arguments' => array('text_captcha_settings_form'), - 'access' => user_access('administer captcha'), 'type' => MENU_LOCAL_TASK, ); } @@ -48,7 +47,7 @@ // radio buttons for selecting the kind of words to use $form['text_captcha_words'] = array( '#type' => 'radios', - '#title' => t('Kind of words to use in the captcha phrase'), + '#title' => t('Kind of words to use in the phrase'), '#options' => array( TEXT_CAPTCHA_GENERATE_NONSENSE_WORDS => t('Generate nonsense random words.'), TEXT_CAPTCHA_USER_DEFINED_WORDS => t('Use user defined words.') @@ -62,10 +61,10 @@ '#default_value' => variable_get('text_captcha_userdefined_words', ''), '#description' => t('Enter a bunch of space separated words (at least @min).', array('@min' => TEXT_CAPTCHA_USER_DEFINED_WORD_MINIMUM)), ); - // textfield for the number of words in the captcha phrase + // textfield for the number of words in the CAPTCHA phrase $form['text_captcha_word_quantity'] = array( '#type' => 'textfield', - '#title' => t('Number of words in the captcha phrase'), + '#title' => t('Number of words in the phrase'), '#default_value' => (int) variable_get('text_captcha_word_quantity', 5), '#size' => 2, '#maxlength' => 2, @@ -91,7 +90,7 @@ // chech text_captcha_word_quantity $word_quantity = (int) $form_values['text_captcha_word_quantity']; if ($word_quantity < 4 || $word_quantity > 10) { - form_set_error('text_captcha_word_quantity', t('Number of words in the captcha phrase should be between 4 and 10.')); + form_set_error('text_captcha_word_quantity', t('Number of words in the phrase should be between 4 and 10.')); } } } @@ -173,7 +172,7 @@ $result['solution'] = $answer; $result['form']['captcha_response'] = array( '#type' => 'textfield', - '#title' => t('What is the @nth word in the captcha phrase "@words"?', array('@nth' => _text_captcha_ordinal($key+1), '@words' => implode(' ', $words))), + '#title' => t('What is the @nth word in the phrase "@words"?', array('@nth' => _text_captcha_ordinal($key+1), '@words' => implode(' ', $words))), '#weight' => 0, '#required' => TRUE, );