Home > Backend Development > PHP Tutorial > 用PHP和ACCESS写聊天室(七)

用PHP和ACCESS写聊天室(七)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 14:31:04
Original
970 people have browsed it
chtcont.php3:
代码如下:
    $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.="
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.="
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="

你已经超时了

这里重新登录

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template