You are here

function spam_url_filter in Spam 5

1 call to spam_url_filter()
spam_content_filter in ./spam.module
Determine whether or not provided text is spam.

File

./spam.module, line 1330

Code

function spam_url_filter($text) {
  if (variable_get('spam_filter_urls', 1)) {
    $weight = 0;
    $matches = 0;
    $result = db_query("SELECT token FROM {spam_tokens} WHERE probability >= %d AND token LIKE 'URL*%%'", variable_get('spam_threshold', 80));
    while ($url = db_fetch_object($result)) {
      $url = preg_replace('/^URL\\*/', '', $url->token);
      $match = preg_match_all("!{$url}!", $text, $temporary);
      $matches += $match;
      if ($match) {
        $weight += $match * WEIGHT_ALWAYS_SPAM;
        spam_log(SPAM_DEBUG, t("url filter: added @weight weight, matched URL '%url'", array(
          '@weight' => $match * WEIGHT_ALWAYS_SPAM,
          '%url' => $url,
        )));
      }
    }
  }
  if ($matches != 0) {
    spam_log(SPAM_LOG, t("url filter: matched @num times, adding weight of @weight", array(
      '@num' => $matches,
      '@weight' => $weight,
    )));
  }
  return $weight;
}