烦,随着Blog书写时间的增加,垃圾评论越来越多,近来更是出现了垃圾引用通告,并且一发就是上百个,让人删到手软,并且经常更改发送者名称,导致我之前的《小修改阻止Movable Type的垃圾评论》毫无作用,让人防不胜防。幸好这些垃圾评论和引用通告还是有些规律,因此照样能够通过修改Movable Type程序的相应文件来阻止它们,下面是具体的方法:
先来说垃圾评论的阻止,用UltraEdit等文本编辑器打开“MT所在路径/lib/MT/App”下的Comments.pm文件,搜索:
if (!$blog->allow_anon_comments &&
(!$comment->author || !$comment->email)) {
return $app->handle_error($app->translate(
"Name and email address are required."));
在其后面加上:
if ( $comment->author =~ /poker/ || $comment->author =~ /viagra/ || $comment->author =~ /phentermine/ || $comment->author =~ /valium/ || $comment->author =~ /debt/ || $comment->author eq "phentermine" || $comment->author eq "online poker" || $comment->author =~ /texas/ || $comment->author =~ /cialis/ || $comment->author =~ /credit/ || $comment->author =~ /gambling/ || $comment->author =~ /loans/ || $comment->author eq "credit cards" || $comment->author =~ /quotes/ || $comment->author eq "insurance quotes" || $comment->author =~ /online/ || $comment->author =~ /bontril/ || $comment->author =~ /casino/ || $comment->author =~ /nurnberg/ || $comment->author =~ /privat/ || $comment->author =~ /kaviar/ || $comment->author =~ /sex/ || $comment->author =~ /kontakte/ || $comment->author =~ /gambling/ || $comment->author =~ /wsop/ || $comment->author =~ /rape/){
return $app->handle_error($app->translate(
"TMD."));
再搜索:
if ($comment->url) {
require MT::Util;
if (my $fixed = MT::Util::is_valid_url($comment->url, 'stringent')) {
$comment->url($fixed);
} else {
return $app->handle_error($app->translate(
"Invalid URL '[_1]'", $comment->url));
}
}
在前面加上:
if ($comment->url =~ /wsop/ || $comment->url =~ /casino/ || $comment->url =~ /texas/ || $comment->url =~ /yelucie/ || $comment->url =~ /kontakte/) {
return $app->handle_error($app->translate(
"TMD."));
修改后,MT程序就可以通过发送者名称和发送者网址中的关键字来判断是否为垃圾评论。如$comment->url =~ /wsop/,只要发送者网址中存在wsop这四个字母,就被判断为垃圾评论,这样您就可以根据自己的需要增加相应的关键字。另外,"TMD."您也可以修改为自己喜欢的判断为垃圾评论后的返回提示,呵呵。
用同样的方法修改“MT所在路径/lib/MT/App”下的Trackback.pm文件,在其中搜索:
return $app->_response(Error=> $app->translate("Need a Source URL (url)."))
在前面加上:
if ($url =~ /poker/ || $url =~ /texas/ || $url =~ /yelucie/ || $url =~ /phentermine/ || $url =~ /casino/ || $url =~ /kontakte/) {
return $app->_response(Error => $app->translate("TMD."), Code => "403 Throttled");
至此,修改完毕,能够抵御不少垃圾评论和垃圾引用通告,以我想来,对中文Blog应该特别有用吧!
CcChen
我要崩溃啦....唉呀~
哥们,你的方法不凑效啊...
俺的MT在无时无刻的被spam中...而正常的trackblack就出现个HTTP error: 403 Throttled错误...唉...救命啊...大哥