程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> ASP實例教程:隱藏下載地址和防盜

ASP實例教程:隱藏下載地址和防盜

編輯:關於ASP編程

     

    以下為引用的內容:
    <% 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 "該文件不存在或者已經刪除."
    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 "該文件不存在或者已經刪除."
    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 "該文件數據不完整或許已損壞."
    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
    %>

    調用

    <%Call DownloadFIle("下載地址")%>

    1. 上一頁:
    2. 下一頁:
    Copyright © 程式師世界 All Rights Reserved