Now Movable Type 3.2 is released.
To enable Scode plugin with the New Version of MT, some code have to be changed.
There is installation instructions for MovableType 3.2 based on original readme file of Scode 0.1c and my guide for MovableType 3.17.
step1:GD Perl 模块安装。
ppm> install GDppm> rep add NewRepSite https://theoryx5.uwinnipeg.ca/ppms/
ppm> search GD
ppm> install GD
Step2:参考了〔给MT加上防范发广告机器人的校验码〕
1)下载SCode plugin,解压缩;
2)编辑解压缩后的SCode.pm,修改my $tmpdir为您服务器的暂存目录,my $scode_length为校验码长度,my $scode_maxtmp为最多同时能够产生多少个校验吗,默认为50,若您的Blog访问人数较多,请适当调整此值;
暂存目录要可读写 例如:c:/website/mt/tmp/
3)修改mt-scode.cgi,$c_background、$c_border、$c_line、$c_code可以设置校验码的颜色;
4)将SCode.pm上传到MT安装目录的lib/MT/目录,scode.pl到plugins/目录,mt-scode.cgi到根目录,并修改mt-scode.cgi属性为可执行;
5)打开lib/MT/App/Comments.pm,找到if (!$q->param('text')) {在后面加上
return $app->handle_error($app->translate("Comment text is required."));
}
#6)打开lib/MT/Template/ContextHandlers.pm,查找_hdlr_comment_fields子函数,
# 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
#
sub _hdlr_comment_fields { my ($ctx, $args, $cond) = @_;在其后添加
# 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
<MT_TRANS phrase="Remember me?">
<input type="radio" id="remember" name="bakecookie" />
在其后都添加
<!-- Security Code Check -->
<input type="hidden" id="code" name="code" value="$securitycode" />
<label for="scode">Security Code:</label><br />
<amp-img layout="responsive" 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" /><br /><br />
<!-- end of Security Code Check -->
7)编辑Individual Entry Archive,在
<label for="url">URL</label><br />即评论的网页地址输入下面加上
<input tabindex="3" id="url" name="url" /><br /><br />
<!-- Security Code Check -->
<label for="scode">SCode:</label><br />
<input type="hidden" id="code" name="code" value="<$MTSecurityCode$>" />
<amp-img layout="responsive" border="0" src="<$MTCGIPath$><$MTSecurityImage$>?code=<$MTSecurityCode$>"><br />
<input tabindex=3 id="scode" name="scode" /><br /><br />
<!-- end of Security Code Check -->
8)重建您的Blog之后,校验码就出现了。