Site icon David Yin's Blog

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
IIS
Movable type 3.121
ActivePerl 5.8


step1:
Install GD Perl module.


ppm> install GD
 ppm> rep add NewRepSite http://theoryx5.uwinnipeg.ca/ppms/
 ppm> search GD
 ppm> install GD

 

Step2:
1)Download SCode plugin,extract it;
2)edit SCode.pm, 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 SCode.pm to the folder lib/MT/, scode.pl to folder plugins/, mt-scode.cgi to root folder of MT, and give mt-scode.cgi right to executable.
5)open lib/MT/App/Comments.pm, 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."));
 }
 MT::SCode::scode_delete($code);
 MT::SCode::scode_create($code);
 #
 # Security hack ends
 #

6)Open lib/MT/Template/Context.pm, 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++;
 MT::SCode::scode_create($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.

Exit mobile version