<!--#include file="conn.asp"-->
<!--#include file="inc/cookies_check.asp"-->
<!--#include file="../include/Lebi_Config.asp"-->
<%
'*****************************************
'* 软件名称 乐彼网上开店软件(56770 EShop)
'* 软件开发 http://www.56770.com
'* 版权所有 http://www.56770.com
'* 文件名称 Admin_sitemap.asp
'* 最后更新 2012-05-18 by 56770.kingdge
'*****************************************
include "lang/"& LangFilePath &"/lang_sys.inc"
include "lang/"& LangFilePath &"/lang_menu.inc"
include "lang/"& LangFilePath &"/lang_sitemap.inc"
CurrentId = 7
CurrentUrl = "admin_sitemap.asp"
If request("do")="" Then
LB_Head()
LB_Menu()
Response.Write("<div class=""mainbody"">")
Response.Write("<div class=""mainbody2"">")
Dim admin_flag
admin_flag=",12.2,"
If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
		adminflag()
End If
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="sitemap" class="classtable">
<Form Name="Form" Method="Post" Action="admin_sitemap.asp">
<tr>
	<td height="30" align="left" class="classhead"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">
	<input type="hidden" name="IS_UP" value="1">
	</td>
	  <td class="classhead" align="right">
	  <%=QuickMenu("admin_html.asp?do=config|"& Lang_Menu(182) &"","admin_data.asp|"& Lang_Menu(163) &"")%>
	</td>
 </tr>
<tr>
<td colspan="2" height="30" class="classtop"><%=Lang_Sitemap(1)%></td>
</tr>
<tr class="classrow">
<td colspan="2" height="30" class="classrow"><%If request("IS_UP") = 1 Then response.write("<iframe src='?do=SaveXml' width='100%' height='50' frameborder='0' scrolling='no'></iframe>")%></td>
</tr>
<tr>
<td colspan="2" class="classfaq">
  <div class="faq_main">
  <p class="faq_title"><%=Lang_sys(49)%></p>
<%=Lang_Sitemap(2)%>
<%
If Not IsObjInstalled("Scripting.FileSystemObject") Then
Response.Write "<br /><font color=red><b>"& Lang_Sitemap(3) &"</b></font>"
End If
%>
<br /><br />
<strong><%=Lang_Sitemap(4)%></strong><br>
<%=Lang_Sitemap(5)%><br>
<strong><%=Lang_Sitemap(6)%></strong><br>
<%=Lang_Sitemap(7)%><br>
<strong><%=Lang_Sitemap(8)%></strong><br>
<%=Lang_Sitemap(9)%><a href="https://www.google.com/accounts/ServiceLogin?service=sitemaps&nui=1&continue=https://www.google.com/webmasters/sitemaps/siteoverview%3Fhl%3Dzh_CN&hl=zh_CN" target="_blank"><u>Google</u></a>
</td>
</tr>
</table>
<script>tdshow("sitemap");</script>
<%
Response.Write("</div>")
Response.Write("</div>")
LB_Footer()
End If
If request("do") = "SaveXml" Then
%>
<body style="margin:0;font-size:12px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td style="background:#ffffff;font-size:12px;" height="25"><%=Lang_Sitemap(10)%></td></tr>
<tr><td style="background:#ffffff;font-size:12px;" height="25"><iframe src='?do=YSaveXml' width='100%' height='25' frameborder='0' scrolling='no'></iframe>
</table>
<%
End If
If request("do") = "YSaveXml" Then
%>
<body style="margin:0;font-size:12px;">
<%
ManageLog "生成Sitemap"
Server.ScriptTimeout=3000
If request.ServerVariables("SERVER_PORT") <> 80 Then
		UrlPath = "http://"&Request.ServerVariables("SERVER_NAME")&":"&request.ServerVariables("SERVER_PORT")&Eshop_url
Else
		UrlPath = "http://"&Request.ServerVariables("SERVER_NAME")&Eshop_url
