<!--#include file="../inc/conn.asp" -->
<!--#include file="../inc/pagefunction.asp"-->
<!--include file="../inc/code.asp"-->
<%
'StarTime = Timer()
on error resume next
if request("exit")="yes" then
   session("bbsuser")=""
   session("name")=""
   session("manager_lp_id")=""
   session("bbs_email")=""
   session("bz")=""
   session("bbsadmin")=""
   'session.Abandon()
   Response.Cookies("bbsuser")=""
   Response.Cookies("name")=""
   Response.Cookies("bz")=""
   Response.Cookies("bbsadmin")=""
   Response.Cookies("payuser")=""

   response.write "<script language='javascript'>"
   response.write "window.location.href='main.asp';"
   response.write "parent.left.document.location.reload();"
   response.write "</script>"
end if
call FTBBS_HTML_MB
jh=request.QueryString("huati")
tj=request.QueryString("sign")
jhtj=""
jhortj=""
order_key=request("order_key")'排序方式
if order_key="" then
	'order_key="bbstop desc,sign desc,huati desc,redate" '默认排序方式:跟贴时间
	'order_key="redate"
	order_key="bbstop desc,redate"
end if
'=======================
layer_1=request("layer_1")'一级类别
if layer_1="" then'总论坛
	BBS_Cate_Manager_Name="FTBBS"
	BBS_Cate_Manager_Email="cht21@163.com"
end if

if layer_1<>"" then	
'一级类别名称
str_BBS_Cate="select BBS_Cate_Name,BBS_Cate_Manager_Name,BBS_Cate_Manager_Email,BBS_Cate_Topic,BBS_Cate_Reply from BBS_Cate where BBS_Cate_ID='"&layer_1&"' and deleted=0"
set rs_BBS_Cate=server.createobject("adodb.recordset")
rs_BBS_Cate.open str_BBS_Cate,conn,1,1
'论坛已经关闭
if rs_BBS_Cate.eof then
	response.write "<center><P><P><P>该论坛已经关闭...</center>"
	response.end
end if

BBS_Cate_Name_1=rs_BBS_Cate("BBS_Cate_Name")'一级类别名称
BBS_Cate_Manager_Name=rs_BBS_Cate("BBS_Cate_Manager_Name")'一级类别板主姓名
BBS_Cate_Manager_Email=rs_BBS_Cate("BBS_Cate_Manager_Email")'一级类别板主email
BBS_Cate_Topic=rs_BBS_Cate("BBS_Cate_Topic")'一级类别主题贴子数
BBS_Cate_Reply=rs_BBS_Cate("BBS_Cate_Reply")'一级类别回复贴子数
rs_BBS_Cate.close
end if

'==============================
layer_2=request("layer_2")'二级类别
IF layer_2<>"" then
'二级类别名称
str_BBS_Cate="select BBS_Cate_Name,BBS_Cate_Manager_Name,BBS_Cate_Manager_Email,BBS_Cate_Topic,BBS_Cate_Reply,Loupan_ID from BBS_Cate where BBS_Cate_ID='"&layer_2&"' and deleted=0"
rs_BBS_Cate.open str_BBS_Cate,conn,1,1

'论坛已经关闭
if rs_BBS_Cate.eof then
	response.write "<center><P><P><P>该论坛已经关闭...</center>"
	response.end
end if

BBS_Cate_Name_2=rs_BBS_Cate("BBS_Cate_Name")'二级类别名称
BBS_Cate_Manager_Name=rs_BBS_Cate("BBS_Cate_Manager_Name")'二级类别板主姓名
BBS_Cate_Manager_Email=rs_BBS_Cate("BBS_Cate_Manager_Email")'二级类别板主email
BBS_Cate_Topic=rs_BBS_Cate("BBS_Cate_Topic")'二级类别主题贴子数
BBS_Cate_Reply=rs_BBS_Cate("BBS_Cate_Reply")'二级类别回复贴子数
Loupan_ID=rs_BBS_Cate("Loupan_ID")
rs_BBS_Cate.close
end if

