<%

dim isvote

sub forum_list_main()
  dim forum_w,forum_w2,f_remark,forum_new_info,f_new_view,mdim,mnum
  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 " & _
      "from bbs_forum where forum_f="&forumid&" and forum_hidden=0 order by forum_order,forum_id"
  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))
    if f_new_view=true then
      forum_new_info=mdim(6,i)
    end if
    response.write vbcrlf&forum_main_body(mdim(0,i),mdim(1,i),forum_w2,mdim(3,i),mdim(4,i),forum_new_info,mdim(7,i),mdim(8,i),mdim(9,i),mdim(10,i),f_remark,mdim(12,i),f_new_view)
  next
  if int(mnum)>-1 then erase mdim
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
  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,tim,istop,isvote 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 then response.write vbcrlf&forum_list_istop_top()
  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 then
    response.write vbcrlf&forum_list_istop_end()
    call web_branch(0)
  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
  response.write vbcrlf&forum_list_top(nummer)
  'response.write vbcrlf&"var forumtopicnum="&forumtopicnum&" & _"
  rssum=forumtopicnum
  call format_pagecute()
  sql="select top "&nummer*viewpage&" id,forum_id,username,topic,tcolor,tbb,icon,tim,counter,re_username,re_counter,re_tim,istop,islock,isgood,isvote,vote_num 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(15,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),joekoe_cms.time_type(bdim(7,i),1),bdim(8,i),bdim(9,i),bdim(10,i),joekoe_cms.time_type(bdim(11,i),1),bdim(12,i),bdim(13,i),bdim(14,i),isvote,bdim(16,i))
      'response.write vbcrlf&"forum_list_body('',"&rs(0)&","&rs(1)&",'"&rs(2)&"','"&topic&"','"&rs(4)&"',"&tbb&",'"&rs(6)&"','"&joekoe_cms.time_type(rs(7),1)&"',"&rs(8)&",'"&rs(9)&"',"&rs(10)&",'"&joekoe_cms.time_type(rs(11),1)&"',"&rs(12)&","&rs(13)&","&rs(14)&","&isvote&","&rs(16)&");"
      'rs.movenext
      'response.buffer
    next
    erase bdim
  end if
  response.write vbcrlf&forum_list_end & _
		 vbcrlf&forum_list_pagecute(nummer,rssum,viewpage,thepages,pageurl)
end sub

sub list_end(ft)
  response.write forum_sea_go("s")
  if ft>0 then
    response.write forum_img_tim
  end if
  response.write forum_img_topic
end sub

function forum_list_istop_top()
  dim temp1
  temp1=temp1&vbcrlf&"<table cellspacing=1 cellpadding=1 class=table>" & _
              vbcrlf&"<tr align=center>" & _
              vbcrlf&"<td width=25 class=td>图</td>" & _
              vbcrlf&"<td width=25 class=td>例</td>" & _
              vbcrlf&"<td width=* class=td>总固顶及本版固顶的主题</td>" & _
              vbcrlf&"<td width=25 class=td>&nbsp;</td>" & _
              vbcrlf&"<td width=160 class=td>发布时间及发布人</td>" & _
              vbcrlf&"</tr>"
  forum_list_istop_top=temp1
end function

