15m44v: 修附件占位符替换+token验真+ghLog路径
- gh_api.php ghSyncCreate: 占位符替换串 '\U📎 附件\1\E' 改 '\u📎 附件\1' 根因: PCRE 的 \U..\E 是大小写转换开关, 夹在 emoji 后把 CJK 误转/乱码, 导致 issue body 里 [图片N] 未正确替换为附件提示; \u 对 CJK 恒等无副作用 加 create 诊断日志(has_attach/desc_head/imgs)写 /plugin/gh_sync.log - gh_api.php ghLog: 路径 dirname(__DIR__)→__DIR__ 根因: gh_api.php 在 /plugin/, __DIR__=/plugin, 旧 dirname 得到网站根 /, 日志被写到网站根而非 /plugin → 用户在 /plugin 找永远 NOT FOUND - gh_api.php ghApiRequest: 加 Cache-Control: no-store 头, 防 CF 边缘缓存验活响应 - gh_oauth.php: /user 验活加唯一 query 尾巴(x=nocache_<ts>rand), 破 CF 缓存, 验活响应不可信是'没授权却显示已授权'根因; 加 probe 日志 - img.json: 修第21行混入的非法字符(反引号+中文逗号, heredoc 事故残留), 保持纯占位符
This commit is contained in:
+11
-2
@@ -74,8 +74,17 @@ if ($code === '') {
|
||||
$trow = $st->execute()->fetchArray(SQLITE3_ASSOC);
|
||||
} catch (\Throwable $e) { $trow = null; }
|
||||
if ($trow && !empty($trow['access_token'])) {
|
||||
// 验活:GitHub /user 用该 token,200=有效 401=失效
|
||||
$v = ghApiRequest('GET', '/user', null, $trow['access_token']);
|
||||
// 验活:GitHub /user 用该 token,200=有效 401=失效。
|
||||
// ★ 15m44v 修:验活加"破缓存"query —— 给 URL 拼一个每毫秒唯一的随机尾巴
|
||||
// (如 /user?x=nocache_<ts><rand>),让 Cloudflare 无法把【同一 token 的验活响应】
|
||||
// 缓存复用。根因:gh_oauth.php 发起授权时调 /user,CF 边缘可能缓存了该 token
|
||||
// 上一次的 200 响应;token 真失效后(被 GitHub 撤销/过期),CF 仍吐缓存 200 →
|
||||
// 前端误判"已授权"(用户实测:没授权却显示已授权、提单后 GitHub 又真同步了
|
||||
// 说明 token 实际有效,但验活逻辑被 CF 缓存干扰导致显示态不可信)。
|
||||
// 随机尾巴让每个验活都是全新 GET,CF 命中不了缓存,真实 200/401 才可信。
|
||||
$v = ghApiRequest('GET', '/user?x=nocache_' . (int)microtime(true) . mt_rand(100000, 999999), null, $trow['access_token']);
|
||||
ghLog('oauth probe player=' . $probePlayer . ' token=' . substr((string)$trow['access_token'], 0, 8)
|
||||
. ' status=' . (int)$v['status'] . ' ok=' . ($v['ok'] ? 'y' : 'n'));
|
||||
if (!empty($v['ok'])) {
|
||||
header('Location: ' . $baseSite . '/player.php?gh_ok=1&gh_inherit=1&gh_user=' . urlencode((string)($trow['gh_login'] ?: '')));
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user