Ejemplo n.º 1
0
 public function postProcess()
 {
     $this->_setFields();
     // set default configuration to default channel & dafault configuration for backup and upgrade
     // (can be modified in expert mode)
     $config = $this->getConfig('channel');
     if ($config === false) {
         $config = array();
         $config['channel'] = Upgrader::DEFAULT_CHANNEL;
         $this->writeConfig($config);
         if (class_exists('Configuration', false)) {
             Configuration::updateValue('PS_UPGRADE_CHANNEL', $config['channel']);
         }
         $this->writeConfig(array('PS_AUTOUP_PERFORMANCE' => '1', 'PS_AUTOUP_CUSTOM_MOD_DESACT' => '1', 'PS_AUTOUP_UPDATE_DEFAULT_THEME' => '1', 'PS_AUTOUP_CHANGE_DEFAULT_THEME' => '0', 'PS_AUTOUP_KEEP_MAILS' => '0', 'PS_AUTOUP_BACKUP' => '1', 'PS_AUTOUP_KEEP_IMAGES' => '0'));
     }
     if (Tools14::isSubmit('putUnderMaintenance')) {
         foreach (Shop::getCompleteListOfShopsID() as $id_shop) {
             Configuration::updateValue('PS_SHOP_ENABLE', 0, false, null, (int) $id_shop);
         }
         Configuration::updateGlobalValue('PS_SHOP_ENABLE', 0);
     }
     if (Tools14::isSubmit('customSubmitAutoUpgrade')) {
         $config_keys = array_keys(array_merge($this->_fieldsUpgradeOptions, $this->_fieldsBackupOptions));
         $config = array();
         foreach ($config_keys as $key) {
             if (isset($_POST[$key])) {
                 $config[$key] = $_POST[$key];
             }
         }
         $res = $this->writeConfig($config);
         if ($res) {
             Tools14::redirectAdmin($this->currentIndex . '&conf=6&token=' . Tools14::getValue('token'));
         }
     }
     if (Tools14::isSubmit('deletebackup')) {
         $res = false;
         $name = Tools14::getValue('name');
         $filelist = scandir($this->backupPath);
         foreach ($filelist as $filename) {
             // the following will match file or dir related to the selected backup
             if (!empty($filename) && $filename[0] != '.' && $filename != 'index.php' && $filename != '.htaccess' && preg_match('#^(auto-backupfiles_|)' . preg_quote($name) . '(\\.zip|)$#', $filename, $matches)) {
                 if (is_file($this->backupPath . DIRECTORY_SEPARATOR . $filename)) {
                     $res &= unlink($this->backupPath . DIRECTORY_SEPARATOR . $filename);
                 } elseif (!empty($name) && is_dir($this->backupPath . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR)) {
                     $res = self::deleteDirectory($this->backupPath . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR);
                 }
             }
         }
         if ($res) {
             Tools14::redirectAdmin($this->currentIndex . '&conf=1&token=' . Tools14::getValue('token'));
         } else {
             $this->_errors[] = sprintf($this->l('Error when trying to delete backups %s'), $name);
         }
     }
     parent::postProcess();
 }