You are here

function spam_update_statistics in Spam 5.3

Increment internal counters.

9 calls to spam_update_statistics()
spam_content_filter in ./spam.module
API call to determine the likeliness that a given piece of content is spam, returning a rating from 1% likelihood to 99% likelihood. It is unlikely that you want to call this function directly.
spam_content_insert in ./spam.module
This function is called when new content is first posted to your website.
spam_content_update in ./spam.module
This function is called when content on your website is updated.
spam_mark_as_not_spam in ./spam.module
Invoke appropriate actions for marking content as not spam. TODO: Integrate with the Actions module, making actions fully configurable.
spam_mark_as_spam in ./spam.module
Invoke appropriate actions for marking content as spam. TODO: Integrate with the Actions module, making actions fully configurable.

... See full list

File

./spam.module, line 387

Code

function spam_update_statistics($name, $op = '+', $inc = 1) {
  if ($op != '+' && $op != '-') {
    watchdog('spam', t('Invalid operator(@op), ignored.', array(
      '@op' => $op,
    )));
  }
  spam_log(LOG_DEBUG, 'spam_update_statistics', t('@name = @name @op @inc', array(
    '@name' => $name,
    '@op' => $op,
    '@inc' => $inc,
  )));
  db_query("UPDATE {spam_statistics} SET count = count %s %d, timestamp = %d WHERE name = '%s'", $op, $inc, time(), $name);
  if (!db_affected_rows()) {
    if ($op == '-') {
      $inc *= -1;
    }
    db_query("INSERT INTO {spam_statistics} (name, count, timestamp) VALUES('%s', %d, %d)", $name, $inc, time());
  }
}