<%@ LANGUAGE=VBScript codepage ="936" %>
<!--#include file="../const3.asp"-->
<%Response.Buffer=true
Response.Expires = 0
Response.CacheControl="no-cache"
Response.AddHeader "pragma","no cache"
cwjh_name=Session("cwjh_name")
cwjh_grade=Session("cwjh_grade")
cwjh_jhdj=Session("cwjh_jhdj")
if cwjh_name="" then Response.Redirect "../error.asp?id=440"
chatroomsn=session("nowinroom")
mychatroomsn=Request.QueryString("roomsn")
chatroomname=Request.QueryString("chatroomname")
chatroomname=Application("cwjh_chatroomname"&mychatroomsn)
n=Year(date())
y=Month(date())
r=Day(date())
s=Hour(time())
f=Minute(time())
m=Second(time())
if len(y)=1 then y="0" & y
if len(r)=1 then r="0" & r
if len(s)=1 then s="0" & s
if len(f)=1 then f="0" & f
if len(m)=1 then m="0" & m
t=s & ":" & f & ":" & m
sj=n & "-" & y & "-" & r & " " & t
if chatroomsn=mychatroomsn then
  response.write "<Script language=javascript>alert('你已经在["&chatroomname&"]不能重复进入!');parent.m.location.reload();parent.r.location.reload();</script>"
  response.end
end if
chatroominfo=split(Application("cwjh_room"),";")
chatroomnum=ubound(chatroominfo)-1
i=mychatroomsn
online=split(trim(Application("cwjh_useronlinename"&i))," ")
onlinenum=ubound(online)+1
sj_chat_info=split(chatroominfo(i),"|")
num=int(sj_chat_info(1))
if onlinenum>=num then
  response.write "<Script>alert('["&chatroomname&"]房间当前人数已满，不能进入！');parent.r.location.reload();</script>"
  response.end
end if
if Instr(LCase(application("cwjh_zanli")),LCase("!"&cwjh_name&"!"))>0 and chatroomname<>"泡点专厢" and cwjh_grade<10 then
   response.write "<Script>alert('提示:泡点中,无法换房!');parent.r.location.reload();</script>"
   response.end
end if
'决战房的判断
if application("cwjh_user")<>cwjh_name then
if chatroomname=cwjh_chat2 and (Weekday(date())<>7 or Hour(time())<>21 or (Hour(time())=21 and Minute(time())>50)) then
	response.write "<Script>alert('决战酷屋只有在每周六的21:00-21:50分才可进入 \n现在时间"&time()&"！时间未到！请稍等！');parent.r.location.reload();</script>"
	response.end
end if
if chatroomname=cwjh_chat2 and cwjh_grade>5 then
	response.write "<Script>alert('提示：官府中人不得参与！');parent.r.location.reload();</script>"
	response.end
end if
end if
if chatroomname=cwjh_chat2 and Instr(Application("cwjh_admin_send"),"|" & cwjh_name & "|")<>0 then
	response.write "<Script>alert('提示：你都是财神了，就不再争夺了！');parent.r.location.reload();</script>"
	response.end
end if
'决战房的判断END
Set conn=Server.CreateObject("ADODB.CONNECTION")
Set rs=Server.CreateObject("ADODB.RecordSet")
conn.open Application("cwjh_usermdb")
rs.open "select * from 用户 where 姓名='" & cwjh_name &"'",conn,2,2
cwjh_id=rs("id")
jhsf=rs("身份")
if Instr(Application("cwjh_guibin"),"|" & cwjh_name & "|")<>0 then
 jhsf="贵宾"
end if
if Instr(Application("cwjh_admin_send"),"|" & cwjh_name & "|")<>0 then 
 jhsf="财神"
end if
if rs("配偶")=Application("cwjh_user") and rs("性别")="女" then
 jhsf="站长夫人"
end if
if Application("cwjh_mengzhu")=cwjh_name then 
 jhsf="武林盟主"
end if
if rs("通缉")=True then
	jhmp="通缉犯"
else
	jhmp=rs("门派")
end if
jhtx=rs("名单头像")
sex=rs("性别")
hydj=rs("会员等级")
myzs=rs("转生")
mypeiou=rs("配偶")
jinhua=rs("封神榜")
js_name=rs("角色")
js_dj=rs("角色等级")
sj=DateDiff("n",rs("操作时间"),now())
if sj<3 and cwjh_grade<6 then
	s=3-sj
	Response.Write "<script language=JavaScript>{alert('提示：转换房间请等["&s&"分钟]再操作！');parent.m.location.reload();parent.r.location.reload();}</script>"
	rs.close
	set rs=nothing	
	conn.close
	set conn=nothing
	Response.End
