<?xml version="1.0" encoding="utf-8"?><%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<% Response.ContentType="text/vnd.wap.wml;charset=utf-8" %>
<wml>
<template >
        <do  type="prev" name="Prev" label="Prev" >
                <prev ></prev>
        </do>
</template>
<%
Function RemoveHTML(strHTML) 
	if(len(strHTML)<=0) then
		exit Function
	end if
	Dim objRegExp, Match, Matches 
	Set objRegExp = New Regexp 	
	objRegExp.IgnoreCase = True 
	objRegExp.Global = True 
	'取闭合的<> 
	objRegExp.Pattern = "<.+?>" 
	'进行匹配 
	if strHTML<>"" then
		Set Matches = objRegExp.Execute(strHTML)
		For Each Match in Matches 
			strHtml=Replace(strHTML,Match.Value,"") 
		Next 
		RemoveHTML=strHTML 
	else
		RemoveHTML=strHTML
	end if
	Set objRegExp = Nothing 
End Function
dim act,title,content,rs,id,currentpage,totalpage,totalnum
const recpage=6
if(request.QueryString("page")<>"") then
	currentpage=Clng(request.QueryString("page"))
else 
	currentpage=1
end if
act=request.QueryString("act")
title="totcms"
content=""
if(act<>"" and act="show") then
	if(request.QueryString("id")<>"") then
	 id=Clng(request.QueryString("id"))
	else
		id=0
	end if
	if(id>0) then
		set rs=server.CreateObject("adodb.recordset") 
		rs.open "select title,content from news where id="&id,conn,3,1
		if not rs.eof then
			title=rs(0)
			content=RemoveHTML(rs(1))
		end if
		rs.close
		set rs=nothing
	end if
end if
%>
<card id="c1" title="<%=title%>" >
        <p align="center">
                <img src="/images/logo.jpg" alt="totcms!"/>
        </p>
        <p>
		<%
		
		if(act<>"" and act="show") then
			response.Write(title+"<br/>")
			response.Write(replace(content,"&nbsp;"," "))
		else
			response.Write("<p>")
			set rs=server.CreateObject("adodb.recordset") 
			rs.open "select count(*) from news where checked=true",conn,3,1
			totalnum=rs(0)
			rs.close
			set rs=nothing
			totalpage=int((totalnum+recpage-1)/recpage)
			set rs=server.CreateObject("adodb.recordset") 
			rs.open "select top "&recpage&" id,title from news where id <=(select min(id) from (select top "&(recpage*(currentpage-1)+1)&" id from news order by id desc) as t) order by id desc ",conn,3,1			
			while not rs.eof
				response.Write("<a href=""index.asp?act=show&amp;id="&rs(0)&""">"&rs(1)&"</a><br/>"&Chr(10))
				rs.movenext
			wend		
			rs.close
			set rs=nothing	
			response.Write("</p>")
			'page lists
				response.Write("<p>")
				dim n,p,startpage,endpage,j
				n=currentpage+1
				p=currentpage-1
				startpage=currentpage-5
				if(startpage<=0) then
					startpage=1
				end if
				endpage=currentpage+5
				if(endpage>totalpage) then
					endpage=totalpage
				end if
				response.write(" 共"&totalnum&"条 ")
				if p>0then
					response.write("["&"<a href='index.asp?page="&cstr(p)&"'>上一页</a>] ")
				else 
					response.write("上一页 ")
				end if 
				'''''''''''''''''
				for j=startpage to endpage
						if(j=currentpage) then
							response.write(j&" ")
						else
							response.write("<a href=""index.asp?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("下一页" )
				else
						response.Write("["&"<a href='index.asp?page="&cstr(n)&"'>下一页</a>]")
				end if
				response.Write("</p>")
		end if
		%>
    </p>
    
		<br/>
    <br/>

</card>
</wml>
<%
call connclose()
%>