<?xml version="1.0" encoding="utf-8"?> 
<%dim tt1
tt1=timer()
On Error Resume Next
Server.ScriptTimeOut=9999999
Session.CodePage = 65001
sid=request.querystring ("sid")
saytk=request.querystring ("saytk")
Function getHTTPPage(Path)
 t = GetBody(Path)
End function

function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.SetRequestHeader "User-Agent", "NokiaN70-1/2.0539.1.2 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1 UCWEB/5.1"
Http.SetRequestHeader "X-FORWARDED-FOR", "221.131.7.255"
Http.send()
if Http.readystate<>4 then 
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"utf-8")
set http=nothing
if err.number<>0 then err.Clear 
end function

Function bytestobstr(body,CSET)
DIM OBJSTREAM
SET OBJSTREAM = Server.CreateObject("adodb.stream")
objstream.type = 1
objstream.Mode = 3
objstream.Open 
objstream.Write body
objstream.Position = 0
objstream.type = 2
objstream.Charset=Cset
bytesTobstr = objstream.readText
objstream.close
set objstream=nothing
end function
%><%on error resume next


Response.ContentType = "text/vnd.wap.wml; charset=utf-8"
%>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> 
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0" forua="true"/>
</head>
<%

dim myids,t_sks,title,myurl
myids="myid"			'系统的身份码名称
t_sks=120			'缓存时间,单位秒(S)
myurl="/index.asp"		'返回的网址


Sub lasts()
	response.write "<br/>"
	if ad_ok=1 then response.write abc(R) & "<br/>" & abc(RR) & "<br/>"
	if instr(request.ServerVariables("SCRIPT_NAME"),"/index.asp")=0 then response.Write "<a href='/index.asp'>首页</a>  <a href='book.asp'>书城</a><br/>"
	'上面填写你网站地步的返回连接，可以自主添加
	response.Write "<a href='" & myurl & "?"&myids&"=" & myid & "'>" & title & "</a><br/>"
	if len(rcurl)>7 then response.write "执行用了" & FormatNumber((timer()-tt1)*1000,3) & "毫秒"
	dim ttts
	ttts=FormatNumber((timer()-tt1)*1000,3)
	if ttts<8 then ttts=8.225
'	response.write "执行用了" & ttts & "ms<br/>"
	response.Write "</p>"
	response.Write "</card>"
	response.Write "</wml>"
End Sub
 Sub lastbody()
	response.write "<br/>"
	if ad_ok=1 then response.write abc(R) & "<br/>" & abc(RR) & "<br/>"
	if instr(request.ServerVariables("SCRIPT_NAME"),"/index.asp")=0 then response.Write "<a href='/index.asp?'>首页</a>  <a href='book.asp'>书城</a><br/>"
	'上面填写你网站地步的返回连接，可以自主添加
	if len(rcurl)>7 then response.write "执行用了" & FormatNumber((timer()-tt1)*1000,3) & "毫秒"
	dim ttts
	ttts=FormatNumber((timer()-tt1)*1000,3)
	if ttts<8 then ttts=8.225
'	response.write "执行用了" & ttts & "ms<br/>"
	response.Write "</p>"
	response.Write "</body>"
	response.Write "</html>"
End Sub
%>
<%
function nshouji(str)
str=trim(str)
if IsNull(str) then exit function
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.pattern="shouji=[a-z0-9]*"
str = re.Replace(str,"shouji=")
set re=Nothing
nshouji=str
end function

