--- captcha.admin.inc	2010-11-30 18:14:55.000000000 -0600
+++ captcha.admin.inc	2010-12-21 03:15:47.000000000 -0600
@@ -212,13 +212,35 @@ function captcha_admin_settings(&$form_s
   );
 
   // Option for logging wrong responses.
-  $form['captcha_log_wrong_responses'] = array(
+  $form['captcha_log_failures'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Log failures'),
+    '#description' =>  t('Report information about failed CAPTCHA responses to the !log.', array('!log' => l(t('log'), 'admin/reports/dblog'))),
+    '#attributes' => array('id' => 'edit-captcha-failures-wrapper'),
+  );
+
+  if (variable_get('captcha_log_wrong_responses', FALSE))  {
+    $wrong_count = db_result(db_query("select count(*) as cnt from {watchdog} where type = 'CAPTCHA' AND severity = " . WATCHDOG_INFO));
+  }
+
+  $form['captcha_log_failures']['captcha_log_wrong_responses'] = array(
     '#type' => 'checkbox',
     '#title' => t('Log wrong responses'),
-    '#description' => t('Report information about wrong responses to the !log.', array('!log' => l(t('log'), 'admin/reports/dblog'))),
+    '#description' => t('Probably valid user. ') . (isset($wrong_count) ? t('Currently: !wrongCount',  array('!wrongCount' => $wrong_count)) : ""),
     '#default_value' => variable_get('captcha_log_wrong_responses', FALSE),
   );
 
+  if (variable_get('captcha_log_empty_responses', FALSE))  {
+    $empty_count = db_result(db_query("select count(*) as cnt from {watchdog} where type = 'CAPTCHA' AND severity = " . WATCHDOG_NOTICE));
+  }
+
+  $form['captcha_log_failures']['captcha_log_empty_responses'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Log empty responses'),
+    '#description' => t('Probably spammer. ') . (isset($empty_count) ? t('Currently: !emptyCount',  array('!emptyCount' => $empty_count)) : ""),
+    '#default_value' => variable_get('captcha_log_empty_responses', FALSE),
+  );
+
   // Submit button.
   $form['submit'] = array(
     '#type' => 'submit',
@@ -318,6 +340,7 @@ function captcha_admin_settings_submit($
   variable_set('captcha_default_validation', $form_state['values']['captcha_default_validation']);
   variable_set('captcha_persistence', $form_state['values']['captcha_persistence']);
   variable_set('captcha_log_wrong_responses', $form_state['values']['captcha_log_wrong_responses']);
+  variable_set('captcha_log_empty_responses', $form_state['values']['captcha_log_empty_responses']); 
 
   drupal_set_message(t('The CAPTCHA settings were saved.'), 'status');
 }
@@ -501,3 +524,42 @@ function captcha_examples($form_state, $
   }
   return $form;
 }
+
+/**
+ * Menu callback; presents the "Log and report failures" page.
+ */
+function captcha_reports() {
+  $watchdog = db_fetch_array(db_query("SELECT timestamp FROM {watchdog} ORDER BY wid ASC LIMIT 1"));
+  
+  if (!$watchdog["timestamp"]) {
+    drupal_set_message(t('No entries in the watchdog table'), 'warning');
+    return "";
+  }
+
+  $output = t("captcha failures since !timestamp", array('!timestamp' => format_date($watchdog["timestamp"])));
+
+  $header = array(
+    array('data' => t('failures'), 'field' => 'hits', 'sort' => 'desc'),
+    array('data' => t('visitor'), 'field' => 'a.hostname'),
+    array('data' => t('operations'))
+  );
+
+  $sql = "select count(a.uid) as hits, a.uid, u.name, a.hostname, ac.aid from {watchdog} a left join {access} ac on ac.type = 'host' and lower(a.hostname) like (ac.mask) left join {users} u on a.uid = u.uid where a.type = 'captcha' group by a.hostname, a.uid, u.name, ac.aid". tablesort_sql($header);
+  $sql_cnt = "select count(*) from (select distinct uid, hostname from {watchdog} where type = 'captcha') as unique_visits";
+  $result = pager_query($sql, 30, 0, $sql_cnt);
+
+  $rows = array();
+  while ($account = db_fetch_object($result)) {
+    $qs = drupal_get_destination();
+    $ban_link = $account->aid ? l(t('unban'), "admin/user/rules/delete/$account->aid", array('query' => $qs)) : l(t('ban'), "admin/user/rules/add/$account->hostname/host", array('query' => $qs));
+    $rows[] = array($account->hits,  ($account->uid ? theme('username', $account) : $account->hostname), $ban_link);
+  }
+
+  if (empty($rows)) {
+    $rows[] = array(array('data' => t('no records available.'), 'colspan' => 3));
+  }
+
+  $output .= theme('table', $header, $rows);
+  $output .= theme('pager', null, 30, 0);
+  return $output;
+}
--- captcha.module	2010-12-13 18:23:54.000000000 -0600
+++ captcha.module	2010-12-21 03:10:45.000000000 -0600
@@ -100,6 +100,15 @@ function captcha_menu() {
     'type' => MENU_LOCAL_TASK,
     'weight' => 5,
   );
+  $items['admin/user/captcha/captcha/reports'] = array(
+    'title' => 'Log',
+    'description' => 'View visitors that fail CAPTCHA response.',
+    'page callback' => 'captcha_reports',
+    'access arguments' => array('administer CAPTCHA settings'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10,
+    'file' => 'captcha.admin.inc',
+  );
   $items['admin/user/captcha/captcha/captcha_point'] = array(
     'title' => 'CAPTCHA point administration',
     'file' => 'captcha.admin.inc',
@@ -581,10 +590,19 @@ function captcha_validate($element, &$fo
       db_query("UPDATE {captcha_sessions} SET attempts=attempts+1 WHERE csid=%d", $csid);
       // set form error
       form_set_error('captcha_response', t('The answer you entered for the CAPTCHA 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)) {
+      if (variable_get('captcha_log_wrong_responses', FALSE) && $captcha_response) {
+        watchdog('CAPTCHA',
+          '%form_id post blocked by CAPTCHA module: challenge "%challenge" (by module "%module"), user answered "%response", but the solution was "%solution".',
+          array('%form_id' => $form_id,
+            '%response' => $captcha_response, '%solution' => $solution,
+            '%challenge' => $captcha_info['captcha_type'], '%module' => $captcha_info['module'],
+          ),
+          WATCHDOG_INFO
+        );
+      }
+
+      if (variable_get('captcha_log_empty_responses', FALSE) && !$captcha_response) {
         watchdog('CAPTCHA',
           '%form_id post blocked by CAPTCHA module: challenge "%challenge" (by module "%module"), user answered "%response", but the solution was "%solution".',
           array('%form_id' => $form_id,
