Index: webform.inc
===================================================================
--- webform.inc	2008-02-29 11:34:08.283032633 -0500
+++ webform.inc	2008-02-29 15:00:05.856569405 -0500
@@ -28,6 +28,7 @@ function _webform_page() {
      $row[] = l(t('Analysis'),'node/'. $node->nid .'/results/analysis');
      $row[] = l(t('Table'),'node/'. $node->nid .'/results/table');
      $row[] = l(t('Download'),'node/'. $node->nid .'/results/download');
+     $row[] = l(t('Anonymous'),'node/'. $node->nid .'/results/anonymizer');
    }
    else {
      $row = array_merge($row, array('','','',''));
@@ -61,6 +62,7 @@ function _webform_results_clear($nid) {
 function _webform_results_clear_submit($form_id, $form_values) {
   db_query('DELETE FROM {webform_submitted_data} WHERE nid = %d', $form_values['nid']);
   db_query('DELETE FROM {webform_submissions} WHERE nid = %d', $form_values['nid']);
+  db_query('DELETE FROM {webform_anonymizer} WHERE nid = %d', $form_values['nid']);
 
   $node = node_load(array('nid' => $form_values['nid']));
   $title = $node->title;
@@ -110,6 +112,46 @@ function _webform_submission_delete_subm
  *   If the results of this fetch will be used in a sortable table, pass the
  *   array header of the table.
  */
+function _webform_fetch_anonymizer($nid, $header = NULL) {
+
+  $query = 'SELECT a.*,u.name,s.sid FROM webform_anonymizer a '.
+           'LEFT JOIN webform_submissions s ON s.submitted=a.submitted '.
+           'LEFT JOIN users u ON u.uid=a.uid WHERE a.nid=495';
+
+  if (is_array($header)) {
+    $query .= tablesort_sql($header);
+  }
+
+  $res = db_query($query, $nid);
+  $anon_subs = array();
+  $previous = array();
+
+  // Outer loop: iterate for each submission.
+  while ($row = db_fetch_object($res)) {
+    if ($row->sid != $previous) {
+      $anon_subs[$row->sid]->sid = $row->sid;
+      $anon_subs[$row->sid]->submitted = $row->submitted;
+      $anon_subs[$row->sid]->remote_addr = $row->remote_addr;
+      $anon_subs[$row->sid]->uid = $row->uid;
+      $anon_subs[$row->sid]->name = $row->name;
+      $anon_subs[$row->sid]->status = $row->status;
+    }
+    $anon_subs[$row->sid]->data[$row->cid]['value'][$row->no] = $row->data;
+    $previous = $row->sid;
+  }
+
+  return $anon_subs;
+}
+
+/**
+ * Return all the submissions for a particular node.
+ * 
+ * @param $nid
+ *   The node ID for which submissions are being fetched.
+ * @param $header
+ *   If the results of this fetch will be used in a sortable table, pass the
+ *   array header of the table.
+ */
 function _webform_fetch_submissions($nid, $header = NULL) {
 
   $query = 'SELECT s.*, sd.cid, sd.no, sd.data, u.name, u.mail, u.status '.
@@ -277,6 +319,10 @@ function _webform_submission_limit_check
   $result = db_query($query, $user->uid, $_SERVER['REMOTE_ADDR'], $user->uid, time() - $node->submit_interval, $node->nid);
   $num_submissions_database = db_num_rows($result);
 
+  // Fetch all the entries from the anonymous submission database within the submit interval with this username and IP.
+  $result_anon = db_query("SELECT * FROM {webform_anonymizer} WHERE uid=%d AND nid=%d AND submitted>%d",$user->uid,$node->nid,time()-$node->submit_interval);
+  $num_submissions_anon = db_num_rows($result_anon);
+
   // Double check the submission history from the users machine using cookies.
   if (variable_get("webform_use_cookies", 0)) {
     $cookie_name = 'webform-'. $node->nid;
@@ -296,10 +342,20 @@ function _webform_submission_limit_check
     }
   }
 
-  if ($num_submissions_database >= $node->submit_limit || $num_submissions_cookie >= $node->submit_limit) {
+  if ($num_submissions_database >= $node->submit_limit) {
     // Limit exceeded.
     return $num_submissions_database;
   }
+
+  else if ($num_submissions_anon >= $node->submit_limit) {
+    // Limit exceeded.
+    return $num_submissions_anon;
+  }
+
+  else if ($num_submissions_cookie >= $node->submit_limit) {
+    // Limit exceeded.
+    return $num_submissions_cookie;
+  }
   else {
     // Increment a cookie for triple recording of the submission.
     if (variable_get("webform_use_cookies", 0)) {
