From a8d0c217e68fdac0331c0d80df511e5340a67fb7 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 30 Aug 2011 13:29:25 +0100 Subject: Present a reCaptcha on the signup form to foreign visitors (judging from their IP address). Fixes #157 (at least as a starter). --- app/controllers/application_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cb64cb922..cae3cb213 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -447,6 +447,17 @@ class ApplicationController < ActionController::Base return query end + def country_from_ip + gaze = MySociety::Config.get('GAZE_URL', '') + default = MySociety::Config.get('ISO_COUNTRY_CODE', '') + country = "" + if !gaze.empty? + country = open("#{gaze}/gaze-rest?f=get_country_from_ip;ip=#{request.remote_ip}").read.strip + end + country = default if country.empty? + return country + end + # URL generating functions are needed by all controllers (for redirects), # views (for links) and mailers (for use in emails), so include them into # all of all. -- cgit v1.2.3