From f70d77a25e778010c3951beaa00f73c582511923 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Tue, 17 Dec 2019 10:34:34 +0100 Subject: [PATCH] [10.0.017.dev] importation revue --- core/core.php | 12 ++++++----- core/module/config/config.php | 29 +++++++++++++------------- core/module/config/ressource/.htaccess | 10 +++++++++ 3 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 core/module/config/ressource/.htaccess diff --git a/core/core.php b/core/core.php index 7ca26656..b2938233 100644 --- a/core/core.php +++ b/core/core.php @@ -34,7 +34,7 @@ class common { const TEMP_DIR = 'site/tmp/'; // Numéro de version - const ZWII_VERSION = '10.0.016.dev'; + const ZWII_VERSION = '10.0.017.dev'; public static $actions = []; public static $coreModuleIds = [ @@ -145,12 +145,14 @@ class common { // Import version 9 if (file_exists(self::DATA_DIR . 'core.json') === true && - $this->getData(['core','dataVersion']) < 10000 && - $this->getData(['core','dataVersion']) !== 0) { // Retour d'importation ne pas déclencher l'import - $this->importData(); + $this->getData(['core','dataVersion']) < 10000) { + $this->importData($_SESSION['KeepUsers']); + unset ($_SESSION['KeepUsers']); + // Réinstaller htaccess + copy('core/module/config/ressource/.htaccess', self::DATA_DIR . '.htaccess'); common::$importNotices [] = "Importation réalisée avec succès" ; //echo ''; - } + } // Installation fraîche, initialisation des modules manquants // La langue d'installation par défaut est fr foreach (self::$dataStage as $stageId) { diff --git a/core/module/config/config.php b/core/module/config/config.php index 3105ea62..95a2c6f5 100755 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -318,13 +318,12 @@ class config extends common { in_array('core.json',$files) === true && in_array ('user.json', $files) === true && in_array ('config.json', $files) === true ) { - // V10 valide + // V10 valide user et config $version = '10'; // Option active, les users sont stockées if ($this->getInput('configManageImportUser', helper::FILTER_BOOLEAN) === true ) { $users = $this->getData(['user']); - } - + } } else { // Version invalide // Valeurs en sortie erreur $this->addOutput([ @@ -334,25 +333,25 @@ class config extends common { ]); } + // Préserver les comptes des utilisateurs d'une version 9 si option cochée + // Positionnement d'une variable de session lue au constructeur + if ($version === '9' && + $this->getInput('configManageImportUser', helper::FILTER_BOOLEAN) === true) { + $_SESSION['KeepUsers'] = true; + } + // Extraire le zip - $success = $zip->extractTo( '.' ); + $success = $zip->extractTo( 'site/' ); // Fermer l'archive $zip->close(); - + // Restaurer les users originaux d'une v10 si option cochée if (!empty($users) && $version === '10' && $this->getInput('configManageImportUser', helper::FILTER_BOOLEAN) === true) { - $this->setData(['user',$users]); - } - - if ($version === '9' ) { - $this->importData($this->getInput('configManageImportUser', helper::FILTER_BOOLEAN)); - $this->setData(['core','dataVersion',0]); - } - - // Met à jours les URL dans les contenus de page - + $this->setData(['user',$users]); + } + // Message de notification $notification = $success === true ? 'Sauvegarde importée avec succès' : 'Erreur d\'extraction'; $redirect = $this->getInput('configManageImportUser', helper::FILTER_BOOLEAN) === true ? helper::baseUrl() . 'config/manage' : helper::baseUrl() . 'user/login/'; diff --git a/core/module/config/ressource/.htaccess b/core/module/config/ressource/.htaccess new file mode 100644 index 00000000..9dd60d3f --- /dev/null +++ b/core/module/config/ressource/.htaccess @@ -0,0 +1,10 @@ +# Bloque l'accès aux données + + Order deny,allow + Deny from all + +# Bloque l'accès htaccess + + Order deny,allow + Deny from all + \ No newline at end of file