Chtcont. php3:
Code 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]