An ASP program that displays the original code

Source: Internet
Author: User
Tags php and

An ASP program that displays the original code

We all know that the ASP this kind of server-side processing programs, one of the benefits is that only to the client output standard HTML stream. So it can play a role in hiding details from the customer. That is, when we type the URL of the ASP program in the browser, we can only see the standard HTML file, and can't see the content of ASP. But sometimes, for example, in an ASP's teaching site, we need to display the contents of ASP files, or you are willing to share your original code with people, through a program to display the code.

Here's an ASP program I wrote, View_code.asp, which provides two ways to submit:

One is to submit in a form, that is, you know the physical address of the source file (similar to: c:\asp_source\test.asp form).
One is a get-way commit (similar to:< a href= "View_code.asp?code_path= <%=server.mappath" (Request.ServerVariables ("Path_info")) % >&cgi_type=asp ">

Click here to view the original code </a >). It also supports two kinds of CGI scripts, one is ASP, one is PHP.

Code Snippets:

<%

On Error Resume Next

' Ignore errors in program execution and deal with them at the end of the program.

% >

<%

function Rt_min (num1,num2)

' The subroutine is used to return the least decimal number in two numbers that is not equal to zero.

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

Rt_min=num1

Else

Rt_min=num2

End If

End Function

% >

<%

function Line_check (strline,cgi_type)

' This subroutine is used to check if the input segment contains a special character for <%,% >, < script > or </SCRIPT

Dim Cgi_flag

If cgi_type= "PHP" Then

Cgi_flag= "?"

Else

cgi_flag= "%"

End If

' defined Cgi_flag used to represent different identifiers for PHP and ASP

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

% >




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.