<!--#include file="conn.asp" -->
<!--#include file="ftbbs_nav.asp" -->
<!--#include file="inc/publicfun.asp" -->
<%
searchcontent=Checkstr(trim(request("searchcontent")))'搜索内容
searchkind=request("searchkind")'搜索类别
tyname1="searchkind"
tyvalue1=searchkind
tyname2="searchcontent"
tyvalue2=searchcontent	
call FTBBS_HTML_MB
defaulthome=Application("FTBBSMB")(31,0)
homepage=ft_home(defaulthome)
'++++++++++++++++++++++++++++++++++++++++++++++
'以下是新增论坛权限访问的功能
if request.cookies("name")="" then
   strqssql="where BBS_Cate_Qs=1 or BBS_Cate_Qs=2 or BBS_Cate_Qs=3"
else
   if request.cookies("payuser")=1 then
      strqssql="where BBS_Cate_Qs=3"
   elseif request.cookies("bz")=1 or request.cookies("bbsadmin")=1 then
      strqssql=""
   else
      strqssql="where BBS_Cate_Qs=2 or BBS_Cate_Qs=3"
   end if
end if

strqs=""
qssqlstr1=""
qssql="select BBS_Cate_ID from BBS_Cate "&strqssql&""
'qssql="select DISTINCT BBS_Cate_ID from BBS_Cate "&strqssql&""
set qsrs=server.createobject("adodb.recordset")
qsrs.open qssql,conn,1,1
if not qsrs.eof and strqssql<>"" then
   qsnum=qsrs.recordcount
  if qsnum>1 then
     i=0
    do while not qsrs.eof
      if i=qsnum-1 then
	        qsbbsx1=qsrs("BBS_Cate_ID")
	  else
            qsbbsx1=qsrs("BBS_Cate_ID")&","
	  end if
	  qsbbs1=qsbbs1&qsbbsx1
      qsrs.movenext
	  i=i+1
    loop
     qsarray1=split(qsbbs1,",")
   for k = 0 to UBound(qsarray1)
     if k=UBound(qsarray1) then
	 qssqlstrx = "Boardid_1<>'" & qsarray1(k) &"' and Boardid_2<>'" & qsarray1(k) &"'"
	 else
	 qssqlstrx = "Boardid_1<>'" & qsarray1(k) &"' and Boardid_2<>'" & qsarray1(k) &"' and "
	 end if
	 qssqlstr1 = qssqlstr1&qssqlstrx
   next
    qssqlstr1 = ""&qssqlstr1
 else
    qssqlstr1 = "Boardid_1<>'"&qsrs("BBS_Cate_ID") &"' and Boardid_2<>'"&qsrs("BBS_Cate_ID")&"'" ' &"' and "
 end if
  strqs=qssqlstr1&" and "
end if
qsrs.close

'++++++++++++++++++++++++++++++++++++++++++++++
dim rssql,getstring
'******************************************
dim wzcount,wzrep,wzpage,wzpagecount,wzpagerep,boardstr
wzrep = Application("FTBBSMB")(5,0)
'+++++++++++++++++++++++++++
'1.已登录的用户搜索将按用户权限查找出相应权限贴子
'2.没有登录的就只能查找出所有用户可以查看的贴(BBS_cate_Qs=0)
'3.我参与的贴子查找
if searchkind="menu" then
   strsql="SELECT id,Boardid_1,Boardid_2,user_id,name,title,hit,rep,dateh,redate,bbs_img,bbs_img_display,huati,img_url_display,P_display,picture,sign,zhiye,htmfilename,bbstop,bbstop1,titlecolor,boardsign,reinfo FROM bbstitle WHERE "&strqs&" (id IN(SELECT pid FROM bbsmenu WHERE (id IN(SELECT MAX(id) FROM bbsmenu where remenu like '%"&searchcontent&"%' GROUP BY pid))) or menu like '%"&searchcontent&"%') and deleted=0 order by bbstop1 desc,bbstop desc,redate desc"
