Stefan Geen’s simple Turing test hack for MT 3.x

Stefan Geen’s simple anti-spam Turing test hack is fantastically efficient – you’ll almost never get any spam. Unlike MT’s anti-spam measures, it saves bandwidth (and, of course, it actually works); unlike Blogger’s turing test, it’s not unbelievably tedious. I’ve put together a tutorial for people who use MT 3.x. (An improved version of the one by Patrik Strang’s, which is no longer online). If you have older version of MT you can read Stefan’s original post (don’t miss the updates).

The hack involves requiring a human mind to complete a simple instruction, such as “type the letter ‘F’ in this textbox” or “Type the third letter of this sentence in the textbox,” before MT accepts the accompanying comment.

Here’s how you do it: In your cgi-bin folder, locate the file The filepath should end with /lib/MT/App/ or something similar (It depends on what version of MT you have). Click edit and do a search for the following piece of code:

if (!$q->param(‘text’)) {
return $app->handle_error($app->translate(“Comment text is required.”));

Right under it, you add:

unless ($q->param(‘spam’) eq ‘F’) {
return $app->handle_error($app->translate(“Type the anti-spam text exactly as shown.”));

Save and close.

Then you must paste this snippet of code

<p><label for=”spam”>Today’s anti-spam measures are brought to you by the letter “F”. Please type it here:</label> <input id=”spam” name=”spam” />

in three different places, which all contain the form elements for commenting:

First you must open the file (In early versions of MT3 it’s called The filepath should be something like cgi-bin/mt/lib/MT/Template/ Search the code for

<p><label for=”url”>URL:
<input tabindex=”1″ type=”text” name=”url” id=”url” value=”$comment_url” />

and add the snippet of code.

Then search for

<p><label for=”url”><MT_TRANS phrase=”URL:”>
<input tabindex=”3″ type=”text” name=”url” id=”url” value=”$comment_url” />

and add the same snippet. Save and close.

Now go to the templates screen in the MT control panel, click on the Individual Entry Archive Template and paste the same lines a third time; under the comment submission form code.

What happens now is that when a comment is submitted, MT checks that the accompanying question is answered correctly; if it is, the comment is accepted. The question is asked in the HTML, the answer is found in the code.