用PHP和ACCESS写聊天室(七)
程序员文章站
2022-07-11 08:07:55
chtcont.php3: 代码如下:
chtcont.php3:
代码如下:
<?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","你",$sline);
else
$sline=str_replace("%m",$rarr[2],$sline);
if ($id==$rarr[5])
$sline=str_replace("%g","你",$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'>你已经超时了</p><p align='center'>按<a href='.' target='_top'>这里</a>重新登录</p></body></html>";
}
else $scont="<p align='center'>口令不对!</p><p align='center'>按<a href='.' target='_top'>这里</a>重新登录</p></body></html>";
}
else $scont="<p align='center'>该用户不存在!</p><p align='center'>按<a href='.' target='_top'>这里</a>重新登录</p></body></html>";
}
@odbc_close($connid);
}
else $scont="<p align='center'>系统故障,无法登录!</p></body></html>";
?>
<html>
<head>
<title>聊天内容</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; ?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
代码如下:
<?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","你",$sline);
else
$sline=str_replace("%m",$rarr[2],$sline);
if ($id==$rarr[5])
$sline=str_replace("%g","你",$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'>你已经超时了</p><p align='center'>按<a href='.' target='_top'>这里</a>重新登录</p></body></html>";
}
else $scont="<p align='center'>口令不对!</p><p align='center'>按<a href='.' target='_top'>这里</a>重新登录</p></body></html>";
}
else $scont="<p align='center'>该用户不存在!</p><p align='center'>按<a href='.' target='_top'>这里</a>重新登录</p></body></html>";
}
@odbc_close($connid);
}
else $scont="<p align='center'>系统故障,无法登录!</p></body></html>";
?>
<html>
<head>
<title>聊天内容</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; ?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】