elseif searchkind="myrepost" then
   strsql="SELECT id,Boardid_1,Boardid_2,user_id,name,title,hit,rep,dateh,redate,bbs_img,bbs_img_display,huati,img_url_display,P_display,picture,sign,zhiye,htmfilename,bbstop,bbstop1,titlecolor,boardsign,reinfo FROM bbstitle WHERE "&strqs&" id IN(SELECT pid FROM bbsmenu WHERE (id IN(SELECT MAX(id) FROM bbsmenu where user_id='"&request.cookies("name")&"' GROUP BY pid))) and deleted=0 order by bbstop1 desc,bbstop desc,redate desc"
elseif searchkind="title" then
   strsql="SELECT id,Boardid_1,Boardid_2,user_id,name,title,hit,rep,dateh,redate,bbs_img,bbs_img_display,huati,img_url_display,P_display,picture,sign,zhiye,htmfilename,bbstop,bbstop1,titlecolor,boardsign,reinfo from bbstitle where "&strqs&" title like '%"&searchcontent&"%' and deleted=0 order by bbstop1 desc,bbstop desc,redate desc"
elseif searchkind="user_id" then
   strsql="SELECT id,Boardid_1,Boardid_2,user_id,name,title,hit,rep,dateh,redate,bbs_img,bbs_img_display,huati,img_url_display,P_display,picture,sign,zhiye,htmfilename,bbstop,bbstop1,titlecolor,boardsign,reinfo from bbstitle where "&strqs&" user_id='"&searchcontent&"' and deleted=0 order by bbstop1 desc,bbstop desc,redate desc"
else
   strsql="SELECT id,Boardid_1,Boardid_2,user_id,name,title,hit,rep,dateh,redate,bbs_img,bbs_img_display,huati,img_url_display,P_display,picture,sign,zhiye,htmfilename,bbstop,bbstop1,titlecolor,boardsign,reinfo from bbstitle where "&strqs&" deleted=0 and (bbstop1=1 or bbstop=1) order by redate desc"
end if
set rs=server.createobject("adodb.recordset")
rs.open strsql,conn,1,1
%>
<HTML><HEAD>
<title>论坛贴子搜索</title>
<META http-equiv=Content-Type content=text/html;charset=gb2312>
<script language=javascript src="inc/cookies.js"></script>
<script>
var stylecook = getCookie("STYLESHOW");
var style;
var strstyle;
if(stylecook=="")
{
 stylecook=1;
}
else
{
 stylecook++;
}
style="main0"+stylecook+".css";
strstyle="<link href=\"css/"+style+"\"  rel=\"stylesheet\" type=\"text/css\"> ";
document.write(strstyle);
</script>
</HEAD>
</head>
<script language="javascript">
<!--
	function check_search(form)
		{
		if (form.searchcontent.value=="")
			{
			alert("请输入搜索内容！");
			form.searchcontent.fors();
			return false;
			}
			return true;
		}
//-->
</script>
<body>
<%
if request.cookies("ftbbstype")=1 then
  response.write headhtml
end if
%>
<table width="99%" border="0" cellspacing="0" cellpadding="0" align="center" class="maintbbg">
  <tr>
    <td> 
      <table width="100%" border=0 cellpadding=2 cellspacing=1 class="maintbbg">
        <tbody>
		<%if request.cookies("ftbbstype")<>1 then%>
          <tr> 
            <td height="25" class="f12bg">&nbsp;<%=userinfo%></td>
          </tr>
		<%end if%>
          <tr> 
            <td height="25" colspan="3" class="maintbtr3">&nbsp;<a href="<%=homepage%>">论坛首页</a> 
              >> 贴子搜索</td>
          </tr>
          <tr>
            <td height="30" class="maintbtr3">
