[Asp-last-code] shows the code for the ASP page

Source: Internet
Author: User
Show | page <%
'*************************************************************
' In the case of support FSO, you can display the code of all ASP pages in this site
' The code that displays the page directly on the effect page when the code is demonstrated without having to make a special page for the code
' Use method: viewsource.asp?file= the file name to display
' such as: viewsource.asp?file=x.asp
' Modify By:babyt
'*************************************************************
%>
<b style= "Font-size:12px;font-family:courier New" >html/asp Source code:</b>
&LT;HR size=1>
<%
Dim objFSO, Objinfile
Dim Strin, strtemp
Dim I, J
Dim strFileName
Dim processstring
Dim Bcharwritten
Dim Binsidescript
Dim binsidestring
Dim iinsidecomment

processstring = 0
Bcharwritten = False
Binsidescript = False
binsidestring = False
iinsidecomment = 0
LineCount = 1

strFileName = request.querystring ("file")

' To protect your other pages, for simple protection, only allow access to files in the current directory
' You can add more rules to your actual needs.
If InStr (1, strFileName, "\", 1) Then strfilename= ""
If InStr (1, strFileName, "/", 1) Then strfilename= ""

If strfilename <> "" Then
Set objFSO = CreateObject ("Scripting.FileSystemObject")
' To determine if a file exists
If objfso.fileexists (Server.MapPath (strFileName)) =false Then
Response.Write "File does not exist"
Response.End
End If
' Open File
Set objinfile = objFSO.OpenTextFile (Server.MapPath (strFileName))
Response.Write "<pre style= ' font-size:12px;font-family:courier New ' >" & VbCRLF
' Read text stream by row
Do as not Objinfile.atendofstream
' To encode
Strin = Server.HTMLEncode (objinfile.readline)
strtemp = ""
' Judgment start <%
' Quick highlight for the entire script, n default Blue
For I = 1 to Len (Strin)
Bcharwritten = False
If InStr (i, Strin, "<%", 1) = I Then
strtemp = strtemp & "<font color= #0000EE >"
Binsidescript = True
Else
' Judgment end sign bit% >
If InStr (i, Strin, "%>", 1) = I Then
strtemp = strtemp & "%></font>"
Bcharwritten = True
' So we dont get the trailing end of this tag again!
' IE. Len ("%>")-1 = 4
i = i + 4
Binsidescript = False
End If
End If
' Toggle Inside String if needed!
If binsidescript and iinsidecomment = 0 and InStr (i, Strin, "" ", 1) = I Then binsidestring = Not binsidestring
' Judge possible annotations, mainly to change their color (default green)
If Binsidescript and not binsidestring and (InStr (I, Strin, "'", 1) OR InStr (i, Strin, "//", 1)) = I Then
strtemp = strtemp & "<font color= #009900 >"
Iinsidecomment = iinsidecomment + 1
End If
' End Comment word processing
If iinsidecomment > 0 and I = Len (strin) Then
strtemp = strtemp & Mid (Strin, I, 1)
For J = 1 to Iinsidecomment
strtemp = strtemp & "</FONT>"
Next ' J
Bcharwritten = True
iinsidecomment = 0
End If
If Bcharwritten = False Then
strtemp = strtemp & Mid (Strin, I, 1)
End If
Next
' The line number, you can remove the line number
Response.Write "<font color= #666666 >" & linecount & "</font>" & strtemp & VbCRLF
LineCount = LineCount + 1
Loop
Response.Write "</PRE>" & VbCRLF

Objinfile.close
Set Objinfile = Nothing
Set objFSO = Nothing
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.