<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p0000")
'''''''''''''''''''''''''''''''''''''''''''''''
Dim classSql,rs,classArr,strBuffer,pri,chfreq,linkstr
classSql = "Select id,title,parentid,templet,savedir,flag,moditime from catalogs order by id asc"
Set rs = Conn.Execute(classSql)
if not rs.eof and not rs.bof then
	classArr=rs.GetRows()
	rs.close
	set rs = Nothing
else
	response.Write("没有分类，请先添加分类！<br><a href=""classadd.asp?id=0"">&nbsp;&nbsp;添加==></a>")
	rs.close
	set rs = Nothing	
end if
'
strBuffer="<?xml version=""1.0"" encoding=""UTF-8"" ?> "&chr(10)
strBuffer=strBuffer&"<urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"">"&chr(10)

if(isarray(classArr)) then
	for i=0 to ubound(classArr,2)
		if(classArr(5,i)=1) then
			pri="1.0000"
			if(classArr(4,i)="/") then
				linkstr=classArr(4,i)
			else
				linkstr=classArr(4,i)&"/index.htm"
			end if
		else
			pri="0.5000"
			linkstr=classArr(4,i)&"/index_1.htm"
		end if
		strBuffer=strBuffer&"<url>"&chr(10)
		strBuffer=strBuffer&"<loc>"&SiteUrl&linkstr&"</loc>"&chr(10)
		'strBuffer=strBuffer&"<lastmod>"&classArr(6,i)&"</lastmod>"&chr(10)
		strBuffer=strBuffer&"<priority>"&pri&"</priority>"&chr(10)
		'strBuffer=strBuffer&"<changefreq>daily</changefreq>"&chr(10)
		strBuffer=strBuffer&"</url>"&chr(10)
	next
end if
strBuffer=strBuffer&"</urlset>"&chr(10)
set classArr=nothing
'生成sitemap.xml
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set file_w = fs.CreateTextFile(server.mappath("../sitemap.xml"),true)	
file_w.WriteLine(strBuffer)
file_w.close
set file_w=nothing
set fs=nothing
response.Write("<br><p align=""center"">成功生成sitemap.xml<br><a href=""/sitemap.xml"">点击查看=></a></p>")
call connclose()
%>