<fieldset>
			<legend>论坛贴子搜索:</legend>
              <form name="form1" method="post" action="" onSubmit="return check_search(this)">
                &nbsp;&nbsp;搜索关键字:
                <input name="searchcontent" type="text" size="35">
                <select name="searchkind" style="background-color:#ffffff;FONT-FAMILY: Arial; FONT-SIZE: 9pt; FONT-STYLE: normal; WIDTH: 65px">
                  <option value="title" selected>按主题</option>
                  <option value="user_id" >按作者</option>
				  <option value="menu" >按内容</option>
                </select>
                <input name="search" src="images/d_search.gif" type="image" value="Submit" width="37" height="21" border="0" align="absmiddle" style="width:37px;height:21px;">
              </form>
			</fieldset>
            </td>
          </tr>
        </tbody>
      </table>
      <table cellspacing=0 cellpadding=0 width="100%" align=center border=0>
        <tbody>
          <tr> 
            <td class="maintbtr1" height=5></td>
          </tr>
        </tbody>
      </table>
      <table width="100%" border=0 cellpadding=2 cellspacing=1 class="maintbbg" align="center">
        <tbody>
          <tr align=middle class=f12> 
            <td width="6%" height="26" class="f12bg">状态</td>
            <td width="50%" class="f12bg" >论坛主题</td>
            <td width="5%" class="f12bg" >作者</td>
            <td width="6%" class="f12bg" >回复</td>
            <td width="6%" class="f12bg" >点击</td>
            <td width="25%" class="f12bg" >最后更新</td>
          </tr>
          <%
if not rs.eof then
   dim i,bgcolor
   wzpage = clng(request("page"))
   
   if len(wzpage) = 0 or wzpage = 0 then wzpage = 1
   rs.PageSize=wzrep
   rs.AbsolutePage=wzpage
   wzpagecount=rs.PageCount
   wzcount=rs.RecordCount
   for i = 0 to wzrep-1
   if rs.eof then exit for  
	indbdate=rs("redate")
	year1=right(year(indbdate),2)
	month1=right("0"&month(indbdate),2)
	day1=right("0"&day(indbdate),2)
	hour1=right("0"&hour(indbdate),2)
	minute1=right("0"&minute(indbdate),2)
	indbdate=year1&"-"&month1&"-"&day1&" "&hour1&":"&minute1

	reinfo=rs("reinfo")
	if instr(reinfo,"||")>0 then
	rearr=split(reinfo,"||")
	arrnum=UBound(rearr)
	reinfo=rearr(arrnum)
	end if
	if reinfo<>"" and instr(reinfo,",")>0 then
	reinfo=replace(reinfo,"|","")
	rearr=split(reinfo,",")
	replydate=rearr(0)
	replyuser="<font color=red>|</font><a class=map href=ftbbsmyinfo.asp?ftbbsuser="&rearr(1)&">"&rearr(1)&"</a>"
	replydate=right(year(replydate),2)&"-"&month(replydate)&"-"&day(replydate)&" "&hour(replydate)&":"&minute(replydate)
	else
	replydate=indbdate
	replyuser=""
	end if
