澳门新浦京app下载用PHP和ACCESS写聊天室(九)

enterrm.php3 代码如下: ?php $ConnID=@odbc_connect(jtfcht,admin,); if
($ConnID){ $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 ($sRefRate2) $sRefRate=2; if
(($rArr[0]==$ps) && ($rArr[1]=(time()-1800))){
$sNewRoomID=substr($selRoom,2); if ($sNewRoomID!=$sRoomID){
$result=@odbc_exec($ConnID,SELECT Password FROM Room WHERE
RoomID=.$sNewRoomID); if (@odbc_fetch_into($result,0,&$rArr)){ if
((strlen(trim($rArr[0]))==0) || ($rArr[0]==$sPass)){
@odbc_exec($ConnID,UPDATE User SET
RoomID=.$sNewRoomID.,ToID=0,ToName=’大家’ WHERE UserID=.$id); if
((int)$sRoomID!=1){ $result=@odbc_exec($ConnID,SELECT COUNT(UserID)
FROM User WHERE RoomID=.$sRoomID); @odbc_fetch_into($result,0,&$rArr);
if ($rArr[0]==0) @odbc_exec($ConnID,DELETE * FROM Room Where
RoomID=.$sRoomID); } } else{ ? html head title输入房间口令/title meta
content=text/html; charset=gb2312 link rel=stylesheet href=main.css
type=text/css script language=JavaScript !– function PassSetFocus( ) {
document.frmEnterSm.sPass.focus(); } //– /script link rel=stylesheet
href=main.css type=text/css /head body onload=PassSetFocus(); p/p p
align=centerfont color=#996666输入房间口令/font/p form name=frmEnterSm
action=enterrm.php3 method=post table width=100% border=0 align=center
tr td colspan=2input type=hidden name=selRoom value=?php echo $selRoom;
?input type=hidden name=id value=?php echo $id; ?input type=hidden
name=ps value=?php echo $ps; ?/td /tr tr td width=40%
align=right口令:/td td width=60%input type=password name=sPass
maxlength=10 size=8/td /tr tr td colspan=2 align=centerinput type=submit
name=cmdYes value=进入/td /tr /table /form p align=center按a
href=room.php3?id=?php echo $id; ?&ps=?php echo $ps; ?&at=?php echo
time(); ?这里/a放弃/p /body /html ?php exit(); } } else{ ? html head
title加入房间出错/title meta content=text/html; charset=gb2312 link
rel=stylesheet href=main.css type=text/css /head body p/p p
align=center这个房间已经被拆了!/p p align=center按a
href=room.php3?id=?php echo $id; ?&ps=?php echo $ps; ?&at=?php echo
time(); ?这里/a返回/p /body /html ?php exit(); } } } else echo
htmlheadmeta ‘Content-Type’ content=’text/html;
charset=gb2312’title房间/titlelink rel=’stylesheet’ href=’main.css’
type=’text/css’/headbody/body/html; } else echo htmlheadmeta
‘Content-Type’ content=’text/html; charset=gb2312’title房间/titlelink
rel=’stylesheet’ href=’main.css’ type=’text/css’/headbody/body/html;
@odbc_close($ConnID); } else echo htmlheadmeta ‘Content-Type’
content=’text/html; charset=gb2312’title房间/titlelink rel=’stylesheet’
href=’main.css’ type=’text/css’/headbody/body/html; include(room.php3);
?

代码如下:
<?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>”;
?>  

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】    

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图