Exemplo n.º 1
0
 public function postProcess()
 {
     if (Tools::getValue('reindex') === 'true') {
         Cmsearch::indexation();
         die;
     }
     if (Tools::getValue('state')) {
         switch (Tools::getValue('state')) {
             case 1:
                 return $this->displayConfirmation($this->l('Configuration updated'));
             case 2:
                 return $this->displayError($this->l('An error occurred while attempting to get certificate.'));
             case 3:
                 return $this->displayError($this->l('An error occurred while attempting to get hash.'));
             case 4:
                 return $this->displayError($this->l('An error occurred while attempting to create fields.'));
         }
     }
     if (Tools::getValue('cm_token')) {
         $convermax = new ConvermaxAPI();
         if ($convermax->getCertificate(Tools::getValue('cm_token'))) {
             if ($convermax->getHash()) {
                 if ($convermax->createIndexFields()) {
                     Tools::redirectAdmin($_SERVER['SCRIPT_NAME'] . '?controller=AdminModules&state=1&configure=convermax&token=' . Tools::getValue('token'));
                 }
                 Tools::redirectAdmin($_SERVER['SCRIPT_NAME'] . '?controller=AdminModules&state=4&configure=convermax&token=' . Tools::getValue('token'));
             }
             Tools::redirectAdmin($_SERVER['SCRIPT_NAME'] . '?controller=AdminModules&state=3&configure=convermax&token=' . Tools::getValue('token'));
         }
         Tools::redirectAdmin($_SERVER['SCRIPT_NAME'] . '?controller=AdminModules&state=2&configure=convermax&token=' . Tools::getValue('token'));
     }
     if (Tools::isSubmit('submitModule')) {
         if (isset($_FILES['cert']) && isset($_FILES['cert']['tmp_name']) && !empty($_FILES['cert']['tmp_name'])) {
             if (!stristr(Tools::substr($_FILES['cert']['name'], -4), '.pem')) {
                 return $this->displayError($this->l('Invalid file'));
             } else {
                 Configuration::updateValue('CONVERMAX_CERT', Tools::file_get_contents($_FILES['cert']['tmp_name']));
             }
         }
         if (stristr(Tools::substr(Tools::getvalue('url'), -1), '/')) {
             $url = Tools::substr(Tools::getvalue('url'), 0, -1);
         } else {
             $url = Tools::getvalue('url');
         }
         if (!$url) {
             return $this->displayError($this->l('Enter URL'));
         }
         Configuration::updateValue('CONVERMAX_URL', $url);
         return $this->displayConfirmation($this->l('Configuration updated'));
     }
 }