<?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);
|
}
|