This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

283 lines
9.3 KiB
PHP

<?php
//------------------------------- 负载管理
header("Content-type: text/html; charset=utf-8");
if(THIS_IN!="edt_admin")
exit("错误的访问!");
$msg_login_user=get_db_msg("select * from ".$table_pre."user where id='".$uid."'");
//---------priv
$priv=return_priv($_m,$msg_login_user["priv"]);
$json_data="{";
if($priv[0]=="n"){
//没有操作权限
$json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
}else{
$json_data.="\"uid\":".$uid.",";
$fwqz="";
foreach($sys_fz_line as $k => $v) {
$fwqz.="{\"value\":\"".$v."\",\"title\":\"".$v."\"},";
}
if($fwqz){
$json_data.="\"fz\":[".deel_end($fwqz)."],";
$json_data.="\"s_fz\":\"".$s_fz."\",";
}
//有权限
switch($_a){
case "add":
//--------------------------新增
if($id){
$msg=get_db_msg("select * from ".$table_pre."servers where id='".$id."'");
//
$s_group=$msg["s_group"];
$ord=$msg["ord"];
$ip=$msg["ip"];
$limit_num=$msg["limit_num"];
}else{
//ord
$tmp=get_db_msg("select max(ord) 'num' from ".$table_pre."servers");
$s_group="";
if($tmp[num]>0)
$ord=$tmp[num]+1;
else
$ord=1;
$ip="192.168.1.3";
$limit_num=200;
}
$json_data.="\"ord\":\"".$ord."\",\"ip\":\"".$ip."\",\"limit_num\":\"".$limit_num."\",\"s_group\":\"".$s_group."\",";
break;
case "save_add":
$tmplast=substr($ip, -1);
if($tmplast=="/"){
$ip=substr($ip,0, strlen($ip)-1);
}
if(strpos($ip,"http://") !== false){
$ip=substr($ip, 7);
}
if(strpos($ip,"https://") !== false){
$ip=substr($ip, 8);
}
if($id){
$msg=get_db_msg("select * from ".$table_pre."servers where id='".$id."'");
$log_action="修改";
if($fwqz){
$query="update ".$table_pre."servers set ord='".$ord."',ip='".$ip."',limit_num='".$limit_num."',s_group='".$s_fz."' where id='".$id."'";
}else{
$query="update ".$table_pre."servers set ord='".$ord."',ip='".$ip."',limit_num='".$limit_num."' where id='".$id."'";
}
$json_data.="\"code\":1,";
}else{
$log_action="新增";
if($fwqz){
$query="insert into ".$table_pre."servers (ord,ip,limit_num,s_group) values ('".$ord."','".$ip."','".$limit_num."','".$s_fz."')";
}else{
$query="insert into ".$table_pre."servers (ord,ip,limit_num) values ('".$ord."','".$ip."','".$limit_num."')";
}
$json_data.="\"code\":1,";
}
$db->query($query);
set_log($log_action."服务器",$text);
break;
case "add2":
//--------------------------新增2
if($id){
$msg=get_db_msg("select * from ".$table_pre."servers_online where id='".$id."'");
//
$ip=$msg["client_ip"];
$server_ip=$msg["server_ip"];
}
$json_data.="\"ip\":\"".$ip."\",\"server_ip\":\"".$server_ip."\",";
break;
case "save_add2" :
if($id){
$msg=get_db_msg("select * from ".$table_pre."servers_online where id='".$id."'");
if($msg["server_ip"]!=$server_ip){
$query="update ".$table_pre."servers_online set server_ip='".$server_ip."' where id='".$id."'";
$db->query("delete from ".$table_pre."session where ip='".$msg["client_ip"]."'");
$json_data.="\"code\":1,";
}
}
$db->query($query);
//echo $query."<br>";
set_log("修改负载均衡",$msg["client_ip"]);
break;
case "kickout" :
$tmp=get_db_msg("select * from ".$table_pre."servers_online where id='".$id."'");
$lid=$tmp["client_ip"];
$db->query("delete from ".$table_pre."servers_online where id='".$id."'");
set_log("删除负载均衡",$lid);
//url_redirect();
break;
case "kickout_pl" :
$num=count($id);
if($num==0)
alert_and_back("请至少选择一条记录!");
for($i=0;$i<$num;$i++){
$tmp=get_db_msg("select * from ".$table_pre."servers_online where id='".$id[$i]."'");
$db->query("delete from ".$table_pre."servers_online where id='".$id[$i]."'");
$lid.=$tmp["client_ip"].", ";
}
$lid=substr($lid,0,-2);
set_log("批量删除负载均衡",$lid);
//url_redirect();
break;
case "kickout_all" :
$db->query("delete from ".$table_pre."servers_online");
$db->query("delete from ".$table_pre."session");
set_log("清空负载均衡");
//url_redirect();
break;
case "kickout_60" :
$check_time=60*60;
$now1=time()-$check_time;
$db->query("delete from ".$table_pre."servers_online where add_date<".$now1);
$db->query("delete from ".$table_pre."session where lastactivity<".$now1);
set_log("清空1小时未操作的负载均衡");
//url_redirect();
break;
case "kickout_30" :
$check_time=30*60;
$now1=time()-$check_time;
$db->query("delete from ".$table_pre."servers_online where add_date<".$now1);
$db->query("delete from ".$table_pre."session where lastactivity<".$now1);
set_log("清空半小时未操作的负载均衡");
//url_redirect();
break;
case "del":
$id=(is_array($id))?$id:array($id);
$num=count($id);
for($i=0;$i<$num;$i++){
$db->query("delete from ".$table_pre."servers where id='".$id[$i]."'");
}
$json_data.="\"code\":1,";
break;
default :
//-----------------------tab
$s_cate=$s_cate?$s_cate:"fwq";
$json_data.="\"s_cate\":\"".$s_cate."\",";
$str_tab="";
$str_tab.="{\"no\":\"fwq\",\"title\":\"服务器管理\"},{\"no\":\"fz\",\"title\":\"负载均衡表\"},";
$str_tab=deel_end($str_tab);
$json_data.="\"tab\":[".$str_tab."],";
//-----------------------/tab
if($s_cate=="fwq"){
//
//
$sql_con="";
if($s_fz){
$sql_con.=" and s_group='".$s_fz."' ";
}
/*if($s_date_start){
$tt=explode("-",$s_date_start);
$stamp=mktime(0,0,0,$tt[1],$tt[2],$tt[0]);
$sql_con.="and add_date>='".$stamp."' ";
}
if($s_date_end){
$tt=explode("-",$s_date_end);
$stamp=mktime(23,59,59,$tt[1],$tt[2],$tt[0]);
$sql_con.=" and add_date<='".$stamp."' ";
}
if($s_ip)
$sql_con.="and ip like '%".$s_ip."%' ";
if($s_action){
$sql_con.=" and action='".$s_action."'";
}
if($s_uidd){
$sql_con.=" and uid='".$s_uidd."'";
}*/
//取得总数
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."servers where id>0".$sql_con);
$total_num=$tmp["num"];
$query="select * from ".$table_pre."servers where id>0".$sql_con." order by ord,ip ";
//echo $query."<br>";
$res=$db->query($query);
$count=0;
$json_data.="\"code\":0,\"msg\":\"\",\"count\":".$total_num.",\"data\":[";
$str_tmp="";
$hj1=$hj2=0;
while($msg=$db->fetch_array($res)){
//取得在线用户数
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."session where server_ip='".$msg["ip"]."'");
$t_num_zx=$tmp["num"];
$t_num_lj=$msg["num"];
$t_s_group=$msg["s_group"];
$t_num_limit=$msg["limit_num"];
$list=$count_first+$count+1;
$str_tmp.="{";
$str_tmp.="\"s_cate\":\"".$s_cate."\",";
$str_tmp.="\"id\":\"".$msg["id"]."\",";
$str_tmp.="\"ord\":\"".$msg["ord"]."\",";
$str_tmp.="\"ip\":\"".$msg["ip"]."\",";
$str_tmp.="\"zx\":\"".$t_num_zx."\",";
$str_tmp.="\"lj\":\"".$t_num_lj."\",";
$str_tmp.="\"s_group\":\"".$t_s_group."\",";
$str_tmp.="\"limit\":\"".$t_num_limit."\"";
$str_tmp.="},";
$count++;
$hj1+=$t_num_zx;
$hj2+=$t_num_lj;
}
$json_data.=substr($str_tmp,0,-1)."],";
}else{
$sql_con=$sql_con1="";
if($s_fz){
$sql_con1.=" and s_group='".$s_fz."' ";
$query="select * from ".$table_pre."servers where id>0".$sql_con1." order by ord,ip ";
$res=$db->query($query);
$tmpfwq="";
while($msg=$db->fetch_array($res)){
$tmpfwq.="'".$msg["ip"]."',";
}
if($tmpfwq){
$sql_con.=" and server_ip in (".deel_end($tmpfwq).")";
}else{
$sql_con.=" and server_ip=''";
}
}
if($s_ip || $s_server_ip){
if($s_ip)
$sql_con.=" and client_ip like '%".$s_ip."%'";
if($s_server_ip)
$sql_con.=" and server_ip like '%".$s_server_ip."%'";
}
$page=$page>0?$page:1;
$limit=$limit>0?$limit:10;
$start=($page-1)*$limit;
$end=$limit;
//取得服务器
$op="";
$r1=$db->query("select * from ".$table_pre."servers order by ord");
while($m1=$db->fetch_array($r1)){
$xx1.="{\"ip\":\"".$m1["ip"]."\"},";
}
//取得总数
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."servers_online where add_date>0 ".$sql_con);
$total_num=$tmp["num"];
$query="select * from ".$table_pre."servers_online where add_date>0 ".$sql_con."order by id limit ".$start.",".$end;
//echo $query."<br>";
$res=$db->query($query);
$count=0;
while($msg=$db->fetch_array($res)){
$list=$count_first+$count+1;
$tmp=get_db_msg("select * from ".$table_pre."session where ip='".$msg["client_ip"]."'");
if($tmp["id"]>0){
$tmp1=get_db_msg("select * from ".$table_pre."client where id='".$tmp["uid"]."'");
$utitle=($tmp1["id"]>0)?$tmp1["title"]."(".$tmp1["username"].")":"";
}else{
$utitle="";
}
$json_data1.="{\"id\":\"".$msg["id"]."\",\"list\":\"".$list."\",\"s_ip\":\"".$msg["client_ip"]."\",\"user\":\"".$utitle."\",\"fwq_ip\":\"".$msg["server_ip"]."\",\"add_date\":\"".date("Y/n/j H:i:s",$msg["add_date"])."\"},";
$count++;
}
$json_data.="\"xx1\":\"".$s_server_ip."\",\"xuanxiang1\":[".substr($xx1,0,-1)."],\"code\":0,\"msg\":\"\",\"count\":".$total_num.",\"data\":[".substr($json_data1,0,-1)."],";
}
break;
}
}
$json_data=substr($json_data,0,-1)."}";
echo $json_data;
?>