<?php
include "./function.php";			//调用自定义函数文件
include "./conn/conn.php";			//连接数据源文件

$query = mysql_query("select * from tb_room where id= '".$_GET[roomid]."'");			//检索指定游戏房间号的信息
$result=mysql_fetch_array($query);
if(!@mysql_num_rows($query))		//如果未检索到相关记录
die("ended");						//输出错误提示信息	
$chess = $result[chess];			//获取棋子在棋盘的位置
$flag = $result[flag];				//获取用户是主机还是客机
$moved = $result[moved];			//获取用户当前移动的棋子位置
$eated = $result[eated];			//获取被吃掉的棋子
$guest = $result[guest];			//获取客机（黑旗）名称
$host = $result[host];				//获取主机（红旗）名称
$time_guest = $result[time_guest];	//获取客机（黑旗）登录的时间
$time_host = $result[time_host];	//获取主机（红旗）登录的时间
$guest_win = $result[guest_win];	//获取客机（黑旗）胜局的次数
$host_win = $result[host_win];		//获取主机（红旗）胜局的次数
$message_guest = $result[message_guest];		//获取客机（黑旗）方发送的信息
$message_host = $result[message_host];			//获取主机（红旗）方发送的信息

mysql_query("update tb_room set `time_".$_GET[site]."` = '".time()."', time = '".time()."' where ID = '".$_GET[roomid]."' limit 1");   //更新记录信息

if(time() - $time_guest > 30)
mysql_query("update tb_room set guest = '',message_guest = '' where id = '".$_GET[roomid]."'");		//如果黑旗30分钟未走棋，则清空黑棋记录
if(time() - $time_host > 30)
mysql_query("update tb_room set host = '',message_host = '' where id = '".$_GET[roomid]."'");		//如果红旗30分钟未走旗，则清空红棋记录

echo $chess."|".$flag."|".$moved."|".$eated."|".$guest."|".$host."|".$guest_win."|".$host_win."|".$message_guest."|".$message_host;		//输出棋盘最新的信息
?>