<!-- #include file="include/con_help.asp" -->
<!-- #include file="include/jk_keyes.asp" -->
<!-- #include file="include/jk_pagecute.asp" -->
<!-- #include file="include/jk_page_cute.asp" -->
<%
dim max_num,nummer,nums,rssum,page,viewpage,thepages,pageurl,sql_add
max_num=0
iframe=true
nummer=dim_num(0)
nums=nummer
page=1
pageurl="?"
index_url="forum"
tit_fir=""
if action="chk" then
  tit="论坛搜索结果"
else
  tit="论坛搜索"
end if
call web_head(2,0,0,0,0)
'----------------------------左边 开始----------------------------
call left_action()
call left_help()
'----------------------------左边 结束----------------------------
call web_center(0)
'----------------------------中间 开始----------------------------
select case action
case "chk"
  call forum_search_chk()
case else
  call forum_search_main()
end select

response.write vbcrlf&ukong
'----------------------------中间 结束----------------------------
call web_end(0,0)

sub forum_search_main()
  dim fid
  fid=trim(request.querystring("sea_fid"))
  if not joekoe_cms.int_true(fid) then fid=0
%>
<table cellspacing=1 cellpadding=4 class=table>
<tr><td class=td colspan=2>&nbsp;<%response.write img_skin("m_forum")&tit%></td></tr>
<form name=forum_sea_frm action='?' method=get onsubmit="javascript:frm_submitonce(this);">
<input type=hidden name=action value='chk'>
<tr class=bg_td>
<td width='20%'>搜索说明：</td>
<td width='80%'>
  <table border=0>
  <tr><td><li>请输入和选择下列搜索选项，带“<%response.write redx%>”为必填(选)项；</td></tr>
  <tr><td><li>搜索关键字最长20位，多个关键字请用 空格 格开；</td></tr>
  </table>
</td>
</tr>
<tr class=bg_tds>
<td height=30>搜索关键字：</td>
<td><input type=text name=keyword value='' size=30 maxlength=20><%response.write redx%></td>
</tr>
<tr class=bg_td>
<td height=30>搜索条件：</td>
<td><input type=radio name=sea_term value='all' checked class=bg_td>&nbsp;满足所有条件&nbsp;&nbsp;<input type=radio name=sea_term value='only' class=bg_td>&nbsp;满足一个条件</td>
</tr>
<tr class=bg_td>
<td height=30>搜索论坛：</td>
<td>
<% response.write forum_isaction_list(fid) %>
</td>
</tr>
<tr class=bg_td>
<td height=30>搜索方式：</td>
<td><input type=radio name=sea_type value='topic' checked class=bg_td>&nbsp;按主题搜索&nbsp;&nbsp;<input type=radio name=sea_type value='username' class=bg_td>&nbsp;按作者搜索（发表主题的作者）</td>
</tr>
<tr class=bg_td>
<td></td>
<td height=50><input type=submit value='开始搜索'>&nbsp;&nbsp;&nbsp;&nbsp;<input type=reset value='重新填写'></td>
</tr>
</form>
</table>
<%
end sub

function forum_search_fid(nfid)
  if not joekoe_cms.int_true(nfid) then
    forum_search_fid=""
    exit function
  end if
  dim fp,temp1
  sql="select top 1 forum_parent from bbs_forum where forum_hidden=0 and forum_id="&nfid
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    forum_search_fid=""
    exit function
  end if
  fp=rs(0)
  rs.close
  temp1=nfid
  sql="select forum_id from bbs_forum where forum_hidden=0 and left(forum_parent,"&(len(fp)+1)&")='"&fp&",' order by forum_id"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    temp1=temp1&","&rs(0)
    rs.movenext
  loop
  rs.close
  forum_search_fid=temp1
end function

