From f61c2a977aa5d3bb269d6c4c8519ac822bfdaae4 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 15 Mar 2024 20:10:06 +0100 Subject: [PATCH 01/15] config options --- module/folder/folder.php | 103 ++++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 35 deletions(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index f79022bf..7159835d 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -75,41 +75,74 @@ class folder extends common } -private function getFolderContent($chemin) -{ - // Vérifier si le chemin existe et est un dossier - if (is_dir($chemin)) { - // Ouvrir le dossier - if ($dh = opendir($chemin)) { - $items = isset($items) ? $items : '"; - - // Fermer le dossier - closedir($dh); - } - return $items; - } -} + private function getFolderContent($chemin, $config = []) + { + $showSubFolder = isset($config['showsubfolder']) ? $config['showsubfolder'] : true; + $sort = isset($config['sort']) ? $config['sort'] : true; + + // Vérifier si le chemin existe et est un dossier + if (!is_null($chemin) && is_dir($chemin)) { + // Ouvrir le dossier + if ($dh = opendir($chemin)) { + // Initialiser les tableaux pour les sous-dossiers et les fichiers + $subDirectories = []; + $files = []; + + // Parcourir les éléments du dossier + while (($element = readdir($dh)) !== false) { + // Exclure les éléments spéciaux + if ($element != '.' && $element != '..') { + // Construire le chemin complet de l'élément + $cheminComplet = $chemin . '/' .$element; + + // Vérifier si c'est un dossier + if (is_dir($cheminComplet)) { + // Ajouter le dossier au tableau des sous-dossiers + $subDirectories[] = $element; + } else { + // Ajouter le fichier au tableau des fichiers + $files[] = $element; + } + } + } + + // Fermer le dossier + closedir($dh); + + // Trier les sous-dossiers et les fichiers si nécessaire + if ($sort) { + sort($subDirectories); + sort($files); + } + + // Initialiser la liste des éléments + $items = '"; + + return $items; + } + } + + return ''; + } + From 75203d6e8e20991b09444729a669e866607f5fe9 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 15 Mar 2024 20:13:58 +0100 Subject: [PATCH 02/15] config options --- module/folder/folder.php | 36 +++++++++++++--------------- module/folder/view/config/config.php | 17 +++++++++---- module/folder/view/index/index.php | 2 +- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index 7159835d..81b13009 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -54,7 +54,12 @@ class folder extends common $this->getUser('permission', __CLASS__, __FUNCTION__) === true && $this->isPost() ) { - $this->setData(['module', $this->getUrl(0), 'path', preg_replace('/^\\./', '', $this->getInput('folderEditPath')) ]); + $this->setData(['module', + $this->getUrl(0),[ + 'path'=> preg_replace('/^\\./', '', $this->getInput('folderConfigPath')), + 'title' => $this->getInput('folderConfigTitle') + + ]]); // Valeurs en sortie $this->addOutput([ @@ -75,13 +80,10 @@ class folder extends common } - private function getFolderContent($chemin, $config = []) + private function getFolderContent($chemin) { - $showSubFolder = isset($config['showsubfolder']) ? $config['showsubfolder'] : true; - $sort = isset($config['sort']) ? $config['sort'] : true; - // Vérifier si le chemin existe et est un dossier - if (!is_null($chemin) && is_dir($chemin)) { + if (is_dir($chemin)) { // Ouvrir le dossier if ($dh = opendir($chemin)) { // Initialiser les tableaux pour les sous-dossiers et les fichiers @@ -109,23 +111,19 @@ class folder extends common // Fermer le dossier closedir($dh); - // Trier les sous-dossiers et les fichiers si nécessaire - if ($sort) { - sort($subDirectories); - sort($files); - } + // Trier les sous-dossiers et les fichiers + sort($subDirectories); + sort($files); // Initialiser la liste des éléments $items = '"; - + return $items; } } - + return ''; } + diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css index 028bbbb3..8c570d35 100644 --- a/module/folder/view/index/index.css +++ b/module/folder/view/index/index.css @@ -55,7 +55,11 @@ margin-left: -40px; } -/* Style pour les informations de fichier */ -.file-info { + +.file-info-container { + display: flex; float: right; -} \ No newline at end of file + align-content: left; + /* Ajout d'une largeur fixe à la div */ + width: 200px; +} From 10083e7ee8a55f0f66df91733673a30c7baf5f9b Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 17 Mar 2024 09:13:32 +0100 Subject: [PATCH 07/15] Folder Alignements --- module/folder.zip | Bin 0 -> 6094 bytes module/folder/folder.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 module/folder.zip diff --git a/module/folder.zip b/module/folder.zip new file mode 100644 index 0000000000000000000000000000000000000000..3d675ab035d6d2faaa43edd1f9128a84807046fe GIT binary patch literal 6094 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 F{{W4~?9~7O literal 0 HcmV?d00001 diff --git a/module/folder/folder.php b/module/folder/folder.php index d3430759..9d1acd62 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -183,7 +183,7 @@ class folder extends common private function formatSizeUnits($bytes) { - $units = array('octest', 'Ko', 'Mo', 'Go', 'To'); + $units = array('octets', 'Ko', 'Mo', 'Go', 'To'); $i = 0; while ($bytes >= 1024) { $bytes /= 1024; From e811660d7cc99d69076637d405e4eda24f364f51 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 17 Mar 2024 12:53:04 +0100 Subject: [PATCH 08/15] =?UTF-8?q?13.1.08=20mise=C3=A0=20jour=20automatis?= =?UTF-8?q?=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 1 + core/module/config/tool/autobackup.php | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 core/module/config/tool/autobackup.php diff --git a/CHANGES.md b/CHANGES.md index 0e6fa285..52d90e08 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ ### Amélioration - Sauvegarde de l'état des sélecteurs dans les tables des fontes et des utilisateurs. +- Fournit un outil de mise à jour automatisé. ## Version 13.1.07 diff --git a/core/module/config/tool/autobackup.php b/core/module/config/tool/autobackup.php new file mode 100644 index 00000000..0b919a85 --- /dev/null +++ b/core/module/config/tool/autobackup.php @@ -0,0 +1,26 @@ +open('../../../../site/backup/' . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); +$directory = '../../../../site'; +$files = new RecursiveIteratorIterator( + new RecursiveCallbackFilterIterator( + new RecursiveDirectoryIterator( + $directory, + RecursiveDirectoryIterator::SKIP_DOTS + ), + function ($fileInfo, $key, $iterator) use ($filter) { + return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter); + } + ) +); +foreach ($files as $name => $file) { + if (!$file->isDir()) { + $filePath = $file->getRealPath(); + $relativePath = substr($filePath, strlen(realpath($directory)) + 1); + $zip->addFile($filePath, $relativePath); + } +} +$zip->close(); \ No newline at end of file From 5f5815cbd950b9c555a7911515145f41977ac00a Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 17 Mar 2024 20:49:15 +0100 Subject: [PATCH 09/15] clean auto backup --- core/module/config/tool/cleanautobackup.php | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 core/module/config/tool/cleanautobackup.php diff --git a/core/module/config/tool/cleanautobackup.php b/core/module/config/tool/cleanautobackup.php new file mode 100644 index 00000000..732ac562 --- /dev/null +++ b/core/module/config/tool/cleanautobackup.php @@ -0,0 +1,22 @@ +isFile() && $file->getExtension() === 'tar.gz') { + // Vérifie si le fichier a été modifié avant la limite de temps + if ($file->getMTime() < $timeLimit) { + // Supprime le fichier + unlink($file->getRealPath()); + } + } +} +?> From a47cbe49fe9ebe7b47abb365d7bf447e7dfb442b Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 17 Mar 2024 21:09:37 +0100 Subject: [PATCH 10/15] =?UTF-8?q?D=C3=A9bordements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/folder/folder.php | 2 +- module/folder/view/index/index.css | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index 9d1acd62..7c959b3b 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -165,7 +165,7 @@ class folder extends common $fileSizeFormatted = $this->formatSizeUnits($fileSize); $fileInfo = "
" . date("d-m-Y H:i", filemtime($fileFullPath)) . " - $fileSizeFormatted
"; } - $items .= "
  • $file$fileInfo
  • "; + $items .= "
  • $file
    $fileInfo
  • "; } // Fermer la liste diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css index 8c570d35..b8499eda 100644 --- a/module/folder/view/index/index.css +++ b/module/folder/view/index/index.css @@ -63,3 +63,10 @@ /* Ajout d'une largeur fixe à la div */ width: 200px; } + +.file-name { + max-width: 400px; /* Largeur maximale du nom de fichier */ + white-space: nowrap; /* Empêcher le débordement du texte à la ligne suivante */ + overflow: hidden; /* Cacher tout texte qui dépasse */ + text-overflow: ellipsis; /* Ajouter des points de suspension (...) pour indiquer que le texte a été tronqué */ +} \ No newline at end of file From c4a23de7448f13cf72c2f228f945af96c3c7669c Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 18 Mar 2024 08:42:36 +0100 Subject: [PATCH 11/15] =?UTF-8?q?Contr=C3=B4le=20de=20cl=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/config/tool/.htaccess | 4 +++ core/module/config/tool/autobackup.php | 28 ++++++++++++++++++--- core/module/config/tool/cleanautobackup.php | 28 +++++++++++++++++++++ core/module/config/tool/data.key | 1 + 4 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 core/module/config/tool/.htaccess create mode 100644 core/module/config/tool/data.key diff --git a/core/module/config/tool/.htaccess b/core/module/config/tool/.htaccess new file mode 100644 index 00000000..a5decbff --- /dev/null +++ b/core/module/config/tool/.htaccess @@ -0,0 +1,4 @@ + + Order Allow,Deny + Deny from all + diff --git a/core/module/config/tool/autobackup.php b/core/module/config/tool/autobackup.php index 0b919a85..26503f50 100644 --- a/core/module/config/tool/autobackup.php +++ b/core/module/config/tool/autobackup.php @@ -1,6 +1,28 @@ open('../../../../site/backup/' . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); @@ -23,4 +45,4 @@ foreach ($files as $name => $file) { $zip->addFile($filePath, $relativePath); } } -$zip->close(); \ No newline at end of file +$zip->close(); diff --git a/core/module/config/tool/cleanautobackup.php b/core/module/config/tool/cleanautobackup.php index 732ac562..a97d38ef 100644 --- a/core/module/config/tool/cleanautobackup.php +++ b/core/module/config/tool/cleanautobackup.php @@ -1,4 +1,32 @@ Date: Mon, 18 Mar 2024 08:51:51 +0100 Subject: [PATCH 12/15] change key --- core/module/config/tool/data.key | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/module/config/tool/data.key b/core/module/config/tool/data.key index 40776184..e404799e 100644 --- a/core/module/config/tool/data.key +++ b/core/module/config/tool/data.key @@ -1 +1 @@ -nokXpczxvrc8hg \ No newline at end of file +saisirunecle \ No newline at end of file From 11753b44761b06c32a7418bc13d533658409dab6 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 18 Mar 2024 17:30:35 +0100 Subject: [PATCH 13/15] add data.key to git ignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 578c3da9..1c959d05 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ site/i18n/*.json core/vendor/tinymce/link_list.json robots.txt sitemap.xml -.gitignore \ No newline at end of file +.gitignore +core/module/config/tool/data.key \ No newline at end of file From 2cbd3d5923ec613f47af8ca3eee885da15dd8249 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 18 Mar 2024 17:40:56 +0100 Subject: [PATCH 14/15] Update rolling backup --- core/module/config/tool/autobackup.php | 56 ++++++++++----------- core/module/config/tool/cleanautobackup.php | 42 ++++++++-------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/core/module/config/tool/autobackup.php b/core/module/config/tool/autobackup.php index 26503f50..bb1e1fa4 100644 --- a/core/module/config/tool/autobackup.php +++ b/core/module/config/tool/autobackup.php @@ -11,38 +11,38 @@ La clé doit être fournie en tant que paramètre "key" dans l'URL et correspond */ // Vérification de la clé -if (isset($_GET['key'])) { +if (isset ($_GET['key'])) { $key = $_GET['key']; $storedKey = file_get_contents('data.key'); if ($key !== $storedKey) { - die("Clé invalide !"); + http_response_code(401); + exit(); } } else { - die("Clé manquante !"); -} - -// Création du ZIP -$filter = ['backup', 'tmp']; -$fileName = date('Y-m-d-H-i-s', time()) . '-rolling-backup.zip'; -$zip = new ZipArchive(); -$zip->open('../../../../site/backup/' . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); -$directory = '../../../../site'; -$files = new RecursiveIteratorIterator( - new RecursiveCallbackFilterIterator( - new RecursiveDirectoryIterator( - $directory, - RecursiveDirectoryIterator::SKIP_DOTS - ), - function ($fileInfo, $key, $iterator) use ($filter) { - return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter); + // Création du ZIP + $filter = ['backup', 'tmp']; + $fileName = date('Y-m-d-H-i-s', time()) . '-rolling-backup.zip'; + $zip = new ZipArchive(); + $zip->open('../../../../site/backup/' . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); + $directory = '../../../../site'; + $files = new RecursiveIteratorIterator( + new RecursiveCallbackFilterIterator( + new RecursiveDirectoryIterator( + $directory, + RecursiveDirectoryIterator::SKIP_DOTS + ), + function ($fileInfo, $key, $iterator) use ($filter) { + return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter); + } + ) + ); + foreach ($files as $name => $file) { + if (!$file->isDir()) { + $filePath = $file->getRealPath(); + $relativePath = substr($filePath, strlen(realpath($directory)) + 1); + $zip->addFile($filePath, $relativePath); } - ) -); -foreach ($files as $name => $file) { - if (!$file->isDir()) { - $filePath = $file->getRealPath(); - $relativePath = substr($filePath, strlen(realpath($directory)) + 1); - $zip->addFile($filePath, $relativePath); } -} -$zip->close(); + $zip->close(); + http_response_code(201); +} \ No newline at end of file diff --git a/core/module/config/tool/cleanautobackup.php b/core/module/config/tool/cleanautobackup.php index a97d38ef..c18800b9 100644 --- a/core/module/config/tool/cleanautobackup.php +++ b/core/module/config/tool/cleanautobackup.php @@ -11,7 +11,7 @@ Le script vérifie également la présence et la validité d'une clé spécifiqu */ // Vérification de la clé -if (isset($_GET['key'])) { +if (isset ($_GET['key'])) { // Récupération de la clé fournie en GET $key = $_GET['key']; @@ -20,31 +20,31 @@ if (isset($_GET['key'])) { // Vérification de correspondance entre les clés if ($key !== $storedKey) { - die("Clé invalide !"); + http_response_code(401); + exit(); } } else { - // Si la clé est manquante, affiche un message d'erreur et arrête l'exécution du script - die("Clé manquante !"); -} -// Récupère le nombre de jours à partir de la variable GET 'days' -$days = isset($_GET['days']) ? (int)$_GET['days'] : 1; // Par défaut à 1 si non spécifié + // Récupère le nombre de jours à partir de la variable GET 'days' + $days = isset ($_GET['days']) ? (int) $_GET['days'] : 1; // Par défaut à 1 si non spécifié -// Chemin vers le répertoire contenant les fichiers -$directory = '../../../../site/backup/'; // Remplacez par le chemin réel + // Chemin vers le répertoire contenant les fichiers + $directory = '../../../../site/backup/'; // Remplacez par le chemin réel -// Convertit le nombre de jours en secondes -$timeLimit = strtotime("-$days days"); + // Convertit le nombre de jours en secondes + $timeLimit = strtotime("-$days days"); -// Crée un nouvel objet DirectoryIterator -foreach (new DirectoryIterator($directory) as $file) { - // Vérifie si l'élément courant est un fichier et a l'extension 'tar.gz' - if ($file->isFile() && $file->getExtension() === 'tar.gz') { - // Vérifie si le fichier a été modifié avant la limite de temps - if ($file->getMTime() < $timeLimit) { - // Supprime le fichier - unlink($file->getRealPath()); + // Crée un nouvel objet DirectoryIterator + foreach (new DirectoryIterator($directory) as $file) { + // Vérifie si l'élément courant est un fichier et a l'extension 'tar.gz' + if ($file->isFile() && $file->getExtension() === 'tar.gz') { + // Vérifie si le fichier a été modifié avant la limite de temps + if ($file->getMTime() < $timeLimit) { + // Supprime le fichier + unlink($file->getRealPath()); + } } } -} -?> + // Si la clé est manquante, affiche un message d'erreur et arrête l'exécution du script + http_response_code(201); +} \ No newline at end of file From 1147b5c5e1fff513cea77da6c0db5a7d2fa3b8a5 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 18 Mar 2024 17:50:54 +0100 Subject: [PATCH 15/15] update roling backup --- core/module/config/tool/autobackup.php | 1 - core/module/config/tool/cleanautobackup.php | 1 - 2 files changed, 2 deletions(-) diff --git a/core/module/config/tool/autobackup.php b/core/module/config/tool/autobackup.php index bb1e1fa4..52166257 100644 --- a/core/module/config/tool/autobackup.php +++ b/core/module/config/tool/autobackup.php @@ -18,7 +18,6 @@ if (isset ($_GET['key'])) { http_response_code(401); exit(); } -} else { // Création du ZIP $filter = ['backup', 'tmp']; $fileName = date('Y-m-d-H-i-s', time()) . '-rolling-backup.zip'; diff --git a/core/module/config/tool/cleanautobackup.php b/core/module/config/tool/cleanautobackup.php index c18800b9..f0144d10 100644 --- a/core/module/config/tool/cleanautobackup.php +++ b/core/module/config/tool/cleanautobackup.php @@ -23,7 +23,6 @@ if (isset ($_GET['key'])) { http_response_code(401); exit(); } -} else { // Récupère le nombre de jours à partir de la variable GET 'days' $days = isset ($_GET['days']) ? (int) $_GET['days'] : 1; // Par défaut à 1 si non spécifié