Scode in Movable Type 3.2

| 3 Comments | No TrackBacks

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 http://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之后,校验码就出现了。


作者: David Yin
原载: FreeThinking
版权所有。转载时必须以链接形式注明作者和及本声明。

No TrackBacks

TrackBack URL: http://www.yinfor.com/mtcgi/mt-t-0912.cgi/699

3 Comments

您好:

我在裝這支插件的時候出了問題,只要一按發表鍵,就會出現底下的錯誤訊息↓

=======
迴響提交錯誤
您的迴響無法提交是因為以下原因:

為防止氾濫的垃圾評論,我開啟了如下功能,即評論人發表評論後,需要等待一小段時間才能夠再次發表評論。請嘗試等待一段時間後再發表評論,謝謝你的耐心。

請以以下方式更正錯誤,然後再發表您的迴響。
=======

可是,我看我該做更改的地方都改過了,檔案權限也都設成755了,不知道為什麼還會出現這種錯誤,可以麻煩你幫我看看嗎?!

多謝~

在Mt的设置里,在feedback部分,试着设置如下,Accept comments:Anyone
Immediately publish comments from: Anyone

现在的新版Scode可以在下面的网址找到。
http://plugins.movalog.com/scode/

Leave a comment

About this Entry

This page contains a single entry by David Yin published on 2005年8月26日 01:47.

MovableType3.2 终于现身了 was the previous entry in this blog.

怪癖停止传播 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Archives

Online Tools

Code Convertor
GeoURL
Listed on BlogShares