Stop spam-bots in PHPBB 2.x. Cheap, easy BOT stopper

WARNING!  As of this writing, this information pertains to the 2.x branch of phpBB.  I strongly recommend you upgrade to the latest phpBB.  As of April 28, 2009 that version is 3.0.4.  Please see http://phpbb.com

NOTICE: I have an updated phpBB patch for the 3.0.x version of phpBB.  Please search this blog for phpBB or look at the phpbb category for more tips and tricks.

In your active template file profile_add_body.tpl find the line:

<!-- Visual Confirmation -->

ABOVE that line, add:

<!-- BOT HACK -->
   <tr>
      <td class="row1"><span class="gen">Are you a robot? *</span></td>
      <td class="row2"><select class="post" name="imarobot">
      <option value="yes">yes</option>
      <option value="yes">of course</option>
      <option value="nope">Humans choose this one</option>
      </select> <span class="gen">Bot buster... choose the right one.</span></td>
   </tr>
<!-- BOT HACK -->

In your forum file includes/usercp_register.php find this section of code:

   else if ( $mode == 'register' )
   {
      if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
      {
         $error = TRUE;
         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty'];
      }

AFTER that part, add this:

// BOT HACK
         if ( empty($HTTP_POST_VARS['imarobot']) )
         {
            die('NO BOTS');
         }
         else
         {
            if ($HTTP_POST_VARS['imarobot'] != 'nope')
            {
               die('NO BOTS');
            }
         }
// BOT HACK

And there you go.

This entry was posted in How Tos, php, phpbb, spam. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *