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

📄 rooms.php

📁 很不错的php聊天室源码,提供给大家学习
💻 PHP
字号:
<?php
session_start();
include "include/query.php";
include "include/functions.php";
$db = new db_query;
timer();
$db->connect();
$roomResult = $db->query("select * from `rooms`");
?>
<html>
<head>
<title>
更改房间-- <?=getConfig("chatroom_name")?>
</title>
<META http-equiv="Content-Type" content="text/html;charset=gb2312">
<style>
td,body
{
	font-size:12px;
	text-align:center;
}
</style>
</head>
<body scroll="auto" bgcolor="<?=getConfig("page_bgcolor")?>">
<br>
<center><font color="blue"><?=getConfig("chatroom_name")?></font> 房间列表(<font color="blue"><?=$db->result($db->query("select count(*) from `rooms`"),0,"count(*)")?></font>) 在线人数(<font color="blue"><?=$db->result($db->query("select count(*) from `onlinelist`"),0,"count(*)")?></font>)</center>
<table width=700 align="center" cellspacing=1 cellpadding=2 bgcolor="black">
<tr>
	<td width=60 bgcolor="buttonface">房间ID</td>
	<td width=60 bgcolor="buttonface">进入级别</td>
	<td width=60 bgcolor="buttonface">是否开启</td>
	<td width=60 bgcolor="buttonface">最大人数</td>
	<td width=60 bgcolor="buttonface">在线人数</td>
	<td width=120 bgcolor="buttonface">房间名称</td>
	<td width=110 bgcolor="buttonface">房间主人</td>
	<td width=110 bgcolor="buttonface">在线名单</td>
	<td width=60 bgcolor="buttonface">进入房间</td>
</tr>
<?php
while($roomRow = $db->fetchArray($roomResult))
{
	$mastersStr = "<select>";
	if($roomRow["masters"]!="")
	{
		$arrMasters = explode(",",$roomRow["masters"]);
		for($i=0;$i<count($arrMasters);$i++)
		{
			$mastersStr .= "<option>".$arrMasters[$i]."</option>";
		}
	}
	$onlines = $db->result($db->query("select count(*) from `onlinelist` where `roomid` = '{$roomRow["id"]}'"),0,"count(*)");
	if($_SESSION["roomid"]==$roomRow["id"])
	{
		$color = "#6699ff";
	}
	else
	{
		$color = "white";
	}
	$onlineStr = "<select>";
	$onlineResult = $db->query("select `username` from `onlinelist` where `roomid` = '{$roomRow["id"]}'");
	while($onlineRow = $db->fetchArray($onlineResult))
	{
		$onlineStr .= "<option>".$onlineRow["username"]."</option>";
	}
	if($onlineStr == "<select>")
	{
		$onlineStr = "无人在线";
	}
	else
	{
		$onlineStr .= "</select>";
	}
	if($mastersStr == "<select>")
	{
		$mastersStr = "无房间主人";
	}
	else
	{
		$mastersStr .= "</select>";
	}

	echo "<tr>\n";
	echo "<td width=60 bgcolor=\"{$color}\">{$roomRow["id"]}</td>\n";
	echo "<td width=60 bgcolor=\"{$color}\">{$roomRow["grade"]}</td>\n";
	echo "<td width=60 bgcolor=\"{$color}\">".($roomRow["inuse"]?"是":"否")."</td>\n";
	echo "<td width=60 bgcolor=\"{$color}\">{$roomRow["maxonline"]}</td>\n";
	echo "<td width=60 bgcolor=\"{$color}\">".$onlines."</td>\n";
	echo "<td width=120 bgcolor=\"{$color}\">{$roomRow["room_name"]}</td>\n";
	echo "<td width=110 bgcolor=\"{$color}\">".$mastersStr."</td>\n";
	echo "<td width=110 bgcolor=\"{$color}\">".$onlineStr."</td>\n";
	echo "<td width=60 bgcolor=\"{$color}\">".(($roomRow["inuse"]&&($_SESSION["userrank"]>=$roomRow["grade"])&&($roomRow["id"]!=$_SESSION["roomid"])&&($onlines<$roomRow["maxonline"]))?"<button onclick=\"dialogArguments.location.href='manage.php?mode=changeRoom&roomid={$roomRow["id"]}';window.close()\">进入</button>":"不能进")."</font></td>\n";
	echo "</tr>\n";
}
?>
</table>
<br>
<?php
include "include/copyrights.php";
?>
</body>
</html>

⌨️ 快捷键说明

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