mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-26 04:51:08 -05:00
add new google captcha
This commit is contained in:
parent
24323dd63f
commit
b6d373573b
@ -696,17 +696,30 @@ class Main extends CI_Controller
|
|||||||
|
|
||||||
function _valid_recaptcha()
|
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 <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->input->post('g-recaptcha-response'))
|
||||||
{
|
{
|
||||||
$pk = $this->recaptcha_privatekey;
|
$pk = $this->recaptcha_privatekey;
|
||||||
$ra = $_SERVER['REMOTE_ADDR'];
|
$ra = $_SERVER['REMOTE_ADDR'];
|
||||||
$cf = $this->input->post('recaptcha_challenge_field');
|
$rf = trim($this->input->post('g-recaptcha-response'));
|
||||||
$rf = $this->input->post('recaptcha_response_field');
|
|
||||||
|
|
||||||
//check
|
$url="https://www.google.com/recaptcha/api/siteverify?secret=".$pk."&response;=".$rf."&remoteip;=".$ra;
|
||||||
$resp = recaptcha_check_answer($pk, $ra, $cf, $rf);
|
$response = $this->curl->simple_get($url);
|
||||||
return $resp->is_valid;
|
$status= json_decode($response, true);
|
||||||
|
|
||||||
|
if($status['success'])
|
||||||
|
{
|
||||||
|
$recaptcha_response->is_valid = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$recaptcha_response->is_valid = false;
|
||||||
|
}
|
||||||
|
return $recaptcha_response;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user