function forum_list_body_istop(l_id,l_forum_id,l_username,l_topic,l_tcolor,l_tbb,l_icon,l_tim,l_istop,l_isvote)
  dim temp1,l_istop_var,new_win,folder_istop,topic_head,topic_color,topic_bb
  l_istop_var="istop"
  new_win="new_win"
  folder_istop=base_forum_istop(l_istop,l_isvote)
  topic_head="&nbsp;"
  topic_color=""
  if l_tcolor<>"" then topic_color="><font color='"&l_tcolor&"'"
  topic_bb=""
  if l_tbb=1 or l_tbb="1" then topic_bb="<b>"
  if topic_is_new(l_tim)="new" then new_win="new"
  temp1=temp1&vbcrlf&"<tr align=center height=25 class=bg_td>" & _
              vbcrlf&"<td>"&folder_istop&"</td>" & _
              vbcrlf&"<td><img src='"&joekoe_cms.web_dir&"images/icon/"&l_icon&".gif' border=0></td>" & _
              vbcrlf&"<td align=left>"&topic_head&topic_bb&"<a href='forum_view.asp?forum_id="&l_forum_id&"&view_id="&l_id&"' "&topic_color&" alt='主题："&joekoe_cms.code_html(l_topic,1,0)&"<br>时间："&l_tim&"'>"&joekoe_cms.code_html(l_topic,1,0)&"</a></td>" & _
              vbcrlf&"<td class=bg_tds><a href='forum_view.asp?forum_id="&l_forum_id&"&view_id="&l_id&"' target=_blank><img src='"&joekoe_cms.web_dir_skin&"small/"&new_win&".gif' alt='打开新窗口浏览此贴' border=0></a></td>" & _
              vbcrlf&"<td align=left>&nbsp;<font class=tims>"&joekoe_cms.time_type(l_tim,3)&"</font>&nbsp;"&format_user_name(l_username,1,"")&"</td>" & _
              vbcrlf&"</tr>"
  forum_list_body_istop=temp1
end function

function forum_list_istop_end()
  forum_list_istop_end="</table>"&ukong
end function

