diff --git a/CHANGES.md b/CHANGES.md index 2e753856..41746a41 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ - Thème de l'administration, amélioration du rendu. - Image tag : adaptations suite à la modification de l'API Google. - Module Blog 2.02 : homogénéisation des interfaces. + - Installation automatique d'une mise à jour en ligne : un nouvelle option de configuration permet de conserver le fichier htaccess afin de préserver les modifications nécessaires à certains hébergeurs. - Correction : - Configuration, favicon clair et sombre : le bouton d'effacement initialise les deux champs. diff --git a/core/core.php b/core/core.php index 903c52c1..c9ee2da4 100755 --- a/core/core.php +++ b/core/core.php @@ -39,7 +39,7 @@ class common { const ACCESS_TIMER = 1800; // Numéro de version - const ZWII_VERSION = '10.2.00.dev33'; + const ZWII_VERSION = '10.2.00.dev34'; const ZWII_UPDATE_CHANNEL = "v10"; public static $actions = []; @@ -1325,6 +1325,8 @@ class common { // Créer les en-têtes du journal $d = 'Date;Heure;Id;Action' . PHP_EOL; file_put_contents(self::DATA_DIR . 'journal.log',$d); + // Init préservation htaccess + $this->setData(['config','autoUpdateHtaccess',false]); $this->setData(['core', 'dataVersion', 10200]); } } diff --git a/core/module/config/config.php b/core/module/config/config.php index ed5b062c..59cbc098 100755 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -445,9 +445,8 @@ class config extends common { 'legalPageId' => $this->getInput('configLegalPageId'), 'metaDescription' => $this->getInput('configMetaDescription', helper::FILTER_STRING_LONG, true), 'title' => $this->getInput('configTitle', helper::FILTER_STRING_SHORT, true), - 'autoUpdate' => helper::urlGetContents('http://zwiicms.com/update/' . common::ZWII_UPDATE_CHANNEL . '/version') === false - ? false - : $this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN), + 'autoUpdate' => $this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN), + 'autoUpdateHtaccess' => $this->getInput('configAutoUpdateHtaccess', helper::FILTER_BOOLEAN), 'proxyType' => $this->getInput('configProxyType'), 'proxyUrl' => $this->getInput('configProxyUrl'), 'proxyPort' => $this->getInput('configProxyPort',helper::FILTER_INT), diff --git a/core/module/config/view/index/index.php b/core/module/config/view/index/index.php index 464ed6ed..ff650a42 100755 --- a/core/module/config/view/index/index.php +++ b/core/module/config/view/index/index.php @@ -148,17 +148,25 @@
- $this->getData(['config', 'autoUpdate']), 'help' => 'Vérifie une fois par jour l\'existence d\'une mise à jour.', 'disabled' => !$error ]); ?>
+
+ $this->getData(['config', 'autoUpdateHtaccess']), + 'help' => 'Lors d\'une mise à jour automatique, conserve le fichier htaccess de la racine du site.', + 'disabled' => !$error + ]); ?> +
'download-cloud', 'href' => helper::baseUrl() . 'install/update', 'value' => 'Mise à jour manuelle', + 'class' => 'buttonRed', 'disabled' => !$error ]); ?>
diff --git a/core/module/install/install.php b/core/module/install/install.php index 84cf7ff5..fa966310 100755 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -131,11 +131,15 @@ class install extends common { $this->setData(['core','updateAvailable', false]); // Backup du dossier Data helper::autoBackup(self::BACKUP_DIR,['backup','tmp','file']); + // Sauvegarde htaccess + if ($this->getData(['config','autoUpdateHtaccess'])) { + $success = copy('.htaccess', '.htaccess' . '.bak'); + } // Nettoyage des fichiers d'installation précédents - if(file_exists(self::TEMP_DIR.'update.tar.gz')) { + if(file_exists(self::TEMP_DIR.'update.tar.gz') && $success) { $success = unlink(self::TEMP_DIR.'update.tar.gz'); } - if(file_exists(self::TEMP_DIR.'update.tar') && $success === true) { + if(file_exists(self::TEMP_DIR.'update.tar') && $success) { $success = unlink(self::TEMP_DIR.'update.tar'); } // Valeurs en sortie @@ -210,6 +214,15 @@ class install extends common { FILE_APPEND ) !== false); } + // Recopie htaccess + if ($this->getData(['config','autoUpdateHtaccess']) && + $success && file_exists( '.htaccess.bak') + ) { + // L'écraser avec le backup + $success = copy( '.htaccess.bak' ,'.htaccess' ); + // Effacer l ebackup + unlink('.htaccess.bak'); + } // Valeurs en sortie $this->addOutput([ 'display' => self::DISPLAY_JSON,