<?php
include "./function.php";					//调用自定义函数文件
include "./conn/conn.php";					//连接数据源文件
mysql_query("delete from tb_room where '".time()."' - time > 30");		//如果系统当前时间减去数据表中的时间大于30，则删除游戏房间
if(isset($_COOKIE[message])){
	echo "<script>alert('".$_COOKIE[message]."');</script>";
	setcookie(message, null);
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>中国网络象棋游戏</title>
<style>
body{
	background-color: #B7EB5B;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url(images/bg_pic.gif);
}
td{
	font-size:9pt;
}
A:visited {
	COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
	COLOR: #000000; TEXT-DECORATION: underline
}
A:active {
	COLOR: #000000; TEXT-DECORATION: none
}
A:link {
	COLOR: #000000; TEXT-DECORATION: none
}
.message_box{
	padding:2px 2px 2px 2px;
	border:1px solid #5A7110;
	background:#CCFF05 no-repeat;	
	color:#000000;
	FONT-SIZE:12px;
	height:19px;
}
</style>
</head>
<body>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="251" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <th height="201" background="images/login.gif" scope="col"><table width="249" bgcolor="#E0F7C1">
      <tr>
        <td width="320">
          <form name=form method=post action='change_name.php' style="margin:0px">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="30%" align="center"> 您的昵称：</td>
                <td width="51%"><input name=nick_name type=text id="nick_name" value=<?php echo $username;?> size=16></td>
                <td width="21%" align="center"><input name=submit type=submit class="message_box" value=更换 ></td>
              </tr>
            </table>
          </form>
          <form name="form" method="post" action="add_d.php" style="margin:0px">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="30%" align="center">游戏房间：</td>
                <td width="52%"><input name="play_room" type="text" id="play_room" value="<?php echo time()."号";?>" size="16" /></td>
                <td width="21%" align="center"> <input name="submit" type=submit class="message_box" value=新建></td>
              </tr>
            </table>
        </form></td>
      </tr>
    </table></th>
  </tr>
</table>
<table width="251" align="center">
  <?php
	$query = mysql_query("select * from tb_room");			//检索数据库中的数据信息
	$info=mysql_fetch_array($query);
	do{
	$r_num = 0;									//变量初始化
	if($info[host])								//如果红旗旗主的值存在
		$r_num ++;								//变量自加1操作
	if($info[guest])							//如果黑旗旗主的值存在
		$r_num ++;								//变量自加1操作
	if($info[id]!=""){
	?>
  <tr>
    <td height="28" valign="middle"><img src="images/room.gif" width="15" height="17" />
	<a href="room.php?id=<?php echo $info[id];?>" ><font color="#990000"><?php echo $info[name];?></font></a>（<?php echo $r_num;?>人/2人）[<a href="room.php?id=<?php echo $info[id];?>">进入房间</a>]
	</td>
  </tr>
  <?php
  	}
	}while($info=mysql_fetch_array($query));
  ?>
</table>
</body>
</html>

