Files
2026-07-23 08:58:13 +08:00

13 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
require dirname(__DIR__) . '/includes/bootstrap.php';
$user = require_user();
if (setting('game_enabled', '1') !== '1') {
http_response_code(503);
echo '<!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>游戏维护</title><body style="margin:0;background:#07192b;color:#fff;font-family:sans-serif;display:grid;place-items:center;min-height:100vh"><main style="text-align:center"><h1>游戏维护中</h1><p style="color:#9eb1c0">请稍后再试</p><a style="color:#ffd55a" href="/index.php">返回会员中心</a></main></body></html>';
exit;
}
$html = (string) file_get_contents(__DIR__ . '/index.html');
$sessionBridge = '<script>localStorage.setItem("sg_accountId",' . json_encode($user['username'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) . ');localStorage.setItem("sg_pwd","__server_session__");</script>';
echo str_replace('<script src="local-api.js"', $sessionBridge . "\n<script src=\"local-api.js\"", $html);