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]