Durcissselment des contrôles

This commit is contained in:
Fred Tempez 2023-07-04 19:03:27 +02:00
parent 38ed0dc1aa
commit 18f00cbe3c
4 changed files with 389 additions and 308 deletions

View File

@ -367,10 +367,10 @@ 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 // Extraction de l'archive dans un dossier temporaire
$tmpDir = uniqid(8); $tmpDir = uniqid(8);
$success = $zip->extractTo(self::TEMP_DIR . $tmpDir); $success = $zip->extractTo(self::TEMP_DIR . $tmpDir);
@ -647,26 +647,36 @@ class config extends common
public function logReset() public function logReset()
{ {
if (file_exists(self::DATA_DIR . 'journal.log')) { // Action interdite
unlink(self::DATA_DIR . 'journal.log'); if (
// Créer les en-têtes des journaux $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
$d = 'Date;Heure;IP;Id;Action' . PHP_EOL; ) {
file_put_contents(self::DATA_DIR . 'journal.log', $d);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => helper::translate('Configuration'), 'access' => false
'view' => 'index',
'notification' => helper::translate('Journal réinitialisé avec succès'),
'state' => true
]); ]);
} else { } else {
// Valeurs en sortie if (file_exists(self::DATA_DIR . 'journal.log')) {
$this->addOutput([ unlink(self::DATA_DIR . 'journal.log');
'title' => helper::translate('Configuration'), // Créer les en-têtes des journaux
'view' => 'index', $d = 'Date;Heure;IP;Id;Action' . PHP_EOL;
'notification' => helper::translate('Aucun journal à effacer'), file_put_contents(self::DATA_DIR . 'journal.log', $d);
'state' => false // Valeurs en sortie
]); $this->addOutput([
'title' => helper::translate('Configuration'),
'view' => 'index',
'notification' => helper::translate('Journal réinitialisé avec succès'),
'state' => true
]);
} else {
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Configuration'),
'view' => 'index',
'notification' => helper::translate('Aucun journal à effacer'),
'state' => false
]);
}
} }
} }
@ -677,25 +687,35 @@ class config extends common
*/ */
public function logDownload() public function logDownload()
{ {
$fileName = self::DATA_DIR . 'journal.log'; // Action interdite
if (file_exists($fileName)) { if (
ob_start(); $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
header('Content-Description: File Transfer'); ) {
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Length: ' . filesize($fileName));
ob_clean();
ob_end_flush();
readfile($fileName);
exit();
} else {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => helper::translate('Configuration'), 'access' => false
'view' => 'index',
'notification' => helper::translate('Aucun fichier journal à télécharger'),
'state' => false
]); ]);
} else {
$fileName = self::DATA_DIR . 'journal.log';
if (file_exists($fileName)) {
ob_start();
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Length: ' . filesize($fileName));
ob_clean();
ob_end_flush();
readfile($fileName);
exit();
} else {
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Configuration'),
'view' => 'index',
'notification' => helper::translate('Aucun fichier journal à télécharger'),
'state' => false
]);
}
} }
} }
@ -704,36 +724,46 @@ class config extends common
*/ */
public function blacklistDownload() public function blacklistDownload()
{ {
ob_start(); // Action interdite
$fileName = self::TEMP_DIR . 'blacklist.log'; if (
$d = 'Date dernière tentative;Heure dernière tentative;Id;Adresse IP;Nombre d\'échecs' . PHP_EOL; $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
file_put_contents($fileName, $d); ) {
if (file_exists($fileName)) {
$d = $this->getData(['blacklist']);
$data = '';
foreach ($d as $key => $item) {
$data .= helper::dateUTF8('%Y %m %d', $item['lastFail']) . ' - ' . helper::dateUTF8('%H:%M', time());
$data .= $key . ';' . $item['ip'] . ';' . $item['connectFail'] . PHP_EOL;
}
file_put_contents($fileName, $data, FILE_APPEND);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Length: ' . filesize($fileName));
ob_clean();
ob_end_flush();
readfile($fileName);
unlink(self::TEMP_DIR . 'blacklist.log');
exit();
} else {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => helper::translate('Confighelper::translate(uration'), 'access' => false
'view' => 'index',
'notification' => helper::translate('Aucune liste noire à télécharger'),
'state' => false
]); ]);
} else {
ob_start();
$fileName = self::TEMP_DIR . 'blacklist.log';
$d = 'Date dernière tentative;Heure dernière tentative;Id;Adresse IP;Nombre d\'échecs' . PHP_EOL;
file_put_contents($fileName, $d);
if (file_exists($fileName)) {
$d = $this->getData(['blacklist']);
$data = '';
foreach ($d as $key => $item) {
$data .= helper::dateUTF8('%Y %m %d', $item['lastFail']) . ' - ' . helper::dateUTF8('%H:%M', time());
$data .= $key . ';' . $item['ip'] . ';' . $item['connectFail'] . PHP_EOL;
}
file_put_contents($fileName, $data, FILE_APPEND);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Length: ' . filesize($fileName));
ob_clean();
ob_end_flush();
readfile($fileName);
unlink(self::TEMP_DIR . 'blacklist.log');
exit();
} else {
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Confighelper::translate(uration'),
'view' => 'index',
'notification' => helper::translate('Aucune liste noire à télécharger'),
'state' => false
]);
}
} }
} }
@ -743,23 +773,33 @@ class config extends common
public function blacklistReset() public function blacklistReset()
{ {
if (file_exists(self::DATA_DIR . 'blacklist.json')) { // Action interdite
$this->setData(['blacklist', []]); if (
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => helper::translate('Configuration'), 'access' => false
'view' => 'index',
'notification' => helper::translate('Liste noire réinitialisée avec succès'),
'state' => true
]); ]);
} else { } else {
// Valeurs en sortie if (file_exists(self::DATA_DIR . 'blacklist.json')) {
$this->addOutput([ $this->setData(['blacklist', []]);
'title' => helper::translate('Configuration'), // Valeurs en sortie
'view' => 'index', $this->addOutput([
'notification' => helper::translate('Aucune liste noire à effacer'), 'title' => helper::translate('Configuration'),
'state' => false 'view' => 'index',
]); 'notification' => helper::translate('Liste noire réinitialisée avec succès'),
'state' => true
]);
} else {
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Configuration'),
'view' => 'index',
'notification' => helper::translate('Aucune liste noire à effacer'),
'state' => false
]);
}
} }
} }
@ -768,16 +808,26 @@ class config extends common
*/ */
public function copyBackups() public function copyBackups()
{ {
// Action interdite
if (
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
} else {
$success = $this->copyDir(self::BACKUP_DIR, self::FILE_DIR . 'source/backup'); $success = $this->copyDir(self::BACKUP_DIR, self::FILE_DIR . 'source/backup');
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => helper::translate('Configuration'), 'title' => helper::translate('Configuration'),
'view' => 'index', 'view' => 'index',
'notification' => $success ? helper::translate('Copie terminée avec succès') : helper::translate('Copie terminée avec des erreurs'), 'notification' => $success ? helper::translate('Copie terminée avec succès') : helper::translate('Copie terminée avec des erreurs'),
'state' => $success 'state' => $success
]); ]);
}
} }
/** /**
@ -785,22 +835,32 @@ class config extends common
*/ */
public function delBackups() public function delBackups()
{ {
$path = realpath(self::BACKUP_DIR); // Action interdite
$success = $fail = 0; if (
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename) { $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
if (strpos($filename, '.zip')) { ) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
} else {
$path = realpath(self::BACKUP_DIR);
$success = $fail = 0;
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename) {
if (strpos($filename, '.zip')) {
$r = unlink($filename); $r = unlink($filename);
$success = $r === true ? $success + 1 : $success; $success = $r === true ? $success + 1 : $success;
$fail = $r === false ? $fail + 1 : $fail; $fail = $r === false ? $fail + 1 : $fail;
}
} }
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Configuration'),
'view' => 'index',
'notification' => $success . helper::translate('Fichiers effacés') . ' - ' . helper::translate('Échecs') . ': ' . $fail,
'state' => true
]);
} }
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Configuration'),
'view' => 'index',
'notification' => $success . helper::translate('Fichiers effacés') . ' - ' . helper::translate('Échecs') . ': ' . $fail,
'state' => true
]);
} }
} }

