Can view the source code ASP program

Source: Internet
Author: User
Tags readline
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
%>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.