Overworked files API and explorer

This commit is contained in:
2025-06-19 23:14:18 +02:00
parent c42d5a2652
commit de1664469c
15 changed files with 529 additions and 407 deletions

30
api/list.php Normal file
View File

@ -0,0 +1,30 @@
<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../vfs.php';
$dir = $_GET['dir'] ?? '';
$showHidden = ($_GET['hidden'] ?? '0') === '1';
$realDir = resolve_path($dir);
if (!is_dir($realDir)) {
echo json_encode([]);
exit;
}
$out = [];
foreach (scandir($realDir) as $name) {
if ($name === '.' || $name === '..') continue;
if (!$showHidden && $name[0] === '.') continue;
$full = $realDir . '/' . $name;
$out[] = [
'name' => $name,
'virtual' => virtualize_path($full),
'isDir' => is_dir($full),
'ext' => pathinfo($name, PATHINFO_EXTENSION),
'size' => is_file($full) ? filesize($full) : null,
'mtime' => filemtime($full),
];
}
echo json_encode($out);