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

<%
Auto_Login2()

dim SumPay,SumIncome,CurrentPage,k,Re,t,p,inum,maxin,classid,key
if Request.QueryString("ac")="GetRoomList" then 
	RS_End
	if Request.QueryString("top")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("top")) then RW "var RoomListRe='参数错误！';":REND
	t = Cint(Request.QueryString("top"))
	if Request.QueryString("ps")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("ps")) then RW "var RoomListRe='参数错误！';":REND
	p = Cint(Request.QueryString("ps"))
	if Request.QueryString("inum")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("inum")) then RW "var RoomListRe='参数错误！';":REND
	inum = Clng(Request.QueryString("inum"))
	if Request.QueryString("maxin")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("maxin")) then RW "var RoomListRe='参数错误！';":REND
	maxin = Clng(Request.QueryString("maxin"))
	
	Re="var RoomListRe=""{data:["
	'Set RS=DB_CONN.EXECUTE("select top "&t&" *,(select [i_User_InComeLevel_Style] from [i_User_IncomeLevel] where [i_User_IncomeNum]>=[i_User_IncomeLevel_MinNum] and [i_User_IncomeNum]<[i_User_IncomeLevel_MaxNum]) as 'incomeclass' from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where [i_User_LastLiveTime] is not null and [i_User_IncomeNum]>="&inum&" and [i_User_IncomeNum]<"&maxin&" and DateDiff(n,[i_User_ForUpdateTime],getdate())<2 order by [i_Sys_Room_OnlineNum] desc")
	Set RS=DB_CONN.EXECUTE("select top "&t&" *,(select [i_User_InComeLevel_Style] from [i_User_IncomeLevel] where [i_User_IncomeNum]>=[i_User_IncomeLevel_MinNum] and [i_User_IncomeNum]<[i_User_IncomeLevel_MaxNum]) as 'incomeclass',DateDiff(n,[i_User_ForUpdateTime],getdate()) as 'islive' from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where [i_User_ForUpdateTime] is not null and [i_User_LastLiveTime] is not null and [i_User_IncomeNum]>="&inum&" and [i_User_IncomeNum]<"&maxin&" order by [i_User_LastLiveTime] desc,[islive]")
	RS.pagesize=p
	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
	while (not RS.eof and k<RS.pagesize )
		if k>0 then Re=Re&","
		islive = RS("islive")
		if(Cstr(RS("i_User_isStop"))="1") then
			islive = "10"
		end if
		Re=Re&"{onlinenum:'"&RS("i_Sys_Room_OnlineNum")&"',maxnum:'"&RS("i_Sys_Room_MaxNum")&"',roomid:'"&RS("i_Sys_Room_ID")&"',roompic:'"&RS("i_User_Face")&"',incomeclass:'"&RS("incomeclass")&"',usernick:'"&vbsEscape(Get_SafeStr(RS("i_User_NickName")))&"',livetime:'"&TimeDiff(RS("i_User_LastLiveTime"),now())&"',IDCType:'"&RS("i_Sys_Room_IDCType")&"',islive:'"&islive&"',isHiFi:'"&RS("i_User_isHiFi")&"'}"
		k=k+1
		RS.MoveNext
	Wend
	Re=Re&"],recordcount:"&RS.recordcount&",pagenum:"&RS.pagecount&",currentpage:"&CurrentPage&"}"";"
	RS_End
	RW Re
	Rend
end if


if Request.QueryString("ac")="GetRoomListByClass" then 
	RS_End
	if Request.QueryString("top")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("top")) then RW "var RoomListRe='参数错误！';":REND
	t = Cint(Request.QueryString("top"))
	if Request.QueryString("ps")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("ps")) then RW "var RoomListRe='参数错误！';":REND
	p = Cint(Request.QueryString("ps"))
	if Request.QueryString("classid")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("classid")) then RW "var RoomListRe='参数错误！';":REND
	classid = Clng(Request.QueryString("classid"))
	
	Re="var RoomListRe=""{data:["
	'Set RS=DB_CONN.EXECUTE("select top "&t&" *,(select [i_User_InComeLevel_Style] from [i_User_IncomeLevel] where [i_User_IncomeNum]>=[i_User_IncomeLevel_MinNum] and [i_User_IncomeNum]<[i_User_IncomeLevel_MaxNum]) as 'incomeclass',DateDiff(n,[i_User_ForUpdateTime],getdate()) as 'islive' from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where [i_User_ForUpdateTime] is not null and [i_User_LastLiveTime] is not null and [i_Sys_Room_ClassID]="&classid&" order by [islive],[i_User_LastLiveTime] desc")
	Set RS=DB_CONN.EXECUTE("select top "&t&" *,(select [i_User_InComeLevel_Style] from [i_User_IncomeLevel] where [i_User_IncomeNum]>=[i_User_IncomeLevel_MinNum] and [i_User_IncomeNum]<[i_User_IncomeLevel_MaxNum]) as 'incomeclass',DateDiff(n,[i_User_ForUpdateTime],getdate()) as 'islive' from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where [i_User_ForUpdateTime] is not null and [i_User_LastLiveTime] is not null and [i_Sys_Room_ClassID]="&classid&" order by [islive],[i_User_LastLiveTime] desc")
	RS.pagesize=p
	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
	while (not RS.eof and k<RS.pagesize )
		if k>0 then Re=Re&","
		Re=Re&"{onlinenum:'"&RS("i_Sys_Room_OnlineNum")&"',maxnum:'"&RS("i_Sys_Room_MaxNum")&"',roomid:'"&RS("i_Sys_Room_ID")&"',roompic:'"&RS("i_User_Face")&"',incomeclass:'"&RS("incomeclass")&"',usernick:'"&vbsEscape(Get_SafeStr(RS("i_User_NickName")))&"',livetime:'"&TimeDiff(RS("i_User_LastLiveTime"),now())&"',IDCType:'"&RS("i_Sys_Room_IDCType")&"',islive:'"&RS("islive")&"',isHiFi:'"&RS("i_User_isHiFi")&"',isStop:'"&RS("i_User_isStop")&"'}"
		k=k+1
		RS.MoveNext
	Wend
	Re=Re&"],recordcount:"&RS.recordcount&",pagenum:"&RS.pagecount&",currentpage:"&CurrentPage&"}"";"
	RS_End
	RW Re
	Rend
