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.
Nice Site!
http://google.com
wonderful it works! (well actually there is a small spelling mistake that needs to be altered on the “spam bote code” for Registertemplate.php that you added..
it comes in the bit that says - size =’30′ value=” (<<look at the dittos here - you have to change it to two single dittos )
if u change that it works.
Thannk you i was being terribly spammed and had to moderate new memberships manually.
Actually, it’s not exactly a spelling mistake, is more of a bug of the text editor that I used at that time.
Now, I’m using Notepad++ so I don’t have this sort of problems anymore!
Great stuff. I was too sure about this story. But this helped a lot so thanks
Great blog. Just stumbled here late on Christmas day - but I’ll definitely be back - - Happy new year to all
Let me see, whether this is working or not….
Do you work in this industry? YOu seem to know a lot about the subject.
Wicked site man. I really like the theme you used. Is it a free one?
what a nice share…
yup, many spams come to our “smf” forum…
then I have told our admins about what u explained above
but our admins replied, “Yes we’ve known bout that since a long time ago, but we have no time to implement that..”
btw,
do u know where can i get spamming tools for SMF forum??
(not for negative things, only for learning)
rgds
a SAP lover