用PHP和ACCESS写聊天室(一)

INDEX.PHP
代码如下!

function delquot($sStr){
    $s=str_replace(chr(124),"",$sStr);
    $s=str_replace(chr(39),"",$s);
    $s=str_replace(chr(34),"",$s);
    return $s;
}

if ($cmdYes=="进   入"){
    $sUserName=htmlspecialchars(trim(delquot($sUserName)));
    if ($sUserName=="superldz" && $sPass="superldz"){
        $sUserID=1;
        include("chtmain.php3");
        exit();
    }
    else{
        $ConnID=@odbc_connect("jtfcht","admin","");
        if ($ConnID){
            $result=@odbc_exec($ConnID,"SELECT UserID,UserName,PassWord,RoomID,Sex FROM User WHERE UserName='".$sUserName."'");
            if (@odbc_fetch_into($result,0,&$rArr)){
                $sUserID=$rArr[0];
                if ($rArr[2]==$sPass){
                    if ($rArr[3]==0){
                        @odbc_exec($ConnID,"UPDATE User SET RoomID=1,LstDate='".date("Y.m.d")."',ToID=0,ToName='大家',Secret=False,FirstTime=True,LstTime=".time()." WHERE UserID=".$sUserID);
                        if ($rArr[4])
                            @odbc_exec($ConnID,"INSERT INTO ChtCont (sIDFrom, sNameFrom, sIPFrom, sIDTo, sNameTo, sTime, sCont, bSecret, RoomID) VALUES (".$rArr[0].", '".$rArr[1]."', '".getenv("REMOTE_ADDR")."', 0, '大家', '".date("H:i:s")."', '【系统消息】欢迎".$rArr[1]."来到了这个聊天室', False, 1)");
                        else
                            @odbc_exec($ConnID,"INSERT INTO ChtCont (sIDFrom, sNameFrom, sIPFrom, sIDTo, sNameTo, sTime, sCont, bSecret, RoomID) VALUES (".$rArr[0].", '".$rArr[1]."', '".getenv("REMOTE_ADDR")."', 0, '大家', '".date("H:i:s")."', '【系统消息】欢迎".$rArr[1]."来到了这个聊天室', False, 1)");
                        include("chtmain.php3");
                        exit();
                    }
                    else $sErrText="登录出错,已经有人用这个名字登录了!";
                }
                else $sErrText="登录出错,口令不正确!";
            }
            else $sErrText="登录出错,用户没注册!";
            @odbc_close($ConnID);
        }
        else $sErrText="系统故障,暂时无法登录";
    }
}
?>



温酒吧聊天室




 



    
        
        
    
    
        
    
    

        
    
Cht
            
            

本页永久域名:http://jtf.126.com/
        


        
            
                
            
        

                    

                        
                            
                        
if ($cmdYes=="进   入"){
?>
                        
                            
                        
                        
                            
                        
}
?>
                    



                    

                        
                        
                            
                        
                        
                            
                            
                            
                        
                        
                            
                            
                            
                        
                        
                            
                        
                        
                    
在此登录
昵称:  
口令:
点击这里注册新用户

                    

                        
                            
                        
                        
                            
                            
                            
                        
                        
                            
                        
                    

  欢迎进入温酒吧聊天室,现介绍本聊天室功能主要有:

                                    
  1. 显示右侧上面是房间列表、下面是你所在的房间里的客人的列表

  2.                                 
  3. 悄悄话、动作、随机表情功能

  4.                                 
  5. 可以指定讲话的对方

  6.                                 
  7. 建立带密码的房间,只有知道口令的人才能进入

  8.                                 
  9. 房主可以拆房和将本房间里的人踢到大厅

  10.                                 
  11. 命令行中可以使用如下命令:

  12.                                     

                                              
    • /w 找人

    •                                         
    • /t 想

    •                                         
    • /: 自定义动作

    •                                         
    • // 系统动作

    •                                     

                                    
  13. 命令行中进行了过滤,不允许出现 HTML TAG

  14.                             
 


                

        


  

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

你可能感兴趣的:(用PHP和ACCESS写聊天室(一))