<!-- #include file="../../include/skin.asp" -->
<!-- #include file="../../style/data_forum.asp" -->
<!-- #include file="../../include/jk_preview.asp" -->

<%
dim forum_config '论坛配置
dim dimforumtip  '论坛专题
joekoe_cms.ishealth=true
dim dim_forum,dim_forum_num,h_var3,ftit,forumid,viewid
dim_forum=split(web_dim(21),"|")
dim_forum_num=ubound(dim_forum)
web_width="777"
h_var3=2
ftit=""
index_url="forum"
tit_fir=format_menu(index_url)
forumid=trim(request.querystring("forum_id"))
viewid=trim(request.querystring("view_id"))
m_channel=index_url
web_img_m="m_"&m_channel
web_img_h="h_"&m_channel
web_img_e="e_"&m_channel

sub forum_load()
  response.write joekoe_cms.js_put("../style/hscms_select.js",0)
end sub

sub forum_istops()
'############################固顶帖缓存对浏览次数和回复人的处理####################
  if istop=1 then application(joekoe_cms.web_cookies&"_forum_istop_"&forumid)=""
  if istop=2 then application(joekoe_cms.web_cookies&"_forum_istops_state")=""
   application(joekoe_cms.web_cookies&"_configs_num_data")=application(joekoe_cms.web_cookies&"_configs_num_data")+1
    application(joekoe_cms.web_cookies&"_configs_new_num")=application(joekoe_cms.web_cookies&"_configs_new_num")+1
    application.contents.remove(joekoe_cms.web_cookies&"_web_config")
    application.unlock
'############################固顶帖缓存对浏览次数和回复人的处理####################
  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 istop=2 order by re_tim desc"
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,1
  if not rs.eof then
    application.lock
    application(joekoe_cms.web_cookies&"_forum_istops_state")="yes"
    application(joekoe_cms.web_cookies&"_forum_istops")=forum_get_istop(rs.getrows())
    application.unlock
  else
    application.lock
    application(joekoe_cms.web_cookies&"_forum_istops_state")="kong"
    application(joekoe_cms.web_cookies&"_forum_istops")=""
    application.unlock
  end if
  rs.close
end sub

function forum_get_istop(ttdim)
  if not isarray(ttdim) then
    forum_get_istop=""
    exit function
  end if
 dim ttnum,tbb,topic,temp1
    for i=0 to ubound(ttdim,2)
      tbb=1
      if ttdim(5,i)=false then tbb=0
      topic=joekoe_cms.code_html(ttdim(3,i),1,0)
      isvote=0
      if ttdim(16,i) then isvote=1
      temp1=temp1&forum_list_body("",ttdim(0,i),ttdim(1,i),ttdim(2,i),topic,ttdim(4,i),tbb,ttdim(6,i),Trim(ttdim(7,i)),joekoe_cms.time_type(ttdim(8,i),1),ttdim(9,i),ttdim(10,i),ttdim(11,i),joekoe_cms.time_type(ttdim(12,i),1),ttdim(13,i),ttdim(14,i),ttdim(15,i),isvote,ttdim(17,i),ttdim(18,i),ttdim(19,i))
    next
    erase ttdim

  forum_get_istop=temp1
end function

sub forum_end()
  if isarray(dimforumtip) then erase dimforumtip
  call forum_end_clear()
end sub

'-------------------------------------版主权限--------------------------------------
function forum_super_true()
  if int(login_modep)=1 or int(login_modep)=2 or int(login_modep)=3 or int(login_modep)=4 then
    forum_super_true=true
  else
    forum_super_true=false
  end if
end function

function forum_power_true(pvar)
  forum_power_true=false
  if int(login_modep)=1 or int(login_modep)=2 or int(login_modep)=3 or int(login_modep)=4 then
    forum_power_true=true
    exit function
  end if
  if int(login_modep)>5 or pvar="" or login_username="" then
    exit function
  end if
  if instr("|"&lcase(pvar)&"|","|"&lcase(login_username)&"|")>0 then
    forum_power_true=true
  end if
end function

function forum_new_view_true(ftype,nname)
  if int(ftype)>(dim_forum_num+1) then
    forum_new_view_true=true
    exit function
  end if
  forum_new_view_true=false
  if ftype=0 then
    dim use,u
    use=split(nname,",")
    for u=0 to ubound(use)
      if login_username=use(u) then
        forum_new_view_true=true
        if isarray(use) then erase use
        exit function
      end if
    next
    forum_new_view_true=false
    if isarray(use) then erase use
    exit function
  end if
  dim f_type_var
  f_type_var=dim_forum(ftype-1)
  f_type_var=left(f_type_var,instr(f_type_var,":")-1)
  if instr("."&f_type_var&".","."&login_modep&".")>0 then
    forum_new_view_true=true
  end if
end function

sub forum_end_clear()
  erase dim_forum
  if isarray(forum_list_sorts) then erase forum_list_sorts
  if isarray(forum_config) then erase forum_config
end sub

function forum_super_view(vars,vt,n)
  dim temp1,ddim,j,s_select_type  
  s_select_type=format_mid_num(44)
  if int(vt)<>0 then
    if vt=2 then vt=0
    s_select_type=vt
  end if
  temp1="<img src='"&joekoe_cms.web_dir_skin&"forum/forum_power.gif' alt='论坛版主' align=absmiddle border=0>"
  if s_select_type=0 then
    if var_null(vars)="" or vars="" then
     temp1=temp1&"&nbsp;<font class=gray>还没呢&nbsp;</font>"
    else
      ddim=split(vars,"|")
      for j=0 to ubound(ddim)
        if j=n then
          temp1=temp1&"<font class=gray>&nbsp;More</font>"
        exit for
        end if
        temp1=temp1&"&nbsp;<a href='../user/view.asp?username="&server.urlencode(ddim(j))&"' class=h_user alt='查看（版主）"&ddim(j)&" 的详细资料' target=_blank>"&ddim(j)&"</a>"
      next
    end if
  else
    temp1=temp1&"&nbsp;<select name=forum_power_sel onchange=""if(this.options[this.selectedIndex].value!=''){window.open('../user/view.asp?username='+this.options[this.selectedIndex].value);}""><option value='' class=gray>本版版主</option>"
    if var_null(vars)="" or vars="" then
      temp1=temp1&"<option value='' class=gray>还没呢</option>"
    else
      ddim=split(vars,"|")
      for j=0 to ubound(ddim)
        temp1=temp1&"<option value='"&ddim(j)&"'>"&ddim(j)&"</option>"
      next
    end if
    temp1=temp1&"</select>"
  end if
  if isarray(ddim) then erase ddim
  forum_super_view=temp1
end function

function forum_sea_go(st)
  dim temp1
  temp1=temp1&vbcrlf&"<table border=0 width='98%' cellspacing=0 cellpadding=0>" & _
              vbcrlf&"<tr><td>"
  if st="s" then
    temp1=temp1&vbcrlf&"  <table border=0>" & _
                vbcrlf&"  <form action='search.asp?' method=get onsubmit=""javascript:frm_submitonce(this);"">" & _
                vbcrlf&"  <input type=hidden name=sea_fid value='"&forumid&"'>" & _
                vbcrlf&"  <input type=hidden name=action value='chk'>" & _
                vbcrlf&"  <input type=hidden name=page value='1'>" & _
                vbcrlf&"  <tr>" & _
                vbcrlf&"  <td>论坛搜索：</td>" & _
                vbcrlf&"  <td><select name=sea_type size=1>" & _
                vbcrlf&"<option value='topic'>按主题</option>" & _
                vbcrlf&"<option value='username'>按作者</option>" & _
                vbcrlf&"</select></td>" & _
                vbcrlf&"  <td><input type=text class=txt name=keyword size=12 maxlength=20></td>" & _
                vbcrlf&"  <td>&nbsp;<input type=submit class=btn value='搜 索'></td>" & _
                vbcrlf&"  </tr>" & _
                vbcrlf&"  </form>" & _
                vbcrlf&"  </table>"
  end if
  temp1=temp1&vbcrlf&"</td>" & _
              vbcrlf&"<td align=right>"&forum_go&"</td>" & _
              vbcrlf&"</tr>" & _
              vbcrlf&"<table>" & _
              vbcrlf&ukong
  forum_sea_go=temp1
