<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"--> 
<%
response.Charset="UTF-8"
dim id,currentpage,totalpage,totalnum,recpage,key,sql,ctitle
recpage=10
if(request.QueryString("id")<>"") then
	id=Clng(request.QueryString("id"))
else
	id=0
end if
if(request.QueryString("page")<>"") then
	currentpage=Clng(request.QueryString("page"))
else
	currentpage=1
end if
if(currentpage<=0) then
	currentpage=1
end if
key=request.QueryString("key")
if(key<>"") then
	key=replace(key,"'","")
end if
urls="key="&key&"&id="&id
if(id>0) then
	set rs=server.CreateObject("adodb.recordset") 
	rs.open "select title from catalogs where id="&id,conn,3,1
	if not rs.eof then		
		ctitle=rs(0)
  end if
	rs.close
	set rs=nothing
end if
%>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta name="viewport" content="width=device-width; initial-scale=1.3; minimum-scale=1.0; maximum-scale=2.0"/>
<meta name="MobileOptimized" content="240"/>
<title><%=ctitle%></title>
<link href="css/index.css" rel="stylesheet" type="text/css" />
</head>
 
<body>  
<div class="wrap">
<div class="logo"><a href="#top"><img src="images/logo.jpg" width="200" /></a></div>
<div class="b3"><a href="news.asp?id=3">国内</a> | <a href="news.asp?id=4">国际</a> | <a href="news.asp?id=5">社会</a></div>
<div class="t1"><img src="images/ent-arrow.gif" /><a href="index.asp">首页 </a>&gt;<a href="news.asp?id=<%=id%>"> <%=ctitle%></a></div>
<div class="c c1">   
<%
sql="select count(*) from news where 1=1"
if(key<>"") then
	sql=sql&" and Title like '%"&key&"%'"
end if
if(id>0) then
	sql=sql&" and classid="&id
end if
allrec=conn.execute(sql)(0)
totalpage=int((allrec-1+recpage)/recpage)

sql="select top "&recpage&" id,Title,ModiTime from news where id<=(select min(id) from (select top "&((currentpage-1)*recpage+1)&" id from news where 1=1"
if(key<>"") then
	sql=sql&" and Title like '%"&key&"%'"
end if
if(id>0) then
	sql=sql&" and classid="&id
end if
sql=sql&" order by id desc) as t) and 1=1"
if(key<>"") then
	sql=sql&" and Title like '%"&key&"%'"
end if
if(id>0) then
	sql=sql&" and classid="&id
end if
sql=sql&" order by id desc"
set rs=server.CreateObject("adodb.recordset") 
rs.open sql,conn,3,1
while not rs.eof
	response.Write("<p>"&"<a href=""news_show.asp?id="&rs(0)&""">"&rs(1)&" ["&month(rs(2))&"-"&day(rs(2))&"] </a></p>")
	rs.movenext
wend
rs.close
set rs=nothing
%>        
</div>

<div class="pages">
              <%
              dim n,p,startpage,endpage,j
              n=currentpage+1
              p=currentpage-1
              startpage=currentpage-1
              if(startpage<=0) then
                startpage=1
              end if
              endpage=currentpage+1
              if(endpage>totalpage) then
                endpage=totalpage
              end if
							response.write("<a href=""?"&urls&"&page=1"">首页</a> ")
              if p>0then
                response.write("<a class=""number"" href=""?"&urls&"&page="&cstr(p)&""">&lt;&lt;</a> ")
              else 
                response.write("<a class=""number"" href=""#"">&lt;&lt;</a> ")
              end if 
              '''''''''''''''''
              for j=startpage to endpage
                  if(j=currentpage) then
                    response.write("<a class=""number hover"">"&j&"</a>")
                  else
                    response.write("<a class=""number"" href=""?"&urls&"&page="&j&""">"&j&"</a> ")
                  end if
                  if(j>(startPage+10)) then
                    exit for
                  end if
              next
              '''''''''''''''''''''''''''''''''''''
              if (n-1)*recpage>=Clng(totalnum) then 
                response.Write("<a class=""number"" href=""#"">&gt;&gt;</a> ")
              else
                response.Write("<a class=""number"" href=""?"&urls&"&page="&cstr(n)&""">&gt;&gt;</a> ")
              end if
              response.write(" <a href=""?"&urls&"&page="&totalpage&""">末页</a> ")
              response.Write(""&currentpage&"/"&totalpage&"页")
              %>
						</div>
<div class="s">
<form action="news.asp" method="get">
  关键字
  <input name="key" class="i1" id="key" value="<%=key%>" size="12" />
<input type="submit" value="查询" />
</form>
<p></p>
</div>
<div class="b3"><a href="news.asp?id=3">国内</a> | <a href="news.asp?id=4">国际</a> | <a href="news.asp?id=5">社会</a></div>
<div class="footer">
    <p><img src="images/9e440e80.gif" alt="" /> <a href="/">淘特CMS</a> </p>
    <p class="f1"><img src="images/ae9e8e3d.gif" alt="" />[<%=date()%>]</p>
</div>
</div>
</body>
</html>
<%
call connclose()
%>