forked from ZwiiCMS-Team/ZwiiCMS
Fix : bug de restauration
This commit is contained in:
parent
7d5d856b75
commit
b5b361c705
@ -49,7 +49,7 @@ class common
|
|||||||
// Numéro de version
|
// Numéro de version
|
||||||
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/';
|
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/';
|
||||||
|
|
||||||
const ZWII_VERSION = '12.0.00-beta05';
|
const ZWII_VERSION = '12.0.00-beta06';
|
||||||
const ZWII_UPDATE_CHANNEL = "test";
|
const ZWII_UPDATE_CHANNEL = "test";
|
||||||
|
|
||||||
public static $actions = [];
|
public static $actions = [];
|
||||||
@ -324,9 +324,10 @@ class common
|
|||||||
'en' => 'en_EN',
|
'en' => 'en_EN',
|
||||||
'pt' => 'pt_PT'
|
'pt' => 'pt_PT'
|
||||||
];
|
];
|
||||||
// COnvertit les dossiers vers la nouvelle structure
|
// Convertit les dossiers vers la nouvelle structure
|
||||||
foreach ($languages as $key => $value) {
|
foreach ($languages as $key => $value) {
|
||||||
if (is_dir(self::DATA_DIR . $key)) {
|
if (is_dir(self::DATA_DIR . $key) &&
|
||||||
|
!is_dir(self::DATA_DIR . $value)) {
|
||||||
rename(self::DATA_DIR . $key, self::DATA_DIR . $value);
|
rename(self::DATA_DIR . $key, self::DATA_DIR . $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,8 +321,7 @@ class config extends common
|
|||||||
|
|
||||||
$fileZip = $this->getInput('configRestoreImportFile');
|
$fileZip = $this->getInput('configRestoreImportFile');
|
||||||
$file_parts = pathinfo($fileZip);
|
$file_parts = pathinfo($fileZip);
|
||||||
$folder = date('Y-m-d-h-i-s', time());
|
// Validité du nom du fichier sélectionné
|
||||||
$zip = new ZipArchive();
|
|
||||||
if ($file_parts['extension'] !== 'zip') {
|
if ($file_parts['extension'] !== 'zip') {
|
||||||
// Valeurs en sortie erreur
|
// Valeurs en sortie erreur
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
@ -332,8 +331,9 @@ class config extends common
|
|||||||
'state' => false
|
'state' => false
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$successOpen = $zip->open(self::FILE_DIR . 'source/' . $fileZip);
|
// Ouverture de l'archive
|
||||||
if ($successOpen === FALSE) {
|
$zip = new ZipArchive();
|
||||||
|
if ($zip->open(self::FILE_DIR . 'source/' . $fileZip) === FALSE) {
|
||||||
// Valeurs en sortie erreur
|
// Valeurs en sortie erreur
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'title' => helper::translate('Restaurer'),
|
'title' => helper::translate('Restaurer'),
|
||||||
@ -343,20 +343,19 @@ class config extends common
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Lire le contenu de l'archive dans le tableau files
|
// Lire le contenu de l'archive dans le tableau files
|
||||||
|
/*
|
||||||
for ($i = 0; $i < $zip->numFiles; $i++) {
|
for ($i = 0; $i < $zip->numFiles; $i++) {
|
||||||
$stat = $zip->statIndex($i);
|
$stat = $zip->statIndex($i);
|
||||||
$files[] = (basename($stat['name']));
|
$files[] = (basename($stat['name']));
|
||||||
}
|
}*/
|
||||||
|
// Extraction de l'archive dans un dossier temporaire
|
||||||
// Lire la dataversion
|
$tmpDir = uniqid(8);
|
||||||
$tmpDir = uniqid(4);
|
|
||||||
$success = $zip->extractTo(self::TEMP_DIR . $tmpDir);
|
$success = $zip->extractTo(self::TEMP_DIR . $tmpDir);
|
||||||
$data = file_get_contents(self::TEMP_DIR . $tmpDir . '/data/core.json');
|
// Version de l'archive
|
||||||
$obj = json_decode($data);
|
$data = json_decode(file_get_contents(self::TEMP_DIR . $tmpDir . '/data/core.json'), true);
|
||||||
$dataVersion = strval($obj->core->dataVersion);
|
$dataVersion = $data['core']['dataVersion'];
|
||||||
switch (strlen($dataVersion)) {
|
// Version non prises en charge <9 ou erreur d'extraction
|
||||||
case 4:
|
if (intval(substr($dataVersion, 0, 1)) <= 9 or !$success) {
|
||||||
if (substr($dataVersion, 0, 1) === '9') {
|
|
||||||
// Valeurs en sortie erreur
|
// Valeurs en sortie erreur
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'title' => helper::translate('Restaurer'),
|
'title' => helper::translate('Restaurer'),
|
||||||
@ -364,43 +363,22 @@ class config extends common
|
|||||||
'notification' => helper::translate('Archive invalide'),
|
'notification' => helper::translate('Archive invalide'),
|
||||||
'state' => false
|
'state' => false
|
||||||
]);
|
]);
|
||||||
} else {
|
|
||||||
$version = 0;
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
$version = substr($dataVersion, 0, 2);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$version = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$this->removeDir(self::TEMP_DIR . $tmpDir);
|
|
||||||
|
|
||||||
if ($version >= 10) {
|
// Fermer le zip
|
||||||
// Option active, les users sont stockées
|
$zip->close();
|
||||||
|
|
||||||
|
// Option active, préservation des utilisateurs
|
||||||
if ($this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true) {
|
if ($this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true) {
|
||||||
$users = $this->getData(['user']);
|
$users = $this->getData(['user']);
|
||||||
}
|
}
|
||||||
} elseif ($version === 0) { // Version invalide
|
|
||||||
// Valeurs en sortie erreur
|
// Copie dans le dossier /site/data
|
||||||
$this->addOutput([
|
$success = $this->copyDir(self::TEMP_DIR . $tmpDir, 'site/');
|
||||||
'title' => helper::translate('Restaurer'),
|
$this->removeDir(self::TEMP_DIR . $tmpDir);
|
||||||
'view' => 'restore',
|
|
||||||
'notification' => helper::translate('Archive invalide'),
|
|
||||||
'state' => false
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
// Extraire le zip ou 'site/'
|
|
||||||
$this->removeDir(self::DATA_DIR);
|
|
||||||
$success = $zip->extractTo('site/');
|
|
||||||
// Fermer l'archive
|
|
||||||
$zip->close();
|
|
||||||
|
|
||||||
// Restaurer les users originaux d'une v10 si option cochée
|
// Restaurer les users originaux d'une v10 si option cochée
|
||||||
if (
|
if (
|
||||||
!empty($users) &&
|
|
||||||
$version >= 10 &&
|
|
||||||
$this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true
|
$this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true
|
||||||
) {
|
) {
|
||||||
$this->setData(['user', $users]);
|
$this->setData(['user', $users]);
|
||||||
@ -412,8 +390,6 @@ class config extends common
|
|||||||
$redirect = $this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true ? helper::baseUrl() . 'config/restore' : helper::baseUrl() . 'user/login/';
|
$redirect = $this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true ? helper::baseUrl() . 'config/restore' : helper::baseUrl() . 'user/login/';
|
||||||
// Valeurs en sortie erreur
|
// Valeurs en sortie erreur
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
/*'title' => 'Restaurer',
|
|
||||||
'view' => 'restore',*/
|
|
||||||
'redirect' => $redirect,
|
'redirect' => $redirect,
|
||||||
'notification' => helper::translate($notification),
|
'notification' => helper::translate($notification),
|
||||||
'state' => $success
|
'state' => $success
|
||||||
@ -604,7 +580,7 @@ class config extends common
|
|||||||
}
|
}
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'title' => sprintf( helper::translate('Éditeur de script %s'), ucfirst($this->geturl(2))),
|
'title' => sprintf(helper::translate('Éditeur de script %s'), ucfirst($this->geturl(2))),
|
||||||
'vendor' => [
|
'vendor' => [
|
||||||
'codemirror'
|
'codemirror'
|
||||||
],
|
],
|
||||||
@ -768,7 +744,7 @@ class config extends common
|
|||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'title' => helper::translate('Configuration'),
|
'title' => helper::translate('Configuration'),
|
||||||
'view' => 'index',
|
'view' => 'index',
|
||||||
'notification' => $success . helper::translate('Fichiers effacés') . ' - ' . helper::translate('Échecs') . ': '. $fail,
|
'notification' => $success . helper::translate('Fichiers effacés') . ' - ' . helper::translate('Échecs') . ': ' . $fail,
|
||||||
'state' => true
|
'state' => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user