Index: captcha.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/captcha.info,v retrieving revision 1.3.2.2 diff -u -u -p -r1.3.2.2 captcha.info --- captcha.info 10 Jul 2007 22:02:33 -0000 1.3.2.2 +++ captcha.info 8 Sep 2007 12:02:06 -0000 @@ -1,5 +1,5 @@ ; $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 CAPTCHAs to arbitrary forms." package = "Spam control" -version = "$Name: $" +version = "$Name: DRUPAL-5--3 $" Index: captcha.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/Attic/captcha.install,v retrieving revision 1.1.4.4 diff -u -u -p -r1.1.4.4 captcha.install --- captcha.install 24 Jul 2007 00:45:39 -0000 1.1.4.4 +++ captcha.install 8 Sep 2007 12:02:06 -0000 @@ -40,7 +40,7 @@ function captcha_install() { } 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.28 diff -u -u -p -r1.42.2.28 captcha.module --- captcha.module 7 Sep 2007 14:19:42 -0000 1.42.2.28 +++ captcha.module 8 Sep 2007 12:02:07 -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); @@ -16,18 +18,17 @@ define('CAPTCHA_UNSOLVED_CHALLENGES_MAX' function captcha_help($section = 'admin/help#captcha') { switch ($section) { case 'admin/help#captcha': - return '

' . 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.') . '

'; + return 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 question or challenge, which should be easy for a human to solve correctly, but hard enough to keep automated scripts and spam bots out.

CAPTCHA is a trademark of Carnegie Mellon University.

