From 6823ce3dc8e8eed8edf025bf005d9812b4f0fb85 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 31 Jul 2023 20:06:15 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9organise=20=C3=A9tape=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/install/install.php | 61 ++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/core/module/install/install.php b/core/module/install/install.php index c78c7c30..4fccd584 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -379,34 +379,13 @@ class install extends common $success = true; $message = ''; $rewrite = $this->getInput('data'); - // Réécriture d'URL - if ($rewrite === 'true') { // Ajout des lignes dans le .htaccess - $fileContent = file_get_contents('.htaccess'); - $rewriteData = PHP_EOL . - '# URL rewriting' . PHP_EOL . - '' . PHP_EOL . - "\tRewriteEngine on" . PHP_EOL . - "\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL . - "\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL . - "\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL . - "\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL . - '' . PHP_EOL . - '# URL rewriting' . PHP_EOL; - $fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent); - $success = file_put_contents( - '.htaccess', - $fileContent - ); - if ($success === false) { - $message = helper::translate('La réécriture d\'URL n\'a pas été restaurée !'); - http_response_code(500); - } - } + /** + * Restaure le fichier htaccess + */ // Recopie htaccess if ( - $this->getData(['config', 'autoUpdateHtaccess']) && - $success && file_exists('.htaccess.bak') + $this->getData(['config', 'autoUpdateHtaccess']) ) { // L'écraser avec le backup $success = copy('.htaccess.bak', '.htaccess'); @@ -416,6 +395,32 @@ class install extends common } // Effacer le backup unlink('.htaccess.bak'); + } else { + /** + * Restaure la réécriture d'URL + */ + if ($rewrite === 'true') { // Ajout des lignes dans le .htaccess + $fileContent = file_get_contents('.htaccess'); + $rewriteData = PHP_EOL . + '# URL rewriting' . PHP_EOL . + '' . PHP_EOL . + "\tRewriteEngine on" . PHP_EOL . + "\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL . + "\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL . + "\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL . + "\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL . + '' . PHP_EOL . + '# URL rewriting' . PHP_EOL; + $fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent); + $success = file_put_contents( + '.htaccess', + $fileContent + ); + if ($success === false) { + $message = helper::translate('La réécriture d\'URL n\'a pas été restaurée !'); + http_response_code(500); + } + } } /** @@ -426,8 +431,10 @@ class install extends common $installedLanguages = $this->getData(['language']); $defaultLanguages = init::$defaultData['language']; foreach ($installedLanguages as $key => $value) { - if (isset($defaultLanguages[$key]['version']) && - $defaultLanguages[$key]['version'] > $value['version']) { + if ( + isset($defaultLanguages[$key]['version']) && + $defaultLanguages[$key]['version'] > $value['version'] + ) { copy('core/module/install/ressource/i18n/' . $key . '.json', self::I18N_DIR . $key . '.json'); $this->setData(['language', $key, $defaultLanguages[$key]]); }