Use PHP and access to write chat rooms (7)

Source: Internet
Author: User

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]

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.