| <?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.serverlist.php"); | 
|   | 
| function ServerInfoEdit($opType) | 
| { | 
|     global $alertMsg; | 
|     // echo "_POST: ", print_r($_POST, true), "<br/>"; | 
|     $channel = $_SESSION['spid']; | 
|     $ServerID = intval($_POST["ServerID"]); | 
|     $ServerName = $_POST["ServerName"]; | 
|     $JsonBranch = intval($_POST["JsonBranch"]); | 
|     $OpenServerWay = intval($_POST["OpenServerWay"]); | 
|     $RelationServerID = intval($_POST["RelationServerID"]); | 
|     $RelationCreateRoles = intval($_POST["RelationCreateRoles"]); | 
|     $StartDate = $_POST["StartDate"]; | 
|     $StartHour = $_POST["StartHour"]; | 
|     $StartMinute = $_POST["StartMinute"]; | 
|     $StartSecond = $_POST["StartSecond"]; | 
|     if ($StartDate) { | 
|         $StartDate .= " " . $StartHour . ":" . $StartMinute . ":" . $StartSecond; | 
|     } | 
|     $ClearState = intval($_POST["ClearState"]); | 
|     $Statue = intval($_POST["Statue"]); | 
|     $RunningStatus = intval($_POST["RunningStatus"]); | 
|     $Recommend = intval($_POST["Recommend"]); | 
|     $RegionDomain = $_POST["RegionDomain"]; | 
|     $LoginPort = intval($_POST["LoginPort"]); | 
|     $GamePort = intval($_POST["GamePort"]); | 
|     $MainServerID = intval($_POST["MainServerID"]); | 
|   | 
|     $find = array( | 
|         "Channel" => $channel, | 
|         "ServerID" => $ServerID | 
|     ); | 
|     if ($opType == "del") { | 
|         if (!DBOper\Remove("GameServers", $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, | 
|         "ServerID" => $ServerID, | 
|         "ServerName" => $ServerName, | 
|         "JsonBranch" => $JsonBranch, | 
|         "OpenServerWay" => $OpenServerWay, | 
|         "RelationServerID" => $RelationServerID, | 
|         "RelationCreateRoles" => $RelationCreateRoles, | 
|         "StartDate" => $StartDate, | 
|         "ClearState" => $ClearState, | 
|         "Statue" => $Statue, | 
|         "RunningStatus" => $RunningStatus, | 
|         "Recommend" => $Recommend, | 
|         "RegionDomain" => $RegionDomain, | 
|         "LoginPort" => $LoginPort, | 
|         "GamePort" => $GamePort, | 
|         "MainServerID" => $MainServerID, | 
|     ); | 
|   | 
|     // 添加 | 
|     if ($opType == "add") { | 
|         $editArray["RelationServerOK"] = 0; | 
|         if (\CommFunc\IsInnerTest() && intval($_POST["InnerTestCount"]) > 0) { | 
|             $testCount = intval($_POST["InnerTestCount"]); | 
|             $testServerID = $ServerID; | 
|             $testServerName = $ServerName; | 
|             DBOper\Find("GameServers", array( | 
|                 "Channel" => $channel, | 
|                 "ServerID" => array('$gte' => $testServerID, '$lt' => ($testServerID +  $testCount)) | 
|             ), $existServer, array("ServerID" => 1)); | 
|             $existServerIDArray = array(); | 
|             foreach ($existServer as $value) { | 
|                 array_push($existServerIDArray, $value["ServerID"]); | 
|             } | 
|             \Logging\LogInfo("测试批量插入服务器: testServerID=" . $testServerID . " testCount=" . $testCount); | 
|             // \Logging\LogInfo("已存在的服务器 => " . print_r($existServer, true)); | 
|             \Logging\LogInfo("已存在的服务器ID => " . print_r($existServerIDArray, true)); | 
|   | 
|             $batchInsArray = array(); | 
|             for ($i = 0; $i < $testCount; $i++) { | 
|                 $tServerID = $testServerID + $i; | 
|                 if (in_array($tServerID, $existServerIDArray)) { | 
|                     \Logging\LogInfo("测试插入服务器已存在: tServerID=" .  $tServerID); | 
|                     continue; | 
|                 } | 
|                 $insArray = array_merge($editArray); | 
|                 $insArray["ServerID"] = $tServerID; | 
|                 $insArray["ServerName"] = "s" . $tServerID; | 
|                 array_push($batchInsArray, $insArray); | 
|             } | 
|             if (DBOper\BatchInsert("GameServers", $batchInsArray)) { | 
|                 $alertMsg = "批量插入测试服务器成功!"; | 
|             } else { | 
|                 $alertMsg = "批量插入测试服务器失败!"; | 
|             } | 
|             // \Logging\LogInfo($alertMsg . print_r($batchInsArray, true)); | 
|             return true; | 
|         } | 
|   | 
|         DBOper\FindOne("GameServers", $find, $ret, null, false); | 
|         if (count($ret) > 0) { | 
|             $alertMsg = "该服务器已存在,不能重复添加!"; | 
|             \Logging\LogInfo($alertMsg . " find=" . print_r($find, true)); | 
|             return false; | 
|         } | 
|         if (!DBOper\Insert("GameServers", $editArray)) { | 
|             $alertMsg = "添加服务器失败!"; | 
|             \Logging\LogError($alertMsg . print_r($editArray, true)); | 
|             return false; | 
|         } | 
|   | 
|         $alertMsg = "添加服务器成功!"; | 
|         \Logging\LogInfo($alertMsg . print_r($editArray, true)); | 
|     } | 
|   | 
|     // 更新 | 
|     elseif ($opType == "upd") { | 
|         if (!DBOper\Update("GameServers", $find, $editArray)) { | 
|             $alertMsg = "更新服务器失败!"; | 
|             \Logging\LogError($alertMsg . " find=" . json_encode($find) . " set=" . json_encode($editArray)); | 
|             return false; | 
|         } | 
|         $alertMsg = "更新服务器成功!"; | 
|         \Logging\LogInfo($alertMsg . " find=" . json_encode($find) . " set=" . json_encode($editArray)); | 
|     } | 
|     return true; | 
| } | 
|   | 
| \Logging\LogInfo("_POST:" . print_r($_POST, true)); | 
| $alertMsg = ""; | 
| $Permission = \User\Permission::P_OPSServerList; | 
| $channel = $_SESSION['spid']; | 
| $user = new \User\User($_SESSION['UserAccount']); | 
| if (!$user->HavePermission($Permission)) { | 
|     exit; | 
| } | 
|   | 
| if ($_POST["opType"]) { | 
|     if (ServerInfoEdit($_POST["opType"])) { | 
|         \ServerOPS\RefreshServerListIni($channel); | 
|     } | 
|     if ($_POST["opType"] == "add" && $alertMsg) { | 
|         $getParams = "opType=add"; | 
|         foreach ($_POST as $key => $value) { | 
|             $getParams .= "&" . $key . "=" . $value; | 
|         } | 
|         $script = "<script>"; | 
|         $script .= "if(window.confirm('" . $alertMsg . " 继续添加?')) {window.location.href='serverEdit.php?$getParams';}"; | 
|         $script .= "</script>"; | 
|         echo $script; | 
|     } else if ($alertMsg) { | 
|         echo "<script>alert('" . $alertMsg . "')</script>"; | 
|     } | 
| } | 
|   | 
| $all = "all"; | 
| $Statue = array_key_exists("Statue", $_POST) ? $_POST["Statue"] : $all; | 
| $RunningStatus = array_key_exists("RunningStatus", $_POST) ? $_POST["RunningStatus"] : $all; | 
| $Recommend = array_key_exists("Recommend", $_POST) ? $_POST["Recommend"] : $all; | 
|   | 
| // 搜索条件组合 {"Channel":"sohagame", "$or":[{"ServerID":{"$gte":1, "$lte":10}}, {"ServerID":{"$gte":80, "$lte":90}}]} | 
| $find = array("Channel" => $channel); | 
| if ($Statue != $all) { | 
|     $find["Statue"] = intval($Statue); | 
| } | 
| if ($RunningStatus != $all) { | 
|     $find["RunningStatus"] = intval($RunningStatus); | 
| } | 
| if ($Recommend != $all) { | 
|     $find["Recommend"] = intval($Recommend); | 
| } | 
| $serverIDCondArray = array(); | 
| $serverIDCondIn = array(); | 
| $serverIDCondFind = array(); | 
| $serverIDCondNumMax = 20; | 
| for ($i = 1; $i < $serverIDCondNumMax + 1; $i++) { | 
|     if (!array_key_exists("ServerIDGTE" . $i, $_POST)) { | 
|         continue; | 
|     } | 
|     $eValue = intval($_POST["ServerIDE" . $i]); | 
|     $gteValue = intval($_POST["ServerIDGTE" . $i]); | 
|     $lteValue = intval($_POST["ServerIDLTE" . $i]); | 
|     // echo $i, " : ", $gteValue, $lteValue, "<br/>"; | 
|     if ($eValue <= 0 && $gteValue <= 0 && $lteValue <= 0) { | 
|         continue; | 
|     } | 
|     if ($gteValue > 0 && $lteValue > 0 && $gteValue > $lteValue) { | 
|         continue; | 
|     } | 
|     $cond = array(); | 
|     if ($eValue > 0) { | 
|         array_push($serverIDCondIn, $eValue); | 
|     } | 
|     if ($gteValue > 0) { | 
|         $cond['$gte'] = $gteValue; | 
|     } | 
|     if ($lteValue > 0) { | 
|         $cond['$lte'] = $lteValue; | 
|     } | 
|     array_push($serverIDCondArray, array($eValue, $gteValue, $lteValue)); | 
|     array_push($serverIDCondFind, array("ServerID" => $cond)); | 
| } | 
| if (count($serverIDCondIn) > 0) { | 
|     array_push($serverIDCondFind, array("ServerID" => array('$in' => $serverIDCondIn))); | 
| } | 
| if (count($serverIDCondFind) > 0) { | 
|     $find['$or'] = $serverIDCondFind; | 
| } | 
| // \Logging\LogInfo("find:" . json_encode($find)); | 
|   | 
| $isSearch = true; | 
| if (array_key_exists("submitsearch", $_POST)) { | 
| } | 
| // 设置合服主服 | 
| else if (array_key_exists("submitSetMainServerID", $_POST)) { | 
|     $SetMainServerID = intval($_POST["SetMainServerID"]); | 
|     $set = array("MainServerID" => $SetMainServerID); | 
|     if ($_POST["SetMainServerDomain"]) { | 
|         \DBOper\FindOne("GameServers", array("Channel" => $channel, "ServerID" => $SetMainServerID), $mainServerInfo, null, false); | 
|         if (isset($mainServerInfo)) { | 
|             $set = array( | 
|                 "MainServerID" => $SetMainServerID, | 
|                 "RegionDomain" => $mainServerInfo["RegionDomain"], | 
|                 "LoginPort" => $mainServerInfo["LoginPort"], | 
|                 "GamePort" => $mainServerInfo["GamePort"] | 
|             ); | 
|         } | 
|     } | 
|     if (!\DBOper\Update("GameServers", $find, $set, false, false, true)) { | 
|         $alertMsg = "批量更新合服主服失败!"; | 
|         \Logging\LogError($alertMsg . " find=" . json_encode($find) . " set=" . json_encode($set)); | 
|     } else { | 
|         $alertMsg = "批量更新合服主服成功!"; | 
|         \Logging\LogInfo($alertMsg . " find=" . json_encode($find) . " set=" . json_encode($set)); | 
|         \ServerOPS\RefreshServerListIni($channel); | 
|     } | 
|     echo "<script>alert('" . $alertMsg . "')</script>"; | 
| } | 
| // 设置状态 | 
| else if (array_key_exists("updSelect", $_POST) && $_POST["updSelect"] != "") { | 
|     $set = array(); | 
|     $updSelect = $_POST["updSelect"]; | 
|     if (substr($updSelect, 0, 6) == "Statue") { | 
|         $set["Statue"] = intval(substr($updSelect, 6)); | 
|     } else if (substr($updSelect, 0, 13) == "RunningStatus") { | 
|         $set["RunningStatus"] = intval(substr($updSelect, 13)); | 
|     } else if (substr($updSelect, 0, 9) == "Recommend") { | 
|         $set["Recommend"] = intval(substr($updSelect, 9)); | 
|     } | 
|     // echo "set: ", json_encode($set), "<br/>"; | 
|     if (count($set) > 0) { | 
|         if (!\DBOper\Update("GameServers", $find, $set, false, false, true)) { | 
|             $alertMsg = "批量更新服务器失败!"; | 
|             \Logging\LogError($alertMsg . " find=" . json_encode($find) . " set=" . json_encode($set)); | 
|         } else { | 
|             $alertMsg = "批量更新服务器成功!"; | 
|             \Logging\LogInfo($alertMsg . " find=" . json_encode($find) . " set=" . json_encode($set)); | 
|             \ServerOPS\RefreshServerListIni($channel); | 
|         } | 
|         echo "<script>alert('" . $alertMsg . "')</script>"; | 
|     } | 
| } else { | 
|     $isSearch = false; | 
| } | 
|   | 
| $pageLimit = 50; # 默认仅展示最近服务器数 | 
| if ($isSearch) { | 
|     $pageLimit = 0; # 搜索的直接显示全部,暂不做分页 | 
| } | 
|   | 
| \DBOper\Find("GameServers", $find, $serverList, null, array("JsonBranch" => 1, "ServerID" => -1), $pageLimit); | 
| $totalCount = count($serverList); | 
| if (!$isSearch && $totalCount == $pageLimit) { | 
|     $totalCount = \DBOper\Count("GameServers", $find); | 
| } | 
|   | 
| // echo "_POST: ", print_r($_POST, true), "<br/>"; | 
| // echo "find: ", json_encode($find), "<br/>"; | 
| // echo "allVersionInfo:", print_r($allVersionInfo, true), "<br/>"; | 
| // echo "branchNameInfo:", print_r($branchNameInfo, true), "<br/>"; | 
|   | 
| //显示表格字段配置 key-参数名,value-说明 | 
| $tableArray = array( | 
|     "ServerID" => array("区服", "5%", "center"), | 
|     "ServerName" => array("名称", "10%", "center"), | 
|     "JsonBranch" => array("导出Json分支文件", "14%", "center"), | 
|     "StartDate" => array("开服时间", "11%", "center"), | 
|     "ClearState" => array("清档状态", "5%", "center"), | 
|     "Statue" => array("开放状态", "5%", "center"), | 
|     "RunningStatus" => array("运行状态", "5%", "center"), | 
|     "Recommend" => array("推荐", "3%", "center"), | 
|     "RegionDomain" => array("域名", "19%", "center"), | 
|     "LoginPort" => array("登录端口", "5%", "center"), | 
|     "GamePort" => array("游戏端口", "5%", "center"), | 
|     "MainServerID" => array("所属主服", "5%", "center"), | 
|     "" => array("操作", ""), | 
| ); | 
|   | 
| ?> | 
|   | 
| <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"> | 
|     <link rel="stylesheet" type="text/css" href="/css/button.css"> | 
| </head> | 
|   | 
| <body> | 
|     <center> | 
|         <p><b>服务器列表</b></P> | 
|     </center> | 
|   | 
|     <form id="serverlist" action="serverlist.php" method="post"> | 
|         开启状态: | 
|         <select name="Statue" id="Statue"> | 
|             <?php | 
|             foreach (array($all => "全部") +  \ServerOPS\ServerStatue::$StatueName as $key => $value) { | 
|                 echo "<option value=\"" . $key . "\""; | 
|                 if ($Statue == $key . "") { | 
|                     echo " selected"; | 
|                 } | 
|                 echo ">" . $value . "</option>"; | 
|             } | 
|             ?> | 
|         </select> | 
|            | 
|         运行状态: | 
|         <select name="RunningStatus" id="RunningStatus"> | 
|             <?php | 
|             foreach (array($all => "全部") + \ServerOPS\ServerRunningStatus::$RunningStatusName as $key => $value) { | 
|                 echo "<option value=\"" . $key . "\""; | 
|                 if ($RunningStatus == $key . "") { | 
|                     echo " selected"; | 
|                 } | 
|                 echo ">" . $value . "</option>"; | 
|             } | 
|             ?> | 
|         </select> | 
|            | 
|         推荐状态: | 
|         <select name="Recommend" id="Recommend"> | 
|             <?php | 
|             foreach (array($all => "全部", "1" => "是", "0" => "否") as $key => $value) { | 
|                 echo "<option value=\"" . $key . "\""; | 
|                 if ($Recommend == $key . "") { | 
|                     echo " selected"; | 
|                 } | 
|                 echo ">" . $value . "</option>"; | 
|             } | 
|             ?> | 
|         </select> | 
|           <input type="button" value="添加服务器ID条件" onclick="AddServerIDCondition('', '', '')" /> | 
|           <input type="button" value="重置条件" onclick="ResetCondition()" /> | 
|           <input type="submit" name="submitsearch" value="搜索" class="button green medium" /> | 
|         <div id="ServerIDCondition"></div> | 
|         <hr /> | 
|         <input type="button" value="新建服务器" onclick="window.location.href='serverEdit.php?opType=add'" /> | 
|         <input type="button" value="区服分组" onclick="window.location.href='serverGroup.php'" /> | 
|         <input type="button" value="刷新选服列表" onclick="window.location.href='refreshServerJson.php'" /> | 
|              | | 
|               | 
|         </select> | 
|            | 
|         <?php | 
|         echo "<select name=\"updSelect\" onchange=\"CheckUpdMulti(this)\">"; | 
|         echo "<option value=\"\">全部设置为</option>"; | 
|         echo "<optgroup label=\"开启状态\">"; | 
|         foreach (\ServerOPS\ServerStatue::$StatueName as $key => $value) { | 
|             echo "<option value=\"Statue" . $key . "\">" . $value . "</option>"; | 
|         } | 
|         echo "</optgroup>"; | 
|         echo "<optgroup label=\"运行状态\">"; | 
|         foreach (\ServerOPS\ServerRunningStatus::$RunningStatusName as $key => $value) { | 
|             echo "<option value=\"RunningStatus" . $key . "\">" . $value . "</option>"; | 
|         } | 
|         echo "</optgroup>"; | 
|         echo "<optgroup label=\"推荐状态\">"; | 
|         foreach (array("1" => "是", "0" => "否") as $key => $value) { | 
|             echo "<option value=\"Recommend" . $key . "\">" . $value . "</option>"; | 
|         } | 
|         echo "</optgroup>"; | 
|         echo "</select>"; | 
|         ?> | 
|            | 
|         <input type="submit" name="submitSetMainServerID" value="批量设置主服ID" onclick="return CheckUpdMulti(this)" /> | 
|         <input type="number" name="SetMainServerID" id="SetMainServerID" value="" placeholder="填入合服主服ID" /> | 
|         <input type="checkbox" name="SetMainServerDomain" id="SetMainServerDomain" <?php echo $_POST["SetMainServerDomain"] ? "checked" : ""  ?> />同步修改为主服地址 | 
|         <hr /> | 
|         <table width="100%"> | 
|             <?php | 
|             if ($serverList) { | 
|                 if ($isSearch) { | 
|                     echo "<caption>符合条件服务器总数: " . count($serverList) . "</caption>"; | 
|                 } else { | 
|                     echo "<caption>服务器数: " . count($serverList) . "/" . $totalCount . "</caption>"; | 
|                 } | 
|                 echo "<thead><tr>"; | 
|                 foreach ($tableArray as $value) { | 
|                     echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>"; | 
|                 } | 
|                 echo "</tr></thead>"; | 
|             } else { | 
|                 echo "无满足条件服务器!<br/>"; | 
|             } | 
|   | 
|             foreach ($serverList as $serverInfo) { | 
|                 echo "<tr class='trc'>"; | 
|                 $ServerID = $serverInfo["ServerID"]; | 
|                 $ServerName = $serverInfo["ServerName"]; | 
|                 foreach ($tableArray as $key => $value) { | 
|                     if (!$key) { | 
|                         echo "<td align='center'>"; | 
|                         echo " <input type=\"button\" value=\"改\" onclick=\"window.location.href='serverEdit.php?opType=upd&ServerID=$ServerID'\" />"; | 
|                         echo " <input type=\"button\" value=\"删\" onclick=\"return suredel('$channel', '$ServerID', '$ServerName')\"/> "; | 
|                         echo "</td>"; | 
|                         continue; | 
|                     } | 
|   | 
|                     $tdContent = $serverInfo[$key]; | 
|                     if ($key == "ServerID") { | 
|                         $tdContent = "s" . $tdContent; | 
|                     } else if ($key == "ClearState") { | 
|                         if ($tdContent == 1) { | 
|                             $tdContent = "已同步"; | 
|                         } else { | 
|                             $tdContent = "<font color='red'>未处理</font>"; | 
|                         } | 
|                     } else if ($key == "Statue") { | 
|                         $statue = $tdContent; | 
|                         $statueName = \ServerOPS\ServerStatue::$StatueName[$statue]; | 
|                         if ($statue != \ServerOPS\ServerStatue::Open) { | 
|                             $tdContent = "<font color='red'>" . $statueName . "</font>"; | 
|                         } else { | 
|                             $tdContent = $statueName; | 
|                         } | 
|                     } else if ($key == "RunningStatus") { | 
|                         $runningStatus = $tdContent; | 
|                         $runningStatusName = \ServerOPS\ServerRunningStatus::$RunningStatusName[$runningStatus]; | 
|                         if ($runningStatus == \ServerOPS\ServerRunningStatus::PreOpen || $runningStatus == \ServerOPS\ServerRunningStatus::Upkeep) { | 
|                             $tdContent = "<font color='red'>" . $runningStatusName . "</font>"; | 
|                         } else { | 
|                             $tdContent = $runningStatusName; | 
|                         } | 
|                     } else if ($key == "Recommend") { | 
|                         $tdContent = $tdContent == 1 ? "是" : "否"; | 
|                     } elseif ($key == "JsonBranch") { | 
|                         $tdContent = \ServerOPS\GetCommonServerlistJsonFileName($channel, $tdContent); | 
|                     } elseif ($key == "StartDate") { | 
|                         $OpenServerWay = $serverInfo["OpenServerWay"]; | 
|                         $RelationServerID = $serverInfo["RelationServerID"]; | 
|                         $RelationCreateRoles = $serverInfo["RelationCreateRoles"]; | 
|                         if ($OpenServerWay == 1 && $RelationServerID && $RelationCreateRoles && !$serverInfo["ClearState"]) { | 
|                             $tdContent = "指定服:" . $RelationServerID . " 创角:" . $RelationCreateRoles; | 
|                         } else { | 
|                             $tdContent = $tdContent; | 
|                         } | 
|                     } | 
|                     echo "<td align='" . $value[2] . "' style=\"display:table-cell; vertical-align:middle\">" . $tdContent . "</td>"; | 
|                 } | 
|                 echo "</tr>"; | 
|             } | 
|             ?> | 
|         </table> | 
|     </form> | 
|     <script type='text/javascript' src="/js/common.js"></script> | 
|     <script type="text/javascript"> | 
|         var serverIDCondNum = 0; // 服务器ID条件编号 | 
|   | 
|         window.onload = function() { | 
|             var serverIDCondList = JSON.parse('<?php echo json_encode($serverIDCondArray); ?>'); | 
|             for (let index = 0; index < serverIDCondList.length; index++) { | 
|                 const cond = serverIDCondList[index]; | 
|                 const eValue = cond[0] > 0 ? cond[0] : ""; | 
|                 const gteValue = cond[1] > 0 ? cond[1] : ""; | 
|                 const lteValue = cond[2] > 0 ? cond[2] : ""; | 
|                 AddServerIDCondition(eValue, gteValue, lteValue); | 
|             } | 
|         } | 
|   | 
|         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, ServerID, ServerName) { | 
|             var br = getbr(); | 
|             if (!window.confirm("删除服务器建议设置为不开放即可!" + br + "确定直接删除【" + Channel + "】服务器【" + ServerName + "】?")) { | 
|                 return false; | 
|             } | 
|             doPost("serverlist.php", { | 
|                 "opType": "del", | 
|                 "ServerID": ServerID, | 
|             }); | 
|             return true; | 
|         } | 
|   | 
|         function AddServerIDCondition(eValue, gteValue, lteValue) { | 
|             var numMax = parseInt("<?php echo $serverIDCondNumMax ?>"); | 
|             if (serverIDCondNum >= numMax) { | 
|                 alert("服务器ID条件超过最大个数: " + numMax); | 
|                 return; | 
|             } | 
|             serverIDCondNum += 1; | 
|             var serverIDCondition = "<div id=\"ServerIDCond" + serverIDCondNum + "\">" + | 
|                 "服务器ID条件" + (serverIDCondNum < 10 ? "  " + serverIDCondNum : serverIDCondNum) + " => " + | 
|                 "  等于: " + "<input type=\"number\" name=\"ServerIDE" + serverIDCondNum + "\"" + | 
|                 " id=\"ServerIDE" + serverIDCondNum + "\" value=\"" + eValue + "\" min=\"0\" style=\"width: 60px\" />" + | 
|                 "  大于等于: " + "<input type=\"number\" name=\"ServerIDGTE" + serverIDCondNum + "\"" + | 
|                 " id=\"ServerIDGTE" + serverIDCondNum + "\" value=\"" + gteValue + "\" min=\"0\" style=\"width: 60px\" />" + | 
|                 "  小于等于: " + "<input type=\"number\" name=\"ServerIDLTE" + serverIDCondNum + "\"" + | 
|                 " id=\"ServerIDLTE" + serverIDCondNum + "\" value=\"" + lteValue + "\" min=\"0\" style=\"width: 60px\" />" + | 
|                 "  <a href=\"javascript:DelServerIDCondition(" + serverIDCondNum + ")\">删除</a>"; | 
|             "</div>"; | 
|             document.getElementById("ServerIDCondition").insertAdjacentHTML("beforeEnd", serverIDCondition); | 
|         } | 
|   | 
|         function DelServerIDCondition(delNum) { | 
|             document.getElementById("ServerIDCondition").removeChild(document.getElementById("ServerIDCond" + delNum)); | 
|         } | 
|   | 
|         function ResetCondition() { | 
|             set_select_checked("Statue", '<?php echo $all; ?>'); | 
|             set_select_checked("RunningStatus", '<?php echo $all; ?>'); | 
|             set_select_checked("Recommend", '<?php echo $all; ?>'); | 
|             document.getElementById("ServerIDCondition").innerHTML = ""; | 
|             serverIDCondNum = 0; | 
|         } | 
|   | 
|         function set_select_checked(selectId, checkValue) { | 
|             var select = document.getElementById(selectId); | 
|             for (var i = 0; i < select.options.length; i++) { | 
|                 if (select.options[i].value == checkValue) { | 
|                     select.options[i].selected = true; | 
|                     break; | 
|                 } | 
|             } | 
|         } | 
|   | 
|         function CheckUpdMulti(obj) { | 
|             var br = getbr(); | 
|             var setStr = ""; | 
|             if (obj.name == "updSelect") { | 
|                 var value = obj.value; | 
|                 if (!value) { | 
|                     return false; | 
|                 } | 
|                 if (value.substr(0, 6) == "Statue") { | 
|                     setStr = "开放状态:" + obj.options[obj.selectedIndex].text; | 
|                 } else if (value.substr(0, 13) == "RunningStatus") { | 
|                     setStr = "运行状态:" + obj.options[obj.selectedIndex].text; | 
|                 } else if (value.substr(0, 9) == "Recommend") { | 
|                     setStr = "推荐状态:" + obj.options[obj.selectedIndex].text; | 
|                 } else { | 
|                     alert("无效设置项!"); | 
|                     return false; | 
|                 } | 
|             } else if (obj.name == "submitSetMainServerID") { | 
|                 var SetMainServerID = document.getElementById("SetMainServerID").value; | 
|                 if (!SetMainServerID || SetMainServerID < 0) { | 
|                     alert("请输入大于等于0的所属主服ID!"); | 
|                     document.getElementById('SetMainServerID').focus(); | 
|                     return false; | 
|                 } | 
|                 setStr = "合服主服ID: " + SetMainServerID; | 
|                 if (document.getElementById("SetMainServerDomain").checked) { | 
|                     setStr += "?" + br + "并同步修改为主服地址"; | 
|                 } | 
|             } else { | 
|                 alert("未知批量更新操作控件: " + obj.name + " type:" + obj.type); | 
|                 return false; | 
|             } | 
|   | 
|             let gteValue, lteValue; | 
|             var serverCondStr = ""; | 
|             var numMax = parseInt("<?php echo $serverIDCondNumMax ?>"); | 
|             for (let index = 1; index < numMax + 1; index++) { | 
|                 if (!document.getElementById("ServerIDGTE" + index)) { | 
|                     continue; | 
|                 } | 
|                 eValue = parseInt(document.getElementById("ServerIDE" + index).value); | 
|                 gteValue = parseInt(document.getElementById("ServerIDGTE" + index).value); | 
|                 lteValue = parseInt(document.getElementById("ServerIDLTE" + index).value); | 
|                 eValue = (isNaN(eValue) || eValue < 0) ? 0 : eValue; | 
|                 gteValue = (isNaN(gteValue) || gteValue < 0) ? 0 : gteValue; | 
|                 lteValue = (isNaN(lteValue) || lteValue < 0) ? 0 : lteValue; | 
|                 if (eValue <= 0 && gteValue <= 0 && lteValue <= 0) { | 
|                     continue; | 
|                 } | 
|                 if (gteValue > 0 && lteValue > 0 && gteValue > lteValue) { | 
|                     alert("服务器ID“大于等于值”不能小于“小于等于值”!"); | 
|                     document.getElementById("ServerIDLTE" + index).focus(); | 
|                     return false; | 
|                 } | 
|                 if (serverCondStr != "") { | 
|                     // serverCondStr += "或"; | 
|                 } | 
|                 serverCondStr += "服务器ID "; | 
|                 if (eValue > 0) { | 
|                     serverCondStr += eValue; | 
|                 } | 
|                 if (gteValue > 0 || lteValue > 0) { | 
|                     if (eValue > 0) { | 
|                         serverCondStr += " , "; | 
|                     } | 
|                     if (gteValue > 0 && lteValue > 0) { | 
|                         serverCondStr += gteValue + " ~ " + lteValue; | 
|                     } else if (gteValue > 0) { | 
|                         serverCondStr += ">=" + gteValue; | 
|                     } else { | 
|                         serverCondStr += "<=" + lteValue; | 
|                     } | 
|                 } | 
|                 serverCondStr += br; | 
|             } | 
|             var StatueSelect = document.getElementById("Statue"); | 
|             var RunningStatusSelect = document.getElementById("RunningStatus"); | 
|             var RecommendSelect = document.getElementById("Recommend"); | 
|   | 
|             var confimStr = "" | 
|             confimStr += "开启状态: " + StatueSelect.options[StatueSelect.selectedIndex].text + br; | 
|             confimStr += "运行状态: " + RunningStatusSelect.options[RunningStatusSelect.selectedIndex].text + br; | 
|             confimStr += "推荐状态: " + RecommendSelect.options[RecommendSelect.selectedIndex].text + br; | 
|             confimStr += serverCondStr; | 
|             confimStr += br + "确定将以上条件服务器设置为 => " + setStr + "?"; | 
|   | 
|             if (!window.confirm(confimStr)) { | 
|                 return false; | 
|             } | 
|             if (obj.type != "submit") { | 
|                 var form = document.getElementById("serverlist"); | 
|                 form.submit(); | 
|             } | 
|             return true; | 
|         } | 
|     </script> | 
| </body> | 
|   | 
| </html> |