站点设置拆出独立「邮件通知」标签页 (#2)
用户反馈:「站点设置现在太长了,应该把邮箱设置单独拿出来,做一个标签页。」 原先一个 settings tab 里塞了:站点信息、页脚、邮件通知、附件存储、审核、 存储体检。光邮件那段就 82 行(10 多个字段 + 测试按钮),往下翻很累。 改动: - 后台导航新增「邮件通知」tab,放在「站点设置」左边 - 邮件那段界面整体搬到新 tab(SMTP 配置 + 通知规则 + 测试发送) - settings 里彻底移除,不留两处 - tab 白名单加 mail - 新 tab 有自己的页头(h1 邮件通知)和「← 回站点设置」返回入口 保存逻辑没动:新 tab 的表单仍提交 act=settings,走的还是原来那段 处理代码,所以 SMTP / notify 的写入行为完全不变。 ## 兼容 旧链接 admin.php?tab=settings 仍然有效,只是里面不再有邮件字段。 邮件配置数据没动,新 tab 打开就能看到原值。 ## 验证 邮件 tab 专项 37/37: - 6 个 tab 全部 200 - 导航有入口、文字正确 - settings 里 smtp_host/port/pass 均 0 次,无测试按钮 - mail tab 11 个字段齐全 + 总开关 + 页头 + 返回入口 - 保存后回显:服务器、端口、冷却秒数正确;口令显示「已设置」 - 两个 tab 互不干扰 回归全绿:全新安装 33/33、安装向导 60/60、老基线 25/25。
This commit is contained in:
@@ -400,7 +400,7 @@ function fb_admin_save_settings() {
|
||||
* 页面
|
||||
* ================================================================== */
|
||||
$tab = (string)(isset($_GET['tab']) ? $_GET['tab'] : 'pending');
|
||||
if (!in_array($tab, ['pending', 'all', 'thread', 'taxonomy', 'statuses', 'settings', 'log'], true)) { $tab = 'pending'; }
|
||||
if (!in_array($tab, ['pending', 'all', 'thread', 'taxonomy', 'statuses', 'settings', 'mail', 'log'], true)) { $tab = 'pending'; }
|
||||
|
||||
fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']);
|
||||
?>
|
||||
@@ -417,6 +417,7 @@ fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']);
|
||||
<a class="tab<?php echo $tab === 'all' ? ' on' : ''; ?>" href="admin.php?tab=all">全部问题</a>
|
||||
<a class="tab<?php echo $tab === 'taxonomy' ? ' on' : ''; ?>" href="admin.php?tab=taxonomy">软件与分类</a>
|
||||
<a class="tab<?php echo $tab === 'statuses' ? ' on' : ''; ?>" href="admin.php?tab=statuses">处理状态</a>
|
||||
<a class="tab<?php echo $tab === 'mail' ? ' on' : ''; ?>" href="admin.php?tab=mail">邮件通知</a>
|
||||
<a class="tab<?php echo $tab === 'settings' ? ' on' : ''; ?>" href="admin.php?tab=settings">站点设置</a>
|
||||
<a class="tab<?php echo $tab === 'log' ? ' on' : ''; ?>" href="admin.php?tab=log">操作日志</a>
|
||||
</nav>
|
||||
@@ -733,88 +734,6 @@ fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']);
|
||||
value="<?php echo e((string)fb_cfg('footer.credit_url', '') !== '' ? (string)fb_cfg('footer.credit_url') : fb_credit_url_default()); ?>">
|
||||
<i class="hint">页脚「FeedLite」二字指向的地址,默认是本项目开源仓库。只接受 http:// 或 https:// 开头的网址;填回默认值即恢复。</i></label>
|
||||
|
||||
<h2 style="margin:24px 0 10px">邮件通知</h2>
|
||||
<?php
|
||||
$smOn = (bool)fb_cfg('smtp.enabled', false);
|
||||
$smHost = (string)fb_cfg('smtp.host', '');
|
||||
$smUser = (string)fb_cfg('smtp.user', '');
|
||||
$smFrom = (string)fb_cfg('smtp.from', '');
|
||||
$smName = (string)fb_cfg('smtp.from_name', '');
|
||||
$smPort = (int)fb_cfg('smtp.port', 465);
|
||||
$smSec = (string)fb_cfg('smtp.secure', 'ssl');
|
||||
$smHasPw = (string)fb_cfg('smtp.pass', '') !== '';
|
||||
$smTmo = (int)fb_cfg('smtp.timeout', 15);
|
||||
$smVerify= (bool)fb_cfg('smtp.verify_ssl', true);
|
||||
?>
|
||||
<label class="check"><input type="checkbox" name="smtp_enabled" value="1"<?php echo $smOn ? ' checked' : ''; ?>> 开启邮件通知
|
||||
<span class="hint" style="display:block;margin:2px 0 0 24px">开启后,有人回复你反馈的问题会发信通知提交人。填好下方参数并用「发送测试邮件」验证通了再勾。</span></label>
|
||||
|
||||
<div class="grid2">
|
||||
<label class="field"><span>SMTP 服务器</span>
|
||||
<input type="text" name="smtp_host" maxlength="120" placeholder="smtp.qiye.aliyun.com"
|
||||
value="<?php echo e($smHost); ?>">
|
||||
<i class="hint">阿里云企业邮 smtp.qiye.aliyun.com;腾讯企业邮 smtp.exmail.qq.com;QQ 邮箱 smtp.qq.com。</i></label>
|
||||
<label class="field"><span>端口与加密</span>
|
||||
<div style="display:flex;gap:8px">
|
||||
<input type="number" name="smtp_port" min="1" max="65535" style="flex:0 0 110px"
|
||||
value="<?php echo (int)$smPort; ?>">
|
||||
<select name="smtp_secure" style="flex:1">
|
||||
<option value="ssl"<?php echo $smSec === 'ssl' ? ' selected' : ''; ?>>SSL(通常 465)</option>
|
||||
<option value="tls"<?php echo $smSec === 'tls' ? ' selected' : ''; ?>>STARTTLS(通常 587)</option>
|
||||
<option value=""<?php echo $smSec === '' ? ' selected' : ''; ?>>不加密(通常 25,不推荐)</option>
|
||||
</select>
|
||||
</div></label>
|
||||
</div>
|
||||
|
||||
<div class="grid2">
|
||||
<label class="field"><span>登录账号</span>
|
||||
<input type="text" name="smtp_user" maxlength="120" placeholder="noreply@example.com"
|
||||
value="<?php echo e($smUser); ?>"></label>
|
||||
<label class="field"><span>密码 / 授权码 <i class="hint" style="display:inline"><?php echo $smHasPw ? '已设置,留空不修改' : '未设置'; ?></i></span>
|
||||
<input type="password" name="smtp_pass" autocomplete="new-password"
|
||||
placeholder="<?php echo $smHasPw ? '留空保持不变' : '邮箱密码或授权码'; ?>"></label>
|
||||
</div>
|
||||
|
||||
<div class="grid2">
|
||||
<label class="field"><span>发件地址</span>
|
||||
<input type="email" name="smtp_from" maxlength="120" placeholder="留空则同登录账号"
|
||||
value="<?php echo e($smFrom); ?>"></label>
|
||||
<label class="field"><span>发件人显示名称</span>
|
||||
<input type="text" name="smtp_from_name" maxlength="60"
|
||||
placeholder="<?php echo e((string)fb_cfg('site_name', '轻反馈')); ?>"
|
||||
value="<?php echo e($smName); ?>"></label>
|
||||
</div>
|
||||
|
||||
<details style="margin:6px 0 12px">
|
||||
<summary style="cursor:pointer;font-size:13px;color:var(--muted)">高级选项</summary>
|
||||
<div class="grid2" style="margin-top:8px">
|
||||
<label class="field"><span>超时(秒)</span>
|
||||
<input type="number" name="smtp_timeout" min="5" max="60" value="<?php echo (int)$smTmo; ?>"></label>
|
||||
<label class="check" style="align-self:end"><input type="checkbox" name="smtp_verify_ssl" value="1"<?php echo $smVerify ? ' checked' : ''; ?>> 校验服务器 SSL 证书
|
||||
<span class="hint" style="display:block;margin-left:24px">服务器缺 CA 证书时可临时取消,但不建议。</span></label>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<?php if ($smHost !== ''): ?>
|
||||
<div class="mail-test">
|
||||
<span class="muted" style="font-size:13.5px">配好后先发一封测试邮件确认能通:</span>
|
||||
<input type="email" id="mailTestTo" placeholder="收件邮箱,默认发给自己"
|
||||
value="<?php echo e((string)fb_cfg('admin_email', '')); ?>">
|
||||
<button type="button" class="btn" id="mailTestBtn" data-csrf="<?php echo e(fb_csrf_token()); ?>">发送测试邮件</button>
|
||||
<span id="mailTestOut" class="mail-test-out"></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h3 style="margin:20px 0 8px;font-size:15px">通知规则</h3>
|
||||
<label class="check"><input type="checkbox" name="notify_enabled" value="1"<?php echo fb_cfg('notify.enabled', true) ? ' checked' : ''; ?>> 有人回复时通知提交人</label>
|
||||
<label class="check"><input type="checkbox" name="notify_on_every_reply" value="1"<?php echo fb_cfg('notify.on_every_reply', false) ? ' checked' : ''; ?>> 每次回复都通知(默认只在官方回复时通知,避免刷屏)</label>
|
||||
<label class="check"><input type="checkbox" name="notify_admin_new_thread" value="1"<?php echo fb_cfg('notify.admin_new_thread', false) ? ' checked' : ''; ?>> 有新反馈时通知管理员
|
||||
<span class="hint" style="display:block;margin-left:24px">发到「站点信息」里填的官方邮箱。</span></label>
|
||||
<label class="field" style="max-width:280px"><span>同一帖同一收件人的最短发信间隔(秒)</span>
|
||||
<input type="number" name="notify_cooldown_seconds" min="0" max="86400"
|
||||
value="<?php echo (int)fb_cfg('notify.cooldown_seconds', 60); ?>">
|
||||
<i class="hint">0 = 不限制。</i></label>
|
||||
|
||||
<h2 style="margin:24px 0 10px">附件存储</h2>
|
||||
<label class="field">
|
||||
<span>附件保存在哪</span>
|
||||
@@ -1005,6 +924,105 @@ fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']);
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php elseif ($tab === 'mail'): ?>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>邮件通知</h1>
|
||||
<p class="muted">配置 SMTP 后,反馈有变动会自动发信通知提交人。</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php fb_flash_box($msg, $msgType); ?>
|
||||
<form method="post" action="admin.php?tab=mail" class="card-form" data-validate>
|
||||
<input type="hidden" name="csrf" value="<?php echo e(fb_csrf_token()); ?>">
|
||||
<input type="hidden" name="act" value="settings">
|
||||
<h2 style="margin:24px 0 10px">邮件通知</h2>
|
||||
<?php
|
||||
$smOn = (bool)fb_cfg('smtp.enabled', false);
|
||||
$smHost = (string)fb_cfg('smtp.host', '');
|
||||
$smUser = (string)fb_cfg('smtp.user', '');
|
||||
$smFrom = (string)fb_cfg('smtp.from', '');
|
||||
$smName = (string)fb_cfg('smtp.from_name', '');
|
||||
$smPort = (int)fb_cfg('smtp.port', 465);
|
||||
$smSec = (string)fb_cfg('smtp.secure', 'ssl');
|
||||
$smHasPw = (string)fb_cfg('smtp.pass', '') !== '';
|
||||
$smTmo = (int)fb_cfg('smtp.timeout', 15);
|
||||
$smVerify= (bool)fb_cfg('smtp.verify_ssl', true);
|
||||
?>
|
||||
<label class="check"><input type="checkbox" name="smtp_enabled" value="1"<?php echo $smOn ? ' checked' : ''; ?>> 开启邮件通知
|
||||
<span class="hint" style="display:block;margin:2px 0 0 24px">开启后,有人回复你反馈的问题会发信通知提交人。填好下方参数并用「发送测试邮件」验证通了再勾。</span></label>
|
||||
|
||||
<div class="grid2">
|
||||
<label class="field"><span>SMTP 服务器</span>
|
||||
<input type="text" name="smtp_host" maxlength="120" placeholder="smtp.qiye.aliyun.com"
|
||||
value="<?php echo e($smHost); ?>">
|
||||
<i class="hint">阿里云企业邮 smtp.qiye.aliyun.com;腾讯企业邮 smtp.exmail.qq.com;QQ 邮箱 smtp.qq.com。</i></label>
|
||||
<label class="field"><span>端口与加密</span>
|
||||
<div style="display:flex;gap:8px">
|
||||
<input type="number" name="smtp_port" min="1" max="65535" style="flex:0 0 110px"
|
||||
value="<?php echo (int)$smPort; ?>">
|
||||
<select name="smtp_secure" style="flex:1">
|
||||
<option value="ssl"<?php echo $smSec === 'ssl' ? ' selected' : ''; ?>>SSL(通常 465)</option>
|
||||
<option value="tls"<?php echo $smSec === 'tls' ? ' selected' : ''; ?>>STARTTLS(通常 587)</option>
|
||||
<option value=""<?php echo $smSec === '' ? ' selected' : ''; ?>>不加密(通常 25,不推荐)</option>
|
||||
</select>
|
||||
</div></label>
|
||||
</div>
|
||||
|
||||
<div class="grid2">
|
||||
<label class="field"><span>登录账号</span>
|
||||
<input type="text" name="smtp_user" maxlength="120" placeholder="noreply@example.com"
|
||||
value="<?php echo e($smUser); ?>"></label>
|
||||
<label class="field"><span>密码 / 授权码 <i class="hint" style="display:inline"><?php echo $smHasPw ? '已设置,留空不修改' : '未设置'; ?></i></span>
|
||||
<input type="password" name="smtp_pass" autocomplete="new-password"
|
||||
placeholder="<?php echo $smHasPw ? '留空保持不变' : '邮箱密码或授权码'; ?>"></label>
|
||||
</div>
|
||||
|
||||
<div class="grid2">
|
||||
<label class="field"><span>发件地址</span>
|
||||
<input type="email" name="smtp_from" maxlength="120" placeholder="留空则同登录账号"
|
||||
value="<?php echo e($smFrom); ?>"></label>
|
||||
<label class="field"><span>发件人显示名称</span>
|
||||
<input type="text" name="smtp_from_name" maxlength="60"
|
||||
placeholder="<?php echo e((string)fb_cfg('site_name', '轻反馈')); ?>"
|
||||
value="<?php echo e($smName); ?>"></label>
|
||||
</div>
|
||||
|
||||
<details style="margin:6px 0 12px">
|
||||
<summary style="cursor:pointer;font-size:13px;color:var(--muted)">高级选项</summary>
|
||||
<div class="grid2" style="margin-top:8px">
|
||||
<label class="field"><span>超时(秒)</span>
|
||||
<input type="number" name="smtp_timeout" min="5" max="60" value="<?php echo (int)$smTmo; ?>"></label>
|
||||
<label class="check" style="align-self:end"><input type="checkbox" name="smtp_verify_ssl" value="1"<?php echo $smVerify ? ' checked' : ''; ?>> 校验服务器 SSL 证书
|
||||
<span class="hint" style="display:block;margin-left:24px">服务器缺 CA 证书时可临时取消,但不建议。</span></label>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<?php if ($smHost !== ''): ?>
|
||||
<div class="mail-test">
|
||||
<span class="muted" style="font-size:13.5px">配好后先发一封测试邮件确认能通:</span>
|
||||
<input type="email" id="mailTestTo" placeholder="收件邮箱,默认发给自己"
|
||||
value="<?php echo e((string)fb_cfg('admin_email', '')); ?>">
|
||||
<button type="button" class="btn" id="mailTestBtn" data-csrf="<?php echo e(fb_csrf_token()); ?>">发送测试邮件</button>
|
||||
<span id="mailTestOut" class="mail-test-out"></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h3 style="margin:20px 0 8px;font-size:15px">通知规则</h3>
|
||||
<label class="check"><input type="checkbox" name="notify_enabled" value="1"<?php echo fb_cfg('notify.enabled', true) ? ' checked' : ''; ?>> 有人回复时通知提交人</label>
|
||||
<label class="check"><input type="checkbox" name="notify_on_every_reply" value="1"<?php echo fb_cfg('notify.on_every_reply', false) ? ' checked' : ''; ?>> 每次回复都通知(默认只在官方回复时通知,避免刷屏)</label>
|
||||
<label class="check"><input type="checkbox" name="notify_admin_new_thread" value="1"<?php echo fb_cfg('notify.admin_new_thread', false) ? ' checked' : ''; ?>> 有新反馈时通知管理员
|
||||
<span class="hint" style="display:block;margin-left:24px">发到「站点信息」里填的官方邮箱。</span></label>
|
||||
<label class="field" style="max-width:280px"><span>同一帖同一收件人的最短发信间隔(秒)</span>
|
||||
<input type="number" name="notify_cooldown_seconds" min="0" max="86400"
|
||||
value="<?php echo (int)fb_cfg('notify.cooldown_seconds', 60); ?>">
|
||||
<i class="hint">0 = 不限制。</i></label>
|
||||
<div class="form-actions">
|
||||
<button class="btn primary" type="submit">保存邮件设置</button>
|
||||
<a class="btn" href="admin.php?tab=settings">← 回站点设置</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<?php else: ?>
|
||||
<?php
|
||||
$logs = $pdo->query('SELECT * FROM mod_log ORDER BY created_at DESC, id DESC LIMIT 100')->fetchAll();
|
||||
|
||||
Reference in New Issue
Block a user