hxp
2024-09-06 49523e4f736ed3aac7ba4e4148b1b99098525b51
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
<?php
include_once "/Common/Logging.php";
include_once "/Account/User.php";
include_once "/db/DBOper.php";
include_once "/Common/CommFunc.php";
include_once "/language/lang.php";
 
\Logging\CreateLogging("serverops.gameVersion.php");
 
function GameVersionEdit($opType)
{
    global $alertMsg;
    // echo "_POST: ", print_r($_POST, true), "<br/>";
    $channel = $_SESSION['spid'];
    $BranchNum = intval($_POST["BranchNum"]);
    $Version = $_POST["Version"];
    $ForceDownUrl = $_POST["ForceDownUrl"];
 
    $find = array(
        "Channel" => $channel,
        "BranchNum" => $BranchNum,
        "Version" => $Version
    );
    if ($opType == "del") {
        if (!DBOper\Remove("GameVersion", $find)) {
            $alertMsg = "删除内容版本失败!";
            \Logging\LogError($alertMsg . print_r($find, true));
            return false;
        }
        $alertMsg = "删除内容版本成功!";
        \Logging\LogInfo($alertMsg . print_r($find, true));
        return true;
    }
 
    $editArray = array(
        "Channel" => $channel,
        "BranchNum" => $BranchNum,
        "Version" => $Version,
        "ForceDownUrl" => $ForceDownUrl,
        "UpdateTime" => date("Y-m-d H:i:s")
    );
 
    // 添加
    if ($opType == "add") {
        DBOper\FindOne("GameVersion", $find, $ret);
        if (count($ret) > 0) {
            $alertMsg = "该内容版本已存在,不能重复添加!";
            \Logging\LogInfo($alertMsg . " find=" . print_r($find, true));
            return false;
        }
        $editArray["VersionTime"] = date("Y-m-d H:i:s");
        if (!DBOper\Insert("GameVersion", $editArray, $find)) {
            $alertMsg = "添加内容版本失败!";
            \Logging\LogError($alertMsg . print_r($editArray, true));
            return false;
        }
 
        $alertMsg = "添加内容版本成功!";
        \Logging\LogInfo($alertMsg . print_r($editArray, true));
    }
 
    // 更新
    elseif ($opType == "upd") {
        $find["Version"] = $_POST["SrcVersion"];
        if (!DBOper\Update("GameVersion", $find, $editArray, true)) {
            $alertMsg = "更新内容版本失败!";
            \Logging\LogError($alertMsg . " find=" . print_r($find, true) . " set=" . print_r($editArray, true));
            return false;
        }
        $alertMsg = "更新内容版本成功!";
        \Logging\LogInfo($alertMsg . " find=" . print_r($find, true) . " set=" . print_r($editArray, true));
    }
    return true;
}
 
$alertMsg = "";
 
$Permission = \User\Permission::P_OPSGameVersion;
$channel = $_SESSION['spid'];
$user = new \User\User($_SESSION['UserAccount']);
if (!$user->HavePermission($Permission)) {
    exit;
}
 
$AllChannel = \CommFunc\GetAllChannel();
if ($_POST["opType"]) {
    GameVersionEdit($_POST["opType"]);
}
 
DBOper\Find(
    "GameVersion",
    array("Channel" => $channel),
    $versionArray,
    null,
    array("BranchNum" => 1, "VersionTime" => -1)
);
 
$branchNameInfo = array();
DBOper\Find(
    "GamePackBranch",
    array("Channel" => $channel),
    $branchArray,
    array("BranchNum" => 1, "BranchName" => 1)
);
foreach ($branchArray as $branchInfo) {
    $branchNameInfo[$branchInfo["BranchNum"]] = $branchInfo["BranchName"];
}
 
// echo "branchNameInfo:", print_r($branchNameInfo, true), "<br/>";
 
//显示表格字段配置 key-参数名,value-说明
$tableArray = array(
    "BranchNum" => array("分支", "5%", "center"),
    "BranchName" => array("名称", "7%", "center"),
    "Version" => array("游戏版本", "7%", "center"),
    "VersionTime" => array("版本时间", "12%", "center"),
    "UpdateTime" => array("修改时间", "12%", "center"),
    "ForceDownUrl" => array("强更下载地址", "40%", "center"),
    "" => array("操作", "", "center"),
);
 
if ($alertMsg) {
    echo "<script>alert('" . $alertMsg . "')</script>";
}
 
?>
 
<html>
 
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>内容版本管理</title>
    <link rel="stylesheet" type="text/css" href="/css/table.css">
</head>
 
<body>
    <center>
        <p><b>内容版本管理</b></P>
    </center>
 
    <input type="button" value="添加分支" onclick="window.location.href='packBranchEdit.php?opType=add'" />
    <?php
    // 先都展示测试用, 后续再优化布局
    foreach ($branchNameInfo as $BranchNum => $BranchName) {
        echo " <input type=\"button\" value=\"[" . $BranchName . "]分支 -> 添加版本\" " .
            "onclick=\"window.location.href='gameVersionEdit.php?opType=add&BranchNum=" . $BranchNum . "&BranchName=" . $BranchName . "'\" />";
    }
    ?>
    <hr />
    <table width="100%">
        <?php
        if ($versionArray) {
            echo "<thead><tr>";
            foreach ($tableArray as $value) {
                echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>";
            }
            echo "</tr></thead>";
        } else {
            echo "无游戏版本,请添加版本!<br/>";
        }
 
        foreach ($versionArray as $versionInfo) {
            echo "<tr class='trc'>";
            $BranchNum = $versionInfo["BranchNum"];
            $BranchName = $branchNameInfo[$BranchNum];
            $Version = $versionInfo["Version"];
            foreach ($tableArray as $key => $value) {
                if (!$key) {
                    echo "<td align='center'>";
                    echo "&nbsp;<input type=\"button\" value=\"改\" onclick=\"window.location.href='gameVersionEdit.php?" .
                        "opType=upd&BranchNum=$BranchNum&BranchName=$BranchName&Version=$Version'\" />";
                    echo " <input type=\"button\" value=\"删\" onclick=\"return suredel('$channel', '$BranchNum', '$Version')\"/>&nbsp;";
                    echo "</td>";
                    continue;
                }
                if ($key == "BranchName") {
                    $tdContent = $BranchName;
                } else {
                    $tdContent = $versionInfo[$key];
                }
                echo "<td align='" . $value[2] . "'>" . $tdContent . "</td>";
            }
            echo "</tr>";
        }
        ?>
    </table>
 
    <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(Channel, BranchNum, Version) {
            if (!window.confirm("确定删除" + Channel + "分支" + BranchNum + "版本" + Version + "?")) {
                return false;
            }
            doPost("gameVersion.php", {
                "opType": "del",
                "BranchNum": BranchNum,
                "Version": Version,
            });
            return true;
        }
    </script>
</body>
 
</html>