⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 saveconfig.php

📁 很不错的php聊天室源码,提供给大家学习
💻 PHP
📖 第 1 页 / 共 2 页
字号:
			$isSameName = $db->result($db->query("select count(*) from `rooms` where `room_name`='{$_POST["roomname"]}'"),0,"count(*)");
			if($isSameName)
			{
				header("location:../notice.php?id=".same_chatroom_name);
				exit;
			}
			if(count(explode(",",$_POST["masters"]))>10)
			{
				header("location:../notice.php?id=".more_masters);
				exit;
			}
			$db->query("insert into `rooms` set `room_name` = '{$_POST["roomname"]}',`maxonline` = '{$_POST["maxonline"]}',`grade` = '{$_POST["grade"]}',`masters` = '{$_POST["masters"]}',`inuse`='{$_POST["inuse"]}'");
			header("location:../notice.php?id=".add_room_ok);
			break;
		case "edit":
			if(count(explode(",",$_POST["masters"]))>10)
			{
				header("location:../notice.php?id=".more_masters);
				exit;
			}
			$db->query("update `rooms` set `room_name` = '{$_POST["roomname"]}',`maxonline` = '{$_POST["maxonline"]}',`grade` = '{$_POST["grade"]}',`masters` = '{$_POST["masters"]}',`inuse` = '{$_POST["inuse"]}' where `id` = '{$_POST["roomid"]}'");
			header("location:../notice.php?id=".edit_room_ok);
			break;
		case "delete":
			if($db->result($db->query("select count(*) from `rooms`"),0,"count(*)")==1)
			{
				header("location:../notice.php?id=".only_one_room);
				exit;
			}
			$db->query("delete from `rooms` where `id` = '{$_POST["roomid"]}'");
			header("location:../notice.php?id=".delete_room_ok);
			break;
		default:
			header("../notice.php?id=".action_not_define);
			break;
	}
	$db->close();
	exit;
}
if($_GET["w"]=="ip")
{
	$db = new db_query;
	$db->connect();
	$ipid = $_POST["ipid"];
	if($_POST["sort"]=="manage")
	{
		if($_POST["act"]=="unlock")
		{
			for($i=0;$i<count($ipid);$i++)
			{
				$theipid = $ipid[$i];
				$db->query("insert into `logs` set `tags` = '".$db->result($db->query("select `ip` from `lockedip` where `id` = '{$theipid}'"),0,"ip")."',`manager` = '聊天室管理员',`time` = '".date("Y-m-d H:i:s")."',`action` = '".msg_unlock."',`type` = '".logtype_manage."',`why` = '".$_POST["why"]."'");
				$db->query("delete from `lockedip` where `id` = {$theipid}");
			}
			header("location:../notice.php?id=".unlock_ip_ok);
			exit;
		}
		if($_POST["act"]=="lock")
		{
			for($i=0;$i<count($ipid);$i++)
			{
				$db->query("update `lockedip` set `always` = 1 where `id` = '{$ipid[$i]}'");
			}
			header("location:../notice.php?id=".always_lock_ip_ok);
			exit;
		}
		exit;
	}
	if($_POST["sort"]=="lock")
	{
		$ip = $_POST["ip"];
		if($db->result($db->query("select count(*) from `lockedip` where `ip` = '{$ip}'"),0,"count(*)"))
		{
			header("location:../notice.php?id=".locked_ip_fail);
			exit;
		}
		$always = $_POST["always"];
		if($always=="")
		{
			$always = 0;
		}
		$db->query("insert into `lockedip` set `ip` = '{$ip}',`time` = '".date("Y-m-d H:i:s")."',`locktime` = '".time()."',`always` = '{$always}'");
		$db->query("insert into `logs` set `user` = '{$ip}',`manager` = '聊天室管理员',`time` = '".date("Y-m-d H:i:s")."',`action` = 30,`type` = '".logtype_manage."',`why` = '".$_POST["why"]."'");
		header("location:../notice.php?id=".locked_ip_ok);
	}
	$db->close();
	exit;
}
if($_GET["w"]=="user")
{
	$db = new db_query;
	$db->connect();
	switch($_POST["act"])
	{
		case "forbid":
			if($db->result($db->query("select count(*) from `members` where `username` ='{$_POST["username"]}'"),0,"count(*)"))
			{
				$db->query("update `members` set `forbid` = 1 where `username` = '{$_POST["username"]}'");
				//写进日志
				$db->query("insert into `logs` set `user` = '{$_POST["username"]}',`manager` = '聊天室管理员',`time` = '".date("Y-m-d H:i:s")."',`action` = '".msg_forbid."',`type` = '".logtype_names."',`why` = '".$_POST["why"]."'");
				header("location:../notice.php?id=".forbid_ok);
			}
			else
			{
				header("location:../notice.php?id=".cant_find_user);
			}
			break;
		case "unforbid":
			$userid = $_POST["userid"];
			for($i=0;$i<count($userid);$i++)
			{
				$ui = $userid[$i];
				$db->query("update `members` set `forbid` = 0 where `id` = '{$ui}'");
				//写进日志
				$db->query("insert into `logs` set `user` = '".$db->result($db->query("select `username` from `members` where `id` = '{$ui}'"),0,"username")."',`manager` = '聊天室管理员',`time` = '".date("Y-m-d H:i:s")."',`action` = '".msg_unforbid."',`type` = '".logtype_names."',`why` = '".$_POST["why"]."'");
			}
			header("location:../notice.php?id=".unforbid_ok);
			break;
		case "protec":
			if($db->result($db->query("select count(*) from `members` where `username` ='{$_POST["username"]}'"),0,"count(*)"))
			{
				$db->query("update `members` set `protected` = 1 where `username` = '{$_POST["username"]}'");
				//写进日志
				$db->query("insert into `logs` set `user` = '{$_POST["username"]}',`manager` = '聊天室管理员',`time` = '".date("Y-m-d H:i:s")."',`action` = '".msg_protec."',`type` = '".logtype_names."',`why` = '".$_POST["why"]."'");
				header("location:../notice.php?id=".protected_ok);
			}
			else
			{
				header("location:../notice.php?id=".cant_find_user);
			}
			break;
		case "unprotec":
			$userid = $_POST["userid"];
			for($i=0;$i<count($userid);$i++)
			{
				$ui = $userid[$i];
				$db->query("update `members` set `protected` = 0 where `id` = '{$ui}'");
				$db->query("insert into `logs` set `user` = '".$db->result($db->query("select `username` from `members` where `id` = '{$ui}'"),0,"username")."',`manager` = '聊天室管理员',`time` = '".date("Y-m-d H:i:s")."',`action` = '".msg_unprotec."',`type` = '".logtype_names."',`why` = '".$_POST["why"]."'");
			}
			header("location:../notice.php?id=".unprotected_ok);
			break;
		case "unupgrade":
			if($db->result($db->query("select count(*) from `members` where `username` ='{$_POST["username"]}'"),0,"count(*)"))
			{
				$db->query("update `members` set `upgrade` = 0 where `username` = '{$_POST["username"]}'");
				$db->query("insert into `logs` set `user` = '{$_POST["username"]}',`manager` = '聊天室管理员',`time` = '".date("Y-m-d H:i:s")."',`action` = '".msg_ungrade."',`type` = '".logtype_names."',`why` = '".$_POST["why"]."'");
				header("location:../notice.php?id=".unupgrade_ok);
			}
			else
			{
				header("location:../notice.php?id=".cant_find_user);
			}
			break;
		case "upgrade":
			$userid = $_POST["userid"];
			for($i=0;$i<count($userid);$i++)
			{
				$ui = $userid[$i];
				$db->query("update `members` set `upgrade` = 1 where `id` = '{$ui}'");
				$db->query("insert into `logs` set `user` = '".$db->result($db->query("select `username` from `members` where `id` = '{$ui}'"),0,"username")."',`manager` = '聊天室管理员',`time` = '".date("Y-m-d H:i:s")."',`action` = '".msg_grade."',`type` = '".logtype_names."',`why` = '".$_POST["why"]."'");
			}
			header("location:../notice.php?id=".upgrade_ok);
			break;
		case "editpassword":
			if($db->result($db->query("select count(*) from `members` where `username` ='{$_POST["username"]}'"),0,"count(*)"))
			{
				$db->query("update `members` set `password` = '".md5($_POST["password"])."' where `username` = '{$_POST["username"]}'");
				header("location:../notice.php?id=".edit_password_ok);
			}
			else
			{
				header("location:../notice.php?id=".cant_find_user);
			}
			break;
		case "editrank":
			if($db->result($db->query("select count(*) from `members` where `username` ='{$_POST["username"]}'"),0,"count(*)"))
			{
				//写入日志
				$db->query("insert into `logs` set `type` = '".logtype_grade."',`action` = 5,`time` = '".date("Y-m-d H:i:s")."',`user`='{$_POST["username"]}' ,`manager` = '聊天室管理员',`why` = '{$_POST["why"]}',`tags`='".$db->result($db->query("select `rank` from `members` where `username` = '{$_POST["username"]}'"),0,"rank").",{$_POST["newrank"]}'");
				$db->query("update `members` set `rank` = '{$_POST["newrank"]}' where `username` = '{$_POST["username"]}'");
				if($_POST["unupgrade"]==1)
				{
					$db->query("insert into `logs` set `type` = '".logtype_names."',`action` = '".msg_unupgrade."',`time` = '".date("Y-m-d H:i:s")."',`user`='{$_POST["username"]}' ,`manager` = '聊天室管理员',`why` = '{$_POST["why"]}'");
					$db->query("update `members` set `upgrade` = 0 where `username` = '{$_POST["username"]}'");
				}
				header("location:../notice.php?id=".edit_rank_ok);
			}
			else
			{
				header("location:../notice.php?id=".cant_find_user);
			}
			break;	
	}
	$db->close();
	exit;
}
if($_GET["w"]=="database")
{
	$db = new db_query;
	$db->connect();
	$table = $_POST["table"];
	switch($_POST["act"])
	{
		case "repair":
			for($i=0;$i<count($table);$i++)
			{
				$tb = $table[$i];
				$db->query("repair table `{$tb}`");
			}
			header("location:../notice.php?id=".repair_ok);
			break;
		case "optimize":
			for($i=0;$i<count($table);$i++)
			{
				$tb = $table[$i];
				$db->query("optimize table `{$tb}`");
			}
			header("location:../notice.php?id=".optimize_ok);
			break;
	}
	$db->close();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -