--- antispam.module.org	2011-02-17 07:09:10.000000000 -0800
+++ antispam.module	2011-02-17 07:07:29.000000000 -0800
@@ -1,5 +1,5 @@
-<?
-// $Id: antispam.module,v 1.3.2.1 2011/01/03 18:24:25 pixture Exp $
+<?php
+// $Id: antispam.module,v 1.3.2.4 2011/01/10 12:15:18 pixture Exp $
 
 /**
 * AntiSpam Drupal and Module versions.
@@ -41,7 +41,7 @@ define('ANTISPAM_COUNT_FALSE_POSITIVE', 
 /**
  * Debug function
  */
-function antispam_debug_log($str)
+function antispam_debug($str)
 {
   if(is_array($str) || is_object($str)) {
     error_log(print_r($str, TRUE) . "\r\n", 3, "/tmp/antispam.txt");
@@ -862,6 +862,7 @@ function antispam_node_validate($node, $
   global $user;
 
   $num_condition = 0;
+  $debug_info = array();
 
   // Ok, let's build a quick query to see if we can catch a spambot.
   $antispambot_rules = antispam_get_anti_spambot_rules();
@@ -870,7 +871,7 @@ function antispam_node_validate($node, $
   if ($antispambot_rules['body']) {
     $query->join('field_data_body', 'e', 'e.entity_id = s.content_id');
   }
-  $query->fields('s');
+  $query->fields('s', array('content_id'));
   if ($antispambot_rules['body']) {
     $query->addField('e', 'body_value', 'body');
   }
@@ -879,24 +880,24 @@ function antispam_node_validate($node, $
 
   if ($antispambot_rules['ip']) {
     $query->condition('s.hostname', ip_address());
+    $debug_info['IP-address'] = ip_address();
     $num_condition++;
   }
   if ($antispambot_rules['mail'] && !empty($user->mail)) {
     $query->condition('s.mail', $user->mail);
+    $debug_info['E-mail'] = $user->mail;
     $num_condition++;
   }
   if ($antispambot_rules['body'] && !empty($node->body)) {
-    $query->condition('e.body', $node->body[$node->language][0]['value']);
+    $query->condition('e.body_value', $node->body[$node->language][0]['value']);
+    $debug_info['Content'] = $node->body[$node->language][0]['value'];
     $num_condition++;
   }
 
   if ($num_condition) {
     $has_rows = $query->execute()->fetchField();
     if ($has_rows) {
-      antispam_anti_spambot_action(array(
-        t('E-mail') => $form_state['values']['mail'],
-        t('Comment') => $form_state['values']['comment']
-      ));
+      antispam_anti_spambot_action($debug_info);
     }
   }
 }
@@ -985,11 +986,13 @@ function antispam_comment_presave($comme
   // if this is updating existing comment, then cid is already assigned.
 
   $num_condition = 0;
+  $debug_info = array();
 
   // Ok, let's build a quick query to see if we can catch a spambot.
   $antispambot_rules = antispam_get_anti_spambot_rules();
 
   $query = db_select('antispam_spam_marks', 's');
+  $query->fields('s', array('content_id'));
   if ($antispambot_rules['body']) {
     $query->join('comment', 'c', 's.content_id = c.cid');
   }
@@ -998,24 +1001,24 @@ function antispam_comment_presave($comme
 
   if ($antispambot_rules['ip']) {
     $query->condition('s.hostname', ip_address());
+    $debug_info['IP-address'] = ip_address();
     $num_condition++;
   }
   if ($antispambot_rules['mail'] && !empty($comment->mail)) {
     $query->condition('s.mail', $comment->mail);
+    $debug_info['E-mail'] = $comment->mail;
     $num_condition++;
   }
   if ($antispambot_rules['body'] && !empty($comment->comment_body)) {
     $query->condition('c.comment', render($comment->comment_body[$comment->language][0]['value']));
+    $debug_info['Content'] = $comment->mail[$comment->language][0]['value'];
     $num_condition++;
   }
 
   if ($num_condition) {
     $has_rows = $query->execute()->fetchField();
     if ($has_rows) {
-      antispam_anti_spambot_action(array(
-        t('E-mail') => $form_state['values']['mail'],
-        t('Comment') => $form_state['values']['comment']
-      ));
+      antispam_anti_spambot_action($debug_info);
     }
   }
 }
@@ -1434,7 +1437,7 @@ function antispam_notify_moderators($con
     $message_args = array(
       '@title-label' => t('Title'),
       '@content-title' => $content->title,
-      '@content-type' => $moderator_types[$content_->type],
+      '@content-type' => $moderator_types[$content->type],
       '!content-link' => url('node/'. $content->nid, array('absolute' => TRUE))
     );
   }
@@ -2011,7 +2014,8 @@ function antispam_prepare_comment_data($
 
   if ($provider == DEFENSIO_SERVICE) {
     // DEFENSIO
-    if ($content->signature != '') {
+    if (isset($content->signature) && $content->signature != '') { // 2011.1.8
+    // if ($content->signature != '') {
       // for submit spam/ham, we only needs signature
       $comment_data = array(
         'signature' => $content->signature,
@@ -2113,7 +2117,10 @@ function _antispam_parse_yaml_response($
     $line = trim($line);
     if ($line != '' && $line != "defensio-result:") {
       $line = preg_replace("/(.*): \"?([^\"]*)\"?/", "$1|$2", $line);
-      list($key, $data) = explode('|', $line);
+      $rec = explode('|', $line);
+      if (!isset($rec[1])) continue;
+      $key = $rec[0];
+      $data = $rec[1];
       $array[$key] = $data;
     }
   }
@@ -2228,7 +2235,7 @@ function antispam_api_cmd_comment_check(
     $response = _antispam_api_http_post($query_string, $api_host, '/app/'. DEFENSIO_API_VERSION .'/audit-comment/' . $api_key . '.yaml');
     if (!isset($response[1])) {
       watchdog('antispam', "cheking a content failed: can not get a response back from the service provider " . antispam_get_privider_name($provider, FALSE));
-      return ANTISPAM_API_RESULT_ERROR;
+      return array(ANTISPAM_API_RESULT_ERROR);
     }
     $res_array = _antispam_parse_yaml_response($response[1]);
     $result = array();
@@ -2253,9 +2260,12 @@ function antispam_api_cmd_comment_check(
 
     if (!isset($response[1])) {
       watchdog('antispam', "cheking a content failed: can not get a response back from the service provider " . antispam_get_privider_name($provider, FALSE));
-      return ANTISPAM_API_RESULT_ERROR;
+      return array(ANTISPAM_API_RESULT_ERROR);
     }
-    return ('true' == $response[1] ? array(ANTISPAM_API_RESULT_IS_SPAM) : array(ANTISPAM_API_RESULT_IS_HAM));
+    $result[0] = ('true' == $response[1] ? ANTISPAM_API_RESULT_IS_SPAM : ANTISPAM_API_RESULT_IS_HAM);
+    $result[1] = '';  // signature
+    $result[2] = 0.0; // spaminess
+    return $result;
   }
 }
 
