Drupal 7: how to block the spam

A big problem for the owners of a web site is the spam by the bots. Me too in this little website that i made with Drupal 7 i had this problem and is for this reason that until some month ago i was usually moderate each single comment approving or deleting it and banning its ip but for me this was a boring operation.

Really annoyed by the spam comment bots i decided to solve the problem and after several months i can tell that i did it. To win the battle against the bots we can simply use these modules:

  • Simple Anti-Spam: this module adds at any form to protect a visible checkbox to check to confirm you are a human and an hidden checkbox that is visible only in the HTML code to not check but that the bots also check because they complete every field present in the code of a page; also it allows filtering of the forms according to a blacklist of words and on the basis of the PHP code; finally it allows to automatically ban an IP after a number of attempts
  • Comment Trust: this module give us the ability to approve the email address instead of the comment
  • Comment IP: this module helps to delete a comment and automatically ban its ip
  • CAPTCHA: this module adds a question to the comments to understand if the user is an human or a bot
  • Boost Captcha: this module is necessary to use the module CAPTCHA with the module for caching BOOST
  • Honeypot: this module adds a field in the HTML for any form of the page, this field is hidden and it is visible only in the code so when it is completed then the comment is locked, the bots scan the page's code and they complete every form present in it and for this the module Honeypot is really great

 

How to configure Simple Anti-Spam:

Simple Anti-Spam is a simple but very powerful module that if properly configured can make the life very hard for bots that try to spam a site.

In Form ID's we have to insert the forms of the site that we want to protect with the final wording |100 :

user_register_form|100
user_login|100
user_login_block|100
user_pass|100
contact_site_form|100
comment_node_blog_form|100

In Stop Words beyond our black list of words we can enter:

[url
comment_body

that are typical fileds of automated bots that attack websites with Drupal.

In PHP Code we can have fun, I put in this code:

if (preg_match('#(\.il|\.in|\.ir|\.pw)#i', $text)) { return 'text contains link at banned domain'; }

to block comments with links to domains that bots spam continuously.

Tags: