home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / rds.cab / showcode.asp < prev    next >
Text File  |  1997-08-14  |  5KB  |  169 lines

  1. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  2.  
  3.  REM *************** NOTICE ****************
  4.  REM * This file may only be used to view  *
  5.  REM * source code of .asp files in the    *
  6.  REM * AdvWorks or ASP Sample directory.   *    
  7.  REM * If you wish to change the security  *
  8.  REM * on this, modify or remove this      *
  9.  REM * function.                           *
  10.  REM ***************************************
  11.  
  12.  FUNCTION fValidPath (ByVal strPath)
  13.   If InStr(1, strPath, "/Msadc/", 1) Then
  14.     fValidPath = 1
  15.   Else
  16.     fValidPath = 0
  17.   End If
  18.  END FUNCTION
  19. </SCRIPT>
  20.  
  21. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  22.  REM Returns the minimum number greater than 0
  23.  REM If both are 0, returns -1
  24.  FUNCTION fMin (iNum1, iNum2)
  25.   If iNum1 = 0 AND iNum2 = 0 Then
  26.     fMin = -1
  27.   ElseIf iNum2 = 0 Then
  28.     fMin = iNum1
  29.   ElseIf iNum1 = 0 Then
  30.     fMin = iNum2
  31.   ElseIf iNum1 < iNum2 Then
  32.     fMin = iNum1
  33.   Else 
  34.     fMin = iNum2
  35.   End If
  36.  END FUNCTION
  37. </SCRIPT>
  38.  
  39. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  40.  FUNCTION fCheckLine (ByVal strLine)
  41.  
  42.   fCheckLine = 0
  43.   iTemp = 0
  44.  
  45.   iPos = InStr(strLine, "<" & "%")
  46.   If fMin(iTemp, iPos) = iPos Then
  47.     iTemp = iPos
  48.     fCheckLine = 1
  49.   End If
  50.   
  51.   iPos = InStr(strLine, "%" & ">")
  52.   If fMin(iTemp, iPos) = iPos Then
  53.     iTemp = iPos
  54.     fCheckLine = 2
  55.   End If
  56.  
  57.   iPos = InStr(1, strLine, "<" & "SCRIPT", 1)
  58.   If fMin(iTemp, iPos) = iPos Then
  59.     iTemp = iPos
  60.     fCheckLine = 3
  61.   End If
  62.  
  63.   iPos = InStr(1, strLine, "<" & "/SCRIPT", 1)
  64.   If fMin(iTemp, iPos) = iPos Then
  65.     iTemp = iPos
  66.     fCheckLine = 4
  67.   End If
  68.  
  69.  END FUNCTION
  70. </SCRIPT>
  71.  
  72. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  73. SUB PrintHTML (ByVal strLine)
  74.     iSpaces = Len(strLine) - Len(LTrim(strLine))
  75.     i = 1
  76.     While Mid(Strline, i, 1) = Chr(9)
  77.         iSpaces = iSpaces + 5
  78.         i = i + 1
  79.     Wend
  80.   If iSpaces > 0 Then
  81.     For i = 1 to iSpaces
  82.       Response.Write(" ")
  83.     Next
  84.   End If
  85.   iPos = InStr(strLine, "<")
  86.   If iPos Then
  87.     Response.Write(Left(strLine, iPos - 1))
  88.     Response.Write("<")
  89.     strLine = Right(strLine, Len(strLine) - iPos)
  90.     Call PrintHTML(strLine)
  91.   Else
  92.     Response.Write(strLine)
  93.   End If
  94.  END SUB
  95. </SCRIPT>
  96.     
  97. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  98.  SUB PrintLine (ByVal strLine, iFlag)
  99.   Select Case iFlag
  100.     Case 0
  101.       Call PrintHTML(strLine)
  102.     Case 1
  103.       iPos = InStr(strLine, "<" & "%")
  104.       Call PrintHTML(Left(strLine, iPos - 1))
  105.       Response.Write("<FONT COLOR=#ff0000>")
  106.       Response.Write("<%")
  107.       strLine = Right(strLine, Len(strLine) - (iPos + 1))
  108.       Call PrintLine(strLine, fCheckLine(strLine))
  109.     Case 2
  110.       iPos = InStr(strLine, "%" & ">")
  111.       Call PrintHTML(Left(strLine, iPos -1))
  112.       Response.Write("%>")
  113.       Response.Write("</FONT>")
  114.       strLine = Right(strLine, Len(strLine) - (iPos + 1))
  115.       Call PrintLine(strLine, fCheckLine(strLine))
  116.     Case 3
  117.       iPos = InStr(1, strLine, "<" & "SCRIPT", 1)
  118.       Call PrintHTML(Left(strLine, iPos - 1))
  119.       Response.Write("<FONT COLOR=#0000ff>")
  120.       Response.Write("<SCRIPT")
  121.       strLine = Right(strLine, Len(strLine) - (iPos + 6))
  122.       Call PrintLine(strLine, fCheckLine(strLine))
  123.     Case 4
  124.       iPos = InStr(1, strLine, "<" & "/SCRIPT>", 1)
  125.       Call PrintHTML(Left(strLine, iPos - 1))
  126.       Response.Write("</SCRIPT>")
  127.       Response.Write("</FONT>")
  128.       strLine = Right(strLine, Len(strLine) - (iPos + 8))
  129.       Call PrintLine(strLine, fCheckLine(strLine))
  130.     Case Else
  131.       Response.Write("FUNCTION ERROR -- PLEASE CONTACT ADMIN.")
  132.   End Select
  133.  END SUB
  134. </SCRIPT>
  135.  
  136. <% strVirtualPath = Request("source") %>
  137.  
  138. <HTML>
  139. <HEAD><TITLE>View Active Server Page Source</TITLE></HEAD>
  140. <BODY BGCOLOR=#FFFFFF>
  141. <FONT FACE="Verdana, Arial, Helvetica" SIZE=6>
  142. <TABLE>
  143. <TR>
  144. <TD><IMG SRC="/Msadc/Samples/Selector/asp.gif" WIDTH=200 HEIGHT=93 BORDER=0 ALT="Active Server Page logo"></TD>
  145. <TD><FONT FACE="Verdana, Arial, Helvetica" SIZE=6>View ASP Source</FONT></TD>
  146. </TR>
  147. </TABLE>
  148. <FONT FACE="Verdana, Arial, Helvetica" SIZE=2>
  149. Go Back to <a href="<%=strVirtualPath%>"><%=strVirtualPath%></A>
  150. <BR>
  151. <hr>
  152. <%
  153. If fValidPath(strVirtualPath) Then
  154.     strFilename = Server.MapPath(strVirtualPath)
  155.     Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
  156.     Set oInStream = FileObject.OpenTextFile (strFilename, 1, FALSE )
  157.     While NOT oInStream.AtEndOfStream
  158.       strOutput = oInStream.ReadLine
  159.       Call PrintLine(strOutput, fCheckLine(strOutput))
  160.       Response.Write("<BR>")
  161.     Wend
  162.   Else
  163.     Response.Write("<H1>View Active Server Page Source-- Access Denied</H1>")
  164.   End If  
  165. %>
  166.  
  167. </BODY>
  168. </HTML>
  169.