View File

@ -273,147 +273,157 @@ class install extends common
*/ */
public function steps() public function steps()
{ {
switch ($this->getInput('step', helper::FILTER_INT)) { // Action interdite
// Préparation if (
case 1: $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
$success = true; ) {
$message = ''; // Valeurs en sortie
// RAZ la mise à jour auto $this->addOutput([
$this->setData(['core', 'updateAvailable', false]); 'access' => false
// Backup du dossier Data ]);
helper::autoBackup(self::BACKUP_DIR, ['backup', 'tmp', 'file']); } else {
// Sauvegarde htaccess switch ($this->getInput('step', helper::FILTER_INT)) {
if ($this->getData(['config', 'autoUpdateHtaccess'])) { // Préparation
$success = copy('.htaccess', '.htaccess' . '.bak'); case 1:
$message = 'Erreur de copie du fichier htaccess'; $success = true;
} $message = '';
// Nettoyage des fichiers d'installation précédents // RAZ la mise à jour auto
if (file_exists(self::TEMP_DIR . 'update.tar.gz') && $success) { $this->setData(['core', 'updateAvailable', false]);
$success = $success || unlink(self::TEMP_DIR . 'update.tar.gz'); // Backup du dossier Data
$message = 'Impossible d\'effacer la mise à jour précédente'; helper::autoBackup(self::BACKUP_DIR, ['backup', 'tmp', 'file']);
} // Sauvegarde htaccess
if (file_exists(self::TEMP_DIR . 'update.tar') && $success) { if ($this->getData(['config', 'autoUpdateHtaccess'])) {
$success = $success || unlink(self::TEMP_DIR . 'update.tar'); $success = copy('.htaccess', '.htaccess' . '.bak');
$message = 'Impossible d\'effacer la mise à jour précédente'; $message = 'Erreur de copie du fichier htaccess';
} }
// Valeurs en sortie // Nettoyage des fichiers d'installation précédents
$this->addOutput([ if (file_exists(self::TEMP_DIR . 'update.tar.gz') && $success) {
'display' => self::DISPLAY_JSON, $success = $success || unlink(self::TEMP_DIR . 'update.tar.gz');
'content' => [ $message = 'Impossible d\'effacer la mise à jour précédente';
'success' => $success, }
'data' => $success ? null : json_encode($message, JSON_UNESCAPED_UNICODE) if (file_exists(self::TEMP_DIR . 'update.tar') && $success) {
] $success = $success || unlink(self::TEMP_DIR . 'update.tar');
]); $message = 'Impossible d\'effacer la mise à jour précédente';
break; }
// Téléchargement // Valeurs en sortie
case 2: $this->addOutput([
file_put_contents(self::TEMP_DIR . 'update.tar.gz', helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.tar.gz')); 'display' => self::DISPLAY_JSON,
$md5origin = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.md5'); 'content' => [
$md5origin = explode(' ', $md5origin); 'success' => $success,
$md5target = md5_file(self::TEMP_DIR . 'update.tar.gz'); 'data' => $success ? null : json_encode($message, JSON_UNESCAPED_UNICODE)
// Valeurs en sortie ]
$this->addOutput([ ]);
'display' => self::DISPLAY_JSON, break;
'content' => [ // Téléchargement
'success' => $md5origin[0] === $md5target, case 2:
'data' => $md5origin[0] === $md5target ? null : json_encode('Erreur de téléchargement ou de somme de contrôle', JSON_UNESCAPED_UNICODE) file_put_contents(self::TEMP_DIR . 'update.tar.gz', helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.tar.gz'));
] $md5origin = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.md5');
]); $md5origin = explode(' ', $md5origin);
break; $md5target = md5_file(self::TEMP_DIR . 'update.tar.gz');
// Installation // Valeurs en sortie
case 3: $this->addOutput([
$success = true; 'display' => self::DISPLAY_JSON,
// Check la réécriture d'URL avant d'écraser les fichiers 'content' => [
$rewrite = helper::checkRewrite(); 'success' => $md5origin[0] === $md5target,
// Décompression et installation 'data' => $md5origin[0] === $md5target ? null : json_encode('Erreur de téléchargement ou de somme de contrôle', JSON_UNESCAPED_UNICODE)
try { ]
// Décompression dans le dossier de fichier temporaires ]);
$pharData = new PharData(self::TEMP_DIR . 'update.tar.gz'); break;
$pharData->decompress(); // Installation
// Installation case 3:
$pharData->extractTo(__DIR__ . '/../../../', null, true); $success = true;
} catch (Exception $e) { // Check la réécriture d'URL avant d'écraser les fichiers
$success = $e->getMessage(); $rewrite = helper::checkRewrite();
} // Décompression et installation
// Nettoyage du dossier try {
if (file_exists(self::TEMP_DIR . 'update.tar.gz')) { // Décompression dans le dossier de fichier temporaires
unlink(self::TEMP_DIR . 'update.tar.gz'); $pharData = new PharData(self::TEMP_DIR . 'update.tar.gz');
} $pharData->decompress();
if (file_exists(self::TEMP_DIR . 'update.tar')) { // Installation
unlink(self::TEMP_DIR . 'update.tar'); $pharData->extractTo(__DIR__ . '/../../../', null, true);
} } catch (Exception $e) {
// Valeurs en sortie $success = $e->getMessage();
$this->addOutput([ }
'display' => self::DISPLAY_JSON, // Nettoyage du dossier
'content' => [ if (file_exists(self::TEMP_DIR . 'update.tar.gz')) {
'success' => $success, unlink(self::TEMP_DIR . 'update.tar.gz');
'data' => $rewrite }
] if (file_exists(self::TEMP_DIR . 'update.tar')) {
]); unlink(self::TEMP_DIR . 'update.tar');
break; }
// Configuration // Valeurs en sortie
case 4: $this->addOutput([
$success = true; 'display' => self::DISPLAY_JSON,
$message = ''; 'content' => [
$rewrite = $this->getInput('data'); 'success' => $success,
// Réécriture d'URL 'data' => $rewrite
if ($rewrite === 'true') { // Ajout des lignes dans le .htaccess ]
$fileContent = file_get_contents('.htaccess'); ]);
$rewriteData = PHP_EOL . break;
'# URL rewriting' . PHP_EOL . // Configuration
'<IfModule mod_rewrite.c>' . PHP_EOL . case 4:
"\tRewriteEngine on" . PHP_EOL . $success = true;
"\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL . $message = '';
"\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL . $rewrite = $this->getInput('data');
"\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL . // Réécriture d'URL
"\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL . if ($rewrite === 'true') { // Ajout des lignes dans le .htaccess
'</IfModule>' . PHP_EOL . $fileContent = file_get_contents('.htaccess');
'# URL rewriting' . PHP_EOL; $rewriteData = PHP_EOL .
$fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent); '# URL rewriting' . PHP_EOL .
$r = file_put_contents( '<IfModule mod_rewrite.c>' . PHP_EOL .
'.htaccess', "\tRewriteEngine on" . PHP_EOL .
$fileContent "\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL .
); "\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL .
$success = $r === false ? false : true; "\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL .
$message = $r === false ? 'Le fichier htaccess n\'a pas été restauré' : null; "\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL .
} '</IfModule>' . PHP_EOL .
// Recopie htaccess '# URL rewriting' . PHP_EOL;
if ( $fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent);
$this->getData(['config', 'autoUpdateHtaccess']) && $r = file_put_contents(
$success && file_exists('.htaccess.bak') '.htaccess',
) { $fileContent
// L'écraser avec le backup );
$success = $success || copy('.htaccess.bak', '.htaccess'); $success = $r === false ? false : true;
// Effacer le backup $message = $r === false ? 'Le fichier htaccess n\'a pas été restauré' : null;
unlink('.htaccess.bak'); }
} // Recopie htaccess
if (
/** $this->getData(['config', 'autoUpdateHtaccess']) &&
* Met à jour les dictionnaires des langues depuis les modèles installés $success && file_exists('.htaccess.bak')
*/ ) {
// L'écraser avec le backup
// Langues installées $success = $success || copy('.htaccess.bak', '.htaccess');
$installedUI = $this->getData(['language']); // Effacer le backup
unlink('.htaccess.bak');
// Langues disponibles avec la mise à jour
require_once('core/module/install/ressource/defaultdata.php');
$default = init::$defaultData['language'];
foreach ($installedUI as $key => $value) {
if ($default[$key]['version'] > $value['version']) {
copy('core/module/install/ressource/i18n/' . $key . '.json', self::I18N_DIR . $key . '.json');
$this->setData(['language', $key, $default[$key]]);
} }
}
// Valeurs en sortie /**
$this->addOutput([ * Met à jour les dictionnaires des langues depuis les modèles installés
'display' => self::DISPLAY_JSON, */
'content' => [
'success' => $success, // Langues installées
'data' => json_encode($message, JSON_UNESCAPED_UNICODE) $installedUI = $this->getData(['language']);
]
]); // Langues disponibles avec la mise à jour
require_once('core/module/install/ressource/defaultdata.php');
$default = init::$defaultData['language'];
foreach ($installedUI as $key => $value) {
if ($default[$key]['version'] > $value['version']) {
copy('core/module/install/ressource/i18n/' . $key . '.json', self::I18N_DIR . $key . '.json');
$this->setData(['language', $key, $default[$key]]);
}
}
// Valeurs en sortie
$this->addOutput([
'display' => self::DISPLAY_JSON,
'content' => [
'success' => $success,
'data' => json_encode($message, JSON_UNESCAPED_UNICODE)
]
]);
}
} }
} }

