? image_captcha/fonts/OLDSH___.TTF
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 11:39:19 -0000
@@ -161,6 +161,11 @@ function captcha_admin($form_id='', $op=
  * Form builder function for the general captcha configuration
  */
 function captcha_admin_settings($form_id='') {
+  // wrong response counter
+  $form['captcha_wrong_response_counter'] = array(
+    '#type' => 'markup',
+    '#value' => t('Already %counter form submissions blocked by CAPTCHA module.', array('%counter' => variable_get('captcha_wrong_response_counter', 0))),
+    );
   // field for the captcha adminstration mode
   $form['captcha_administration_mode'] = array(
     '#type' => 'checkbox',
@@ -236,6 +241,13 @@ function captcha_admin_settings($form_id
     '#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),
   );
+  // option for logging failed captchas
+  $form['captcha_log_wrong_responses'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Log wrong captcha responses'),
+    '#description' => t('When enabled, information about wrong captcha responses will be logged to the watchdog log.'),
+    '#default_value' => variable_get('captcha_log_wrong_responses', FALSE),
+  );
   // submit button
   $form['submit'] = array(
     '#type' => 'submit',
@@ -283,9 +295,10 @@ function captcha_admin_settings_submit($
       }
     }
     else {
-    variable_set('captcha_description', $form_values['captcha_description']);
+      variable_set('captcha_description', $form_values['captcha_description']);
     }
     variable_set('captcha_persistence', $form_values['captcha_persistence']);
+    variable_set('captcha_log_wrong_responses', $form_values['captcha_log_wrong_responses']);
     drupal_set_message(t('Your captcha settings were saved.'), 'status');
   }
 }
@@ -321,7 +334,7 @@ function captcha_form_alter($form_id, &$
     $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',
+      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);
@@ -388,7 +401,7 @@ function captcha_form_alter($form_id, &$
     // 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
@@ -442,7 +455,17 @@ function captcha_validate($form_values) 
     $_SESSION['captcha'][$form_id]['success'] = TRUE;
   }
   else {
+    // set form error
     form_set_error('captcha_response', t('The answer you entered for the captcha challenge was not correct.'));
+    // update wrong response counter
+    variable_set('captcha_wrong_response_counter', variable_get('captcha_wrong_response_counter', 0) + 1);
+    // log to watchdog if needed
+    if (variable_get('captcha_log_wrong_responses', FALSE)) {
+      watchdog('CAPTCHA',
+        t('%form_id post blocked by CAPTCHA module: user answered "%response", but the solution was "%solution".',
+          array('%form_id' => $form_id, '%response' => $captcha_response, '%solution'=> $_SESSION['captcha'][$form_id][$captcha_token])),
+        WATCHDOG_NOTICE);
+    }
     // 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
