diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 6bcc7a6..84630e9 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -285,7 +285,7 @@ class CmsController < MyProfileController @task = SuggestArticle.new(params[:task]) if request.post? @task.target = profile - if @task.save + if verify_recaptcha(:model => @task, :message => _('Please type the words correctly')) && @task.save session[:notice] = _('Thanks for your suggestion. The community administrators were notified.') redirect_to @back_to end diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 0baaadd..4b5483a 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -2,8 +2,6 @@ class AccountController < ApplicationController no_design_blocks - inverse_captcha :field => 'e_mail' - require_ssl :except => [ :login_popup, :logout_popup, :profile_details ] before_filter :login_required, :only => [:activation_question, :accept_terms, :activate_enterprise] @@ -69,7 +67,7 @@ class AccountController < ApplicationController @user.person_data = params[:profile_data] @person = Person.new(params[:profile_data]) @person.environment = @user.environment - if request.post? && params[self.icaptcha_field].blank? + if request.post? @user.signup! owner_role = Role.find_by_name('owner') @user.person.affiliate(@user.person, [owner_role]) if owner_role diff --git a/app/controllers/public/contact_controller.rb b/app/controllers/public/contact_controller.rb index d7a58eb..36fee63 100644 --- a/app/controllers/public/contact_controller.rb +++ b/app/controllers/public/contact_controller.rb @@ -4,10 +4,9 @@ class ContactController < PublicController needs_profile - inverse_captcha :field => 'e_mail' def new @contact - if request.post? && params[self.icaptcha_field].blank? && params[:confirm] == 'true' + if request.post? && params[:confirm] == 'true' @contact = user.build_contact(profile, params[:contact]) @contact.city = (!params[:city].blank? && City.exists?(params[:city])) ? City.find(params[:city]).name : nil @contact.state = (!params[:state].blank? && State.exists?(params[:state])) ? State.find(params[:state]).name : nil diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index fa17d3f..4c9f208 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -2,8 +2,6 @@ class ContentViewerController < ApplicationController needs_profile - inverse_captcha :field => 'e_mail' - helper ProfileHelper helper TagsHelper @@ -76,7 +74,7 @@ class ContentViewerController < ApplicationController @form_div = params[:form] - if params[:comment] && params[self.icaptcha_field].blank? && params[:confirm] == 'true' + if params[:comment] && params[:confirm] == 'true' @comment = Comment.new(params[:comment]) if request.post? && @page.accept_comments? add_comment @@ -121,7 +119,7 @@ class ContentViewerController < ApplicationController def add_comment @comment.author = user if logged_in? @comment.article = @page - if @comment.save + if (@comment.reply_of_id || verify_recaptcha(:model => @comment, :message => _('Please type the words correctly'))) && @comment.save @page.touch @comment = nil # clear the comment form redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view] diff --git a/app/models/comment.rb b/app/models/comment.rb index 024fdc3..e0385a2 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,7 +1,5 @@ class Comment < ActiveRecord::Base - has_captcha - track_actions :leave_comment, :after_create, :keep_params => ["article.title", "article.url", "title", "url", "body"], :custom_target => :action_tracker_target validates_presence_of :title, :body diff --git a/app/models/suggest_article.rb b/app/models/suggest_article.rb index dd3d21e..b9ce5fe 100644 --- a/app/models/suggest_article.rb +++ b/app/models/suggest_article.rb @@ -1,7 +1,5 @@ class SuggestArticle < Task - has_captcha - validates_presence_of :target_id, :article_name, :email, :name, :article_body settings_items :email, :type => String diff --git a/app/views/account/_signup_form.rhtml b/app/views/account/_signup_form.rhtml index edaff05..b570615 100644 --- a/app/views/account/_signup_form.rhtml +++ b/app/views/account/_signup_form.rhtml @@ -7,8 +7,7 @@ <% end %> -<% labelled_form_for :user, @user do |f| %> -<%= icaptcha_field() %> +<% labelled_form_for :user, @user, :html => { :multipart => true } do |f| %> <%= hidden_field_tag :invitation_code, @invitation_code %> diff --git a/app/views/cms/suggest_an_article.rhtml b/app/views/cms/suggest_an_article.rhtml index 2ab614a..d71f07f 100644 --- a/app/views/cms/suggest_an_article.rhtml +++ b/app/views/cms/suggest_an_article.rhtml @@ -18,13 +18,10 @@ <%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true, :object => :task, :abstract_method => 'article_abstract', :body_method => 'article_body'} %> -
- <%= labelled_form_field(_("What is the result of '%s = ?'") % @task.captcha.task, text_field(:task, 'captcha_solution')) %> - <%= hidden_field :task, :captcha_secret %> -
-
- <%= hidden_field_tag('back_to', @back_to) %> + + <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) %> + <% button_bar do %> <%= submit_button :save, _('Save') %> <%= button :cancel, _('Cancel'), @back_to %> diff --git a/app/views/contact/new.rhtml b/app/views/contact/new.rhtml index 9d5712b..03a12d3 100644 --- a/app/views/contact/new.rhtml +++ b/app/views/contact/new.rhtml @@ -4,7 +4,6 @@ <% labelled_form_for :contact, @contact do |f| %> - <%= icaptcha_field() %> <%= hidden_field_tag(:confirm, 'false') %> <%= required_fields_message %> diff --git a/app/views/content_viewer/_comment_form.rhtml b/app/views/content_viewer/_comment_form.rhtml index d5191a1..ae73269 100644 --- a/app/views/content_viewer/_comment_form.rhtml +++ b/app/views/content_viewer/_comment_form.rhtml @@ -20,7 +20,6 @@ <% form_tag( url_for(@page.view_url.merge({:only_path => true})), { :class => 'comment_form' } ) do %> - <%= icaptcha_field() %> <%= hidden_field_tag(:confirm, 'false') %> <%= required_fields_message %> @@ -29,7 +28,6 @@ <%= required labelled_form_field(_('Name'), text_field(:comment, :name)) %> <%= required labelled_form_field(_('e-mail'), text_field(:comment, :email)) %> -

