<?
require("common.inc.php");
require("include/msginfopage.inc.php");
if($room<1){$room=1;}//房间号容错
if(!isset($HTTP_COOKIE_VARS["cookies_loginid"])){
$COOKIRS_TIME=time();
SetCookie("cookies_loginid", $COOKIRS_TIME,NULL,DW_COOKIES_DIR);
}else{
$COOKIRS_TIME=$HTTP_COOKIE_VARS["cookies_loginid"];
}
SetCookie("cookies_chatroom", $room,NULL,DW_COOKIES_DIR);//记录当前房间号
$DbLink->query("SELECT * FROM ".$DW_DBTABLE["Chat"]["room"]." where id=$room and islocked=0 limit 0,1");
if($DbLink->next_record()){
$CHAT_NAME=$DbLink->f("chatname");//当前房间名字
$CHAT_MAXNUM=$DbLink->f("maxnum");//当前房间容纳最多人数
$DbLink->query("SELECT count(username) AS num FROM ".$DW_DBTABLE["Chat"]["line"]." where room=$room"); //现在聊天室中的人数
$DbLink->next_record();
$CHAT_NUM=$DbLink->f("num");//当前房间人数
if($CHAT_MAXNUM>$CHAT_NUM){
$AUTH_USERNAME = $HTTP_COOKIE_VARS["cookies_username"];//用户名称
$AUTH_PASSWORD = $HTTP_COOKIE_VARS["cookies_password"];//用户口令密文
if($AUTH_USERNAME){
$DbLink->query("SELECT * FROM ".$DW_DBTABLE["Chat"]["user"]." where username='$AUTH_USERNAME' and password='$AUTH_PASSWORD' limit 0,1");
if($DbLink->next_record()){
if(0==$DbLink->f("islocked")){
$chatlock=$DbLink->f("chatlock");
if($chatlock<time()){
$AUTH_IP=$_SERVER["REMOTE_ADDR"];//用户当前IP
$AUTH_SEX=$DbLink->f("sex");//用户性别
$AUTH_TIME=time();//当前时间
$AUTH_CHATRANK=$DbLink->f("chatrank");//当前聊天室权限
$AUTH_CHATSKIN=$DbLink->f("chatskin");//当前界面
$chat_count=$DbLink->f("chatcount");
if($AUTH_CHATRANK<11){
if($chat_count<=5000){$AUTH_CHATRANK=intval($chat_count/1000); //5级及以下每级1000点
}else if($chat_count<=15000){$AUTH_CHATRANK=5+intval(($chat_count-5000)/2000);//5-10级以下每级2000点
}
if($AUTH_CHATRANK>10){$AUTH_CHATRANK=10;}
$DbLink->query("UPDATE ".$DW_DBTABLE["Chat"]["user"]." SET chatrank=$AUTH_CHATRANK where username='$AUTH_USERNAME'");
}
include("include/cleanusr.inc.php");
$DbLink->query("SELECT username,room,loginid FROM ".$DW_DBTABLE["Chat"]["line"]." where username='$AUTH_USERNAME' limit 0,1"); //是否已经在线
$changeroom=false;//换房间标记
$islogined=false;//重入标记
if($DbLink->next_record()){
if($DbLink->f("loginid")==$COOKIRS_TIME){
$logtmplog=false;//重入标记
$oldroom=$DbLink->f("room");//原来房间
$sqltmpstr="UPDATE ".$DW_DBTABLE["Chat"]["line"]." SET username='$AUTH_USERNAME',sex=$AUTH_SEX,outtime=$AUTH_TIME,flushtime=$AUTH_TIME,ip='$AUTH_IP',savetime=$AUTH_TIME,rank=$AUTH_CHATRANK,room=$room where username='$AUTH_USERNAME'";
if($oldroom!=$room){$changeroom=true;}
}else{
$islogined=true;
}
}else{
$logtmplog=true;//进入标记
$sqltmpstr="INSERT INTO ".$DW_DBTABLE["Chat"]["line"]." (username,sex,outtime,flushtime,ip,savetime,rank,room,loginid) VALUES ('$AUTH_USERNAME',$AUTH_SEX,$AUTH_TIME,$AUTH_TIME,'$AUTH_IP',$AUTH_TIME,$AUTH_CHATRANK,$room,$COOKIRS_TIME)";
}
if($islogined==false){
//echo $HTTP_COOKIE_VARS["cookies_loginid"],"|";
//echo $sqltmpstr;
$DbLink->query($sqltmpstr);
//<-基本验证通过
if($logtmplog or $changeroom){
//<-第一次进入该房间,显示欢迎词
if($changeroom){
$sqltmpstrinc="$AUTH_USERNAME 转到了 $CHAT_NAME 房间去了";
$DbLink->query("INSERT INTO ".$DW_DBTABLE["Chat"]["mess"]." (username,sayto,color,message,attrib,saytime,room) VALUES ('$AUTH_USERNAME','everyone','009900','$sqltmpstrinc',2,$AUTH_TIME,$oldroom)");
}
switch($DbLink->f("sex")){
case 1: $sextmpstr = "小伙子";break;
case 2: $sextmpstr = "小姑娘";break;
default: $sextmpstr = "";break;
}
$sqltmpstrinc="$sextmpstr <a href=javascript:parent.userClick(\'$AUTH_USERNAME\'); target=sendform>$AUTH_USERNAME</a> 进入了 $CHAT_NAME 聊天室<bgsound src=\'sound/in.mid\' loop=\'1\'>";
$DbLink->query("INSERT INTO ".$DW_DBTABLE["Chat"]["mess"]." (username,sayto,color,message,attrib,saytime,room) VALUES ('$AUTH_USERNAME','everyone','009900','$sqltmpstrinc',2,$AUTH_TIME,$room)");
}
//->第一次进入,显示欢迎词
?>
<html>
<head>
<title><? echo $DW_CHAT_VAR["CHATWEB"]; ?></title>
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate" />
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" />
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
<META NAME="Keywords" CONTENT="Dowebs,Chat DowebsChat,Juchen" />
<link rel="Shortcut Icon" href="<?=$DW_PHPLIB["imgdir"];?>dowebs.ico"></link>
<link rel='stylesheet' type='text/css' href='chat.css'></link>
<Script Language="JavaScript">
var USERNAME = "<?=$AUTH_USERNAME;?>";//当前用户
var ROOMNAME = "<?=$CHAT_NAME;?>";//当前房间名
var ALLNAME= "<?=$DW_CHAT_VAR["ALLNAME"];?>";//所有人的总称
var SYSIMGDIR="<?=$DW_PHPLIB["imgdir"];?>";
var FLUSHLOADING =true ;//记录读取标记
var ONLINELOADING =true;//名单列表读取标记
var FILTERSTRING="";//屏蔽列表字串
var startok = true;
var list;
<?//配色方案
include("include/skins.inc.php");
echo "var SKINCOLOR = new Array(".$skincolor[$AUTH_CHATSKIN].");\n";
?>
var lst = 0;
/* 发言校验开始 */
function submitchk(){
var saysfilterstr = "阴道,阴茎,吃粪,卵,去死,靠你,婊子,匹,做爱,操你,处女,强奸,王八,狗娘,狗男女,干你,我操,你操".split(",");
with (this.sendform.document.form){
if(chatmess.value.length < 1){alert("在说哑语?");chatmess.focus();return false; }
if(chatmess.value.length > 60){alert("发言内容太长啦!(>60)");chatmess.focus();return false; }
if(oldmess.value==chatmess.value && oldman.value==sayto.value){alert('老说一句话,多单调呀!'); chatmess.focus();return false;}
for(var i = 0;i < saysfilterstr.length;i++){
if(saysfilterstr[i] == null)continue;
if(chatmess.value.indexOf(saysfilterstr[i]) != -1){alert('口腔卫生,从自已做起!');chatmess.focus();chatmess.select(); return false;}
}
oldmess.value=chatmess.value;
oldman.value=sayto.value;
chatmess.value='';
chatmess.focus();
//客户端说话速度限制
ty=new Date();
var nh=ty.getHours();
var nm=ty.getMinutes();
var ns=ty.getSeconds();
var ct=(nh*3600)+(nm*60)+ns;
if((ct-lst)>1){lst=ct;}else{chatmess.value=oldmess.value;oldmess.value='';return false;}
this.sendform.addOne(oldmess.value);
Submit.disabled=1;
return true;
}
}
/* 发言校验结束 */
function write(){
var style="<style type=text/css> .t{color:FF00FF;font-size:9pt;}body,table{font-family:'宋体';font-size:10.5pt}A{text-decoration:none}A:Hover{text-decoration:underline}A:visited{color:blue}</style>";
with(this.mymess.document){
open("text/html");
writeln("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\">"+style+"</head>");
writeln("<\script Language='JavaScript'>this.document.bgColor=parent.SKINCOLOR[2];</\script>");
writeln("<body text=660099 leftmargin='1' topmargin='1'>这里可以看到和你有关的话!<hr size=1>");
}
with(this.mainmess.document){
open();
writeln("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\">"+style+"</head>");
writeln("<\script Language='JavaScript'>this.document.bgColor=parent.SKINCOLOR[2];</\script>");
writeln("<body text=660099 leftmargin='1' topmargin='1'>欢迎你光临聊天室!<hr size=1>");
}
this.sendform.document.form.chatmess.focus();
}
//<-显示话语
function printmess(attr,sayname,sayto,saycolor,word,time){
var show="";
if(FILTERSTRING.indexOf("|"+sayname+"|") == -1){
if(attr==0||attr==1){
show=show+"";
if(attr==1){show=show+"【私聊】";}
show=show+"<a href=\"javascript:parent.userClick('"+sayname+"');\" target=sendform>"+sayname+"</a>";
if(sayname==sayto){
show=show+"自言自语道:";
}else if(sayto==USERNAME){
show=show+"对"+"<a href=\"javascript:parent.userClick('"+sayto+"');\" target=sendform><font