'); 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 (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 a CAPTCHA, 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; } /** @@ -36,20 +37,20 @@ function captcha_help($section = 'admin/ 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, ); @@ -62,7 +63,7 @@ function captcha_menu($may_cache) { $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 CAPTCHA types with examples.'), 'callback' => 'captcha_examples', 'type' => MENU_LOCAL_TASK, 'weight' => 5, @@ -75,28 +76,28 @@ function captcha_menu($may_cache) { * Implementation of hook_perm(). */ function captcha_perm() { - return array('administer captcha', 'skip captcha challenges'); + return array('administer CAPTCHA settings', '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; } /** @@ -118,34 +119,34 @@ function _captcha_get_description($lang_ } /** - * 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. @@ -153,43 +154,43 @@ function captcha_admin($form_id='', $op= break; } } - // 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_id); } /** - * Form builder function for the general captcha configuration + * Form builder function for the general CAPTCHA configuration */ function captcha_admin_settings($form_id='') { - // 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 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). These links make it possible to enable/disable a CAPTCHA and configure the CAPTCHA type.', array('%admincaptcha' => 'administer CAPTCHA settings')), ); // 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('CAPTCHA configuration per form'), + '#description' => t('Select what kind of CAPTCHA you want for each available form. 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, ); // if a form_id was given as argument of this form builder, highlight the captcha type select widget if ($form_id == $captcha_point->form_id) { @@ -202,19 +203,19 @@ function captcha_admin_settings($form_id )) ); } - // 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('CAPTCHA description'), + '#description' => t('With this description you can explain the purpose of the CAPTCHA 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, ); @@ -222,18 +223,18 @@ function captcha_admin_settings($form_id } 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('CAPTCHA description'), + '#description' => t('With this description you can explain the purpose of the CAPTCHA to the user.'), + '#default_value' => _captcha_get_description(), + '#maxlength' => 256, + ); } - // field for captcha persistence + // field for CAPTCHA persistence $form['captcha_persistence'] = array( '#type' => 'checkbox', - '#title' => t('Persistent captchas'), - '#description' => t('If checked, the user will always have to solve a captcha. If not checked, the captcha check for a form will be omitted during the rest of the session once the user has successfully solved a captcha for that form.'), + '#title' => t('Persistent CAPTCHAs'), + '#description' => t('If checked, the user will always have to solve a CAPTCHA. If not checked, the CAPTCHA check for a form will be omitted during the rest of the session once the user has successfully solved a CAPTCHA for that form.'), '#default_value' => variable_get('captcha_persistence', TRUE), ); // submit button @@ -245,7 +246,7 @@ function captcha_admin_settings($form_id } /** - * 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) { @@ -255,7 +256,7 @@ function theme_captcha_admin_settings_ca $row[] = drupal_render($form[$key]['operations']); $rows[] = $row; } - $header = array('form_id', t('Captcha type (module)'), t('Operations')); + $header = array('form_id', t('CAPTCHA type (module)'), t('Operations')); $output = theme('table', $header, $rows); return $output; } @@ -286,28 +287,28 @@ function captcha_admin_settings_submit($ 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'); } } /** * 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) { global $user; - if (!user_access('skip captcha challenges')) { - // Visitor does not have permission to skip the captcha challenge + if (!user_access('skip CAPTCHA')) { + // Visitor does not have permission to skip the CAPTCHA - // 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(!variable_get('captcha_persistence', TRUE) && ($_SESSION['captcha'][$form_id]['success'] === TRUE)) { return; } - // Get captcha type and module for this form. Return if no captcha was set. + // 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; @@ -317,40 +318,40 @@ function captcha_form_alter($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 CAPTCHA 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 ( @@ -358,9 +359,9 @@ function captcha_form_alter($form_id, &$ '#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 ( @@ -382,16 +383,16 @@ function captcha_form_alter($form_id, &$ // 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()); - // prevent caching of the page with this captcha enabled form + // prevent caching of the page with this CAPTCHA enabled form global $conf; $conf['cache'] = FALSE; - + } - 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 + elseif (user_access('administer CAPTCHA settings') && variable_get('captcha_administration_mode', FALSE) && arg(0) != 'admin') { + // 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; @@ -400,23 +401,23 @@ function captcha_form_alter($form_id, &$ if ($captcha_point->type) { $form['captcha'] = array( '#type' => 'item', - '#title' => t('Captcha administration'), - '#description' => t('The captcha challenge "@type" (by module "@module") is enabled here for untrusted users: !edit or !disable.', array( + '#title' => t('CAPTCHA administration'), + '#description' => t('The CAPTCHA "@type" (by module "@module") is enabled here for untrusted users: !edit or !disable.', 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()), + '!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()), )) ); } 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 CAPTCHA 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'); } } @@ -435,14 +436,14 @@ function captcha_validate($form_values) $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]) { $_SESSION['captcha'][$form_id]['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 @@ -453,9 +454,9 @@ function captcha_validate($form_values) } } - // 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]); } @@ -463,36 +464,36 @@ function captcha_validate($form_values) /** * 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 (!variable_get('captcha_persistence', TRUE) && ($_SESSION['captcha'][$form_id]['success'] === TRUE)) { 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 CAPTCHAs without solving them. Your previous CAPTCHA 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; @@ -501,7 +502,7 @@ function captcha_pre_render($form_id, &$ } /** - * 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 @@ -512,7 +513,7 @@ function captcha_pre_render_place_captch } } 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_weigth = min($button_weights); $form['captcha']['#weight'] = $first_button_weigth - 0.5/1000.0; @@ -522,18 +523,18 @@ function captcha_pre_render_place_captch } /** - * 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"; @@ -542,24 +543,24 @@ function captcha_examples($module=NULL, } } 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 CAPTCHA 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 + foreach ($challenges as $challenge) { + // generate CAPTCHA $captcha = call_user_func_array($module .'_captcha', array('generate', $challenge)); // build form $form = array(); $form['captcha'] = array( '#type' => 'fieldset', - '#title' => t('Challenge "%challenge" by module "%module"', array('%challenge' => $challenge, '%module' => $module)), + '#title' => t('CAPTCHA "%challenge" by module "%module"', array('%challenge' => $challenge, '%module' => $module)), ); $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 CAPTCHA type.'), "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.5 diff -u -u -p -r1.1.4.5 captcha_api.txt --- captcha_api.txt 17 Aug 2007 18:43:13 -0000 1.1.4.5 +++ captcha_api.txt 8 Sep 2007 12:02:07 -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 @@ enter "foo" in a textfield. 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 @@ function foo_captcha_captcha($op, $captc """ 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 @@ dependencies = captcha === 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 @@ function foo_captcha_menu($may_cache) { 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 @@ returns the form of your configuration p === 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,7 +116,7 @@ For our simple foo captcha module this w 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; } @@ -125,7 +125,7 @@ function foo_captcha_help($section) { === 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 +137,7 @@ function foo_captcha_captcha($op, $captc switch($op) { ... case 'generate': - if ($captcha_type == "Foo captcha") { + if ($captcha_type == "Foo CAPTCHA") { ... $captcha['preprocess'] = TRUE, ... @@ -151,7 +151,7 @@ function foo_captcha_captcha($op, $captc 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 -u -p -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 8 Sep 2007 12:02:07 -0000 @@ -1,6 +1,6 @@ ; $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 = "Enables an image based CAPTCHA." package = "Spam control" dependencies = captcha -version = "$Name: $" +version = "$Name: DRUPAL-5--3 $" 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.14 diff -u -u -p -r1.1.4.14 image_captcha.module --- image_captcha/image_captcha.module 29 Aug 2007 19:18:34 -0000 1.1.4.14 +++ image_captcha/image_captcha.module 8 Sep 2007 12:02:07 -0000 @@ -2,7 +2,7 @@ // $Id: image_captcha.module,v 1.1.4.14 2007/08/29 19:18:34 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 @@ DEFINE(IMAGE_CAPTCHA_ALLOWED_CHARACTERS, 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 type of CAPTCHA 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 CAPTCHA, generated with the current settings:

!img', array('!img' => $img)); } return $output; } @@ -36,10 +36,9 @@ function image_captcha_menu($may_cache) // 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 @@ function image_captcha_menu($may_cache) /** * 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 @@ function _image_captcha_get_font() { } 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); } @@ -114,7 +113,7 @@ function image_captcha_settings_form() { // 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('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'); return array(); } else { @@ -128,7 +127,7 @@ function image_captcha_settings_form() { '#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('The TrueType font (.ttf) to use for the text in the image CAPTCHA.'), '#options' => $available_fonts, ); } @@ -278,7 +277,7 @@ function _image_captcha_utf8_split($str) 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'); @@ -288,7 +287,7 @@ function image_captcha_captcha($op, $cap } case 'generate': if ($captcha_type == 'Image') { - // 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 = ''; @@ -320,7 +319,7 @@ function image_captcha_captcha($op, $cap } /** - * menu callback function that generates the captcha image + * menu callback function that generates the CAPTCHA image */ function image_captcha_image($seed=NULL) { if (!$seed) { @@ -328,7 +327,7 @@ function image_captcha_image($seed=NULL) } // 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 -u -p -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 8 Sep 2007 12:02:08 -0000 @@ -1,6 +1,6 @@ ; $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 = "CAPTCHA module that implements a simple text based CAPTCHA." package = "Spam control" dependencies = captcha -version = "$Name: $" +version = "$Name: DRUPAL-5--3 $" 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.8 diff -u -u -p -r1.1.4.8 text_captcha.module --- text_captcha/text_captcha.module 25 Aug 2007 13:29:49 -0000 1.1.4.8 +++ text_captcha/text_captcha.module 8 Sep 2007 12:02:08 -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 @@ DEFINE('TEXT_CAPTCHA_USER_DEFINED_WORD_M 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('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 $output; } @@ -30,10 +30,9 @@ function text_captcha_menu($may_cache) { // 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 @@ function text_captcha_settings_form() { // 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 CAPTCHA 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 @@ function text_captcha_settings_form() { '#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 CAPTCHA phrase'), '#default_value' => (int) variable_get('text_captcha_word_quantity', 5), '#size' => 2, '#maxlength' => 2, @@ -91,7 +90,7 @@ function text_captcha_settings_form_vali // 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 CAPTCHA phrase should be between 4 and 10.')); } } } @@ -105,7 +104,7 @@ function _text_captcha_generate_nonsense $vowel_max = strlen($vowels) - 1; $consonant_max = strlen($consonants) - 1; $word = ''; - $o = mt_rand(0,1); // randomly start with vowel or consonants + $o = mt_rand(0, 1); // randomly start with vowel or consonants for ($i = 0; $i < $characters ; ++$i) { if (($i+$o) % 2) { $word .= $consonants[mt_rand(0, $consonant_max)]; @@ -126,14 +125,14 @@ function _text_captcha_generate_words($n // use user defined words $uwords = explode(' ', variable_get('text_captcha_userdefined_words', '')); $keys = array_rand($uwords, $num); - foreach($keys as $key) { + foreach ($keys as $key) { $words[] = $uwords[$key]; } } else { // generate nonsense words for ($w=0; $w<$num; ++$w) { - $words[] = _text_captcha_generate_nonsense_word(mt_rand(3,7)); + $words[] = _text_captcha_generate_nonsense_word(mt_rand(3, 7)); } } return $words; @@ -158,7 +157,7 @@ function _text_captcha_ordinal($n) { * Implementation of hook_captcha */ function text_captcha_captcha($op, $captcha_type='') { - switch($op) { + switch ($op) { case 'list': return array('Text'); case 'generate': @@ -171,9 +170,9 @@ function text_captcha_captcha($op, $capt // store the answer and build the form elements $result = array(); $result['solution'] = $answer; - $result['form']['captcha_response'] = array ( + $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 CAPTCHA phrase "@words"?', array('@nth' => _text_captcha_ordinal($key+1), '@words' => implode(' ', $words))), '#weight' => 0, '#required' => TRUE, );