<!--#include file="tgzcm_Conn.asp"-->
<!--#include file="tgzcm_Check.asp"-->
<!--#include file="../tgzcm.Include/tgzcm.Lable.All.asp"-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<TITLE>网站生成管理</TITLE>
<style type="text/css">
<!--
body {background-color:#E4EDF9; line-height:20px; font-size:12px; color:#135294; padding:2px;}
-->
</style>
</head>
<body>
<%
Dim DataPath
Action=Trim(Request.QueryString("action"))
Allnumber=Clng(Request.Form("allnumber"))
Pagenumber=Clng(Request.Form("pagenumber"))
If Allnumber<1 or Allnumber="" Then Allnumber=1
If Pagenumber<1 or Pagenumber="" Then Pagenumber=1
tgzcmPath = left(tgzcmpath,instrrev(tgzcmpath, "/")-1)'获取安装目录
tgzcmPath = left(tgzcmpath,instrrev(tgzcmpath, "/"))'获取安装目录
'
Set Crs = Server.CreateObject("adodb.recordset")
sql = "select top "&Allnumber&" name_id,class_id,data_name,data_picbig,data_intro,data_inputer,data_lastdate,data_status from tgzcm_name where data_status=1 order by name_id desc"
Crs.Open sql, Conn, 1, 1
If Not (Crs.bof And Crs.eof) Then
	Crs.pagesize=Pagenumber'每页数据
	m=Crs.recordcount     '总记录
	n=Crs.PageCount       '总页数
	'Crs.AbsolutePage=Page
	'z=Crs.pagesize        '每页数量
	If Action="google" Then
		Call Google()
	ElseIf Action="baidu" Then
		Call baidu()
	ElseIf Action="rss" Then
		Call rss()			
	End If		
Else
    Response.Write("暂时没有数据无需生成！")	
End If
Crs.Close
Set Crs=nothing
'
'加载模板
Sub rss()
	moban =  "<?xml version=""1.0"" encoding=""GB2312"" ?>"& vbCrLf
	moban = moban + "<rss version='2.0'>" & vbCrLf
    moban = moban + "<channel>" & vbCrLf
	moban = moban + "<title>"&tgzcm(0)&"</title>" & vbCrLf
	moban = moban + "<description>"&tgzcm(0)&"</description>" & vbCrLf
	moban = moban + "<link>"&tgzcm(1)&"</link>" & vbCrLf
	moban = moban + "<language>zh-cn</language>" & vbCrLf
	moban = moban + "<docs>"&tgzcm(0)&"</docs>" & vbCrLf
	moban = moban + "<generator>Rss Powered By "&tgzcm(1)&"</generator>" & vbCrLf
	moban = moban + "<image>" & vbCrLf
	moban = moban + "<title>"&tgzcm(0)&"</title>" & vbCrLf
	moban = moban + "<link>"&tgzcm(1)&"/</link>" & vbCrLf
	moban = moban + "<url>"&tgzcm(1)&"/images/logo.gif</url>" & vbCrLf
	moban = moban + "</image>" & vbCrLf	
	Do while not Crs.eof
		moban = moban + "<item>"& vbCrLf
		moban = moban + "<title><![CDATA["&Trim(Crs("data_name"))&"]]></title>"&vbCrLf
		Call GetLinkPath(Crs("class_id"),Crs("name_id"))'该影片的路径
		If tgzcmPath="/" Then DataPath=DataUrl Else DataPath=Replace(DataUrl,tgzcmPath,"/") End If'转化生成路径的相对目录
		moban = moban + "<link>"&tgzcm(1)&DataPath&"</link>"& vbCrLf
		moban = moban + "<author>"&Crs("data_inputer")&"</author>"& vbCrLf
		moban = moban + "<pubDate>"&Crs("data_lastdate")&"</pubDate>"& vbCrLf
		moban = moban + "<description><![CDATA["&Trim(left(fhtml(Crs("data_intro")),200))&"]]></description>"& vbCrLf			
		moban = moban + "</item>"& vbCrLf
	Crs.movenext
	Loop
	moban = moban + "</channel></rss>" & vbCrLf
	Call MakeHtml("../rss.xml",moban) 
	Response.Write("生成页面（<a href='../rss.xml' target='_blank'>"&tgzcm(1)&"/rss.xml</a>）<font color=red>成功!</font><br>")
	Response.flush
End Sub

Sub baidu()
    Response.Write("总共需要生成"&n&"页...正在生成...<br>")
    For i=1 to n
	moban =  "<?xml version=""1.0"" encoding=""GB2312"" ?>"& vbCrLf
	moban = moban + "<document>"& vbCrLf
	moban = moban + "<webSite>"&tgzcm(1)&"/</webSite>"& vbCrLf
	moban = moban + "<webMaster>"&tgzcm(2)&"</webMaster>"& vbCrLf
	moban = moban + "<updatePeri>1440</updatePeri>"& vbCrLf
	ii=0
	Do while not Crs.eof  and ii<Pagenumber
		moban = moban + "<item>"& vbCrLf
		moban = moban + "<title>"&Crs("data_name")&"</title>"& vbCrLf
		Call GetLinkPath(Crs("class_id"),Crs("name_id"))'该影片的路径
		If tgzcmPath="/" Then DataPath=DataUrl Else DataPath=Replace(DataUrl,tgzcmPath,"/") End If'转化生成路径的相对目录
		moban = moban + "<link>"&tgzcm(1)&DataPath&"</link>"& vbCrLf		
		moban = moban + "<text>"&left(fhtml(Crs("data_intro")),300)&"</text>"& vbCrLf
		If instr(Crs("data_picbig"),"http://")>0  Then
		moban = moban + "<image>"&Crs("data_picbig")&"</image>"& vbCrLf
		Else
		moban = moban + "<image>"&tgzcm(1)&"/"&Crs("data_picbig")&"</image>"& vbCrLf
		End If
		moban = moban + "<keywords>"&Crs("data_name")&"</keywords>"& vbCrLf
		moban = moban + "<author>"&Crs("data_inputer")&"</author>"& vbCrLf
		moban = moban + "<source>TgzcmCms</source>"& vbCrLf
		moban = moban + "<pubDate>" & Year(Crs("data_lastdate")) & "-" & Right("0" & Month(Crs("data_lastdate")), 2) & "-" & Right("0" & Day(Crs("data_lastdate")), 2) & "</pubDate>"& vbCrLf
		'moban = moban + "<pubDate>"&Crs("data_lastdate")&"</pubDate>"& vbCrLf
		moban = moban + "</item>"& vbCrLf
	Crs.movenext
	ii=ii+1
	Loop
	moban = moban + "</document>" & vbCrLf
    moban = "" + moban + ""
    moban = "" & moban & ""
	Call MakeHtml("../baidumap_"&i&".xml",moban) 
	Response.Write("生成页面（<a href='../baidumap_"&i&".xml' target='_blank'>"&tgzcm(1)&"/baidumap_"&i&".xml</a>）<font color=red>成功!</font><br>")
	If i=n Then Response.Write("请通过  <a href='http://news.baidu.com/newsop.html' target='_blank'>http://news.baidu.com/newsop.html</a>  提交!<br>")
	Response.flush
	Next
End Sub

Sub Google()
    Response.Write("总共需要生成"&n&"页...正在生成...<br>")
    For i=1 to n
	moban =  "<?xml version=""1.0"" encoding=""UTF-8""?>"
	moban = moban + "<!--Google Site Map File Generated by "&tgzcm(1)&" " & return_RFC822_Date(now,"GMT") & "-->"
	moban = moban + "<urlset xmlns=""http://www.google.com/schemas/sitemap/0.84"">"
	moban = moban + "<url>"
	moban = moban + "<loc>"&tgzcm(1)&"/</loc> "
	moban = moban + "</url>"
	ii=0
	Do while not Crs.eof  and ii<Pagenumber
		'Response.Write(""&Crs("name_id")&"---")
		moban = moban + "<url>"
		Call GetLinkPath(Crs("class_id"),Crs("name_id"))'该影片的路径
		If tgzcmPath="/" Then DataPath=DataUrl Else DataPath=Replace(DataUrl,tgzcmPath,"/") End If'转化生成路径的相对目录
		moban = moban + "<loc>"&tgzcm(1)&DataPath&"</loc> "  '修改为你的文件名称和id
		moban = moban + "</url>"
	Crs.movenext
	ii=ii+1
	Loop
	moban = moban + "</urlset>" 
    moban = "" + moban + ""
    moban = "" & moban & ""
	Call MakeHtml("../sitemap_"&i&".xml",moban) 
	Response.Write("生成页面（<a href='../sitemap_"&i&".xml' target='_blank'>"&tgzcm(1)&"/sitemap_"&i&".xml</a>）<font color=red>成功!</font><br>")
	If i=n Then Response.Write("请通过  <a href='http://www.google.com/webmasters/tools/' target='_blank'>http://www.google.com/webmasters/tools/</a>  添加它!<br>")
	Response.flush
	Next
End Sub

Function return_RFC822_Date(byVal myDate, byVal TimeZone)
	Dim myDay, myDays, myMonth, myYear
	Dim myHours, myMinutes, mySeconds
	myDate = CDate(myDate)
	myDay = EnWeekDayName(myDate)
	myDays = Right("00" & Day(myDate),2)
	myMonth = EnMonthName(myDate)
	myYear = Year(myDate)
	myHours = Right("00" & Hour(myDate),2)
	myMinutes = Right("00" & Minute(myDate),2)
	mySeconds = Right("00" & Second(myDate),2) 
	return_RFC822_Date = myDay&", "& _
	myDays&" "& _
	myMonth&" "& _ 
	myYear&" "& _
	myHours&":"& _
	myMinutes&":"& _
	mySeconds&" "& _ 
	" " & TimeZone
End Function 

Function EnWeekDayName(InputDate)
	Dim Result
	Select Case WeekDay(InputDate,1)
	Case 1:Result="Sun"
	Case 2:Result="Mon"
	Case 3:Result="Tue"
	Case 4:Result="Wed"
	Case 5:Result="Thu"
	Case 6:Result="Fri"
	Case 7:Result="Sat"
	End Select
	EnWeekDayName = Result
End Function

Function EnMonthName(InputDate)
	Dim Result
	Select Case Month(InputDate)
	Case 1:Result="Jan"
	Case 2:Result="Feb"
	Case 3:Result="Mar"
	Case 4:Result="Apr"
	Case 5:Result="May"
	Case 6:Result="Jun"
	Case 7:Result="Jul"
	Case 8:Result="Aug"
	Case 9:Result="Sep"
	Case 10:Result="Oct"
	Case 11:Result="Nov"
	Case 12:Result="Dec"
	End Select
	EnMonthName = Result
End Function
'ShowPage("0.asp", m, z, Page, True, True, "条", False)

'**************************************************
'函数名：fhtml
'作  用：强化过滤HTML标记
'**************************************************
Function fhtml(istr)
    istr = cuthtml(istr)
    fhtml = Replace(Replace(Replace(Replace(Replace(Replace(istr, " ", ""), "'", "&apos;"), """", "&quot;"), ">", "&gt;"), "<", "&lt;"), "&", "&amp;")
End Function

Function cuthtml(ByVal str)
    If IsNull(str) Or Trim(str) = "" Then
        cuthtml = ""
        Exit Function
    End If
    regEx.Pattern = "(\<.[^\<]*\>)"
    str = regEx.Replace(str, " ")
    regEx.Pattern = "(\<\/[^\<]*\>)"
    str = regEx.Replace(str, "")
    
    str = Replace(str, "'", "")
    str = Replace(str, Chr(34), "")
    cuthtml = str
End Function
%>
</body>
</html>