ASP防止盗链的一段代码

<%@Language="vbscript"%>
<%
Response.Buffer = true
Response.Expires = -1441

' variables
dim ref : ref=Request.ServerVariables("HTTP_REFERER")
dim arrReferer : arrReferer = split(ref, "/")
dim imgName, strDomain, strDirectory, strImage, strAntiLeech

' assign variables
strDomain = "http://www.xxxx.net"
strDirectory = "/"

' assign variables
strAntiLeech = "anti-leech.jpg"
strImage = request.querystring("img")

if ref > "" then
ref = arrReferer(2) 
end if

if request.querystring("img") <> "" then

if ref = "localhost" or ref = strDomain or ref = "www." & strDomain then
imgname = strDirectory & strImage
else
imgName = strDirectory & strAntiLeech
end if

else

imgName = strDirectory & strAntiLeech

end if

dim objStream
set objStream = server.CreateObject("ADODB.Stream")
objStream.Type = 1
objStream.Open()
objStream.loadFromFile(Server.MapPath(imgName))

Response.ContentType = "image/gif"
Response.BinaryWrite(objStream.Read())

objStream.close()
set objstream = nothing

%>上面代码保存为a.asp
<img src="a.asp" border="0" /> 

  

转载于:https://www.cnblogs.com/uuxanet/p/3282683.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值