Program | Source code <b>asp sources code:</b>
<HR>
<%
Dim objFSO, Objinfile ' object variables for file access
Dim Strin, strtemp ' string variables for reading and color
Processing
Dim I ' Standard loop control variable
Dim straspfilename ' string containing filename of ASP file to view
Dim processstring ' flag determining whether or not to output each
Line
' We don ' t start showing code till we find the start script comment
processstring = 0
' Get file name from query string
Straspfilename = request.querystring ("file")
' Conditional limiting use of this file to current directory
If InStr (1, straspfilename, "\", 1) Then straspfilename = ""
If InStr (1, Straspfilename, "/", 1) Then straspfilename = ""
' Set ' default so it shows itself if or a invalid
' Path is passed in. Delete the following line to just display
' A message.
If straspfilename = "" Then straspfilename = "source.asp"
If straspfilename <> "" Then
Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set objinfile = objFSO.OpenTextFile ("D:\Webs\asp101
\www\samples\ "& Straspfilename)
Response.Write "<PRE>" & VbCRLF
' Loop through real File and Output Results to Browser
Do as not Objinfile.atendofstream
Strin = Server.HTMLEncode (objinfile.readline)
' Check for Start script comment
If InStr (1, Strin, "<!--BEGIN SCRIPT-->",
1) Then
processstring = 1
Strin = Server.HTMLEncode
(Objinfile.readline)
End If
' Check for End script Comment
If InStr (1, Strin, "<!--end SCRIPT-->", 1)
Then processstring = 0
' If we ' on a-line to is processed then do
If processstring = 1 Then
strtemp = ""
' Loop through Line
For I = 1 to Len (Strin)
' A for script openers
To start red
If InStr (I, Strin, "<%", 1) =
I Then
strtemp = strtemp
& "<font color= #FF0000 >" & Mid (Strin, I, 1)
Else
' If no script openers
Look for closers to end red
If InStr (I, Strin, "%
> ", 1) = I Then
strtemp =
strtemp & "%></font>"
i = i + 4
Else
' If neither
Just copy to strtemp as is
strtemp =
Strtemp & Mid (Strin, I, 1)
End If
End If
Next
' Output out processed line
Response.Write Strtemp & VbCRLF
End If
Loop
Response.Write "</PRE>" & VbCRLF
' Close file and free variables
Objinfile.close
Set Objinfile = Nothing
Set objFSO = Nothing
Else
' If they entered no filename or one with a/or \ ... deny
Access
Response.Write "Sorry, but you don't have access to view
Files outside the current directory.
End If
%>