end function

sub search_left()
  dim isadv
  isadv=false
  if trim(request.QueryString("mod"))="adv" then isadv=true
   sea_type=trim(request.querystring("sea_type"))
   keyword=trim(request.querystring("keyword"))
   sea_term=trim(request.querystring("sea_term"))
   tim_start=trim(request.querystring("tim_start"))
   tim_end=trim(request.querystring("tim_end"))
   sea_fid=trim(request.querystring("sea_fid"))
%>

 <table cellspacing=1 cellpadding=4 class=bbs_tables>
  <tr class=bbs_td><td>论坛搜索</td></tr>
  <tr class=bbs_tr><td align=center>
    <table border=0 cellspacing=0 cellpadding=2>
    <form name=frm_search action="search.asp?" method=get>
    <input type=hidden name=action value='chk'>
	<input type=hidden name=mod value='<%if isadv then response.write "adv"%>'>
	
    <tr><td height=5></td></tr>
    <tr><td>您要搜索的帖子是：</td></tr>
    <tr><td height=5></td></tr>
    <tr><td height=1 background="<%=joekoe_cms.web_dir_skin%>bg_line.gif"></td></tr>
    <tr><td height=5></td></tr>
    <tr><td>关键字：</td></tr>
    <tr><td><input type=text class=txt name=keyword value="<%=keyword%>" size=22 maxlength=20></td></tr>
    <tr><td height=5></td></tr>
    <tr><td>发布人是：</td></tr>
    <tr><td><select name=sea_type size=1>
               <option value='topic' <%if sea_type="topic" then response.write " selected"%>>按主题</option>
               <option value='username'<%if sea_type="username" then response.write " selected"%>>按作者</option>
               </select></td></tr>
			   <%if isadv then%>
    <tr><td>搜索条件：</td></tr>
    <tr><td><input type=radio name=sea_term value="all"<%if sea_term<>"or" then response.write " checked"%>>满足全部 <input type=radio name=sea_term value="only"<%if sea_term="or" then response.write " checked"%>>满足一个</td></tr>
<%
  else
    if sea_term="" then sea_term="and"
%>
    <input type=hidden name=sea_term value="<%=sea_term%>">
<%end if%>
    <tr><td>搜索范围：</td></tr>
    <tr><td><% response.write forum_isaction_list(sea_fid) %></td></tr>
<%if isadv then%>
    <tr><td>发贴日期：</td></tr>
    <tr><td><input type=text class=txt name=tim_start value="<%=tim_start%>" size=9 maxlength=10> 至 <input type=text class=txt name=tim_end value="<%=tim_end%>" size=9 maxlength=10></td></tr>
    <tr><td>（日期格式：YYYY-MM-DD ）</td></tr>
<%end if%>
    <tr><td height=5></td></tr>
    <tr><td align=center>
<%if isadv then%>
<%=img_skin("ico_hign")%><a href="<%=dirchnfile%>?mod=&action=search">普通搜索</a>
<%else%>
<%=img_skin("ico_hign")%><a href="<%=dirchnfile%>?mod=adv&action=search">高级搜索</a>
<%end if%>&nbsp; <input type=submit class=btn value="提交搜索"></td></tr>
    <tr><td height=5></td></tr>
    </form>
    </table>
  </td></tr>
  </table>
<%
end sub

