<!-- #include file="include/config.asp" -->
<!-- #include file="include/fir.asp" -->
<!-- #include file="include/main.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,h_var3,0,0)
ftit=tit
call forum_grade2()
%>

<table border=0 cellspacing=0 cellpadding=0 class=bbs_tablew>
<tr align=center valign=top>
<td width=200>
<%
call search_left()
%>
</td>
<td width=5></td>
<td width="*">
<%
'----------------------------中间 开始----------------------------
response.write replace(forum_main_head(),"bbs_table","bbs_tables")

select case action
case "chk"
  call forum_search_chk()
case else
  call forum_search_main()
end select
response.write forum_main_end()
response.write vbcrlf&ukong
%>
</td></tr></table>
<%
'----------------------------中间 结束----------------------------
call web_end(0,0)

sub forum_search_main()
%>
<tr><td class=bbs_td colspan=2>论坛搜索</td></tr>
  <tr class=bbs_tr><td height=200 align=center>
    <table border=0>
    <tr>
    <td><img border=0 src="<%=joekoe_cms.web_dir_skin%>load.gif"></td>
    <td width=10></td>
    <td width=200 align=center class=blue>
请在左框输入搜索关键词
    </td>
    </tr>
<%
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()
  ta="#"
  if joekoe_cms.web_vt=1 then ta="'"
  call format_search("topic","topic,username",2,1)
  tim_start=trim(request.querystring("tim_start"))
  tim_end=trim(request.querystring("tim_end"))
  if isdate(tim_start) then  sql_add=sql_add&" and tim > "&ta&joekoe_cms.time_type(tim_start,4)&ta
  if isdate(tim_end) then  sql_add=sql_add&" and tim < "&ta&joekoe_cms.time_type(tim_end,4)&ta
  
  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
  
 ' response.write forum_main_head()
%>

<tr align=center>
<td class=bbs_td width=30>状态</td>
<td class=bbs_td  width=*><%response.write img_skin("fk_plus")&"论坛主题（"+tit+"）"%></td>
<td class=bbs_td  width=90>作者</td>
<td class=bbs_td  width=70>回复/人气</td>
</tr>
<%
 if sql_add="" then
 sql_add=" where forum_id<>999999999 "
 else
 sql_add= sql_add & " and forum_id<>999999999 "
 end if
  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=bbs_trb>
<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>
<%
'response.write forum_main_end()
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
  dim isnew
  if topic_is_new(t_tim)="new" then 
  isnew="&nbsp;"&img_skin("ico_new")
  else
  isnew=""
  end if
  temp1=temp1&vbcrlf&"<tr class=bbs_tr align=center>" & _
              vbcrlf&"<td>"&base_forum_is(t_re_counter,t_islock,t_isvote,t_vote_num)&"</td>" & _
              vbcrlf&"<td align=left><a href='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)&isnew&"</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 topic_is_new(t_time)
  dim isnew
  isnew=""
  if datediff("d",t_time,joekoe_cms.now_time)<2 then isnew="new"
  topic_is_new=isnew
end function


%>