From 34c4d0d0c37c7f640a1a6373bba30ebe1129d6c4 Mon Sep 17 00:00:00 2001 From: polo Date: Wed, 3 Jun 2026 21:42:46 +0200 Subject: =?UTF-8?q?t=C3=A9l=C3=A9chargement=20des=20fichiers=20media,=20un?= =?UTF-8?q?=20tout=20petit=20peu=20de=20responsive=20design?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/css/foot.css | 2 +- public/css/maintenance.css | 8 ++++++ public/js/maintenance.js | 18 ++++++++----- src/controller/MaintenanceController.php | 18 ++++++++++++- src/service/Installation.php | 2 +- src/service/UserDataService.php | 46 ++++++++++++++++++++++++++++++++ src/service/router.php | 4 +++ src/view/templates/maintenance.php | 12 +++++++++ 8 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 src/service/UserDataService.php diff --git a/public/css/foot.css b/public/css/foot.css index ed65666..8ffb6d7 100644 --- a/public/css/foot.css +++ b/public/css/foot.css @@ -177,7 +177,7 @@ footer .data > div position: fixed; z-index: 1; left: 50%; - bottom: 30px; + bottom: 40px; transform: translateX(-50%); /*opacity: 0;*/ transition: opacity 0.5s, visibility 0.5s; diff --git a/public/css/maintenance.css b/public/css/maintenance.css index 9b6f525..4a0dbb0 100644 --- a/public/css/maintenance.css +++ b/public/css/maintenance.css @@ -27,4 +27,12 @@ border-radius: 4px; background-color: white; border: lightgrey 2px outset; +} + +@media screen and (max-width: 480px) +{ + .maintenance select + { + font-size: 86%; + } } \ No newline at end of file diff --git a/public/js/maintenance.js b/public/js/maintenance.js index 078c223..a742cf6 100644 --- a/public/js/maintenance.js +++ b/public/js/maintenance.js @@ -42,19 +42,14 @@ function cleanLogs(){ fetcher.send({}); } -// notification après restauration +// notification de succès ou erreur après restauration document.addEventListener('DOMContentLoaded', function(){ + // 1/ message généré avant la redirection const params = new URLSearchParams(window.location.search); - // ça pourrait être bien de récupérer le message d'erreur de l'exception d'une autre manière (message dans la variable globale window? c'est faisable??) - - if(typeof window.error_message !== "undefined"){ - toastNotify(window.error_message); - } if(params.has('read_backups_dir')){ toastNotify("Une erreur s'est produite:
" + params.get('read_backups_dir')); } - if(params.has('database_restauration')){ if(params.get('database_restauration') === 'successful'){ toastNotify("La base de données a été restaurée avec succès !!"); @@ -63,4 +58,13 @@ document.addEventListener('DOMContentLoaded', function(){ toastNotify("Une erreur s'est produite:
" + params.get('database_restauration')); } } + if(params.has('get_all_media')){ + toastNotify(params.get('get_all_media')); + } + + + // 2/ message généré après la redirection, au moment de l'ouverture de la page + if(typeof window.error_message !== "undefined"){ + toastNotify(window.error_message); + } }); diff --git a/src/controller/MaintenanceController.php b/src/controller/MaintenanceController.php index 3b58fe6..eb1db04 100644 --- a/src/controller/MaintenanceController.php +++ b/src/controller/MaintenanceController.php @@ -16,7 +16,7 @@ class MaintenanceController echo json_encode(['success' => false]); } else{ - $view = '

Table ' . TABLE_PREFIX . 'log de la BDD

+ $view = '

Table ' . TABLE_PREFIX . 'log de la base de données

@@ -65,6 +65,22 @@ class MaintenanceController } die; } + static public function getAllMedia(): void + { + try{ + $file_path = '../var/' . UserDataService::createZip('all_media.zip', ['user_data/assets', 'user_data/images', 'user_data/media']); + header('Content-Type: application/zip'); + header('Content-Disposition: attachment; filename="' . basename($file_path) . '"'); // pour provoquer un téléchargement et non pour afficher + header('Content-Length: ' . filesize($file_path)); // peut servir côté client (barre de progression...) + readfile($file_path); + die; + } + // exeptions lancées dans Backup::mySQLdump + catch(RuntimeException $e){ // pas d'info $e pour le client7 + header('Location: ' . new URL(['page' => 'maintenance', 'get_all_media' => $e->getMessage()])); + } + die; + } // parce qu'il faut un contrôleur static public function handleBackupSelection(EntityManager $entityManager, string $selected_file): void diff --git a/src/service/Installation.php b/src/service/Installation.php index 100001d..f7de2cf 100644 --- a/src/service/Installation.php +++ b/src/service/Installation.php @@ -8,7 +8,7 @@ class Installation static public function phpDependancies(): void { $flag = false; - $extensions = ['pdo_mysql', 'mbstring', 'ctype', 'json', 'tokenizer', 'imagick']; // les 5 premières sont pour doctrine + $extensions = ['pdo_mysql', 'mbstring', 'ctype', 'json', 'tokenizer', 'imagick', 'zip']; // les 5 premières sont pour doctrine // ajouter plus tard zlib pour la compression des backups foreach($extensions as $extension){ if(!extension_loaded($extension)){ diff --git a/src/service/UserDataService.php b/src/service/UserDataService.php new file mode 100644 index 0000000..5fa60d5 --- /dev/null +++ b/src/service/UserDataService.php @@ -0,0 +1,46 @@ +open($file_path, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== TRUE){ // ou ZipArchive::FL_OVERWRITE, à comparer à ZipArchive::OVERWRITE + throw new RuntimeException("Création ou ouverture du fichier demandé impossible à cause d'une erreur de permissions sur le serveur."); + } + + // recherche récursive dans les dossiers dans $source_directories, c'est comme le paramètre "-r" dans la console + $counter = 0; + foreach($source_directories as $path){ + $directory = new RecursiveDirectoryIterator($path); + $iterator = new RecursiveIteratorIterator($directory); + + foreach($iterator as $info){ + if($info->getFilename() != "." && $info->getFilename() != ".."){ // chemins inutiles . et .. + $Zip->addGlob($info->getPathname(), 0, array('')); + $counter++; + } + } + } + // recherche à la racine avec des pattern de noms de fichiers (optionnel) + foreach($pattern_to_target_in_user_data as $one_pattern){ + $Zip->addGlob($one_pattern, 0, array('')); + } + + $Zip->close(); + if($counter > 0){ + //chmod($file_path, 0666); + return $zip_name; + } + else{ + throw new RuntimeException("Téléchargement des fichiers impossible, aucun fichier n'a été trouvé sur le serveur."); + } + } +} \ No newline at end of file diff --git a/src/service/router.php b/src/service/router.php index 8ddaf7f..556651f 100644 --- a/src/service/router.php +++ b/src/service/router.php @@ -49,6 +49,10 @@ if($request->getMethod() === 'GET'){ MaintenanceController::getLastDump(); die; } + if($request->query->has('action') && $request->query->get('action') === 'get_all_media'){ + MaintenanceController::getAllMedia(); + die; + } } // construction d'une page diff --git a/src/view/templates/maintenance.php b/src/view/templates/maintenance.php index bc9caf0..403ed97 100644 --- a/src/view/templates/maintenance.php +++ b/src/view/templates/maintenance.php @@ -43,6 +43,18 @@ +
+

+ + +
+ Toutes vos photos et vos documents dans un "zip" +

+

+
+ Gérer les fichiers multimedia, fonction actuellement indisponible +

+
-- cgit v1.2.3