<%= _('If you are a registered user, you can login and be automatically recognized.') %>

@@ -39,8 +37,7 @@ <%= required labelled_form_field(_('Title'), text_field(:comment, :title)) %> <%= required labelled_form_field(_('Enter your comment'), text_area(:comment, :body, :rows => 5)) %> - <%= required labelled_form_field(_("What is the result of '%s = ?'") % @comment.captcha.task, text_field(:comment, :captcha_solution)) %> - <%= hidden_field(:comment, :captcha_secret) %> + <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) unless logged_in? %> <% button_bar do %> <%= submit_button('add', _('Post comment'), :onclick => "this.form.confirm.value = 'true'; this.disabled = true; this.form.submit(); return true;") %> diff --git a/app/views/profile_editor/edit.rhtml b/app/views/profile_editor/edit.rhtml index b6201f1..9ff179e 100644 --- a/app/views/profile_editor/edit.rhtml +++ b/app/views/profile_editor/edit.rhtml @@ -13,7 +13,6 @@ <% end %> -

<%= _('Privacy options') %>

<% if profile.person? %> diff --git a/config/initializers/recaptcha.rb b/config/initializers/recaptcha.rb new file mode 100644 index 0000000..e1d3e9c --- /dev/null +++ b/config/initializers/recaptcha.rb @@ -0,0 +1,4 @@ +Recaptcha.configure do |config| + config.public_key = '6LdLTsgSAAAAACYr0rHdF2sVqt3sMaoz_h6uN4k7' + config.private_key = '6LdLTsgSAAAAADM9Mxg-EFjXc4tCe6zpKiPOEMs8' +end diff --git a/features/comment.feature b/features/comment.feature index 3a416cd..41b5991 100644 --- a/features/comment.feature +++ b/features/comment.feature @@ -82,11 +82,6 @@ Feature: comment And I should be exactly on /booking/article-with-comment And I should be moved to anchor "comment_form" - Scenario: ask captcha question - Given I am on /booking/article-with-comment - When I follow "Post a comment" within ".post-comment-button" - Then I should see "What is the result of " - @selenium Scenario: keep comments field filled while trying to do a comment Given I am on /booking/article-with-comment diff --git a/features/comment_reply.feature b/features/comment_reply.feature index 6192956..f812543 100644 --- a/features/comment_reply.feature +++ b/features/comment_reply.feature @@ -64,8 +64,7 @@ Feature: comment @selenium Scenario: reply a comment - Given skip comments captcha - And I go to /booking/another-article + Given I go to /booking/another-article And I follow "Reply" within ".comment-balloon" And I fill in "Name" within "comment-balloon" with "Joey" And I fill in "e-mail" within "comment-balloon" with "joey@ramones.com" diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index 634a866..b5a6ac7 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -368,7 +368,6 @@ Given /^the articles of "(.+)" are moderated$/ do |organization| end Given /^the following comments?$/ do |table| - Comment.skip_captcha! table.hashes.each do |item| data = item.dup article = Article.find_by_name(data.delete("article")) @@ -388,7 +387,6 @@ Given /^the community "(.+)" is closed$/ do |community| end Given /^someone suggested the following article to be published$/ do |table| - SuggestArticle.skip_captcha! table.hashes.map{|item| item.dup}.each do |item| target = Community[item.delete('target')] task = SuggestArticle.create!(:target => target, :data => item) @@ -422,10 +420,6 @@ Given /^the environment domain is "([^\"]*)"$/ do |domain| d.save(false) end -Given /^skip comments captcha$/ do - Comment.any_instance.stubs(:skip_captcha?).returns(true) -end - When /^([^\']*)'s account is activated$/ do |person| Person.find_by_name(person).user.activate end diff --git a/features/step_definitions/selenium_steps.rb b/features/step_definitions/selenium_steps.rb index b2a3779..88d4ec0 100644 --- a/features/step_definitions/selenium_steps.rb +++ b/features/step_definitions/selenium_steps.rb @@ -93,12 +93,6 @@ When /^I type "([^\"]*)" in TinyMCE field "([^\"]*)"$/ do |value, field_id| response.selenium.type("dom=document.getElementById('#{field_id}_ifr').contentDocument.body", value) end -When /^I answer the captcha$/ do - question = response.selenium.get_text("//label[@for='task_captcha_solution']").match(/What is the result of '(.+) = \?'/)[1] - answer = eval(question) - response.selenium.type("id=task_captcha_solution", answer) -end - When /^I refresh the page$/ do response.selenium.refresh end diff --git a/features/suggest_article.feature b/features/suggest_article.feature index 3df228e..1f83a66 100644 --- a/features/suggest_article.feature +++ b/features/suggest_article.feature @@ -31,7 +31,6 @@ Feature: suggest article And I fill in "Email" with "someguy@somewhere.com" And I type "This is my suggestion's lead" in TinyMCE field "task_article_abstract" And I type "I like free software" in TinyMCE field "task_article_body" - And I answer the captcha And I press "Save" And I am logged in as "joaosilva" And I go to Sample Community's control panel diff --git a/public/javascripts/application.js b/public/javascripts/application.js index c368626..a134af2 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -662,6 +662,7 @@ function add_comment_reply_form(button, comment_id) { var f = container.find('.comment_form'); if (f.length == 0) { f = jQuery('#page-comment-form .comment_form').clone(); + f.find('#dynamic_recaptcha').remove(); f.find('.fieldWithErrors').map(function() { jQuery(this).replaceWith(jQuery(this).contents()); }); f.prepend(''); container.append(f); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 18da049..5ee65ef 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -6136,3 +6136,30 @@ h1#agenda-title { #user a#pending-tasks-count { color: #FFFFFF; } + +/* Captcha */ + +.comment_reply #recaptcha_area { + margin-bottom: 3px !important; +} + +.comment_reply .recaptchatable tr td + td + td { + display: none !important; +} + +.comment_reply .recaptcha-container { + width: 100%; + overflow: hidden; +} + +.comment_reply .recaptcha-container:hover { + overflow: visible; +} + +.comment_reply .recaptcha-container tr:hover td { + background: transparent; +} + +.comment_reply .recaptcha_image_cell { + background: transparent !important; +} diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 913aadb..f490608 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -571,17 +571,6 @@ class AccountControllerTest < Test::Unit::TestCase # end of enterprise activation tests - should 'not be able to signup while inverse captcha field filled' do - assert_no_difference User, :count do - new_user({}, @controller.icaptcha_field => 'bli@bla.email.foo') - end - end - - should 'render inverse captcha field' do - get :signup - assert_tag :tag => 'input', :attributes => { :type => 'text', :name => @controller.icaptcha_field } - end - should 'use the current environment for the template of user' do template = create_user('test_template', :email => 'test@bli.com', :password => 'pass', :password_confirmation => 'pass').person template.boxes.destroy_all diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 8b10425..7e8ce25 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -1320,7 +1320,6 @@ class CmsControllerTest < Test::Unit::TestCase should 'create a task suggest task to a profile' do c = Community.create!(:name => 'test comm', :identifier => 'test_comm', :moderated_articles => true) - SuggestArticle.any_instance.stubs(:skip_captcha?).returns(true) assert_difference SuggestArticle, :count do post :suggest_an_article, :profile => c.identifier, :back_to => 'action_view', :task => {:article_name => 'some name', :article_body => 'some body', :email => 'some@localhost.com', :name => 'some name'} end diff --git a/test/functional/contact_controller_test.rb b/test/functional/contact_controller_test.rb index 9ae51b2..93d051b 100644 --- a/test/functional/contact_controller_test.rb +++ b/test/functional/contact_controller_test.rb @@ -74,13 +74,6 @@ class ContactControllerTest < Test::Unit::TestCase assert_no_tag :tag => 'select', :attributes => {:name => 'state'} end - should 'not be able to post contact while inverse captcha field filled' do - post :new, :profile => enterprise.identifier, @controller.icaptcha_field => 'filled', :contact => {:subject => 'Hi', :message => 'Hi, all', :state => '', :city => ''} - - assert_response :success - assert_template 'new' - end - should 'not allow if not logged' do logout get :new, :profile => profile.identifier @@ -93,12 +86,6 @@ class ContactControllerTest < Test::Unit::TestCase assert_equal Person['contact_test_user'], assigns(:contact).sender end - should 'send contact while inverse captcha field not filled' do - post :new, :profile => enterprise.identifier, :contact => {:subject => 'Hi', :message => 'Hi, all', :state => '', :city => ''}, :confirm => 'true' - assert_response :redirect - assert_redirected_to :action => 'new' - end - should 'deliver contact if subject and message are filled' do post :new, :profile => enterprise.identifier, :contact => {:subject => 'Hi', :message => 'Hi, all'}, :confirm => 'true' assert_response :redirect diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index fe04760..98f2bd8 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -15,7 +15,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase @profile = create_user('testinguser').person @environment = @profile.environment - Comment.skip_captcha! end attr_reader :profile, :environment @@ -188,17 +187,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase end end - should 'not be able to post comment while inverse captcha field filled' do - profile = create_user('popstar').person - page = profile.articles.build(:name => 'myarticle', :body => 'the body of the text') - page.save! - profile.home_page = page; profile.save! - - assert_no_difference Comment, :count do - post :view_page, :profile => profile.identifier, :page => [ 'myarticle' ], @controller.icaptcha_field => 'filled', :comment => { :title => 'crap!', :body => 'I think that this article is crap', :name => 'Anonymous coward', :email => 'coward@anonymous.com' } - end - end - should 'be able to remove comments if is moderator' do commenter = create_user('commenter_user').person community = Community.create!(:name => 'Community test', :identifier => 'community-test') @@ -212,15 +200,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase end end - should 'render inverse captcha field' do - profile = create_user('popstar').person - page = profile.articles.build(:name => 'myarticle', :body => 'the body of the text') - page.save! - profile.home_page = page; profile.save! - get :view_page, :profile => profile.identifier, :page => [ 'myarticle' ] - assert_tag :tag => 'input', :attributes => { :type => 'text', :name => @controller.icaptcha_field } - end - should 'filter html content from body' do login_as @profile.identifier page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text') diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index eb29483..a9cc95c 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -17,7 +17,6 @@ class SearchControllerTest < Test::Unit::TestCase domain.save! @product_category = fast_create(ProductCategory) - Comment.skip_captcha! end def create_article_with_optional_category(name, profile, category = nil) diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index a4824f1..25f5e49 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -238,7 +238,6 @@ class TasksControllerTest < Test::Unit::TestCase c = fast_create(Community) c.add_admin profile @controller.stubs(:profile).returns(c) - SuggestArticle.skip_captcha! t = SuggestArticle.create!(:article_name => 'test name', :article_abstract => 'test abstract', :article_body => 'test body', :name => 'some name', :email => 'test@localhost.com', :target => c) get :index @@ -251,7 +250,6 @@ class TasksControllerTest < Test::Unit::TestCase c = fast_create(Community) c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) @controller.stubs(:profile).returns(c) - SuggestArticle.skip_captcha! t = SuggestArticle.create!(:article_name => 'test name', :article_body => 'test body', :name => 'some name', :email => 'test@localhost.com', :target => c) post :close, :tasks => {t.id => { :task => {}, :decision => "finish"}} @@ -263,7 +261,6 @@ class TasksControllerTest < Test::Unit::TestCase c = fast_create(Community) c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) @controller.stubs(:profile).returns(c) - SuggestArticle.skip_captcha! t = SuggestArticle.new t.article_name = 'test name' t.article_body = 'test body' diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 331fb38..a4cbf20 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -6,7 +6,6 @@ class ArticleTest < Test::Unit::TestCase def setup @profile = create_user('testing').person - Comment.skip_captcha! end attr_reader :profile diff --git a/test/unit/category_finder_test.rb b/test/unit/category_finder_test.rb index 46aa176..cd296f4 100644 --- a/test/unit/category_finder_test.rb +++ b/test/unit/category_finder_test.rb @@ -7,7 +7,6 @@ class CategoryFinderTest < ActiveSupport::TestCase @finder = CategoryFinder.new(@category) @product_category = fast_create(ProductCategory, :name => 'Products') - Comment.skip_captcha! end should 'search for articles in a specific category' do diff --git a/test/unit/category_test.rb b/test/unit/category_test.rb index 5d50271..cacf305 100644 --- a/test/unit/category_test.rb +++ b/test/unit/category_test.rb @@ -5,7 +5,6 @@ class CategoryTest < Test::Unit::TestCase def setup @env = fast_create(Environment) - Comment.skip_captcha! end def test_mandatory_field_name diff --git a/test/unit/comment_notifier_test.rb b/test/unit/comment_notifier_test.rb index 5a55489..3b9c38e 100644 --- a/test/unit/comment_notifier_test.rb +++ b/test/unit/comment_notifier_test.rb @@ -10,7 +10,6 @@ class CommentNotifierTest < Test::Unit::TestCase ActionMailer::Base.deliveries = [] @profile = create_user('user_comment_test').person @article = fast_create(Article, :name => 'Article test', :profile_id => @profile.id, :notify_comments => true) - Comment.skip_captcha! end should 'deliver mail after make aarticle commment' do diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index dae3784..526f250 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/../test_helper' class CommentTest < Test::Unit::TestCase def setup - Comment.skip_captcha! end should 'have a name and require it' do @@ -331,12 +330,4 @@ class CommentTest < Test::Unit::TestCase assert_nil Comment.new(:email => 'my@email.com').author_url end - should 'have the captcha_solution be solved' do - Comment.dont_skip_captcha! - c = Comment.new - assert !c.valid? && c.errors.invalid?(:captcha_solution) - c.skip_captcha! - assert !c.valid? && !c.errors.invalid?(:captcha_solution) - end - end diff --git a/test/unit/community_test.rb b/test/unit/community_test.rb index 37c45f4..9588ca6 100644 --- a/test/unit/community_test.rb +++ b/test/unit/community_test.rb @@ -4,7 +4,6 @@ class CommunityTest < Test::Unit::TestCase def setup @person = fast_create(Person) - Comment.skip_captcha! end attr_reader :person diff --git a/test/unit/forum_helper_test.rb b/test/unit/forum_helper_test.rb index c418189..a0f0c84 100644 --- a/test/unit/forum_helper_test.rb +++ b/test/unit/forum_helper_test.rb @@ -12,7 +12,6 @@ class ForumHelperTest < Test::Unit::TestCase @environment = Environment.default @profile = create_user('forum_helper_test').person @forum = fast_create(Forum, :profile_id => profile.id, :name => 'Forum test') - Comment.skip_captcha! end attr :profile diff --git a/test/unit/suggest_article_test.rb b/test/unit/suggest_article_test.rb index b659338..7381687 100644 --- a/test/unit/suggest_article_test.rb +++ b/test/unit/suggest_article_test.rb @@ -45,18 +45,6 @@ class SuggestArticleTest < ActiveSupport::TestCase assert t.errors.invalid?(:target_id) end - should 'have the captcha_solution be solved' do - t = SuggestArticle.new - assert !t.errors.invalid?(:captcha_solution) - t.valid? - assert t.errors.invalid?(:captcha_solution) - - t.skip_captcha! - assert t.skip_captcha? - t.valid? - assert !t.errors.invalid?(:captcha_solution) - end - should 'have the article_abstract' do t = SuggestArticle.new assert t.respond_to?(:article_abstract) diff --git a/vendor/plugins/inverse_captcha/README b/vendor/plugins/inverse_captcha/README deleted file mode 100644 index 441a98e..0000000 --- a/vendor/plugins/inverse_captcha/README +++ /dev/null @@ -1,29 +0,0 @@ -InverseCaptcha -============== - -Implement simple Anti-Comment-Spam Technique. - -Basic Usage -=========== - -Add method inverse_captcha on controller: - -ps.: dont use this method more than once time on same controller. - - inverse_captcha :field => 'e-mail'[, class => 'ghost'] - -Add the field in view form: - - <%= icaptcha_field() %> - -Check if field is blank in your controller: - - if params[controller.icaptcha_field].blank? - do... - else - dont... - end - ---- -Joenio Costa -Qui Mar 27 15:48:12 BRT 2008 diff --git a/vendor/plugins/inverse_captcha/init.rb b/vendor/plugins/inverse_captcha/init.rb deleted file mode 100644 index f224c2c..0000000 --- a/vendor/plugins/inverse_captcha/init.rb +++ /dev/null @@ -1,3 +0,0 @@ -ActionController::Base.extend(InverseCaptcha::ClassMethods) -ActionController::Base.send(:include, InverseCaptcha::InstanceMethods) -ActionView::Base.send(:include, InverseCaptchaHelper) diff --git a/vendor/plugins/inverse_captcha/lib/inverse_captcha.rb b/vendor/plugins/inverse_captcha/lib/inverse_captcha.rb deleted file mode 100644 index 8f7a341..0000000 --- a/vendor/plugins/inverse_captcha/lib/inverse_captcha.rb +++ /dev/null @@ -1,18 +0,0 @@ -module InverseCaptcha - - module ClassMethods - def inverse_captcha(opt = {}) - InverseCaptcha.const_set("ICAPTCHA_FIELD", opt[:field]) unless InverseCaptcha.const_defined? "ICAPTCHA_FIELD" - InverseCaptcha.const_set("ICAPTCHA_LABEL", opt[:label] || N_("Don't fill this field")) unless InverseCaptcha.const_defined? "ICAPTCHA_LABEL" - InverseCaptcha.const_set("ICAPTCHA_STYLECLASS", opt[:class] || 'ghost') unless InverseCaptcha.const_defined? "ICAPTCHA_STYLECLASS" - self.send(:include, InverseCaptcha) - end - end - - module InstanceMethods - def icaptcha_field - ICAPTCHA_FIELD - end - end - -end diff --git a/vendor/plugins/inverse_captcha/lib/inverse_captcha_helper.rb b/vendor/plugins/inverse_captcha/lib/inverse_captcha_helper.rb deleted file mode 100644 index a756db8..0000000 --- a/vendor/plugins/inverse_captcha/lib/inverse_captcha_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -module InverseCaptchaHelper - - def icaptcha_field(opt = {}) - label = controller.class::ICAPTCHA_LABEL - field = controller.class::ICAPTCHA_FIELD - opt.merge!({:class => controller.class::ICAPTCHA_STYLECLASS}) - stylesheet = "" - stylesheet + content_tag('span', labelled_form_field(_(label), text_field_tag(field, nil)), opt) - end - -end diff --git a/vendor/plugins/rails-math-captcha/MIT-LICENSE b/vendor/plugins/rails-math-captcha/MIT-LICENSE deleted file mode 100644 index 570ecf8..0000000 --- a/vendor/plugins/rails-math-captcha/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2007 [name of plugin creator] - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/rails-math-captcha/README b/vendor/plugins/rails-math-captcha/README deleted file mode 100644 index 822e6ac..0000000 --- a/vendor/plugins/rails-math-captcha/README +++ /dev/null @@ -1,45 +0,0 @@ -MathCaptcha -=========== - -TODO: Create form helpers - -Validates your Model to be saved by a human (or very clever script) by asking -the user to solve a very basic mathematical equation. - -It does not use the session to store the secret, but uses AES from EzCrypto. - - -Requirements -============ - * gem ezcrypto - * users who can calculate - -Usage -===== - -In your Model < ActiveRecord::Base - - has_captcha - - -In your form view: - - <%= @model.captcha.task %> = ? - <%= form.text_field :captcha_solution %> - <%= form.hidden_field :captcha_secret %> - - -If you want to skip the validation (in tests/specs), you can - - Model.skip_captcha! # or - @model.skip_captcha! - -and turn that off by - - Model.dont_skip_captcha! # or - @model.dont_skip_captcha! - - - -Copyright (c) 2007 Pat Nakajima, released under the MIT license -Copyright (c) 2009 Niklas Hofer, released under the MIT license diff --git a/vendor/plugins/rails-math-captcha/Rakefile b/vendor/plugins/rails-math-captcha/Rakefile deleted file mode 100644 index 71c2164..0000000 --- a/vendor/plugins/rails-math-captcha/Rakefile +++ /dev/null @@ -1,22 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the math_captcha plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the math_captcha plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'MathCaptcha' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/plugins/rails-math-captcha/init.rb b/vendor/plugins/rails-math-captcha/init.rb deleted file mode 100644 index 7745252..0000000 --- a/vendor/plugins/rails-math-captcha/init.rb +++ /dev/null @@ -1 +0,0 @@ -require 'math_captcha' \ No newline at end of file diff --git a/vendor/plugins/rails-math-captcha/install.rb b/vendor/plugins/rails-math-captcha/install.rb deleted file mode 100644 index f7732d3..0000000 --- a/vendor/plugins/rails-math-captcha/install.rb +++ /dev/null @@ -1 +0,0 @@ -# Install hook code here diff --git a/vendor/plugins/rails-math-captcha/lib/math_captcha.rb b/vendor/plugins/rails-math-captcha/lib/math_captcha.rb deleted file mode 100644 index fcdff2d..0000000 --- a/vendor/plugins/rails-math-captcha/lib/math_captcha.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'math_captcha/captcha' -require 'math_captcha/has_captcha' diff --git a/vendor/plugins/rails-math-captcha/lib/math_captcha/captcha.rb b/vendor/plugins/rails-math-captcha/lib/math_captcha/captcha.rb deleted file mode 100644 index 472547e..0000000 --- a/vendor/plugins/rails-math-captcha/lib/math_captcha/captcha.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'rubygems' -require 'ezcrypto' -class Captcha - NUMBERS = (1..9).to_a - OPERATORS = [:+, :-, :*] - - attr_reader :x, :y, :operator - - def initialize(x=nil, y=nil, operator=nil) - @x = x || NUMBERS.sort_by{rand}.first - @y = y || NUMBERS.sort_by{rand}.first - @operator = operator || OPERATORS.sort_by{rand}.first - end - - # Only the #to_secret is shared with the client. - # It can be reused here to create the Captcha again - def self.from_secret(secret) - yml = cipher.decrypt64 secret - args = YAML.load(yml) - new(args[:x], args[:y], args[:operator]) - end - - def self.cipher - EzCrypto::Key.with_password key, 'bad_fixed_salt' - end - - def self.key - 'ultrasecret' - end - - - def check(answer) - answer == solution - end - - def task - "#{@x} #{@operator.to_s} #{@y}" - end - def task_with_questionmark - "#{@x} #{@operator.to_s} #{@y} = ?" - end - alias_method :to_s, :task - - def solution - @x.send @operator, @y - end - - def to_secret - cipher.encrypt64(to_yaml) - end - - def to_yaml - YAML::dump({ - :x => x, - :y => y, - :operator => operator - }) - end - - private - def cipher - @cipher ||= self.class.cipher - end - def reset_cipher - @cipher = nil - end - -end diff --git a/vendor/plugins/rails-math-captcha/lib/math_captcha/has_captcha.rb b/vendor/plugins/rails-math-captcha/lib/math_captcha/has_captcha.rb deleted file mode 100644 index e71bd94..0000000 --- a/vendor/plugins/rails-math-captcha/lib/math_captcha/has_captcha.rb +++ /dev/null @@ -1,54 +0,0 @@ -module MathCaptcha - module HasCaptcha - module InstanceMethods - def must_solve_captcha - self.errors.add(:captcha_solution, "wrong answer.") unless self.captcha.check(self.captcha_solution.to_i) - end - def skip_captcha! - self.class.skip_captcha! - end - def skip_captcha? - self.class.skip_captcha? - end - def captcha - @captcha ||= Captcha.new - end - def captcha_secret=(secret) - @captcha = Captcha.from_secret(secret) - end - def captcha_secret - captcha.to_secret - end - end - - module ClassMethods - def has_captcha - include InstanceMethods - attr_accessor :captcha_solution - dont_skip_captcha! - validates_presence_of :captcha_solution, - :on => :create, :message => "can't be blank", - :unless => Proc.new {|record| record.skip_captcha? } - validate_on_create :must_solve_captcha, - :unless => Proc.new {|record| record.skip_captcha? } - end - def skip_captcha! - @@skip_captcha = true - end - def dont_skip_captcha! - @@skip_captcha = false - end - def skip_captcha? - @@skip_captcha - end - def skipping_captcha(&block) - skipping_before = skip_captcha? - skip_captcha! - yield - dont_skip_captcha! if skipping_before - end - end - end -end - -ActiveRecord::Base.send(:extend, MathCaptcha::HasCaptcha::ClassMethods) diff --git a/vendor/plugins/rails-math-captcha/spec/captcha_spec.rb b/vendor/plugins/rails-math-captcha/spec/captcha_spec.rb deleted file mode 100644 index cc48f35..0000000 --- a/vendor/plugins/rails-math-captcha/spec/captcha_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'lib/math_captcha/captcha' -require 'base64' - -describe Captcha do - describe "with a random task" do - before(:each) do - @captcha = Captcha.new - end - it "should have arguments and an operator" do - @captcha.x.should_not be_nil - @captcha.y.should_not be_nil - @captcha.operator.should_not be_nil - end - it "should use numbers bigger than zero" do - @captcha.x.should > 0 - @captcha.y.should > 0 - end - it "should offer a human readable task" do - @captcha.task.should =~ /^\d+\s*[\+\-\*]\s*\d+$/ - end - it "should have a secret to use in forms" do - @captcha.to_secret.should_not be_nil - @captcha.to_secret.should_not be_empty - end - - it "should re-use its cipher" do - @captcha.send(:cipher).should == @captcha.send(:cipher) - end - - it "should have a base64 encoded secret" do - lambda { Base64.decode64(@captcha.to_secret).should_not be_nil }.should_not raise_error - end - - describe "re-creating another from secret" do - before(:each) do - @secret = @captcha.to_secret - @new_captcha = Captcha.from_secret(@secret) - end - it "should have the same arguments and operator" do - @new_captcha.x.should == @captcha.x - @new_captcha.y.should == @captcha.y - @new_captcha.operator.should == @captcha.operator - end - it "should have the same string" do - @new_captcha.task.should == @captcha.task - end - end - end -end diff --git a/vendor/plugins/rails-math-captcha/spec/spec.opts b/vendor/plugins/rails-math-captcha/spec/spec.opts deleted file mode 100644 index 391705b..0000000 --- a/vendor/plugins/rails-math-captcha/spec/spec.opts +++ /dev/null @@ -1,4 +0,0 @@ ---colour ---format progress ---loadby mtime ---reverse diff --git a/vendor/plugins/recaptcha/CHANGELOG b/vendor/plugins/recaptcha/CHANGELOG new file mode 100644 index 0000000..92a63fd --- /dev/null +++ b/vendor/plugins/recaptcha/CHANGELOG @@ -0,0 +1,23 @@ +== 0.2.2 / 2009-09-14 + +* Add a timeout to the validator +* Give the documentation some love + +== 0.2.1 / 2009-09-14 + +* Removed Ambethia namespace, and restructured classes a bit +* Added an example rails app in the example-rails branch + +== 0.2.0 / 2009-09-12 + +* RecaptchaOptions AJAX API Fix +* Added 'cucumber' as a test environment to skip +* Ruby 1.9 compat fixes +* Added option :message => 'Custom error message' to verify_recaptcha +* Removed dependency on ActiveRecord constant +* Add I18n + +== 0.1.0 / 2008-2-8 + +* 1 major enhancement + * Initial Gem Release \ No newline at end of file diff --git a/vendor/plugins/recaptcha/Gemfile b/vendor/plugins/recaptcha/Gemfile new file mode 100644 index 0000000..d65e2a6 --- /dev/null +++ b/vendor/plugins/recaptcha/Gemfile @@ -0,0 +1,3 @@ +source 'http://rubygems.org' + +gemspec diff --git a/vendor/plugins/recaptcha/LICENSE b/vendor/plugins/recaptcha/LICENSE new file mode 100644 index 0000000..dc9c67e --- /dev/null +++ b/vendor/plugins/recaptcha/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2007 Jason L Perry + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/vendor/plugins/recaptcha/README.rdoc b/vendor/plugins/recaptcha/README.rdoc new file mode 100644 index 0000000..87810be --- /dev/null +++ b/vendor/plugins/recaptcha/README.rdoc @@ -0,0 +1,150 @@ += reCAPTCHA + +Author:: Jason L Perry (http://ambethia.com) +Copyright:: Copyright (c) 2007 Jason L Perry +License:: {MIT}[http://creativecommons.org/licenses/MIT/] +Info:: http://ambethia.com/recaptcha +Git:: http://github.com/ambethia/recaptcha/tree/master +Bugs:: http://github.com/ambethia/recaptcha/issues + +This plugin adds helpers for the {reCAPTCHA API}[http://recaptcha.net]. In your +views you can use the +recaptcha_tags+ method to embed the needed javascript, +and you can validate in your controllers with +verify_recaptcha+. + +Beforehand you need to configure Recaptcha with your custom private and public +key. You may find detailed examples below. Exceptions will be raised if you +call these methods and the keys can't be found. + +== About this fork + +This fork tries to introduces a more convenient way to configure recaptcha's +settings. The API will be inspired by {Thoughtbot's +Hoptoad}[http://robots.thoughtbot.com/post/344833329/mygem-configure-block]. + +== Rails Installation + +reCAPTCHA for Rails, add this to your Gemfile: + + gem "recaptcha", :require => "recaptcha/rails" + +Or, it can be installed as a gem: + + config.gem "recaptcha", :lib => "recaptcha/rails" + +Or, as a standard rails plugin: + + script/plugin install git://github.com/ambethia/recaptcha.git + +== Merb Installation + +reCAPTCHA can also be used in a Merb application when installed as a gem: + + dependency "alm-recaptcha", ">=0.2.2.1", :require_as => "recaptcha/merb" + +Initial Merb compatability funded by ALM Labs. + +== Setting up your API Keys + +There are multiple ways to setup your reCAPTCHA API key once you +{obtain}[http://recaptcha.net/whyrecaptcha.html] a pair. + +=== Recaptcha.configure + +You may use the block style configuration. The following code could be placed +into a +config/initializers/recaptcha.rb+ when used in a Rails project. + + Recaptcha.configure do |config| + config.public_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy' + config.private_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx' + config.proxy = 'http://myrpoxy.com.au:8080' + end + +This way, you may also set additional options to fit recaptcha into your +deployment environment. + +== Recaptcha#with_configuration + +If you want to temporarily overwrite the configuration you set with `Recaptcha.configure` (when testing, for example), you can use a `Recaptcha#with_configuration` block: + + Recaptcha.configure(:public_key => '12345') do + # Do stuff with the overwritten public_key. + end + +=== Shell environment + +Or, you can keep your keys out of your code base by exporting the following +environment variables. You might do this in the .profile/rc, or equivalent for +the user running your application: + + export RECAPTCHA_PUBLIC_KEY = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy' + export RECAPTCHA_PRIVATE_KEY = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx' + +=== Per call + +You can also pass in your keys as options at runtime, for example: + + recaptcha_tags :public_key => '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy' + +and later, + + verify_recaptcha :private_key => '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx' + +This option might be useful, if the same code base is used for multiple +reCAPTCHA setups. + +== To use 'recaptcha' + +Add +recaptcha_tags+ to each form you want to protect. + +And, add +verify_recaptcha+ logic to each form action that you've protected. + +=== +recaptcha_tags+ + +Some of the options available: + +:ssl:: Uses secure http for captcha widget (default +false+) +:noscript:: Include