mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 07:11:18 +02:00
cleanup: sélection multiple + page dédiée (/admin/cleanup.php)
- cleanup-tmp.php: accepte les arrays filepond_dirs[] et trash_files[] pour suppression en lot - cleanup-stats-fragment.php: ajout checkboxes + barre d'actions groupées + formulaire bulk HTMX - admin-cleanup-bulk.js: module JS pour toggleAll, updateBulk, bulkDelete - Nouvelle page /admin/cleanup.php remplace la modale (tmp-cleanup.php supprimé) - Bouton Nettoyer dans index.php devient un lien vers la page dédiée
This commit is contained in:
@@ -43,32 +43,42 @@ $details = [];
|
||||
$db = new Database();
|
||||
$pdo = $db->getPDO();
|
||||
|
||||
// ── Individual deletion mode ────────────────────────────────────────────
|
||||
// ── Individual / bulk deletion mode ────────────────────────────────────
|
||||
$individualFilepond = trim($_POST['filepond_dir'] ?? '');
|
||||
$individualTrash = trim($_POST['trash_file'] ?? '');
|
||||
$bulkFilepond = $_POST['filepond_dirs'] ?? [];
|
||||
$bulkTrash = $_POST['trash_files'] ?? [];
|
||||
|
||||
if ($individualFilepond !== '' || $individualTrash !== '') {
|
||||
if ($individualFilepond !== '') {
|
||||
$dirPath = $filepondDir . '/' . basename($individualFilepond);
|
||||
// Normalize: single values also become arrays for unified handling
|
||||
$filepondItems = $individualFilepond !== '' ? [$individualFilepond] : (is_array($bulkFilepond) ? $bulkFilepond : []);
|
||||
$trashItems = $individualTrash !== '' ? [$individualTrash] : (is_array($bulkTrash) ? $bulkTrash : []);
|
||||
|
||||
if (!empty($filepondItems) || !empty($trashItems)) {
|
||||
foreach ($filepondItems as $item) {
|
||||
$item = trim($item);
|
||||
if ($item === '') continue;
|
||||
$dirPath = $filepondDir . '/' . basename($item);
|
||||
if (is_dir($dirPath) && str_starts_with(realpath($dirPath), realpath($filepondDir))) {
|
||||
rmdirRecursive($dirPath);
|
||||
$filepondRemoved = 1;
|
||||
$details[] = "filepond/$individualFilepond: suppression manuelle";
|
||||
$filepondRemoved++;
|
||||
$details[] = "filepond/$item: suppression manuelle";
|
||||
} else {
|
||||
$errors[] = 'Dossier introuvable : ' . htmlspecialchars($individualFilepond);
|
||||
$errors[] = 'Dossier introuvable : ' . htmlspecialchars($item);
|
||||
}
|
||||
}
|
||||
if ($individualTrash !== '') {
|
||||
$filePath = $trashDir . '/' . basename($individualTrash);
|
||||
foreach ($trashItems as $item) {
|
||||
$item = trim($item);
|
||||
if ($item === '') continue;
|
||||
$filePath = $trashDir . '/' . basename($item);
|
||||
if (is_file($filePath) && str_starts_with(realpath($filePath), realpath($trashDir))) {
|
||||
if (@unlink($filePath)) {
|
||||
$trashRemoved = 1;
|
||||
$details[] = "_trash/$individualTrash: suppression manuelle";
|
||||
$trashRemoved++;
|
||||
$details[] = "_trash/$item: suppression manuelle";
|
||||
} else {
|
||||
$errors[] = 'Impossible de supprimer : ' . htmlspecialchars($individualTrash);
|
||||
$errors[] = 'Impossible de supprimer : ' . htmlspecialchars($item);
|
||||
}
|
||||
} else {
|
||||
$errors[] = 'Fichier introuvable : ' . htmlspecialchars($individualTrash);
|
||||
$errors[] = 'Fichier introuvable : ' . htmlspecialchars($item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user