📁 File Manager

'.htmlspecialchars($login_err).''; ?>
= 1024 && $i < 4) { $b /= 1024; $i++; } return round($b, 1) . ' ' . $u[$i]; } /* ---------- Handle actions ---------- */ $msg = ''; $err_msg = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') !== 'login') { $action = $_POST['action'] ?? ''; $base = realpath($_POST['dir'] ?? $FM_ROOT) ?: $FM_ROOT; try { if ($action === 'save') { $target = $base . DIRECTORY_SEPARATOR . basename($_POST['file'] ?? ''); if (file_put_contents($target, $_POST['content'] ?? '') === false) throw new Exception('Cannot write file'); $msg = 'Saved: ' . basename($target); } if ($action === 'upload') { if (($_FILES['file']['error'] ?? 1) !== UPLOAD_ERR_OK) throw new Exception('Upload failed'); $target = $base . DIRECTORY_SEPARATOR . basename($_FILES['file']['name']); if (!move_uploaded_file($_FILES['file']['tmp_name'], $target)) throw new Exception('move_uploaded_file failed'); $msg = 'Uploaded: ' . basename($target); } if ($action === 'unzip') { if (!class_exists('ZipArchive')) throw new Exception('Install php-zip (ZipArchive missing)'); if (($_FILES['zip']['error'] ?? 1) !== UPLOAD_ERR_OK) throw new Exception('Zip upload failed'); $z = new ZipArchive; if ($z->open($_FILES['zip']['tmp_name']) !== true) throw new Exception('Cannot open zip'); $z->extractTo($base); $z->close(); $msg = 'Extracted into ' . $base; } if ($action === 'mkdir') { $name = trim($_POST['name'] ?? ''); if ($name === '') throw new Exception('Empty name'); if (!@mkdir($base . DIRECTORY_SEPARATOR . basename($name), 0755)) throw new Exception('mkdir failed'); $msg = 'Folder created'; } if ($action === 'delete') { $t = $base . DIRECTORY_SEPARATOR . basename($_POST['file'] ?? ''); if (is_dir($t)) { if (!@rmdir($t)) throw new Exception('Dir not empty'); } else { if (!@unlink($t)) throw new Exception('unlink failed'); } $msg = 'Deleted: ' . basename($t); } } catch (Exception $e) { $err_msg = $e->getMessage(); } } /* ---------- Resolve current dir ---------- */ // Default to the script's own directory when no ?dir= is given. $dir = $_GET['dir'] ?? $FM_ROOT; if (!is_dir($dir)) $dir = $FM_ROOT; $dir = realpath($dir); /* ---------- Editor ---------- */ $edit_file = $_GET['edit'] ?? null; $edit_content = null; if ($edit_file) { $p = $dir . DIRECTORY_SEPARATOR . basename($edit_file); if (is_file($p)) $edit_content = file_get_contents($p); } /* ---------- Listing ---------- */ $entries = @scandir($dir) ?: []; $entries = array_values(array_filter($entries, fn($e) => $e !== '.' && $e !== '..')); usort($entries, function ($a, $b) use ($dir) { $da = is_dir("$dir/$a"); $db = is_dir("$dir/$b"); if ($da !== $db) return $da ? -1 : 1; return strcasecmp($a, $b); }); $parent = dirname($dir); ?> FM — <?= h($dir) ?>
📁 File Manager | /'; $acc = ''; foreach (preg_split('#[/\\\\]+#', trim($dir, '/\\')) as $p) { if ($p === '') continue; $acc .= DIRECTORY_SEPARATOR . $p; echo ' / ' . h($p) . ''; } ?> Logout

✏️ Editing:

NameSizeModifiedActions
⬆ .. (parent)
(empty)