用戶登錄  |  用戶注冊
首 頁源碼下載網絡學院最新源碼源碼排行屏蔽廣告
當前位置:新興網絡 > 網絡學院 > Asp編程 > Asp 技巧

ASP 防盜鏈下載及隱藏文件路徑

減小字體 增大字體 作者:佚名  來源:本站整理  發布時間:2010-06-10 05:20:04
ASP code復制代碼
<%
Call ChkPostAgent '防止盜鏈檢測
Call DownloadFIle("soft/test.rar")   '下載文件
%>

<%
Public Sub ChkPostAgent()
    'On Error Resume Next
    Dim server_v1, server_v2
    Dim m_blnAgent, m_strAgent
    m_blnAgent = False
    server_v1 = CStr(Request.ServerVariables("HTTP_REFERER"))
    server_v2 = CStr(Request.ServerVariables("SERVER_NAME"))
    If Mid(server_v1, 8, Len(server_v2)) = server_v2 Then
        m_blnAgent = True
    End If
    If m_blnAgent Then
        m_strAgent = Request.ServerVariables("HTTP_USER_AGENT")
        If Left(m_strAgent, 7) = "Mozilla" Or Left(m_strAgent, 5) = "Opera" Then
            m_blnAgent = True
        End If
    End If
    If m_blnAgent = False Then
        response.Write "非法鏈接"
        Response.End
    End If
End Sub

Public Sub 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
        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 Sub
%>

Tags:ASP 防盜鏈 隱藏文件路徑

作者:佚名
  • 好的評價 如果您覺得此文章好,就請您
      100%(2)
  • 差的評價 如果您覺得此文章差,就請您
      0%(0)

網絡學院評論評論內容只代表網友觀點,與本站立場無關!

   評論摘要(共 0 條,得分 0 分,平均 0 分) 查看完整評論
175哪个门派赚钱快 黑龙江三十六选7期开奖结果 体彩6 1预测推荐 家庭存款都买理财好吗 湖北快三开奖走势图 股票短线高手群 安徽十一选五开奖结果一定牛... 天涯股票论坛高手帖子 重庆快乐十分稳定计划 股票涨跌原理详解 河南今日泳坛夺金开奖结果