やっぱり続くコメントスパム[MT5]

2011年8月10日

MTのバージョンアップしたものの、何が楽しいんか、英文が並んだコメントが続々書きこまれてます。この手のもんは、バージョンアップしても解消せんのね。

しゃーないので、何か対策はないかと検索。

keystrokesというプラグインが有効みたいなので、それを使ってみることにした。

[参考サイト]

 

keystrokesのダウンロード

1)まずは配布サイトにいき、keystrokes-0.1.5をダウンロード。リンクは0.1.4のままになっているので、手動でURLの0.1.4の部分を0.1.5に修正します。

 2)解凍して出てきたpluginsフォルダの中にある、keystrokes.plを取り出しておきます。

 

 keystrokes.plの修正

1)66行目辺り、MTのバージョンが5なので書き換え(赤字部分)。

return 1 unless $MT::VERSION =~ m(^5\.);

2)91行目辺りの、この2行を書き換え。

$eh->error("keystroke failed: " . $obj->email) if $LOG && $keystrokes < 1;
$eh->error("keystroke id: " . $obj->blog_id);

 変更後(赤字部分)↓

my $keystrokes = 0;
$keystrokes = $q->param($FIELD_NAME) if $q->param($FIELD_NAME);
$app->log({message => $app->translate("Comment save failed with [_1]",
"keystroke failed"),
blog_id => $obj->blog_id,
class => 'comment',
level => MT::Log::ERROR()
}) if $LOG && $keystrokes < 1;
return $keystrokes > 0

 3)以上2点の変更が済んだら、サーバーのpluginsフォルダにkeystrokes.plをアップします。

 

 コメント入力部分の修正

 うちの場合は、コメントもコメントプレビューもコメント入力フォームだけをいじれば良いのであった。

 1)タグの追加(青字)。

<form method="post" action="<mt:CGIPath /><mt:CommentScript />" id="comments-form" onsubmit="return mtCommentOnSubmit(this)">
<$MTKeystrokes$>
<fieldset>

2)textarea タグ内に属性を追加(青字)。

<textarea id="comment-text" name="text" tabindex="6" accesskey="t" rows="10" cols="30" onkeypress="keystrokes(this.form)" onfocus="if (this.value == 'Please comment') this.value = '';" onblur="if (this.value == '') this.value = 'Please comment';<mt:if name="body_class" like="mt-comment-preview|mt-comment-error">mtShowCaptcha()<mt:else>mtCommentFormOnFocus()</mt:if>">

3)input タグ内に属性を追加(青字)。

<input type="submit" tabindex="7" accesskey="s" name="post" id="comment-submit" onclick="keystrokes(this.form)" value="投稿" />

4)以上3点変更したら、再構築して終わり。

 

たぶん、これでうまくいくはず・・・。もしこれも効かんのであれば、他に手があるんやろか・・・。

  • 1