hxp
2025-06-09 6c3f6335c70859ded94a1ad8d218acb0ac34239c
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
<?php
set_time_limit(120); //暂时设置本脚本执行时间秒
header("Content-type: text/html; charset=utf-8");
include_once "/Common/Logging.php";
include_once "/Common/CommFunc.php";
include_once "/Account/User.php";
include_once "/language/lang.php";
 
function Process()
{
    \Logging\CreateLogging("QueryEventDataSend.php");
    \Logging\LogInfo("Session数据" . print_r($_SESSION, true));
    \Logging\LogInfo("Post数据" . print_r($_POST, true));
 
    $user = new \User\User($_SESSION['UserAccount']);
    if (!$user->HavePermission($_POST['Permission'])) {
        return;
    }
 
    $pack_data = $_POST;
 
    // echo "Session数据" . print_r($_SESSION, true), "<br/>";
    // echo "Post数据" . print_r($_POST, true), "<br/>";
 
    $sendServers = array();
    $serversArray = $user->GetServers();
    $multiserversName = "";
    // 多服查询的
    if (array_key_exists("multiservers", $_POST) && $_POST["multiservers"] != "") {
        $onlyServerID = 0; // 默认0
        $multiserversName = $_POST["multiservers"];
        foreach ($serversArray as $serverName => $serverInfo) {
            $postServerName = urlencode($serverName);
            if (!array_key_exists($postServerName, $_POST)) {
                continue;
            }
            if (!$_POST[$postServerName] == 'on') {
                continue;
            }
            unset($pack_data[$postServerName]);
 
            if ($serverInfo['MainServer'] && !$onlyServerID && $serverInfo['MainServer'] != $serverInfo['ServerID']) {
                # 有主服的代表是合服的,只发主服;因为子服是同一台服务器,没必要重复发送
                continue;
            }
            $sendServers[] = array($serverName, GetQueryEventUrl($serverInfo['Page'], array()));
        }
    } else if ($_SESSION['server_id']) {
        $sendServers[] = array($_SESSION['server_id'], GetQueryEventUrl($_SESSION['tool_page']), array());
    }
 
    if (!$sendServers) {
        echo "Error. " . \Lang\gettext("请先选择服务器");
        return;
    }
 
    // 去除参数
    unset($pack_data['submit']);
    unset($pack_data["pack_type"]);
    unset($pack_data["OnlyServerID"]);
    unset($pack_data["multiservers"]);
    unset($pack_data["server_select_all"]);
 
    $UserAccount = $_SESSION['UserAccount'];
    \CommFunc\GetConfig("ServerInfo", "SpecialServerIDStart", $SpecialServerIDStart);
    \CommFunc\GetConfig("ServerInfo", "SpecialAccountList", $SpecialAccountList);
    $SpecialAccountList = explode(",", $SpecialAccountList);
    $SpecialServerIDStart = intval($SpecialServerIDStart);
    $isSpecialUser = in_array($UserAccount, $SpecialAccountList);
 
    $pack_data["spID"] = $user->GetSPID();
    $pack_data["lang"] = \Lang\getLang();
    for ($i = 0; $i < count($sendServers); $i++) {
        $serverName = $sendServers[$i][0];
        if ($serversArray[$serverName]["MixServerStr"]) {
            $pack_data["mixServerIDInfo"] = $serversArray[$serverName]["MixServerStr"];
        } else {
            $pack_data["mixServerIDInfo"] = $serversArray[$serverName]["ServerID"];
        }
        $pack_data["serverID"] = $serversArray[$serverName]["ServerID"];
        if ($isSpecialUser) { // 特殊账号默认只查本服ID
            // 270只查自己的
            if (strpos($pack_data["mixServerIDInfo"], '270') != false) {
                $pack_data["OnlyServerID"] = "270";
            } else if ($pack_data["OnlyServerID"] == "270") {
                unset($pack_data['OnlyServerID']);
            }
        }
        $sendServers[$i][2] = $pack_data;
    }
 
    // echo "sendServers" . print_r($sendServers, true), "<br/>";
    // echo "pack_data" . print_r($pack_data, true), "<br/>";
 
    \Logging\LogInfo("待发送的服务器信息: " . count($sendServers) . " " . print_r($sendServers, true));
 
    $retList = array();
    if (count($sendServers) == 1) {
        $retList[] = \CommFunc\DoPost($sendServers[0][1], $sendServers[0][2]);
    } else {
        $retList = \CommFunc\DoPostMulti($sendServers);
    }
    $retCount = count($retList);
    \Logging\LogInfo("返回查询结果: " .  $retCount . " " .  print_r($retList, true));
 
    // 多服查询总标题
    if ($multiserversName) {
        echo "<center><p>" . $multiserversName . "</p></center>";
    }
 
    for ($i = 0; $i < $retCount; $i++) {
        // 多服查询的情况,输出服务器名及合服明细
        if ($multiserversName && $i < count($sendServers)) {
            echo ($i + 1) . ". ";
            $serverName = $sendServers[$i][0];
            if ($serversArray[$serverName]["MixServerStr"]) {
                echo $serverName . "--->" . \Lang\gettext("已合服") . "[" . $serversArray[$serverName]["MixServerStr"] . "]";
            } else {
                echo $serverName . "--->" . \Lang\gettext("未合服") . "";
            }
            echo "<br/>";
        }
        echo $retList[$i];
        echo "<hr/>";
    }
}
 
/**获取目标服务器流向查询url地址 */
function GetQueryEventUrl($tool_page)
{
    // 在原GM工具地址下同层级
    return substr($tool_page, 0,  -strlen("tool.php")) . "eventdata/tool.php";
}
 
Process();
?>
 
<style type="text/css">
    .border-table {
        border-collapse: collapse;
        border: none;
        font-size: 13px;
    }
 
    .border-table td {
        border: solid #000 1px;
        padding: 0px 5px;
    }
</style>