Write a chat room in PHP and Access (vii)

Source: Internet
Author: User
Keywords Write a chat room in PHP and Access (vii)
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 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 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've already timed out.

Click here to log back in

";
}
else $sCont = "

Wrong password!

Click here to log back in

";
}
else $sCont = "

The user does not exist!

Click here to log back in

";
}
@odbc_close ($ConnID);
}
else $sCont = "

System failure, unable to login!

";
?>


<title>Chat content</title>




 

"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and 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.