maxmind.php (3008B)
1 <?php 2 class Controller3rdPartyMaxmind extends Controller { 3 private $error = array(); 4 5 public function index() { 6 $this->load->language('3rd_party/maxmind'); 7 8 $this->document->setTitle($this->language->get('heading_title')); 9 10 $this->load->model('3rd_party/maxmind'); 11 12 if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { 13 $this->model_3rd_party_maxmind->editSetting($this->request->post); 14 15 $this->session->data['success'] = $this->language->get('text_success'); 16 17 $this->response->redirect($this->url->link('install/step_4')); 18 } 19 20 $data['heading_title'] = $this->language->get('heading_title'); 21 22 $data['text_maxmind'] = $this->language->get('text_maxmind'); 23 $data['text_signup'] = sprintf($this->language->get('text_signup'), ''); 24 25 $data['entry_key'] = $this->language->get('entry_key'); 26 $data['entry_score'] = $this->language->get('entry_score'); 27 $data['entry_order_status'] = $this->language->get('entry_order_status'); 28 29 $data['help_score'] = $this->language->get('help_score'); 30 $data['help_order_status'] = $this->language->get('help_order_status'); 31 32 $data['button_continue'] = $this->language->get('button_continue'); 33 $data['button_back'] = $this->language->get('button_back'); 34 35 $data['action'] = $this->url->link('3rd_party/maxmind'); 36 37 if (isset($this->error['key'])) { 38 $data['error_key'] = $this->error['key']; 39 } else { 40 $data['error_key'] = ''; 41 } 42 43 if (isset($this->error['score'])) { 44 $data['error_score'] = $this->error['score']; 45 } else { 46 $data['error_score'] = ''; 47 } 48 49 if (isset($this->request->post['fraud_maxmind_key'])) { 50 $data['fraud_maxmind_key'] = $this->request->post['fraud_maxmind_key']; 51 } else { 52 $data['fraud_maxmind_key'] = ''; 53 } 54 55 if (isset($this->request->post['fraud_maxmind_score'])) { 56 $data['fraud_maxmind_score'] = $this->request->post['fraud_maxmind_score']; 57 } else { 58 $data['fraud_maxmind_score'] = '80'; 59 } 60 61 if (isset($this->request->post['maxmind_order_status_id'])) { 62 $data['maxmind_order_status_id'] = $this->request->post['maxmind_order_status_id']; 63 } else { 64 $data['maxmind_order_status_id'] = ''; 65 } 66 67 $data['order_statuses'] = $this->model_3rd_party_maxmind->getOrderStatuses(); 68 69 $data['back'] = $this->url->link('install/step_4'); 70 71 $data['footer'] = $this->load->controller('common/footer'); 72 $data['header'] = $this->load->controller('common/header'); 73 74 $this->response->setOutput($this->load->view('3rd_party/maxmind', $data)); 75 } 76 77 private function validate() { 78 if (!$this->request->post['fraud_maxmind_key']) { 79 $this->error['key'] = $this->language->get('error_key'); 80 } 81 82 if (!$this->request->post['fraud_maxmind_score'] || (int)$this->request->post['fraud_maxmind_score'] > 100 || (int)$this->request->post['fraud_maxmind_score'] < 0) { 83 $this->error['score'] = $this->language->get('error_score'); 84 } 85 86 return !$this->error; 87 } 88 }