程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> PHP綜合 >> 用PHP和ACCESS寫聊天室(七)

用PHP和ACCESS寫聊天室(七)

編輯:PHP綜合
chtcont.php3:
代碼如下:
<?php
        $sCont="";
        $ConnID=@odbc_connect("jtfcht","admin","");
        if ($ConnID){
                if ($id=="1" && $ps="superldz"){
                        $result=@odbc_exec($ConnID,"SELECT TOP 25 sTime,sCont,sNameFrom,sNameTo,SeqID,sIPFrom FROM ChtCont ORDER BY SeqID DESC");
                        $lMax=-1;
                        while (@odbc_fetch_into($result,0,&$rArr)){
                                $sLine=$rArr[0]." ".$rArr[1];
                                $sLine=str_replace("%m",$rArr[2]."[".$rArr[5]."]",$sLine);
                                $sLine=str_replace("%g",$rArr[3],$sLine);
                                $sLine.="<br>n";
                                if ($rArr[4]>$lMax) $lMax=$rArr[4];
                                $sCont=$sLine.$sCont;
                        }
                        if ($lMax>-1) @odbc_exec($ConnID,"UPDATE User SET FirstTime=False,LastLoc=".($lMax+1)." WHERE UserID=".$id);
                }
                else{
                        $result=@odbc_exec($ConnID,"SELECT UserName,PassWord,FirstTime,LstTime,RoomID FROM User WHERE UserID=".$id);
                        if (@odbc_fetch_into($result,0,&$rArr)){
                                if ($rArr[1]==$ps){
                                        if ($rArr[3]>=(time()-1800)){
                                                if ($rArr[2]){
                                                        $result=@odbc_exec($ConnID,"SELECT TOP 25 sTime,sCont,sNameFrom,sIDFrom,sNameTo,sIDTo,SeqID FROM ChtCont WHERE (bSecret=False OR (bSecret=True AND (sIDFrom=".$id." OR sIDTo=".$id." OR sIDTo=0))) AND (RoomID=".$rArr[4]." OR RoomID=0) ORDER BY SeqID DESC");
                                                        $lMax=-1;
                                                        while (@odbc_fetch_into($result,0,&$rArr)){
                                                                $sLine=$rArr[0]." ".$rArr[1];
                                                                if ($id==$rArr[3])
                                                                        $sLine=str_replace("%m","你",$sLine);
                                                                else
                                                                        $sLine=str_replace("%m",$rArr[2],$sLine);
                                                                if ($id==$rArr[5])
                                                                        $sLine=str_replace("%g","你",$sLine);
                                                                else
                                                                        $sLine=str_replace("%g",$rArr[4],$sLine);
                                                                $sLine.="<br>n";
                                                                if ($rArr[6]>$lMax) $lMax=$rArr[6];
                                                                $sCont=$sLine.$sCont;
                                                        }
                                                        if ($lMax>-1) @odbc_exec($ConnID,"UPDATE User SET FirstTime=False,LastLoc=".($lMax+1)." WHERE UserID=".$id);
                                                }
                                        }
                                        else $sCont="<p align='center'>你已經超時了</p><p align='center'>按<a href='.' target='_top'>這裡</a>重新登錄</p></body></html>";
                                }
                                else $sCont="<p align='center'>口令不對!</p><p align='center'>按<a href='.' target='_top'>這裡</a>重新登錄</p></body></html>";
                        }
                        else $sCont="<p align='center'>該用戶不存在!</p><p align='center'>按<a href='.' target='_top'>這裡</a>重新登錄</p></body></html>";
                }
                @odbc_close($ConnID);
        }
        else $sCont="<p align='center'>系統故障,無法登錄!</p></body></html>";
?>
<html>
<head>
<title>聊天內容</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--link rel="stylesheet" href="main.css" type="text/css"-->
</head>
<body>
<?php echo $sCont; ?>  

【本文版權歸作者與奧索網共同擁有,如需轉載,請注明作者及出處】    
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved