SMF anti-spam bots registration mod

Among other sites, I’m also an administrator on the romanian anime forum Manga-anime.ro. That forum is a SMF one and recently we had some problems with the spam bots registering our boards and spamming them with porn or pharmaceutical stuff. The root admin tried to install a SMF mod that should have prevented them from registering by making them solve some simple puzzles, but the mod just didn’t work. So I tried to make something myself, from scratch. I came with the idea of adding a simple math problem for them to solve: the sum of two numbers. The numbers are randomly generated from 1 to 5 so the sum should be pretty simple to solve by anyone. However, since I don’t know how SMF system works, this modification is not that complex or accurate.

In order to do this on your SMF site too, you must follow three simple steps.

Step 1. Editing the Register.template.php file

In this step, you will create the extra form where you will ask for the sum of those two numbers. You can find this file in each theme’s folder, but you only need to modify it for the default theme. It’s location should be themes/default-theme/Register.template.php. There, search for the part that generates the password fiels. It should look like this:

echo ‘
</td>
</tr><tr>
<td width=”40%”>
<b>’, $txt[81], ‘:</b>
</td>
<td>
<input type=”password” name=”passwrd1″ size=”30″ tabindex=”‘, $context[’tabindex’]++, ‘” />
</td>
</tr><tr>
<td width=”40%”>
<b>’, $txt[82], ‘:</b>
</td>
<td>
<input type=”password” name=”passwrd2″ size=”30″ tabindex=”‘, $context[’tabindex’]++, ‘” />
</td>
</tr>’;

Now, add below the following code:

/*spam bote code begin*/

$a=rand(1,5);
$b=rand(1,5);
$suma=$a+$b;
echo “<tr><td width=’40%’><b>In casuta urmatoare scrieti suma numerelor $a si $b:<b><td> <input type=’text’ name=’sumafals’ size =’30′ value=”></td></td></tr>”;
echo “<td><input type=’hidden’ name=’suma’ value=’$suma’></td>”;
/*spam bote code end*/

This part will generate the two random numbers from 1 to 5 and will send the correct sum among with the sum inputed by the user, so you can verify if he did the sum right or wrong. Now, we can move to the next step.

Step 2. Editing the Register.php file

You should be able to find this file in the Sources folder, placed in the root of your forum. Just like above, search for the part of the code that looks something like this:

// Make sure they came from *somewhere*, have a session.
if (!isset($_SESSION[’old_url’]))
redirectexit(’action=register’);

and then add below:

//the spam bot modification
if ($_POST[’sumafals’]!=$_POST[’suma’])
fatal_lang_error(’visual_verification_failed’, false);

Now you’re ready to move to the final step.

Step 3. Editing the errors language file.

This step isn’t actually necessary but you should do it anyways. In the default theme’s Languages directory, search the default language error file. In my case, it’s name is Errors.english.php. In this file, search for the following line:

$txt[’visual_verification_failed’] = ‘The letters you typed don\’t match the letters that were shown in the picture.’;

and modify it to display this message:

$txt[’visual_verification_failed’] = ‘The letters you typed don\’t match the letters that were shown in the picture or the sum was incorect.’;

And that was it! All done! I hope this will help you just as much as it helped me.

Tags: , , , , , ,
permalinkRead More CommentComments (1) CatSMF

One Response to “SMF anti-spam bots registration mod”

  1. unsecured card Says:

    Nice Site!
    http://google.com

Leave a Reply

CSS Template by RamblingSoul | Tomodachi theme by Theme Lab
Anime