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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<?php
include_once "/Common/Logging.php";
include_once "/Account/User.php";
include_once "/db/DBOper.php";
include_once "/language/lang.php";
include_once "/Account/userlogcomm.php";
include_once "/Common/GMTRetCode.php";
 
\Logging\CreateLogging("account.userlog.php");
$Permission = \User\Permission::P_UserLog;
 
$alertMsg = "";
$spid = $_SESSION['spid'];
$UserAccount = $_SESSION['UserAccount'];
$user = new \User\User($UserAccount);
if (!$user->HavePermission($Permission)) {
    exit;
}
 
$Organization = array_key_exists("Organization", $_POST) ? $_POST["Organization"] : $user->GetAttr("Organization");
 
$showPermissionArray = array();
$PermissionModules = \User\GetPermissionModules();
foreach ($PermissionModules as $index => $mInfo) {
    foreach ($mInfo["PList"] as $pName => $pInfo) {
        if (!$pInfo["Log"]) {
            continue;
        }
        if (!$user->HavePermission($pName, false)) {
            // 只展示自己有的权限动态
            continue;
        }
        $showPermissionArray[$pName] = $pInfo;
    }
}
 
$findPermission = $_POST["findPermission"];
$findCheckState = intval($_POST["findCheckState"]);
$onlyErrorMsg = $_POST["onlyErrorMsg"];
 
$find = array("SPID" => $spid);
if ($findPermission) {
    $find["Permission"] = $findPermission;
} else {
    $find["Permission"] = array('$in' => array_keys($showPermissionArray));
}
if ($findCheckState) {
    $find["CheckState"] = $findCheckState;
}
if ($onlyErrorMsg == 'on') {
    $find["ErrorMsg"] = array('$nin' => array(array()));
}
$limitDefault = 15;
$limit = array_key_exists("limit", $_COOKIE) ? intval($_COOKIE["limit"]) : $limitDefault; // 单页条数
$page = 1;
if (array_key_exists("limit", $_POST) && intval($_POST["limit"]) > 0) {
    $limit = intval($_POST["limit"]);
}
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("GMTLog", $find, $logArray, null, array("OPTime" => -1), $limit, $skip);
$totalCount = count($logArray);
if ($totalCount >= $limit || $page > 1) {
    $totalCount = \DBOper\Count("GMTLog", $find);
}
 
//显示表格字段配置 key-参数名,value-说明
$tableArray = array(
    "Num" => array(\Lang\gettext("编号"), "3%", "center"),
    "UserAccount" => array(\Lang\gettext("操作账号"), "8%", "center"),
    "Permission" => array(\Lang\gettext("操作类型"), "8%", "center"),
    "Post" => array(\Lang\gettext("请求数据"), "10%", "center"),
    "Result" => array(\Lang\gettext("请求结果"), "12%", "center"),
    "OPTime" => array(\Lang\gettext("请求时间"), "11%", "center"),
    "IP" => array("IP", "9%", "center"),
    "CheckState" => array(\Lang\gettext("审核状态"), "5%", "center"),
    "CheckUserAccount" => array(\Lang\gettext("审核账号"), "8%", "center"),
    "CheckTime" => array(\Lang\gettext("审核时间"), "11%", "center"),
    "CheckIP" => array(\Lang\gettext("审核IP"), "9%", "center"),
    "" => array(\Lang\gettext("操作"), "", "center"),
);
 
if ($alertMsg) {
    echo "<script>alert('" . $alertMsg . "')</script>";
}
 
$checkStateNameInfo = \User\GMTCheckState::StateNameInfo();
// echo "_COOKIE:", json_encode($_COOKIE), "<br/>";
// echo "_POST:", json_encode($_POST), "<br/>";
// echo "find:", json_encode($find), "<br/>";
 
$showDetailInfo = array(
    0 => \Lang\gettext("简要信息"),
    1 => \Lang\gettext("明细信息"),
);
$showDetail = array_key_exists("showDetail", $_COOKIE) ? intval($_COOKIE["showDetail"]) : 0;
if (array_key_exists("showDetail", $_POST)) {
    $showDetail = intval($_POST["showDetail"]);
}
 
// 保存cookie
setcookie("limit", $limit);
setcookie("showDetail", $showDetail);
?>
 
