打开文件 SoftDown.Asp 在:
if request.QueryString("ID")="" then
response.write "不能连接或者没有指定下载软件"
response.end
end if
的上面或者是下面加上下列代码
dim strReferer,domain,splDomain,isHttp
isHttp=false
本站下载cn-media.com/i-v/index.shtm>系统网址列表,不要带上http://
domain="sron.net,61.156.14.223,61.156.14.227"
splDomain=split(domain,",")
strReferer=Request.ServerVariables("HTTP_REFERER")
for iii = 0 to ubound(splDomain)
if instr(strReferer,trim(splDomain(iii)))>0 then isHttp=True
next
if isnull(strReferer) or isHttp=false then
Response.Write "下载链接来自其他网站,这是不允许的,<a href=""./"">请进入本站页面后再进行下载。</a>"
CloseDatabase
response.end
end if
本站下载cn-media.com/i-v/index.shtm>系统网址列表 就是访问你下载频道网址里的域名,比如你的下载频道可以用多个网址来访问,所以这里用逗号隔开.
当然这里的防盗链只是相对的,只要知道了软件存放地址,防盗链就不管用了.
第三方法
用Asp实现防盗链技术(带自动返回功能)源文件代码:
------------------------------------------------------------------------------------------------------------------------
<%
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 "<b>非法链接!<br><span id=yu>3</span><a href=javascript:countDown></a>秒钟后cn-media.com/i-v/index.shtm>系统将自动返回首页......</b>"
response.write "<meta http-equiv=refresh content=3;url=index.asp>"
response.write "<SCRIPT>valignbottom()</SCRIPT>"
response.write "<script>function countDown(secs){yu.innerText=secs;if(--secs>0)setTimeout('countDown('+secs+')',1000);}countDown(3);</script>"
response.end
end if
Function GetFileName(longname)'/folder1/folder2/file.asp=>file.asp
while instr(longname,"/")
longname = right(longname,len(longname)-1)
wend
GetFileName = longname
End Function
Dim Stream
Dim Contents
Dim FileName
Dim TrueFileName
Dim FileExt
Const adTypeBinary = 1
FileName = Request.QueryString("FileName")
if FileName = "" Then
Response.Write "无效文件名!"
Response.End
End if
FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
Select Case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
Response.Write "非法操作!"
Response.End
End Select
Response.Clear
Response.AddHeader "content-disposition", "attachment; filename=" & GetFileName(Request.QueryString("FileName"))
Set Stream = server.CreateObject("ADODB.Stream")
Stream.Type = adTypeBinary
Stream.Open
if lcase(right(FileName,3))="rar" then '设置文件类型
TrueFileName = "/files/"&FileName '设置文件目录的相对路径
end if
Stream.LoadFromFile Server.MapPath(TrueFileName)
While Not Stream.EOS
Response.BinaryWrite Stream.Read(1024 * 64)
Wend
Stream.Close
Set Stream = Nothing
Response.Flush
Response.End
%>猜你感兴趣
最新文章