google.php (3570B)
1 <?php 2 class ControllerExtensionCaptchaGoogle extends Controller { 3 private $error = array(); 4 5 public function index() { 6 $this->load->language('extension/captcha/google'); 7 8 $this->document->setTitle($this->language->get('heading_title')); 9 10 $this->load->model('setting/setting'); 11 12 if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { 13 $this->model_setting_setting->editSetting('captcha_google', $this->request->post); 14 15 $this->session->data['success'] = $this->language->get('text_success'); 16 17 $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=captcha', true)); 18 } 19 20 if (isset($this->error['warning'])) { 21 $data['error_warning'] = $this->error['warning']; 22 } else { 23 $data['error_warning'] = ''; 24 } 25 26 if (isset($this->error['key'])) { 27 $data['error_key'] = $this->error['key']; 28 } else { 29 $data['error_key'] = ''; 30 } 31 32 if (isset($this->error['secret'])) { 33 $data['error_secret'] = $this->error['secret']; 34 } else { 35 $data['error_secret'] = ''; 36 } 37 38 $data['breadcrumbs'] = array(); 39 40 $data['breadcrumbs'][] = array( 41 'text' => $this->language->get('text_home'), 42 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) 43 ); 44 45 $data['breadcrumbs'][] = array( 46 'text' => $this->language->get('text_extension'), 47 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=captcha', true) 48 ); 49 50 $data['breadcrumbs'][] = array( 51 'text' => $this->language->get('heading_title'), 52 'href' => $this->url->link('extension/captcha/google', 'user_token=' . $this->session->data['user_token'], true) 53 ); 54 55 $data['action'] = $this->url->link('extension/captcha/google', 'user_token=' . $this->session->data['user_token'], true); 56 57 $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=captcha', true); 58 59 if (isset($this->request->post['captcha_google_key'])) { 60 $data['captcha_google_key'] = $this->request->post['captcha_google_key']; 61 } else { 62 $data['captcha_google_key'] = $this->config->get('captcha_google_key'); 63 } 64 65 if (isset($this->request->post['captcha_google_secret'])) { 66 $data['captcha_google_secret'] = $this->request->post['captcha_google_secret']; 67 } else { 68 $data['captcha_google_secret'] = $this->config->get('captcha_google_secret'); 69 } 70 71 if (isset($this->request->post['captcha_google_status'])) { 72 $data['captcha_google_status'] = $this->request->post['captcha_google_status']; 73 } else { 74 $data['captcha_google_status'] = $this->config->get('captcha_google_status'); 75 } 76 77 $data['header'] = $this->load->controller('common/header'); 78 $data['column_left'] = $this->load->controller('common/column_left'); 79 $data['footer'] = $this->load->controller('common/footer'); 80 81 $this->response->setOutput($this->load->view('extension/captcha/google', $data)); 82 } 83 84 protected function validate() { 85 if (!$this->user->hasPermission('modify', 'extension/captcha/google')) { 86 $this->error['warning'] = $this->language->get('error_permission'); 87 } 88 89 if (!$this->request->post['captcha_google_key']) { 90 $this->error['key'] = $this->language->get('error_key'); 91 } 92 93 if (!$this->request->post['captcha_google_secret']) { 94 $this->error['secret'] = $this->language->get('error_secret'); 95 } 96 97 return !$this->error; 98 } 99 }