end if
if cstr(sj_chat_info(2))=1 and cwjh_grade<7 then
	rs.close
	rs.open "select id from 用户 where 姓名='" & cwjh_name &"'"&" and "&sj_chat_info(4),conn
	if rs.eof or rs.bof  then
		rs.close
		set rs=nothing	
		conn.close
		set conn=nothing
		Response.Write "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><meta http-equiv='pragma' content='no-cache'></head><body bgcolor=" + Application("cwjh_chatbgcolor") + " background=" + Application("cwjh_chatimage") + " bgproperties=fixed>"
		Response.Write "<script language=JavaScript>{alert('进入["&sj_chat_info(0)&"]的条件是："&sj_chat_info(3)&"');parent.r.location.reload();}</script>"
		Response.End
	end if
	rs.close
end if
jinhua_pic="无"
if jinhua<>"" and jinhua<>"无" and jinhua<>"初学忍者" then
j_star="<img src=../twt/fengshen/pic/time_star.gif border=0>"
j_yueliang="<img src=../twt/fengshen/pic/time_yueliang.gif border=0>"
j_sun="<img src=../twt/fengshen/pic/time_sun.gif border=0>"
rs.close
rs.open "select * from 封神榜 where 名号='"&jinhua&"'",conn,1,1
if not rs.eof then
 jinhua_pic=rs("图标")
 jinhua_pic=replace(jinhua_pic,"A",j_star)
 jinhua_pic=replace(jinhua_pic,"B",j_yueliang)
 jinhua_pic=replace(jinhua_pic,"C",j_sun)
 jinhua_pic="<a href=../twt/fengshen target=cwjh_win title="&jinhua&">"&jinhua_pic&"</a>"
end if
end if
'姓名0,性别1,门派2,身份3,头象4,等级5,id6,会员等级7,暂离8,心情9,配偶10,转生11,进化图片12,角色13,角色等级14
myzanli=0
if Instr(LCase(application("cwjh_zanli")),LCase("!"&cwjh_name&"!"))>0 then myzanli=1
myonline = cwjh_name & "|" & sex & "|" & jhmp & "|" & jhsf & "|" & jhtx & "|" & cwjh_jhdj& "|" & cwjh_id& "|" & hydj&"|"&myzanli&"|"&"正常"&"|"&mypeiou&"|"&myzs&"|"&jinhua_pic&"|"&js_name&"|"&js_dj
if sj_chat_info(7)<>0 or jhmp="天网" then
	conn.Execute "update 用户 set 保护=false,操作时间=now() where 姓名='" & cwjh_name &"'"	
else
	conn.Execute "update 用户 set 保护=true,操作时间=now() where 姓名='" & cwjh_name &"'"	
end if
set rs=nothing	
conn.close
set conn=nothing
'退出原房间
Application.Lock
mychatroomname=Application("cwjh_chatroomname"&chatroomsn)
onlinelist=Application("cwjh_onlinelist"&chatroomsn)
onno=ubound(onlinelist)
for i=1 to onno
 if InStr(onlinelist(i),cwjh_name & "|")=1 then
'myonline=onlinelist(i)
  for j=i to onno-1
   onlinelist(j)=onlinelist(j+1)
  next
  ReDim Preserve onlinelist(onno-1)
  Application("cwjh_onlinelist"&chatroomsn)=onlinelist
  exit for
 end if
next
Application("cwjh_useronlinename"&chatroomsn)=Replace(Application("cwjh_useronlinename"&chatroomsn)," " & cwjh_name & " ","")
'进入新房间
dim newonlinelist()
js=1
onlinelist=Application("cwjh_onlinelist"&mychatroomsn)
onlineno=ubound(onlinelist)
yjl=0
for i=1 to onlineno
onuser=split(onlinelist(i),"|")
'if yjl=0 and StrComp(onuser(2),jhmp,1)=1 then		'按门派名字汉语拼音排序
'if yjl=0 and len(onuser(2))<len(jhmp) then			'按门派名字长度，长的在前
'if yjl=0 and len(onuser(2))>len(jhmp) then			'按门派名字长度,短的在前
if yjl=0 and StrComp(onuser(0),cwjh_name,1)=1 then	'按名字汉语拼音排序
'if yjl=0 and len(onuser(0))<len(cwjh_name) then	'按名字长度，长的在前
'if yjl=0 and len(onuser(0))>len(cwjh_name) then	'按名字长度,短的在前
	Redim Preserve newonlinelist(js+1)
	yjl=1
	newonlinelist(js)=myonline
	newonlinelist(js+1)=onlinelist(i)
	js=js+2
