Personal tools
You are here: Home 清水川記 COREBlog2簡易spam-filter
Document Actions

COREBlog2簡易spam-filter

コメント追加の許可設定の件を調べようと思ったら、コメント追加が可能になったとたんspamコメントが10件以上投稿されていた。ムカツク。とりあえず、COREBlog1のBuzzWordsチェック機構をCOREBlog2用に改造してチェックするようにしたので、これで様子見。

追加コードは意外と少なくて、portal_skins/COREBlog2/validateCommentを以下のようにカスタマイズする。これでBuzzWordsに引っかかった項目がエラーとなって投稿できない。

for key in ['title', 'body', 'author', 'email', 'url']:
    if REQUEST.has_key(key):
        m = context.validateBuzzWords(REQUEST[key])
        if not m:
            state.setError(key, 'Pleae remove NG words.', new_status='failure')

if state.getErrors():

いちおうvalidateBuzzWordsも載せておく。これもportal_skins/custom等に置いて、引数textを取るようにしておく。今回の用途ではmoderated変数が用をなしていないけど、まぁいいか。

buzz_words = (
  'casino',
  'poker',
)

moderated=True
try:
    if not moderated:
        return moderated

    s = str(text).lower()
    for w in buzz_words:
        if s.find(w) >= 0:
            moderated = False
            break
    else:
        moderated = True

except:
    pass

return moderated
COREBlog2spamfilter

Category(s)
Plone Plone

COREBlog2 簡易 trackback spam 対策

Posted by takalog at Jun 13, 2006 11:29 PM
最近このサイトに大量の trackback spam が届くようになりました。 で、言及リンク付きかどうかチェックではじこうかと思っていたんですが、いろいろ問題があってできてませんでした。 そうは言っても spam は止まりません。COREB...
Add comment

You can add a comment by filling out the form below. Plain text formatting.

(Required)
(Required)
(Required)

« March 2010 »
Mo Tu We Th Fr Sa Su
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
About this blog
Zope, Python, FreeBSD, その他色々について。つまり日記か。
Recent comments
現在翻訳中! しみずかわ Jan 23, 2010
パッチ使わせていただきます 檜山正幸 Dec 21, 2009
いまきづいた jack Dec 19, 2009
Re:讃岐うどん 新宿 楽釜製麺所 jack Dec 19, 2009
Re:讃岐うどん 新宿 楽釜製麺所 とか★ちん Dec 19, 2009
Error
There was an error while rendering the portlet.