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
<?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.packBranch.php");
 
function PackBranchEdit($opType)
{
    global $alertMsg;
    // echo "_POST: ", print_r($_POST, true), "<br/>";
    $channel = $_SESSION['spid'];
    $BranchNum = intval($_POST["BranchNum"]);
 
    $find = array(
        "Channel" => $channel,
        "BranchNum" => $BranchNum
    );
 
    if ($opType == "del") {
        if (!DBOper\Remove("GamePackBranch", $find)) {
            $alertMsg = "删除分支失败!";
            \Logging\LogError($alertMsg . print_r($find, true));
            return false;
        }
        $alertMsg = "删除分支成功!";
        \Logging\LogInfo($alertMsg . print_r($find, true));
        return true;
    }
 
    $BranchName = $_POST["BranchName"];
    $NoticeUrl = $_POST["NoticeUrl"];
    $ResourceUrl = $_POST["ResourceUrl"];
    $ResourceAwardInfo = $_POST["ResourceAwardInfo"];
    // $ResourceAwardVer = intval($_POST["ResourceAwardVer"]);
    $JsonBranch = intval($_POST["JsonBranch"]);
    $AuditState = intval($_POST["AuditState"]);
 
    $editArray = array(
        "Channel" => $channel,
        "BranchNum" => $BranchNum,
        "BranchName" => $BranchName,
        "JsonBranch" => $JsonBranch,
        "NoticeUrl" => $NoticeUrl,
        "ResourceUrl" => $ResourceUrl,
        "ResourceAwardInfo" => $ResourceAwardInfo,
        "AuditState" => $AuditState,
        // "ResourceAwardVer" => $ResourceAwardVer,
    );
 
    // 添加
    if ($opType == "add") {
        DBOper\FindOne("GamePackBranch", $find, $ret);
        if (count($ret) > 0) {
            $alertMsg = "该分支已存在,不能重复添加!";
            \Logging\LogInfo($alertMsg . print_r($editArray, true));
            return false;
        }
 
        if (!DBOper\Insert("GamePackBranch", $editArray, $find)) {
            $alertMsg = "添加分支失败!";
            \Logging\LogError($alertMsg . print_r($editArray, true));
            return false;
        }
 
        $alertMsg = "添加分支成功!";
        \Logging\LogInfo($alertMsg . print_r($editArray, true));
    }
    // 更新
    elseif ($opType == "upd") {
        $find["BranchNum"] = intval($_POST["SrcBranchNum"]);
        if (!DBOper\Update("GamePackBranch", $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_OPSPackBranch;
$channel = $_SESSION['spid'];
$user = new \User\User($_SESSION['UserAccount']);
if (!$user->HavePermission($Permission)) {
    exit;
}
 
if ($_POST["opType"]) {
    PackBranchEdit($_POST["opType"]);
}
 
DBOper\Find("GamePackBranch", array("Channel" => $channel), $branchArray);
// $branchCount = $branchArray ? count($branchArray) : 0;
 
//显示表格字段配置 key-参数名,value-说明
$tableArray = array(
    "BranchNum" => array("分支编号", "5%", "center"),
    "BranchName" => array("名称", "5%", "center"),
    "JsonBranch" => array("选服Json分支文件", "13%", "center"),
    "ResourceAwardInfo" => array("资源下载奖励信息", "9%", "center"),
    // "ResourceAwardVer" => array("奖励版本号", "6%", "center"),
    "ResourceUrl" => array("资源地址", "28%", "center"),
    "NoticeUrl" => array("公告地址", "28%", "center"),
    "AuditState" => array("审核状态", "5%", "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'" />
    &nbsp;注:打包分支对应的选服、资源、公告等为默认值,即如果对应版本不存在或版本状态不存在则读该打包分支下配置的默认信息;
    <hr />
    <table width="100%">
        <?php
        if ($branchArray) {
            echo "<thead><tr>";
            foreach ($tableArray as $value) {
                echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>";
            }
            echo "</tr></thead>";
            foreach ($branchArray as $branchInfo) {
                echo "<tr class='trc'>";
                $BranchNum = $branchInfo["BranchNum"];
                $BranchName = $branchInfo["BranchName"];
                foreach ($tableArray as $key => $value) {
                    if (!$key) {
                        echo "<td align='center'>";
                        echo "&nbsp;<input type=\"button\" value=\"改\" onclick=\"window.location.href='packBranchEdit.php?opType=upd&BranchNum=$BranchNum'\" />";
                        echo " <input type=\"button\" value=\"删\" onclick=\"return suredel('$channel', '$BranchNum', '$BranchName')\"/>&nbsp;";
                        echo "</td>";
                        continue;
                    }
                    $tdContent = $branchInfo[$key];
                    if ($key == "JsonBranch") {
                        $tdContent = \ServerOPS\GetCommonServerlistJsonFileName($channel, $tdContent);
                    } elseif ($key == "AuditState") {
                        $tdContent = ($tdContent == 1) ? "是" : "否";
                    }
                    echo "<td align='" . $value[2] . "' width=\"100\">" . $tdContent . "</td>";
                }
                echo "</tr>";
            }
        } else {
            echo "无分支,请添加分支!<br/>";
        }
        ?>
    </table>
 
    <script type='text/javascript' src="/js/common.js"></script>
    <script type="text/javascript">
        function suredel(Channel, BranchNum, BranchName) {
            if (!window.confirm("确定删除" + Channel + "分支: " + BranchName + " (" + BranchNum + ") ?")) {
                return false;
            }
            doSubmit("packBranch.php", {
                "opType": "del",
                "BranchNum": BranchNum,
            }, 'post');
            return true;
        }
    </script>
</body>
 
</html>