Write chat rooms with PHP and access (vii) _php basics
Last Update:2017-01-19
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 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 the 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> re-login </p></body>}
else $sCont = "<p align= ' center ' > password is not correct!" </p><p align= ' center ' > Press <a href= '. ' target= ' _top ' > here </a> re-login </p></body></ Html> ";
}
else $sCont = "<p align= ' center ' > The user does not exist!" </p><p align= ' center ' > Press <a href= '. ' target= ' _top ' > here </a> re-login </p></body></ Html> ";
}
@odbc_close ($ConnID);
}
else $sCont = "<p align= ' Center ' > system failure, unable to log in!" </p></body>?>
<title> Chat Content </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<!--link rel= "stylesheet" href= "Main.css" type= "Text/css"-->
<body>
<?php echo $sCont;?>
"This article copyright belongs to the author and the Osso net jointly owns, if needs to reprint, please indicate the author and the origin"