From b85e4d23fbdb5c3a3958512f1483210f422747ff Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 26 Apr 2013 12:37:15 +0200 Subject: [PATCH] recaptcha for the win --- htdocs/application/config/stikked.php | 8 +++---- htdocs/application/controllers/main.php | 23 +++++++++---------- .../bootstrap/views/defaults/paste_form.php | 8 +++++-- .../default/views/defaults/paste_form.php | 6 ++++- .../geocities/views/defaults/paste_form.php | 8 +++++-- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/htdocs/application/config/stikked.php b/htdocs/application/config/stikked.php index 3beadf4..02675cd 100644 --- a/htdocs/application/config/stikked.php +++ b/htdocs/application/config/stikked.php @@ -88,15 +88,15 @@ $config['per_page'] = 15; * * private_only: No recent pastes will be displayed. * enable_captcha: Users must enter a captcha to post. - * recaptcha_publickey & recaptcha_privatekey: If filled in correctly, reCaptcha will be used + * recaptcha_publickey & recaptcha_privatekey: If filled, reCaptcha will be used (get a key from https://www.google.com/recaptcha/admin/create) * blocked_words: Comma separated list, e.g. '.es.tl, mycraft.com, yourbadword' * disable_api: Don't allow pasting via API (because we can't use a captcha there...) * **/ $config['private_only'] = false; -$config['enable_captcha'] = true; -$config['recaptcha_publickey'] = '6LcNfOASAAAAAAP8AlckZgKxxvgzhHqFtfqnALG-'; -$config['recaptcha_privatekey'] = '6LcNfOASAAAAAMsddBL8WIQI-oc7Sh6vtJRYN9FK'; +$config['enable_captcha'] = false; +$config['recaptcha_publickey'] = ''; +$config['recaptcha_privatekey'] = ''; $config['disable_api'] = false; $config['blocked_words'] = ''; diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index 87bde7a..aa9ff43 100644 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -44,7 +44,12 @@ class Main extends CI_Controller //recaptcha $this->recaptcha_publickey = config_item('recaptcha_publickey'); $this->recaptcha_privatekey = config_item('recaptcha_privatekey'); - $this->use_recaptcha = ($this->recaptcha_publickey != '' && $this->recaptcha_privatekey != '' ? true : false); + + if ($this->recaptcha_publickey != '' && $this->recaptcha_privatekey != '') + { + $this->load->helper('recaptcha'); + $this->use_recaptcha = true; + } if (!$this->db->table_exists('ci_sessions')) { @@ -269,6 +274,10 @@ class Main extends CI_Controller } } $data['codemirror_modes'] = $cmm; + + //recaptcha + $data['use_recaptcha'] = $this->use_recaptcha; + $data['recaptcha_publickey'] = $this->recaptcha_publickey; if (!$this->input->post('submit')) { @@ -611,7 +620,6 @@ class Main extends CI_Controller function _valid_recaptcha() { - $this->load->helper('recaptcha'); if ($this->input->post('recaptcha_response_field')) { @@ -622,16 +630,7 @@ class Main extends CI_Controller //check $resp = recaptcha_check_answer($pk, $ra, $cf, $rf); - - if ($resp->is_valid) - { - return true; - } - else - { - $this->form_validation->set_message('_valid_captcha', $resp->error); - return false; - } + return $resp->is_valid; } else { diff --git a/htdocs/themes/bootstrap/views/defaults/paste_form.php b/htdocs/themes/bootstrap/views/defaults/paste_form.php index 119d437..625e4ef 100644 --- a/htdocs/themes/bootstrap/views/defaults/paste_form.php +++ b/htdocs/themes/bootstrap/views/defaults/paste_form.php @@ -113,8 +113,12 @@ - captcha - + + captcha + + diff --git a/htdocs/themes/default/views/defaults/paste_form.php b/htdocs/themes/default/views/defaults/paste_form.php index f3cd8fb..8a3d401 100644 --- a/htdocs/themes/default/views/defaults/paste_form.php +++ b/htdocs/themes/default/views/defaults/paste_form.php @@ -110,8 +110,12 @@ + captcha - + + diff --git a/htdocs/themes/geocities/views/defaults/paste_form.php b/htdocs/themes/geocities/views/defaults/paste_form.php index f40c61e..4afefd0 100644 --- a/htdocs/themes/geocities/views/defaults/paste_form.php +++ b/htdocs/themes/geocities/views/defaults/paste_form.php @@ -113,8 +113,12 @@ - captcha - + + captcha + +