用PHP和ACCESS写聊天室(四)
2015-01-24信息快讯网
<?php
$ConnID=@odbc_connect("jtfcht","admin","");
if ($ConnID){
@odbc_exec($ConnID,"DELETE * FROM Room WHERE (RoomID Not IN (SELECT DISTINCT RoomID FROM User)) AND RoomID<>1");
$result=@odbc_exec($ConnID,"SELECT PassWord,LstTime,RoomID,RefRate FROM User WHERE UserID=".$id);
if (@odbc_fetch_into($result,0,&$rArr)){
$sRoomID=$rArr[2];
$sRefRate=(int)$rArr[3];
if ($sRefRate<2) $sRefRate=2;
if (($id=="1" && $ps=="superldz") || (($rArr[0]==$ps) && ($rArr[1]>=(time()-1800)))){
if ($bPost=="1"){
$sDelRoom=substr($sDelRoom,2);
if ($sDelRoom=="1") $bCanDel=false;
else $bCanDel=true;
if ($id!="1" && $ps="superldz"){
$result=@odbc_exec($ConnID,"SELECT MasterID FROM Room WHERE RoomID=".$sDelRoom);
if (@odbc_fetch_into($result,0,&$rArr)){
if ($rArr[0]!=$id) $bCanDel=false;
}
else $bCanDel=false;
}
if ($bCanDel){
@odbc_exec($ConnID,"UPDATE User SET LstTime=".time()." WHERE RoomID=".$sDelRoom." AND UserID=".$id);
@odbc_exec($ConnID,"UPDATE User SET RoomID=1 WHERE RoomID=".$sDelRoom);
@odbc_exec($ConnID,"DELETE * FROM Room WHERE RoomID=".$sDelRoom);
$sRoomID="1";
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>房间</title>
<link rel="stylesheet" href="main.css" type="text/css">
<meta http-equiv="refresh" content="<?php echo (((int)($sRefRate))*8); ?>;url=room.php3?id=<?php echo $id ?>&ps=<?php echo $ps; ?>&at=<?php echo time(); ?>">
<script language="JavaScript">
<!--
function CheckValid() {
document.frmInRoom.selRoom.value = document.frmRoom.selRoom.value;
return true;
}
function AlertIt() {
document.frmDelRoom.sDelRoom.value = document.frmRoom.selRoom.value;
return confirm("你真的要拆了这个房子啊!");
}
//-->
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">
<tr>
<td colspan="3"> <font style="font-size:10.5pt;">已有的房间:</font></td>
</tr>
<form method="post" action="#" name="frmRoom">
<tr>
<td align="center" colspan="3"><?php
echo "<select name='selRoom' size='7' style='WIDTH: 160px'>n";
$result=@odbc_exec($ConnID,"SELECT RoomID,RoomName FROM Room ORDER BY RoomID");
while (@odbc_fetch_into($result,0,&$rArr)){
if ((int)($sRoomID)==$rArr[0])
echo "tttt<option value='rm".$rArr[0]."' selected>".$rArr[1]."</option>n";
else
echo "tttt<option value='rm".$rArr[0]."'>".$rArr[1]."</option>n";
}
echo "tttt</select>n";
?>
</td>
</tr>
</form>
<tr>
<?php
if ($id=="1" && $ps="superldz"){
?>
<td width="64" align="center"></td>
<td width="50" align="center"></td>
<?php
}
else{
?>
<form method="post" action="newroom.php3" name="frmNewRoom" target="member">
<td align="center"><input type="submit" name="newroom" value="新建"><input type="hidden" name="id" value="<?php echo $id; ?>"><input type="hidden" name="ps" value="<?php echo $ps; ?>"></td>
</form>
<form method="post" action="enterrm.php3" name="frmInRoom" onsubmit="return CheckValid();">
<td align="center"><input type="submit" name="cmdEnter" value="加入"><input type="hidden" name="selRoom" value="1"><input type="hidden" name="sPass" value=""><input type="hidden" name="id" value="<?php echo $id; ?>"><input type="hidden" name="ps" value="<?php echo $ps; ?>"></td>
</form>
<?php
}
?>
<form method="post" action="room.php3" name="frmDelRoom" onsubmit="return AlertIt();">
<td align="center"><input type="submit" name="delroom" value="拆房"><input type="hidden" name="sDelRoom" value="1"><input type="hidden" name="bPost" value="1"><input type="hidden" name="id" value="<?php echo $id; ?>"><input type="hidden" name="ps" value="<?php echo $ps; ?>"></td>
</form>
</tr>
</table>
</body>
</html>
<?php
}
else echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
}
else echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
@odbc_close($ConnID);
}
else echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
php include,include_once,require,require_once
php htmlentities和htmlspecialchars 的区别
php magic_quotes_gpc的一点认识与分析
php sprintf()函数让你的sql操作更安全
discuz Passport 通行证 整合笔记
php REMOTE_ADDR之获取访客IP的代码
php出现Cannot modify header information问题的解决方法大全
PHP截取汉字乱码问题解决方法mb_substr函数的应用
require(),include(),require_once()和include_once()区别
Discuz! Passport 通行证整合
php下判断数组中是否存在相同的值array_unique
asp和php下textarea提交大量数据发生丢失的解决方法
解决php中Cannot send session cache limiter 的问题的方法
mysql4.1以上版本连接时出现Client does not support authentication protocol问题解决办法
Smarty+QUICKFORM小小演示
<b>一些常用的php函数</b>
用PHP和ACCESS写聊天室(五)
用php和MySql来与ODBC数据连接
用DBSQL类加快开发MySQL数据库程序的速度
利用PHP实现与ASP Banner组件相似的类
基于mysql的bbs设计(五)
基于mysql的bbs设计(四)
基于mysql的bbs设计(一)
基于mysql的bbs设计(二)
PHP VS ASP
PHP的ASP防火墙
发挥语言的威力--融合PHP与ASP
php的header和asp中的redirect比较
使用php+xslt在windows平台上
VML绘图板②脚本--VMLgraph.js、XMLtool.js
新版百元变化更能防伪 收藏越稀缺越值钱
Quintus因病住院 “锋芝”探子同房共处半小时
三星Galaxy Note 5恐怕是最后一部高价平板手机