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 // activate any tablesorters
$('.tablesorter').tablesorter(); $('.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 # if no message
elsif params[:message].blank? elsif params[:message].blank?
flash[:alert] = t(:contact_us_no_message) flash[:alert] = t(:contact_us_no_message)
# else send email if not a spambot # else send email if not a spambot (user must have javascript enabled)
elsif params[:userlogin].blank? elsif params[:userlogin_js] == '6H2W6QYUAJT1Q8EB'
Mailer.contact_us(params[:email], params[:message]).deliver Mailer.contact_us(params[:email], params[:message]).deliver
flash[:notice] = t(:contact_us_success) flash[:notice] = t(:contact_us_success)
end end

View File

@ -1,5 +1,5 @@
<%= form_tag({:controller => 'pages', :action => 'contact_us', :method => :post}, :class => 'form-horizontal') do %> <%= 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"> <div class="form-group">
<label class="col-sm-4 col-xs-3 control-label"><%= t(:email_address).titleize %></label> <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" message_field: "Message Field"
metadata: 'metadata' metadata: 'metadata'
minute: 'minute' minute: 'minute'
minutes: 'minutes'
myaccount: "My Account" myaccount: "My Account"
name: 'name' name: 'name'
new: "New" new: "New"
@ -358,6 +359,7 @@ en:
timecontrol_delete: "Delete TimeControl" timecontrol_delete: "Delete TimeControl"
timecontrol_delete_message: "Want to delete this TimeControl?" timecontrol_delete_message: "Want to delete this TimeControl?"
timecontrol_error: "There were some problems creating your 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_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_new: "New TimeControl"
timecontrol_run_at: 'run at' 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. # 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| create_table "active_admin_comments", force: true do |t|
t.string "namespace" t.string "namespace"
@ -336,6 +336,7 @@ ActiveRecord::Schema.define(version: 20140923230924) do
t.datetime "updated_at" t.datetime "updated_at"
t.string "name" t.string "name"
t.datetime "run_at" t.datetime "run_at"
t.integer "fuzzy_seconds", default: 0
end end
add_index "timecontrols", ["frequency", "minute", "hour", "day"], name: "index_timecontrols_on_frequency_and_minute_and_hour_and_day", using: :btree 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