A simple introduction to the function bar: the use of an ASP object ServerVariables (server environment variables), through this environment variable can get to the real download address and then through some simple VBS built-in functions to destroy the integrity of its true address. Achieve the ability to cheat download software. Now attached to the source code to provide you learn.
Copy Code code as follows:
<% FunctIon DownloadFIle (strfile)
Strfilename=strfile
Response.buffer=true
Response.Clear
Set s=server.createobject ("ADODB. Stream ")
S.open
S.type=1
On Error Resume Next
Set fso=server.createobject ("Scripting.FileSystemObject")
If not fso.fileexists (strFileName) Then
From_url=cstr (Request.ServerVariables ("Http_referer"))
Serv_url=cstr (Request.ServerVariables ("SERVER_NAME"))
If MId (From_url,8,len (serv_url)) <> Serv_url Then
Response.Write "The file does not exist or has been deleted."
Response.End
End If
Response.Redirect request.servervariables ("Http_referer")
Response.End
End If
Fileext=mid (Strfilename,instrrev (strFileName, ".") +1)
Select case UCase (Fileext)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB", "PHP", "JSP", "SHTML", "HTML", "HTM", "TV", "DATA"
From_url=cstr (Request.ServerVariables ("Http_referer"))
Serv_url=cstr (Request.ServerVariables ("SERVER_NAME"))
If MId (From_url,8,len (serv_url)) <> Serv_url Then
Response.Write "The file does not exist or has been deleted."
Response.End
End If
Response.Redirect request.servervariables ("Http_referer")
Response.End
End Select
Set F=fso.getfile (strFileName)
Intfilelength=f.size
S.loadfromfile (strFileName)
If ERR Then
From_url=cstr (Request.ServerVariables ("Http_referer"))
Serv_url=cstr (Request.ServerVariables ("SERVER_NAME"))
If MId (From_url,8,len (serv_url)) <> Serv_url Then
Response.Write "The file data is incomplete or corrupted."
Response.End
End If
Response.Redirect request.servervariables ("Http_referer")
Response.End
End If
Set upload=server.createobject ("Persits.upload")
If Upload is nothing Then
Response.AddHeader "Content-disposition", "attachment"; Filename= "&f.name
Response.AddHeader "Content-length", intfilelength
response.charset= "UTF-8"
Response.contenttype= "Application/x-download"
Response.BinaryWrite S.read
Response.Flush
S.close
Set s=nothing
Else
Upload.sendbinary strfilename,true, "Application/x-download", False
End If
End FunctIon
%>
Use: <%call DownloadFIle ("DownloadFIle")%>.