« 07.17 ぎりぎりセーフ | ココ | 07.18 萌えビジネスに参戦 »
2006年7月18日
コメントスパム対策(2)
最近、TBスパムばっかり来るなぁ…と溜めに溜めたあとに一気に消す日々が続いてたけど。TBスパムのパターンが掴めたんで、TBスパムを弾くプログラムを組み入れたら、めっきり来なかったコメントスパムがまた来るように。
ということで、TBスパムと同じ作戦でコメントスパムを判定するようにしてみた。
sub post {
...
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->text contains $comment->url, block the comment.
if ($comment->text =~ /$comment->url/) {
return $app->handle_error($app->translate(
"You are not allowed to post comments."));
}
# --ここまでreturn $app->handle_error($app->errstr()) unless $comment;
## Here comes the fancy logic for deciding whether or not the
## comment appears.
{$MT}/lib/MT/App/Comments.pmに「#ここから…#ここまで」のコードを加える。と。
ちなみに、トラックバックスパム対策は、.../App/Trackback.pmに
sub ping {
...
if (my $fixed = MT::Util::is_valid_url($url || "")) {
$url = $fixed;
} else {
return $app->_response(Error =>
$app->translate("Invalid URL '[_1]'", $url));
}# --ここから
## filter out the spam trackbacks.
if ($title eq $blog_name) {
return $app->response;
}
# --ここまでrequire MT::TBPing;
と入れる。
By ただ at 02:50 カテゴリー ; さんぷるライブラリー , PinMarch Samples , Perl , MT , mein Erbe
« 07.17 ぎりぎりセーフ |
07月の記事
| 07.18 萌えビジネスに参戦 »
トラックバック
このエントリーのトラックバックURL:
http://pinmarch.sakura.ne.jp/mt/mt-tb.cgi/576
このリストは、次のエントリーを参照しています: コメントスパム対策(2):
昨日のコメントスパムチェック、チェックする場所間違えてた。 $comment->...
トラックバック時刻: 2006年7月19日 22:34