diff --git a/core/module/config/config.php b/core/module/config/config.php
index 73233d67..18734c5d 100644
--- a/core/module/config/config.php
+++ b/core/module/config/config.php
@@ -367,10 +367,10 @@ class config extends common
}
// Lire le contenu de l'archive dans le tableau files
/*
- for ($i = 0; $i < $zip->numFiles; $i++) {
- $stat = $zip->statIndex($i);
- $files[] = (basename($stat['name']));
- }*/
+ for ($i = 0; $i < $zip->numFiles; $i++) {
+ $stat = $zip->statIndex($i);
+ $files[] = (basename($stat['name']));
+ }*/
// Extraction de l'archive dans un dossier temporaire
$tmpDir = uniqid(8);
$success = $zip->extractTo(self::TEMP_DIR . $tmpDir);
@@ -647,26 +647,36 @@ class config extends common
public function logReset()
{
- if (file_exists(self::DATA_DIR . 'journal.log')) {
- unlink(self::DATA_DIR . 'journal.log');
- // Créer les en-têtes des journaux
- $d = 'Date;Heure;IP;Id;Action' . PHP_EOL;
- file_put_contents(self::DATA_DIR . 'journal.log', $d);
+ // Action interdite
+ if (
+ $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
+ ) {
// Valeurs en sortie
$this->addOutput([
- 'title' => helper::translate('Configuration'),
- 'view' => 'index',
- 'notification' => helper::translate('Journal réinitialisé avec succès'),
- 'state' => true
+ 'access' => false
]);
} else {
- // Valeurs en sortie
- $this->addOutput([
- 'title' => helper::translate('Configuration'),
- 'view' => 'index',
- 'notification' => helper::translate('Aucun journal à effacer'),
- 'state' => false
- ]);
+ if (file_exists(self::DATA_DIR . 'journal.log')) {
+ unlink(self::DATA_DIR . 'journal.log');
+ // Créer les en-têtes des journaux
+ $d = 'Date;Heure;IP;Id;Action' . PHP_EOL;
+ file_put_contents(self::DATA_DIR . 'journal.log', $d);
+ // 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()
{
- $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 {
+ // Action interdite
+ if (
+ $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
+ ) {
// Valeurs en sortie
$this->addOutput([
- 'title' => helper::translate('Configuration'),
- 'view' => 'index',
- 'notification' => helper::translate('Aucun fichier journal à télécharger'),
- 'state' => false
+ 'access' => 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()
{
- 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 {
+ // Action interdite
+ if (
+ $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
+ ) {
// Valeurs en sortie
$this->addOutput([
- 'title' => helper::translate('Confighelper::translate(uration'),
- 'view' => 'index',
- 'notification' => helper::translate('Aucune liste noire à télécharger'),
- 'state' => false
+ 'access' => 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()
{
- if (file_exists(self::DATA_DIR . 'blacklist.json')) {
- $this->setData(['blacklist', []]);
+ // Action interdite
+ if (
+ $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
+ ) {
// Valeurs en sortie
$this->addOutput([
- 'title' => helper::translate('Configuration'),
- 'view' => 'index',
- 'notification' => helper::translate('Liste noire réinitialisée avec succès'),
- 'state' => true
+ 'access' => false
]);
} else {
- // Valeurs en sortie
- $this->addOutput([
- 'title' => helper::translate('Configuration'),
- 'view' => 'index',
- 'notification' => helper::translate('Aucune liste noire à effacer'),
- 'state' => false
- ]);
+ if (file_exists(self::DATA_DIR . 'blacklist.json')) {
+ $this->setData(['blacklist', []]);
+ // Valeurs en sortie
+ $this->addOutput([
+ 'title' => helper::translate('Configuration'),
+ '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()
{
+ // 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
- $this->addOutput([
- 'title' => helper::translate('Configuration'),
- 'view' => 'index',
- 'notification' => $success ? helper::translate('Copie terminée avec succès') : helper::translate('Copie terminée avec des erreurs'),
- 'state' => $success
- ]);
+ // Valeurs en sortie
+ $this->addOutput([
+ 'title' => helper::translate('Configuration'),
+ 'view' => 'index',
+ 'notification' => $success ? helper::translate('Copie terminée avec succès') : helper::translate('Copie terminée avec des erreurs'),
+ 'state' => $success
+ ]);
+ }
}
/**
@@ -785,22 +835,32 @@ class config extends common
*/
public function delBackups()
{
- $path = realpath(self::BACKUP_DIR);
- $success = $fail = 0;
- foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename) {
- if (strpos($filename, '.zip')) {
+ // Action interdite
+ if (
+ $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
+ ) {
+ // 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);
- $success = $r === true ? $success + 1 : $success;
- $fail = $r === false ? $fail + 1 : $fail;
+ $r = unlink($filename);
+ $success = $r === true ? $success + 1 : $success;
+ $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
- ]);
}
}
\ No newline at end of file
diff --git a/core/module/install/install.php b/core/module/install/install.php
index 26ae0119..6baa922c 100644
--- a/core/module/install/install.php
+++ b/core/module/install/install.php
@@ -273,147 +273,157 @@ class install extends common
*/
public function steps()
{
- switch ($this->getInput('step', helper::FILTER_INT)) {
- // Préparation
- case 1:
- $success = true;
- $message = '';
- // RAZ la mise à jour auto
- $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');
- $message = 'Erreur de copie du fichier htaccess';
- }
- // Nettoyage des fichiers d'installation précédents
- if (file_exists(self::TEMP_DIR . 'update.tar.gz') && $success) {
- $success = $success || unlink(self::TEMP_DIR . 'update.tar.gz');
- $message = 'Impossible d\'effacer la mise à jour précédente';
- }
- 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';
- }
- // Valeurs en sortie
- $this->addOutput([
- 'display' => self::DISPLAY_JSON,
- 'content' => [
- 'success' => $success,
- 'data' => $success ? null : json_encode($message, JSON_UNESCAPED_UNICODE)
- ]
- ]);
- break;
- // Téléchargement
- case 2:
- 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);
- $md5target = md5_file(self::TEMP_DIR . 'update.tar.gz');
- // Valeurs en sortie
- $this->addOutput([
- 'display' => self::DISPLAY_JSON,
- 'content' => [
- 'success' => $md5origin[0] === $md5target,
- 'data' => $md5origin[0] === $md5target ? null : json_encode('Erreur de téléchargement ou de somme de contrôle', JSON_UNESCAPED_UNICODE)
- ]
- ]);
- break;
- // Installation
- case 3:
- $success = true;
- // Check la réécriture d'URL avant d'écraser les fichiers
- $rewrite = helper::checkRewrite();
- // Décompression et installation
- try {
- // Décompression dans le dossier de fichier temporaires
- $pharData = new PharData(self::TEMP_DIR . 'update.tar.gz');
- $pharData->decompress();
- // Installation
- $pharData->extractTo(__DIR__ . '/../../../', null, true);
- } catch (Exception $e) {
- $success = $e->getMessage();
- }
- // Nettoyage du dossier
- if (file_exists(self::TEMP_DIR . 'update.tar.gz')) {
- unlink(self::TEMP_DIR . 'update.tar.gz');
- }
- if (file_exists(self::TEMP_DIR . 'update.tar')) {
- unlink(self::TEMP_DIR . 'update.tar');
- }
- // Valeurs en sortie
- $this->addOutput([
- 'display' => self::DISPLAY_JSON,
- 'content' => [
- 'success' => $success,
- 'data' => $rewrite
- ]
- ]);
- break;
- // Configuration
- case 4:
- $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);
- $r = file_put_contents(
- '.htaccess',
- $fileContent
- );
- $success = $r === false ? false : true;
- $message = $r === false ? 'Le fichier htaccess n\'a pas été restauré' : null;
- }
- // Recopie htaccess
- if (
- $this->getData(['config', 'autoUpdateHtaccess']) &&
- $success && file_exists('.htaccess.bak')
- ) {
- // L'écraser avec le backup
- $success = $success || copy('.htaccess.bak', '.htaccess');
- // Effacer le backup
- unlink('.htaccess.bak');
- }
-
- /**
- * Met à jour les dictionnaires des langues depuis les modèles installés
- */
-
- // Langues installées
- $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]]);
+ // Action interdite
+ if (
+ $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
+ ) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'access' => false
+ ]);
+ } else {
+ switch ($this->getInput('step', helper::FILTER_INT)) {
+ // Préparation
+ case 1:
+ $success = true;
+ $message = '';
+ // RAZ la mise à jour auto
+ $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');
+ $message = 'Erreur de copie du fichier htaccess';
+ }
+ // Nettoyage des fichiers d'installation précédents
+ if (file_exists(self::TEMP_DIR . 'update.tar.gz') && $success) {
+ $success = $success || unlink(self::TEMP_DIR . 'update.tar.gz');
+ $message = 'Impossible d\'effacer la mise à jour précédente';
+ }
+ 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';
+ }
+ // Valeurs en sortie
+ $this->addOutput([
+ 'display' => self::DISPLAY_JSON,
+ 'content' => [
+ 'success' => $success,
+ 'data' => $success ? null : json_encode($message, JSON_UNESCAPED_UNICODE)
+ ]
+ ]);
+ break;
+ // Téléchargement
+ case 2:
+ 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);
+ $md5target = md5_file(self::TEMP_DIR . 'update.tar.gz');
+ // Valeurs en sortie
+ $this->addOutput([
+ 'display' => self::DISPLAY_JSON,
+ 'content' => [
+ 'success' => $md5origin[0] === $md5target,
+ 'data' => $md5origin[0] === $md5target ? null : json_encode('Erreur de téléchargement ou de somme de contrôle', JSON_UNESCAPED_UNICODE)
+ ]
+ ]);
+ break;
+ // Installation
+ case 3:
+ $success = true;
+ // Check la réécriture d'URL avant d'écraser les fichiers
+ $rewrite = helper::checkRewrite();
+ // Décompression et installation
+ try {
+ // Décompression dans le dossier de fichier temporaires
+ $pharData = new PharData(self::TEMP_DIR . 'update.tar.gz');
+ $pharData->decompress();
+ // Installation
+ $pharData->extractTo(__DIR__ . '/../../../', null, true);
+ } catch (Exception $e) {
+ $success = $e->getMessage();
+ }
+ // Nettoyage du dossier
+ if (file_exists(self::TEMP_DIR . 'update.tar.gz')) {
+ unlink(self::TEMP_DIR . 'update.tar.gz');
+ }
+ if (file_exists(self::TEMP_DIR . 'update.tar')) {
+ unlink(self::TEMP_DIR . 'update.tar');
+ }
+ // Valeurs en sortie
+ $this->addOutput([
+ 'display' => self::DISPLAY_JSON,
+ 'content' => [
+ 'success' => $success,
+ 'data' => $rewrite
+ ]
+ ]);
+ break;
+ // Configuration
+ case 4:
+ $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);
+ $r = file_put_contents(
+ '.htaccess',
+ $fileContent
+ );
+ $success = $r === false ? false : true;
+ $message = $r === false ? 'Le fichier htaccess n\'a pas été restauré' : null;
+ }
+ // Recopie htaccess
+ if (
+ $this->getData(['config', 'autoUpdateHtaccess']) &&
+ $success && file_exists('.htaccess.bak')
+ ) {
+ // L'écraser avec le backup
+ $success = $success || copy('.htaccess.bak', '.htaccess');
+ // Effacer le backup
+ unlink('.htaccess.bak');
}
- }
- // Valeurs en sortie
- $this->addOutput([
- 'display' => self::DISPLAY_JSON,
- 'content' => [
- 'success' => $success,
- 'data' => json_encode($message, JSON_UNESCAPED_UNICODE)
- ]
- ]);
+ /**
+ * Met à jour les dictionnaires des langues depuis les modèles installés
+ */
+
+ // Langues installées
+ $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)
+ ]
+ ]);
+ }
}
}
diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php
index c5f122cd..8d4a9b5d 100644
--- a/core/module/theme/theme.php
+++ b/core/module/theme/theme.php
@@ -1016,81 +1016,91 @@ class theme extends common
public function import($zipName = '')
{
-
+ // Action interdite
if (
- $zipName !== '' &&
- file_exists($zipName)
+ $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
) {
- // Init variables de retour
- $success = false;
- $notification = '';
- // Dossier temporaire
- $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('.');
+ // Valeurs en sortie
+ $this->addOutput([
+ 'access' => false
+ ]);
+ } else {
- // 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
+ if (
+ $zipName !== '' &&
+ file_exists($zipName)
+ ) {
+ // Init variables de retour
$success = false;
- $notification = helper::translate('Impossible d\'ouvrir l\'archive');
- }
- return (['success' => $success, 'notification' => $notification]);
- }
+ $notification = '';
+ // Dossier temporaire
+ $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')]);
+ }
}
diff --git a/core/module/user/user.php b/core/module/user/user.php
index 89cb7f77..d01325da 100644
--- a/core/module/user/user.php
+++ b/core/module/user/user.php
@@ -1014,7 +1014,8 @@ class user extends common
else {
// Soumission du formulaire
if (
- $this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
+ // Tous les suers peuvent réinitialiser
+ // $this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
$this->isPost()
) {
// Double vérification pour le mot de passe