sub forum_search_chk()
  call format_search("topic","topic,username",2,1)
  if var_null(keyword)="" then
    call forum_search_main()
    exit sub
  end if
  pageurl=pageurl&"action="&action&"&"
  dim fid,fids
  fid=trim(request.querystring("sea_fid"))
  fids=forum_search_fid(fid)
  if var_null(fids)="" then
    fid=""
  else
    if sql_add="" then
      'sql_add=" where forum_id="&fid
      sql_add=" where forum_id in ("&fids&")"
    else
      'sql_add=sql_add&" and forum_id="&fid
      sql_add=sql_add&" and forum_id in ("&fids&")"
    end if
    pageurl=pageurl&"sea_fid="&fid&"&"
  end if
%>
<table cellspacing=1 cellpadding=4 class=table>
<tr align=center>
<td class=td width=30>状态</td>
<td class=td width=*><%response.write img_skin("fk_plus")&"论坛主题（"+tit+"）"%></td>
<td class=td width=90>作者</td>
<td class=td width=70>回复/人气</td>
</tr>
<%
  sql="select count(id) from bbs_topic "&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  if rssum>max_num and max_num>0 then rssum=max_num
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from bbs_topic "&sql_add&" order by id desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,0,1
  if rs.eof then
    nums=0
  else
    if int(viewpage)>1 then rs.move (viewpage-1)*nummer
    if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  end if
  for i=1 to nums
    response.write vbcrlf&forum_topic_type(rs("id"),rs("forum_id"),joekoe_cms.code_html(rs("topic"),1,0),joekoe_cms.time_type(rs("tim"),2),rs("username"),rs("re_username"),joekoe_cms.time_type(rs("re_tim"),2),rs("counter"),rs("re_counter"),rs("istop"),rs("islock"),rs("isgood"),rs("isvote"),rs("vote_num"))
    rs.movenext
  next
  rs.close
%>
<tr class=bg_tds>
<td colspan=3 height=<%response.write m_hei%>>
&nbsp;共&nbsp;<font class=red><%response.write rssum%></font>&nbsp;贴搜索结果
&nbsp;页次：<font class=red><%response.write viewpage%></font>/<font class=red><%response.write thepages%></font>&nbsp;
&nbsp;分页：<%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")%>
</td>
<td align=center><b><a href='?sea_fid=<%response.write fid%>'>重新搜索</a></b></td>
</tr>
</table>
<table border=0><tr><td height=30><%response.write img_topic%></td></tr></table>
<%
end sub

function forum_topic_type(t_id,t_forum_id,t_topic,t_tim,t_username,t_re_username,t_re_tim,t_counter,t_re_counter,t_istop,t_islock,t_isgood,t_isvote,t_vote_num)
  dim temp1
  temp1=temp1&vbcrlf&"<tr class=bg_td align=center>" & _
              vbcrlf&"<td>"&base_forum_is(t_re_counter,t_istop,t_islock,t_isgood,t_isvote,t_vote_num)&"</td>" & _
              vbcrlf&"<td align=left><a href='forum_view.asp?forum_id="&t_forum_id&"&view_id="&t_id&"' target=_blank alt='<b>"&joekoe_cms.code_html(t_topic,1,0)&"</b><br>发表时间："&t_tim&"<br>最后回复："&t_re_username&"<br>回复时间："&t_re_tim&"'>"&joekoe_cms.code_html(t_topic,1,28)&"</td>" & _
              vbcrlf&"<td>"&format_user_name(t_username,5,"")&"</td>" & _
              vbcrlf&"<td class=tims>"&t_re_counter&"/"&t_counter&"</td>" & _
              vbcrlf&"</tr>"
  forum_topic_type=temp1
end function

function forum_isaction_list(il_forumid)
  dim temp1,ncid,forumn,nfid,classid
  ncid=0
  temp1="<select name=sea_fid><option value='' class=bg_tds>搜索所有论坛分区</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")
    if int(ncid)<>int(classid) then
      temp1=temp1&vbcrlf&"<option class=bg_td>╋"&rs("forum_name")&"</option>"
      ncid=classid
    else
      forumn=rs("forum_n")
      nfid=rs("forum_id")
      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
%>