$p, 'dir' => $accum]; } } // Gather entries $entries = []; if (is_dir($realCurrent)) { $dh = opendir($realCurrent); if ($dh) { while (($name = readdir($dh)) !== false) { if ($name === '.' || $name === '..') continue; $full = $realCurrent . '/' . $name; $isDir = is_dir($full); $entries[] = [ 'name' => $name, 'is_dir' => $isDir, 'size' => $isDir ? null : filesize($full), 'ext' => $isDir ? null : strtolower(pathinfo($name, PATHINFO_EXTENSION)), ]; } closedir($dh); } } // Sort: dirs first, then files, alphabetical usort($entries, function ($a, $b) { if ($a['is_dir'] !== $b['is_dir']) return $a['is_dir'] ? -1 : 1; return strnatcasecmp($a['name'], $b['name']); }); // Human-readable filesize function fmtSize(?int $bytes): string { if ($bytes === null) return ''; if ($bytes >= 1_000_000_000) return round($bytes / 1_000_000_000, 1) . ' GB'; if ($bytes >= 1_000_000) return round($bytes / 1_000_000, 1) . ' MB'; if ($bytes >= 1_000) return round($bytes / 1_000, 1) . ' KB'; return $bytes . ' B'; } // Determine parent dir $parentDir = ''; if ($relDir !== '') { $parentParts = explode('/', $relDir); array_pop($parentParts); $parentDir = implode('/', $parentParts); } $rootDirs = ['tfe', 'these', 'frart', 'documents', 'theses']; // SVG icon for a given extension function fileIcon(string $ext): string { $ext = strtolower($ext); if ($ext === 'pdf') { return icon('file-text-audio'); } if (in_array($ext, ['zip', 'tar', 'gz', 'bz2', 'xz', '7z', 'rar'], true)) { return icon('file-doc'); } // Default text-file icon for all other extensions return icon('file-lines'); } // SVG folder icon (same for all directories) function folderIcon(): string { return icon('folder'); } ?>
Sélectionnez un dossier pour parcourir les fichiers orphelins.
Ce dossier est vide.