Advertisement
Guest User

opencart

a guest
Jun 9th, 2015
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.03 KB | None | 0 0
  1.     class ControllerPaymentIcicipg extends Controller {
  2.         private $error = array();
  3.    
  4.         public function index() {
  5.             $this->language->load('payment/icicipg');
  6.    
  7.             $this->document->setTitle($this->language->get('heading_title'));
  8.    
  9.             $this->load->model('setting/setting');
  10.    
  11.             if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
  12.                
  13.                 $this->model_setting_setting->editSetting('icicipg', $this->request->post);
  14.    
  15.                 $this->session->data['success'] = $this->language->get('text_success');
  16.                
  17.                 $this->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
  18.             }
  19.    
  20.             $data['heading_title'] = $this->language->get('heading_title');
  21.    
  22.             $data['text_enabled'] = $this->language->get('text_enabled');
  23.             $data['text_disabled'] = $this->language->get('text_disabled');
  24.             $data['text_all_zones'] = $this->language->get('text_all_zones');
  25.             $data['text_yes'] = $this->language->get('text_yes');
  26.             $data['text_no'] = $this->language->get('text_no');
  27.             $data['text_edit'] = $this->language->get('text_edit');
  28.    
  29.             $data['entry_MID'] = $this->language->get('entry_MID');
  30.             $data['entry_total'] = $this->language->get('entry_total');
  31.             $data['entry_success_status'] = $this->language->get('entry_success_status');
  32.             $data['entry_pending_status'] = $this->language->get('entry_pending_status');
  33.             $data['entry_failed_status'] = $this->language->get('entry_failed_status');
  34.             $data['entry_RedirectURL'] = $this->language->get('entry_RedirectURL');
  35.             $data['entry_keyfile'] = $this->language->get('entry_keyfile');
  36.             $data['entry_geo_zone'] = $this->language->get('entry_geo_zone');
  37.             $data['entry_status'] = $this->language->get('entry_status');
  38.             $data['entry_sort_order'] = $this->language->get('entry_sort_order');
  39.             //$data['entry_order_prefix'] = $this->language->get('entry_order_prefix');
  40.             $data['entry_tts'] = $this->language->get('entry_tts');
  41.            
  42.            
  43.             $data['help_tts'] = $this->language->get('help_tts');
  44.             $data['help_total'] = $this->language->get('help_total');
  45.             $data['help_RedirectURL'] = $this->language->get('help_RedirectURL');
  46.    
  47.             $data['button_save'] = $this->language->get('button_save');
  48.             $data['button_cancel'] = $this->language->get('button_cancel');
  49.    
  50.             if (isset($this->error['warning'])) {
  51.                 $data['error_warning'] = $this->error['warning'];
  52.             } else {
  53.                 $data['error_warning'] = '';
  54.             }
  55.    
  56.             if (isset($this->error['MID'])) {
  57.                 $data['error_MID'] = $this->error['MID'];
  58.             } else {
  59.                 $data['error_MID'] = '';
  60.             }
  61.            
  62.             if (isset($this->error['RedirectURL'])) {
  63.                 $data['error_RedirectURL'] = $this->error['RedirectURL'];
  64.             } else {
  65.                 $data['error_RedirectURL'] = '';
  66.             }
  67.            
  68.             if (isset($this->error['keyfile'])) {
  69.                 $data['error_keyfile'] = $this->error['keyfile'];
  70.             } else {
  71.                 $data['error_keyfile'] = '';
  72.             }
  73.            
  74.             /*if (isset($this->error['order_prefix'])) {
  75.                 $data['error_order_prefix'] = $this->error['order_prefix'];
  76.             } else {
  77.                 $data['error_order_prefix'] = '';
  78.             }*/
  79.            
  80.             if (isset($this->error['tts'])) {
  81.                 $data['error_tts'] = $this->error['tts'];
  82.             } else {
  83.                 $data['error_tts'] = '';
  84.             }
  85.    
  86.             $data['breadcrumbs'] = array();
  87.    
  88.             $data['breadcrumbs'][] = array(
  89.                 'text'      => $this->language->get('text_home'),
  90.                 'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),           
  91.                 'separator' => false
  92.             );
  93.    
  94.             $data['breadcrumbs'][] = array(
  95.                 'text'      => $this->language->get('text_payment'),
  96.                 'href'      => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'),
  97.                 'separator' => ' :: '
  98.             );
  99.    
  100.             $data['breadcrumbs'][] = array(
  101.                 'text'      => $this->language->get('heading_title'),
  102.                 'href'      => $this->url->link('payment/icicipg', 'token=' . $this->session->data['token'], 'SSL'),
  103.                 'separator' => ' :: '
  104.             );
  105.    
  106.             $data['action'] = $this->url->link('payment/icicipg', 'token=' . $this->session->data['token'], 'SSL');
  107.    
  108.             $data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL');
  109.    
  110.             if (isset($this->request->post['icicipg_MID'])) {
  111.                 $data['icicipg_MID'] = $this->request->post['icicipg_MID'];
  112.             } else {
  113.                 $data['icicipg_MID'] = $this->config->get('icicipg_MID');
  114.             }
  115.    
  116.             /*if (isset($this->request->post['cc_RedirectURL'])) {
  117.                 $data['cc_RedirectURL'] = $this->request->post['cc_RedirectURL'];
  118.             } else {
  119.                 $data['cc_RedirectURL'] = $this->config->get('cc_RedirectURL');
  120.             }*/
  121.            
  122.             $data['icicipg_RedirectURL'] = HTTP_CATALOG . 'index.php?route=payment/icicipg/callback';
  123.            
  124.             /*if (isset($this->request->post['icicipg_Wkey'])) {
  125.                 $data['icicipg_Wkey'] = $this->request->post['icicipg_Wkey'];
  126.             } else {
  127.                 $data['icicipg_Wkey'] = $this->config->get('icicipg_Wkey');
  128.             }*/
  129.            
  130.             if (isset($this->request->post['icicipg_total'])) {
  131.                 $data['icicipg_total'] = $this->request->post['icicipg_total'];
  132.             } else {
  133.                 $data['icicipg_total'] = $this->config->get('icicipg_total');
  134.             }
  135.            
  136.             if (isset($this->request->post['icicipg_success_status_id'])) {
  137.                 $data['icicipg_success_status_id'] = $this->request->post['icicipg_success_status_id'];
  138.             } else {
  139.                 $data['icicipg_success_status_id'] = $this->config->get('icicipg_success_status_id');
  140.             }
  141.            
  142.             if (isset($this->request->post['icicipg_failed_status_id'])) {
  143.                 $data['icicipg_failed_status_id'] = $this->request->post['icicipg_failed_status_id'];
  144.             } else {
  145.                 $data['icicipg_failed_status_id'] = $this->config->get('icicipg_failed_status_id');
  146.             }
  147.            
  148.             $this->load->model('localisation/order_status');
  149.    
  150.             $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
  151.    
  152.             if (isset($this->request->post['icicipg_geo_zone_id'])) {
  153.                 $data['icicipg_geo_zone_id'] = $this->request->post['icicipg_geo_zone_id'];
  154.             } else {
  155.                 $data['icicipg_geo_zone_id'] = $this->config->get('icicipg_geo_zone_id');
  156.             }
  157.    
  158.             $this->load->model('localisation/geo_zone');
  159.    
  160.             $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
  161.    
  162.             if (isset($this->request->post['icicipg_status'])) {
  163.                 $data['icicipg_status'] = $this->request->post['icicipg_status'];
  164.             } else {
  165.                 $data['icicipg_status'] = $this->config->get('icicipg_status');
  166.             }
  167.            
  168.             if (isset($this->request->post['icicipg_sort_order'])) {
  169.                 $data['icicipg_sort_order'] = $this->request->post['icicipg_sort_order'];
  170.             } else {
  171.                 $data['icicipg_sort_order'] = $this->config->get('icicipg_sort_order');
  172.             }
  173.    
  174.             /*if (isset($this->request->post['icicipg_order_prefix'])) {
  175.                 $data['icicipg_order_prefix'] = $this->request->post['icicipg_order_prefix'];
  176.             } else {
  177.                 $data['icicipg_order_prefix'] = $this->config->get('icicipg_order_prefix');
  178.             }*/
  179.            
  180.             if (isset($this->request->post['icicipg_tts'])) {
  181.                 $data['icicipg_tts'] = $this->request->post['icicipg_tts'];
  182.             } else {
  183.                 $data['icicipg_tts'] = $this->config->get('icicipg_tts');
  184.             }
  185.            
  186.            
  187.             $data['header'] = $this->load->controller('common/header');
  188.             $data['column_left'] = $this->load->controller('common/column_left');
  189.             $data['footer'] = $this->load->controller('common/footer');
  190.            
  191.    
  192.             //$this->response->setOutput($this->render());
  193.            
  194.             $this->response->setOutput($this->load->view('payment/icicipg.tpl', $data));
  195.         }
  196.    
  197.         private function validate() {
  198.             if (!$this->user->hasPermission('modify', 'payment/icicipg')) {
  199.                 $this->error['warning'] = $this->language->get('error_permission');
  200.             }
  201.    
  202.             if (!$this->request->post['icicipg_MID']) {
  203.                 $this->error['MID'] = $this->language->get('error_MID');
  204.             }
  205.            
  206.             if (!$this->request->post['icicipg_RedirectURL']) {
  207.                 $this->error['RedirectURL'] = $this->language->get('error_RedirectURL');
  208.             }
  209.            
  210.             /*if (!$this->request->post['icicipg_order_prefix'] || strlen($this->request->post['icicipg_order_prefix'])!=2 ) {
  211.                 $this->error['order_prefix'] = $this->language->get('error_order_prefix');
  212.             }*/
  213.            
  214.             if (!$this->request->post['icicipg_tts']) {
  215.                 $this->error['tts'] = $this->language->get('error_tts');
  216.             }
  217.            
  218.             if ((isset( $this->request->files['upload'] )) && (is_uploaded_file($this->request->files['upload']['tmp_name']))) {
  219.                 //$file = $this->request->files['upload']['tmp_name'];
  220.                 if($this->request->files['upload']['name']==$this->request->post['icicipg_MID'] . '.key'){
  221.                     move_uploaded_file($this->request->files['upload']['tmp_name'], substr(DIR_SYSTEM,0,strlen(DIR_SYSTEM)-7) . 'Sfa/' . $this->request->post['icicipg_MID'] . '.key');
  222.                 } else {
  223.                     $this->error['keyfile'] = $this->language->get('error_keyfile2');
  224.                 }
  225.                 //$file = substr(DIR_SYSTEM,0,strlen(DIR_SYSTEM)-7) . 'Sfa/' . $this->request->post['icicipg_MID'] . '.key';
  226.             } else {
  227.                 if (!file_exists(substr(DIR_SYSTEM,0,strlen(DIR_SYSTEM)-7) . 'Sfa/' . $this->request->post['icicipg_MID'] . '.key')) {
  228.                     $this->error['keyfile'] = $this->language->get('error_keyfile');
  229.                 }
  230.             }
  231.             /*
  232.            
  233.                 $this->error['keyfile'] = $this->language->get('error_keyfile');
  234.             }*/
  235.    
  236.             if (!$this->error) {
  237.                 return true;
  238.             } else {
  239.                 return false;
  240.             }
  241.         }
  242.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement