<%
dim isvote

sub forum_list_main()  
  dim forum_w,forum_w2,f_remark,forum_new_info,f_new_view,mdim,mnum,o_dim,j,f_online
  sql="select l_forum_online from user_login where l_forum_online<>0"
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,1
  if not rs.eof then o_dim=rs.getrows()
  rs.close
  if joekoe_cms.web_vt=1 then
  sql="execute joekoe_forum_list_main "&forumid
else
   sql="select forum_id,forum_n,forum_w,forum_name,forum_type,forum_pro,forum_new_info,forum_new_num,forum_topic_num,forum_data_num,forum_power,forum_remark,forum_pic,forum_user,forum_config " & _
      "from bbs_forum where forum_f="&forumid&" and forum_hidden=0 order by forum_order,forum_id"
end if
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  mnum=-1
  if not rs.eof then
    mdim=rs.getrows()
    mnum=ubound(mdim,2)
  end if
  rs.close
  for i=0 to mnum
    forum_w=mdim(2,i)
    f_remark=mdim(11,i)
	f_remark=replace(f_remark,vbcrlf,"<br>")
    forum_w2=1
    if forum_w=false then forum_w2=0
    forum_new_info=""
    f_new_view=forum_new_view_true(mdim(4,i),mdim(13,i))
    if f_new_view=true then
      forum_new_info=mdim(6,i)
    end if
	  f_online=0
        if isarray(o_dim) then
          for j=0 to ubound(o_dim,2)
            if o_dim(0,j)=mdim(0,i) then f_online=f_online+1
          next
        end if
    response.write vbcrlf&forum_main_body(mdim(0,i),mdim(1,i),forum_w2,mdim(3,i),mdim(4,i),mdim(5,i),forum_new_info,mdim(7,i),mdim(8,i),mdim(9,i),mdim(10,i),f_remark,mdim(12,i),f_new_view,mdim(14,i),f_online)
  next
  if int(mnum)>-1 then erase mdim
  if isarray(o_dim) then erase o_dim
end sub

sub forum_list_istop()
  page=trim(request.querystring("page"))
  if not(isnumeric(page)) then page=1
  if int(page)>1 or action="manage" then exit sub
  dim istop_true,forum_istop_var,l_nummer
  istop_true=false
  forum_istop_var=application(joekoe_cms.web_cookies&"_forum_istop_"&forumid)
  if application(joekoe_cms.web_cookies&"_forum_istops_state")="yes" or var_null(forum_istop_var)<>"" then istop_true=true
  if instr(application(joekoe_cms.web_cookies&"_forum_istop_state"),","&forumid&",")=0 or var_null(application(joekoe_cms.web_cookies&"_forum_istop_state_"&forumid))="" or var_null(forum_istop_var)="" then
    sql="select id,forum_id,username,topic,tcolor,tbb,icon,mode,tim,counter,re_username,re_counter,re_tim,istop,islock,isgood,isvote,vote_num,special,tipid from bbs_topic where forum_id="&forumid&" and istop=1 order by re_tim desc"
    call joekoe_cms.exec(sql,-1)
    rs.open sql,conn,1,1
    application.lock
    if not rs.eof then
      application(joekoe_cms.web_cookies&"_forum_istop_state_"&forumid)="yes"
      application(joekoe_cms.web_cookies&"_forum_istop_"&forumid)=forum_get_istop(rs.getrows())
      istop_true=true
    else
      application(joekoe_cms.web_cookies&"_forum_istop_state_"&forumid)="kong"
      application(joekoe_cms.web_cookies&"_forum_istop_"&forumid)=""
    end if
    application(joekoe_cms.web_cookies&"_forum_istop_state")=application(joekoe_cms.web_cookies&"_forum_istop_state")&","&forumid&","
    application.unlock
    rs.close
    forum_istop_var=application(joekoe_cms.web_cookies&"_forum_istop_"&forumid)
  end if
  if istop_true and format_mid_num(49)=1  then response.write vbcrlf&" <table cellspacing=1 cellpadding=4 class=bbs_table>"& _
 vbcrlf&forum_list_top(l_nummer)
  if application(joekoe_cms.web_cookies&"_forum_istops_state")="yes" then response.write application(joekoe_cms.web_cookies&"_forum_istops")
  if var_null(forum_istop_var)<>"" then  response.write forum_istop_var
  if istop_true and format_mid_num(49)=1 then
    response.write vbcrlf&"</table>"
    'call web_branch(0)
	response.write ukong
  end if
end sub

sub list_body()
  dim bdim,btrue,tbb,topic,sql_add,pageurl
  btrue=true
  pageurl="?forum_id="&forumid&"&action="&action&"&"
  sql_add=""
  if action="isgood" then
    sql_add=" and isgood=1"
    sql="select count(id) from bbs_topic where istop=0 and forum_id="&forumid&sql_add
    set rs=joekoe_cms.exec(sql,1)
    forumtopicnum=rs(0)
    rs.close
  end if
'-------------------论坛专题---------------------
  if isarray(dimforumtip) then
    tipid=trim(request.querystring("tip_id"))
    if tipid<>"" then 
    sql_add=" and tipid="&tipid&""
    pageurl="?forum_id="&forumid&"&tip_id="&tipid&"&"
    sql="select count(id) from bbs_topic where istop=0 and forum_id="&forumid&sql_add
    set rs=joekoe_cms.exec(sql,1)
    forumtopicnum=rs(0)
    rs.close
  end if
 end if
'-------------------论坛专题---------------------
  response.write vbcrlf&forum_list_top(nummer)
  if format_mid_num(49)=0 then 
  call forum_list_istop() 
  if page=1 then response.write "<tr class=bbs_trline><td colspan=7></td></tr>"
  end if
  rssum=forumtopicnum
  call format_pagecute()
  sql="select top "&nummer*viewpage&" id,forum_id,username,topic,tcolor,tbb,icon,mode,tim,counter,re_username,re_counter,re_tim,istop,islock,isgood,isvote,vote_num,special,tipid from bbs_topic where istop=0 and forum_id="&forumid&sql_add&" order by re_tim desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  'rs.movefirst
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if rs.eof then
    rs.close
    btrue=false
  end if
  if btrue then
    bdim=rs.getrows(nummer)
    rs.close
    for i=0 to ubound(bdim,2)
      tbb=1
      if bdim(5,i)=false then tbb=0
      topic=joekoe_cms.code_html(bdim(3,i),1,0)
      isvote=0
      if bdim(16,i) then isvote=1
      response.write vbcrlf&forum_list_body("",bdim(0,i),bdim(1,i),bdim(2,i),topic,bdim(4,i),tbb,bdim(6,i),Trim(bdim(7,i)),joekoe_cms.time_type(bdim(8,i),1),bdim(9,i),bdim(10,i),bdim(11,i),joekoe_cms.time_type(bdim(12,i),1),bdim(13,i),bdim(14,i),bdim(15,i),isvote,bdim(17,i),bdim(18,i),bdim(19,i))
    next
    erase bdim
  end if
  response.write vbcrlf&forum_list_end 
  response.write vbcrlf&forum_list_pagecute(nummer,rssum,viewpage,thepages,pageurl)
end sub

sub list_end(ft)
  response.write forum_sea_go("s")
  'response.write forum_img_topic
end sub


function forum_list_top(l_nummer)
  forum_list_top=CMS_Skin.GetDB("forum_list_bar")
  forum_list_top=Replace(forum_list_top,"{$nummer}",l_nummer)
  forum_list_top=Replace(forum_list_top,"{$web_skin}",joekoe_cms.web_dir_skin)
  if action="manage" then forum_list_top=forum_list_top&"<form name=del_frm action='isaction.asp' method=get>"
end function

function forum_list_body(l_istop_var,l_id,l_forum_id,l_username,l_topic,l_tcolor,l_tbb,l_icon,l_mode,l_tim,l_counter,l_re_username,l_re_counter,l_re_tim,l_istop,l_islock,l_isgood,l_isvote,l_vote_num,l_special,l_tipid)
  dim tmp,folder_is,new_win,listop,topic_head,topic_color,topic_bb,vote,topics,topic,class_tr,tipw
  tipw=0
  folder_is=base_forum_is(l_re_counter,l_islock,l_isvote,l_vote_num)
  new_win="new_win"
  if l_mode<>"" then
  l_mode="<img src='"&joekoe_cms.web_path&"images/mode/"&l_mode&".gif' border=0>"
  else
  l_mode=""
  end if
  topics=joekoe_cms.code_html(l_topic,1,0-tipw)
  if l_re_counter<20 then
  topic=joekoe_cms.code_html(l_topic,1,40-tipw)
  else
  topic=joekoe_cms.code_html(l_topic,1,23-tipw)
  end if
  select case l_istop
    case 1
      listop="<img src='"&joekoe_cms.web_dir_skin&"forum/istop.gif' border=0> "
	  class_tr="class=bbs_trt"
    case 2
      listop="<img src='"&joekoe_cms.web_dir_skin&"forum/istops.gif' border=0> "
	  class_tr="class=bbs_trt"
	case else
	  listop=""
	  class_tr="class=bbs_tr"
   end select
  topic_head="<img src='"&joekoe_cms.web_dir_skin&"small/fk_minus.gif' border=0 align=absMiddle id=followImg"&l_istop_var&l_id&">"
  topic_color=""
  if l_tcolor<>"" then topic_color="><font color='"&l_tcolor&"'"
  topic_bb=""
  if l_tbb<>0 or l_tbb="1" then topic_bb="<b>"
