function httpbl_comment_presave in http:BL 7
Same name and namespace in other branches
- 8 httpbl.module \httpbl_comment_presave()
Implementation of hook_comment_presave()
Checks and Blocks comment submissions from nuisance IPs
File
- ./
httpbl.module, line 151 - Implementation of http:BL for Drupal. It provides IP-based blacklisting through http:BL and allows linking to a honeypot.
Code
function httpbl_comment_presave($comment) {
if (variable_get('httpbl_check', HTTPBL_CHECK_NONE) != HTTPBL_CHECK_COMMENTS) {
return;
}
if ($logs = variable_get('httpbl_log', HTTPBL_LOG_MIN) == HTTPBL_LOG_VERBOSE) {
watchdog('httpbl', 'Checking user\'s IP during comment pre-save.', array(), WATCHDOG_DEBUG, NULL);
}
if (httpbl_check()) {
// Comment user's IP found in Project Honeypot.
// Let them know
drupal_set_message(t('Your comment was rejected because your IP address is ranked "suspicious" by Project Honeypot.'), 'error', FALSE);
// alter the comment subject and body
$comment->status = 0;
// Force comment to unpublished status
$comment->subject = t('(THIS COMMENT HAS BEEN HONEY-BLOCKED!)');
$comment->comment_body[LANGUAGE_NONE][0]['value'] .= t('<strong><<<<<< This comment was blocked and unpublished because <a href="http://www.projecthoneypot.org/">Project Honeypot</a> indicates it came from a suspicious IP address.</strong>');
// Add to our statistics
if (variable_get('httpbl_stats', TRUE)) {
variable_set('httpbl_stat_comment', variable_get('httpbl_stat_comment', 0) + 1);
}
}
return;
}