function spam_scan in Spam 6
Same name and namespace in other branches
- 5.3 spam.module \spam_scan()
API call for scanning content for spam. If spam is found, the appropriate action will be taken.
5 calls to spam_scan()
- comment_spam_scan in content/
spam_content_comment.inc - Scan comment content before it is posted into the database.
- contact_spam_scan in content/
spam_content_contact.inc - Scan contact form content before it is sent to users.
- node_spam_scan in content/
spam_content_node.inc - Scan node content before it is posted into the database.
- user_spamapi in content/
spam_content_user.inc - User module _spamapi() hook.
- user_spam_scan in content/
spam_content_user.inc - Scan user before it is created in the database.
File
- ./
spam.module, line 31 - Spam module, v3 Copyright(c) 2006-2008 Jeremy Andrews <jeremy@tag1consulting.com>. All rights reserved.
Code
function spam_scan($content, $type, $extra = array(), $filter_test = FALSE) {
$id = spam_invoke_module($type, 'content_id', $content, $extra);
spam_log(SPAM_DEBUG, 'spam_scan', t('scanning content'), $type, $id);
$spam = spam_content_is_spam($content, $type, $extra, $filter_test);
if (spam_bypass_filters() || user_access('bypass filters')) {
spam_log(SPAM_DEBUG, 'spam_scan', t('bypassing spam actions'), $type, $id);
return $spam['score'];
}
_spam_update_statistics(t('scan @type', array(
'@type' => $type,
)));
if ($spam['is_spam']) {
spam_log(SPAM_DEBUG, 'spam_scan', t('content is spam'), $type, $id);
_spam_update_statistics(t('detected spam @type', array(
'@type' => $type,
)));
switch (variable_get('spam_visitor_action', SPAM_ACTION_PREVENT)) {
case SPAM_ACTION_PREVENT_SILENT:
spam_log(SPAM_LOG, 'spam_scan', t('content is spam, action(prevent silently)'), $type, $id);
_spam_update_statistics(t('silently prevented spam @type', array(
'@type' => $type,
)));
// TODO: We redirect to avoid the content being posted, but we should
// be much smarter about where we redirect to.
drupal_goto('');
break;
case SPAM_ACTION_UNPUBLISH:
spam_log(SPAM_LOG, 'spam_scan', t('content is spam, action(unpublish)'), $type, $id);
_spam_update_statistics(t('prevented spam @type', array(
'@type' => $type,
)));
if ($id) {
spam_unpublish($type, $id, $extra);
}
break;
case SPAM_ACTION_HOLD:
$_SESSION['spam_content'] = serialize((array) $content);
$_SESSION['spam_type'] = $type;
spam_log(SPAM_LOG, 'spam_scan', t('content is spam, holding'), $type, $id);
_spam_update_statistics(t('held spam @type', array(
'@type' => $type,
)));
if ($id) {
spam_hold($type, $id, $content);
}
break;
case SPAM_ACTION_PREVENT:
spam_log(SPAM_LOG, 'spam_scan', t('content is spam, action(prevent)'), $type, $id);
default:
$_SESSION['spam_content'] = serialize((array) $content);
$_SESSION['spam_type'] = $type;
_spam_update_statistics(t('prevented spam @type', array(
'@type' => $type,
)));
drupal_goto('spam/denied');
break;
}
}
}