Use PHP and ACCESS to write chat rooms (7)

Source: Internet
Author: User

Chtcont. php3:
The Code is as follows:
<? 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", "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. = "<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'> you have timed out </p> <p align = 'center'> press <a href = '. 'Target = '_ top'> here </a> log on again </p> </body> }
Else $ sCont = "<p align = 'center'> the password is incorrect! </P> <p align = 'center'> press <a href = '. 'Target = '_ top'> here </a> log on again </p> </body> }
Else $ sCont = "<p align = 'center'> this user does not exist! </P> <p align = 'center'> press <a href = '. 'Target = '_ top'> here </a> log on again </p> </body> }
@ Odbc_close ($ ConnID );
}
Else $ sCont = "<p align = 'center'> failed to log on because of a system failure! </P> </body> ?>
<Html>
<Head>
<Title> chat content </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;?>

[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.