diff --git a/core/core.php b/core/core.php index 82097232..9b33eac7 100644 --- a/core/core.php +++ b/core/core.php @@ -348,6 +348,8 @@ class common } } } + // Mise à jour des données core + include('core/include/update.inc.php'); // Récupère un utilisateur connecté if ($this->user === []) { @@ -428,8 +430,6 @@ class common ); stream_context_set_default($context); } - // Mise à jour des données core - include('core/include/update.inc.php'); } @@ -469,7 +469,7 @@ class common */ public function checkCSRF() { - return ((empty($_POST['csrf']) or hash_equals( $_POST['csrf'], $_SESSION['csrf']) === false) === false); + return ((empty($_POST['csrf']) or hash_equals($_POST['csrf'], $_SESSION['csrf']) === false) === false); } /** @@ -1346,4 +1346,4 @@ class common file_put_contents(self::DATA_DIR . 'journal.log', $dataLog, FILE_APPEND); } } -} +} \ No newline at end of file diff --git a/core/include/checkup.php b/core/include/checkup.php index 16eecfbf..6e9206bb 100644 --- a/core/include/checkup.php +++ b/core/include/checkup.php @@ -9,8 +9,8 @@ if(version_compare(PHP_VERSION, '7.2.0', '<') ) { } -if ( version_compare(PHP_VERSION, '8.2.999', '>') ) { - exit('PHP 8.2 pas encore supporté, installez PHP 7.n ou PHP 8.1.n - PHP 8.2 not yet supported, install PHP 7.n or PHP 8.1.n'); +if ( version_compare(PHP_VERSION, '8.3.999', '>') ) { + exit('PHP 8.3 pas encore supporté, installez PHP 7.n ou PHP 8.1.n - PHP 8.3 not yet supported, install PHP 7.n or PHP 8.1.n'); } /** diff --git a/core/include/pre-update.php b/core/include/pre-update.php index 3c21a6b5..0e915d94 100644 --- a/core/include/pre-update.php +++ b/core/include/pre-update.php @@ -7,8 +7,11 @@ if (file_exists('site/data/core.json')) { $version = json_decode(file_get_contents('site/data/core.json'), true); - // Avant version 12.0.00 - if ($version['core']['dataVersion'] < 12000) { + // Avant version 12.skey0.00 + if ( + array_key_exists('dataVersion',$version) && + $version['core']['dataVersion'] < 12000 + ) { // Correspondance pour les dossiers de langue à convertir $languages = [ 'fr' => 'fr_FR', @@ -28,7 +31,10 @@ if (file_exists('site/data/core.json')) { } // Renomme les bases de données - if ($version['core']['dataVersion'] < 12400) { + if ( + array_key_exists('dataVersion',$version) && + $version['core']['dataVersion'] < 12400 + ) { // Renommage les fichiers de données au pluriel $t = [ 'site/data/languages.json' => 'site/data/language.json', @@ -37,13 +43,13 @@ if (file_exists('site/data/core.json')) { foreach ($t as $k => $v) { if (file_exists($k)) { $d = file_get_contents($k); - $d = str_replace(basename($k,'.json'), basename($v, '.json'), $d); + $d = str_replace(basename($k, '.json'), basename($v, '.json'), $d); file_put_contents($v, $d); unlink($k); } } if (file_exists('core/module/install/ressource/i18n/languages.json')) { - unlink ('core/module/install/ressource/i18n/languages.json'); + unlink('core/module/install/ressource/i18n/languages.json'); } } diff --git a/core/include/update.inc.php b/core/include/update.inc.php index 3b415798..0e592b3c 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -3,7 +3,17 @@ /** * Mises à jour suivant les versions de Zwii */ -if ($this->getData(['core', 'dataVersion']) < 9227) { + +// Premier appel lors de l'installation, les fichiers sont vides en lecture +if (is_null($this->getData(['core', 'dataVersion']))) { + header("Location: " . $_SERVER['PHP_SELF']); + exit(); +} + +// Pas d'installation depuis une version inférieur +if ( + $this->getData(['core', 'dataVersion']) < 9227 +) { // Arrêt du script exit('ZwiiCMS version 12 est incompatible avec la base de données installée. L\'installation d\'une version intermédiaire 10 ou 11 est nécessaire.'); } @@ -1016,7 +1026,7 @@ if ($this->getData(['core', 'dataVersion']) < 13000) { $this->setData(['user', $userId, 'profil', 1]); break; default: - $this->setData(['user', $userId, 'profil', 0]); + $this->setData(['user', $userId, 'profil', 0]); break; } } diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index 8b7dd9a5..d12f45d7 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -45,7 +45,7 @@ class init extends common ] ], 'core' => [ - 'dataVersion' => 12400, + 'dataVersion' => 13000, 'lastBackup' => 0, 'lastClearTmp' => 0, 'lastAutoUpdate' => 0,