--- spam.module	2012-01-13 15:23:47.547071160 +0100
+++ spam.NEU.module	2012-01-13 15:24:54.248071080 +0100
@@ -29,6 +29,7 @@ define('SPAM_DEBUG', 5);
  * action will be taken.
  */
 function spam_scan($content, $type, $extra = array(), $filter_test = FALSE) {
+
   $id = spam_invoke_module($type, 'content_id', $content, $extra);
   spam_log(SPAM_DEBUG, 'spam_scan', t('scanning content'), $type, $id);
   $spam = spam_content_is_spam($content, $type, $extra, $filter_test);
@@ -41,8 +42,11 @@ function spam_scan($content, $type, $ext
   _spam_update_statistics(t('scan @type', array('@type' => $type)));
 
   if ($spam['is_spam']) {
+
     spam_log(SPAM_DEBUG, 'spam_scan', t('content is spam'), $type, $id);
     _spam_update_statistics(t('detected spam @type', array('@type' => $type)));
+
+
     switch (variable_get('spam_visitor_action', SPAM_ACTION_PREVENT)) {
       case SPAM_ACTION_PREVENT_SILENT:
         spam_log(SPAM_LOG, 'spam_scan', t('content is spam, action(prevent silently)'), $type, $id);
@@ -118,6 +122,7 @@ function spam_content_is_spam($content,
  */
 function spam_content_filter($content, $type, $extra, $filter_test = FALSE) {
   $id = spam_invoke_module($type, 'content_id', $content, $extra);
+
   if (!spam_filter_content_type($content, $type, $extra)) return;
 
   static $scores = array();
@@ -226,10 +231,12 @@ function spam_content_insert($content, $
   if (!spam_filter_content_type($content, $type, $extra)) return;
 
   $id = spam_invoke_module($type, 'content_id', $content, $extra);
+
   if (spam_bypass_filters() || user_access('bypass filters')) {
     spam_log(SPAM_DEBUG, 'spam_content_insert', t('bypassing filters'), $type, $id);
     return;
   }
+
   spam_log(SPAM_VERBOSE, 'spam_content_insert', t('inserting'), $type, $id);
   $score = 0;
 
@@ -653,18 +660,19 @@ function spam_help($path, $arg) {
  * Drupal form_alter() hook.
  */
 function spam_form_alter(&$form, &$form_state, $form_id) {
-  foreach (module_list() as $module) {
-    // For PHP4, allows modules to update $form.
-    $function = $module .'_spamapi_form_alter';
-    if (function_exists($function)) {
-      $function($form, $form_state, $form_id);
-    }
-    // Alternative method, for modules that don't need to update $form.
-    $function = $module .'_spamapi';
-    if (function_exists($function)) {
-      $function('process_form', $form_id, $form);
-    }
-  }
+
+	foreach (module_list() as $module) {
+		// For PHP4, allows modules to update $form.
+		$function = $module .'_spamapi_form_alter';
+		if (function_exists($function)) {
+		$function($form, $form_state, $form_id);
+		}
+		// Alternative method, for modules that don't need to update $form.
+		$function = $module .'_spamapi';
+		if (function_exists($function)) {
+		$function('process_form', $form_id, $form);
+		}
+	}
 }
 
 /**
@@ -863,7 +871,9 @@ function spam_admin_settings_form() {
  * Determine if we should be filtering a given content type.
  */
 function spam_filter_content_type($content, $type, $extra) {
+
   $filter = spam_invoke_module($type, 'filter_content_type', $content, $extra);
+
   if (!$filter) {
     spam_log(SPAM_DEBUG, 'spam_filter_content_type', t('not configured to scan this content type'), $type);
   }
@@ -981,6 +991,7 @@ function spam_invoke_module() {
   $args = func_get_args();
   $module = array_shift($args);
   array_unshift($args, $module, 'spamapi');
+
   return call_user_func_array('module_invoke', $args);
 }
 
@@ -988,7 +999,11 @@ function spam_invoke_module() {
  * Manage spam content.
  */
 function spam_admin_list() {
-  $output = drupal_get_form('spam_filter_form');
+
+	// H.S.
+  $output = drupal_get_form('spam_scan_form');
+
+  $output .= drupal_get_form('spam_filter_form');
   $output .= drupal_get_form('spam_admin_overview');
   return $output;
 }
@@ -1138,6 +1153,139 @@ function _spam_truncate($text, $length =
   return $text;
 }
 
+
+
+/***************************++++++++**********       H.S.       *********************************/
+/***************************++++++++**********       H.S.       *********************************/
+//
+function spam_scan_form() {
+
+	$form = array();
+
+  $form['scan'] = array(
+		'#type' => 'fieldset',
+    '#title' => t('Scan old content'),
+  );
+
+  $form['scan']['submit'] = array(
+		'#type' =>		'submit', 
+		'#value' =>		'scan',
+		'#submit'	=>	array('spam_scan_submit'),
+		);
+
+  return $form;
+}
+
+function theme_spam_scan_form() {
+  $output = '<div id="spam-scan">';
+  $output .= drupal_render($form['scan']);
+  $output .= '</div>';
+  $output .= drupal_render($form);
+  return $output;
+}
+
+function spam_scan_submit($form, &$form_state) {
+
+	$nodeArray = array();
+	$nodeRevisionsArray = array();
+
+	$result = db_query("SELECT nid, title, body FROM {node_revisions} ORDER BY nid DESC");
+	while($row = db_fetch_object($result)) {
+		$nodeRevisionsArray[$row->nid]['title'] = $row->title;
+		$nodeRevisionsArray[$row->nid]['body'] = $row->body;
+	}
+
+	$result = db_query("SELECT nid, type FROM {node} ORDER BY nid DESC");
+	while($row = db_fetch_object($result)) {
+		$nodeArray[$row->nid]['type'] = $row->type;
+	}
+
+
+	foreach($nodeArray AS $nid => $dataArray) {
+		$contentObj = new stdClass();
+
+		$contentObj->nid = $nid;
+		$contentObj->title = $nodeRevisionsArray[$nid]['title'];
+		$contentObj->body = $nodeRevisionsArray[$nid]['body'];
+		$contentObj->type = $dataArray['type'];
+
+		spam_scan_content($contentObj, 'node');
+	}
+  return $form;
+}
+
+
+function spam_scan_content($content, $type, $extra = array()) {
+
+  if (!spam_filter_content_type($content, $type, $extra)) return;
+
+  $id = spam_invoke_module($type, 'content_id', $content, $extra);
+
+  spam_log(SPAM_VERBOSE, 'spam_content_insert', t('inserting'), $type, $id);
+  $score = 0;
+
+  $error = FALSE;
+  if ($id) {
+    $spam = spam_content_is_spam($content, $type, $extra);
+    $score = $spam['score'];
+
+    // this is neccessary in case that some content types have potentially identical IDs, such as hashes.
+    $sid = db_result(db_query("SELECT sid FROM {spam_tracker} WHERE content_type = '%s' AND content_id = '%s'", $type, $id));
+    if (!$sid) {
+      db_query("INSERT INTO {spam_tracker} (content_type, content_id, score, hostname, timestamp) VALUES('%s', '%s', %d, '%s', %d)", $type, $id, $score, ip_address(), time());
+      $sid = db_result(db_query("SELECT sid FROM {spam_tracker} WHERE content_type = '%s' AND content_id = '%s'", $type, $id));
+    }
+    if ($sid) {
+      watchdog('spam', 'Inserted %type with id %id into spam tracker table.', array('%type' => $type, '%id' => $id), WATCHDOG_NOTICE);
+      $extra['sid'] = $sid;
+      if (!isset($extra['host'])) {
+        // Content type modules can set this value, should REMOTE_ADDR not be
+        // the correct IP for their content type.
+        $extra['host'] = ip_address();
+      }
+      $fields = spam_invoke_module($type, 'filter_fields', $content, $extra);
+      if (!empty($fields) && is_array($fields['main'])) {
+        $filters = db_query('SELECT name, module, gain FROM {spam_filters} WHERE status = %d ORDER BY weight', SPAM_FILTER_ENABLED);
+        while ($filter = db_fetch_object($filters)) {
+          // Let filters act on insert action.
+          spam_invoke_module($filter->module, 'insert', $type, $content, $fields, $extra);
+        }
+      }
+      else {
+        watchdog('spam', 'Function spam_content_insert failed, no fields are defined for %type content type.', array('%type' => $type), WATCHDOG_ERROR);
+        $error = -3;
+      }
+    }
+    else {
+        watchdog('spam', 'Function spam_content_insert failed, unable to insert %type with id %id into spam_tracker table.', array('%type' => $type, '%id' => $id), WATCHDOG_ERROR);
+      $error = -2;
+    }
+  }
+  else {
+    watchdog('spam', 'Function spam_content_insert failed, unable to insert %type into spam_tracker table, no id found in the content array.', array('%type' => $type), WATCHDOG_ERROR);
+    $error = -1;
+  }
+
+  // This content became spam during an insert, mark it as such.
+  if ($score >= variable_get('spam_threshold', SPAM_DEFAULT_THRESHOLD)) {
+    spam_mark_as_spam($type, $id, $extra);
+
+    if (!in_array(variable_get('spam_visitor_action', SPAM_ACTION_PREVENT), array(SPAM_ACTION_HOLD))) {
+      _spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
+      spam_log(SPAM_DEBUG, 'spam_content_insert', t('redirecting to spam/denied'), $type, $id);
+      drupal_goto('spam/denied');
+    }
+  }
+
+  return $error;
+}
+
+
+
+
+/******************************************************************************************++*****************/
+/*************************************************************************************************************/
+
 /**
  * Return form for spam administration overview filters.
  */
@@ -1860,18 +2008,26 @@ function spam_mark_as_not_spam($type, $i
  * Extract text from content array.
  */
 function spam_get_text($content, $type, $fields, $extra = array(), $full = TRUE) {
+
+
   if (is_object($content)) {
     $content = (array)$content;
   }
 
+
   $text = '';
   if (isset($fields['main']) && is_array($fields['main'])) {
+
+
     foreach ($fields['main'] as $field) {
+
       $text .= $content[$field] .' ';
     }
   }
   if ($full && isset($fields['other']) && is_array($fields['other'])) {
+
     foreach ($fields['other'] as $field) {
+
       $text .= $content[$field] .' ';
     }
   }
