shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

google.php (1264B)


      1 <?php
      2 class ControllerExtensionCaptchaGoogle extends Controller {
      3     public function index($error = array()) {
      4         $this->load->language('extension/captcha/google');
      5 
      6         if (isset($error['captcha'])) {
      7 			$data['error_captcha'] = $error['captcha'];
      8 		} else {
      9 			$data['error_captcha'] = '';
     10 		}
     11 
     12 		$data['site_key'] = $this->config->get('captcha_google_key');
     13 
     14         $data['route'] = $this->request->get['route']; 
     15 
     16 		return $this->load->view('extension/captcha/google', $data);
     17     }
     18 
     19     public function validate() {
     20 		if (empty($this->session->data['gcapcha'])) {
     21 			$this->load->language('extension/captcha/google');
     22 
     23 			if (!isset($this->request->post['g-recaptcha-response'])) {
     24 				return $this->language->get('error_captcha');
     25 			}
     26 
     27 			$recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('captcha_google_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR']);
     28 
     29 			$recaptcha = json_decode($recaptcha, true);
     30 
     31 			if ($recaptcha['success']) {
     32 				$this->session->data['gcapcha']	= true;
     33 			} else {
     34 				return $this->language->get('error_captcha');
     35 			}
     36 		}
     37     }
     38 }