File: commentkey.rb

package info (click to toggle)
tdiary-contrib 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,772 kB
  • sloc: ruby: 17,305; javascript: 8,263; lisp: 562; xml: 451; php: 61; sql: 40; makefile: 18
file content (29 lines) | stat: -rw-r--r-- 806 bytes parent folder | download | duplicates (7)
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
#
# comment_key.rb: Comment-key filter  Ver.0.5.0
#  included TDiary::Filter::CommentKeyFilter class
#
# caution:
#   * This filter must use together plugin 'comment_key.rb'.
#
# see:
#   http://www20.big.or.jp/~rin_ne/soft/tdiary/commentkey.htm
#
# Copyright (c) 2005 Hahahaha <rin_ne@big.or.jp>
# Distributed under the GPL
#

module TDiary
	module Filter
		class CommentkeyFilter < Filter
			def comment_filter( diary, comment )
				return true unless @conf['comment_key.enable']
				return true if /^(?:TrackBack|Pingback)$/ =~ comment.name

				require 'digest/md5'
				keyprefix = @conf['comment_key.prefix'] || 'tdiary'
				vkey = Digest::MD5.hexdigest(keyprefix + (@conf['comment_key.nodate'] == 'true' ? "" : @cgi.params['date'][0]))
				vkey == @cgi.params['comment_key'][0]
			end
		end
	end
end