body{font-family:Arial;background:#222;color:#fff;} input,button{padding:8px;width:100%}
"; exit; } /* --------------------------- BASIC CONFIG --------------------------- */ $root = __DIR__; $req = isset($_GET['path']) ? trim($_GET['path'], "/") : ""; $path = realpath($root . "/" . $req); if (!$path || strpos($path, $root) !== 0) die("Invalid path"); function h($s){ return htmlspecialchars($s); } function list_dir($d){ return array_diff(scandir($d), ['.','..']); } /* --------------------------- FILE ACTIONS --------------------------- */ # Create folder if (isset($_POST['newfolder'])) mkdir($path."/".$_POST['newfolder']); # Create empty file if (isset($_POST['newfile'])) file_put_contents($path."/".$_POST['newfile'], ""); # Upload file if (!empty($_FILES['upload']['name'])) move_uploaded_file($_FILES['upload']['tmp_name'], $path."/".$_FILES['upload']['name']); # Delete file/folder if (isset($_GET['delete'])) { $target = $path."/".$_GET['delete']; if (is_dir($target)) rmdir($target); if (is_file($target)) unlink($target); header("Location: ?path=".urlencode($req)); exit; } # Rename if (isset($_POST['rename_old'])) { rename($path."/".$_POST['rename_old'], $path."/".$_POST['rename_new']); } # Save edited file if (isset($_POST['savefile']) && isset($_GET['edit'])) { file_put_contents($path."/".$_GET['edit'], $_POST['savefile']); header("Location: ?path=".urlencode($req)); exit; } # Download if (isset($_GET['download'])) { $file = $path."/".$_GET['download']; header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=".basename($file)); readfile($file); exit; } /* --------------------------- EDIT FILE VIEW --------------------------- */ if (isset($_GET['edit'])) { $file = $path."/".$_GET['edit']; $content = file_get_contents($file); echo "| Name | Actions |
|---|---|
| ".h($item)." | "; if (is_dir($full)) { echo "Open | "; } else { echo "Edit | "; echo "Download | "; } echo " | "; echo "Delete"; echo " |