ASP程序实现查看ASP文件源码实例代码

王朝网络·asp·作者佚名  2006-11-24
宽屏版  字体: |||超大  

<%

SUB PrintLine (ByVal strLine)

strLine=server.HTMLEncode(strLine)

strLine=replace(strLine,"<%","<FONT COLOR=#ff0000><%")

strLine=replace(strLine,"%>","%></FONT>")

strLine=replace(strLine,"<SCRIPT","<FONT COLOR=#0000ff><SCRIPT",1,-1,1)

strLine=replace(strLine,"</SCRIPT>","</SCRIPT></FONT>",1,-1,1)

strLine=replace(strLine,"<!--","<FONT COLOR=#008000><!--",1,-1,1)

strLine=replace(strLine,"-->","--></FONT>",1,-1,1)

Response.Write strLine

END SUB

Function ShowCode(filename)

Dim strFilename

Dim FileObject, oInStream, strOutput

strFilename = filename

Set FileObject = Server.CreateObject("Scripting.FileSystemObject")

Set oInStream = FileObject.OpenTextFile(strFilename, 1, 0, 0 )

While NOT oInStream.AtEndOfStream

strOutput = oInStream.ReadLine

Call PrintLine(strOutput)

Response.Write("<BR>")

Wend

end function

%>

<HTML>

<HEAD>

<TITLE>ASP源码浏览器</TITLE>

</HEAD>

<BODY BGCOLOR=#FFFFFF>

<form action=viewcode.asp method=post>

请输入ASP文件名

<input type=file name=filename>

<input type=submit value="查看源程序">

</form>

<%

on error resume next

dim file

file=request.form("filename")

response.write file & "源程序如下<hr>"

if trim(file)<> "" then

call showcode(file)

end if

%>

</FONT>

</BODY>

</HTML>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有