完成批次 L-R:限流移除/白名单驱动/打印增强/全屏/表格对齐/主题变量/滚动闪烁修复
- 移除登录失败限流;fix-config.php 修正 e2e 串味的 127.0.0.1 连接 - 白名单驱动缺/待考名单(DataService + SurveyKingClient::getWhitelist,复用已取 survey) - 打印成绩明细增强(范围/合格列默认关/去页脚);看板全屏占满;表格 vertical-align:middle;隐藏登陆账号;导入默认追加 - 主题变量收口(:root 新增 brand/primary-2/ok-2 等,替换硬编码渐变);删死规则 - 表头/数据列对齐修复(index 未匹配表、dashboard 成员榜、draw 结果/历史/排除表);看板占位卡片配色一致 - 修复滚动闪烁:row-drop-in 动画经 _dropAnim 门控,仅强制重绘时播放 - 测试:新增 test-whitelist.js;run-all.sh 全绿 132
This commit is contained in:
+20
-1
@@ -126,6 +126,19 @@ function ny_csrf_token(): string
|
||||
return $_SESSION['ny_csrf'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 取请求原始 body(仅读一次并缓存)。
|
||||
* 写接口既要校验 CSRF(从 body 取 _csrf)又要解析业务 JSON,二者都需读 php://input;
|
||||
* 大多数 SAPI 下 php://input 可重复读,但个别环境只能读一次,因此这里统一缓存避免第二次读为空。
|
||||
*/
|
||||
function ny_request_body(): string
|
||||
{
|
||||
if (!isset($GLOBALS['__ny_body'])) {
|
||||
$GLOBALS['__ny_body'] = (string)@file_get_contents('php://input');
|
||||
}
|
||||
return $GLOBALS['__ny_body'];
|
||||
}
|
||||
|
||||
/** 校验 CSRF token(写操作调用)。失败返回 false 并应拒绝请求。 */
|
||||
function ny_csrf_ok(): bool
|
||||
{
|
||||
@@ -136,7 +149,7 @@ function ny_csrf_ok(): bool
|
||||
$given = (string)$_POST['_csrf'];
|
||||
} else {
|
||||
// JSON body 里的 _csrf(api.php 写接口多走 JSON)
|
||||
$raw = (string)file_get_contents('php://input');
|
||||
$raw = ny_request_body();
|
||||
if ($raw !== '') {
|
||||
$j = json_decode($raw, true);
|
||||
if (is_array($j) && isset($j['_csrf'])) {
|
||||
@@ -286,6 +299,12 @@ function ny_save_config(array $cfg): bool
|
||||
}
|
||||
}
|
||||
$fileOk = ny_write_json(ny_config_file(), $cfg);
|
||||
// 尽量收紧配置文件权限(仅属主可读写),降低明文密码被其它本地用户读取的风险。
|
||||
// Windows 下 chmod 基本无效(真正的防护是 data/ 目录禁止 Web 访问,见 .htaccess / 部署文档);
|
||||
// 明文密码仍需保留以便卷王 token 失效时平台自动重新登录,无法改为只存哈希。
|
||||
if ($fileOk && is_file(ny_config_file())) {
|
||||
@chmod(ny_config_file(), 0600);
|
||||
}
|
||||
if (!$ok) {
|
||||
$GLOBALS['__ny_cfg_source'] = 'file';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user