Scode in Movable Type 3.2

作者:


最后更新于 | 最初发布于 | 分类:


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 GD

ppm> 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."));
}
在后面加上
#
# 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)打开lib/MT/Template/ContextHandlers.pm,查找_hdlr_comment_fields子函数,
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 />
<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" /><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$>" />
<img border="0" src="<$MTCGIPath$><$MTSecurityImage$>?code=<$MTSecurityCode$>"><br />
<input tabindex=3 id="scode" name="scode" /><br /><br />
<!-- end of Security Code Check -->

8)重建您的Blog之后,校验码就出现了。





关于作者
搜索
归档

Online Tools

Code Convertor