'--------------------------论坛专题-------------------------
  if isarray(dimforumtip) and l_istop_var="" then
   for d=0 to ubound(dimforumtip,2)
    if int(dimforumtip(2,d))=int(l_tipid) then
    topic_bb="<a href="""&dimforumtip(6,d)&""">"&dimforumtip(4,d)&"</a>"&topic_bb
    tipw=len(dimforumtip(3,d))+2
    exit for
   end if
  next
 end if
'--------------------------论坛专题-------------------------
  if topic_is_new(l_tim)="new" then new_win="new"
  if l_re_counter>0 then topic_head="<img loaded=no src='"&joekoe_cms.web_dir_skin&"small/fk_plus.gif' border=0 align=absMiddle id=followImg"&l_istop_var&l_id&" style=""cursor:hand;"" onclick=""javascript:load_tree("&l_forum_id&","&l_id&",'"&l_istop_var&"')"" alt='展开贴子列表'>"
  if action="manage" and int(forumid)=int(l_forum_id) and l_istop_var="" then topic_head="<input type=checkbox name=sel_id value='"&l_id&"' >"
  if l_isvote=1 then
    vote="<td colspan=2>共 <font class=red>"&l_vote_num&"</font> 票</td><td>"&l_counter&"</td>"
  else
    vote="<td>"&l_re_counter&"</td><td>"&l_counter&"</td>"
  end if
'新贴、热贴、精华贴、锁定贴、特殊贴等标志显示
    dim isnew,ishot,isspecial,isgood
	isnew=""
	ishot=""
	isspecial=""
        isgood=""
        islock=""
  if topic_is_new(l_tim)="new" then isnew="&nbsp;"&img_skin("ico_new")
  if l_re_counter>20 and l_counter>50 then ishot="&nbsp;"&img_skin("hot")
  if l_special<>"" and l_special>0 then  isspecial="<img border=0  src='"&joekoe_cms.web_dir_skin&"forum/special.gif' title=""特殊贴"" align=right>"
  if l_isgood=1 then isgood="<img border=0  src='"&joekoe_cms.web_dir_skin&"forum/isgood.gif' title=""精华贴"" align=right>" 
  if l_islock=1 then  islock="<img border=0  src='"&joekoe_cms.web_dir_skin&"forum/islock.gif' title=""锁定贴"" align=right>"  
  tmp=CMS_Skin.GetDB("forum_list")
  tmp=Replace(tmp,"{$folder_is}",folder_is)
  tmp=Replace(tmp,"{$class_tr}",class_tr)
  tmp=Replace(tmp,"{$istop}",listop)
  tmp=Replace(tmp,"{$topic_head}",topic_head)
  tmp=Replace(tmp,"{$topic_bb}",topic_bb)
  tmp=Replace(tmp,"{$mode}",l_mode)
  tmp=Replace(tmp,"{$forum_id}",l_forum_id)
  tmp=Replace(tmp,"{$id}",l_id)
  tmp=Replace(tmp,"{$topic_color}",topic_color)
  tmp=Replace(tmp,"{$topics}",topics)
  tmp=Replace(tmp,"{$topic}",topic)
  tmp=Replace(tmp,"{$isnew}",isnew)
  tmp=Replace(tmp,"{$ishot}",ishot)
  tmp=Replace(tmp,"{$isspecial}",isgood&isspecial)
  tmp=Replace(tmp,"{$icon}","<img src='"&joekoe_cms.web_path&"images/icon/"&l_icon&".gif'>")
  tmp=Replace(tmp,"{$tim}",joekoe_cms.time_type(l_tim,4))
  tmp=Replace(tmp,"{$list_pagecute}",joekoe_cms.js_put("document.write (list_pagecute('view.asp?forum_id="&l_forum_id&"&view_id="&l_id&"',"&l_re_counter+1&","&dim_num(1)&"));",1))
  tmp=Replace(tmp,"{$format_user}",format_user_name(l_username,0,"")&"<br><font class=gray>"&joekoe_cms.time_type(l_tim,4)&"</font>")
  tmp=Replace(tmp,"{$last_user}",format_user_name(l_re_username,0,""))
  tmp=Replace(tmp,"{$web_skin}",joekoe_cms.web_dir_skin)
  tmp=Replace(tmp,"{$new_win}",new_win)
  tmp=Replace(tmp,"{$vote}",vote)
  tmp=Replace(tmp,"{$time_type}",joekoe_cms.time_type(l_re_tim,3))
  tmp=Replace(tmp,"{$istop_var}",l_istop_var)
  forum_list_body=tmp
end function


function forum_list_end()
  dim temp1
  if action="manage" then
    temp1=temp1&vbcrlf&"<input type=hidden name=forum_id value='"&forumid&"'>" & _
                vbcrlf&"<tr class=bbs_trb><td colspan=8 height=30 align=center>" & _
                vbcrlf&"  <table border=0>" & _
                vbcrlf&"  <tr>" & _
                vbcrlf&"  <td>版面管理：</td>" & _
                vbcrlf&"  <td><input  type=checkbox name=sel_all onClick=""javascript:select_all(this.form);""> 选中所有</td>" & _
                vbcrlf&"  <td><input  type=radio name=action value='revert' checked>还原</td>" & _
                vbcrlf&"  <td><input  type=radio name=action value='restore'>修复</td>" & _
                vbcrlf&"  <td><input  type=radio name=action value='rap'>奖惩</td>" & _
                vbcrlf&"  <td><input  type=radio name=action value='move'>转移</td>" & _
                vbcrlf&"  <td><input  type=radio name=action value='istop'>固顶</td>" & _
                vbcrlf&"  <td><input  type=radio name=action value='istops'>总固顶</td>" & _
                vbcrlf&"  <td><input  type=radio name=action value='isgood'>精华</td>" & _
                vbcrlf&"  <td><input  type=radio name=action value='islock'>锁定</td>" & _
                vbcrlf&"  <td><input  type=radio name=action value='delete'>删除</td>"
    if isarray(dimforumtip) then
     temp1=temp1&vbcrlf&"  <td><input  type=radio name=action value='tipid'>专题</td>"
 end if
     temp1=temp1&vbcrlf&"  <td width=2></td>" & _
                vbcrlf&"  <td><input type=submit class=btn value='执行操作' onclick=""javascript:return sel_click(this.form);""></td>" & _
                vbcrlf&"  </tr>" & _
                vbcrlf&"  </table>" & _
                vbcrlf&"</td></tr>" & _
                vbcrlf&"</form>"
  end if
  forum_list_end=temp1
end function

function forum_list_pagecute(p_nummer,p_rssum,p_viewpage,p_thepages,p_pageurl)
  dim temp1
  temp1=temp1&vbcrlf&"<tr class=bbs_trline><td colspan=7></td></tr>" & _
              vbcrlf&" <tr height=25><td class=bbs_trp colspan=7> "& _
              vbcrlf&"<table border=0 cellspacing=0 cellpadding=1>" & _
              vbcrlf&"<tr><td width=5></td><td>" & _
              vbcrlf&"共有<font class=red>"&forumtopicnum&"</font>条主题 页次："&p_viewpage&"/"&p_thepages&"</td>" & _
              vbcrlf&"<td width=5></td><td>分页："&jk_pagecute(p_nummer,p_thepages,p_viewpage,p_pageurl,10,"#ff0000")&"</td>" & _
              vbcrlf&"<td width=5></td><form method=post action='list.asp"&p_pageurl&p_thepages&"'><td>转到：<input type=text name=Page size=3 maxlength=10 value='"&p_viewpage&"'> <input type=submit  value='GO' name=submit></td></form></tr>" & _
              vbcrlf&"</table></td/></tr>"
  forum_list_pagecute=temp1
end function

function topic_is_new(t_time)
  dim isnew
  isnew=""
  if datediff("h",t_time,joekoe_cms.now_time)<24 then isnew="new"
  topic_is_new=isnew
end function
%>
