<%
' Site Validator 1.0.0
' Very simple concept, run this script on your server, it records the "file details to"
' XML file which you download and store. Then, when your come back to make changes can
"Run the XML file back through this script and it'll tell you if any of the files have
' Been modified. Quite simple really.
' Requires XML parser version 3 to work really. Also needs access to the FileSystemObject.
Dim objrequest, objFSO, SXML, Objxml, Objnode, objfile, Ldifferences, Sversion, sdate
Sversion = "1.0.0"
Response.Expires =-1
Set objrequest = New proxyrequest
If UCase (objrequest ("action") = "UPLOAD" Then
Response.ContentType = "Text/html"
%>
<HTML>
<HEAD>
<title>aspvalidate, Site Validator <%=sVersion%></TITLE>
</HEAD>
<BODY>
<p>validation results</p>
<%
Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")
Set objxml = Server.CreateObject ("MSXML2. DOMDocument ")
Objxml.async = False
SXML = Objrequest ("Xmlupload")
Objxml.loadxml Objrequest.asciitounicode (SXML)
ldifferences = 0
"Now we go through" XML entries and validate each one against this on the server
For each objnode in ObjXML.documentElement.childNodes
On Error Resume Next
Set objfile = Objfso.getfile (Objnode.getattribute ("path"))
If Err.Number <> 0 Then
"Problem with the" file
Response.Write "<b>"
Response.Write Objnode.getattribute ("path") & "<br>"
Response.Write "^^ ^^ FILE has BEEN removed<br>"
Response.Write "</b>"
Else
If CStr (objfile.datelastmodified) <> Objnode.getattribute ("modified") or CStr (objfile.size) <> Objnode.getattribute ("size") then
Response.Write "<b>"
Response.Write Objnode.getattribute ("path") & "<br> ^^ ^^ Changed,"
Response.Write "Original:" & Objnode.getattribute ("Modified") & "Modified:" & Objfile.datelastmodified &am P ", "
Response.Write "was" & Objnode.getattribute ("Size") & "Bytes-now" & CStr (objfile.size) & "Bytes<b R> "
Response.Write "</b>"
Ldifferences = ldifferences + 1
ElseIf objrequest ("View") <> "" Then
Response.Write Objnode.getattribute ("path") & "-File has not changed<br>"
End If
End If
On Error Goto 0
Next
If ldifferences = 0 Then
Response.Write "<p>the site matches the last update</p>"
Else
Response.Write "<p>" & Ldifferences & "difference (s) detected in the above files</p>"
End If
%>
<a href= "aspvalidate.asp" >back to the main page</a>
</BODY>
</HTML>
<%
Response.End
ElseIf UCase (objrequest.querystring ("action") = "XML" Then
Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")
SXML = "<?xml version= ' 1.0 '?>" & VbCRLF
SXML = SXML & <!--generated by Site Validator "& sversion &"--> "& VbCRLF
SXML = SXML & "<!--author:chris Read-->" & VbCRLF
SXML = SXML & "<site>" & VbCRLF
SXML = SXML & ProcessFolder (Server.MapPath ("/"))
SXML = SXML & "</site>" & VbCRLF
Sdate = year (date ()) & "-" & Month (Date ()) & "-" & Day (date ())
Response.ContentType = "Text/xml"
Response.AddHeader "Content-disposition", "attachment"; Filename=site "& Sdate &". xml; "
Response.Write SXML
Response.End
Else
Response.ContentType = "Text/html"
%>
<HTML>
<HEAD>
<title>aspvalidate, Site Validator <%=sVersion%></TITLE>
</HEAD>
<BODY>
<p>this script would scan your entire Web site from the root folder, and a record of the file sizes and last modified date s for all ASP pages.
This is saved as XML. Then, at a later date, where you need to make adjustments or check anything, and you can load the XML into
This script again and it ' ll tell you which files have changed and when.</p>
Checksum all ASP files in this site and generate an XML Checksum file<br>
<a href= "Aspvalidate.asp?action=xml&html=0" >right-click here and select "Save as" to download for ASP files </a><br>
<a href= "Aspvalidate.asp?action=xml&html=1" >right-click here and select "Save as" to download for ASP and HTML F Iles</a><br>
<form action= "aspvalidate.asp" method= "post" enctype= "Multipart/form-data" Id=form1 name=form1>
<br>OR<br><br>
Upload XML File of checksums and validate it against this site<br>
File: <input type=file name=xmlupload><br>
Show all results: <input Type=checkbox name=view><br>
<input type=submit name=action value= "Upload" >
</form>
</BODY>
</HTML>
<%
Response.End
End If
' Bit of ' recursion to traverse the folder structure building XML
Function ProcessFolder (Sfolder)
Dim objfolder, Objroot, objfile, Stemp, slastmodified, ssize
Set objroot = Objfso.getfolder (Sfolder)
Stemp = ""
For each objfile in Objroot.files
objfile.name,4 = ". asp" or (right (objfile.name,5) = ". html" or right (objfile.name,4) = ". htm") and Request ("HT ML ") = 1)) and InStr (Sfolder &" "& Objfile.name," _vti_cnf ") = 0 Then
Slastmodified = objfile.datelastmodified
Ssize = Objfile.size
Stemp = stemp & "<file path=" "& Sfolder &" "& Objfile.name &" ' modified= ' "" & Slastmodifie D & "' Size= '" "& Ssize &" '/> "& VbCRLF
End If
Next
For each objfolder in Objroot.subfolders
Stemp = stemp & ProcessFolder (Sfolder & "" & Objfolder.name)
Next
Set objfolder = Nothing
ProcessFolder = stemp
End Function
' Reques object proxy for uploads.
Class Proxyrequest
Public ClientCertificate
Public Cookies
Public Form
Public querystring
Public ServerVariables
Public TotalBytes
Private M_item
Public Default Property Get Item (Sindex)
Item = M_item (Sindex)
End Property
Private Sbinarytext
Public Function BinaryRead (ltotalbytes)
BinaryRead = LeftB (sbinarytext,ltotalbytes)
End Function
Private Sub parserequest ()
Dim Sdelimeter
Dim Lkeylength
Dim Lblockend
Dim Sblock
Dim stemp
Dim Sfield
Dim Lstart
Dim Llength
Dim sFileName
Dim Scontenttype
Dim scontent
Sblock = Sbinarytext
Lkeylength = InstrB (1,SBLOCK,CHRB (&h0d))-1
If lkeylength > 0 Then
Sdelimeter = LeftB (sblock,lkeylength)
Lblockend = 0
While Lblockend >= 0
' Chop off the key, including the cr/lf pair
Sblock = RIGHTB (Sblock,lenb (Sblock)-(lblockend + lkeylength + 2))
Lblockend = InStrB (1,sblock,sdelimeter)-1
If Lblockend >= 0 Then
Stemp = LeftB (sblock,lblockend-2)
Lstart = InStrB (1,stemp,unicodetoascii ("name=")) + 6
Llength = InStrB (LSTART,STEMP,CHRB)-Lstart
Sfield = MidB (stemp,lstart,llength)
Lstart = InStrB (1,stemp,unicodetoascii ("filename=")) + 10
Llength = InStrB (LSTART,STEMP,CHRB)-Lstart
If Lstart > Then
sFileName = MidB (stemp,lstart,llength)
Lstart = InStrB (1,stemp,unicodetoascii ("Content-type:")) + 14
Llength = InStrB (LSTART,STEMP,CHRB (&h0d))-Lstart
Scontenttype = MidB (stemp,lstart,llength)
Else
sFileName = ""
Scontenttype = ""
End If
Lstart = InStrB (1,stemp,unicodetoascii (VbCRLF & VbCRLF)) + 4
Llength = LenB (stemp)-Lstart + 1
Scontent = MidB (stemp,lstart,llength)
If Asciitounicode (sfilename) <> "" Then
M_item.add Asciitounicode (Sfield), scontent
M_item.add Asciitounicode (Sfield) & "_filename", Asciitounicode (sFileName)
M_item.add Asciitounicode (Sfield) & "_contenttype", Asciitounicode (Scontenttype)
Else
M_item.add Asciitounicode (Sfield), Asciitounicode (scontent)
End If
End If
Wend
End If
End Sub
Public Function unicodetoascii (stext)
Dim ltemp
Dim objstream
Set objstream = Server.CreateObject ("ADODB. Stream ")
objStream.Open
For ltemp = 1 to Len (stext)
Objstream.writetext ChrB (ASC (stext,ltemp,1))
Next
objstream.position = 0
Unicodetoascii = Objstream.readtext
End Function
Public Function Asciitounicode (stext)
' Do this with the stream, avoiding VBScript string concatenation, which are slow to say the least
Dim ltemp
Dim objstream
Set objstream = Server.CreateObject ("ADODB. Stream ")
objStream.Open
For ltemp = 1 to LenB (stext)
Objstream.writetext MidB (Stext, Ltemp, 1) & ChrB (0), 0
Next
objstream.position = 0
Asciitounicode = Objstream.readtext
End Function
Private Sub Class_Initialize ()
Set M_item = Server.CreateObject ("Scripting.Dictionary")
Set ClientCertificate = request.clientcertificate
Set Cookies = Request.Cookies
Set Form = Request.Form
Set querystring = Request.QueryString
Set ServerVariables = Request.ServerVariables
TotalBytes = Request.TotalBytes
Sbinarytext = Request.BinaryRead (request.totalbytes)
Parserequest
End Sub
Private Sub Class_Terminate ()
Set ClientCertificate = Nothing
Set Cookies = Nothing
Set Form = Nothing
Set querystring = Nothing
Set ServerVariables = Nothing
End Sub
End Class
%>