According to the code modification provided by the forest, the webmaster has been tested in Vevb.com, which is easy to use!
ASP version, requires FSO support of space!
The following is the code fragment:
<%
Server.scripttimeout = 50000
'Sitemap_gen.asp
'A SIMPLE SCRIP to Automatical 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
'
'BSD 2.0 License,
'http://www.opensource.org/licenses/bsd-dhense.php
'Collect and organize: Chongqing [email protected]
session (server) = http: //192.168.0.111 'Your domain name
VDIR = / 'Make a directory of Sitemap, relative directory (relative to the root directory)
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.dateLastModify)
Set colors = objfolder.files
For Each Objfile in Colfiles
'Response.write getfilelink (objfile.path, objfile.datelastmodify)
Str = Str & GetFileLink (Objfile.Path, Objfile.datelastmodify) & VBCRLF
Next
Showsubfolders (Objfolder)
'Response.write </urlset>
Str = Str & </urlset> & vbcrf
set fSO = Nothing
Set objstream = Server.createObject (Adodb.Stream)
With objstream
'.Type = adtypetext
'.Mode = admodeReadwrite
.Opeen
.Charset = UTF-8
.Position = objstream.size
.Writetext = STR
.Savetofile server.mappath (/sitemap.xml), the xml file name generated by 2 '
.Close
End with
Set objstream = Nothing
If NOT ERR THEN
Response.write (<script> Alert ('Successful generating site map!'); History.back (); </script>)
Response.end
End if
Sub showsubfolders (Objfolder)
Set colorders = objfolder.subfolders
For Each Objsubfolder in Colfolders
If FolderPerMission (Objsubfolder.Path) then
'Response.write getfilelink (Objsubfolder.Path, Objsubfolder.datelastmodify)
Str = Str & GetFileLink (Objsubfolder.path, Objsubfolder.dateLastModify) & VBCRLF
Set colors = objsubfolder.files
For Each Objfile in Colfiles
'Response.write getfilelink (objfile.path, objfile.datelastmodify)
Str = Str & GetFileLink (Objfile.Path, Objfile.datelastmodify) & VBCRLF
Next
Showsubfolders (Objsubfolder)
end if
Next
End sub
Function getfilelink (file, dataFile)
file = replace (file, root,)
file = replace (file,/,/)
If fileXTENSIONISBAD (File) then exit function
if Month (DataFile) <10d FileDatem = 0
if day (datafile) <10d filedated = 0
FileDate = Year (DataFile) &-& FileDatem & Month (DataFile) &-& Filedated & Day (DataFile)
getfilelink = <url> <Loc> & server.htmlencode (session (server) & vdir & file) & </local) q> <priority> 1.0 </priority> </url "
Response.flush
End function
Function FolderPerMission (PathName)
'The directory that needs to be filtered (not listed in Sitemap)
Pathexclusion = Aray (/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)
'Set the file name of the list, if the extension is not among it, Sitemap will not include the file of the extended name
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 (sfileextation) then
bfileeXTENSIONISVALID = TRUE
exit for
end if
next
FileEXTENSIONISBAD = Not BFileExtentisvalid
End function
%>