Вход Регистрация
Файл: system/controllers/recaptcha/hooks/captcha_validate.php
Строк: 26
<?php

class onRecaptchaCaptchaValidate extends cmsAction {

    private 
$api_url 'https://www.google.com/recaptcha/api/siteverify';

    public function 
run($request){

        
$response $request->get('g-recaptcha-response'false);
        if(!
$response){ return false; }

        return 
$this->callApi(array(
            
'secret'   => $this->options['private_key'],
            
'response' => $response,
            
'remoteip' => cmsUser::getIp()
        ));

    }

    private function 
callApi($params) {

        if (!
function_exists('curl_init')){

            
$data = @file_get_contents($this->api_url.'?'.http_build_query($params));

        } else {

            
$curl curl_init();

            if(
strpos($this->api_url'https') !== false){
                
curl_setopt($curlCURLOPT_SSL_VERIFYHOST0);
                
curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse);
            }
            
curl_setopt($curlCURLOPT_URL$this->api_url);
            
curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
            
curl_setopt($curlCURLOPT_HEADERfalse);
            
curl_setopt($curlCURLOPT_TIMEOUT5);
            
curl_setopt($curlCURLOPT_POSTtrue);
            
curl_setopt($curlCURLOPT_POSTFIELDS$params);

            
$data curl_exec($curl);

            
curl_close($curl);

        }

        if(!
$data){ return false; }

        
$data json_decode($datatrue);

        return !empty(
$data['success']);

    }

}
Онлайн: 1
Реклама