You are here

function httpbl_comment in http:BL 5

Same name and namespace in other branches
  1. 6.2 httpbl.module \httpbl_comment()
  2. 6 httpbl.module \httpbl_comment()

Implementation of hook_comment().

File

./httpbl.module, line 61
Implementation of http:BL for Drupal. It provides IP-based blacklisting through http:BL and allows linking to a honeypot.

Code

function httpbl_comment($comment, $op) {
  if (variable_get('httpbl_check', 0) != 1) {
    return;
  }
  switch ($op) {
    case 'insert':
    case 'update':
      $comment = (object) $comment;
      $blacklisted = httpbl_blacklisted();
      if ($blacklisted != 0) {

        // Unpublish and inform the user.
        $operation = comment_operations('unpublish');
        $query = $operation['unpublish'][1];
        db_query($query, $comment->cid);
        drupal_set_message(t('Your comment has been queued for moderation by site administrators and will be published after approval.'));

        // Add to our statistics
        if (variable_get('httpbl_stats', TRUE)) {
          variable_set('httpbl_stat_comment', variable_get('httpbl_stat_comment', 0) + 1);
        }
      }
      return;
  }
}