function forum_list_top(l_nummer)
  dim temp1
  temp1=temp1&vbcrlf&"<table cellspacing=1 cellpadding=1 class=table>" & _
              vbcrlf&"<tr align=center>" & _
              vbcrlf&"<td width=25 class=td></td>" & _
              vbcrlf&"<td width=25 class=td></td>" & _
              vbcrlf&"<td width=* class=td1>主题（每页&nbsp;"&l_nummer&"&nbsp;贴&nbsp;&nbsp;点击&nbsp;<img src='"&joekoe_cms.web_dir_skin&"small/fk_plus.gif' align=absMiddle border=0>&nbsp;可展开贴子列表）</td>" & _
              vbcrlf&"<td width=80 class=td1>发布人</td>" & _
              vbcrlf&"<td width=25 class=td1>&nbsp;</td>" & _
              vbcrlf&"<td width=45 class=td1>回复</td>" & _
              vbcrlf&"<td width=45 class=td1>浏览</td>" & _
              vbcrlf&"<td width=160 class=td1>最后回复信息</td>" & _
              vbcrlf&"</tr>"
  if action="manage" then temp1=temp1&vbcrlf&"<form name=del_frm action='forum_isaction.asp' method=get>"
  forum_list_top=temp1
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_tim,l_counter,l_re_username,l_re_counter,l_re_tim,l_istop,l_islock,l_isgood,l_isvote,l_vote_num)
  dim temp1,folder_is,new_win,icon_type,topic_head,topic_color,topic_bb
  folder_is=base_forum_is(l_re_counter,l_istop,l_islock,l_isgood,l_isvote,l_vote_num)
  new_win="new_win"
  icon_type="<img src='"&joekoe_cms.web_dir&"images/icon/"&l_icon&".gif' border=0>"
  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=1 or l_tbb="1" then topic_bb="<b>"
  if action="manage" and int(forumid)=int(l_forum_id) and l_istop_var="" then icon_type="<input type=checkbox name=sel_id value='"&l_id&"' class=bg_tds>"
  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='展开贴子列表'>"
  'dim_num(1)=page_num
  temp1=temp1&vbcrlf&"<tr align=center height=25 class=bg_td>" & _
              vbcrlf&"<td class=bg_tds>"&folder_is&"</td>" & _
              vbcrlf&"<td class=bg_tds>"&icon_type&"</td>" & _
              vbcrlf&"<td align=left>"&topic_head&topic_bb&"<a href='forum_view.asp?forum_id="&l_forum_id&"&view_id="&l_id&"'"&topic_color&" alt='主题："&joekoe_cms.code_html(l_topic,1,0)&"<br>时间："&l_tim&"'>"&joekoe_cms.code_html(l_topic,1,20)&"</a>"&joekoe_cms.js_put("document.write (list_pagecute('forum_view.asp?forum_id="&l_forum_id&"&view_id="&l_id&"',"&l_re_counter+1&","&dim_num(1)&"));",1)&"</td>" & _
              vbcrlf&"<td>"&format_user_name(l_username,1,"")&"</td>" & _
              vbcrlf&"<td><a href='forum_view.asp?forum_id="&l_forum_id&"&view_id="&l_id&"' target=_blank><img src='"&joekoe_cms.web_dir_skin&"small/"&new_win&".gif' alt='打开新窗口浏览此贴' border=0></a></td>"
  if l_isvote=1 then
    temp1=temp1&vbcrlf&"<td class=bg_tds colspan=2>共 <font class=red>"&l_vote_num&"</font> 票</td>"
  else
    temp1=temp1&vbcrlf&"<td class=bg_tds>"&l_re_counter&"</td>" & _
                vbcrlf&"<td class=bg_tds>"&l_counter&"</td>"
  end if
  temp1=temp1&vbcrlf&"<td align=left>&nbsp;<font class=tims>"&joekoe_cms.time_type(l_re_tim,3)&"</font>&nbsp;"&format_user_name(l_re_username,1,"")&"</td>" & _
              vbcrlf&"</tr>" & _
              vbcrlf&"<tr class=bg_td style=""display:none"" id=follow"&l_istop_var&l_id&" height=30><td colspan=2>&nbsp;</td><td colspan=6 align=left id=followTd"&l_istop_var&l_id&"><div class=div_alt onclick=""javascript:load_tree("&l_forum_id&","&l_id&",'"&l_istop_var&"')"">正在读取关于本主题的跟贴，请稍侯……</div></td></tr>"
  forum_list_body=temp1
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=bg_td><td colspan=8 height=30 align=center>" & _
                vbcrlf&"  <table border=0>" & _
                vbcrlf&"  <tr>" & _
                vbcrlf&"  <td>版面管理：</td>" & _
                vbcrlf&"  <td><input class=bg_td type=checkbox name=sel_all onClick=""javascript:select_all(this.form);""> 选中所有</td>" & _
                vbcrlf&"  <td><input class=bg_td type=radio name=action value='revert' checked>还原</td>" & _
                vbcrlf&"  <td><input class=bg_td type=radio name=action value='restore'>修复</td>" & _
                vbcrlf&"  <td><input class=bg_td type=radio name=action value='rap'>奖惩</td>" & _
                vbcrlf&"  <td><input class=bg_td type=radio name=action value='move'>转移</td>" & _
                vbcrlf&"  <td><input class=bg_td type=radio name=action value='istop'>固顶</td>" & _
                vbcrlf&"  <td><input class=bg_td type=radio name=action value='istops'>总固顶</td>" & _
                vbcrlf&"  <td><input class=bg_td type=radio name=action value='isgood'>精华</td>" & _
                vbcrlf&"  <td><input class=bg_td type=radio name=action value='islock'>锁定</td>" & _
                vbcrlf&"  <td><input class=bg_td type=radio name=action value='delete'>删除</td>" & _
                vbcrlf&"  <td width=2></td>" & _
                vbcrlf&"  <td><input type=submit value='执行操作' onclick=""javascript:return sel_click(this.form);""></td>" & _
                vbcrlf&"  </tr>" & _
                vbcrlf&"  </table>" & _
                vbcrlf&"</td></tr>" & _
                vbcrlf&"</form>"
  end if
  temp1=temp1&vbcrlf&"</table>"&ukong
  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&"<table cellspacing=1 cellpadding=1 class=table>" & _
              vbcrlf&"<tr><td class=bg_td height=25>" & _
              vbcrlf&"&nbsp;主题：<font class=red>"&forumtopicnum&"</font>&nbsp;" & _
              vbcrlf&"页次：<font class=red>"&p_viewpage&"</font>/<font class=red>"&p_thepages&"</font>&nbsp;" & _
              vbcrlf&"&nbsp;分页："&jk_pagecute(p_nummer,p_thepages,p_viewpage,p_pageurl,8,"#ff0000") & _
              vbcrlf&"</td></tr>" & _
              vbcrlf&"</table>"&ukong
  forum_list_pagecute=temp1
end function

function topic_is_new(t_time)
  dim isnew
  isnew=""
  if datediff("d",t_time,joekoe_cms.now_time)<1 then isnew="new"
  topic_is_new=isnew
end function

%>