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
<?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";
 
\Logging\CreateLogging("serverops.versionState.php");
 
function VersionStateEdit($opType)
{
    global $alertMsg;
    // echo "_POST: ", print_r($_POST, true), "<br/>";
    $channel = $_SESSION['spid'];
    $BranchNum = intval($_POST["BranchNum"]);
    $VersionState = intval($_POST["VersionState"]);
 
    $find = array(
        "Channel" => $channel,
        "BranchNum" => $BranchNum,
        "VersionState" => $VersionState,
    );
 
    if ($opType == "del") {
        if (!DBOper\Remove("GameVersionState", $find)) {
            $alertMsg = "删除失败!";
            \Logging\LogError($alertMsg . print_r($find, true));
            return false;
        }
        $alertMsg = "删除成功!";
        \Logging\LogInfo($alertMsg . print_r($find, true));
        return true;
    }
 
    $StateName = $_POST["StateName"];
    $JsonBranch = intval($_POST["JsonBranch"]);
    $NoticeUrl = $_POST["NoticeUrl"];
    $ResourceUrl = $_POST["ResourceUrl"];
    $ResourceAwardInfo = $_POST["ResourceAwardInfo"];
    $IsDefault = intval($_POST["IsDefault"]);
 
    $editArray = array(
        "Channel" => $channel,
        "BranchNum" => $BranchNum,
        "VersionState" => $VersionState,
        "StateName" => $StateName,
        "JsonBranch" => $JsonBranch,
        "NoticeUrl" => $NoticeUrl,
        "ResourceUrl" => $ResourceUrl,
        "ResourceAwardInfo" => $ResourceAwardInfo,
    );
 
    // 添加
    if ($opType == "add") {
        DBOper\FindOne("GameVersionState", $find, $ret);
        if (count($ret) > 0) {
            $alertMsg = "该版本状态已存在,不能重复添加!";
            \Logging\LogInfo($alertMsg . print_r($editArray, true));
            return false;
        }
 
        if (!DBOper\Insert("GameVersionState", $editArray, $find)) {
            $alertMsg = "添加版本状态失败!";
            \Logging\LogError($alertMsg . print_r($editArray, true));
            return false;
        }
 
        $alertMsg = "添加版本状态成功!";
        \Logging\LogInfo($alertMsg . print_r($editArray, true));
    }
    // 更新
    elseif ($opType == "upd") {
        $find["VersionState"] = intval($_POST["SrcVersionState"]);
        if (!DBOper\Update("GameVersionState", $find, $editArray, true)) {
            $alertMsg = "更新版本状态失败!";
            \Logging\LogError($alertMsg . print_r($editArray, true));
            return false;
        }
        $alertMsg = "更新版本状态成功!";
        \Logging\LogInfo($alertMsg . print_r($editArray, true));
    }
    return true;
}
 
$alertMsg = "";
$Permission = \User\Permission::P_OPSVersionState;
$channel = $_SESSION['spid'];
$user = new \User\User($_SESSION['UserAccount']);
if (!$user->HavePermission($Permission)) {
    exit;
}
 
// 打包分支
$BranchNum = 0;
$branchNameInfo = array();
DBOper\Find(
    "GamePackBranch",
    array("Channel" => $channel),
    $branchArray,
    array("BranchNum" => 1, "BranchName" => 1)
);
foreach ($branchArray as $branchInfo) {
    $branchNameInfo[$branchInfo["BranchNum"]] = $branchInfo["BranchName"];
    if ($BranchNum == 0) {
        $BranchNum = $branchInfo["BranchNum"];
    }
}
 
if (array_key_exists("BranchNum", $_POST)) {
    $BranchNum = intval($_POST["BranchNum"]);
    VersionStateEdit($_POST["opType"]);
}
 
// 版本状态
DBOper\Find(
    "GameVersionState",
    array("Channel" => $channel, "BranchNum" => $BranchNum),
    $versionStateArray
);
 
//显示表格字段配置 key-参数名,value-说明
$tableArray = array(
    "VersionState" => array("状态", "5%", "center"),
    "StateName" => array("状态名", "5%", "center"),
    "JsonBranch" => array("选服Json分支文件", "13%", "center"),
    "ResourceAwardInfo" => array("资源下载奖励信息", "9%", "center"),
    "ResourceUrl" => array("资源地址", "28%", "center"),
    "NoticeUrl" => array("公告地址", "28%", "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>
    <form action="" method="post">
        打包分支:
        <select name="BranchNum" id="BranchNum" onchange="ChangeBranchNum(this)">
            <?php
            foreach ($branchNameInfo as $key => $value) {
                echo "<option value=\"" . $key . "\"";
                if ($BranchNum == $key) {
                    echo " selected";
                }
                echo ">" . $value . "</option>";
            }
            ?>
        </select>
        &nbsp;&nbsp;
        <input type="button" value="添加版本状态" onclick="window.location.href='versionStateEdit.php?opType=add&BranchNum=<?php echo $BranchNum ?>'" />
    </form>
    <hr />
    <?php
    if ($versionStateArray) {
        echo '<table width="100%">';
        echo "<thead><tr>";
        foreach ($tableArray as $value) {
            echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>";
        }
        echo "</tr></thead>";
        foreach ($versionStateArray as $stateInfo) {
            echo "<tr class='trc'>";
            $BranchNum = $stateInfo["BranchNum"];
            $VersionState = $stateInfo["VersionState"];
            $StateName = $stateInfo["StateName"];
            foreach ($tableArray as $key => $value) {
                if (!$key) {
                    echo "<td align='center'>";
                    echo "&nbsp;<input type=\"button\" value=\"改\" onclick=\"window.location.href='versionStateEdit.php?" .
                        "opType=upd&BranchNum=$BranchNum&VersionState=$VersionState'\" />";
                    echo " <input type=\"button\" value=\"删\" onclick=\"return suredel('$channel', '$BranchNum', '$VersionState', '$StateName')\"/>&nbsp;";
                    echo "</td>";
                    continue;
                }
                $tdContent = $stateInfo[$key];
                if ($key == "JsonBranch") {
                    $tdContent = \ServerOPS\GetCommonServerlistJsonFileName($channel, $tdContent);
                }
                echo "<td align='" . $value[2] . "' width=\"100\">" . $tdContent . "</td>";
            }
            echo "</tr>";
        }
        echo "</table>";
    } else {
        echo "无版本状态,请添加状态!<br/>";
    }
    ?>
 
    <script type='text/javascript' src="/js/common.js"></script>
    <script type="text/javascript">
        function ChangeBranchNum(obj) {
            document.forms[0].submit();
        }
 
        function suredel(Channel, BranchNum, VersionState, StateName) {
            if (!window.confirm("确定删除" + Channel + "分支: " + BranchNum + " 版本状态:" + VersionState + "(" + StateName + ") ?")) {
                return false;
            }
            doSubmit("", {
                "opType": "del",
                "BranchNum": BranchNum,
                "VersionState": VersionState,
            }, 'post');
            return true;
        }
    </script>
</body>
 
</html>