以文本方式查看主题

-  智睿软件_技术交流论坛  (http://zhirui.net/bbs/index.asp)
--  Web程序开发  (http://zhirui.net/bbs/list.asp?boardid=22)
----  [推荐]ASP 防盗下载代码,隐藏真实下载地址  (http://zhirui.net/bbs/dispbbs.asp?boardid=22&id=1331)

--  作者:zhirui
--  发布时间:2011-08-21 09:45:48
--  [推荐]ASP 防盗下载代码,隐藏真实下载地址

<%
call downloadFile("Images/1.gif")
function downloadFile(strFile)
    strFilename = server.MapPath(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
        Response.Write("<h1>Error:</h1>" & strFilename & " does not exist<p>")
        Response.End
    end if
    Set f = fso.GetFile(strFilename)
    intFilelength = f.size
    s.LoadFromFile(strFilename)
    if err then
        Response.Write("<h1>Error: </h1>" & err.Description & "<p>")
        Response.End
    end if
    Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
    Response.AddHeader "Content-Length", intFilelength
    Response.CharSet = "UTF-8"
    Response.C
    Response.BinaryWrite s.Read
    Response.Flush
    s.Close
    Set s = Nothing
End Function
%>

<%
filepath=request.servervariables("script_name")
value=Request.QueryString("ID")
if(value="100") then
Response.Write("下载地址:<a href=\'http://www.google.com\'>这里就模拟连到Google,假装是下载地址!</a>")
else%>
<a href="<%=filepath%>?ID=100">Link</a>
<%
end if
%>