Use PHP and ACCESS to write chat rooms (7)

Source: Internet
Author: User
Use PHP and ACCESS to write a chat room (7) chtcont. php3:
The code is as follows:
$ 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", "you", $ sLine );
Else
$ SLine = str_replace ("% m", $ rArr [2], $ sLine );
If ($ id = $ rArr [5])
$ SLine = str_replace ("% g", "you", $ 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 ="

You have timed out.

Click here to log on again

";
}
Else $ sCont ="

Wrong password!

Click here to log on again

";
}
Else $ sCont ="

This user does not exist!

Click here to log on again

";
}
@ Odbc_close ($ ConnID );
}
Else $ sCont ="

System fault, unable to log on!

";
?>


Chat content






[This article is copyrighted by the author and osuo. if you need to reprint it, please indicate the author and its source]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.