<% Option Explicit %> <% If InStr(UCase(Request("Source")),".CDX") > 0 Then %> <% Else %> <% End If %>
   ASP Script
   Comments
  XML and TextHTML and Text

<% OutputSource %> <% Sub OutputSource Dim strVirtualPath, strFilename strVirtualPath = Request("Source") If fValidPath(strVirtualPath) Then strFilename = Server.MapPath(strVirtualPath) Dim FileObject, oInStream, strOutput Set FileObject = CreateObject("Scripting.FileSystemObject") response.write strVirtualPath Response.Write "

" Set oInStream = FileObject.OpenTextFile(strFilename, 1, 0, 0) While NOT oInStream.AtEndOfStream strOutput = oInStream.ReadLine Call PrintLine(strOutput, fCheckLine(strOutput)) Response.Write "
" Wend Else Response.Write("

View Active Server Page Source-- Access Denied

") End If End Sub ' Returns the minimum number greater than 0 ' If both are 0, returns -1 Function fMin(iNum1, iNum2) If iNum1 = 0 AND iNum2 = 0 Then fMin = -1 ElseIf iNum2 = 0 Then fMin = iNum1 ElseIf iNum1 = 0 Then fMin = iNum2 ElseIf iNum1 < iNum2 Then fMin = iNum1 Else fMin = iNum2 End If End Function Function fMax(iNum1,iNum2) if iNum1 > iNum2 then fMax = iNum1 else fMax = iNum2 end if End Function Function fCheckLine (ByVal strLine) Dim iTemp, iPos fCheckLine = 0 iTemp = 0 iPos = InStr(1, strLine, "<" & "FONT", 1) If fMin(iTemp, iPos) = iPos Then iTemp = iPos fCheckLine = -2 End If iPos = InStr(1, strLine, "<" & "/FONT", 1) If fMin(iTemp, iPos) = iPos Then iTemp = iPos fCheckLine = -1 End If iPos = InStr(strLine, "<" & "%") If fMin(iTemp, iPos) = iPos Then iTemp = iPos fCheckLine = 1 End If iPos = InStr(strLine, "%" & ">") If fMin(iTemp, iPos) = iPos Then iTemp = iPos fCheckLine = 2 End If iPos = InStr(1, strLine, "<" & "SCRIPT", 1) If fMin(iTemp, iPos) = iPos Then iTemp = iPos fCheckLine = 3 End If iPos = InStr(1, strLine, "<" & "/SCRIPT", 1) If fMin(iTemp, iPos) = iPos Then iTemp = iPos fCheckLine = 4 End If iPos = InStr(1, strLine, "<" & "!--", 1) If fMin(iTemp, iPos) = iPos Then iTemp = iPos fCheckLine = 5 End If iPos = InStr(1, strLine, "-" & "->", 1) If fMin(iTemp, iPos) = iPos Then iTemp = iPos fCheckLine = 6 End If iPos = InStr(1, strLine, "<" & "T", 1) If fMin(iTemp, iPos) = iPos Then iTemp = iPos fCheckLine = 7 End If iPos = InStr(1, strLine, "<" & "/T", 1) If fMin(iTemp, iPos) = iPos Then iTemp = iPos fCheckLine = 8 End If End Function Sub PrintHTML (ByVal strLine) Dim iPos, iSpaces, i iSpaces = Len(strLine) - Len(LTrim(strLine)) i = 1 While Mid(Strline, i, 1) = Chr(9) iSpaces = iSpaces + 5 i = i + 1 Wend If iSpaces > 0 Then For i = 1 to iSpaces Response.Write(" ") Next End If iPos = InStr(strLine, "<") If iPos Then Response.Write(Left(strLine, iPos - 1)) Response.Write("<") strLine = Right(strLine, Len(strLine) - iPos) Call PrintHTML(strLine) Else Response.Write(strLine) End If End Sub Sub Doreplace(fstrLine,btag1,bTag2,bString,eString) Dim ipos iPos = InStr(1,fstrLine, btag1 & bTag2) if ipos = 0 then Exit Sub 'Call PrintLine(strLine, fCheckLine(strLine)) end if Call PrintHTML(Left(fstrLine, iPos - 1)) Response.Write(bString) if btag1 = "<" then Response.Write("<" & bTag2) else if bTag2 = ">" then Response.Write(btag1 & ">") else Response.Write(btag1 & bTag2) end if end if if bTag2 = ">" or bTag2 = "%" then Response.Write(eString ) fstrLine = Right(fstrLine, Len(fstrLine) - (iPos + len(bTag2))) Call PrintLine(fstrLine, fCheckLine(fstrLine)) if bTag2 <> ">" and bTag2 <> "%" then Response.Write(eString) End Sub Sub PrintLine (ByVal strLine, iFlag) Dim iPos,xpos Select Case iFlag Case -2 iPos = InStr(1,strLine, "<" & "FONT") if ipos = 0 then Exit Sub 'Call PrintLine(strLine, fCheckLine(strLine)) end if Call PrintHTML(Left(strLine, iPos - 1)) Response.Write("") Response.Write("<FONT") xPos = InStr(iPos + 4 ,strLine, ">") Response.Write(">") Call PrintHTML(Mid(strLine, iPos + 6, (xpos+1)-(ipos+5))) Response.Write("") strLine = Right(strLine, Len(strLine) - (xPos)) Call PrintLine(strLine, fCheckLine(strLine)) Case -1 iPos = InStr(1,strLine, "<" & "/FONT") if ipos = 0 then Exit Sub 'Call PrintLine(strLine, fCheckLine(strLine)) end if Call PrintHTML(Left(strLine, iPos -1)) Response.Write("") Response.Write("</FONT") xPos = InStr(iPos + 4 ,strLine, ">") Response.Write(">") Call PrintHTML(Mid(strLine, iPos + 7, (xpos+1)-(ipos+6))) Response.Write("") strLine = Right(strLine, Len(strLine) - (xPos)) Call PrintLine(strLine, fCheckLine(strLine)) Case 0 Call PrintHTML(strLine) Case 1 Call Doreplace(strLine,"<","%","","") Case 2 Call Doreplace(strLine,"%",">","","") Case 3 Call Doreplace(strLine,"<","SCRIPT","","") Case 4 Call Doreplace(strLine,"<","/SCRIPT","","") Case 5 Call Doreplace(strLine,"<","!--","","") Case 6 Call Doreplace(strLine,"-","->","","") Case 7 Call Doreplace(strLine,"<","T","","") Case 8 Call Doreplace(strLine,"<","/T","","") Case Else Response.Write("Function Error -- Please contact the administrator.") End Select End Sub %>