function forum_isaction_list(il_forumid)
  if il_forumid="" then il_forumid=0
  dim temp1,ncid,forumn,nfid,classid
  ncid=0
  temp1="<select name=sea_fid><option value='' >所有论坛分区</option>"
  sql="select forum_id,class_id,forum_name,forum_n,forum_w,forum_star,forum_hidden,forum_pro from bbs_forum where forum_hidden=0 order by class_id,forum_order,forum_star"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    classid=rs("class_id")
	forumn=rs("forum_n")
    nfid=rs("forum_id")
    if int(ncid)<>int(classid) then
      temp1=temp1&vbcrlf&"<option class=trb value='"&nfid&"'>╋"&rs("forum_name")&"</option>"
      ncid=classid
    else
      temp1=temp1&vbcrlf&"<option value='"&nfid&"'"
      if int(nfid)=int(il_forumid) then
        temp1=temp1&" selected"
      end if
      temp1=temp1&">"
      for i=1 to rs("forum_star")-1
        temp1=temp1&"│"
      next
      temp1=temp1&"├"&rs("forum_name")
      if rs("forum_w")=false then temp1=temp1&" <不可发贴>"
      if rs("forum_hidden")=true then temp1=temp1&" <隐>"
      if rs("forum_pro")=1 then temp1=temp1&" <只读>"
      temp1=temp1&"</option>"
    end if
    rs.movenext
  loop
  rs.close
  temp1=temp1&"</select>"
  forum_isaction_list=temp1
end function

function forum_go()
  dim gi,gj,gnum,ocid,gdim,temp1
  ocid=0
  temp1=temp1&vbcrlf&"<select name=forum_sort_sel size=1 onchange=""if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}"">" & _
              vbcrlf&"<option value=''>快速跳转论坛至...</option>"
  gnum=ubound(forum_list_sorts)
  for gi=0 to gnum
    gdim=split(forum_list_sorts(gi),"|")
    temp1=temp1&vbcrlf&"<option value='list.asp?forum_id="&gdim(0)&"'>"
    if int(ocid)=int(gdim(1)) then
      for gj=1 to int(gdim(2))
        temp1=temp1&"│"
      next
      temp1=temp1&"├"
    else
      temp1=temp1&"╋"
      ocid=gdim(1)
    end if
    temp1=temp1&gdim(3)&"</option>"
  next
  temp1=temp1&vbcrlf&"</select>"
  if isarray(gdim) then erase gdim
  forum_go=temp1
end function

function base_forum_istop(b_istop,b_isvote)
  dim temp_b
  temp_b="istop"
  if b_isvote=1 then
    temp_b="isvote"
  elseif b_istop=2 then
    temp_b="istops"
  end if
  base_forum_istop="<img src='"&joekoe_cms.web_dir_skin&"forum/"&temp_b&".gif' border=0>"
end function


function base_forum_isview(b_isvote,b_islock,b_re_counter,b_istop,b_isgood)
  dim temp_b,hot_num
  if forum_config(11)>0 then   '论坛热贴数
     hot_num=forum_config(11)
  else
     hot_num=dim_num(18)
  end if  
  if fir_isvote then
    temp_b=temp_b&"<img src='"&joekoe_cms.web_dir_skin&"forum/isvote.gif' border=0 title='投票'>&nbsp;"
  else
    if fir_islock=1 then
      temp_b=temp_b&"<img src='"&joekoe_cms.web_dir_skin&"forum/islock.gif' border=0 title='锁定'>&nbsp;"
    else
      if re_counter>=hot_num then
        temp_b=temp_b&"<img src='"&joekoe_cms.web_dir_skin&"forum/ishot.gif' border=0 title='热门'>&nbsp;"
      else
        temp_b=temp_b&"<img src='"&joekoe_cms.web_dir_skin&"forum/isok.gif' border=0 title='开放'>&nbsp;"
      end if
    end if
  end if
  if fir_istop=1 then temp_b=temp_b&"<img src='"&joekoe_cms.web_dir_skin&"forum/istop.gif' border=0  title='固顶'>&nbsp;"
  if fir_istop=2 then temp_b=temp_b&"<img src='"&joekoe_cms.web_dir_skin&"forum/istops.gif' border=0 title='总固顶'>&nbsp;"
  if fir_isgood=1 then temp_b=temp_b&"<img src='"&joekoe_cms.web_dir_skin&"forum/isgood.gif' border=0 title='精华'>&nbsp;"
  base_forum_isview=temp_b
