function spam_filter_surbl_spam_filter in Spam 6
Search for known spam urls in content.
1 call to spam_filter_surbl_spam_filter()
- spam_filter_surbl_spamapi in filters/
spam_filter_surbl/ spam_filter_surbl.module - Spam hook_spamapi implementation.
File
- filters/
spam_filter_surbl/ spam_filter_surbl.module, line 96 - Surbl filter plug in for the spam module. Copyright(c) 2007-2008 Jeremy Andrews <jeremy@tag1consulting.com>.
Code
function spam_filter_surbl_spam_filter($content, $type, $fields, $extra = array(), $filter_test = FALSE) {
$action = array();
$id = spam_invoke_module($type, 'content_id', $content, $extra);
$spam = FALSE;
$urls = _spam_filter_surbl_url_extract($content, $type, $fields, $extra);
if (is_array($urls) && !empty($urls)) {
foreach ($urls as $url) {
$lookup = "{$url}.multi.surbl.org";
$ip = gethostbyname($lookup);
if ($ip != $lookup) {
// this domain was in a SURBL, process accordingly
preg_match("/[^\\.\\/]+\$/", $ip, $code);
if ($code[0] & SPAM_FILTER_SURBL_SC) {
spam_log(SPAM_IMPORTANT, 'spam_filter_surbl_spam_filter', t('found spam url(@url) @surbl', array(
'@url' => $url,
'@surbl' => t('SpamCop message-body URI domains'),
)), $type, $id);
}
if ($code[0] & SPAM_FILTER_SURBL_WS) {
spam_log(SPAM_IMPORTANT, 'spam_filter_surbl_spam_filter', t('found spam url(@url) @surbl', array(
'@url' => $url,
'@surbl' => t('sa-blacklist domains'),
)), $type, $id);
}
if ($code[0] & SPAM_FILTER_SURBL_PH) {
spam_log(SPAM_IMPORTANT, 'spam_filter_surbl_spam_filter', t('found spam url(@url) @surbl', array(
'@url' => $url,
'@surbl' => t('Phishing data source'),
)), $type, $id);
}
if ($code[0] & SPAM_FILTER_SURBL_OB) {
spam_log(SPAM_IMPORTANT, 'spam_filter_surbl_spam_filter', t('found spam url(@url) @surbl', array(
'@url' => $url,
'@surbl' => t('Outblaze URI blacklist'),
)), $type, $id);
}
if ($code[0] & SPAM_FILTER_SURBL_AB) {
spam_log(SPAM_IMPORTANT, 'spam_filter_surbl_spam_filter', t('found spam url(@url) @surbl', array(
'@url' => $url,
'@surbl' => t('AbuseButler spamvertised sites'),
)), $type, $id);
}
if ($code[0] & SPAM_FILTER_SURBL_JP) {
spam_log(SPAM_IMPORTANT, 'spam_filter_surbl_spam_filter', t('found spam url(@url) @surbl', array(
'@url' => $url,
'@surbl' => t('jwSpamSpy + Prolocation data source'),
)), $type, $id);
}
$action['spam_filter_surbl'][] = array(
'url' => $url,
'probability' => 99,
);
$spam = TRUE;
}
else {
spam_log(SPAM_DEBUG, 'spam_filter_surbl_spam_filter', t('not spam url(@url)', array(
'@url' => $url,
)), $type, $id);
}
}
}
if ($spam) {
$action['total'] = 99;
}
else {
$action['total'] = 0;
}
return $action;
}