set rs_BBS_Cate=nothing
'==========================================
'**************
'分页导航栏函数
'**************
Function pagination(pagecount)
   Dim wzpage,wzpagecount,pagenum,boardid
       If Len(Request.QueryString("page"))<>0 Then
          wzpage = clng(Request.QueryString("page"))
         Else 
          wzpage =1
       End If
       If wzpage <= 0 Then wzpage =1
       pagenum = (wzpage \ 10)*10+1
       If wzpage mod 10 = 0 Then pagenum = (wzpage \ 10)*10-9
       If wzpage > 10 Then
            Response.Write ("<font face=""webdings"">")
            Response.Write ("<a href=""?page=1&layer_1="&layer_1&"&layer_2="&layer_2&"&huati="&jh&"&sign="&tj&""" title=""首页"">9</a> ")
            Response.Write ("<a href=""?page="& pagenum-1 &"&layer_1="&layer_1&"&layer_2="&layer_2&"&huati="&jh&"&sign="&tj&""" title=""前十页"">7</a> ")
            Response.Write ("</font>")
       End If
       For pagenum = pagenum To pagenum + 9
	   
           If pagenum = wzpage Then
                  Response.Write ("<font color=""#ff0000"">")
                  Response.Write (" ["& pagenum &"] ")
                  Response.Write ("</font>")
           Else
                  Response.Write (" <a href=""?page="& pagenum &"&layer_1="&layer_1&"&layer_2="&layer_2&"&huati="&jh&"&sign="&tj&""">")
                  Response.Write ("["& pagenum &"]")
                  Response.Write ("</a> ")
           End If
		  
         If pagenum >= pagecount Then Exit For
       Next
	   
     If wzpage < (pagecount - (pagecount \ 10))  Then
            Response.Write ("<font face=""webdings"">")
            Response.Write ("<a href=""?page="& pagenum &"&layer_1="&layer_1&"&layer_2="&layer_2&"&huati="&jh&"&sign="&tj&"""  title=""后十页"">8</a> ")
            Response.Write ("<a href=""?page="& pagecount &"&layer_1="&layer_1&"&layer_2="&layer_2&"&huati="&jh&"&sign="&tj&"""  title=""末页"">:</a> ")
            Response.Write ("</font>")
     End If
End Function

searchcontent=trim(request("searchcontent"))'搜索内容
searchkind=request("searchkind")'搜索类别

if jh="1" then
   jhtj="and huati="&jh
   jhortj=" and huati="&jh
end if
if tj="1" then
   jhtj="and sign="&tj
   jhortj=" and sign="&tj
end if

dim rssql,getstring
'******************************************
dim wzcount,wzrep,wzpage,wzpagecount,wzpagerep,boardstr
wzrep = Application("FTBBSMB")(5,0)

if searchkind<>"" then
  searchstr3=" and "&searchkind&" like '%"&searchcontent&"%'"
end if

if layer_1<>"" and layer_2="" then
   if searchkind<>"" then
   searchstr1="where boardid_1='"&layer_1&"'"
   else
   searchstr1="where boardid_1='"&layer_1&"'"
   end if
elseif layer_1="" then
   if searchkind<>"" then
   searchstr1="where "&searchkind&" like '%"&searchcontent&"%'"
   searchstr3=""
   else
   searchstr1=""
   searchstr2=""
   searchstr3=""
      if jh="1" then
      jhtj="where huati="&jh
	  jhortj=" and huati="&jh
	  end if
      if tj="1" then
      jhtj="where sign="&tj
	  jhortj=" and sign="&tj
      end if
   end if
end if

if layer_1<>"" and layer_2<>"" then
   if searchkind<>"" then
   searchstr2="where boardid_1='"&layer_1&"' and boardid_2='"&layer_2&"'"&searchstr3
   else
   searchstr2="where boardid_1='"&layer_1&"' and boardid_2='"&layer_2&"'"
   end if
end if

aaa="select count(id) from bbstitle "&searchstr1&searchstr2&searchstr3&jhtj

wzcount = conn.execute (aaa,0,1)(0)
wzpagecount = abs(int(-abs(wzcount/wzrep)))
wzpage = clng(request.querystring("page"))
if len(wzpage) = 0 or wzpage = 0 then wzpage = 1

if searchkind="" then'正常浏览方式
	search_str=" "
elseif searchkind="title" then'主题搜索方式
	search_str=" and title like '%"&searchcontent&"%' "
elseif searchkind="user_id" then'用户搜索方式
	search_str=" and user_id= '"&searchcontent&"' "
elseif searchkind="name" then '新增
    if request.cookies("name")="" then
       response.write "<script language='javascript'>"
       response.write "alert('你还没有登录论坛，请先登录！');"
       response.write "history.go(-1);"
       response.write "</script>"
       response.end
	end if
	search_str=" and name= '"&searchcontent&"' "
end if

'========================================
if layer_1="" then'总论坛
	strsql="select id,Boardid_1,Boardid_2,user_id,name,title,hit,rep,dateh,redate,bbs_img_display,huati,img_url_display,P_display,picture,sign,htmfilename,bbstop,bbstop1,titlecolor from bbstitle where deleted=0 "&search_str&" "&jhortj&" order by "&order_key&" desc"
else
	if layer_2="" then'一级类别论坛
		strsql="select id,Boardid_1,Boardid_2,user_id,name,title,hit,rep,dateh,redate,bbs_img_display,huati,img_url_display,P_display,picture,sign,htmfilename,bbstop,bbstop1,titlecolor from bbstitle where deleted=0 and boardid_1='"&layer_1&"'"&search_str&" "&jhortj&" order by "&order_key&" desc"
	else'二级类别论坛
		strsql="select id,Boardid_1,Boardid_2,user_id,name,title,hit,rep,dateh,redate,bbs_img_display,huati,img_url_display,P_display,picture,sign,htmfilename,bbstop,bbstop1,titlecolor from bbstitle where deleted=0 and boardid_1='"&layer_1&"' and boardid_2='"&layer_2&"' "&jhortj&" order by "&order_key&" desc"
	end if
end if

set cus=server.createobject("adodb.recordset")
cus.open strsql,conn,1,1
cus.absoluteposition=cus.absoluteposition+((abs(wzpage)-1)*wzrep)
%>
<HTML><HEAD>
<title>老宫在线</title>
<META http-equiv=Content-Type content=text/html;charset=gb2312>
<link href="../css/news2.css" rel="stylesheet" type="text/css">
<STYLE type=text/css>
BODY {
	BACKGROUND: #ffffff; MARGIN: 5px
}
.sec_menu {
	BORDER-RIGHT: white 1px solid; BACKGROUND: #d6dff7; OVERFLOW: hidden; BORDER-LEFT: white 1px solid; BORDER-BOTTOM: white 1px solid
}
.menu_title SPAN {
	FONT-WEIGHT: bold; LEFT: 10px; COLOR: #215dc6; POSITION: relative; TOP: 2px
}
.menu_title2 SPAN {
	FONT-WEIGHT: bold; LEFT: 10px; COLOR: #428eff; POSITION: relative; TOP: 2px
}
</STYLE>
</HEAD>
<script language=javascript src="../inc/wyjs.js"></script>

<script language="javascript">
<!--
	function check_search(form)
		{
		if (form.searchcontent.value=="")
			{
			alert("请输入搜索内容！");
			form.searchcontent.focus();
			return false;
			}
			return true;
		}
//-->
</script>
<script language="javascript">
<!--

function check(form)
	{
    if (form.bbsuser.value=="")
    	{
    		alert("请填写用户名！");
    		form.bbsuser.focus();
    		return false;
  	}
    if (form.password.value=="")
    	{
    		alert("请填写密码！");
    		form.password.focus();
    		return false;
  	}
return true;
	}
//-->
</script>
<SCRIPT LANGUAGE="VBScript"> 
<!--
Sub order_key_OnChange
	if document.jump.order_key.value <> "" then
		document.jump.action = "../bbs/main.asp?layer_1=<%=layer_1%>&layer_2=<%=layer_2%>&order_key="&document.jump.order_key.value&"&Searchkind=<%=Searchkind%>&Searchcontent=<%=Searchcontent%>"
		jump.submit
	end if
End Sub
-->
</SCRIPT>

<table width="835" border="0" align="center" cellpadding="2" cellspacing="1" bordercolor="#A4B6D7" class="aaaa">
  <tr>
    <td width="835"><a target="_blank" href="http://www.pceggs.com/pgComDefault.aspx?ID=249973"><img src="http://www.unionsky.cn/pceggs/tuiguang/img/775x60.gif" border="0" /></a></td>
  </tr>
</table>
<table width="99%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td> 
      <table width="100%" border=0 cellpadding=2 cellspacing=1 bgcolor="#A4B6D7">
        <tbody>
          <tr> 
            <td width="51%" background="../images/bbs_bg1.gif" ><img src="../images/bbs_t1.gif" align="absmiddle"> 
              <%if layer_1<>"" then%>
              <a href="../bbs/main.asp?layer_1=<%=layer_1%>"><%=BBS_Cate_Name_1%></a> 
              <%if layer_2<>"" then%>
              >> 
              <%if layer_1="A_3" then'连接楼盘%>
              <!--<a href="../loupan/display.asp?id=<%=encode(Loupan_ID)%>" target=_blank><%=BBS_Cate_Name_2%></a>-->
              <%=BBS_Cate_Name_2%> 
              <%else%>
              <%=BBS_Cate_Name_2%> 
              <%
						end if
					end if
					%>
              <%else%>
              <a href="../bbs/main.asp">首页</a> 
              <%end if%>
            </td>
            <td width="49%" align=right background="../images/bbs_bg1.gif" > <div align="center"><a href="main.asp?layer_1=<%=layer_1%>&layer_2=<%=layer_2%>&huati=1">精华贴</a> 
                <a href="main.asp?layer_1=<%=layer_1%>&layer_2=<%=layer_2%>&sign=1">推荐贴</a> 
                在线：<font color=red><%=Application("onlineuser")%></font>人 
                站长:宫静</div>
            </td>
          </tr>
        </tbody>
      </table>
      <table cellspacing=0 cellpadding=0 width="100%" border=0>
        <tbody> 
        <tr> 
            <td width="30%" height="40"><a href="fbht.asp?layer_1=<%=request("layer_1")%>&layer_2=<%=request("layer_2")%>"><img src="../images/bbs_add.gif" width="81" height="21" border="0"></a>&nbsp;<a href="bbspoll.asp?layer_1=<%=request("layer_1")%>&layer_2=<%=request("layer_2")%>"><img src="../images/poll_add.gif" width="81" height="21" border="0"></a></td>
          <FORM METHOD=POST ACTION="main.asp" onSubmit="return check_search(this)">
            <td width="50%" align=right> 
              <div align="center"><img src="../images/bbs_find.gif" width="16" height="16"> 
                  <input type="hidden" name="layer_1" value="<%=layer_1%>">
                  <input type=text name=searchcontent size=15 class=p1 value="">
                <select name="searchkind" style="width:60">
                  <option value="title" selected>按主题</option>
                  <option value="user_id" >按用户名</option>
                </select>
                <input name="search" src="../images/d_search.gif" type="image" value="Submit" width="37" height="21" border="0" align="absmiddle"> 
                <img src="../images/refesh.gif" width="37" height="21" align="absmiddle" onClick="javascript:window.location.reload();" style="CURSOR: hand">
              </div>
            </td>
          </form>
          <form name="jump" method="post" action="">     
            <td width="20%" valign="middle"> 
              <div align="center">排序 
                <select name="order_key" style="width:75px">
                  <option value="dateh" <%if order_key="dateh" then%>selected<%end if%>>发帖时间 
                  <option value="redate" <%if order_key="redate" then%>selected<%end if%> >跟帖时间 
                  <option value="hit" <%if order_key="hit" then%>selected<%end if%>>浏览量 
                  <option value="rep" <%if order_key="rep" then%>selected<%end if%>>跟帖数 
                </select>
                  <input name="layer_2" type="hidden" id="layer_2" value="<%=layer_2%>">
				  <input name="layer_1" type="hidden" id="layer_1" value="<%=layer_1%>">
                </div>
            </td>
          </form>
        </tr>
        </tbody> 
      </table>
      <table width="100%" border=0 cellpadding=2 cellspacing=1 bgcolor="#A4B6D7" align="center">
        <tbody> 
        <tr align=middle> 
          <td width="6%" background="../images/bbs_bg1.gif">点击</td>
            <td width="52%" background="../images/bbs_bg1.gif" >论坛主题</td>
            <td width="5%" background="../images/bbs_bg1.gif" >回复</td>
            <td width="11%" background="../images/bbs_bg1.gif" >作者</td>
          <!--<td width="10%" background="../images/bbs_bg1.gif" >所属论坛</td>-->
            <td width="25%" background="../images/bbs_bg1.gif" >最后更新</td>
        </tr>
        <%
if not cus.eof then
   dim i,bgcolor
  for i = 0 to wzrep-1
     if cus.eof then exit for
'while not cus.eof and i <= wzrep
    bgColor="#FFFFFF"
    if i mod 2=0 then bgColor="#DFEFFF"	
	'日期
	indbdate=cus("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
	titlecolor=cus("titlecolor")
	bbstitle=cus("title")
	if titlecolor<>"" then
	title="<font color="&titlecolor&">"&bbstitle&"</font>"
	else
	title=bbstitle
	end if
    str="select top 1 user_id,rename from bbsmenu where pid="&cus("id")&" order by id desc"
    set rers=server.createobject("adodb.recordset")
    rers.open str,conn,1,3
%>
        <tr align=middle> 
          <td bgcolor="#ECF5FF" width="6%" height="28"> <%if cus("hit")>=500 then response.write "<font color=red>"&cus("hit")&"</font>" else response.write cus("hit") end if%></td>
            <td width="52%"  align=left valign="middle" bgcolor="#F2F8FF">
			<%if layer_1="" then%>
              <%if cus("bbstop")="1" then%>
              <img src="IMAGES/ding.gif" width="15" height="13" align="absmiddle"> 
              <%end if%>
			<%else%>
              <%if cus("bbstop")="1" or cus("bbstop1")="1" then%>
              <img src="IMAGES/ding.gif" width="15" height="13" align="absmiddle"> 
              <%end if%>			
			<%end if%>
              <%if cus("sign")="1" then%>
              <img src="IMAGES/jian.gif" width="15" height="13" align="absmiddle"> 
              <%end if%>
              <%if cus("huati")="1" then%>
              <img src="IMAGES/jing.gif" width="15" height="13" align="absmiddle"> 
              <%end if%>
              <%if cus("P_display")="0" then%>
              <img src="IMAGES/suo.gif" width="12" height="13" align="absmiddle"> 
              <%end if%>
			  <%if cus("P_display")<>"0" and cus("bbstop")<>1 and cus("sign")<>"1" and cus("huati")<>"1" then%>
			  <img src="../images/<%=cus("picture")%>" width="19" height="19" align="absmiddle">
			  <%end if%>
              <a class=f14 href="../html/<%=cus("htmfilename")%>" title="<%=cus("title")%>" target="_blank"><%=title%></a>
			  <%if cus("bbs_img_display")=1 then%><font color=red>[图]</font><%end if%>
<%if year(cus("dateh")) & "-" & month(cus("dateh")) & "-" & day(cus("dateh"))=date()&"" then%><font color=red><img src="../images/new.gif"></font><%end if%>
			  <%
			  pagefilename=replace(cus("htmfilename"),".htm","")
			  pagenum=20 '每页显示20条
              k=cus("rep")/pagenum
			  if int(k)=k then
   			  page=k
			  else
   			  page=int(k)+1
			  end if
			  if page>1 then
			    response.write "[" '<img src=""IMAGES/pagelist.gif"" width=""10"" height=""12"" align=""absmiddle"">"
			    for z=2 to page
				   pagehtm=pagefilename&"_"&z&".htm"
				   if z>2 then
				   response.write " <a href=../html/"&pagehtm&" target=""_blank""><font color=red>"&z&"</font></a>"
				   else
				   response.write "<a href=../html/"&pagehtm&" target=""_blank""><font color=red>"&z&"</font></a>"
				   end if
				next
				response.write "]"
			  end if
			  %>		  
            </td>
          <td bgcolor="#ECF5FF" width="7%" ><%=cus("rep")%></td>
          <td bgcolor="#F2F8FF" width="9%" >
		  <a href="../bbs/main.asp?searchkind=user_id&searchcontent=<%=cus("user_id")%>&layer_1=<%=cus("boardid_1")%>"><%=cus("user_id")%></a></td>
          <!--<td bgcolor="#ECF5FF" width="10%" > 
            <%
			 if layer_1="" then'总论坛
				layer_1_temp=cus("Boardid_1")'一级类别
				layer_2_temp=cus("Boardid_2")'2级类别
				if layer_2_temp="" then'一级
						str_BBS_Cate="select BBS_Cate_Name from BBS_Cate where BBS_Cate_ID='"&layer_1_temp&"'"
						set rs_BBS_Cate=server.createobject("adodb.recordset")
						rs_BBS_Cate.open str_BBS_Cate,conn,1,1
						BBS_Cate_Name=rs_BBS_Cate("BBS_Cate_Name")'论坛名称
						rs_BBS_Cate.close
						set rs_BBS_Cate=nothing
						BBS_Cate_Link="main.asp?layer_1="&layer_1_temp'论坛连接地址
				else'2级
						str_BBS_Cate="select BBS_Cate_Name from BBS_Cate where BBS_Cate_ID='"&layer_2_temp&"'"
						set rs_BBS_Cate=server.createobject("adodb.recordset")
						rs_BBS_Cate.open str_BBS_Cate,conn,1,1
						BBS_Cate_Name=rs_BBS_Cate("BBS_Cate_Name")'论坛名称
						rs_BBS_Cate.close
						set rs_BBS_Cate=nothing
						BBS_Cate_Link="main.asp?layer_1="&layer_1_temp&"&layer_2="&layer_2_temp'论坛连接地址
				end if

			 else'分论坛

				if layer_2="" then'一级类别					
					if cus("boardid_2")="" then
						BBS_Cate_Name=BBS_Cate_Name_1'论坛名称
						BBS_Cate_Link="main.asp?layer_1="&layer_1'论坛连接地址
					else
						str_BBS_Cate="select BBS_Cate_Name from BBS_Cate where BBS_Cate_ID='"&trim(cus("boardid_2"))&"'"
						set rs_BBS_Cate=server.createobject("adodb.recordset")
						rs_BBS_Cate.open str_BBS_Cate,conn,1,1
						BBS_Cate_Name=rs_BBS_Cate("BBS_Cate_Name")'论坛名称
						rs_BBS_Cate.close
						set rs_BBS_Cate=nothing
						BBS_Cate_Link="main.asp?layer_1="&layer_1&"&layer_2="&cus("boardid_2")
					end if
            
				else'2级类别
					BBS_Cate_Name=BBS_Cate_Name_2'论坛名称
					BBS_Cate_Link="main.asp?layer_1="&layer_1&"&layer_2="&cus("boardid_2")'论坛连接地址
				end if
			end if
if BBS_Cate_Link="" then
   BBS_Cate_Link="#"
end if						
%>
            <a href="<%=BBS_Cate_Link%>"><%=BBS_Cate_Name%></a> </td>-->
            <td bgcolor="#F2F8FF" width="16%">
			<div align="left">
			<%=indbdate%><%if rers("user_id")<>"" then response.write "<font color=red>|</font>"&rers("user_id")%>
              </div></td>
        </tr>
<%
cus.movenext
'i=i+1
'wend
next
%>
        <tr valign="top"> 
            <td colspan="6"  background="../images/bbs_bg1.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr> 
                  <td align="left" width="213">&nbsp;共<font color=red><%= wzcount%></font>个主题 <font color=red><%= wzrep%></font>/页 
                    共<font color=red><%= wzpagecount%></font>页</td>
                  <td width="548" height="23" align="right"> <%= pagination(wzpagecount)%> 
                  </td>
                </tr>
              </table> </td>
        </tr>
        <%else%>
        <tr bgcolor="#EFF7FA"> 
          <td colspan=6 align=center height=20> 欢迎到本论坛发表贴子！ </td>
        </tr>
        <%end if%>
        </tbody> 
      </table>
    </td>
  </tr>
</table>
<!--#include file="../inc/bbstail.htm"-->
<script src="http://woocall.sina.com.cn/rls/stable.js" type="text/javascript"></script>