end function

function user_view_sex(us,utim)
  dim tmpa,tmpb,tmpnum,tmpsex,tmpsname
  tmpa="0"
  tmpb="离线了"
  tmpnum=DateDiff("s",utim,joekoe_cms.now_time)
  if tmpnum<=(dim_num(2)*60) then
    tmpa=""
    tmpb="在线哦！有人找吗？"
  end if
  tmpsex="boy"
  tmpsname=web_n_boy
  if us=false then
    tmpsex="girl"
    tmpsname=web_n_girl
  end if
  user_view_sex="<img src='"&joekoe_cms.web_dir_skin&"small/"&tmpsex&tmpa&".gif' align=absmiddle alt='"&tmpsname&"，"&tmpb&"' border=0>"
end function

function forum_user_power_grade(u_int,u_power)  
  dim dim_power,dim_grade,si,snum,sdim,sdim2,gp_type,gp_types,gp_name,up_type,up_name,n_int,b
  n_int=0
  b=0
  dim_power=dim_user
  dim_grade=split(web_user_grade,"|")
  snum=ubound(dim_power)
  for si=0 to snum
    sdim=split(dim_power(si),":")
    if u_power=sdim(0) then
      up_type=sdim(0)
      up_name=sdim(1)
      select case si
      case 0
        gp_types=up_type
        gp_type="p"
      case 1
        gp_types=up_type
        gp_type="p"
      case 2
        gp_type="p"
      end select
    end if
  next
  if up_type="" or up_name="" then
    sdim=split(dim_power(0),":")
    up_type=sdim(0)
    up_name=sdim(1)
  end if
  snum=ubound(dim_grade)
  for si=0 to snum
    sdim=split(dim_grade(si),":")'''
    if int(si)<>int(snum-1) then sdim2=split(dim_grade(si+1),":")
    select case si
    case snum-1
      if int(u_int)>=int(sdim(0)) then
        n_int=si
        gp_name=sdim(1)
        b=1
      end if
    case else
      if int(u_int)<int(sdim2(0)) then
        n_int=si
        gp_name=sdim(1)
        b=1
      end if
    end select
    if b=1 then exit for
  next
  dim gp_type2,gp_type3
  gp_type2=gp_type
  gp_type3=gp_type&n_int
  if gp_types<>"" and var_null(gp_types)<>"" then
    gp_type3=gp_types
  end if
  if isarray(dim_power) then erase dim_power
  if isarray(dim_grade) then erase dim_grade
  if isarray(sdim) then erase sdim
  if isarray(sdim2) then erase sdim2
  forum_user_power_grade="<img src='"&joekoe_cms.web_dir_skin&"star/star_"&gp_type3&".gif' border=0><br>等级：<img border=0 src='"&joekoe_cms.web_dir_skin&"small/icon_"&up_type&".gif' alt='"&up_name&"' align=absmiddle>&nbsp;<FONT style=""PADDING-RIGHT: 1px; PADDING-LEFT: 1px; FILTER: glow(color=#ff0000,strength=1); PADDING-BOTTOM: 1px; COLOR: #fed966; PADDING-TOP: 1px; HEIGHT: 8px"">"&gp_name&"</font>"
end function

'-------------------------论坛专题导航栏显示--------------------------
sub forum_tip_select(strid,n)
  dim d
if n=1 then 
n="disabled" 
else 
n="enabled" 
end if 
%>
  <select name=tip_id size=1 class=sel <%=n%>>
  <option value="0" selected>请选择所属专题</option>
<%for d=0 to ubound(dimforumtip,2)%>
  <option value="<%=dimforumtip(2,d)%>" <%if int(strid)=int(dimforumtip(2,d)) then response.write "selected"%>><%=dimforumtip(3,d)%></option>
<%next%>
  </select>
<%
end sub 
%>
