网上收集的显示asp与php程序源代码的程序。不知能否加入精华区。
<%
on error resume next
%>
<%
function rt_min(num1,num2)
if num1=0 and num2=0 then
rt_min=-1
elseif num1=0 then
rt_min=num2
elseif num2=0 then
rt_min=num1
elseif num1<num2 then
rt_min=num1
else
rt_min=num2
end if
end function
%>
<%
function line_check(strline,cgi_type)
dim cgi_flag
if cgi_type="php" then
cgi_flag="?"
else
cgi_flag="%"
end if
line_check=0
itemp=0
ipos=instr(strline,"<"&cgi_flag)
if rt_min(ipos,itemp)=ipos then
itemp=ipos
line_check=1
end if
ipos=instr(strline,cgi_flag&">")
if rt_min(ipos,itemp)=ipos then
itemp=ipos
line_check=2
end if
ipos=instr(1,strline,"<"&"script",1)
if rt_min(ipos,itemp)=ipos then
itemp=ipos
line_check=3
end if
ipos=instr(1,strline,"<"&"/script",1)
if rt_min(ipos,itemp)=ipos then
itemp=ipos
line_check=4
end if
end function
%>
<%
sub printhtml(strline)
ispace=len(strline)-len(ltrim(strline))
i=1
while(mid(strline,i,1))=chr(9)
ispace=ispace+5
i=i+1
wend
if ispace>0 then
for i=1 to ispace
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(strline,iflag,cgi_type)
dim cgi_flag
if cgi_type="php" then
cgi_flag="?"
else
cgi_flag="%"
end if
select case iflag
case 0
call printhtml(strline)
case 1
ipos=instr(strline,"<"&cgi_flag)
call printhtml(left(strline,ipos-1))
response.write("<font color=#ff0000>")
response.write("<"&cgi_flag)
strline=right(strline,len(strline)-ipos-1)
call printline(strline,line_check(strline,cgi_type),cgi_type)
case 2
ipos=instr(strline,cgi_flag&">")
call printhtml(left(strline,ipos-1))
response.write(cgi_flag&">")
response.write("</font>")
strline=right(strline,len(strline)-ipos-1)
call printline(strline,line_check(strline,cgi_type),cgi_type)
case 3
ipos=instr(1,strline,"<"&"script",1)
call printhtml(left(strline,ipos-1))
response.write("<font color=#00ff00>")
response.write("<"&"script")
strline=right(strline,len(strline)-ipos-6)
call printline(strline,line_check(strline.cgi_type),cgi_type)
case 4
ipos=instr(1,strline,"<"&"/script>",1)
call printhtml(left(strline,ipos-1))
response.write("lt;"&"/script"&">")
response.write("</font>")
strline=right(strline,len(strline)-ipos-8)
call printline(strline,line_check(strline,cgi_type),cgi_type)
case else
response.write("error")
end select
end sub
%>
<html>
<head>
<title> view cgi_code(.asp or .php) </title>
</head>
<body>
<form action="view_code.asp" method="POST">
请输入路径:<input type=text name="code_path">
请选择类型:<select name="cgi_type">
<option value="asp">asp</option>
<option value="php">php</option>
</select>
<input type=submit>
</form>
<hr>
<%
if vartype(request.servervariables("HTTP_REFERER")) then
if request.servervariables("REQUEST_METHOD")="POST" then
code_path=request.form("code_path")
cgi_type=request.form("cgi_type")
response.write("下面的代码来自表格的提交:"&"<br>")
response.write("路径为:"&code_path&"<br>")
elseif request.servervariables("REQUEST_METHOD")="GET" then
code_path=request.querystring("code_path")
cgi_type=request.querystring("cgi_type")
response.write("下面的代码来自"&code_path&"的提交:"&"<br>")
response.write("路径为:"&code_path&"<br>")
end if
set fileobject=server.createobject("Scripting.FileSystemObject")
if fileobject.fileexists(code_path) then
set stream=fileobject.opentextfile(code_path,1,false,0)
while not stream.atendofstream
stroutput=stream.readline
call printline(stroutput,line_check(stroutput,cgi_type),cgi_type)
response.write("<br>")
wend
set stream=nothing
else
response.write("不能打开文件"&"<br>")
end if
end if
%>
<%
if err.number<>0 then
response.write("error"&"<br>")
response.write("错误代码:"&err.number&"<br>")
response.write("错误描述:"&err.description)
end if
%>
</body>
</html>
Tags:
作者:佚名评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论