C:\captcha>"C:\Program Files\CVSNT\cvs.exe" -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib diff -up contributions/modules/captcha Index: contributions/modules/captcha/image_captcha/image_captcha.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/image_captcha/image_captcha.admin.inc,v retrieving revision 1.8 diff -u -p -r1.8 image_captcha.admin.inc --- contributions/modules/captcha/image_captcha/image_captcha.admin.inc 28 Apr 2008 10:03:00 -0000 1.8 +++ contributions/modules/captcha/image_captcha/image_captcha.admin.inc 15 May 2008 02:01:37 -0000 @@ -42,7 +42,14 @@ function image_captcha_settings_form() { '#default_value' => (int) variable_get('image_captcha_code_length', 5), '#description' => t('The code length influences the size of the image. Note that larger values make the image generation more CPU intensive.'), ); - + // remove case sensitivity from test to make it easier to pass captcha + $form['image_captcha_code_settings']['captcha_ignore_case_sensitivity'] = array( + '#type' => 'checkbox', + '#title' => t('Ignore case sensitivity'), + '#description' => t('Ignore the user\'s case sensitivity in their answer. This will make it easier for users to pass CAPTCHA.'), + '#default_value' => variable_get('captcha_ignore_case_sensitivity', FALSE), + ); + // font related stuff $form['image_captcha_font_settings'] = array( '#type' => 'fieldset', Index: contributions/modules/captcha/image_captcha/image_captcha.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/image_captcha/image_captcha.module,v retrieving revision 1.14 diff -u -p -r1.14 image_captcha.module --- contributions/modules/captcha/image_captcha/image_captcha.module 7 Apr 2008 21:35:18 -0000 1.14 +++ contributions/modules/captcha/image_captcha/image_captcha.module 13 May 2008 04:01:13 -0000 @@ -102,7 +102,7 @@ function _image_captcha_utf8_split($str) /** * Implementation of hook_captcha */ -function image_captcha_captcha($op, $captcha_type='') { +function image_captcha_captcha($op, $captcha_type='', $response='') { switch ($op) { case 'list': // only offer image CAPTCHA if possible to generate an image CAPTCHA @@ -129,8 +129,26 @@ function image_captcha_captcha($op, $cap for ($i = 0; $i < $code_length; $i++) { $code .= $allowed_chars[array_rand($allowed_chars)]; } + + // check for case sensitivity + if (variable_get('captcha_ignore_case_sensitivity')) { + // the operator has requested the test be insensitive + // set the test to all lower case characters + $code = strtolower($code); + // set a hook for the preprocessor so that the response + // from the user will also be set to lower case + $captcha['preprocess'] = TRUE; + } + else + { + // reset preprocessor to FALSE + // just in case things change at runtime + $captcha['preprocess'] = FALSE; + } + // store the answer in $_SESSION for the image generator function (which happens in another http request) $seed = mt_rand(); + $_SESSION['image_captcha'][$seed] = $code; // build the result to return $result = array(); @@ -150,6 +168,13 @@ function image_captcha_captcha($op, $cap ); return $result; } + case 'preprocess': + // this hook should only be enabled if the operator + // has selected case insensitivity. + // it is enabled in the generate process above + if ($capcha_type == 'Image') { + return strtolower($response); + } break; } }