<html>
 
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php echo \Lang\gettext("操作动态"); ?></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><?php echo \Lang\gettext("操作动态"); ?></b></P>
    </center>
 
    <form id="userlog" action="userlog.php" method="post">
        <?php
        echo "<select name=\"findPermission\">";
        echo "<option value=\"\"" . ">" . \Lang\gettext("操作类型") . "</option>";
        foreach ($showPermissionArray as $pName => $pInfo) {
            echo "<option value=\"" . $pName . "\"";
            if ($findPermission == $pName) {
                echo " selected";
            }
            echo ">" .  $pInfo["Name"] . "</option>";
        }
        echo "</select>";
 
        echo "&nbsp;&nbsp;";
        echo "<select name=\"findCheckState\">";
        echo "<option value=\"\"" . ">" . \Lang\gettext("审核状态") . "</option>";
        foreach ($checkStateNameInfo as $checkState => $msg) {
            echo "<option value=\"" . $checkState . "\"";
            if ($findCheckState == $checkState) {
                echo " selected";
            }
            echo ">" .  $msg . "</option>";
        }
        echo "</select>";
 
        //明细信息
        echo "&nbsp;&nbsp;";
        foreach ($showDetailInfo as $value => $t) {
            echo "<input type=\"radio\" name=\"showDetail\" value=\"" . $value . "\"";
            if ($showDetail == $value) {
                echo " checked";
            }
            echo " />" . $t;
        }
 
        // 过滤错误结果
        echo "&nbsp;&nbsp;";
        echo '<input type="checkbox" name="onlyErrorMsg" id="onlyErrorMsg" ' . ($onlyErrorMsg == "on" ? "checked" : "") . ' />' . \Lang\gettext("仅显示错误请求");
 
        echo "&nbsp;&nbsp;";
        echo \Lang\gettext("单页条数"), ": ";
        echo "<input type=\"number\" name=\"limit\" id=\"limit\" value=\"" . $limit . "\" min=\"1\" style=\"width: 60px\" />";
        ?>
        &nbsp;&nbsp;<input type="submit" name="submit" value="<?php echo \Lang\gettext("搜索"); ?>" class="button green medium" />
        <hr />
        <table width="100%">
            <?php
            if ($logArray) {
                echo "<thead><tr>";
                foreach ($tableArray as $value) {
                    echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>";
                }
                echo "</tr></thead>";
            } else {
                echo \Lang\gettext("暂无动态"), "<br/>";
            }
 
            $Num = $skip;
            foreach ($logArray as $logInfo) {
                $Num += 1;
                echo "<tr class='trc'>";
                $Permission = $logInfo["Permission"];
                $GUID = $logInfo["GUID"];
                $PerInfo = \User\GetPermissionInfo($Permission);
                $MultiServer = $logInfo["Post"]["MultiServer"];
                foreach ($tableArray as $key => $value) {
                    if (!$key) {
                        echo "<td align='center'>";
                        echo "<input type=\"button\" value=\"" . \Lang\gettext("查看") . "\" onclick=\"showLogDetail('" . $GUID . "', '" . $Num . "', '" . $showDetail . "')\" />";
                        echo "</td>";
                        continue;
                    }
 
                    $tdContent = $logInfo[$key];
                    if ($key == "Num") {
                        $tdContent = $Num;
                    } else if ($key == "Permission") {
                        $tdContent = $PerInfo["Name"];
                    } else if ($key == "CheckState") {
                        if ($tdContent == \User\GMTCheckState::OK && !$logInfo["CheckUserAccount"]) {
                            $tdContent = \Lang\gettext("免审通过");
                        } else {
                            $tdContent = $checkStateNameInfo[$tdContent];
                        }
                    } else if ($key == "Post") {
                        ParseGMTLogTDHtml_Post($logInfo, $showDetail, $tdContent);
                    } else if ($key == "Result") {
                        ParseGMTLogTDHtml_Result($logInfo, $showDetail, $tdContent);
                    } else if ($key == "OPTime") {
                        $tdContent = date("Y-m-d H:i:s", $tdContent);
                    } else if ($key == "CheckTime" && $tdContent) {
                        $tdContent = date("Y-m-d H:i:s", $tdContent);
                    }
                    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>
</body>
 
<script type="text/javascript">
    function doPost(to, p) { // to:提交动作(action),p:参数 
        var myForm = document.createElement("form");
        myForm.method = "post";
        myForm.action = to;
        for (var i in p) {
            var myInput = document.createElement("input");
            myInput.setAttribute("name", i); // 为input对象设置name 
            myInput.setAttribute("value", p[i]); // 为input对象设置value 
            myForm.appendChild(myInput);
        }
        document.body.appendChild(myForm);
        myForm.submit();
        document.body.removeChild(myForm); // 提交后移除创建的form 
    }
 
    function suredel(Organization, UserAccount) {
        var confirmstr = "<?php echo \Lang\gettext("确定删除账号? 目标账号:"); ?>";
        if (!window.confirm(confirmstr + UserAccount)) {
            return false;
        }
        doPost("userlist.php", {
            "opType": "del",
            "Organization": Organization,
            "UserAccount": UserAccount,
        });
        return true;
    }
 
    function showLogDetail(GUID, Num, showDetail) {
        var width = 1000;
        var height = 900;
        // 兼容分屏
        var l = (window.screenX || window.screenLeft || 0) + (screen.availWidth - width) / 2;
        var t = (screen.availHeight - height) / 2;
        var specs = 'width=' + width + ',height=' + height + ',top=' + t + ', left = ' + l +
            ',toolbar=no,menubar=no,location=no';
        var url = 'userlogdetail.php?GUID=' + GUID + '&Num=' + Num + "&showDetail=" + showDetail;
        myWindow = window.open(url, 'newwindow', specs);
        myWindow.focus();
    }
</script>
 
</html>