This is a simple ASP site map generator that I wrote some time ago using VBScript, it’s for a human-readable sitemap not the XML sitemaps used by Google and other search engines. It uses the Scripting.FileSystemObject to scan the same directory level that the ASP is placed at and returns a link to any htm or html pages found along with the last modification time and the title of the page. It was fairly quickly written so the parsing used for the title tag is just to suit the format I was using and it might need some other tweaking to suit your own site.
Because I don’t actively use the script anymore I haven’t updated to XHTML 1.0 Strict so on the W3C Markup Validation Service it will only pass as HTML 4.01 Transitional. Currently presentation elements are embedded in the HTML rather than a CSS style sheet. Here is the main logic for the page:
<table border="1">
<tr><td><b>Page name</b></td><td ALIGN="RIGHT"><b>Modified</b></td><td><b>Title</b></td></tr>
<%
Dim objFSO, objFolder, objFiles, objFile, strFile, Title, CurLine, LCaseLine, TitlePos, PageCount, FontColour
Private Sub GetTitle(FileName)
Dim fso, file, strPhysicalPath
Title = ""
set fso = Server.Createobject("Scripting.FileSystemObject")
strPhysicalPath = Server.MapPath(FileName)
set file = fso.opentextfile(strPhysicalPath, 1)
do until file.AtEndOfStream or Len(Title) > 0
CurLine = file.ReadLine
LCaseLine = LCase(CurLine)
TitlePos = InStr(LCaseLine, "<title>")
if TitlePos then
Title = Right(CurLine, Len(CurLine) - TitlePos - 6)
Title = Left(Title, InStr(LCaseLine, "</title>") - 8 )
end if
loop
file.close
End Sub
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath("."))
Set objFiles = objFolder.Files
PageCount = 0
For Each objFile in objFiles
strFile = LCase(objFile.Name)
If Right(strFile, 4) = ".htm" or Right(strFile, 5) = ".html" then
GetTitle(objFile.Name)
if Len(Title) > 0 then
PageCount = PageCount + 1
if objFile.DateLastModified >= Date - 7 then
FontColour = "<font color=""#FF0000"">"
else
FontColour = "<font color=""#000000"">"
end if
Response.Write("<tr><td><a href=""" & strFile & """>" & _
strFile & "</a></td><td align=""RIGHT"">" & _
FontColour & DateValue(objFile.DateLastModified) & "</font>" & _
"</td><td>" & Title & "</td></tr>")
end if
end if
next
Response.Write("<tr><td> </td><td> </td><td><b>Total pages: " & PageCount & "</b></td></tr>")
%>
</table>