一个网站的一个页面download.asp通过判断referer来确定是不是从他本站点过来的链接,使用这个功能我们可以用来防止下载盗链,当然这种方法不是最可靠的,看下面的代码,通过XMLHTTP就伪造了REFERER地址。
ASP实现下载系统防盗链方法
代码:
<%
Function GetBody(weburl)
Set Retrieval = Server.CreateObject("MSXML2.XMLHTTP")
With Retrieval
.Open "Get", weburl, False, "", ""
.setRequestHeader "referer","http://www.aspxhome.com/"'想改什么就改什么
.Send
GetBody = .ResponseBody
End With
GetBody = BytesToBstr(GetBody,"GB2312")
Set Retrieval = Nothing
End Function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Response.Write(GetBody("http://www.aspxhome.com/referer.asp"))
%>