hxp
2025-06-04 f4a514d5ac952110da846636ecbb9de951eaf3d2
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
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>