上一篇:用ASP创建Microsoft Word 文件 >>
加亮显示ASP文章原代码
<% option explicit %>
<%
file: codebrws.asp
overview: this formats and writes the text of the selected page for
the view script button
this file is provided as part of the microsoft visual studio 6.0 samples
this code and information is provided "as is" without
warranty of any kind, either expressed or implied,
including but not limited to the implied warranties
of merchantability and/or fitness for a particular
purpose.
copyright (c) 1997, 1998 microsoft corporation, all rights reserved
%>
<html>
<head>
<meta name="description" content="asp source code browser">
<meta name="generator" content="microsoft frontpage 3.0">
<meta http-equiv="content-type" content="text/html; charset=iso8859-1">
<title></title>
</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0" alink="#23238e" vlink="#808080"
link="#ffcc00">
<basefont face="verdana, arial, helvetica" size="2"><!--- display the color legend --->
<table border="1">
<tr>
<td width="25" bgcolor="#ff0000"> </td>
<td><font face="verdana, arial, helvetica" size="2">asp script</font> </td>
</tr>
<tr>
<td bgcolor="#0000ff"> </td>
<td><font face="verdana, arial, helvetica" size="2">comments</font> </td>
</tr>
<tr>
<td bgcolor="#000000"> </td>
<td><font face="verdana, arial, helvetica" size="2">html and text</font> </td>
</tr>
</table>
<hr>
<font face="verdana, arial, helvetica" size="2"><% outputsource %>
</font>
</body>
</html>
<%
sub outputsource
dim strvirtualpath, strfilename
strvirtualpath = request("source")
strfilename = server.mappath(strvirtualpath)
dim fileobject, oinstream, stroutput
creates a file object to hold the text of the selected page
set fileobject = createobject("scripting.filesystemobject")
set oinstream = fileobject.opentextfile(strfilename, 1, 0, 0)
loop that writes each line of text in the file according to
the printline function below
while not oinstream.atendofstream
stroutput = oinstream.readline
call printline(stroutput, fcheckline(stroutput))
response.write "<br>"
wend
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 fcheckline (byval strline)
dim itemp, ipos
fcheckline = 0
itemp = 0
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
end function
sub printhtml (byval strline)
dim ipos, ispaces, i
ispaces = len(strline) - len(ltrim(strline))
i = 1
correct for tabs
while mid(strline, i, 1) = chr(9)
ispaces = ispaces + 5
i = i + 1
wend
insert spaces
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 printline (byval strline, iflag)
dim ipos
select case iflag
case 0
call printhtml(strline)
case 1
ipos = instr(strline, "<" & "%")
call printhtml(left(strline, ipos - 1))
response.write("<font color=#ff0000>")
response.write("<%")
strline = right(strline, len(strline) - (ipos + 1))
call printline(strline, fcheckline(strline))
case 2
ipos = instr(strline, "%" & ">")
call printhtml(left(strline, ipos -1))
response.write("%>")
response.write("</font>")
strline = right(strline, len(strline) - (ipos + 1))
call printline(strline, fcheckline(strline))
case 3
ipos = instr(1, strline, "<" & "script", 1)
call printhtml(left(strline, ipos - 1))
response.write("<font color=#0000ff>")
response.write("<script")
strline = right(strline, len(strline) - (ipos + 6))
call printline(strline, fcheckline(strline))
case 4
ipos = instr(1, strline, "<" & "/script>", 1)
call printhtml(left(strline, ipos - 1))
response.write("</script>")
response.write("</font>")
strline = right(strline, len(strline) - (ipos + 8))
call printline(strline, fcheckline(strline))
case 5
ipos = instr(1, strline, "<" & "!--", 1)
call printhtml(left(strline, ipos - 1))
response.write("<font color=#0000ff>")
response.write("<!--")
strline = right(strline, len(strline) - (ipos + 3))
call printline(strline, fcheckline(strline))
case 6
ipos = instr(1, strline, "-" & "->", 1)
call printhtml(left(strline, ipos - 1))
response.write("-->")
response.write("</font>")
strline = right(strline, len(strline) - (ipos + 2))
call printline(strline, fcheckline(strline))
case else
response.write("function error -- please contact the administrator.")
end select
end sub
%>
()
下一篇:ASP漏洞分析和解决方法(10) >>
相关文章:
- · 一个基于ASP的标题广告管理系统(一)
- · 深入研究“用ASP上载文件”(二)
- · 深入研究“用ASP上载文件”(一)
- · 在Visual J++中编写ASP COM组件
- · 复杂表单的动态生成与动态验证
- · w3 upload组件实例应用3
- · w3 upload组件实例应用2
- · w3 upload组件实例应用1
- · Ad Rotator 组件参考(五) - Ad Rotator 的方法
- · Ad Rotator 组件参考(四) - Ad Rotator 的属性
- · Ad Rotator 组件参考(三) - 重定向文件
- · 导入大量MYSQL数据的方法
- · Ad Rotator 组件参考(二) - Rotator Schedule 文件
- · Ad Rotator 组件参考(一) - 概述
- · Counters 组件参考(五) - Set方法
- · Counters 组件参考(四) - Remove方法
- · Counters 组件参考(三) - Increment方法
- · Counters 组件参考(二) - Get方法
- · Counters 组件参考(一) - 概述
- · 用Java开发组件
- · ASP的几大可扩展组件(二)
- · ASP的几大可扩展组件(一)
- · NewMail 对象(CDONTS 库)发送邮件
- · 浅谈MsChart在ASP中的应用
- · 用ASP生成Chart (二维饼图)
- · 用ASP生成Chart
- · 使用ASP建立Http组件
- · FileSystemobject组件
- · Dns组件的一些用法
- · chart组件在ASP中的应用
- · Zaks Pop3 参考说明
- · Zaks Pop3 简要介绍
- · ASP Image 使用范例
- · Asp Image 简要介绍
- · ASP HTTP 使用范例
- · Asp HTTP 简要介绍
- · ASP Ping 简要介绍
- · ASP Chart 使用范例
