Security Code Plug-in English Version

To serve the net friend Niklas only know English.
Now I want to post the english version of how to install the Security Code Plugin.
My platform:

Windows server2003
Movable type 3.121
ActivePerl 5.8

Install GD Perl module.

ppm> install GD
 ppm> rep add NewRepSite
 ppm> search GD
 ppm> install GD


1)Download SCode plugin,extract it;
2)edit, modify “my $tmpdir” to temporary folder of your server, “my $scode_length” is the length of code, “my $scode_maxtmp” is the max number of security code generated at the same time, default is 50.
temporary folder must be given the right to write such as: c:/website/mt/tmp/
3)Modify “mt-scode.cgi”, $c_background,$c_border, $c_line, $c_code is the color of the Security Code.
4)Upload to the folder lib/MT/, to folder plugins/, mt-scode.cgi to root folder of MT, and give mt-scode.cgi right to executable.
5)open lib/MT/App/, find

if (!$q->param('text')) {
 return $app->handle_error($app->translate("Comment text is required."));


add following code after above:

 # SecurityCode hack start
 require MT::SCode;
 my $code = $q->param('code');
 my $scode = $q->param('scode');
 my $sscode = MT::SCode::scode_get($code);
 if ($scode ne $sscode) {
 return $app->handle_error($app->translate(
 "Wrong or missing Security Code."));
 # Security hack ends

6)Open lib/MT/Template/, find “_hdlr_comment_fields” function,

sub _hdlr_comment_fields { my ($ctx, $args, $cond) = @_;

after that add following:

# Security code validation
 srand int (time/10)+$$;
 my $securitycode = int rand(MT::SCode::scode_tmp()); $securitycode++;
 # End Security code hack

find another two place:

<MT_TRANS phrase="Remember me?">
 <input type="radio" id="remember" name="bakecookie" />

add following code after them:

<!-- Security Code Check -->
 <input type="hidden" id="code" name="code" value="$securitycode" />
 <label for="scode">Security Code:</label>
 <img border="0" alt="Please enter the security code you see here" src="$path/mt-scode.cgi?code=$securitycode" /><br /> <input tabindex="3" id="scode" name="scode" />
 <!-- end of Security Code Check -->

7)Edit Individual Entry Archive, under

<label for="url">URL</label>
 <input tabindex="3" id="url" name="url" />


please add following:

<!-- Security Code Check -->
 <label for="scode">SCode:</label>
 <input type="hidden" id="code" name="code" value="<$MTSecurityCode$>" />
 <img border="0" src="<$MTCGIPath$><$MTSecurityImage$>?code=<$MTSecurityCode$>">
 <input tabindex=3 id="scode" name="scode" />
 <!-- end of Security Code Check -->

8) Now, rebuild your Blog, the Security code appears.


  1. David, Thanks for the download link. Now, I really really need your help. Ok, I set up everything according to your instructions. Everything seem ok in term of the installation/hack, but there is no scode image. Is just blank with no error. I ran the scodetest.cgi and this is what it returns:
    Step 1.1 OK : is installed
    Step 1.2 OK : GD is installed
    Step 1.3 OK : GD has PNG support
    Step 3.0 OK : is installed
    Step 2.0 OK : $tmpdir in is defined properly
    NOTE: This script does not test the Step 4 to 7 of the installation guide, namely
    4. mt-scode.cgi is installed in the main directory and executable
    5. is installed in plugins directory
    6. is patch properly with the neccessary testing
    7. template is patch properly with the neccessary tags
    Please also note you have to additional installation if you are using MT 3.x. See README for more details
    Is not working because it required the jpg lib? Or what can it be? I been banging my head and can’t seem to figure it out. Any help would be greatly appreciate.

  2. 还在不断地改进

      参考楚水网志的做法把mt.cgi, mt-comments,cgi和mt-tb.cgi都改名了。这样一般的自动垃圾留言程序就没办法了。   由于管理界面顶上有广告,所以在nav toolbar上增加了个Logout的链接,这下方便�…

Leave a Reply

Your email address will not be published.