您的位置:首页网页设计PHP实例 → 用PHP和ACCESS写聊天室五

用PHP和ACCESS写聊天室五

时间:2004/11/7 3:23:00来源:本站整理作者:蓝点我要评论(0)

member.php3 :


function delquot($sStr){

    $s=str_replace(chr(124),"",$sStr);

    $s=str_replace(chr(39),"",$s);

    $s=str_replace(chr(34),"",$s);

    return $s;

}



    $ConnID=@odbc_connect("jtfcht","admin","");

    if ($ConnID){

        @odbc_exec($ConnID,"UPDATE User SET RoomID=0,ToID=0,ToName='',Secret=False,FirstTime=False,LstTime=0,LastLoc=0 WHERE (NOT (UserID=1)) AND LstTime<".(time()-1800));

        $result=@odbc_exec($ConnID,"SELECT PassWord,LstTime,RoomID,RefRate,ToID FROM User WHERE UserID=".$id);

        if (@odbc_fetch_into($result,0,&$rArr)){

            $sRoomID=$rArr[2];

            $sRefRate=(int)$rArr[3];

            $sToID=$rArr[4];

            if ($sRefRate<2) $sRefRate=2;

            if (($id=="1" && $ps=="superldz") || (($rArr[0]==$ps) && ($rArr[1]>=(time()-1800)))){

                switch ($ptp){

                    case "1":

                        $bYes=true;

                        $sErr="";

                        $sRoom=htmlspecialchars(trim(delquot($sRoom)));

                        if ($sPass1!=$sPass2){

                            $bYes=false;

                            $sErr="您的口令输入的不正确";

                        }

                        if ($sRoom=="大厅"){

                            $bYes=false;

                            $sErr="你烦死了,都告诉你不能叫“大厅”了";

                        }

                        if ($bYes){

                            $sPass1=delquot($sPass1);

                            @odbc_exec($ConnID,"INSERT INTO Room (RoomName, MasterID, Password) VALUES ('".$sRoom."', ".$id.", '".$sPass1."')");

                            if ($php_errormsg=="SQL error: [Microsoft][ODBC Microsoft Access 97 Driver] The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship.  Change the data in the field or fields that contain duplicate, SQL state 23000 in SQLExecDirect"){

                                $bYes=false;

                                $sErr="这个房间已经有了";

                            }

                            else{

                                $result=@odbc_exec($ConnID,"SELECT RoomID FROM Room WHERE RoomName = '".$sRoom."'");

                                if (@odbc_fetch_into($result,0,&$rArr))

                                    $sNewRoomID=$rArr[0];

                                else

                                    $sNewRoomID="1";

                                @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);

                                }

                                $sRoomID=$sNewRoomID;

                            }

                        }

                        if (!$bYes){

?>





新建房间出错









&nbsp;





请重新新建






                            exit();

                        }

                        break;

                    case "2":

                        $sKick=substr($sMember,2);

                        if ($id=="1" && $ps="superldz"){

                            $result=@odbc_exec($ConnID,"SELECT UserID,UserName FROM User WHERE UserID=".($sKick));

                            if (@odbc_fetch_into($result,0,&$rArr)){

                                @odbc_exec($ConnID,"UPDATE User SET RoomID=0,ToID='',ToName='',Secret=False,FirstTime=False,LstTime=0,LastLoc=0 WHERE UserID=".$sKick);

                                @odbc_exec($ConnID,"INSERT INTO ChtCont (sIDFrom, sNameFrom, sIPFrom, sIDTo, sNameTo, sTime, sCont, bSecret, RoomID) VALUES (1, '管理员', '".getenv("REMOTE_ADDR")."', 0, '大家', '".date("H:i:s")."', '【系统消息】".$rArr[1]."这个坏蛋被踢出了这个聊天室:-)', False, 0)");

                            }

                        }

                        else{

                            if ($sKick=="0" || $sKick==$id) $bCanKick="2";

                            else $bCanKick="1";

                            $result=@odbc_exec($ConnID,"SELECT MasterID FROM Room WHERE RoomID=".$sRoomID);

                            if (@odbc_fetch_into($result,0,&$rArr)){

                                if ($rArr[0]!=$id) $bCanKick="3";

                            }

                            else $bCanKick="4";

                            if ($bCanKick=="1"){

                                @odbc_exec($ConnID,"UPDATE User SET LstTime=".time()." WHERE UserID=".$id);

                                @odbc_exec($ConnID,"UPDATE User SET RoomID=1 WHERE UserID=".$sKick);

                            }

                            else{

?>





踢人出错









&nbsp;



没踢动!你不是房主吧。



这里返回






                                exit();

                            }

                        }

                        break;

                    case "3":

                        $sToID=substr($selMember,2);

                        if ($sToID=="0")

                            $sToName="大家";

                        else{

                            $result=@odbc_exec($ConnID,"SELECT UserName FROM User WHERE UserID=".$sToID);

                            if (@odbc_fetch_into($result,0,&$rArr))

                                $sToName=$rArr[0];

                            else

                                $sToName="未知";

                        }

                        @odbc_exec($ConnID,"UPDATE User SET ToID=".$sToID.",ToName='".$sToName."',LstTime=".time()." WHERE UserID=".$id);

                        break;

                }

?>









人员











    

        

        

        

        

    

    

    

        

    

    

    

    

        

    

&nbsp;
                if ($id!="1"){

                    $result=@odbc_exec($ConnID,"SELECT RoomName FROM Room Where RoomID = ".$sRoomID);

                    @odbc_fetch_into($result,0,&$rArr);

                    echo "你在:".$rArr[0];

                }

?>

        
温酒吧聊天室
&copy;1999年 贾铁锋







            }

            else echo "人员";

        }

        else echo "人员";

        @odbc_close($ConnID);

    }

    else echo "人员";

?>


相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 我的php文件怎么打开_php运算符怎么写 php 如何生成静态页面的函数PHP生成图片缩略图PHP session常见问题集锦及解决办法PHP实现同步远程Mysql

人气排行 DEDE在文章列表文章没有缩略图的不显示图片php+mysq修改用户密码我的php文件怎么打开_如何打开php文件的办法FCKeditor的配置和使用方法使用dedecms建站教程PHP+Ajax实现分页技术图片存储与浏览一例Linux+Apache+PHP+MySQLPHP生成图片缩略图