<%
'==================================
'=文 件 名：news.asp
'
'=功    能：新闻列表
'=作    者：新酷数据
'=日    期：2008-2-19 18:09
'=版    权：http://www.xksj.net
'=联系QQ：308588016 389057646
'==================================
%>
<!--#include file="Ft_config.asp"-->
<!--#include file="Ft_conn.asp"-->
<!--#include file="Ft_format.asp"-->
<!--#include file="Ft_lib.asp"-->
<%
sub_title="最新动态"
call head()
call body()
call foot()
sub body()
'==================================
'=功    能：取出当前模板
'==================================
StrTemp=split(mb_news,"|||@@@|||")
dim Ft_mbstr
Ft_mbstr=replace(StrTemp(0),"{left_pub}",left_pub())
Ft_mbstr=replace(Ft_mbstr,"$hotnum$",hotnum)
sql="select top "&hotnum&" * from Ft_news order by news_count DESC,news_date desc"
set rs2 = server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
if rs2.bof and rs2.eof then
	topnews="<span class=""disable_font"" >内容正在更新之中……</span>"
else
	do while not rs2.eof
		topnews=topnews+"<img src="""&signimgpath&"/biao.gif"" border=""0"">&nbsp;<a href=shownews.asp?id="&rs2("news_id")&">"&rs2("news_title")&"</a><br>"
		rs2.movenext
	loop
end if
rs2.close
set rs2=nothing
'左栏
Ft_mbstr=replace(Ft_mbstr,"$topnews$",topnews)
dim totalnews,Currentpage,totalpages,catid,page,catname
'设置新闻系统为默认分页大小的倍率
pagenum=pagenum*2
if request.querystring("page")<>"" then
	page=cint(checksql("新闻分页",request.querystring("page"),0,8))
end if
if request.querystring("cat_id")<>"" then
	catid=checksql("新闻分类",request.querystring("cat_id"),0,4)
	sql="select cat_id from Ft_news_cat where cat_id="&catid
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
	if rs.eof and rs.bof then
		response.redirect("showerr.asp?errmsg=<br><li>没有此分类或该分类已删除！</li>")
		response.end
	end if
	rs.close
	set rs=nothing
	sql="select * from Ft_news where cat_id="&catid&" order by istop=1,news_date DESC"
else
	sql="select * from Ft_news order by istop=1,news_date DESC"
end if
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
sql="select * from Ft_news_cat"
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
do while not rs2.eof
catlist=catlist+"<span class=""key_font"">|</span> <a href=""news.asp?cat_id="&rs2("cat_id")&""" >"&rs2("cat_name")&"</a>"
rs2.movenext
loop
if rs2.bof and rs2.eof then
catlist="| 暂无分类"
end if
rs2.close
set rs2=nothing
if request.querystring("cat_id")<>"" then
	catname=""
	sql="select cat_name from Ft_news_cat where cat_id="&catid
	set rscat=conn.execute(sql)
	catname=rscat("cat_name")
	rscat.close
	set rscat=nothing
	total_cat="<span class=""key_font"">【"&catname&"】</span>分类共有 <span class=""key_font"">"&rs.recordcount&"</span> 条新闻&nbsp;"
else
	total_cat="目前本站共有 <span class=""key_font"">"&rs.recordcount&"</span> 条新闻&nbsp;"
end if
'分类
Ft_mbstr=replace(Ft_mbstr,"$catlist$",catlist)
Ft_mbstr=replace(Ft_mbstr,"$total_cat$",total_cat)
Ft_mbstr_newslist=split(Ft_mbstr,"///")
'新闻列表前的内容输出
response.write Ft_mbstr_newslist(0)
if not rs.eof then
	rs.movefirst
	rs.pagesize=pagenum
if trim(request.querystring("page"))<>"" then
	currentpage=page
	if currentpage>rs.pagecount then
		currentpage=rs.pagecount
	end if
else
	currentpage=1
end if
totalnews=rs.recordcount
if currentpage<>1 then
	if(currentpage-1)*pagenum<totalnews then
		rs.move(currentpage-1)*pagenum
	end if
end if
if (totalnews mod pagenum)=0 then
	totalpages=totalnews\pagenum
else
	totalpages=totalnews\pagenum+1
end if
i=0
do while not rs.eof and i<pagenum
if rs("istop")=1 then
	newsstate="<a href='shownews.asp?id="&rs("news_id")&"' target='_blank'><img src='"&signimgpath&"/ztop.gif' border='0' alt='置顶新闻'></a>"
elseif rs("user_view")=1 then
	newsstate="<a href='shownews.asp?id="&rs("news_id")&"' target='_blank'><img src='"&signimgpath&"/userview.gif' border='0' alt='会员新闻，此条需消费"&rs("moneypay")&"个金币'></a>"
elseif rs("user_view")=2 then
	newsstate="<a href='shownews.asp?id="&rs("news_id")&"' target='_blank'><img src='"&signimgpath&"/vipview.gif' border='0' alt='VIP会员新闻，此条需消费"&rs("moneypay")&"个金币'></a>"
else
	newsstate="<a href='shownews.asp?id="&rs("news_id")&"' target='_blank'><img src='"&signimgpath&"/normal.gif' border='0' alt='普通新闻'></a>"
end if
if DateDiff("d",rs("news_date"),now())<1 then
	newnews="<img src='"&signimgpath&"/new.gif' border='0'>"
else
	newnews=""
end if 
'列表输出
Ft_mbstr=replace( Ft_mbstr_newslist(1),"$newsstate$",newsstate)
Ft_mbstr=replace(Ft_mbstr,"$newsid$",rs("news_id"))
Ft_mbstr=replace(Ft_mbstr,"$newstitle$",rs("news_title"))
Ft_mbstr=replace(Ft_mbstr,"$newnews$",newnews)
Ft_mbstr=replace(Ft_mbstr,"$newsdate$",rs("news_date"))
Ft_mbstr=replace(Ft_mbstr,"$newscount$",rs("news_count"))
response.write Ft_mbstr
i=i+1
rs.movenext
loop
elseif rs.eof and rs.bof then
	response.write"<tr class=""tablebody""><td colspan=""4"" height=""70"" align=""center"" class=""disable_font"">暂时没有此分类或此类新闻！</td></tr>"
end if
'新闻列表表格尾部</table>输出
response.write  Ft_mbstr_newslist(2)
'分页
Ft_mbstr=replace(Ft_mbstr_newslist(3),"$newspage$","")
if totalnews>pagenum then
	showpage totalnews,pagenum,"news.asp?"
end if
response.write Ft_mbstr
rs.close
set rs=nothing
end sub
%>