function ushouji(str)
str=trim(str)
if IsNull(str) then exit function
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.pattern="shouji=[a-z0-9]*"
str = re.Replace(str,"shouji="&shouji&"")
set re=Nothing
ushouji=str
end function
%>
<%on error resume next
dim filename,bookurl
filename="book.asp"
bookurl=request("bookurl")
bookurl=Replace(bookurl,"@^@","?")
bookurl=Replace(bookurl,"@@","&")
if bookurl="" then bookurl="index.php"
if instr(bookurl,"type=txt")>0 and (instr(bookurl,"type=txtchapter")=0 or instr(bookurl,"cid=")>0) then
Response.Redirect("http://ndbook.cn/wap/article/"&bookurl&"")
Response.end()
end if
if (instr(bookurl,"type=jar")>0 or instr(bookurl,"type=jad")>0) and (instr(bookurl,"vsize=")=0 or instr(bookurl,"vid=")>0) then
Response.Redirect("http://ndbook.cn/wap/article/"&bookurl&"")
Response.end()
end if
if (instr(bookurl,"type=umd")>0 or instr(bookurl,"type=jad")>0) and (instr(bookurl,"vsize=")=0 or instr(bookurl,"vid=")>0) then
Response.Redirect("http://ndbook.cn/wap/article/"&bookurl&"")
Response.end()
end if
dim content,numstart,numstart1,numstarts
t_sss=Application("k_book_t_"&bookurl)
content=Application("k_book_"&bookurl)
'call FreeApplicationMemory("k")
if content="" or DateDiff("s",t_sss,now())>t_sks then
if instr(bookurl,"article/")>0 then
bookurl=Replace(bookurl,"article/","")
content=getHTTPPage("http://www.ndbook.cn/wap/article/"&bookurl)
else
if instr(bookurl,"index.php")>0 then
content=getHTTPPage("http://www.ndbook.cn/wap/"&bookurl)
else
content=getHTTPPage("http://www.ndbook.cn/wap/article/"&bookurl)
end if
end if
if instr(bookurl,"index.php")>0 then
Response.Write("<card title=""书城首页""><p>")
numstart=Instr(content,"【热门推荐】")
else
numstart=InStr(content,"<card")
end if
	if numstart<1 or InStr(content,"- 提示")>0 then
	response.write "<card title='服务器错误'><p>" & now() & "<br/>服务器错误，请稍后尝试刷新本页。<br/>"
	else
		numstart1=InStr(content,"(ND)wap.NDbook.cn")
		'numstart1=InStr(content,"</wml>")
		numstarts=numstart1-numstart
		content=MID(content,numstart,numstarts)
		content=replace(content,Chr(13),"")
		content=replace(content,Chr(10),"")
		content=replace(content,"<a href=""http://ndbook.cn/wap/"" title=""首页"">首页</a>","")
		content=replace(content,"""","'")
		content=replace(content,"&amp;","@@")
		content=replace(content,"?","@^@")
		
		
		Set re=new RegExp
		re.IgnoreCase =true
		re.Global=True
		re.pattern="您好!游客[\s\S]+?注册<\/a><br\/>"
		content= re.Replace(content,"")
		re.pattern="\.<a href='http:\/\/ndbook\.cn\/wap\/article\/top\.php' title='排行'>排行<\/a>[\s\S]+?<a href='http:\/\/ndbook\.cn\/wap\/forum\/' title='论坛'>论坛<\/a><br\/>"
		content= re.Replace(content,"")
		re.pattern="<a href='addbookcase.php[\s\S]+?>打开书架<\/a><br\/>"
		content= re.Replace(content,"")
		re.pattern="\|<a href='votebook\.[\s\S]+?最新章节"
		content= re.Replace(content,"<br/>最新章节")
		're.pattern="<a href='http://[\s\S]+?</a><br/>"
		'content= re.Replace(content,"")
		're.pattern="<a href='#nextcard'>快速翻页</a>"
		'content= re.Replace(content,"")
		're.pattern="<a href='([A-Za-z0-9\./=\?%\-&_&#x7E;`@':+!;*()#]+)'>评论\(\d+?条\).+?</anchor>\|"
		'content= re.Replace(content,"")
		're.pattern="<anchor>登录评论[\s\S]+?</go></anchor>"
		'content= re.Replace(content,"")
		're.pattern="(<br\/>)+"
		'content= re.Replace(content,"<br/>")
		set re=Nothing
       content=replace(content,"嗯多小说网 - ","")
		content=replace(content,"<a href='http://ndbook.cn/wap/","<a href='")
		
		content=replace(content,"<a href='","<a href='"&filename&"?bookurl=")
		Application.Lock
		Application("k_book_t_"&bookurl)=now()
		Application("k_book_"&bookurl)=content
		Application.UnLock

	response.write content
	end if
else
response.write ushouji(content)
end if
%>
<%

dim rcurl,ad_ok,R,RR,t_sss
rcurl="/ip/in.asp?url="&filename&""				'请在双引号间加上图片统计器的地址，没有请保持为空值
ad_ok=0					'广告开关，1为显示，0为不显示


'以下为广告地址，至少要有两个广告，自己可按数字的规则增减，修改前备份就行了
dim abc(17)
abc(0)=""
abc(1)=""
abc(2)=""
abc(3)=""
abc(4)=""
abc(5)=""
abc(6)=""
abc(7)=""
abc(8)=""
abc(9)=""
abc(10)=""
abc(11)=""
abc(12)=""
abc(13)=""
abc(14)=""
abc(15)=""
abc(16)=""
abc(17)=""

Randomize
R=Int(Rnd()*16)
RR=R-1
if RR<0 then RR=R+1
%>
<%
call lasts()
%>