<!--#include file="../Inc/conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../Inc/ubb.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>admin</title>
<link href="Images/admin_css.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="<%=SitePath%>images/myfav.ico" type="image/x-icon" />
</head>
<body>
<p align="left" style="line-height:25px; font-size:14px;">
<font color="#000000"><b>注意：只有当您开启本站静态时，这里生成才有效果</b></font><br />
<font color="#0000FF"><b>点击生成网站文章静态：</b></font><br />
<a href="news_html_1.asp?Sub=newshtml&pid=0">生成全部新闻</a>　|　<a href="news_html_2.asp?Sub=newshtml&pid=0">生成今日新闻</a>　|　<a href="news_html_3.asp">按ID号生成新闻</a>
</p>


<%
Select Case Request("Sub")
Case "newshtml"
	
	'得到域名
	sqldomain="select * from Yao_Config where ID=3" 
	Set rsdomain= Server.CreateObject("ADODB.Recordset")
	rsdomain.open sqldomain,conn,3,3
	yuming=rsdomain("Value")
	
	'数据库中第一个ID
	sqlk="select top 1 * from Yao_Article" 
	Set rsk= Server.CreateObject("ADODB.Recordset")
	rsk.open sqlk,conn,3,3
	kaishi=rsk("ID")
	
	'数据库中最后一个ID
	sqlz="select top 1 * from Yao_Article order by ID desc" 
	Set rsz= Server.CreateObject("ADODB.Recordset")
	rsz.open sqlz,conn,3,3
	zuihou=rsz("ID")
	
	if request("pid")=0 then
	m=kaishi
	else
	m=request("pid")+1
	end if
	
	if m<=zuihou then
	
	Set rs= Server.CreateObject("ADODB.Recordset")
	sql="select * from Yao_Article where ID="&m&"" 
	rs.open sql,conn,3,3
	dim http,reurl
	set http=Server.createobject("Microsoft."&chr(120)&"MLHTTP") 
	Http.open "GET","http://"&yuming&"/article.asp?ID="&rs("id")&"",false 
	Http.send() 
	set objStream = Server.CreateObject("ADODB.Stream") 
	objStream.type = 1 
	objStream.open 
	objstream.write http.responseBody
	objstream.saveToFile server.mappath("../article/"&rs("id")&".html"),2
	response.Write "../article/"&rs("id")&".html 生成成功！<br>"
	
	
	
	
	
	
	
	
	'产品分页显示
		If rs("PageNum")=0 then '无分页或者有手工分页
			
			if Instr(UBBCode(rs("Content")),"[Yao_page]")<=0 then
			'无分页是，都不操作
			response.Write "文章无分页"
			else
				
				dim ArticleId,strContent,CurrentPage
				dim ContentLen,pages,i
				dim arrContent,ManualPagination_Tmp
				
				strContent=UBBCode(rs("Content"))
				arrContent=split(strContent,"[Yao_page]")
				pages=Ubound(arrContent)+1
				
				for i=1 to pages
					'开始生成
					Set rs1= Server.CreateObject("ADODB.Recordset")
					sql1="select * from Yao_Article where ID="&m&"" 
					rs1.open sql1,conn,3,3
					set http1=Server.createobject("Microsoft."&chr(120)&"MLHTTP") 
					Http1.open "GET","http://"&yuming&"/article2.asp?ID="&rs1("id")&"&Page="&i&"",false 
					Http1.send() 
					set objStream1 = Server.CreateObject("ADODB.Stream") 
					objStream1.type = 1 
					objStream1.open 
					objstream1.write http1.responseBody
					objstream1.saveToFile server.mappath("../article/"&rs1("id")&"_"&i&".html"),2
					response.Write "../article/"&rs1("id")&"_"&i&".html<br>"
					'结束生成
				next
				rs1.close
				
			end if

		
		else  '自动分页
			
			CurrentPageaaa=LaoYRequest(request("Page"))
			strContentaaa=Lcase(UBBCode(rs("Content")))
			ContentLenaaa=len(strContentaaa)
			MaxPerPageaaa = rs("PageNum")
			if ContentLenaaa<=MaxPerPageaaa then
			response.Write "内容少于分页字数，暂不生成分页"
			else
				if CurrentPageaaa="" then
				CurrentPageaaa=1
				else
					CurrentPageaaa=Cint(CurrentPageaaa)
				end if
				pagesa=ContentLenaaa\MaxPerPageaaa
				if MaxPerPageaaa*pagesa<ContentLenaaa then
					pagesa=pagesa+1
				end if
			end if
			
			for ii=1 to pagesa
				'开始生成
				Set rs2= Server.CreateObject("ADODB.Recordset")
				sql2="select * from Yao_Article where ID="&m&"" 
				rs2.open sql2,conn,3,3
				set http2=Server.createobject("Microsoft."&chr(120)&"MLHTTP") 
				Http2.open "GET","http://"&yuming&"/article2.asp?ID="&rs2("id")&"&Page="&ii&"",false 
				Http2.send() 
				set objStream2 = Server.CreateObject("ADODB.Stream") 
				objStream2.type = 1 
				objStream2.open 
				objstream2.write http2.responseBody
				objstream2.saveToFile server.mappath("../article/"&rs2("id")&"_"&ii&".html"),2
				response.Write "../article/"&rs2("id")&"_"&ii&".html<br>"
				'结束生成
			next
			rs2.close
		
		end if
		'产品分页显示结束
		'北京实用技术网CMS
	
	
	
	
	
	
	
	
	
	
	
	response.write"<Script Language=Javascript>location.href='news_html_1.asp?Sub=newshtml&pid="&m&"';</Script>"
	rs.close

	else
	response.Write "全部生成成功！总生成"&(zuihou-kaishi)&"个<br>"
	end if

	
	
End Select
%>
</body>
</html>