给MT加上防范发广告机器人的校验码

引用通告(3) 评论(7)

Blog写的久了,总有一些广告机器人滥发评论,垃圾留言是越来越多。本来想使用jayallen.org推出的阻止垃圾留言的控件MT-Blacklist,或者是QinYun阻止Movble Type垃圾留言的另一种方法,但MT-Blacklist使用较为复杂,QinYun的方法需要修改的模板太多。不过后来发现了jsen写的校验插件(SCode plugin, security code plugin),能够有效防止滥发垃圾邮件。

1.在安装之前,首先需要确定的是您的主机安装有GD模块;

2.在此处下载SCode plugin,解压缩;

3.编辑解压缩后的SCode.pm,修改my $tmpdir为您服务器的暂存目录,my $scode_length为校验码长度,my $scode_maxtmp为最多同时能够产生多少个校验吗,默认为50,若您的Blog访问人数较多,请适当调整此值;

4.修改mt-scode.cgi,$c_background、$c_border、$c_line、$c_code可以设置校验码的颜色;

5.将SCode.pm上传到MT安装目录的lib/MT/目录,scode.pl到plugins/目录,mt-scode.cgi到根目录,并修改mt-scode.cgi属性为755;

6.打开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 #

7.打开lib/MT/Template/Context.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 -->

8.编辑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 -->

9.重建您的Blog,校验码就出现了,可以有效防止评论机器人滥发垃圾留言

引用通告(3)

被引用的日记: 给MT加上防范发广告机器人的校验码

TrackBack URL for this entry: http://www.thinkjam.org/loveblog/tjtb.cgi/48.
如果您想引用这篇日记到您的Blog,
请复制上面的链接,放置到您发表文章时的相应界面中。

» 来自David Yin's BLOG:Security Code Plug-in installed successfully

终于安装成功了,花了超过5个小时。下面把自己安装的过程简述一下,做一记录,供有相同或类似经历的朋友参考: 我的平台是: Windows server2003 IIS Movable type 3.121 ActivePerl 5.8 最初是在Learning ... 阅读更多细节

Ping Back来自:www.donews.net 阅读更多细节

关于如何在Movable Type上禁止Spam(垃圾留言),以前有朋友问起这些问题,写一个比较完整的版本在这里: 1] Spam 的工作原理 Spam 搜索网络上现有的,已知的 comment 的资源位置,例如MT的 mt-comments.cgi comment.cgi -spam,然后从中找到这些资源的URL。 或者搜索一些明... 阅读更多细节

评论(7)

试图安装MT BLACKLIST,未遂。
又想安装SCode plugin,可是又找不到GD模块。
请问如何在如下环境安装GD模块和SCode plugin.
Windows server2003
IIS
Movable type 3.121
ActivePerl 5.8

平生一笑 于 November 7, 2004 11:04 AM

没有安装过,不过看到可以在命令行下输入perl -MCPAN -e "install 'GD'"安装,参照了[url=http://www.sztest.net/download/Bugzillia%20install.txt]http://www.sztest.net/download/Bugzillia%20install.txt[/url]。

David Yin 于 November 7, 2004 4:01 PM

还是看不到图片,估计是GD,和GD Lib 问题。
不明白GD 和 GD Lib是什么东西?有什么区别?

平生一笑 于 November 7, 2004 11:54 PM

[url=http://www.cgier.com/cgi-bin/topic.cgi?forum=4&topic=7]http://www.cgier.com/cgi-bin/topic.cgi?forum=4&topic=7[/url],按照这里的试试。

David Yin 于 November 8, 2004 4:30 AM

多谢,可以了,我在“布拉格的春天”找到安装GD的方法了。

不好意思,近来想要安装GD模组,找到这篇旧文章,有一些问题~

1.我当初安装movable type时,并没有多安装perl模组,去查询目录,发现在C:\Program Files\OurInternet\Common\parl底下,只有perl.exe跟parl.exe等几个档案,像是ppm这些都没有,请问这种情况下该如何安装GD呢?

2.在SCode.pm的部份,my $tmpdir这一行,因为我的系统是windows平台,我的目录写法这样可以吗?
my $tmpdir = "C:\Program Files\temp\"

抱歉唐突问了这些问题~

I love this blog! Come visit my site, it's the only free and open MLS in all of Mexico. Ajijic real estate, chapala real estate, mexico city real estate, you name it, it's a free MLS.

发表评论

最新发布

世界地球日
猛然间看到Google换了Logo,肯定是有什么大日子发生。果然,今天是一年…
Google提供域名Whois信息查询服务
昨天在DRL看到有坛友发此信息,追究起来,出处应该还是GSeeker,正好这…
入吾彀中
【解释】:彀:张满弓弩;彀中:指箭能射及的范围,比喻牢笼,圈套。进入了我的弓箭射…