ASP 隱藏下載地址及防盜鏈代碼
更新時(shí)間:2010年04月06日 13:02:44 作者:
好多朋友做了下載站,但經(jīng)常被盜鏈的嚴(yán)重,所以大家可以用這個(gè)方法隱藏真實(shí)下載地址。讓別人無(wú)法看到具體的下載地址。
復(fù)制代碼 代碼如下:
<% 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 "該文件不存在或者已經(jīng)刪除."
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 "該文件不存在或者已經(jīng)刪除."
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 "該文件數(shù)據(jù)不完整或許已損壞."
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
%>
調(diào)用
復(fù)制代碼 代碼如下:
<%Call DownloadFIle("下載地址")%>
您可能感興趣的文章:
- IIS防盜鏈 ISAPI Rewrite圖片防盜鏈規(guī)則寫(xiě)法
- ASP.NET 圖片加水印防盜鏈實(shí)現(xiàn)代碼
- Apache下MP3 防盜鏈的解決辦法
- php下通過(guò)偽造http頭破解防盜鏈的代碼
- php防盜鏈的常用方法小結(jié)
- asp.net下結(jié)合HttpHandler實(shí)現(xiàn)圖片防盜鏈
- 破解圖片防盜鏈的代碼(asp/php)測(cè)試通過(guò)
- asp 防盜鏈代碼(徹底屏蔽迅雷,旋風(fēng),快車(chē)下載站內(nèi)資源)
- Asp.net 圖片文件防盜鏈(尊重勞動(dòng)成果)及BeginRequest事件學(xué)習(xí)
相關(guān)文章
ASP之處理用Javascript動(dòng)態(tài)添加的表單元素?cái)?shù)據(jù)的代碼
ASP之處理用Javascript動(dòng)態(tài)添加的表單元素?cái)?shù)據(jù)的代碼...2007-11-11服務(wù)端 VBScript 與 JScript 幾個(gè)相同特性的寫(xiě)法與示例
服務(wù)端 VBScript 與 JScript 幾個(gè)相同特性的寫(xiě)法與示例...2007-03-03ASP實(shí)現(xiàn)網(wǎng)頁(yè)打開(kāi)任何類(lèi)型文件都提示保存的方法附代碼
ASP實(shí)現(xiàn)網(wǎng)頁(yè)打開(kāi)任何類(lèi)型文件都提示保存的方法附代碼...2007-11-11asp之自動(dòng)閉合HTML/ubb標(biāo)簽函數(shù) 附簡(jiǎn)單注釋
在用到編輯器時(shí),就會(huì)碰到一點(diǎn),那就是標(biāo)簽的閉合問(wèn)題,這個(gè)問(wèn)題非常嚴(yán)峻,因?yàn)檫@可能會(huì)導(dǎo)致網(wǎng)頁(yè)顯示的整體樣式受到破壞。2010-04-04ASP的Server.MapPath()不同參數(shù)返回路徑總結(jié)
這篇文章主要介紹了ASP的Server.MapPath()不同參數(shù)返回路徑總結(jié),也就是在Server.MapPath()中填入絕對(duì)路徑、相對(duì)路徑等情況的返回值總結(jié),需要的朋友可以參考下2014-07-07ASP讀取XML實(shí)例 優(yōu)酷專(zhuān)輯采集程序 雷鋒版
用asp獲取指定專(zhuān)題的xml文件,然后讀取xml文件的列表內(nèi)容批量讀取。2009-12-12