<!--#include file="../inc/Bll.asp"-->
<!--#include file="../inc/Constant.asp"-->
<!--#include file="../inc/Md5.asp"-->

<%
Auto_Login2()
'e.IsLogin,e.UserID,e.UserNickName,e.LevelClass,e.VIPIcon,e.BestAccount,e.FixIcon,e.LevelID,e.RoomID
dim SumPay,SumIncome,CurrentPage,k,Re,t,p,inum,maxin,classid,key,rid,uid,wherestr,islogin,T_RS,s,T_Re,PayStar
if Request.QueryString("ac")="GetRoomUserList" then 
	RS_End
	if Request.QueryString("rid")="" then RW "":REND
	if not IsNumeric(Replace(Request.QueryString("rid"),",","")) then RW "":REND
	rid = Clng(Replace(Request.QueryString("rid"),",",""))
	if Request.QueryString("uid")="" then RW "":REND
	if not IsNumeric(Request.QueryString("uid")) and Session(Session_UserID_Arg)<>"" then RW "":REND
	uid = Get_SafeStr(Request.QueryString("uid"))
	if Check_SafeStr(uid)=false then RW "非法注入":REND
	if Session(Session_UserID_Arg)<>"" then
		wherestr="[i_Sys_RoomUserList_UserID]="&Session(Session_UserID_Arg)
	else
		wherestr="[i_Sys_RoomUserList_GuestID]='"&uid&"'"
	end if
	RS.OPEN "select top 1 * from [i_Sys_RoomUserList] where [i_Sys_RoomUserList_RoomID]="&rid&" and "&wherestr , DB_CONN , 1 , 3
		if RS.recordcount=0 then RS.addnew()
		RS("i_Sys_RoomUserList_RoomID")=rid
		if Session(Session_UserID_Arg)<>"" then
			RS("i_Sys_RoomUserList_UserID")=Session(Session_UserID_Arg)
		else
			RS("i_Sys_RoomUserList_GuestID")=uid
		end if
		RS("i_Sys_RoomUserList_LastTime") = now()
	RS.update()
	RS_End
	DB_CONN.EXECUTE("delete from [i_Sys_RoomUserList] where [i_Sys_RoomUserList_RoomID]="&rid&" and datediff(second,[i_Sys_RoomUserList_LastTime],getdate())>=10")
	RS_End
	Re="{data:["
	set RS=DB_CONN.EXECUTE("select top 100 * from [i_Sys_RoomUserList] where i_Sys_RoomUserList_RoomID="&rid)
	RS.pagesize=100
	if isempty(Request.QueryString("page")) or Request.QueryString("page")="" then CurrentPage=1 else CurrentPage=Cint(Request.QueryString("page")) end if
	if not RS.eof then RS.absolutepage = CurrentPage
	dim iAllPayNum
	while (not RS.eof and k<RS.pagesize )
		if k>0 then Re=Re&","
		if RS("i_Sys_RoomUserList_UserID")<>"" then
			islogin = "true" 
			iAllPayNum = GetUserPayStar(RS("i_Sys_RoomUserList_UserID"))
		else
			islogin = "false"
			iAllPayNum = "/images/pixel.gif"
		end if
		Re=Re&"{IsLogin:"&islogin&",IsManager:"&Ismanager(RS("i_Sys_RoomUserList_UserID"),rid)&",UserID:'"&RS("i_Sys_RoomUserList_UserID")&""&RS("i_Sys_RoomUserList_GuestID")&"',RoomID:'"&GetUserRoomInfoByUserID(RS("i_Sys_RoomUserList_UserID"),"i_Sys_Room_ID")&"',LevelClass:'"&GetUserPaymentLevelInfoByID(RS("i_Sys_RoomUserList_UserID"),"i_User_PaymentLevel_Style")&"',VIPIcon:'"&GetClassInfoByID(RS("i_Sys_RoomUserList_UserID"),"i_User_Class_Style")&"',BestAccount:'',FixIcon:'/images/pixel.gif',LevelID:"&iclng(GetUserPaymentLevelInfoByID(RS("i_Sys_RoomUserList_UserID"),"i_User_PaymentLevel_Sort"))+iclng(GetClassInfoByID(RS("i_Sys_RoomUserList_UserID"),"i_User_Class_SortValue"))&",UserNickName:'"&vbsEscape(Get_SafeStr(GUInfoByID(RS("i_Sys_RoomUserList_UserID"),"i_User_NickName"))&RS("i_Sys_RoomUserList_GuestID"))&"',ServerTime:'"&now()&"',time:'"&RS("i_Sys_RoomUserList_LastTime")&"',PayStar:'"&iAllPayNum&"'}"
		k=k+1
		RS.MoveNext
	Wend
	
	if OpenRobot=true then
		
		if DateDiff("n",Application.contents("Robot_"&rid&"_Time"),now)>30 then 
			Application.Lock()
			Application.contents("Robot_"&rid)=""
			Application.Unlock()
		end if
		if Application.contents("Robot_"&rid) <>"" then
			dim T_Arr,T_Str
			T_Str = Application.contents("Robot_"&rid)
			T_Arr = split(T_Str,",")
			for i=0 to (ubound(T_Arr)-1) 
				Re=Re&","
				Re=Re&"{IsLogin:true,UserID:'"&T_Arr(i)&"',RoomID:'"&GetUserRoomInfoByUserID(T_Arr(i),"i_Sys_Room_ID")&"',LevelClass:'"&GetUserPaymentLevelInfoByID(T_Arr(i),"i_User_PaymentLevel_Style")&"',VIPIcon:'"&GetClassInfoByID(T_Arr(i),"i_User_Class_Style")&"',BestAccount:'',FixIcon:'/images/pixel.gif',LevelID:"&iclng(GetUserPaymentLevelInfoByID(T_Arr(i),"i_User_PaymentLevel_Sort"))+iclng(GetClassInfoByID(T_Arr(i),"i_User_Class_SortValue"))&",UserNickName:'"&vbsEscape(Get_SafeStr(GUInfoByID(T_Arr(i),"i_User_NickName")))&"',ServerTime:'"&now()&"',time:'robot'}"
			next
		else
			dim T_Num
			RANDOMIZE
			T_Num=Int((RobotNum_Max - RobotNum_Min + 1) * Rnd + RobotNum_Min) 
			set T_RS=DB_CONN.EXECUTE("select top "&T_Num&" * from [i_User_Info] where [i_User_ID]<>(select [i_Sys_Room_AdminUserID] from [i_Sys_Room] where [i_Sys_Room_ID]="&rid&" ) order by newid()")
			while (not T_RS.eof and s<T_RS.recordcount )
				if s>0 then T_Re=T_Re&","
				T_Re=T_Re&T_RS("i_User_ID")
				Re=Re&","
				Re=Re&"{IsLogin:true,UserID:'"&T_RS("i_User_ID")&"',RoomID:'"&GetUserRoomInfoByUserID(T_RS("i_User_ID"),"i_Sys_Room_ID")&"',LevelClass:'"&GetUserPaymentLevelInfoByID(T_RS("i_User_ID"),"i_User_PaymentLevel_Style")&"',VIPIcon:'"&GetClassInfoByID(T_RS("i_User_ID"),"i_User_Class_Style")&"',BestAccount:'',FixIcon:'/images/pixel.gif',LevelID:"&iclng(GetUserPaymentLevelInfoByID(T_RS("i_User_ID"),"i_User_PaymentLevel_Sort"))+iclng(GetClassInfoByID(T_RS("i_User_ID"),"i_User_Class_SortValue"))&",UserNickName:'"&vbsEscape(Get_SafeStr(GUInfoByID(T_RS("i_User_ID"),"i_User_NickName")))&"',ServerTime:'"&now()&"',time:'robot'}"
				s=s+1
				T_RS.MoveNext			
			Wend
			Application.Lock()
			Application.contents("Robot_"&rid)=T_Re
			Application.contents("Robot_"&rid&"_Time")=now()
			Application.Unlock()
		end if
	end if
	
	Re=Re&"]}"
	RS_End
	RW Re
	Rend
end if

function iclng(n)
	if IsNumeric(n) then
		iclng = clng(n)
	else
		iclng = 0
	end if
end function

function Ismanager(UID,RID)
	dim m,IRS
	Set IRS=DB_CONN.EXECUTE("select top 1 * ,(select CharIndex('|"&UID&"|',[i_Sys_Room_ManagerUsers])) as 'ismanager' from [i_Sys_Room] where [i_Sys_Room_ID]="&RID)
	if not IRS.eof then 
		m = IRS("ismanager")
		if cint(m)>0 then 
			Ismanager = "true"
		else
			Ismanager = "false"
		end if
	else
		Ismanager = "false"
	end if
end function
%>