function antispam_anti_spambot_action in AntiSpam 7
Same name and namespace in other branches
- 6 antispam.module \antispam_anti_spambot_action()
Perform an anti-spambot action based on module settings.
Parameters
array $debug_info: Extra data, used here to enhance the logged information, for debugging purposes.
2 calls to antispam_anti_spambot_action()
- antispam_comment_presave in ./
antispam.module - Implements hook_comment_presave()
- antispam_node_validate in ./
antispam.module - Implements hook_node_validate().
File
- ./
antispam.module, line 1146 - Primary hook implementations for the Antispam module.
Code
function antispam_anti_spambot_action($debug_info) {
$antispambot_action = variable_get('antispam_antispambot_action', '503');
// First action is generate a delay, if requested to.
if (($seconds = variable_get('antispam_antispambot_delay', 60)) > 0) {
sleep($seconds);
}
// If no other action was set, we're done.
if ($antispambot_action == 'none') {
return;
}
$items = array();
foreach ($debug_info as $label => $value) {
$items[] = '<strong>' . check_plain($label) . '</strong>: ' . check_plain($value);
}
// From here on, the request is killed using different methods.
if ($antispambot_action == '403d') {
drupal_access_denied();
$message = t('Spambot detected (action: 403 Forbidden).');
}
elseif ($antispambot_action == '403') {
@header('HTTP/1.0 403 Forbidden');
print t('Access denied');
$message = t('Spambot detected (action: 403 Forbidden).');
}
else {
// 503
@header('HTTP/1.0 503 Service unavailable');
print t('Service unavailable');
$message = t('Spambot detected (action: 503 Service unavailable).');
}
watchdog('antispam', '%message<p>Additional information:</p>%items', array(
'%message' => $message,
'%items' => theme('item_list', $items),
));
module_invoke_all('exit');
exit;
}