zubrag.com
Free php and cpanel scripts to automate your daily routine

Articles :: Spam Protection


Sooner or later spammers will find your site, and will flood it with spam. You'll need some kind of spam protection to stop spam.

One thing one may try is adding CAPTCHA. This measure can stop spam bots (automated spam programs). But this kind of protection cannot prevent spam generated by real people (spammers can easily find a workforce on freelance sites for $1/hour or even less).

Hopefully there are free online stop spam services. Their databases updated on a daily basis contain emails, usernames, and IPs of spammers. They also provide an interface (API) for checking whether email, username, or IP exists in their known spammers database. You can query their spam database and decide how to proceed based on result. Unfortunately, even some widespread software does not have a feature of checking emails against third party services. So you'll either have to search for plugins (preferred approach for beginners), or add spam protection by yourself.

I will not describe how to install spam protection plugins as different software has different plugin installation instructions. For me, it was easier to minimize spam by changing the code.

  • SMF (Simple Machines Forum)
    • locate Security.php file in the folder where you have forum installed. It resides in Sources/ folder by default.
    • in this file, find following code
      // Can't ban an empty email
      if (empty($email) || trim($email) == '')
      	return;
      
    • and put following code after it
      // check against stopforumspam.com spam database
      $res = @file_get_contents('http://www.stopforumspam.com/api?email=' . $email);
      if (($res !== FALSE) && (@strpos($res,'<appears>yes</appears>') > 0)) {
          die("Sorry, your email listed in spammers database. Please contact administrator at example.com for assistance if you think it is by error.");
      }
      
    • save/override Security.php on server
  • PHPBB
    • locate ucp_register.php file in the folder where you have forum installed. It resides in includes/ucp/ folder by default.
    • in this file, find following: // validate custom profile fields
    • and put following code before it
      // check against stopforumspam.com spam database
      $res = @file_get_contents('http://www.stopforumspam.com/api?email=' . $data['email']);
      if (($res !== FALSE) && (@strpos($res,'<appears>yes</appears>') > 0)) {
          die("Sorry, your email listed in spammers database. Please contact administrator at example.com for assistance if you think it is by error.");
      }
      
  • you can verify spam protection by trying to register as new user using one of blacklisted emails, like g2fsehis5e_at_mail.ru
  • Will update this post with "stop spam" instructions for vbulletin as soon as I have them.


    Comments

    May 10, 2016
    comentario
    seveninternetuk [anti-spam] gmail.com
    October 26, 2016
    Your blog is so informative thanks for sharing. This is a great information for Spam Protection.Keep it up!

    Add Comment

    E-mail or Name: Not required. Email will be protected from spammers

    Comment: Please do not post unrelated comments

    Anti-spam: Please enter (0c46600a) into the box