%>
          <tr align=middle> 
            <td width="5%" height="28" class="maintbtr1"> 
              <%if rs("bbstop1")="1" then
              response.write "<a class=f14 href=""ftbbs.asp?id="&rs("id")&""" target=""_blank""><img src=""images/ding.gif"" alt=""总固顶的主题&#xA;点击开新窗口浏览"" width=""15"" height=""13"" border=""0"" align=""absmiddle"" board=0></a>"
              elseif rs("bbstop")="1" then
              response.write "<a class=f14 href=""ftbbs.asp?id="&rs("id")&""" target=""_blank""><img src=""images/blueding.gif"" width=""15"" height=""13"" align=""absmiddle"" border=""0"" alt=""分论坛固顶的主题&#xA;点击开新窗口浏览""></a>" 
              elseif rs("sign")="1" then
              response.write "<a class=f14 href=""ftbbs.asp?id="&rs("id")&""" target=""_blank""><img src=""images/jian.gif"" width=""15"" height=""13"" align=""absmiddle"" border=""0"" alt=""版主推荐的话题&#xA;点击开新窗口浏览""></a>" 
              elseif rs("huati")="1" then
              response.write "<a class=f14 href=""ftbbs.asp?id="&rs("id")&""" target=""_blank""><img src=""images/jing.gif"" width=""15"" height=""13"" align=""absmiddle"" border=""0"" alt=""版主精选的话题&#xA;点击开新窗口浏览""></a>" 
              elseif rs("P_display")="0" then
              response.write "<a class=f14 href=""ftbbs.asp?id="&rs("id")&""" target=""_blank""><img src=""images/suo.gif"" width=""12"" height=""13"" align=""absmiddle"" border=""0"" alt=""分论坛固顶的主题&#xA;点击开新窗口浏览""></a>" 
              elseif rs("hit")>=500 then
              response.write "<a class=f14 href=""ftbbs.asp?id="&rs("id")&""" target=""_blank""><img src=""images/hotpost.gif"" width=""14"" height=""16"" align=""absmiddle"" border=""0"" alt=""热门的话题&#xA;点击开新窗口浏览""></a>" 
              else
              response.write "<a class=f14 href=""ftbbs.asp?id="&rs("id")&""" target=""_blank""><img src=""images/normal.gif"" width=""14"" height=""16"" align=""absmiddle"" border=""0"" alt=""开放的话题&#xA;点击开新窗口浏览""></a>" 
              end if%>
            </td>
            <td width="52%"  align=left valign="middle" class="maintbtr2"> <a class=f14 href="ftbbs.asp?id=<%=rs("id")%>" title="<%=rs("title")%>&#xA;作者:<%=rs("user_id")%>&#xA;发表于:<%=indbdate%>" target="_blank"><%=rs("title")%></a> 
               <%
			  if rs("bbs_img_display")=1 then
              response.write "<img src=""images/picflag.gif"" width=""13"" height=""13"" align=""absmiddle"" alt=""附带图片"">" 
              end if
			  pagenum=Application("FTBBSMB")(6,0)
              k=rs("rep")/pagenum
			  if int(k)=k then
   			  page=k
			  else
   			  page=int(k)+1
			  end if
			  if page>1 then
			    response.write "["
			    for z=1 to page
				   if z>=4 and page>6 then
				      response.write "..<a href=ftbbs.asp?id="&rs("id")&"&page="&page&"><font color=red>"&page&"</font></a>"    
				      exit for
				   end if
				   if z=1 then
				   response.write "<a href=ftbbs.asp?id="&rs("id")&"&page="&z&"><font color=red>"&z&"</font></a> "
				   else
				   response.write " <a href=ftbbs.asp?id="&rs("id")&"&page="&z&"><font color=red>"&z&"</font></a>"
				   end if
				next
				response.write "]"
			  end if
			  %>
            </td>
            <td width="7%" class="maintbtr1"><a href="ftbbsmyinfo.asp?ftbbsuser=<%=rs("user_id")%>"><%=rs("user_id")%></a></td>
            <td width="3%" class="maintbtr3"> <%=rs("rep")%></td>
            <td width="6%" class="maintbtr3"><%=rs("hit")%></td>
            <td width="16%" class="maintbtr3"><div align="left"><%response.write replydate&replyuser%></div></td>
          </tr>
<%
rs.movenext
next
%>
          <tr valign="top"> 
            <td colspan="7" class="maintbtr1"><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr> 
                  <td height="20" align="left"><%= SearchPage(wzpagecount,tyname1,tyvalue1,tyname2,tyvalue2)%></td>
				  <td align="right" width="200"><script src="ftbbsdh.js"></script></td>
                </tr>
              </table></td>
          </tr>
          <%else%>
          <tr class="maintbtr3"> 
            <td colspan=7 align=center height=25> 没有找到相关贴子！ </td>
          </tr>
          <%end if%>
        </tbody>
      </table>
    </td>
  </tr>
</table>
<!--#include file="inc/bbstail.htm"-->
<%CloseDb%>