You are here

function spambot_sfs_request in Spambot 6.3

Same name and namespace in other branches
  1. 8 spambot.module \spambot_sfs_request()
  2. 7 spambot.module \spambot_sfs_request()

Invoke www.stopforumspam.com's api

Parameters

$query: A keyed array of url parameters ie. array('email' => 'blah@blah.com')

$data: An array that will be filled with the data from www.stopforumspam.com.

Return value

TRUE on successful request (and $data will contain the data), FALSE if error

$data should be an array of the following form: Array ( [success] => 1 [email] => Array ( [lastseen] => 2010-01-10 08:41:26 [frequency] => 2 [appears] => 1 )

[username] => Array ( [frequency] => 0 [appears] => 0 ) )

3 calls to spambot_sfs_request()
spambot_account_is_spammer in ./spambot.module
Checks an account to see if it's a spammer. This one uses configurable automated criteria checking of email and username only
spambot_user_register_validate in ./spambot.module
Validate the user_register form
spambot_user_spam_admin_form_submit in ./spambot.pages.inc

File

./spambot.module, line 232

Code

function spambot_sfs_request($query, &$data) {

  // An empty request results in no match
  if (empty($query)) {
    return FALSE;
  }

  // Use php serialisation format
  $query['f'] = 'serial';

  // Change to use http_build_query() once PHP 4.x can be dropped
  $params = array();
  foreach ($query as $key => $value) {
    $params[] = $key . '=' . urlencode($value);
  }
  $url = 'http://www.stopforumspam.com/api?' . join('&', $params);
  $result = drupal_http_request($url);
  if (!empty($result->code) && $result->code == 200 && empty($result->error) && !empty($result->data)) {
    $data = unserialize($result->data);
    if (!empty($data['success'])) {
      return TRUE;
    }
    else {
      watchdog('spambot', t("Request unsuccessful: @url <pre>\n@dump</pre>", array(
        '@url' => $url,
        '@dump' => print_r($data, TRUE),
      )));
    }
  }
  else {
    watchdog('spambot', t("Error contacting service: @url <pre>\n@dump</pre>", array(
      '@url' => $url,
      '@dump' => print_r($result, TRUE),
    )));
  }
  return FALSE;
}