找回密码
 注册
【阿里云】2核2G云新老同享 99元/年,续费同价华为云精选云产品特惠做网站就用糖果主机Jtti,新加坡服务器,美国服务器,香港服务器
查看: 494|回复: 2

加亮显示ASP文章原代码

[复制链接]
发表于 2005 年 7 月 20 日 18:15:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
  1. <%@ LANGUAGE="VBSCRIPT" %>
  2. <% Option Explicit %>
  3. <%
  4. 'File: CodeBrws.asp
  5. 'Overview: This formats and writes the text of the selected page for
  6. ' the View Script Button
  7. 'This file is provided as part of the Microsoft Visual Studio 6.0 Samples
  8. 'THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
  9. 'WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
  10. 'INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
  11. 'OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  12. 'PURPOSE.
  13. 'Copyright (C) 1997, 1998 Microsoft Corporation, All rights reserved
  14. %>
  15. <html>
  16. <head>
  17. <meta NAME="DESCRIPTION" CONTENT="ASP Source code browser">
  18. <meta NAME="GENERATOR" CONTENT="Microsoft FrontPage 3.0">
  19. <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso8859-1">
  20. <title></title>
  21. </head>
  22. <body BGCOLOR="#FFFFFF" TOPMARGIN="0" LEFTMARGIN="0" ALINK="#23238E" VLINK="#808080"
  23. LINK="#FFCC00">
  24. <basefont FACE="VERDANA, ARIAL, HELVETICA" SIZE="2"><!--- DISPLAY THE COLOR LEGEND --->
  25. <table BORDER="1">
  26. <tr>
  27. <td WIDTH="25" BGCOLOR="#FF0000"> </td>
  28. <td><font FACE="VERDANA, ARIAL, HELVETICA" SIZE="2">ASP Script</font> </td>
  29. </tr>
  30. <tr>
  31. <td BGCOLOR="#0000FF"> </td>
  32. <td><font FACE="VERDANA, ARIAL, HELVETICA" SIZE="2">Comments</font> </td>
  33. </tr>
  34. <tr>
  35. <td BGCOLOR="#000000"> </td>
  36. <td><font FACE="VERDANA, ARIAL, HELVETICA" SIZE="2">HTML and Text</font> </td>
  37. </tr>
  38. </table>
  39. <hr>
  40. <font FACE="VERDANA, ARIAL, HELVETICA" SIZE="2"><% OutputSource %>
  41. </font>
  42. </body>
  43. </html>
  44. <%
  45. Sub OutputSource
  46. Dim strVirtualPath, strFilename
  47. strVirtualPath = Request("Source")
  48. strFilename = Server.MapPath(strVirtualPath)
  49. Dim FileObject, oInStream, strOutput
  50. 'Creates a file object to hold the text of the selected page
  51. Set FileObject = CreateObject("Scripting.FileSystemObject")
  52. Set oInStream = FileObject.OpenTextFile(strFilename, 1, 0, 0)
  53. 'Loop that writes each line of text in the file according to
  54. 'the PrintLine function below
  55. While NOT oInStream.AtEndOfStream
  56. strOutput = oInStream.ReadLine
  57. Call PrintLine(strOutput, fCheckLine(strOutput))
  58. Response.Write "<BR>"
  59. Wend
  60. End Sub
  61. ' Returns the minimum number greater than 0
  62. ' If both are 0, returns -1
  63. Function fMin(iNum1, iNum2)
  64. If iNum1 = 0 AND iNum2 = 0 Then
  65. fMin = -1
  66. ElseIf iNum2 = 0 Then
  67. fMin = iNum1
  68. ElseIf iNum1 = 0 Then
  69. fMin = iNum2
  70. ElseIf iNum1 < iNum2 Then
  71. fMin = iNum1
  72. Else
  73. fMin = iNum2
  74. End If
  75. End Function
  76. Function fCheckLine (ByVal strLine)
  77. Dim iTemp, iPos
  78. fCheckLine = 0
  79. iTemp = 0
  80. iPos = InStr(strLine, "<" & "%")
  81. If fMin(iTemp, iPos) = iPos Then
  82. iTemp = iPos
  83. fCheckLine = 1
  84. End If
  85. iPos = InStr(strLine, "%" & ">")
  86. If fMin(iTemp, iPos) = iPos Then
  87. iTemp = iPos
  88. fCheckLine = 2
  89. End If
  90. iPos = InStr(1, strLine, "<" & "SCRIPT", 1)
  91. If fMin(iTemp, iPos) = iPos Then
  92. iTemp = iPos
  93. fCheckLine = 3
  94. End If
  95. iPos = InStr(1, strLine, "<" & "/SCRIPT", 1)
  96. If fMin(iTemp, iPos) = iPos Then
  97. iTemp = iPos
  98. fCheckLine = 4
  99. End If
  100. iPos = InStr(1, strLine, "<" & "!--", 1)
  101. If fMin(iTemp, iPos) = iPos Then
  102. iTemp = iPos
  103. fCheckLine = 5
  104. End If
  105. iPos = InStr(1, strLine, "-" & "->", 1)
  106. If fMin(iTemp, iPos) = iPos Then
  107. iTemp = iPos
  108. fCheckLine = 6
  109. End If
  110. End Function
  111. Sub PrintHTML (ByVal strLine)
  112. Dim iPos, iSpaces, i
  113. iSpaces = Len(strLine) - Len(LTrim(strLine))
  114. i = 1
  115. 'Correct for tabs
  116. While Mid(Strline, i, 1) = Chr(9)
  117. iSpaces = iSpaces + 5
  118. i = i + 1
  119. Wend
  120. 'Insert spaces
  121. If iSpaces > 0 Then
  122. For i = 1 to iSpaces
  123. Response.Write(" ")
  124. Next
  125. End If
  126. iPos = InStr(strLine, "<")
  127. If iPos Then
  128. Response.Write(Left(strLine, iPos - 1))
  129. Response.Write("<")
  130. strLine = Right(strLine, Len(strLine) - iPos)
  131. Call PrintHTML(strLine)
  132. Else
  133. Response.Write(strLine)
  134. End If
  135. End Sub
  136. Sub PrintLine (ByVal strLine, iFlag)
  137. Dim iPos
  138. Select Case iFlag
  139. Case 0
  140. Call PrintHTML(strLine)
  141. Case 1
  142. iPos = InStr(strLine, "<" & "%")
  143. Call PrintHTML(Left(strLine, iPos - 1))
  144. Response.Write("<FONT COLOR=#ff0000>")
  145. Response.Write("<%")
  146. strLine = Right(strLine, Len(strLine) - (iPos + 1))
  147. Call PrintLine(strLine, fCheckLine(strLine))
  148. Case 2
  149. iPos = InStr(strLine, "%" & ">")
  150. Call PrintHTML(Left(strLine, iPos -1))
  151. Response.Write("%>")
  152. Response.Write("</FONT>")
  153. strLine = Right(strLine, Len(strLine) - (iPos + 1))
  154. Call PrintLine(strLine, fCheckLine(strLine))
  155. Case 3
  156. iPos = InStr(1, strLine, "<" & "SCRIPT", 1)
  157. Call PrintHTML(Left(strLine, iPos - 1))
  158. Response.Write("<FONT COLOR=#0000ff>")
  159. Response.Write("<SCRIPT")
  160. strLine = Right(strLine, Len(strLine) - (iPos + 6))
  161. Call PrintLine(strLine, fCheckLine(strLine))
  162. Case 4
  163. iPos = InStr(1, strLine, "<" & "/SCRIPT>", 1)
  164. Call PrintHTML(Left(strLine, iPos - 1))
  165. Response.Write("</SCRIPT>")
  166. Response.Write("</FONT>")
  167. strLine = Right(strLine, Len(strLine) - (iPos + 8))
  168. Call PrintLine(strLine, fCheckLine(strLine))
  169. Case 5
  170. iPos = InStr(1, strLine, "<" & "!--", 1)
  171. Call PrintHTML(Left(strLine, iPos - 1))
  172. Response.Write("<FONT COLOR=#0000ff>")
  173. Response.Write("<!--")
  174. strLine = Right(strLine, Len(strLine) - (iPos + 3))
  175. Call PrintLine(strLine, fCheckLine(strLine))
  176. Case 6
  177. iPos = InStr(1, strLine, "-" & "->", 1)
  178. Call PrintHTML(Left(strLine, iPos - 1))
  179. Response.Write("-->")
  180. Response.Write("</FONT>")
  181. strLine = Right(strLine, Len(strLine) - (iPos + 2))
  182. Call PrintLine(strLine, fCheckLine(strLine))
  183. Case Else
  184. Response.Write("Function Error -- Please contact the administrator.")
  185. End Select
  186. End Sub
  187. %>
复制代码
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
发表于 2005 年 7 月 23 日 17:11:47 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
看看
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2005 年 8 月 1 日 11:17:31 | 显示全部楼层
这个怎么用啊
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|金光论坛

GMT+8, 2024 年 11 月 19 日 23:28 , Processed in 0.020098 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表