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
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
include_once '/Common/CommFunc.php';
include_once '/Common/Logging.php';
include_once "/db/DBOper.php";
 
header("Content-type: text/html; charset=utf-8");
 
// https://developer.shg.vn/article/view?id=150&lang=ch
 
\Logging\CreateLogging("sohagame.roles.php");
 
$successCode = "0";
$codeMessage = array(
    "0" => "successful",
    "1" => "checkdata error",
);
 
function resfail($status = "1", $errlog = "")
{
    global $codeMessage;
    $message = "unknown error";
    if (array_key_exists($status, $codeMessage)) {
        $message = $codeMessage[$status];
    }
    if (!$errlog) {
        $errlog = $message;
    }
 
    \Logging\LogInfo("_GET:" . print_r($_GET, true));
    \Logging\LogError($errlog);
 
    $errorRet = array("status" => $status, "mess" => $message);
    echo json_encode($errorRet);
}
 
$user_id = $_GET["user_id"];
$checkdata = $_GET["checkdata"];
 
if (!$user_id || !$checkdata) {
    resfail();
    return;
}
$checkdata = strtolower($checkdata);
 
// bt6123 99dc6a3d8a0094c924d41fe3f991e667
// 123 19714fa3018459672428bf3a7c437472
$spid = "sohagame";
if ($_GET["spid"]) {
    // 可选参数,也可用于测试用
    $spid = $_GET["spid"];
}
 
\CommFunc\GetKeyFromConfig(dirname(__FILE__) . '\\..\\..\\InterfaceConfig.php', "SP." . $spid, "app_secret", $app_secret);
$sign = md5($user_id . $app_secret);
if ($checkdata != $sign) {
    resfail("1", "checkdata error! checkdata(" . $checkdata . ") != sign(" . $sign . ")");
    return;
}
 
$playerServers = array();
$find = array("Channel" => $spid, "AccountID" => $user_id);
if (\DBOper\FindOne("GameRoles", $find, $findData) && isset($findData)) {
    foreach ($findData as $field => $value) {
        $serverID = \CommFunc\GetServerIDBySid($field);
        if ($serverID <= 0) {
            continue;
        }
        if (!array_key_exists("PlayerName", $value)) {
            continue;
        }
        $playerServers[] = array(
            "area_id" => "" . $serverID,
            "role_id" => "" . $value["PlayerID"],
            "role_name" => "" . $value["PlayerName"],
            "role_level" => "" . $value["LV"],
        );
    }
} else {
    resfail("2");
    return;
}
 
// \Logging\LogInfo("_GET:" . print_r($_GET, true));
// \Logging\LogInfo("retList: " . print_r($retList, true));
$retData = array(
    "status" => $successCode,
    "mess" => $codeMessage[$successCode],
    "info" => $playerServers,
);
echo \CommFunc\MyJson_encode($retData);