View File

@ -1016,81 +1016,91 @@ class theme extends common
public function import($zipName = '') public function import($zipName = '')
{ {
// Action interdite
if ( if (
$zipName !== '' && $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
file_exists($zipName)
) { ) {
// Init variables de retour // Valeurs en sortie
$success = false; $this->addOutput([
$notification = ''; 'access' => false
// Dossier temporaire ]);
$tempFolder = uniqid(); } else {
// Ouvrir le zip
$zip = new ZipArchive();
if ($zip->open($zipName) === TRUE) {
mkdir(self::TEMP_DIR . $tempFolder, 0755);
$zip->extractTo(self::TEMP_DIR . $tempFolder);
$modele = '';
// Archive de thème ?
if (
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css')
and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css')
and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json')
) {
$modele = 'theme';
}
if (
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json')
and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.css')
) {
$modele = 'admin';
}
if (!empty($modele)) {
// traiter l'archive
$success = $zip->extractTo('.');
// Substitution des fontes Google if (
if ($modele = 'theme') { $zipName !== '' &&
$c = $this->subFont(self::DATA_DIR . 'theme.json'); file_exists($zipName)
// Un remplacement nécessite la régénération de la feuille de style ) {
if ( // Init variables de retour
$c > 0
and file_exists(self::DATA_DIR . 'theme.css')
) {
unlink(self::DATA_DIR . 'theme.css');
}
}
if ($modele = 'admin') {
$c = $this->subFont(self::DATA_DIR . 'admin.json');
// Un remplacement nécessite la régénération de la feuille de style
if (
$c > 0
and file_exists(self::DATA_DIR . 'admin.css')
) {
unlink(self::DATA_DIR . 'admin.css');
}
}
// traitement d'erreur
$notification = $success ? helper::translate('Thème importé') : helper::translate('Erreur lors de l\'extraction, vérifiez les permissions');
} else {
// pas une archive de thème
$success = false;
$notification = helper::translate('Archive de thème invalide');
}
// Supprimer le dossier temporaire même si le thème est invalide
$this->removeDir(self::TEMP_DIR . $tempFolder);
$zip->close();
} else {
// erreur à l'ouverture
$success = false; $success = false;
$notification = helper::translate('Impossible d\'ouvrir l\'archive'); $notification = '';
} // Dossier temporaire
return (['success' => $success, 'notification' => $notification]); $tempFolder = uniqid();
} // Ouvrir le zip
$zip = new ZipArchive();
if ($zip->open($zipName) === TRUE) {
mkdir(self::TEMP_DIR . $tempFolder, 0755);
$zip->extractTo(self::TEMP_DIR . $tempFolder);
$modele = '';
// Archive de thème ?
if (
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css')
and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css')
and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json')
) {
$modele = 'theme';
}
if (
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json')
and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.css')
) {
$modele = 'admin';
}
if (!empty($modele)) {
// traiter l'archive
$success = $zip->extractTo('.');
return (['success' => false, 'notification' => helper::translate('Archive non spécifiée ou introuvable')]); // Substitution des fontes Google
if ($modele = 'theme') {
$c = $this->subFont(self::DATA_DIR . 'theme.json');
// Un remplacement nécessite la régénération de la feuille de style
if (
$c > 0
and file_exists(self::DATA_DIR . 'theme.css')
) {
unlink(self::DATA_DIR . 'theme.css');
}
}
if ($modele = 'admin') {
$c = $this->subFont(self::DATA_DIR . 'admin.json');
// Un remplacement nécessite la régénération de la feuille de style
if (
$c > 0
and file_exists(self::DATA_DIR . 'admin.css')
) {
unlink(self::DATA_DIR . 'admin.css');
}
}
// traitement d'erreur
$notification = $success ? helper::translate('Thème importé') : helper::translate('Erreur lors de l\'extraction, vérifiez les permissions');
} else {
// pas une archive de thème
$success = false;
$notification = helper::translate('Archive de thème invalide');
}
// Supprimer le dossier temporaire même si le thème est invalide
$this->removeDir(self::TEMP_DIR . $tempFolder);
$zip->close();
} else {
// erreur à l'ouverture
$success = false;
$notification = helper::translate('Impossible d\'ouvrir l\'archive');
}
return (['success' => $success, 'notification' => $notification]);
}
return (['success' => false, 'notification' => helper::translate('Archive non spécifiée ou introuvable')]);
}
} }

View File

@ -1014,7 +1014,8 @@ class user extends common
else { else {
// Soumission du formulaire // Soumission du formulaire
if ( if (
$this->getUser('permission', __CLASS__, __FUNCTION__) === true && // Tous les suers peuvent réinitialiser
// $this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
$this->isPost() $this->isPost()
) { ) {
// Double vérification pour le mot de passe // Double vérification pour le mot de passe