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