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é.');
}