国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > ASP > 正文

生成googlesitemap函數(shù)asp(轉(zhuǎn)老外)

2024-05-04 11:05:57
字體:
供稿:網(wǎng)友

        <td id="uynzh"><tr id="uynzh"></tr></td>
        • 以下是代碼片段:
          <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
          <%
          Response.Charset = "utf-8"
          Server.ScriptTimeout=50000
          ’ sitemap_gen.asp
          ’ A simple script to automatically produce sitemaps for a webserver, in the Google Sitemap Protocol (GSP)
          ’ by Francesco Passantino
          ’ www.iteam5.net/francesco/sitemap
          ’ v0.2 released 5 june 2005 (Listing a directory tree recursively improvement)


          session("server")="http://7thpark.com/" ’你的域名
          vDir = "/" ’SiteMap的目錄,相對(duì)目錄(相對(duì)于根目錄而言)


          set objfso = CreateObject("Scripting.FileSystemObject")
          root = Server.MapPath(vDir)

          ’response.ContentType = "text/xml"
          ’response.write "<?xml version=’1.0’ encoding=’UTF-8’?>"
          ’response.write "<urlset xmlns=’http://www.google.com/schemas/sitemap/0.84’>"

          str = "<?xml version=’1.0’ encoding=’UTF-8’?>"&vbcrlf’換行符
          str = str&"<urlset xmlns=’http://www.google.com/schemas/sitemap/0.84’>"&vbcrlf

          Set objFolder = objFSO.GetFolder(root)
          ’response.write getfilelink(objFolder.Path,objFolder.dateLastModified)
          Set colFiles = objFolder.Files
          For Each objFile In colFiles
          ’response.write getfilelink(objFile.Path,objfile.dateLastModified)
          str = str&getfilelink(objFile.Path,objfile.dateLastModified)&vbcrlf
          Next
          ShowSubFolders(objFolder)

          ’response.write "</urlset>"
          str = str&"</urlset>"&vbcrlf
          set fso = nothing

          Set objStream = Server.CreateObject("ADODB.Stream")
          With objStream
          ’.Type = adTypeText
          ’.Mode = adModeReadWrite
          .Open
          .Charset = "utf-8"
          .Position = objStream.Size
          .WriteText=str
          .SaveToFile server.mappath("/sitemap.xml"),2 ’生成的XML文件名
          .Close
          End With

          Set objStream = Nothing
          If Not Err Then
          Response.Write("<script>alert(’成功生成站點(diǎn)地圖!’);history.back();</script>")
          Response.End
          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)
          str = str & getfilelink(objSubFolder.Path,objSubFolder.dateLastModified)&vbcrlf
          Set colFiles = objSubFolder.Files
          For Each objFile In colFiles
          ’response.write getfilelink(objFile.Path,objFile.dateLastModified)
          str = str & getfilelink(objFile.Path,objFile.dateLastModified)&vbcrlf
          Next
          ShowSubFolders(objSubFolder)
          end if
          Next
          End Sub


          Function getfilelink(file,datafile)
          file=replace(file,root,"")
          file=replace(file,"/","/")
          If FileExtensionIsBad(file) then Exit Function
          if month(datafile)<10 then filedatem="0"
          if day(datafile)<10 then filedated="0"
          filedate=year(datafile)&"-"&filedatem&month(datafile)&"-"&filedated&day(datafile)
          getfilelink = "<url><loc>"&server.htmlencode(session("server")&vDir&file)&"</loc><lastmod>"&filedate&"</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>"
          Response.Flush
          End Function


          Function Folderpermission(pathName)

          ’需要過濾的目錄(不列在SiteMap里面)
          PathExclusion=Array("/temp","/_vti_cnf","_vti_pvt","_vti_log","cgi-bin","/admin","/edu")
          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
          ’modify for your file extension (http://www.googleguide.com/file_type.html)
          Extensions = Array("png","gif","jpg","jpeg","zip","pdf","ps","html","htm","php","wk1","wk2","wk3","wk4","wk5","wki","wks","wku","lwp","mw","xls","ppt","doc","swf","wks","wps","wdb","wri","rtf","ans","txt")
          ’設(shè)置列表的文件名,擴(kuò)展名不在其中的話SiteMap則不會(huì)收錄該擴(kuò)展名的文件
          發(fā)表評(píng)論 共有條評(píng)論
          用戶名: 密碼:
          驗(yàn)證碼: 匿名發(fā)表
          主站蜘蛛池模板: 申扎县| 凤山市| 西城区| 巴楚县| 新巴尔虎右旗| 确山县| 广宁县| 巩留县| 始兴县| 钟祥市| 临潭县| 沙河市| 崇仁县| 堆龙德庆县| 资源县| 兴宁市| 蓬莱市| 东乡县| 花垣县| 长阳| 文水县| 永安市| 乌拉特后旗| 洞头县| 布尔津县| 四平市| 涟源市| 平邑县| 筠连县| 定陶县| 梅河口市| 正宁县| 万山特区| 牙克石市| 侯马市| 会宁县| 黔西县| 许昌县| 韶关市| 云浮市| 平遥县|