- Timestamp:
- 09/24/08 23:33:02 (2 months ago)
- Location:
- lang/ruby/misc
- Files:
-
- 2 modified
-
as-antispam.rb (modified) (3 diffs)
-
tp-antispam.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/misc/as-antispam.rb
r15033 r19842 6 6 require 'net/http' 7 7 8 TYPEPADANTISPAM_VERSION = '1.0'9 TYPEPADANTISPAM_API_VERSION = '1.1'8 TYPEPADANTISPAM_VERSION = '1.0' 9 TYPEPADANTISPAM_API_VERSION = '1.1' 10 10 TYPEPADANTISPAM_SIG = %w|blog user_ip user_agent article_date permalink comment_type comment_author comment_author_email comment_author_url comment_content| 11 11 … … 20 20 self.comment_type = 'comment' # commentまたはtrackback 21 21 self.comment_author = 'foo' # コメント投稿者の名前 22 self.comment_author_email = 'foo@ bar.com'# コメント投稿者のメールアドレス23 self.comment_author_url = 'http://blog. bar.com/'# コメント投稿者のURL24 self.comment_content = 'Hello!' # コメントの内容22 self.comment_author_email = 'foo@example.org' # コメント投稿者のメールアドレス 23 self.comment_author_url = 'http://blog.example.org/' # コメント投稿者のURL 24 self.comment_content = 'Hello!' # コメントの内容 25 25 end 26 26 27 27 def check 28 28 header = { 29 'User-Agent' => "TypePad AntiSpam RubyLibrary/#{TYPEPADANTISPAM_VERSION}",29 'User-Agent' => "TypePad_AntiSpam_Ruby_Library/#{TYPEPADANTISPAM_VERSION}", 30 30 'Content-Type' => "application/x-www-form-urlencoded; charset=#{@charset}" 31 31 } 32 32 data = [] 33 each_pair do |member, value| 33 each_pair do |member, value| 34 34 data << "#{member}=#{CGI::escape( value )}" if value 35 35 end … … 38 38 Net::HTTP.start( "#{@key}.rest.akismet.com" ) do |http| 39 39 response, = http.post( "/#{TYPEPADANTISPAM_API_VERSION}/comment-check", data*'&', header ) 40 case response.body 41 when /false/ i40 case response.body.downcase 41 when /false/ 42 42 r = true 43 when /true/ i43 when /true/ 44 44 r = false 45 45 end -
lang/ruby/misc/tp-antispam.rb
r15033 r19842 6 6 require 'net/http' 7 7 8 TYPEPADANTISPAM_VERSION = '1.0'9 TYPEPADANTISPAM_API_VERSION = '1.1'8 TYPEPADANTISPAM_VERSION = '1.0' 9 TYPEPADANTISPAM_API_VERSION = '1.1' 10 10 TYPEPADANTISPAM_SIG = %w|blog user_ip user_agent article_date permalink comment_type comment_author comment_author_email comment_author_url comment_content| 11 11 … … 20 20 self.comment_type = 'comment' # commentまたはtrackback 21 21 self.comment_author = 'foo' # コメント投稿者の名前 22 self.comment_author_email = 'foo@ bar.com'# コメント投稿者のメールアドレス23 self.comment_author_url = 'http://blog. bar.com/'# コメント投稿者のURL24 self.comment_content = 'Hello!' # コメントの内容22 self.comment_author_email = 'foo@example.org' # コメント投稿者のメールアドレス 23 self.comment_author_url = 'http://blog.example.org/' # コメント投稿者のURL 24 self.comment_content = 'Hello!' # コメントの内容 25 25 end 26 26 27 27 def check 28 28 header = { 29 'User-Agent' => "TypePad AntiSpam RubyLibrary/#{TYPEPADANTISPAM_VERSION}",29 'User-Agent' => "TypePad_AntiSpam_Ruby_Library/#{TYPEPADANTISPAM_VERSION}", 30 30 'Content-Type' => "application/x-www-form-urlencoded; charset=#{@charset}" 31 31 } 32 32 data = [] 33 each_pair do |member, value| 33 each_pair do |member, value| 34 34 data << "#{member}=#{CGI::escape( value )}" if value 35 35 end … … 38 38 Net::HTTP.start( "#{@key}.api.antispam.typepad.com" ) do |http| 39 39 response, = http.post( "/#{TYPEPADANTISPAM_API_VERSION}/comment-check", data*'&', header ) 40 case response.body 41 when /false/ i40 case response.body.downcase 41 when /false/ 42 42 r = true 43 when /true/ i43 when /true/ 44 44 r = false 45 45 end
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)