Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
3.9 KiB

  1. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  2. REM *************** NOTICE ****************
  3. REM * This file may only be used to view *
  4. REM * source code of .asp files in the *
  5. REM * IXSTest directory. If you wish to *
  6. REM * change the security on this, modify *
  7. REM * or remove this function. *
  8. REM ***************************************
  9. FUNCTION fValidPath (ByVal strPath)
  10. If InStr(1, strPath, "/IXSTest/", 1) Then
  11. fValidPath = 1
  12. Else
  13. fValidPath = 0
  14. End If
  15. END FUNCTION
  16. </SCRIPT>
  17. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  18. REM Returns the minimum number greater than 0
  19. REM If both are 0, returns -1
  20. FUNCTION fMin (iNum1, iNum2)
  21. If iNum1 = 0 AND iNum2 = 0 Then
  22. fMin = -1
  23. ElseIf iNum2 = 0 Then
  24. fMin = iNum1
  25. ElseIf iNum1 = 0 Then
  26. fMin = iNum2
  27. ElseIf iNum1 < iNum2 Then
  28. fMin = iNum1
  29. Else
  30. fMin = iNum2
  31. End If
  32. END FUNCTION
  33. </SCRIPT>
  34. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  35. FUNCTION fCheckLine (ByVal strLine)
  36. fCheckLine = 0
  37. iTemp = 0
  38. iPos = InStr(strLine, "<" & "%")
  39. If fMin(iTemp, iPos) = iPos Then
  40. iTemp = iPos
  41. fCheckLine = 1
  42. End If
  43. iPos = InStr(strLine, "%" & ">")
  44. If fMin(iTemp, iPos) = iPos Then
  45. iTemp = iPos
  46. fCheckLine = 2
  47. End If
  48. iPos = InStr(1, strLine, "<" & "SCRIPT", 1)
  49. If fMin(iTemp, iPos) = iPos Then
  50. iTemp = iPos
  51. fCheckLine = 3
  52. End If
  53. iPos = InStr(1, strLine, "<" & "/SCRIPT", 1)
  54. If fMin(iTemp, iPos) = iPos Then
  55. iTemp = iPos
  56. fCheckLine = 4
  57. End If
  58. END FUNCTION
  59. </SCRIPT>
  60. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  61. SUB PrintHTML (ByVal strLine)
  62. iSpaces = Len(strLine) - Len(LTrim(strLine))
  63. If iSpaces > 0 Then
  64. For i = 1 to iSpaces
  65. Response.Write("&nbsp;")
  66. Next
  67. End If
  68. iPos = InStr(strLine, "<")
  69. If iPos Then
  70. Response.Write(Left(strLine, iPos - 1))
  71. Response.Write("&lt;")
  72. strLine = Right(strLine, Len(strLine) - iPos)
  73. Call PrintHTML(strLine)
  74. Else
  75. Response.Write(strLine)
  76. End If
  77. END SUB
  78. </SCRIPT>
  79. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  80. SUB PrintLine (ByVal strLine, iFlag)
  81. Select Case iFlag
  82. Case 0
  83. Call PrintHTML(strLine)
  84. Case 1
  85. iPos = InStr(strLine, "<" & "%")
  86. Call PrintHTML(Left(strLine, iPos - 1))
  87. Response.Write("<FONT COLOR=#ff0000>")
  88. Response.Write("&lt;%")
  89. strLine = Right(strLine, Len(strLine) - (iPos + 1))
  90. Call PrintLine(strLine, fCheckLine(strLine))
  91. Case 2
  92. iPos = InStr(strLine, "%" & ">")
  93. Call PrintHTML(Left(strLine, iPos -1))
  94. Response.Write("%&gt;")
  95. Response.Write("</FONT>")
  96. strLine = Right(strLine, Len(strLine) - (iPos + 1))
  97. Call PrintLine(strLine, fCheckLine(strLine))
  98. Case 3
  99. iPos = InStr(1, strLine, "<" & "SCRIPT", 1)
  100. Call PrintHTML(Left(strLine, iPos - 1))
  101. Response.Write("<FONT COLOR=#0000ff>")
  102. Response.Write("&lt;SCRIPT")
  103. strLine = Right(strLine, Len(strLine) - (iPos + 6))
  104. Call PrintLine(strLine, fCheckLine(strLine))
  105. Case 4
  106. iPos = InStr(1, strLine, "<" & "/SCRIPT>", 1)
  107. Call PrintHTML(Left(strLine, iPos - 1))
  108. Response.Write("&lt;/SCRIPT&gt;")
  109. Response.Write("</FONT>")
  110. strLine = Right(strLine, Len(strLine) - (iPos + 8))
  111. Call PrintLine(strLine, fCheckLine(strLine))
  112. Case Else
  113. Response.Write("FUNCTION ERROR -- PLEASE CONTACT ADMIN.")
  114. End Select
  115. END SUB
  116. </SCRIPT>
  117. <HTML>
  118. <HEAD><TITLE>View Source Code</TITLE></HEAD>
  119. <%
  120. strVirtualPath = Request("source")
  121. If fValidPath(strVirtualPath) Then
  122. strFilename = Server.MapPath(strVirtualPath)
  123. Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
  124. Set oInStream = FileObject.OpenTextFile (strFilename, 1, FALSE, TRUE )
  125. While NOT oInStream.AtEndOfStream
  126. strOutput = oInStream.ReadLine
  127. Call PrintLine(strOutput, fCheckLine(strOutput))
  128. Response.Write("<BR>")
  129. Wend
  130. Else
  131. Response.Write("<H1>View Source Code -- Access Denied</H1>")
  132. End If
  133. %>
  134. </HTML>