Files
freeshop/points_debug.php
T
2026-08-14 10:55:06 +08:00

44 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// 诊断脚本:打印当前商城实际连接的数据库 + 指定用户真实积分
// 用完请删除本文件。
if (!defined('IN_APP')) { define('IN_APP', true); }
require __DIR__ . '/includes/config.php';
require __DIR__ . '/includes/db.php';
require __DIR__ . '/includes/functions.php';
header('Content-Type: text/plain; charset=utf-8');
echo "=== 当前商城实际连接的数据库 ===\n";
echo "DB_HOST = " . DB_HOST . "\n";
echo "DB_NAME = " . DB_NAME . "\n";
echo "DB_PREFIX= " . DB_PREFIX . "\n\n";
$target = $_GET['u'] ?? 'freenw';
echo "=== 查询用户「{$target}」的真实积分(来自数据库)===\n";
$stmt = db()->prepare('SELECT id, username, is_admin, points FROM ' . tn('users') . ' WHERE username = ?');
$stmt->execute([$target]);
$rows = $stmt->fetchAll();
if (empty($rows)) {
echo "未找到用户「{$target}\n";
} else {
foreach ($rows as $r) {
echo "id=" . (int)$r['id']
. " username=" . $r['username']
. " is_admin=" . (int)$r['is_admin']
. " points=" . (int)$r['points'] . "\n";
}
// 用和前台完全相同的方式再取一次,验证 getCurrentUser 路径
$u = currentUser();
echo "\n=== 当前登录会话(currentUser===\n";
if ($u) {
echo "id=" . (int)$u['id'] . " username=" . $u['username'] . " points(对象)=" . (int)$u['points']
. " points(getUserPoints)=" . getUserPoints($u['id']) . "\n";
} else {
echo "(未登录)\n";
}
}
echo "\n提示:如果这里显示的 points 就是 900,说明数据库没错,问题在页面缓存/没上传最新代码;\n";
echo "如果这里也是 130,说明后台加的那笔积分写到了别的数据库——检查云服务器上商城自己的 config.php 的 DB_HOST。\n";