hxp
2025-06-09 6c3f6335c70859ded94a1ad8d218acb0ac34239c
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
include_once '/Common/CommFunc.php';
include_once '/Common/Logging.php';
include_once "/db/DBOper.php";
include_once "/ProjComm/CfgReader.php";
 
header("Content-type: text/html; charset=utf-8");
 
// https://www.eolink.com/share/inside/Yk3vUm/api/844628/detail/3309842
 
\Logging\CreateLogging("gmgame.query_role.php");
\Logging\LogInfo("_POST: " . print_r($_POST, true));
 
$user = $_POST["user"]; // {channel}_{user_id},quick渠道ID_sdk账号ID
$server_id = $_POST["server_id"]; // 游戏区服ID
$terminal = $_POST["terminal"]; // 1为安卓,2为IOS,3为互通,如果为互通,研发需要注明。
$sign = $_POST["sign"]; // 签名校验sign = md5(terminal+server_id+user+key);
 
$appid = "gmgame";
 
if (
    !\CfgReader\ReadConfig()
    || !\CfgReader\GetConfigData("gmgame", "Md5_Key2", $Md5_Key)
) {
    retFail("CfgError");
    exit;
}
 
$md5SignLocal = md5($terminal . $server_id . $user . $Md5_Key);
if ($md5SignLocal != $sign) {
    retFail("ErrorSign", "md5SignLocal:" . $md5SignLocal . " != sign:" . $sign);
    exit;
}
 
$userInfo = explode("_", $user);
if (!$userInfo || count($userInfo) < 2) {
    retFail("user_param_error");
    exit;
}
$channel = $userInfo[0];
$user_id = join("_", array_slice($userInfo, 1));
$accountID = $user_id . "@" . $channel;
 
$serverID = intval($server_id);
$find = array("Channel" => $appid, "AccountID" => $accountID, "ServerID" => $serverID);
if (!\DBOper\FindOne("ServerRoles", $find, $roleInfo, array("PlayerID" => 1, "PlayerName" => 1, "_id" => 0))) {
    retFail("fail");
    exit;
};
 
if (isset($roleInfo)) {
    \Logging\LogInfo("roleInfo: " . print_r($roleInfo, true));
    $role_id = $roleInfo["PlayerID"];
    $role_name = $roleInfo["PlayerName"];
    retOK(array(array("role_id" => $role_id, "role_name" => $role_name)));
} else {
    retFail("norole");
}
exit;
 
 
function retOK($data)
{
    ret(0, "OK", $data);
}
 
function retFail($msg, $errMsg = "")
{
    $code = -1;
    \Logging\LogError("err_code:" . $code . " err_msg:" . $msg . " errMsg:" . $errMsg);
    ret($code, $msg);
}
function ret($code, $msg, $data = array())
{
    $retData = array("err_code" => $code, "err_msg" => $msg, "data" => $data);
    echo \CommFunc\MyJson_encode($retData);
}