From e44e4ffcb7315f523bc4425b767e9745b0bd12fa Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sun, 5 Apr 2015 12:34:36 -0700 Subject: [PATCH] No more SEO spam from report tool that does not require login --- app/site.rb | 7 +++++++ views/site.erb | 32 ++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/app/site.rb b/app/site.rb index e007bb87..4f019533 100644 --- a/app/site.rb +++ b/app/site.rb @@ -115,6 +115,11 @@ post '/site/:username/report' do |username| redirect request.referer if site.nil? + if !recaptcha_valid? + flash[:error] = 'Captcha was not filled out (or was filled out incorrectly)' + redirect request.referer + end + report = Report.new site_id: site.id, type: params[:type], comments: params[:comments] if current_site @@ -133,6 +138,8 @@ post '/site/:username/report' do |username| body: "Reported by #{report.reporting_site_id ? report.reporting_site.username : report.ip}: #{report.comments}" }) + flash[:success] = "Thank you for the report, we will look into it." + redirect request.referer end diff --git a/views/site.erb b/views/site.erb index ec880b25..f59d00dd 100644 --- a/views/site.erb +++ b/views/site.erb @@ -35,13 +35,13 @@ <% if current_site && current_site != site %> <% is_following = current_site.is_following?(site) %> - + Unfollow Following - + <% end %> @@ -60,8 +60,8 @@
- disabled<% end %> >Post
- + <% unless current_site.commenting_allowed? %>

To prevent spam, you cannot comment until you have updated your site <%= Site::COMMENTING_ALLOWED_UPDATED_COUNT %> times (on <%= Site::COMMENTING_ALLOWED_UPDATED_COUNT %> separate days), and your account is one week old. While waiting, now is a great time to start building your awesome site! @@ -117,11 +117,14 @@ <% if site != current_site %>

- Report | - <% if current_site && current_site.is_blocking?(site) %> - Unblock - <% else %> - Block + Report + <% if signed_in? %> + | + <% if current_site && current_site.is_blocking?(site) %> + Unblock + <% else %> + Block + <% end %> <% end %>
<% end %> @@ -148,8 +151,13 @@

-

Comments:

+

Please describe the problem:

+ +

Please fill out the captcha so we know you're not a robot:

+
+ <%== recaptcha_tag :challenge, ssl: request.ssl? %> +
- \ No newline at end of file +