From c118bb230350e9f62def2e4cc928827c8802819f Mon Sep 17 00:00:00 2001 From: ypsdf1 Date: Thu, 19 Nov 2026 23:23:48 +0800 Subject: [PATCH] =?UTF-8?q?125=E7=BB=AD15l-5:=20=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E7=AD=BE=E7=BD=B2=E6=83=85=E5=86=B5=E6=9D=BF?= =?UTF-8?q?=E5=9D=97=20+=20=E7=8E=A9=E5=AE=B6=E7=AB=AF=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E5=8E=9F=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - admin.php: 侧边栏加'📜 用户协议'(data-p=rules), go('rules')→loadRules 后台视角=玩家签署情况: 已签总数/当前版本已签/旧版本待重签 + 签署记录倒序表 (玩家名/签署时间/版本状态徽章), 调 api/sync.php?action=rules_content rules目录无.md 时后台提示未配置 - player.php: 侧边栏加'📜 用户协议', switchPage('rules')→renderRules 玩家端视角=查看协议原文: 轻量markdown渲染(标题/列表/加粗/引用/代码/链接), 无外部依赖 展示版本指纹+行数; rules目录无.md 时提示未配置 --- admin.php | 74 ++++++++++++++++++++++++++++++++++++++++++ player.php | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+) diff --git a/admin.php b/admin.php index 4ddd342..1ebb00a 100644 --- a/admin.php +++ b/admin.php @@ -209,6 +209,7 @@ if (is_file($ossTxt)) {
🧾 收银员管理
💳 充值对账
🛒 充值商店配置
+
📜 用户协议
🛡️ 安全配置(2FA / IP白名单 / 入口令牌)
@@ -288,6 +289,7 @@ function go(p) { else if (p==='cashier_manage') loadCashierManage(c); else if (p==='recharge_orders') loadRechargeOrders(c); else if (p==='shop_config') loadShopConfig(c); + else if (p==='rules') loadRules(c); } // 检查登录状态 @@ -4480,6 +4482,78 @@ async function loadShopConfig(el) { loadShopConfigData(); } +async function loadRules(el) { + el.innerHTML = '
加载中...
'; + try { + const res = await fetch('api/sync.php?action=rules_content', { + credentials: 'same-origin', + headers: { 'Content-Type': 'application/json' } + }); + const data = await res.json(); + if (!data.success || !data.data) { + el.innerHTML = '
❌ 加载失败:' + esc(data.message || '未知错误') + '
'; + return; + } + const d = data.data; + // 服务器未配置用户协议 + if (d.skipped || !d.has_agreement) { + el.innerHTML = `
+

📜 用户协议 · 玩家签署情况

+

服务器未配置用户协议(Web 目录 rules/ 下没有 .md 文件)。

+

此时登录页不显示勾选门控,也不要求玩家签章。

+
`; + return; + } + + const list = d.signed_list || []; + const totalSigned = d.total_signed || 0; + const curVersion = list.filter(r => r.current_version).length; + + let html = `
`; + html += `

📜 用户协议 · 玩家签署情况

`; + html += `
`; + html += ``; + html += `
`; + + html += '
'; + html += `
${totalSigned}
已签署玩家
`; + html += `
${curVersion}
当前版本已签
`; + html += `
${totalSigned - curVersion}
旧版本待重签
`; + html += `
`; + + // 协议元信息 + html += '

当前协议

'; + html += `

协议标题:${esc(d.title || '(无)')}
`; + html += `版本指纹:${esc(d.fingerprint || '')} | 共 ${d.line_count || 0} 行

`; + html += `

玩家端可通过登录页「查看协议原文」或 /rules 阅读正文;后台此处仅监控签署进度。

`; + html += '
'; + + // 签署清单表 + html += '

签署记录(按签署时间倒序,最多显示 200 条)

'; + if (list.length === 0) { + html += '

暂无玩家签署记录。玩家登录 Web 端并勾选「已阅用户协议」后,此处将生成签章回执并在此登记。

'; + } else { + html += ''; + html += ''; + for (const r of list) { + const when = r.signed_at > 0 ? new Date(r.signed_at * 1000).toLocaleString('zh-CN') : '未知'; + const verBadge = r.current_version + ? '✔ 当前版本' + : '⚠ 旧版本(协议已更新,需重签)'; + html += `` + + `` + + ``; + } + html += '
玩家签署时间版本状态
${esc(r.player)}${when}${verBadge}
'; + } + html += '
'; + + el.innerHTML = html; + } catch (e) { + el.innerHTML = '
加载失败:' + esc(e.message) + '
'; + } +} + async function loadShopConfigData() { const el = document.getElementById('shopConfigList'); if (!el) return; diff --git a/player.php b/player.php index 8372074..3758f0a 100644 --- a/player.php +++ b/player.php @@ -381,6 +381,7 @@ if ($currentVersion !== $BUILD_VERSION) { +
@@ -1273,6 +1274,99 @@ if ($currentVersion !== $BUILD_VERSION) { else if (page === 'credit') renderCredit(c); else if (page === 'recharge') renderRecharge(c); else if (page === 'orders') renderMyOrders(c); + else if (page === 'rules') renderRules(c); + } + + // ==================== 用户协议(玩家端查看协议原文) ==================== + // 数据源:api/sync.php?action=rules_content(读 Web 目录 rules/*.md) + // rules 目录无 .md → 提示"服务器未配置用户协议" + async function renderRules(el) { + el.innerHTML = `
正在加载用户协议...
`; + let d = null; + try { + const res = await fetch('api/sync.php?action=rules_content', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + credentials: 'same-origin' + }); + const json = await res.json(); + if (json.success && json.data) d = json.data; + } catch (e) { + el.innerHTML = `
协议加载失败:${e.message}
`; + return; + } + if (!d || d.skipped || !d.has_agreement) { + el.innerHTML = `
+

📜 用户协议

+

服务器当前未配置用户协议(rules 目录无协议文件)。

+
`; + return; + } + // 渲染:用 原文 + 简单 markdown 转 html(标题/列表/加粗),不引入外部依赖 + el.innerHTML = `
+
+

📜 ${esc(d.title || '服务器用户协议')}

+ +
+
+ ${renderMarkdownLite(d.content)} +
+

协议版本指纹:${esc(d.fingerprint || '')} | 共 ${d.line_count || 0} 行

+
`; + } + + // 轻量 markdown → HTML(仅处理标题/无序列表/加粗/表格分隔线/引用/代码/链接,足够展示协议) + function renderMarkdownLite(md) { + if (!md) return ''; + const lines = String(md).split('\n'); + let html = ''; + let inList = false; + const closeList = () => { if (inList) { html += ''; inList = false; } }; + for (let raw of lines) { + let s = raw; + // 表格分隔线丢弃 + if (s.trim().match(/^\|?[\s:|-]+\|?$/) && s.trim().length > 1 && s.includes('-')) { closeList(); continue; } + // 代码围栏 ``` 整行丢弃(json 动作配置已在后端剥离,双保险) + if (s.trim().startsWith('```')) { closeList(); continue; } + // 标题 + if (s.match(/^#{1,6}\s/)) { + closeList(); + const lvl = s.match(/^#+/)[0].length; + const txt = s.replace(/^#+\s*/, ''); + const sz = Math.max(15, 22 - lvl); + html += `
${esc(txt)}
`; + continue; + } + // 无序列表 + if (s.match(/^\s*[-*+]\s+/)) { + if (!inList) { html += '
    '; inList = true; } + const item = s.replace(/^\s*[-*+]\s+/, ''); + html += `
  • ${inlineMd(item)}
  • `; + continue; + } + closeList(); + // 引用 + if (s.match(/^\s*>/)) { + html += `
    ${inlineMd(s.replace(/^\s*>\s?/, ''))}
    `; + continue; + } + // 空行 + if (s.trim() === '') { html += '
    '; continue; } + // 普通段落 + html += `
    ${inlineMd(s)}
    `; + } + closeList(); + return html; + } + + // 行内 markdown:加粗/斜体/代码/链接 + function inlineMd(s) { + let t = esc(s); + t = t.replace(/`([^`]*)`/g, '$1'); + t = t.replace(/(\*\*|__)(.+?)\1/g, '$2'); + t = t.replace(/(^|[^*])(\*)([^*]+)\*(?!\*)/g, '$1$3'); + t = t.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1'); + return t; } // ==================== 债券在线充值(动态加载商品) ====================