mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
commit
97dbfa30e4
@ -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 <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;
|
||||
$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
|
||||
{
|
||||
|
@ -119,13 +119,17 @@ function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
|
||||
if ($error) {
|
||||
$errorpart = "&error=" . $error;
|
||||
}
|
||||
return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
|
||||
return '<script src=\'https://www.google.com/recaptcha/api.js\'></script>
|
||||
<div class="g-recaptcha" data-sitekey="' . $pubkey . '"></div>';
|
||||
|
||||
|
||||
/*return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
|
||||
|
||||
<noscript>
|
||||
<iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
|
||||
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
|
||||
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
|
||||
</noscript>';
|
||||
</noscript>';*/
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user