diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index cd92a6e..ef44825 100644 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -41,6 +41,7 @@ class Main extends CI_Controller parent::__construct(); $this->output->enable_profiler(false); $this->load->model('languages'); + $this->load->library('curl'); if (config_item('require_auth')) { @@ -696,17 +697,30 @@ class Main extends CI_Controller function _valid_recaptcha() { - - if ($this->input->post('recaptcha_response_field')) + + if ($this->recaptcha_privatekey == null || $this->recaptcha_privatekey == '') { + die ("To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create"); + } + + if ($this->input->post('g-recaptcha-response')) { $pk = $this->recaptcha_privatekey; $ra = $_SERVER['REMOTE_ADDR']; - $cf = $this->input->post('recaptcha_challenge_field'); - $rf = $this->input->post('recaptcha_response_field'); + $rf = trim($this->input->post('g-recaptcha-response')); - //check - $resp = recaptcha_check_answer($pk, $ra, $cf, $rf); - return $resp->is_valid; + $url="https://www.google.com/recaptcha/api/siteverify?secret=".$pk."&response;=".$rf."&remoteip;=".$ra; + $response = $this->curl->simple_get($url); + $status= json_decode($response, true); + + if($status['success']) + { + $recaptcha_response->is_valid = true; + } + else + { + $recaptcha_response->is_valid = false; + } + return $recaptcha_response; } else { diff --git a/htdocs/application/helpers/recaptcha_helper.php b/htdocs/application/helpers/recaptcha_helper.php index 32c4f4d..3aafda8 100644 --- a/htdocs/application/helpers/recaptcha_helper.php +++ b/htdocs/application/helpers/recaptcha_helper.php @@ -119,13 +119,17 @@ function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) if ($error) { $errorpart = "&error=" . $error; } - return ' + return ' +
'; + + + /*return ' '; + ';*/ }