tdiary-contrib 3.2.2.20130518
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +35 -0
- data/README.en.md +12 -0
- data/README.md +13 -0
- data/Rakefile +41 -0
- data/doc/en/filter/spambayes.txt +3 -0
- data/doc/en/plugin.txt +1 -0
- data/doc/en/style/hatena.txt +10 -0
- data/doc/en/style/markdown.txt +16 -0
- data/doc/en/util.txt +1 -0
- data/doc/ja/filter/antirefspam.history.txt +59 -0
- data/doc/ja/filter/antirefspam.txt +86 -0
- data/doc/ja/filter/comment_key.ja.html +182 -0
- data/doc/ja/filter/spambayes.txt +3 -0
- data/doc/ja/plugin/add_bookmark.txt +50 -0
- data/doc/ja/plugin/category_to_tag.txt +21 -0
- data/doc/ja/plugin/cocoment.txt +31 -0
- data/doc/ja/plugin/google_adsense.txt +25 -0
- data/doc/ja/plugin/google_analytics.txt +7 -0
- data/doc/ja/plugin/image_detail.txt +69 -0
- data/doc/ja/plugin/image_gps.txt +36 -0
- data/doc/ja/plugin/image_gps2.txt +41 -0
- data/doc/ja/plugin/livedoor_weather.txt +105 -0
- data/doc/ja/plugin/opensearch_ad.txt +16 -0
- data/doc/ja/plugin/section_footer.txt +84 -0
- data/doc/ja/plugin/select_theme.txt +1 -0
- data/doc/ja/plugin.txt +13 -0
- data/doc/ja/style/hatena.txt +10 -0
- data/doc/ja/style/markdown.txt +13 -0
- data/doc/ja/util.txt +12 -0
- data/filter/antirefspam.rb +263 -0
- data/filter/commentkey.rb +29 -0
- data/filter/commentsize.rb +18 -0
- data/filter/hidecomment.rb +13 -0
- data/filter/iplookup.rb +55 -0
- data/filter/plugin/antirefspam.rb +59 -0
- data/filter/plugin/commentkey.rb +58 -0
- data/filter/plugin/commentsize.rb +12 -0
- data/filter/plugin/en/iplookup.rb +9 -0
- data/filter/plugin/en/spambayes.rb +123 -0
- data/filter/plugin/iplookup.rb +39 -0
- data/filter/plugin/ja/antirefspam.rb +91 -0
- data/filter/plugin/ja/commentkey.rb +17 -0
- data/filter/plugin/ja/commentsize.rb +6 -0
- data/filter/plugin/ja/iplookup.rb +9 -0
- data/filter/plugin/ja/spambayes.rb +124 -0
- data/filter/plugin/spambayes.rb +501 -0
- data/filter/plugin/zh/iplookup.rb +9 -0
- data/filter/rblcheck.rb +36 -0
- data/filter/spambayes.rb +535 -0
- data/filter/spamlookup.rb +37 -0
- data/io/dbi_io/ChangeLog +19 -0
- data/io/dbi_io/README.ja +39 -0
- data/io/dbi_io/dbi_io.rb +181 -0
- data/io/dbi_io/plugin/refererDbiIO.rb +76 -0
- data/io/dbi_io/tdiary_table.sql +42 -0
- data/js/appstore.js +109 -0
- data/js/datepicker.js +69 -0
- data/js/editor.js +82 -0
- data/js/flickr.js +157 -0
- data/js/image_ex.js +79 -0
- data/js/jquery.socialbutton.js +842 -0
- data/js/nicovideo.js +17 -0
- data/js/picasa.js +322 -0
- data/js/plugin_checker.js +71 -0
- data/js/prettify/lang-apollo.js +2 -0
- data/js/prettify/lang-clj.js +18 -0
- data/js/prettify/lang-css.js +2 -0
- data/js/prettify/lang-go.js +1 -0
- data/js/prettify/lang-hs.js +2 -0
- data/js/prettify/lang-lisp.js +3 -0
- data/js/prettify/lang-lua.js +2 -0
- data/js/prettify/lang-ml.js +2 -0
- data/js/prettify/lang-n.js +4 -0
- data/js/prettify/lang-proto.js +1 -0
- data/js/prettify/lang-scala.js +2 -0
- data/js/prettify/lang-sql.js +2 -0
- data/js/prettify/lang-tex.js +1 -0
- data/js/prettify/lang-vb.js +2 -0
- data/js/prettify/lang-vhdl.js +3 -0
- data/js/prettify/lang-wiki.js +2 -0
- data/js/prettify/lang-xq.js +3 -0
- data/js/prettify/lang-yaml.js +2 -0
- data/js/prettify/prettify.css +1 -0
- data/js/prettify/prettify.js +28 -0
- data/js/referer.js +17 -0
- data/js/show_and_hide.js +39 -0
- data/js/socialbutton.js +126 -0
- data/js/twitter_anywhere.js +28 -0
- data/js/yahoo_kousei.js +21 -0
- data/lib/bayes/convert.rb +34 -0
- data/lib/bayes.rb +232 -0
- data/lib/exifparser/BUGS +1 -0
- data/lib/exifparser/ChangeLog +169 -0
- data/lib/exifparser/README +15 -0
- data/lib/exifparser/install.rb +1015 -0
- data/lib/exifparser/lib/exifparser/makernote/canon.rb +502 -0
- data/lib/exifparser/lib/exifparser/makernote/fujifilm.rb +415 -0
- data/lib/exifparser/lib/exifparser/makernote/minolta.rb +84 -0
- data/lib/exifparser/lib/exifparser/makernote/mk_nikonflensname.rb +39 -0
- data/lib/exifparser/lib/exifparser/makernote/nikon.rb +267 -0
- data/lib/exifparser/lib/exifparser/makernote/nikon2.rb +581 -0
- data/lib/exifparser/lib/exifparser/makernote/nikonflensname.rb +438 -0
- data/lib/exifparser/lib/exifparser/makernote/olympus.rb +225 -0
- data/lib/exifparser/lib/exifparser/makernote/prove.rb +84 -0
- data/lib/exifparser/lib/exifparser/makernote/sigma.rb +237 -0
- data/lib/exifparser/lib/exifparser/pre-setup.rb +1 -0
- data/lib/exifparser/lib/exifparser/scan.rb +278 -0
- data/lib/exifparser/lib/exifparser/tag.rb +2298 -0
- data/lib/exifparser/lib/exifparser/thumbnail.rb +76 -0
- data/lib/exifparser/lib/exifparser/utils.rb +88 -0
- data/lib/exifparser/lib/exifparser.rb +265 -0
- data/lib/exifparser/sample/exifview.rb +279 -0
- data/lib/tdiary-contrib.rb +19 -0
- data/lib/wgs2tky.rb +93 -0
- data/misc/section_footer2/buzzurl.yaml +6 -0
- data/misc/section_footer2/fc2.yaml +6 -0
- data/misc/section_footer2/ldc.yaml +6 -0
- data/misc/section_footer2/retweet.yaml +7 -0
- data/misc/section_footer2/twitter.yaml +7 -0
- data/misc/section_footer2/yahoo.yaml +6 -0
- data/misc/tdiarygraph/tdiarygraph120x90e.swf +0 -0
- data/misc/tdiarygraph/tdiarygraph125x125e.swf +0 -0
- data/misc/tdiarygraph/tdiarygraph240x180e.swf +0 -0
- data/misc/tdiarygraph/tdiarygraph468x60e.swf +0 -0
- data/misc/tdiarygraph/tdiarygraph728x90e.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes125x125r.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes125x125r7.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes125x125s.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes125x30.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes234x30.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes468x30.swf +0 -0
- data/plugin/add_bookmark.rb +89 -0
- data/plugin/apple_webclip.rb +26 -0
- data/plugin/appstore.rb +47 -0
- data/plugin/bigpresen.rb +86 -0
- data/plugin/bitly.rb +39 -0
- data/plugin/bootstrap-navi.rb +54 -0
- data/plugin/canonical.rb +9 -0
- data/plugin/category_similar.rb +73 -0
- data/plugin/category_to_tag.rb +60 -0
- data/plugin/category_to_tagcloud.rb +172 -0
- data/plugin/cocomment.rb +37 -0
- data/plugin/code-prettify.rb +23 -0
- data/plugin/coderwall.rb +34 -0
- data/plugin/datepicker.rb +28 -0
- data/plugin/day2section.rb +20 -0
- data/plugin/del_footer.rb +111 -0
- data/plugin/description_from_body.rb +23 -0
- data/plugin/development.rb +16 -0
- data/plugin/editor.rb +11 -0
- data/plugin/en/add_bookmark.rb +20 -0
- data/plugin/en/del_footer.rb +10 -0
- data/plugin/en/git-register.rb +3 -0
- data/plugin/en/livedoor_weather.rb +25 -0
- data/plugin/en/microsummary.rb +18 -0
- data/plugin/en/nicovideo.rb +38 -0
- data/plugin/en/openid.rb +8 -0
- data/plugin/en/section_footer.rb +6 -0
- data/plugin/en/section_footer2.rb +3 -0
- data/plugin/en/socialbutton.rb +5 -0
- data/plugin/everytrail.rb +39 -0
- data/plugin/facebook_comments.rb +59 -0
- data/plugin/flickr.rb +209 -0
- data/plugin/gist.rb +16 -0
- data/plugin/git-register.rb +240 -0
- data/plugin/github_badge.rb +27 -0
- data/plugin/github_link.rb +9 -0
- data/plugin/goo_gl.rb +42 -0
- data/plugin/google_adsense.rb +132 -0
- data/plugin/google_analytics.rb +39 -0
- data/plugin/google_map.rb +168 -0
- data/plugin/google_sitemaps.rb +60 -0
- data/plugin/google_webmaster.rb +22 -0
- data/plugin/hatena_bookmark_nocomment.rb +9 -0
- data/plugin/hatena_star.rb +66 -0
- data/plugin/hb_footer.rb +255 -0
- data/plugin/hb_footer4sec.rb +244 -0
- data/plugin/hb_footer4sec_js.rb +30 -0
- data/plugin/hide_comment_form.rb +4 -0
- data/plugin/hide_sidebar_iphone.rb +21 -0
- data/plugin/iddy.rb +81 -0
- data/plugin/image_detail.rb +143 -0
- data/plugin/image_ex.rb +462 -0
- data/plugin/image_gps.rb +128 -0
- data/plugin/inline_wiki.rb +6 -0
- data/plugin/instagr.rb +64 -0
- data/plugin/ja/add_bookmark.rb +20 -0
- data/plugin/ja/del_footer.rb +10 -0
- data/plugin/ja/flickr.rb +62 -0
- data/plugin/ja/git-register.rb +3 -0
- data/plugin/ja/google_sitemaps.rb +35 -0
- data/plugin/ja/livedoor_weather.rb +25 -0
- data/plugin/ja/microsummary.rb +18 -0
- data/plugin/ja/nicovideo.rb +41 -0
- data/plugin/ja/openid.rb +7 -0
- data/plugin/ja/section_footer.rb +6 -0
- data/plugin/ja/section_footer2.rb +4 -0
- data/plugin/ja/socialbutton.rb +6 -0
- data/plugin/jdate.rb +20 -0
- data/plugin/jholiday.rb +16 -0
- data/plugin/jmonth.rb +20 -0
- data/plugin/jquery_ui_theme.rb +55 -0
- data/plugin/jroku.rb +28 -0
- data/plugin/jyear.rb +37 -0
- data/plugin/latlonglab_route.rb +25 -0
- data/plugin/lazy_referer.rb +38 -0
- data/plugin/livedoor_weather.rb +180 -0
- data/plugin/make_link.rb +44 -0
- data/plugin/makerss_category.rb +43 -0
- data/plugin/makerss_comment.rb +35 -0
- data/plugin/microsummary.rb +62 -0
- data/plugin/mm_footer.rb +215 -0
- data/plugin/monthly_autopagerize.rb +67 -0
- data/plugin/my_hotentry.rb +132 -0
- data/plugin/navi_day.rb +118 -0
- data/plugin/navi_this_month.rb +15 -0
- data/plugin/nicovideo.rb +115 -0
- data/plugin/notify_miniblog.rb +134 -0
- data/plugin/ogp.rb +55 -0
- data/plugin/ohmsha_estore.rb +71 -0
- data/plugin/openid.rb +90 -0
- data/plugin/opensearch_ad.rb +33 -0
- data/plugin/picasa.rb +56 -0
- data/plugin/plugin_checker.rb +41 -0
- data/plugin/popit.rb +22 -0
- data/plugin/prettify.rb +19 -0
- data/plugin/prezi.rb +10 -0
- data/plugin/profile.rb +222 -0
- data/plugin/puboo.rb +93 -0
- data/plugin/pygments_css.rb +76 -0
- data/plugin/rating.rb +419 -0
- data/plugin/recent_estraier.rb +50 -0
- data/plugin/recent_tweet.rb +71 -0
- data/plugin/retweet.rb +86 -0
- data/plugin/rubykaigi.rb +99 -0
- data/plugin/search-bing.rb +87 -0
- data/plugin/search-default.rb +264 -0
- data/plugin/search-google-custom.rb +60 -0
- data/plugin/search-yahoo-websearch.rb +121 -0
- data/plugin/search-yahoo.rb +109 -0
- data/plugin/section_footer.rb +195 -0
- data/plugin/section_footer2.rb +278 -0
- data/plugin/section_permalink.rb +73 -0
- data/plugin/section_permalink_anchor.rb +39 -0
- data/plugin/select_style.rb +42 -0
- data/plugin/select_theme.rb +90 -0
- data/plugin/show_and_hide.rb +77 -0
- data/plugin/slideshare.rb +10 -0
- data/plugin/socialbutton.rb +60 -0
- data/plugin/tatsu_zine.rb +93 -0
- data/plugin/tdiarygraph_flashstyle.rb +296 -0
- data/plugin/tdiarytimes.rb +166 -0
- data/plugin/tdiarytimes2.rb +406 -0
- data/plugin/tdiarytimes_flashstyle.rb +263 -0
- data/plugin/tdiarytimes_textstyle.rb +290 -0
- data/plugin/title_anchor.rb +16 -0
- data/plugin/tweet_quote.rb +106 -0
- data/plugin/twitpic.rb +10 -0
- data/plugin/twitter.rb +46 -0
- data/plugin/twitter_anywhere.rb +209 -0
- data/plugin/twitter_badge.rb +42 -0
- data/plugin/twitter_js.rb +59 -0
- data/plugin/ustream.rb +19 -0
- data/plugin/vimeo.rb +14 -0
- data/plugin/volatile.rb +89 -0
- data/plugin/vote.rb +100 -0
- data/plugin/wikiloc.rb +27 -0
- data/plugin/windex.rb +512 -0
- data/plugin/yahoo_kousei.rb +79 -0
- data/plugin/yahoo_map.rb +97 -0
- data/plugin/youtube.rb +33 -0
- data/plugin/yshop.rb +189 -0
- data/plugin/zenback.rb +46 -0
- data/spec/apple_webclip_spec.rb +46 -0
- data/spec/fixtures/friendfeed.xml +2 -0
- data/spec/fixtures/github.json +1 -0
- data/spec/fixtures/twitter.xml +73 -0
- data/spec/gist_spec.rb +16 -0
- data/spec/github_link_spec.rb +39 -0
- data/spec/google_analytics_spec.rb +60 -0
- data/spec/jdate_spec.rb +23 -0
- data/spec/jmonth_spec.rb +28 -0
- data/spec/jyear_spec.rb +21 -0
- data/spec/my_hotentry_spec.rb +78 -0
- data/spec/openid_spec.rb +246 -0
- data/spec/opensearch_ad_spec.rb +50 -0
- data/spec/profile_spec.rb +88 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec_helper.rb +223 -0
- data/spec/title_anchor_spec.rb +39 -0
- data/spec/twitter_js_spec.rb +116 -0
- data/spec/youtube_spec.rb +20 -0
- data/style/hatena_style.rb +1011 -0
- data/style/markdown_style.rb +239 -0
- data/style/wikiext_style.rb +21 -0
- data/tdiary-contrib.gemspec +25 -0
- data/util/clean-spam/README.ja +1 -0
- data/util/clean-spam/tdiary-comment-clean +46 -0
- data/util/clean-spam/tdiary-comment-clean2 +81 -0
- data/util/clean-spam/tdiary-referer-clean +46 -0
- data/util/convert_pstore.rb +82 -0
- data/util/estraier-search/ChangeLog +36 -0
- data/util/estraier-search/README.ja +114 -0
- data/util/estraier-search/en/estraier-register.rb +3 -0
- data/util/estraier-search/estraier-register.rb +298 -0
- data/util/estraier-search/estraier-search.rb +273 -0
- data/util/estraier-search/estraier.rhtml +73 -0
- data/util/estraier-search/estraier.rxml +23 -0
- data/util/estraier-search/i.estraier.rhtml +31 -0
- data/util/estraier-search/ja/estraier-register.rb +3 -0
- data/util/image-gallery/README.ja +27 -0
- data/util/image-gallery/image-gallery.rb +523 -0
- data/util/image-gallery/image-gallery.rb.euc-jp +523 -0
- data/util/image-gallery/js/SmoothGallery/Changelog +52 -0
- data/util/image-gallery/js/SmoothGallery/css/ReMooz.css +186 -0
- data/util/image-gallery/js/SmoothGallery/css/img/carrow1.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/carrow2.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/closebox.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/closebox.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/fleche1.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/fleche1.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/fleche2.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/fleche2.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/loading-bar-black.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/open.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/open.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_e.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_n.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_ne.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_nw.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_s.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_se.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_sw.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_w.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/spinner.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/jd.gallery.css +371 -0
- data/util/image-gallery/js/SmoothGallery/css/layout.css +91 -0
- data/util/image-gallery/js/SmoothGallery/license.txt +621 -0
- data/util/image-gallery/js/SmoothGallery/resizer.php +113 -0
- data/util/image-gallery/js/SmoothGallery/scripts/Changelog +52 -0
- data/util/image-gallery/js/SmoothGallery/scripts/History.Routing.js +126 -0
- data/util/image-gallery/js/SmoothGallery/scripts/History.js +109 -0
- data/util/image-gallery/js/SmoothGallery/scripts/ReMooz.js +364 -0
- data/util/image-gallery/js/SmoothGallery/scripts/jd.gallery.js +843 -0
- data/util/image-gallery/js/SmoothGallery/scripts/jd.gallery.set.js +183 -0
- data/util/image-gallery/js/SmoothGallery/scripts/jd.gallery.transitions.js +90 -0
- data/util/image-gallery/js/SmoothGallery/scripts/jdgalleryresize.js +828 -0
- data/util/image-gallery/js/SmoothGallery/scripts/license.txt +621 -0
- data/util/image-gallery/js/SmoothGallery/scripts/mootools-1.2-more.js +103 -0
- data/util/image-gallery/js/SmoothGallery/scripts/mootools-1.2.1-core-yc.js +349 -0
- data/util/image-gallery/js/SmoothGallery/scripts/resizer.php +113 -0
- data/util/image-gallery/misc/plugin/recent_image.rb +406 -0
- data/util/image-gallery/skel/gallery.rhtml +154 -0
- data/util/image-gallery/skel/gallery.rhtml.euc-jp +154 -0
- data/util/image-gallery/tdiary.conf.igsample +8 -0
- data/util/image-gallery/theme/image-gallery.css +85 -0
- data/util/image2flickr.rb +282 -0
- data/util/posttdiary/README.ja +12 -0
- data/util/posttdiary/posttdiary-ex.rb +1155 -0
- data/util/posttdiary/posttdiary.rb +245 -0
- data/util/rast-search/ChangeLog +55 -0
- data/util/rast-search/README.ja +99 -0
- data/util/rast-search/en/rast-register.rb +3 -0
- data/util/rast-search/i.rast.rhtml +33 -0
- data/util/rast-search/ja/rast-register.rb +3 -0
- data/util/rast-search/rast-register.rb +326 -0
- data/util/rast-search/rast-search.rb +249 -0
- data/util/rast-search/rast.rhtml +66 -0
- data/util/rast-search/rast.rxml +21 -0
- data/util/section_link/README +11 -0
- data/util/section_link/misc/plugin/section_link.rb +68 -0
- data/util/section_link/misc/plugin/section_link_anchor.rb +38 -0
- data/util/section_link/tdiary/tdiary_day_ext.rb +21 -0
- data/util/section_link/tdiary/tdiaryext_style.rb +36 -0
- data/util/section_link/tdiary/wikiext_style.rb +36 -0
- data/util/tdiary-for-ruby1.9/compatible.rb +97 -0
- data/util/tdiary-for-ruby1.9/tdiary-2.2.0.patch +98 -0
- data/util/tdiary-for-ruby1.9/tdiary-2.3.1.patch +212 -0
- data/util/tdiary-grep/README +4 -0
- data/util/tdiary-grep/grep.rb +445 -0
- data/util/tdiary-mode/http.el +130 -0
- data/util/tdiary-mode/tdiary-mode.el +613 -0
- data/util/tdiary-vim/ChangeLog +25 -0
- data/util/tdiary-vim/README +60 -0
- data/util/tdiary-vim/tdiary.vim +350 -0
- data/util/tdiarysearch/README.en +53 -0
- data/util/tdiarysearch/README.ja +99 -0
- data/util/tdiarysearch/search.rb +504 -0
- metadata +497 -0
data/filter/spambayes.rb
ADDED
@@ -0,0 +1,535 @@
|
|
1
|
+
# Copyright (C) 2007, KURODA Hiraku <hiraku@hinet.mydns.jp>
|
2
|
+
# You can redistribute it and/or modify it under GPL2.
|
3
|
+
|
4
|
+
require "bayes"
|
5
|
+
|
6
|
+
module TDiary::Filter
|
7
|
+
class SpambayesFilter < Filter
|
8
|
+
class TokenList < Bayes::TokenList
|
9
|
+
def initialize
|
10
|
+
super(Bayes::CHARSET::UTF8)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Misc
|
15
|
+
@@without_filtering = nil
|
16
|
+
@@force_filtering = nil
|
17
|
+
def without_filtering?
|
18
|
+
@@without_filtering || (@conf[conf_use]||"").size==0
|
19
|
+
end
|
20
|
+
def without_filtering
|
21
|
+
orig = @@without_filtering
|
22
|
+
@@without_filtering = true
|
23
|
+
yield
|
24
|
+
ensure
|
25
|
+
@@without_filtering = orig
|
26
|
+
end
|
27
|
+
def force_filtering?; @@force_filtering; end
|
28
|
+
def force_filtering
|
29
|
+
orig = @@force_filtering
|
30
|
+
@@force_filtering = true
|
31
|
+
yield
|
32
|
+
ensure
|
33
|
+
@@force_filtering = orig
|
34
|
+
end
|
35
|
+
|
36
|
+
@@conf = nil
|
37
|
+
def self.conf=(conf)
|
38
|
+
@@conf ||= conf
|
39
|
+
end
|
40
|
+
def self.conf; @@conf; end
|
41
|
+
def self.to_native(s)
|
42
|
+
s ? @@conf.to_native(CGI.unescape(s)).gsub(/[\x00-\x20]/, " ") : ""
|
43
|
+
end
|
44
|
+
|
45
|
+
PREFIX = "spambayes"
|
46
|
+
def conf_filter; "#{PREFIX}.filter"; end
|
47
|
+
def conf_mail; "#{PREFIX}.mail"; end
|
48
|
+
def conf_threshold; "#{PREFIX}.threshold"; end
|
49
|
+
def conf_threshold_ham; "#{PREFIX}.threshold_ham"; end
|
50
|
+
def conf_use; "#{PREFIX}.use"; end
|
51
|
+
def conf_log; "#{PREFIX}.log"; end
|
52
|
+
def conf_for_referer; "#{PREFIX}.for_referer"; end
|
53
|
+
|
54
|
+
def cache_path
|
55
|
+
@conf.cache_path || "#{@conf.data_path}cache"
|
56
|
+
end
|
57
|
+
|
58
|
+
def bayes_cache
|
59
|
+
Dir.mkdir(cache_path) unless File.exist?(cache_path)
|
60
|
+
r = "#{cache_path}/bayes"
|
61
|
+
Dir.mkdir(r) unless File.exist?(r)
|
62
|
+
r
|
63
|
+
end
|
64
|
+
|
65
|
+
def referer_cache(key)
|
66
|
+
"#{bayes_cache}/referer_#{key}.log"
|
67
|
+
end
|
68
|
+
|
69
|
+
def referer_corpus
|
70
|
+
"#{corpus_path}/referer.db"
|
71
|
+
end
|
72
|
+
|
73
|
+
def unescape_referer(referer)
|
74
|
+
@conf.to_native(CGI.unescape(referer)).gsub(/[\x00-\x20]+/, " ")
|
75
|
+
end
|
76
|
+
|
77
|
+
def debug_log
|
78
|
+
"#{bayes_cache}/debug.log"
|
79
|
+
end
|
80
|
+
|
81
|
+
def debug(*args)
|
82
|
+
open(debug_log, "a") do |f|
|
83
|
+
f.puts(*args)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def corpus_path
|
88
|
+
r = "#{bayes_cache}/corpus"
|
89
|
+
Dir.mkdir(r) unless File.exist?(r)
|
90
|
+
r
|
91
|
+
end
|
92
|
+
|
93
|
+
def bayes_db
|
94
|
+
"#{@conf.data_path}/bayes.db"
|
95
|
+
end
|
96
|
+
|
97
|
+
def bayes_filter(reset=false)
|
98
|
+
if reset
|
99
|
+
@bayes_filter = nil
|
100
|
+
File.delete(bayes_db) if File.exist?(bayes_db)
|
101
|
+
end
|
102
|
+
|
103
|
+
case @conf[conf_filter]
|
104
|
+
when /graham/i
|
105
|
+
@bayes_filter ||= Bayes::PaulGraham.new(bayes_db, Bayes::CHARSET::UTF8)
|
106
|
+
else
|
107
|
+
@bayes_filter ||= Bayes::PlainBayes.new(bayes_db, Bayes::CHARSET::UTF8)
|
108
|
+
end
|
109
|
+
convert_to_utf8 unless @bayes_filter.charset==Bayes::CHARSET::UTF8
|
110
|
+
@bayes_filter
|
111
|
+
end
|
112
|
+
|
113
|
+
def convert_to_utf8
|
114
|
+
require "bayes/convert"
|
115
|
+
require "kconv"
|
116
|
+
|
117
|
+
@bayes_filter.convert(Bayes::CHARSET::UTF8, Bayes::CHARSET::EUC)
|
118
|
+
@bayes_filter.save
|
119
|
+
comments = []
|
120
|
+
["S", "H", "D"].each do |c|
|
121
|
+
comments.concat(Dir["#{bayes_cache}/#{c}*"])
|
122
|
+
end
|
123
|
+
["S", "H"].each do |c|
|
124
|
+
comments.concat(Dir["#{corpus_path}/#{c}*"])
|
125
|
+
end
|
126
|
+
comments.each do |f|
|
127
|
+
Comment.load(f).convert_to_utf8.save(f)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def threshold
|
132
|
+
(@conf[conf_threshold]||"0.95").to_f
|
133
|
+
end
|
134
|
+
|
135
|
+
def threshold_ham
|
136
|
+
(@conf[conf_threshold_ham]||"0.05").to_f
|
137
|
+
end
|
138
|
+
|
139
|
+
def url(path=nil)
|
140
|
+
if /^https?:\/\// =~ (path||"")
|
141
|
+
path
|
142
|
+
else
|
143
|
+
File.join(@conf.base_url, (path||""))
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def index_url
|
148
|
+
url(@conf.index)
|
149
|
+
end
|
150
|
+
|
151
|
+
def update_url
|
152
|
+
url(@conf.update)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
class Comment
|
157
|
+
attr_reader :name, :date, :mail, :body, :remote_addr, :diary_date
|
158
|
+
|
159
|
+
def self.load(file_name)
|
160
|
+
r = nil
|
161
|
+
open(file_name) do |f|
|
162
|
+
f.flock(File::LOCK_SH)
|
163
|
+
r = Marshal.load(f)
|
164
|
+
end
|
165
|
+
raise "NoData" unless r.is_a?(self)
|
166
|
+
r
|
167
|
+
end
|
168
|
+
|
169
|
+
def initialize(comment, cgi)
|
170
|
+
@name = comment.name || ""
|
171
|
+
@date = comment.date || Time.now
|
172
|
+
@mail = comment.mail || ""
|
173
|
+
@body = comment.body || ""
|
174
|
+
@remote_addr = cgi.remote_addr || ""
|
175
|
+
d = cgi.params['date'][0] || Time.now.strftime("%Y%m%d")
|
176
|
+
@diary_date = Time::local(*d.scan(/^(\d{4})(\d\d)(\d\d)$/)[0]) + 12*60*60
|
177
|
+
end
|
178
|
+
|
179
|
+
def convert_to_utf8
|
180
|
+
@name = @name.kconv(Kconv::UTF8, Kconv::EUC)
|
181
|
+
@body = @body.kconv(Kconv::UTF8, Kconv::EUC)
|
182
|
+
self
|
183
|
+
end
|
184
|
+
|
185
|
+
def save(filename)
|
186
|
+
open(filename, "w") do |f|
|
187
|
+
f.flock(File::LOCK_SH)
|
188
|
+
f.rewind
|
189
|
+
Marshal.dump(self, f)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def digest
|
194
|
+
Digest::MD5.hexdigest([@name, @date, @mail, @body, @remote_addr, @diary_date].join)
|
195
|
+
end
|
196
|
+
|
197
|
+
RE_URL = %r[(?:https?|ftp)://[a-zA-Z0-9;/?:@&=+$,\-_.!~*\'()%]+]
|
198
|
+
def token
|
199
|
+
r = TokenList.new
|
200
|
+
|
201
|
+
if @name.empty?
|
202
|
+
r.push("", "N")
|
203
|
+
else
|
204
|
+
r.add_message(@name, "N")
|
205
|
+
end
|
206
|
+
r.add_mail_addr(@mail, "M")
|
207
|
+
b = @body.dup
|
208
|
+
b.gsub!(RE_URL) do |m|
|
209
|
+
r.add_url(m, "U")
|
210
|
+
""
|
211
|
+
end
|
212
|
+
r.add_message(b)
|
213
|
+
r.add_host(@remote_addr, "A")
|
214
|
+
|
215
|
+
r
|
216
|
+
end
|
217
|
+
|
218
|
+
def cache_name
|
219
|
+
@date.strftime("%Y%m%d%H%M%S")+digest
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
class Referer
|
224
|
+
@@specials = {}
|
225
|
+
|
226
|
+
def self.load_list(f)
|
227
|
+
r = []
|
228
|
+
open(f) do |f|
|
229
|
+
f.flock(File::LOCK_SH)
|
230
|
+
r << Marshal.load(f) until f.eof?
|
231
|
+
end
|
232
|
+
r
|
233
|
+
rescue
|
234
|
+
[]
|
235
|
+
end
|
236
|
+
|
237
|
+
def self.truncate_list(fn, size)
|
238
|
+
return unless File.exist?(fn)
|
239
|
+
open(fn, "a+") do |f|
|
240
|
+
f.flock(File::LOCK_EX)
|
241
|
+
|
242
|
+
buff = []
|
243
|
+
buff << Marshal.load(f) until f.eof?
|
244
|
+
|
245
|
+
buff.slice!(0, size)
|
246
|
+
f.truncate(0)
|
247
|
+
buff.each do |i|
|
248
|
+
Marshal.dump(i, f)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def self.from_link(link)
|
254
|
+
if /^(.*?)_(.*)$/=~link
|
255
|
+
addr = $1
|
256
|
+
url = $2
|
257
|
+
new(CGI.unescape(url), addr ? CGI.unescape(addr) : nil)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def self.from_html(html)
|
262
|
+
if /^(.*?)_(.*)$/=~html
|
263
|
+
addr = $1
|
264
|
+
url = $2
|
265
|
+
new(CGI.unescapeHTML(url), addr ? CGI.unescapeHTML(addr) : nil)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
attr_reader :referer, :remote_addr
|
270
|
+
def initialize(referer, remote_addr = nil)
|
271
|
+
@referer = referer
|
272
|
+
@remote_addr = remote_addr
|
273
|
+
end
|
274
|
+
|
275
|
+
def hash
|
276
|
+
@referer.hash
|
277
|
+
end
|
278
|
+
|
279
|
+
def eql?(dst)
|
280
|
+
(self.class == dst.class) and (@referer == dst.referer)
|
281
|
+
end
|
282
|
+
|
283
|
+
def to_s
|
284
|
+
Misc.to_native(@referer)
|
285
|
+
end
|
286
|
+
|
287
|
+
def to_html
|
288
|
+
CGI.escapeHTML(@remote_addr||"") + "_" + CGI.escapeHTML(@referer)
|
289
|
+
end
|
290
|
+
|
291
|
+
def to_link
|
292
|
+
CGI.escape(@remote_addr||"") + "_" + CGI.escape(@referer)
|
293
|
+
end
|
294
|
+
|
295
|
+
def <=>(o)
|
296
|
+
to_s <=> o.to_s
|
297
|
+
end
|
298
|
+
|
299
|
+
def split_url
|
300
|
+
base, request, anchor = @referer.scan(/^(.*?)(?:\?(.*?)(?:\#(.*))?)?$/)[0]
|
301
|
+
end
|
302
|
+
|
303
|
+
def token
|
304
|
+
if l=special?
|
305
|
+
m = l+"_token"
|
306
|
+
if respond_to?(m)
|
307
|
+
r = send(m)
|
308
|
+
else
|
309
|
+
r = special_token(@@specials[l])
|
310
|
+
end
|
311
|
+
else
|
312
|
+
r = TokenList.new
|
313
|
+
|
314
|
+
base, request, anchor = split_url
|
315
|
+
r.add_url(base, "R")
|
316
|
+
r.add_message(Misc.to_native(request)) if request
|
317
|
+
r.add_message(Misc.to_native(anchor)) if anchor
|
318
|
+
end
|
319
|
+
|
320
|
+
r.add_host(@remote_addr, "A") if @remote_addr
|
321
|
+
r
|
322
|
+
end
|
323
|
+
|
324
|
+
def viewable_html
|
325
|
+
if l=special?
|
326
|
+
m = l+"_html"
|
327
|
+
if respond_to?(m)
|
328
|
+
r = send(m)
|
329
|
+
else
|
330
|
+
r = special_html(@@specials[l])
|
331
|
+
end
|
332
|
+
else
|
333
|
+
r = to_s
|
334
|
+
end
|
335
|
+
CGI.escapeHTML(r||"")
|
336
|
+
end
|
337
|
+
|
338
|
+
def special?
|
339
|
+
r = @@specials.find do |n, a|
|
340
|
+
a[0] =~ @referer
|
341
|
+
end
|
342
|
+
r ? r[0] : false
|
343
|
+
end
|
344
|
+
|
345
|
+
def self.special(name, regexp, label = nil)
|
346
|
+
name = name.to_s
|
347
|
+
label ||= name.capitalize
|
348
|
+
@@specials[name.to_s] = [regexp, label]
|
349
|
+
end
|
350
|
+
|
351
|
+
def special_html(special)
|
352
|
+
re, label = special
|
353
|
+
"#{label}: " + Misc.to_native(@referer[re, 1])
|
354
|
+
end
|
355
|
+
|
356
|
+
def special_token(special)
|
357
|
+
re = special[0]
|
358
|
+
r = TokenList.new
|
359
|
+
r.add_message(Misc.to_native(@referer[re, 1]))
|
360
|
+
r
|
361
|
+
end
|
362
|
+
|
363
|
+
RE_QUERY_SEP = /[&;]|$/
|
364
|
+
RE_QUERY_HEAD = /\?(?:.*#{RE_QUERY_SEP})?/o
|
365
|
+
|
366
|
+
RE_GOOGLE_HOSTS = /.*\.google\.(?:(?:co\.)?[a-z]{2}|com(?:\.[a-z]{2})?)/o
|
367
|
+
RE_GOOGLE = %r[^https?://#{RE_GOOGLE_HOSTS}/.*#{RE_QUERY_HEAD}(?:as_)?q=(.*?)#{RE_QUERY_SEP}]o
|
368
|
+
special :google, RE_GOOGLE
|
369
|
+
|
370
|
+
RE_GOOGLE_IP = /209\.85\.\d{3}\.\d{1,3}|72\.14\.\d{3}\.\d{1,3}/
|
371
|
+
RE_GOOGLE_CACHE = %r[^https?://#{RE_GOOGLE_IP}/search#{RE_QUERY_HEAD}q=cache:[^:]+:(.*?)(?:(?:\+|\s+)(.*?))?#{RE_QUERY_SEP}]o
|
372
|
+
special :google_cache, RE_GOOGLE_CACHE
|
373
|
+
def google_cache_token
|
374
|
+
r = TokenList.new
|
375
|
+
RE_GOOGLE_CACHE =~ @referer
|
376
|
+
ref = "http://#{CGI.unescape($1)}"
|
377
|
+
words = $2
|
378
|
+
r.add_url(ref, "R")
|
379
|
+
r.add_message(Misc.to_native(words))
|
380
|
+
end
|
381
|
+
|
382
|
+
def google_cache_html
|
383
|
+
RE_GOOGLE_CACHE =~ @referer
|
384
|
+
ref = "http://#{CGI.unescape($1)}"
|
385
|
+
words = $2
|
386
|
+
"Google(Cache): #{ref} #{Misc.to_native(words)}"
|
387
|
+
end
|
388
|
+
|
389
|
+
RE_EZ_GOOGLE = %r[^https?://ezsch\.ezweb\.ne\.jp/search/ezGoogleMain\.php#{RE_QUERY_HEAD}query=(.*?)#{RE_QUERY_SEP}]o
|
390
|
+
special :ez_google, RE_EZ_GOOGLE, "Google(ezweb)"
|
391
|
+
|
392
|
+
RE_EZWEB = %r[^https?://ezsch\.ezweb\.ne\.jp/.*?#{RE_QUERY_HEAD}query=(.*?)#{RE_QUERY_SEP}]
|
393
|
+
special :ezweb, RE_EZWEB, "EZweb"
|
394
|
+
|
395
|
+
RE_GOO = %r[^http://search\.goo\.ne\.jp/.*?#{RE_QUERY_HEAD}MT=(.*?)#{RE_QUERY_SEP}]o
|
396
|
+
special :goo, RE_GOO
|
397
|
+
|
398
|
+
RE_NIFTY = %r[^https?://search\.nifty\.com/.*?#{RE_QUERY_HEAD}Text=(.*?)#{RE_QUERY_SEP}]o
|
399
|
+
special :nifty, RE_NIFTY
|
400
|
+
|
401
|
+
RE_LIVESEARCH = %r[^https?://search\.live\.com/.*?#{RE_QUERY_HEAD}q=(.*?)#{RE_QUERY_SEP}]o
|
402
|
+
special :livesearch, RE_LIVESEARCH, "Live Search"
|
403
|
+
|
404
|
+
RE_BIGLOBE = %r[^https?://.*search\.biglobe\.ne\.jp/.*?#{RE_QUERY_HEAD}q=(.*?)#{RE_QUERY_SEP}]o
|
405
|
+
special :biglobe, RE_BIGLOBE
|
406
|
+
|
407
|
+
RE_MSN = %r[^https?://search\.msn\.co\.jp/.*?#{RE_QUERY_HEAD}q=(.*?)#{RE_QUERY_SEP}]o
|
408
|
+
special :msn, RE_MSN, "MSN"
|
409
|
+
|
410
|
+
RE_INFOSEEK = %r[^https?://search\.www\.infoseek\.co\.jp/.*?#{RE_QUERY_HEAD}qt=(.*?)#{RE_QUERY_SEP}]o
|
411
|
+
special :infoseek, RE_INFOSEEK
|
412
|
+
|
413
|
+
RE_HATENA_B = %r[^https?://b\.hatena\.ne\.jp/[^/]+/(.*?)(?:\?.*)?$]o
|
414
|
+
special :hatena_b, RE_HATENA_B, "Hatena::Bookmark"
|
415
|
+
|
416
|
+
RE_YAHOO = %r[^https?://.*\.yahoo\.co(?:m|\.[a-z]{2})/.*?#{RE_QUERY_HEAD}p=(.*?)#{RE_QUERY_SEP}]o
|
417
|
+
special :yahoo, RE_YAHOO
|
418
|
+
|
419
|
+
RE_BAIDU = %r[^https?://.*\.baidu\.jp/.*?#{RE_QUERY_HEAD}wd=(.*?)#{RE_QUERY_SEP}]o
|
420
|
+
special :baidu, RE_BAIDU
|
421
|
+
end
|
422
|
+
|
423
|
+
include Misc
|
424
|
+
|
425
|
+
def initialize( cgi, conf )
|
426
|
+
super
|
427
|
+
|
428
|
+
Misc.conf = conf
|
429
|
+
end
|
430
|
+
|
431
|
+
def ham?(tokens)
|
432
|
+
e = bayes_filter.estimate(tokens) || (threshold_ham+threshold)/2
|
433
|
+
case
|
434
|
+
when e<threshold_ham
|
435
|
+
true
|
436
|
+
when e>threshold
|
437
|
+
false
|
438
|
+
else
|
439
|
+
nil
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
def comment_filter(diary, comment)
|
444
|
+
return false if force_filtering?
|
445
|
+
return true if without_filtering?
|
446
|
+
r = true
|
447
|
+
data = Comment.new(comment, @cgi)
|
448
|
+
|
449
|
+
base_url = "#{update_url}?conf=spambayes;mode=conf;sb_mode="
|
450
|
+
spam_url = "Register as spam : #{base_url}confirm_spam"
|
451
|
+
ham_url = "Register as ham : #{base_url}confirm_ham"
|
452
|
+
|
453
|
+
case ham?(data.token)
|
454
|
+
when true
|
455
|
+
r = true
|
456
|
+
tag = "HAM"
|
457
|
+
url = spam_url
|
458
|
+
when false
|
459
|
+
r = false
|
460
|
+
tag = "SPAM"
|
461
|
+
url = ham_url
|
462
|
+
else
|
463
|
+
r = false
|
464
|
+
tag = "DOUBT"
|
465
|
+
url = "#{spam_url}\n#{ham_url}"
|
466
|
+
end
|
467
|
+
cn = tag[0,1]+data.cache_name
|
468
|
+
data.save("#{bayes_cache}/#{cn}")
|
469
|
+
url.gsub!(/(\n|\z)/){";comment_id=#{cn}#$1"}
|
470
|
+
|
471
|
+
require "socket"
|
472
|
+
require "time"
|
473
|
+
subject = "#{tag}:#{data.body.gsub(/\n/, " ")}".scan(/.{1,8}/e).map{|b| @conf.to_mail(b)}
|
474
|
+
subject = subject.map{|i| "=?ISO-2022-JP?B?"+[i].pack("m").chomp+"?="}.join("\n ")
|
475
|
+
addr = @conf[conf_mail]
|
476
|
+
body = <<EOT
|
477
|
+
From: BayesFilter <#{addr}>
|
478
|
+
To: #{addr}
|
479
|
+
Date: #{Time.now.rfc2822}
|
480
|
+
Message-Id: <bayesfilter_#{cn}@#{Socket::gethostname}>
|
481
|
+
Subject: #{subject}
|
482
|
+
MIME-Version: 1.0
|
483
|
+
Content-Type: text/plain; charset="iso-2022-jp"
|
484
|
+
Content-Transfer-Encoding: 7bit
|
485
|
+
Errors-To: #{addr}
|
486
|
+
X-Mailer: tDiary #{TDIARY_VERSION}
|
487
|
+
X-URL: http://www.tdiary.org/
|
488
|
+
|
489
|
+
Filter treated comment as #{tag}.
|
490
|
+
#{url}
|
491
|
+
----
|
492
|
+
Target: #{index_url}/?date=#{data.diary_date.strftime("%Y%m%d")}
|
493
|
+
Name: #{data.name}
|
494
|
+
Mail: #{data.mail}
|
495
|
+
IP : #{data.remote_addr}
|
496
|
+
Body:------
|
497
|
+
#{data.body.scan(/.{1,40}/).map{|l| @conf.to_mail(l)}.join("\n")}
|
498
|
+
EOT
|
499
|
+
begin
|
500
|
+
plugin = TDiary::Plugin.new("conf"=>@conf, "mode"=>"comment", "diaries"=>nil, "cgi"=>@cgi, "years"=>nil, "cache_path"=>cache_path, "date"=>data.diary_date, "comment"=>comment, "last_modified"=>nil)
|
501
|
+
plugin.comment_mail(body, addr) if /^.*@.*/ =~ addr
|
502
|
+
rescue ArgumentError
|
503
|
+
end
|
504
|
+
r
|
505
|
+
rescue Exception => e
|
506
|
+
debug "---- comment_filter ----", Time.now, e.message, e.class.name, e.backtrace.join("\n")
|
507
|
+
r
|
508
|
+
end
|
509
|
+
|
510
|
+
def referer_filter(referer)
|
511
|
+
return true if without_filtering? || !(@conf[conf_for_referer])
|
512
|
+
r = true
|
513
|
+
referer = Referer.new(referer, ENV["REMOTE_ADDR"])
|
514
|
+
token = referer.token
|
515
|
+
case ham?(token)
|
516
|
+
when true
|
517
|
+
key = "ham"
|
518
|
+
when false
|
519
|
+
r = false
|
520
|
+
key = "spam"
|
521
|
+
else
|
522
|
+
r = false
|
523
|
+
key = "doubt"
|
524
|
+
end
|
525
|
+
open(referer_cache(key), "a") do |f|
|
526
|
+
f.flock(File::LOCK_SH)
|
527
|
+
Marshal.dump(referer, f)
|
528
|
+
end
|
529
|
+
r
|
530
|
+
rescue Exception => e
|
531
|
+
debug "---- referer_filter ----", Time.now, e.message, e.class.name, e.backtrace.join("\n")
|
532
|
+
raise
|
533
|
+
end
|
534
|
+
end
|
535
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# spamlookup.rb: included TDiary::Filter::SpamlookupFilter class
|
3
|
+
#
|
4
|
+
|
5
|
+
require 'resolv'
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
module TDiary
|
9
|
+
module Filter
|
10
|
+
class SpamlookupFilter < Filter
|
11
|
+
def black_domain?( domain )
|
12
|
+
begin
|
13
|
+
Resolv.getaddress( "#{domain}.rbl.bulkfeeds.jp" )
|
14
|
+
return true
|
15
|
+
rescue
|
16
|
+
end
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
def black_url?( body )
|
21
|
+
URI.extract( body, %w[http] ) do |url|
|
22
|
+
domain = URI.parse( url ).host.sub( /\.$/, '' )
|
23
|
+
return true if black_domain?( domain )
|
24
|
+
end
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
def comment_filter( diary, comment )
|
29
|
+
!black_url?( comment.body )
|
30
|
+
end
|
31
|
+
|
32
|
+
def referer_filter( referer )
|
33
|
+
!black_url?( referer )
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/io/dbi_io/ChangeLog
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
2007-02-18 sasasin <sasasin at sasasin.net>
|
2
|
+
* dbi_io.rb: delete restore_referer and store_referer impl.
|
3
|
+
* tdiary_table.sql: add referervolatile table definition.
|
4
|
+
* plugin/refererDbiIO.rb: add new plugin for referer.
|
5
|
+
|
6
|
+
2005-12-27 Kazuhiko <kazuhiko@fdiary.net>
|
7
|
+
* dbi_io.rb (store_referer): ignore invalid referers.
|
8
|
+
|
9
|
+
2005-12-20 Kazuhiko <kazuhiko@fdiary.net>
|
10
|
+
* dbi_io.rb.fast (transaction): lock whole transaction exlusively.
|
11
|
+
(store_referer): update different entries only.
|
12
|
+
|
13
|
+
2005-12-11 Kazuhiko <kazuhiko@fdiary.net>
|
14
|
+
* dbi_io.rb (store_comment): delete possible duplicate comments.
|
15
|
+
(restore_referer): quote diary_id.
|
16
|
+
(calendar): fix a bug in a multi-user environment.
|
17
|
+
|
18
|
+
2005-12-10 Kazuhiko <kazuhiko@fdiary.net>
|
19
|
+
* dbi_io.rb: code cleanup.
|
data/io/dbi_io/README.ja
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
!dbi_io
|
2
|
+
|
3
|
+
<dbname> データベース名('tDiaryDB')
|
4
|
+
<user> データベースに接続するユーザ
|
5
|
+
<password> データベースに接続するパスワード
|
6
|
+
<author> 作者。今後、マルチユーザ対応するときに使います。
|
7
|
+
|
8
|
+
!!データベースの作成
|
9
|
+
|
10
|
+
!!! PostgreSQLの場合
|
11
|
+
|
12
|
+
$ createdb -h <host> -U <user> -E EUC-JP <dbname>
|
13
|
+
Password: <password>
|
14
|
+
$ psql -h <host> -U <user> -f tdiary_table.sql <dbname>
|
15
|
+
Password: <password>
|
16
|
+
CREATE DATABASE
|
17
|
+
|
18
|
+
!!tdiary.confの編集
|
19
|
+
|
20
|
+
#require 'tdiary/pstoreio'
|
21
|
+
#@io_class = TDiary::PStoreIO
|
22
|
+
require 'tdiary/dbi_io'
|
23
|
+
@io_class = TDiary::DbiIO
|
24
|
+
#-- dbi_ioの場合の設定 --
|
25
|
+
@dbi_driver_url = 'dbi:Pg:<dbname>' # URLを設定します。
|
26
|
+
@dbi_user = '<user>' # DBのアカウント
|
27
|
+
@dbi_passwd = '<password> # DBのパスワード
|
28
|
+
@dbi_author = '<author>' # author
|
29
|
+
|
30
|
+
!! プラグインのインストール
|
31
|
+
リンク元の保存・表示のために、プラグインを以下のいずれかの
|
32
|
+
方法でインストールする必要があります
|
33
|
+
|
34
|
+
(1) tdiary.confの@option['sp.path']に、このディレクトリに
|
35
|
+
あるpluginのパスを追加し、設定画面からrefererDbiIO.rb
|
36
|
+
を有効にする。
|
37
|
+
|
38
|
+
(2) tDiaryのインストール先にあるpluginディレクトリに、
|
39
|
+
plugin/refererDbiIO.rbをコピーする。
|