<!-- #include file="../Include/Skin.asp" -->
<!-- #Include File="../Include/Functions.asp" -->
<!-- #Include File="../Include/Cls_IpSys.asp" -->
<!-- #Include File="../Include/Cls_PageCute.asp" -->
<%

'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

select case action
case "online"
  tit="读取在线数据"
case "f_online"
  tit="读取论坛版面在线数据"
case else
  tit="读取论坛数据"
end select
Call DoWebHead(0,3)
Cls.LoadTemplate(4)
'----------------------------中间 开始----------------------------
select case action
case "online"
  call load_online(0)
case "f_online"
  call load_online(1)
case else
  call load_tree()
end select
'----------------------------中间 结束----------------------------
Call DoWebEnd()

sub load_tree()
  dim Bbsid,viewid,istop_var,html_temp,Bbstype,tt,tmpnologin,now_bbs_data
  Bbsid=Cls.bbs_ID
  viewid=Cls.Code_ID("id")
  istop_var=Cls.Code_Query("istop_var")
  html_temp="var temp1="""";"
  html_temp=html_temp&vbcrlf&"temp1+=""<div>"";"
  if Is_LoginTrue=false then
    tmpnologin=web_nologin
    tmpnologin=replace(tmpnologin,"""","\""")
    html_temp=html_temp&vbcrlf&"temp1+=""&nbsp;&nbsp;"&tmpnologin&""";"
  else
    i=0
    sql="select top 1 f.bbs_type,t.bbs_data from AsaiMHBbsClass f,AsaiMHBbsTopic t where t.id="&viewid&" and f.bbs_id="&Bbsid&" and f.bbs_hidden=0"
    set rs=Cls.exec(sql,1)
    if rs.eof then
      html_temp=html_temp&vbcrlf&"temp1+=""<font class=red_2>BbsID 出錯！</font>"";"
      i=1
    end if
    now_bbs_data=rs("bbs_data")
    rs.close
    if i=0 then
      sql="select top 10 d.username,d.word,d.is_topic,d.is_shield,u.ispb from "&now_bbs_data&" as d,AsaiMHUserData as u where d.userid=u.id and d.bbs_id="&Bbsid&" and d.reply_id="&viewid&" order by d.id desc"
      set rs=Cls.exec(sql,1)
      i=0
      do while not rs.eof
		if rs("is_topic")=false then
          html_temp=html_temp&vbcrlf&"temp1+="""&Cls.img("fk_minus")
          if rs("ispb")=true then
            html_temp=html_temp&"<font class=red2>该用户的论坛发言已被系统屏蔽！</font>"
          else
            if rs("is_shield")=true then
              html_temp=html_temp&"<font class=red2>该贴已被系统单贴屏蔽！</font>"
            else
              tt=Cls.Code_Html(rs("word"),1,45)
              tt=replace(tt,vbcrlf,"")
              tt=replace(tt,"\","\\")
              tt=replace(tt,"""","")
              tt=replace(tt,CHR(10),"")		'回车
              tt=replace(tt,CHR(13),"")
              html_temp=html_temp&tt
            end if
          end if
          html_temp=html_temp&"&nbsp;<font class=Gys>-</font>&nbsp;"&load_replace(format_user_view(rs("username"),1,0))&""";"
          i=i+1
		end if
        rs.movenext
      loop
      rs.close
      if i=0 then
        html_temp=html_temp&vbcrlf&"temp1+=""<font class=red_2>您的操作有误：ID 出錯（2）！</font>"";"
      end if
    end if
  end if
  html_temp=html_temp&vbcrlf&"temp1+=""</div>"";"
  Response.write Cls.js_put(html_temp&vbcrlf&"window.parent.followTd"&istop_var&viewid&".innerHTML=temp1;",1)
end sub

sub load_online(ft)
	dim html_temp,n_online_num,n_online_user,n_online_guest,l_username,login_uname,col_num,row_num,Bbsid,sql_add,l_type
	col_num=5
	row_num=5
	if Is_LoginTrue then
		login_uname=login_username
	else
		login_uname=Cls.Cookies_Get("guest_name")
	end if
	Bbsid=Cls.bbs_ID
	if ft=0 then
		sql_add=""
		n_online_num=Cls.lk_Online
	else
		sql_add="l_bbs_id="&Bbsid&""
		n_online_num=Cls.bbs_Online
	end if
	if int(n_online_num)<>int(Cls.Cache_Get("lk_Online")) then
		'call Cls.Cache_Set("lk_Online",n_online_num)
		call Cls.Cache_Set("n_online_num",n_online_num)
	end if
	dim obj_page
	set obj_page=new Cls_PageCute
	obj_page.pageurl="load.asp?action="&action&"&"
	obj_page.pagetarget="hiddenframe"
	obj_page.nummer=col_num*row_num
	obj_page.page_t=2
	obj_page.page_p=5
	obj_page.page_unit="位"
	obj_page.page_tit="在线用户"
	obj_page.v_id="l_id"
	Call obj_page.p_init("*","AsaiMHUserLogin",sql_add,"l_login_id desc,l_tim_end desc")
	sql=obj_page.sql_count
	set rs=Cls.exec(sql,1)
	obj_page.rssum=rs(0)
	rs.close
  n_online_user=obj_page.rssum
  call obj_page.p_main("*","AsaiMHUserLogin",sql_add,"l_login_id desc,l_tim_end desc")
  html_temp="var temp1="""";"
  html_temp=html_temp&vbcrlf&"temp1+=""<table border=0 width='100%' align=right cellspacing=2 cellpadding=0>"";" & _
            vbcrlf&"temp1+="""";"
  do while not rs.eof
    html_temp=html_temp&vbcrlf&"temp1+="""";"
    for i=1 to col_num
      if rs.eof then exit for
      l_username=rs("l_username")
	  l_type=rs("l_type")
		if int(l_type)=1 then
			html_temp=html_temp&vbcrlf&"temp1+="""&load_replace(Cls.img("icon_"&rs("l_power")))&"&nbsp;<a href='"&Cls.Web_Dir&"User/View.asp?username="&server.urlencode(l_username)&"' title='目前位置："&load_replace(rs("l_where"))&"\n来访时间："&rs("l_tim_login")&"\n活动时间："&rs("l_tim_end")&"\n"&ip_types(rs("l_ip"))&"\n"&view_sys(rs("l_sys"),1)&"' target=_blank"
			if cstr(l_username)=cstr(login_uname) then
				html_temp=html_temp&" class=blue"
			end if
			html_temp=html_temp&">"&load_replace(l_username)&"</a>"";"
		else
			html_temp=html_temp&vbcrlf&"temp1+="""&load_replace(Cls.img("icon_"&rs("l_power")))&"&nbsp;<font title='目前位置："&load_replace(rs("l_where"))&"\n来访时间："&rs("l_tim_login")&"\n活动时间："&rs("l_tim_end")&"\n"&ip_types(rs("l_ip"))&"\n"&view_sys(rs("l_sys"),1)&"'"
			if cstr(l_username)=cstr(login_uname) then
				html_temp=html_temp&" class=blue"
			end if
			html_temp=html_temp&">"&load_replace(l_username)&"</font>"";"
		end if
		rs.movenext
    next
    html_temp=html_temp&vbcrlf&"temp1+="""";"
  loop
  rs.close
	html_temp=html_temp&vbcrlf&"temp1+="""";" & _
	    vbcrlf&"temp1+=""<div id=asaipage>"";" & _
	    vbcrlf&"temp1+="""&load_replace(obj_page.page_var)&""";" & _
	    vbcrlf&"temp1+="""";" & _
	    vbcrlf&"temp1+="""&load_replace(obj_page.page_cute)&""";" & _
	    vbcrlf&"temp1+=""</div>"";"
	set obj_page=nothing
	'n_online_guest=n_online_num-n_online_user
	'if int(n_online_guest)<>int(Cls.lk_GuestOnline) then
		'n_online_user=Cls.lk_UserOnline
		'n_online_guest=Cls.lk_GuestOnline
	'end if
	if ft=0 then
		n_online_user=Cls.lk_UserOnline
		n_online_guest=Cls.lk_GuestOnline
	else
		'n_online_guest=int(n_online_num-n_online_user)
		'n_online_user=int(n_online_num-n_online_guest)
		n_online_guest=Cls.bbs_GuestOnline
		n_online_user=Cls.bbs_UserOnline
	end if
	Response.write Cls.js_put(html_temp&vbcrlf&"window.parent.bbs_online.innerHTML=temp1;window.parent.online_num.innerHTML="""&n_online_num&""";window.parent.online_user.innerHTML="""&n_online_user&""";window.parent.online_guest.innerHTML="""&n_online_guest&""";",1)
end sub

function load_replace(lr_var)
  load_replace=replace(lr_var,"""","\""")
end function
%>
