prevent contact form spam

This commit is contained in:
Lee Lawlor 2014-09-30 21:09:01 -04:00
parent 1f892a89c0
commit 4f05d39cfb
10 changed files with 14 additions and 6 deletions

View File

@ -28,5 +28,8 @@ $(document).on('page:load ready', function() {
// activate any tablesorters
$('.tablesorter').tablesorter();
// set value for userlogin_js, which is used to determine if a form was submitted with javascript enabled
$('#userlogin_js').val('6H2W6QYUAJT1Q8EB');
});

View File

@ -28,8 +28,8 @@ class PagesController < ApplicationController
# if no message
elsif params[:message].blank?
flash[:alert] = t(:contact_us_no_message)
# else send email if not a spambot
elsif params[:userlogin].blank?
# else send email if not a spambot (user must have javascript enabled)
elsif params[:userlogin_js] == '6H2W6QYUAJT1Q8EB'
Mailer.contact_us(params[:email], params[:message]).deliver
flash[:notice] = t(:contact_us_success)
end

View File

@ -1,5 +1,5 @@
<%= form_tag({:controller => 'pages', :action => 'contact_us', :method => :post}, :class => 'form-horizontal') do %>
<input name='userlogin' class='userlogin' />
<input type='text' id='userlogin_js' name='userlogin_js' class='userlogin' />
<div class="form-group">
<label class="col-sm-4 col-xs-3 control-label"><%= t(:email_address).titleize %></label>

View File

@ -163,6 +163,7 @@ en:
message_field: "Message Field"
metadata: 'metadata'
minute: 'minute'
minutes: 'minutes'
myaccount: "My Account"
name: 'name'
new: "New"
@ -358,6 +359,7 @@ en:
timecontrol_delete: "Delete TimeControl"
timecontrol_delete_message: "Want to delete this TimeControl?"
timecontrol_error: "There were some problems creating your TimeControl:"
timecontrol_fuzzy_time: 'fuzzy time'
timecontrol_max_message: "You have reached the maximum number of TimeControls available per user. Please delete an existing TimeControl before adding a new one."
timecontrol_new: "New TimeControl"
timecontrol_run_at: 'run at'

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140923230924) do
ActiveRecord::Schema.define(version: 20140930202952) do
create_table "active_admin_comments", force: true do |t|
t.string "namespace"
@ -336,6 +336,7 @@ ActiveRecord::Schema.define(version: 20140923230924) do
t.datetime "updated_at"
t.string "name"
t.datetime "run_at"
t.integer "fuzzy_seconds", default: 0
end
add_index "timecontrols", ["frequency", "minute", "hour", "day"], name: "index_timecontrols_on_frequency_and_minute_and_hour_and_day", using: :btree

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long