hxp
2025-06-04 f4a514d5ac952110da846636ecbb9de951eaf3d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
include_once "../../../Common/CommFunc.php";
include_once "../../../Common/Logging.php";
include_once '../../../Common/MongoDB7.php';
 
\Logging\CreateLogging("socialUserInfo.php");
 
$openid = $_GET['openid'];
$gamename = $_GET['gamename'];
if (!$openid) {
    \Logging\LogInfo('没有openid,不处理!');
    return;
}
 
// 可更新的字段列表,只允许更新列表中字段
$fieldList = ["avatarUrl", "nickName", "gender", "country", "province", "city"];
 
$update = [];
foreach ($fieldList as $field) {
    if (array_key_exists($field, $_GET)) {
        $update[$field] = $_GET[$field];
    }
}
 
if ($update) {
    \Logging\LogInfo('更新玩家社交信息 openid=' . $openid . '  update=' . print_r($update, true));
    $gameconfig = parse_ini_file("config/" . $gamename . ".ini", true);
    $dbOpt = new \MongoDB7\MongoDb("Player", $gameconfig["db"]);
    $where = ['openid' => $openid];
    $modCount = $dbOpt->update($where, $update);
    \Logging\LogInfo('更新条数: ' . $modCount);
} else {
    \Logging\LogInfo('没有需要更新的社交信息');
}