HavePermission($Permission)) {
exit;
}
$UserAccount = $_SESSION['UserAccount'];
$all = "all";
$Statue = \ServerOPS\ServerStatue::Open; // 开放状态固定只针对已开放的
$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, "
";
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)) {
}
// 设置状态
elseif (array_key_exists("updSelect", $_POST) && $_POST["updSelect"] != "") {
$set = array();
$updSelect = $_POST["updSelect"];
if (substr($updSelect, 0, 9) == "Recommend") {
$set["Recommend"] = intval(substr($updSelect, 9));
}
// echo "set: ", json_encode($set), "
";
if (count($set) > 0) {
if (!\DBOper\Update("GameServers", $find, $set, false, false, true)) {
$alertMsg = \Lang\gettext("批量更新服务器失败");
\Logging\LogError($alertMsg . " find=" . json_encode($find) . " set=" . json_encode($set));
} else {
$alertMsg = \Lang\gettext("批量更新服务器成功");
\Logging\LogInfo($alertMsg . " find=" . json_encode($find) . " set=" . json_encode($set));
\ServerOPS\RefreshServerListIni($channel);
$logPost = $_POST;
$logPost["serverIDCondArray"] = $serverIDCondArray;
AddSuccessLog($channel, $UserAccount, $Permission, $logPost, $set);
}
echo "";
}
} 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), "
";
// echo "find: ", json_encode($find), "
";
//显示表格字段配置 key-参数名,value-说明
$tableArray = array(
"ServerID" => array(\Lang\gettext("区服"), "10%", "center"),
"ServerName" => array(\Lang\gettext("名称"), "15%", "center"),
"StartDate" => array(\Lang\gettext("开服时间"), "15%", "center"),
"Statue" => array(\Lang\gettext("开放状态"), "10%", "center"),
"RunningStatus" => array(\Lang\gettext("运行状态"), "10%", "center"),
"Recommend" => array(\Lang\gettext("推荐"), "10%", "center"),
"MainServerID" => array(\Lang\gettext("所属主服"), "10%", "center"),
);
?>