No more SEO spam from report tool that does not require login

This commit is contained in:
Kyle Drake 2015-04-05 12:34:36 -07:00
parent 02cea425e9
commit e44e4ffcb7
2 changed files with 27 additions and 12 deletions

View file

@ -115,6 +115,11 @@ post '/site/:username/report' do |username|
redirect request.referer if site.nil? 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] report = Report.new site_id: site.id, type: params[:type], comments: params[:comments]
if current_site 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}" 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 redirect request.referer
end end

View file

@ -117,12 +117,15 @@
<% if site != current_site %> <% if site != current_site %>
<div class="report"> <div class="report">
<a href="#report" data-toggle="modal">Report</a> | <a href="#report" data-toggle="modal">Report</a>
<% if signed_in? %>
|
<% if current_site && current_site.is_blocking?(site) %> <% if current_site && current_site.is_blocking?(site) %>
<a href="#">Unblock</a> <a href="#">Unblock</a>
<% else %> <% else %>
<a href="#block" data-toggle="modal">Block</a> <a href="#block" data-toggle="modal">Block</a>
<% end %> <% end %>
<% end %>
</div> </div>
<% end %> <% end %>
</div> </div>
@ -148,8 +151,13 @@
<option value="other">Other</option> <option value="other">Other</option>
</select> </select>
</p> </p>
<p>Comments:</p> <p>Please describe the problem:</p>
<textarea name="comments" type="text" style="width: 400px; margin-bottom: 20px;"></textarea> <textarea name="comments" type="text" style="width: 400px; margin-bottom: 20px;"></textarea>
<p>Please fill out the captcha so we know you're not a robot:</p>
<div class="recaptcha" style="margin-bottom: 20px">
<%== recaptcha_tag :challenge, ssl: request.ssl? %>
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn cancel" data-dismiss="modal" aria-hidden="true">Cancel</button> <button class="btn cancel" data-dismiss="modal" aria-hidden="true">Cancel</button>