End If
ShopDir=LCase(Eshop_url)
utcOffset = 1
URLS = 0
phisicalDir = LCase(Server.MapPath(Eshop_url))
set objfso = CreateObject("Scripting.FileSystemObject")
root = Server.MapPath(ShopDir)
temp_sitemap ="<?xml version='1.0' encoding='UTF-8'?>"&vbcrlf
temp_sitemap = temp_sitemap & "<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>"&vbcrlf
rem 循环商品信息开始 2007-12-27 by 56770.kingdge
Set rs = conn.execute("select top 1000 id,sj from [Lebi_product] order by sj desc")
If Not rs.eof Then
        Do While Not rs.eof
		For LangT = 1 To TotalLang
				If show_html = 0 Then 
						Select Case ISAPI_Rewrite
							   Case "0"
								If Config_Lebi_Eshop(16) = 0 Then
										temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"showproduct.asp?id="& rs("id") &"</loc><lastmod>"&iso8601date(rs(1),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
										temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"showpic.asp?id="& rs("id") &"</loc><lastmod>"&iso8601date(rs(1),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
								Else
										temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"product/?id="& rs("id") &"</loc><lastmod>"&iso8601date(rs(1),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
										temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"product/showpic/?id="& rs("id") &"</loc><lastmod>"&iso8601date(rs(1),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
								End If
							   Case "1" 
								temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"product-"& rs(0) &".html</loc><lastmod>"&iso8601date(rs(1),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
								temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"product_pic-"& rs(0) &"-tpro.html</loc><lastmod>"&iso8601date(rs(1),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
						End Select
				Else
						temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) & Folder(0) & rs("id") &".1."& Sys_Ext &"</loc><lastmod>"&iso8601date(rs(1),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
				End If 
		Next
        URLS=URLS+2
        rs.movenext
        Loop
End If
rs.close()
rem 循环商品信息结束
rem 循环商品分类信息开始 2007-12-27 by 56770.kingdge
Set rs = conn.execute("select top 1000 c_id,c_foldername,c_filename from [Lebi_category] order by c_order desc,c_id desc")
If Not rs.eof Then
        Do While Not rs.eof
		For LangT = 1 To TotalLang
				If show_html = 0 Then 
						Select Case ISAPI_Rewrite
							   Case "0"
								If Config_Lebi_Eshop(16) = 0 Then
										temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"showsort.asp?sort_id="& rs(0) &"</loc><lastmod>"&iso8601date(Date(),utcOffset)&"</lastmod><priority>0.9</priority></url>"&vbcrlf
								Else
										temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"category/"& rs(1) &"/</loc><lastmod>"&iso8601date(Date(),utcOffset)&"</lastmod><priority>0.9</priority></url>"&vbcrlf
								End If
							   Case "1" temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"category-"& rs(1) &".html</loc><lastmod>"&iso8601date(Date(),utcOffset)&"</lastmod><priority>0.9</priority></url>"&vbcrlf
						End Select
				Else
						temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) & Folder(2) & rs(2) &".1."& Sys_Ext &"</loc><lastmod>"&iso8601date(Date(),utcOffset)&"</lastmod><priority>0.9</priority></url>"&vbcrlf
				End If 
		Next
        URLS=URLS+1
        rs.movenext
        Loop
End If
rs.close()
rem 循环商品分类信息结束
rem 循环商品专题分类开始 2007-12-27 by 56770.kingdge
Set rs = conn.execute("select top 1000 classid,n_foldername,n_filename from [Lebi_newsclass] order by b_order desc,classid desc")
If Not rs.eof Then
        Do While Not rs.eof
		For LangT = 1 To TotalLang
				If show_html = 0 Then 
						Select Case ISAPI_Rewrite
							   Case "0"
								If Config_Lebi_Eshop(16) = 0 Then
										temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"zhuanti.asp?action=news_class&classid="& rs(0) &"</loc><lastmod>"&iso8601date(Date(),utcOffset)&"</lastmod><priority>0.8</priority></url>"&vbcrlf
								Else
										temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"news/"& rs(1) &"</loc><lastmod>"&iso8601date(Date(),utcOffset)&"</lastmod><priority>0.8</priority></url>"&vbcrlf
								End If
							   Case "1" temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"news_class-"& rs(0) &".html</loc><lastmod>"&iso8601date(Date(),utcOffset)&"</lastmod><priority>0.8</priority></url>"&vbcrlf
						End Select
				Else
						temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) & Folder(1) & rs(2) &".1."& Sys_Ext &"</loc><lastmod>"&iso8601date(Date(),utcOffset)&"</lastmod><priority>0.8</priority></url>"&vbcrlf
				End If 
		Next
        URLS=URLS+1
        rs.movenext
        Loop
End If
rs.close()
rem 循环商品专题分类结束
rem 循环商品专题信息开始 2007-12-27 by 56770.kingdge
Set rs = conn.execute("select top 1000 id,infotime from [Lebi_news] order by infotime desc,id desc")
If Not rs.eof Then
        Do While Not rs.eof
		For LangT = 1 To TotalLang
				If show_html = 0 Then
						Select Case ISAPI_Rewrite
							   Case "0"
								If Config_Lebi_Eshop(16) = 0 Then
										temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"zhuanti.asp?action=news_list&id="& rs("id") &"</loc><lastmod>"&iso8601date(rs(1),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
								Else
										temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"news/list/?id="& rs("id") &"</loc><lastmod>"&iso8601date(rs(1),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
								End If
							   Case "1" temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) &"news_list-"& rs("id") &".html</loc><lastmod>"&iso8601date(rs(1),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
						End Select
				Else
						temp_sitemap = temp_sitemap & "<url><loc>"& UrlPath & LanguagePath(LangT) & Folder(1) &"info/"& rs(0) &".1."& Sys_Ext &"</loc><lastmod>"&iso8601date(Date(),utcOffset)&"</lastmod><priority>"& GETpriority(rs(1)) &"</priority></url>"&vbcrlf
				End If 
		Next
        URLS=URLS+1
        rs.movenext
        Loop
End If
rs.close()
rem 循环商品专题信息结束
Set objFolder = objFSO.GetFolder(root)
Set colFiles = objFolder.Files
For Each objFile In colFiles
	temp_sitemap = temp_sitemap & getfilelink(objFile.Path,objfile.dateLastModified,phisicalDir)
Next
ShowSubFolders(objFolder)
temp_sitemap = temp_sitemap & "</urlset>"
response.write "成功生成 Sitemap.xml，共生成 "& URLS &" 个URL地址。"
Savehtml "../Sitemap.xml",temp_sitemap
End If

Sub ShowSubFolders(objFolder)
	Set colFolders = objFolder.SubFolders
	For Each objSubFolder In colFolders
		if folderpermission(objSubFolder.Path) then
			'response.write getfilelink(objSubFolder.Path,objSubFolder.dateLastModified)
			Set colFiles = objSubFolder.Files
			For Each objFile In colFiles
				temp_sitemap = temp_sitemap & getfilelink(objFile.Path,objFile.dateLastModified,phisicalDir)
				'response.write objFile.Path
			Next
			ShowSubFolders(objSubFolder)
		end if
	Next
End Sub

Function getfilelink(file,data,phisicalDir)
    file=replace(LCase(file),phisicalDir &"\","")
    file=replace(file,"\","/")
	If FileExtensionIsBad(file) then Exit Function
	If FileNameIsBad(file) then Exit Function
	filelmdate=iso8601date(data,utcOffset)
'	getfilelink = "<url><loc>"&Replace(UrlPath & file,"//","/")&"</loc><lastmod>"& filelmdate &"</lastmod><changefreq>daily</changefreq> <priority>1.0</priority></url>"&vbcrlf
	getfilelink = "<url><loc>"&Replace(UrlPath & file,"//","/")&"</loc><lastmod>"& filelmdate &"</lastmod><priority>"& GETpriority(data) &"</priority></url>"&vbcrlf
	URLS=URLS+1
	'Response.Flush
End Function


Function Folderpermission(pathName)
	'modify this to exclude path
    PathExclusion=Array("\"&Adminpath&"","\jxc","\pic","\js_html","\images","\include","\Skins","\Suppliers","\Database","\webservice","\Plus","\wap","\api","\qs","\union")
	Folderpermission =True
	for each PathExcluded in PathExclusion
		if instr(ucase(pathName),ucase(PathExcluded))>0 then
			Folderpermission = False
			exit for
		end if
	next
End Function


Function FileExtensionIsBad(sFileName)
	Dim sFileExtension, bFileExtensionIsValid, sFileExt
	'http://www.googleguide.com/file_type.html
	Extensions = Array("html","htm","asp")

	if len(trim(sFileName)) = 0 then
		FileExtensionIsBad = true
		Exit Function
	end if

	sFileExtension = right(sFileName, len(sFileName) - instrrev(sFileName, "."))
	bFileExtensionIsValid = false	'assume extension is bad
	for each sFileExt in extensions
		if ucase(sFileExt) = ucase(sFileExtension) then
			bFileExtensionIsValid = True
			exit for
		end if
	next
	FileExtensionIsBad = not bFileExtensionIsValid
End Function

Function FileNameIsBad(sFileName)
        if len(trim(sFileName)) = 0 then
                FileNameIsBad = true
                Exit Function
        end if
        Filename = Array("/alive.asp","/404.asp","/500.asp","/sitemap_gen.asp")
        FileNameNumber = ubound(Filename)
        for i=0 to FileNameNumber
                if Filename(i) = sFileName then
                        FileNameIsBad = True
                end if
        next
End Function

Function iso8601date(dLocal,utcOffset)
	Dim d
	' convert local time into UTC
	d = DateAdd("H",-1 * utcOffset,dLocal)

	' compose the date
	iso8601date = Year(d) & "-" & Right("0" & Month(d),2) & "-" & Right("0" & Day(d),2) & "T" & _
		Right("0" & Hour(d),2) & ":" & Right("0" & Minute(d),2) & ":" & Right("0" & Second(d),2) & "Z"
End Function

Function GETpriority(str)
		If DateDiff("d",str,Date()) <= 1 Then
				GETpriority = "1.0"
		ElseIf DateDiff("d",str,Date()) <= 7 Then
				GETpriority = "0.9"
		ElseIf DateDiff("d",str,Date()) <= 15 Then
				GETpriority = "0.8"
		ElseIf DateDiff("d",str,Date()) <= 30 Then
				GETpriority = "0.7"
		Else
				GETpriority = "0.6"
		End If
End Function
%>