Account/User.php | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
InterfaceConfig.php | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
index.php | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
serverops/hy/report_server.php | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
serverops/serverreportsp.php | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
task/minuteLoop.php | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Account/User.php
@@ -165,6 +165,7 @@ Permission::P_OPSGameVersion => array("Name" => \Lang\gettext("内容版本管理")), Permission::P_OPSServerList => array("Name" => \Lang\gettext("服务器列表")), Permission::P_OPSServerStateMgr => array("Name" => \Lang\gettext("服务器状态管理"), "Log" => array("1")), Permission::P_OPSServerReportSP => array("Name" => \Lang\gettext("服务器推送SP")), Permission::P_OPSRefreshServer => array("Name" => \Lang\gettext("刷新选服列表"), "Log" => array("1")), Permission::P_SetOpenServerTime => array("Name" => \Lang\gettext("设置开服时间"), "GMTKey2" => array("GMT_SetOpenServerTime")), Permission::P_CrossServerMaintain => array("Name" => \Lang\gettext("跨服主服维护"), "GMTKey2" => array("GMT_CrossServerMaintain")), @@ -307,6 +308,7 @@ const P_OPSGameVersion = "P_OPSGameVersion"; const P_OPSServerList = "P_OPSServerList"; const P_OPSServerStateMgr = "P_OPSServerStateMgr"; const P_OPSServerReportSP = "P_OPSServerReportSP"; const P_OPSRefreshServer = "P_OPSRefreshServer"; const P_SetOpenServerTime = "P_SetOpenServerTime"; const P_CrossServerMaintain = "P_CrossServerMaintain"; InterfaceConfig.php
@@ -60,6 +60,13 @@ ;媒体卡类型对应分组,目前用于越南版本运营公会分组 {"卡类型":"显示分组名", ...} CoupontypeGroup = '{"g001":"公会1", "g002":"公会2"}' [report_server] ;开服推送给运营方 ;需要推送的appID {"appID":对应game_id, ...} game_id = '{"hyenglish":1141, "hyyngame":1135}' ;需要推送的选服json分支,只会主动推送该选服分支下的服务器,且开服状态为正式开放的服务器 jsonbranch = 1 [db] ;接口Mongo数据库IP @@ -68,7 +75,7 @@ DBPort=27017 ;要连接的Mongo数据库名 DataBaseName=GameCenter_xbqy DataBaseName=GameCenter_xbqy_en ;Mongo数据账号 DBUser='TlZCWlBWPT1=' index.php
@@ -111,6 +111,7 @@ array(\User\Permission::P_OPSGameVersion, "serverops/gameVersion.php", "内容版本管理"), array(\User\Permission::P_OPSServerList, "serverops/serverlist.php", "服务器列表"), array(\User\Permission::P_OPSServerStateMgr, "serverops/serverstatemgr.php", "服务器状态管理"), array(\User\Permission::P_OPSServerReportSP, "serverops/serverreportsp.php", "服务器推送SP"), // array(\User\Permission::P_SetOpenServerTime, "SuperGMToolClient/SetOpenServerTime.php", \Lang\gettext("设置开服时间")), array(\User\Permission::P_CrossServerMaintain, "SuperGMToolClient/CrossServerMaintain.php", \Lang\gettext("跨服主服维护")), array(\User\Permission::P_CrossClientServerMaintain, "SuperGMToolClient/CrossClientServerMaintain.php", \Lang\gettext("跨服子服维护")), serverops/hy/report_server.php
New file @@ -0,0 +1,95 @@ <?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://docs.aldgames.com/docs/al-sdk#18rmb \Logging\CreateLogging("serverops.hy.report_server.php"); \Logging\LogInfo("_POST: " . print_r($_POST, true)); $channel = $_POST["channel"]; $server_id = intval($_POST["server_id"]); if ( !\CfgReader\ReadConfig() || !\CfgReader\GetConfigData("Quick", "Key_" . $channel . "_Callback_Key", $Callback_Key) || !\CfgReader\GetConfigData("report_server", "game_id", $gameIDInfo) || !\CfgReader\GetConfigData("report_server", "jsonbranch", $jsonbranch) ) { exit; } // \Logging\LogInfo("gameIDInfo" . $gameIDInfo); $gameIDInfo = json_decode($gameIDInfo, true); if (!isset($gameIDInfo) || !array_key_exists($channel, $gameIDInfo) || !$Callback_Key || !$jsonbranch) { exit; } $game_id = $gameIDInfo[$channel]; if (!DBOper\FindOne("GameServers", array("Channel" => $channel, "ServerID" => $server_id), $serverInfo, null, false) || !isset($serverInfo)) { exit; } $StartDateStr = $serverInfo["StartDate"]; $JsonBranch = $serverInfo["JsonBranch"]; $ServerName = $serverInfo["ServerName"]; // 请求参数 // 属性 描述 类型 必填 // game_id 我方的游戏id,我们运营提供 int 是 // server_id 区服id String 是 // server_name 区服名称 String 是 // open_time 开服时间,格式yyyy-MM-dd HH:mm:ss string 是 // timestamp 请求时间,时间戳,精确到秒 int 是 // sign 签名 String 是,通用签名规则 // 响应结果 // 属性 描述 类型 必返 // code 响应码:0成功,1失败 int 是 // msg 响应消息 string 是 // data 响应数据 array 否 $postData = array( "game_id" => $game_id, "server_id" => $server_id, "server_name" => $ServerName, "open_time" => $StartDateStr, "timestamp" => time(), ); $postData["sign"] = make_sign($postData, $Callback_Key); $postUrl = "https://api.aldgames.com/cp/report_server"; // $postUrl = "http://127.0.0.1:8080/serverops/hy/report_server_t.php"; \Logging\LogInfo("postUrl: " . $postUrl); \Logging\LogInfo("postData: " . print_r($postData, true)); $retStr = \CommFunc\DoPost($postUrl, $postData); \Logging\LogInfo("retStr: " . $retStr); $ret = json_decode($retStr, true); if (!isset($ret) || $ret["code"] != 0) { \Logging\LogError("errormsg:" . $ret["msg"]); echo $retStr; exit; } \Logging\LogInfo("report_server OK! server_id:" . $server_id); $ReportSPTime = date("Y-m-d H:i:s"); DBOper\Update("GameServers", array("Channel" => $channel, "ServerID" => $server_id), array("ReportSPTime" => $ReportSPTime)); $ret["ReportSPTime"] = $ReportSPTime; echo json_encode($ret); exit; function make_sign(array $data, $game_key) { if (array_key_exists('sign', $data)) { unset($data['sign']); } ksort($data); $_data = []; foreach ($data as $k => $v) { $_data[] = $k . '=' . $v; } $str = implode('&', $_data) . '&' . $game_key; return sha1(md5($str)); } serverops/serverreportsp.php
New file @@ -0,0 +1,202 @@ <?php include_once "/Common/Logging.php"; include_once "/Account/User.php"; include_once "/db/DBOper.php"; include_once "/Common/ServerOPS.php"; include_once "/Common/CommFunc.php"; include_once "/language/lang.php"; include_once "/ProjComm/CfgReader.php"; \Logging\CreateLogging("serverops.serverreportsp.php"); $alertMsg = ""; $Permission = \User\Permission::P_OPSServerReportSP; $channel = $_SESSION['spid']; $user = new \User\User($_SESSION['UserAccount']); if (!$user->HavePermission($Permission)) { exit; } if ( !\CfgReader\ReadConfig() || !\CfgReader\GetConfigData("report_server", "game_id", $gameIDInfo) || !\CfgReader\GetConfigData("report_server", "jsonbranch", $jsonbranch) ) { echo "没有推送SP相关配置"; exit; } \Logging\LogInfo("gameIDInfo" . $gameIDInfo); $gameIDInfo = json_decode($gameIDInfo, true); if (!isset($gameIDInfo) || !array_key_exists($channel, $gameIDInfo) || !$jsonbranch) { echo "不需要推送SP"; exit; } $game_id = $gameIDInfo[$channel]; $jsonbranch = intval($jsonbranch); $isSearch = false; $find = array( "Channel" => $channel, "Statue" => array('$in' => array(\ServerOPS\ServerStatue::Open, \ServerOPS\ServerStatue::InternalOpen)), "JsonBranch" => $jsonbranch ); $limit = 50; // 单页条数 $page = 1; if (array_key_exists("topage", $_POST) && intval($_POST["topage"]) > 1) { $page = intval($_POST["topage"]); } else if (array_key_exists("page", $_POST) && intval($_POST["page"]) > 1) { $page = intval($_POST["page"]); } $skip = ($page - 1) * $limit; \DBOper\Find("GameServers", $find, $serverList, null, array("JsonBranch" => 1, "ServerID" => -1), $limit, $skip); $totalCount = count($serverList); if ($totalCount >= $limit || $page > 1) { $totalCount = \DBOper\Count("GameServers", $find); } //显示表格字段配置 key-参数名,value-说明 $tableArray = array( "ServerID" => array("区服", "5%", "center"), "ServerName" => array("名称", "10%", "center"), "StartDate" => array("开服时间", "11%", "center"), "ClearState" => array("清档状态", "5%", "center"), "Statue" => array("开放状态", "5%", "center"), "RunningStatus" => array("运行状态", "5%", "center"), "Recommend" => array("推荐", "3%", "center"), "ReportSPTime" => array("推送时间", "11%", "center"), "" => array("操作", "5%"), ); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>服务器推送SP</title> <link rel="stylesheet" type="text/css" href="/css/table.css"> <link rel="stylesheet" type="text/css" href="/css/button.css"> </head> <body> <center> <p><b>服务器推送SP</b></P> </center> <form method="post"> <hr /> <table width="100%"> <?php if ($serverList) { if ($isSearch) { echo "<caption>符合条件服务器总数: " . count($serverList) . "</caption>"; } else { echo "<caption>服务器数: " . count($serverList) . "/" . $totalCount . "</caption>"; } echo "<thead><tr>"; foreach ($tableArray as $value) { echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>"; } echo "</tr></thead>"; } else { echo "无满足条件服务器!<br/>"; } $Num = $skip; foreach ($serverList as $serverInfo) { $Num += 1; echo "<tr class='trc'>"; $ServerID = $serverInfo["ServerID"]; $ServerName = $serverInfo["ServerName"]; foreach ($tableArray as $key => $value) { if (!$key) { echo "<td align='center'>"; echo "<input type=\"button\" value=\"" . \Lang\gettext("推送") . "\" onclick=\"reportsp('" . $Num . "', '" . $channel . "', '" . $ServerID . "')\" />"; echo "</td>"; continue; } $tdContent = $serverInfo[$key]; if ($key == "ServerID") { $tdContent = "s" . $tdContent; } else if ($key == "ClearState") { if ($tdContent == 1) { $tdContent = "已同步"; } else { $tdContent = "<font color='red'>未处理</font>"; } } else if ($key == "Statue") { $statue = $tdContent; $statueName = \ServerOPS\ServerStatue::$StatueName[$statue]; if ($statue != \ServerOPS\ServerStatue::Open) { $tdContent = "<font color='red'>" . $statueName . "</font>"; } else { $tdContent = $statueName; } } else if ($key == "RunningStatus") { $runningStatus = $tdContent; $runningStatusName = \ServerOPS\ServerRunningStatus::$RunningStatusName[$runningStatus]; if ($runningStatus == \ServerOPS\ServerRunningStatus::PreOpen || $runningStatus == \ServerOPS\ServerRunningStatus::Upkeep) { $tdContent = "<font color='red'>" . $runningStatusName . "</font>"; } else { $tdContent = $runningStatusName; } } else if ($key == "Recommend") { $tdContent = $tdContent == 1 ? "是" : "否"; } elseif ($key == "StartDate") { $OpenServerWay = $serverInfo["OpenServerWay"]; $RelationServerID = $serverInfo["RelationServerID"]; $RelationCreateRoles = $serverInfo["RelationCreateRoles"]; if ($OpenServerWay == 1 && $RelationServerID && $RelationCreateRoles && !$serverInfo["ClearState"]) { $tdContent = "指定服:" . $RelationServerID . " 创角:" . $RelationCreateRoles; } else { $tdContent = $tdContent; } } elseif ($key == "ReportSPTime") { } echo "<td align='" . $value[2] . "' style=\"display:table-cell; vertical-align:middle\">"; echo "<div id='" . $key . "_" . $Num . "'>" . $tdContent . "</div>"; echo "</td>"; } echo "</tr>"; } ?> </table> <?php include_once "/Common/SelectPage.php"; ?> </form> <script type='text/javascript' src="/js/common.js"></script> <script type="text/javascript"> window.onload = function() {} function reportsp(Num, channel, server_id) { console.log("reportsp", Num, channel, server_id); ajaxRequest("hy/report_server.php?channel=" + channel + "&server_id=" + server_id, function(xmlhttp) { var br = getbr(); try { var res = JSON.parse(xmlhttp.responseText); if (res["code"] == 0) { var succ = '<?php echo \Lang\gettext("成功") ?>'; alert(succ); var updObj = document.getElementById("ReportSPTime" + "_" + Num); updObj.innerHTML = res["ReportSPTime"]; } else { var fail = '<?php echo \Lang\gettext("失败") ?>'; alert(fail + br + res["msg"]); } } catch (error) { console.error(error); alert("出错啦"); } }, "POST" ); } </script> </body> </html> task/minuteLoop.php
@@ -231,6 +231,8 @@ "Channel" => $Channel, "ServerID" => array('$nin' => array($ServerID)) ), array("Recommend" => 0), false, false, true); // 通知sp服务器开放 \CommFunc\DoPost("http://127.0.0.1/serverops/hy/report_server.php", array("channel" => $Channel, "server_id" => $ServerID)); } else { \Logging\LogError("set server open error." . print_r($serverInfo, true)); }