else
	Redim Preserve newonlinelist(js)
	newonlinelist(js)=onlinelist(i)
	js=js+1
end if
next 
if yjl=0  then
	Redim Preserve newonlinelist(js)
	newonlinelist(js)=myonline
end if
Application("cwjh_onlinelist"&mychatroomsn)=newonlinelist
Application("cwjh_useronlinename"&mychatroomsn)=Application("cwjh_useronlinename"&mychatroomsn)& " "&cwjh_name & " "
erase  newonlinelist
erase  onlinelist
' onlinelist=Application("cwjh_onlinelist"&mychatroomsn)
' onlineno=ubound(onlinelist)+1
' ReDim Preserve onlinelist(onlineno)
'onlinelist(onlineno)=myonline
'Application("cwjh_onlinelist"&mychatroomsn)=onlinelist
'Application("cwjh_useronlinename"&mychatroomsn)=Application("cwjh_useronlinename"&mychatroomsn)& " "&cwjh_name & " "
session("nowinroom")=mychatroomsn
Application.UnLock	

Function Yushu(a)
	Yushu=(a and 31)
End Function
Sub AddMsg(Str)
	Application.Lock()
	Application("SayCount")=Application("SayCount")+1
	i="SayStr"&YuShu(Application("SayCount"))
	Application(i)=Str
	Application.UnLock()
End Sub
act="退出"
towhoway=0
towho="大家"
addwordcolor="660099"
saycolor="008888"
addsays="对"
says="<bgsound src=wav/folder.wav loop=1><font color=black>【换房】</font><font color=#009933><font color=red>" & cwjh_name & "</font>施展出“凌波微步”轻功，转眼间便从〖" & mychatroomname & "〗消失了，原来是去【" &chatroomname & "】了。</font><font class=t>(" & time() & ")</font>"
says=replace(says,chr(39),"\'")
says=replace(says,chr(34),"\"&chr(34))
saystr="<"&"script>parent.sh("& chr(39) & addwordcolor & chr(39) &","& chr(39) & saycolor & chr(39) &","& chr(39) & act & chr(39) &","& chr(39) & cwjh_name & chr(39) &","& chr(39) & addsays & chr(39) &","& chr(39) & towho & chr(39) &"," & chr(39) & says & chr(39) &",0," & chatroomsn & ");<"&"/script>"
addmsg saystr
'session("SayCount")=Application("SayCount")
act="进入"
towhoway=0
towho="大家"
addwordcolor="660099"
saycolor="008888"
addsays="对"
says="<bgsound src=wav/folder.wav loop=1><font color=black>【换房】</font><font color=#009933><a href=javascript:parent.sw('[" & cwjh_name & "]'); target=f2>" & cwjh_name & "</a>施展出“凌波微步”轻功，转眼间从〖" & mychatroomname & "〗来到了【" &chatroomname & "】。</font><font class=t>(" & t & ")</font><bgsound src='readonly/cd.mid' loop='1'>"	'受话者
says=replace(says,chr(39),"\'")
says=replace(says,chr(34),"\"&chr(34))
saystr="<"&"script>parent.sh("& chr(39) & addwordcolor & chr(39) &","& chr(39) & saycolor & chr(39) &","& chr(39) & act & chr(39) &","& chr(39) & cwjh_name & chr(39) &","& chr(39) & addsays & chr(39) &","& chr(39) & towho & chr(39) &"," & chr(39) & says & chr(39) &",0," & session("nowinroom") & ");<"&"/script>"
addmsg saystr
For i = 1 to Application("SayCount")-Session("SayCount")
	Response.Write Application("SayStr"&YuShu((Session("SayCount")+i)))
Next
session("SayCount")=Application("SayCount")
%>
<Script >
parent.crm='<%=Application("cwjh_chatroomname"&session("nowinroom"))%>';
parent.myroom=<%=session("nowinroom")%>
parent.f2.location.href="f2.asp";
//parent.f2.document.af.mdsx.checked=true;
//parent.f2.document.af.sytemp.focus();
//parent.f2.document.af.towho.value="大家";
parent.m.location.reload();
//parent.f2.location.reload();
parent.qp();
alert('欢迎来到〖<%=chatroomname%>〗！');
</script>