[點晴永久免費OA]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("下載地址")%> 該文章在 2022/6/21 18:10:48 編輯過 |
關鍵字查詢
相關文章
正在查詢... |