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