第58批续29:PHP积分HTML污染修复+closeModal缺失修复
- adminDeduct/adminAddBonds 用 exit(json_encode()) 改为 jsonResponse() jsonResponse 内部清空所有缓冲区再输出,避免PHP警告污染JSON - admin.php 添加 closeModal 函数(原本缺少,showModal 路径会调用)
This commit is contained in:
@@ -2117,6 +2117,11 @@ function showModal(title, message, defaultValue, customHtml) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第58批续29-问题3:添加 closeModal 函数(admin.php 原本缺少)
|
||||||
|
function closeModal() {
|
||||||
|
document.querySelectorAll('[data-modal-overlay]').forEach(el => el.remove());
|
||||||
|
}
|
||||||
|
|
||||||
// ===== 自定义背景系统(第46批):纯色 / 图片URL / API壁纸(必应) 三模式 =====
|
// ===== 自定义背景系统(第46批):纯色 / 图片URL / API壁纸(必应) 三模式 =====
|
||||||
let _wpPendingUrl = null; // 待应用的图片URL(预览/获取后暂存,点应用才生效)
|
let _wpPendingUrl = null; // 待应用的图片URL(预览/获取后暂存,点应用才生效)
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -153,8 +153,8 @@ function adminDeduct() {
|
|||||||
$player = getParam('player');
|
$player = getParam('player');
|
||||||
$amount = (int)getParam('amount', 0);
|
$amount = (int)getParam('amount', 0);
|
||||||
$reason = getParam('reason', '管理员扣减');
|
$reason = getParam('reason', '管理员扣减');
|
||||||
if (!$player) exit(json_encode(['success' => false, 'message' => 'Missing player'], JSON_UNESCAPED_UNICODE));
|
if (!$player) jsonResponse(['success' => false, 'message' => 'Missing player']);
|
||||||
if ($amount <= 0) exit(json_encode(['success' => false, 'message' => 'Invalid amount'], JSON_UNESCAPED_UNICODE));
|
if ($amount <= 0) jsonResponse(['success' => false, 'message' => 'Invalid amount']);
|
||||||
$db = getDB();
|
$db = getDB();
|
||||||
$db->exec("CREATE TABLE IF NOT EXISTS bond_cache (player_name TEXT PRIMARY KEY, amount INTEGER DEFAULT 0, updated_at INTEGER DEFAULT 0)");
|
$db->exec("CREATE TABLE IF NOT EXISTS bond_cache (player_name TEXT PRIMARY KEY, amount INTEGER DEFAULT 0, updated_at INTEGER DEFAULT 0)");
|
||||||
try {
|
try {
|
||||||
@@ -162,7 +162,7 @@ function adminDeduct() {
|
|||||||
$stmt->bindValue(':name', $player, SQLITE3_TEXT);
|
$stmt->bindValue(':name', $player, SQLITE3_TEXT);
|
||||||
$row = $stmt->execute()->fetchArray(SQLITE3_ASSOC);
|
$row = $stmt->execute()->fetchArray(SQLITE3_ASSOC);
|
||||||
$current = $row ? $row['amount'] : 0;
|
$current = $row ? $row['amount'] : 0;
|
||||||
if ($current < $amount) exit(json_encode(['success' => false, 'message' => "Insufficient: $current"], JSON_UNESCAPED_UNICODE));
|
if ($current < $amount) jsonResponse(['success' => false, 'message' => "Insufficient: $current"]);
|
||||||
$newAmount = $current - $amount;
|
$newAmount = $current - $amount;
|
||||||
$stmt = $db->prepare("UPDATE bond_cache SET amount = :amount, updated_at = :time WHERE player_name = :name");
|
$stmt = $db->prepare("UPDATE bond_cache SET amount = :amount, updated_at = :time WHERE player_name = :name");
|
||||||
$stmt->bindValue(':amount', $newAmount, SQLITE3_INTEGER);
|
$stmt->bindValue(':amount', $newAmount, SQLITE3_INTEGER);
|
||||||
@@ -185,10 +185,10 @@ function adminDeduct() {
|
|||||||
// ★ 通知Java插件立即拉取
|
// ★ 通知Java插件立即拉取
|
||||||
notifyJavaPluginImmediatePull();
|
notifyJavaPluginImmediatePull();
|
||||||
|
|
||||||
exit(json_encode(['success' => true, 'message' => 'OK', 'remaining' => $newAmount], JSON_UNESCAPED_UNICODE));
|
jsonResponse(['success' => true, 'message' => 'OK', 'remaining' => $newAmount]);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@error_log('[Function] Error: ' . $e->getMessage());
|
@error_log('[Function] Error: ' . $e->getMessage());
|
||||||
exit(json_encode(['success' => false, 'message' => 'Internal error'], JSON_UNESCAPED_UNICODE));
|
jsonResponse(['success' => false, 'message' => 'Internal error'], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,8 +197,8 @@ function adminAddBonds() {
|
|||||||
$player = getParam('player');
|
$player = getParam('player');
|
||||||
$amount = (int)getParam('amount', 0);
|
$amount = (int)getParam('amount', 0);
|
||||||
$reason = getParam('reason', '管理员充值');
|
$reason = getParam('reason', '管理员充值');
|
||||||
if (!$player) exit(json_encode(['success' => false, 'message' => 'Missing player'], JSON_UNESCAPED_UNICODE));
|
if (!$player) jsonResponse(['success' => false, 'message' => 'Missing player']);
|
||||||
if ($amount <= 0) exit(json_encode(['success' => false, 'message' => 'Invalid amount'], JSON_UNESCAPED_UNICODE));
|
if ($amount <= 0) jsonResponse(['success' => false, 'message' => 'Invalid amount']);
|
||||||
$db = getDB();
|
$db = getDB();
|
||||||
$db->exec("CREATE TABLE IF NOT EXISTS bond_cache (player_name TEXT PRIMARY KEY, amount INTEGER DEFAULT 0, updated_at INTEGER DEFAULT 0)");
|
$db->exec("CREATE TABLE IF NOT EXISTS bond_cache (player_name TEXT PRIMARY KEY, amount INTEGER DEFAULT 0, updated_at INTEGER DEFAULT 0)");
|
||||||
try {
|
try {
|
||||||
@@ -228,10 +228,10 @@ function adminAddBonds() {
|
|||||||
// ★ 通知Java插件立即拉取
|
// ★ 通知Java插件立即拉取
|
||||||
notifyJavaPluginImmediatePull();
|
notifyJavaPluginImmediatePull();
|
||||||
|
|
||||||
exit(json_encode(['success' => true, 'message' => 'OK', 'new_amount' => $newAmount], JSON_UNESCAPED_UNICODE));
|
jsonResponse(['success' => true, 'message' => 'OK', 'new_amount' => $newAmount]);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@error_log('[Function] Error: ' . $e->getMessage());
|
@error_log('[Function] Error: ' . $e->getMessage());
|
||||||
exit(json_encode(['success' => false, 'message' => 'Internal error'], JSON_UNESCAPED_UNICODE));
|
jsonResponse(['success' => false, 'message' => 'Internal error'], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user