end if

if Request.QueryString("ac")="GetRoomTopList" then 
	RS_End
	if Request.QueryString("top")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("top")) then RW "var RoomListRe='参数错误！';":REND
	t = Cint(Request.QueryString("top"))
	if Request.QueryString("ps")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("ps")) then RW "var RoomListRe='参数错误！';":REND
	p = Cint(Request.QueryString("ps"))
	
	Re="var RoomListRe=""{data:["
	Set RS=DB_CONN.EXECUTE("select top "&t&" *,isnull([i_User_LastLiveTime],'1999-1-1 11:59:59') as [LastLiveTime],ISNULL(DateDiff(n,[i_User_ForUpdateTime],getdate()),1000) as 'islive',(select [i_User_InComeLevel_Style] from [i_User_IncomeLevel] where [i_User_IncomeNum]>=[i_User_IncomeLevel_MinNum] and [i_User_IncomeNum]<[i_User_IncomeLevel_MaxNum]) as 'incomeclass' from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where [i_User_IsRecommend]=1  order by newid()")
	RS.pagesize=p
	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
	while (not RS.eof and k<RS.pagesize )
		if k>0 then Re=Re&","
		Re=Re&"{onlinenum:'"&RS("i_Sys_Room_OnlineNum")&"',maxnum:'"&RS("i_Sys_Room_MaxNum")&"',roomid:'"&RS("i_Sys_Room_ID")&"',roompic:'"&RS("i_User_Face")&"',incomeclass:'"&RS("incomeclass")&"',usernick:'"&vbsEscape(Get_SafeStr(RS("i_User_NickName")))&"',livetime:'"&TimeDiff(RS("LastLiveTime"),now())&"',IDCType:'"&RS("i_Sys_Room_IDCType")&"',islive:'"&RS("islive")&"',isHiFi:'"&RS("i_User_isHiFi")&"',isStop:'"&RS("i_User_isStop")&"'}"
		k=k+1
		RS.MoveNext
	Wend
	Re=Re&"],recordcount:"&RS.recordcount&",pagenum:"&RS.pagecount&",currentpage:"&CurrentPage&"}"";"
	RS_End
	RW Re
	Rend
end if

if Request.QueryString("ac")="GetRoomListBySearch" then 
	RS_End
	if Request.QueryString("top")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("top")) then RW "var RoomListRe='参数错误！';":REND
	t = Cint(Request.QueryString("top"))
	if Request.QueryString("ps")="" then RW "var RoomListRe='参数错误！';":REND
	if not IsNumeric(Request.QueryString("ps")) then RW "var RoomListRe='参数错误！';":REND
	p = Cint(Request.QueryString("ps"))
	key = GetInStr( vbsUnEscape(Request.QueryString("key")) )
	
	
	Re="var RoomListRe=""{data:["
	Set RS=DB_CONN.EXECUTE("select top "&t&" *,(select [i_User_InComeLevel_Style] from [i_User_IncomeLevel] where [i_User_IncomeNum]>=[i_User_IncomeLevel_MinNum] and [i_User_IncomeNum]<[i_User_IncomeLevel_MaxNum]) as 'incomeclass',isnull([i_User_LastLiveTime],'1990-1-1 11:59:59') as 'LastLiveTime',DateDiff(n,[i_User_ForUpdateTime],getdate()) as 'islive' from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where [i_User_NickName] like '%"&key&"%' order by [islive],[i_User_LastLiveTime] desc")
	RS.pagesize=p
	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
	while (not RS.eof and k<RS.pagesize )
		if k>0 then Re=Re&","
		if RS("LastLiveTime")="1990-1-1 11:59:59" then 
			itime = "" 
			ilive = 10
		else 
			itime = TimeDiff(RS("LastLiveTime"),now())
			ilive = RS("islive")
		end if
		Re=Re&"{onlinenum:'"&RS("i_Sys_Room_OnlineNum")&"',maxnum:'"&RS("i_Sys_Room_MaxNum")&"',roomid:'"&RS("i_Sys_Room_ID")&"',roompic:'"&RS("i_User_Face")&"',incomeclass:'"&RS("incomeclass")&"',usernick:'"&vbsEscape(Get_SafeStr(RS("i_User_NickName")))&"',livetime:'"&itime&"',IDCType:'"&RS("i_Sys_Room_IDCType")&"',islive:'"&ilive&"',isHiFi:'"&RS("i_User_isHiFi")&"',isStop:'"&RS("i_User_isStop")&"'}"
		k=k+1
		RS.MoveNext
	Wend
	Re=Re&"],recordcount:"&RS.recordcount&",pagenum:"&RS.pagecount&",currentpage:"&CurrentPage&"}"";"
	RS_End
	RW Re
	Rend
end if

%>