cleanup modal: list stale files to remove; storage restructure: documents/ → {objet}/

This commit is contained in:
Pontoporeia
2026-05-19 22:00:10 +02:00
parent c6199525f9
commit defc919cd0
19 changed files with 292 additions and 22 deletions

View File

@@ -34,6 +34,7 @@ $now = time();
// ── FilePond stats ───────────────────────────────────────────────────────
$fpStaleCount = 0;
$fpStaleSize = 0;
$fpStaleFiles = [];
$fpActiveCount = 0;
$fpActiveSize = 0;
@@ -75,6 +76,12 @@ if (is_dir($filepondDir)) {
if ($stale) {
$fpStaleCount++;
$fpStaleSize += $size;
$fpStaleFiles[] = [
'name' => $item,
'size' => $size,
'human' => humanBytes($size),
'age_minutes' => $ageMinutes,
];
} else {
$fpActiveCount++;
$fpActiveSize += $size;
@@ -96,6 +103,7 @@ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$trStaleCount = 0;
$trStaleSize = 0;
$trStaleFiles = [];
$trActiveCount = 0;
$trActiveSize = 0;
@@ -131,6 +139,12 @@ if (is_dir($trashDir)) {
if ($stale) {
$trStaleCount++;
$trStaleSize += $size;
$trStaleFiles[] = [
'name' => $item,
'size' => $size,
'human' => humanBytes($size),
'age_days' => $ageDays,
];
} else {
$trActiveCount++;
$trActiveSize += $size;
@@ -144,12 +158,14 @@ echo json_encode([
'filepond_stale_count' => $fpStaleCount,
'filepond_stale_size' => $fpStaleSize,
'filepond_stale_human' => humanBytes($fpStaleSize),
'filepond_stale_files' => $fpStaleFiles,
'filepond_active_count' => $fpActiveCount,
'filepond_active_size' => $fpActiveSize,
'filepond_active_human' => humanBytes($fpActiveSize),
'trash_stale_count' => $trStaleCount,
'trash_stale_size' => $trStaleSize,
'trash_stale_human' => humanBytes($trStaleSize),
'trash_stale_files' => $trStaleFiles,
'trash_active_count' => $trActiveCount,
'trash_active_size' => $trActiveSize,
'trash_active_human' => humanBytes($trActiveSize),

View File

@@ -51,8 +51,8 @@ if (!$thesisId || $filePath === '') {
relinkError(400, 'Paramètres invalides (thesis_id + file_path requis).');
}
// Security: only allow paths under documents/ or theses/
if (!preg_match('#^(documents|theses)/#', $filePath)) {
// Security: only allow paths under tfe/ these/ frart/ documents/ or theses/
if (!preg_match('#^(tfe|these|frart|documents|theses)/#', $filePath)) {
relinkError(403, 'Chemin de fichier non autorisé.');
}

View File

@@ -1,6 +1,6 @@
<?php
/**
* File browser fragment — returns a clickable directory tree of documents/ + theses/.
* File browser fragment — returns a clickable directory tree of tfe/ these/ frart/ documents/ + theses/.
*
* GET /admin/fragments/file-browser.php?dir=documents/2025
*
@@ -17,7 +17,7 @@ error_log('[file-browser] ENTRY | dir=' . ($_GET['dir'] ?? '(root)') . ' | stora
// Determine which directory to browse
$relDir = trim($_GET['dir'] ?? '', '/');
if ($relDir !== '' && !preg_match('#^(documents|theses)(/|$)#', $relDir)) {
if ($relDir !== '' && !preg_match('#^(tfe|these|frart|documents|theses)(/|$)#', $relDir)) {
$relDir = '';
}
@@ -84,7 +84,7 @@ if ($relDir !== '') {
$parentDir = implode('/', $parentParts);
}
$rootDirs = ['documents', 'theses'];
$rootDirs = ['tfe', 'these', 'frart', 'documents', 'theses'];
// SVG icon for a given extension
function fileIcon(string $ext): string {