The code from the Internet has been slightly modified, and the cache class is actually used. .
Save the code as, for example, pic.asp
Use: http://www.xxx.com/pic.asp?url=http://www.aaaa.com/log.gif
Not only 163, but also many pictures of anti-theft can be realized.
<%
'Judgement of theft of links
'IfInstr(Request.ServerVariables("http_referer"),"http://"&Request.ServerVariables("server_name")&"")=0Then
'Response.Write "Illegal Link"
'Response.End
'EndIf
Dimurl, body, myCache
url=Request.QueryString("url")
SetmyCache=newcache
myCache.name="picindex"&url
IfmyCache.validThen
body=myCache.value
Else
body=GetWebData(url)
myCache.addbody,dateadd("d",1,now)
EndIf
IfErr.Number=0Then
Response.CharSet="UTF-8"
Response.ContentType="application/octet-stream"
Response.BinaryWritebody
Response.Flush
Else
Wscript.EchoErr.Description
Endif
'Get data
PublicFunctionGetWebData(ByValstrUrl)
Dimcurlpath
curlpath=Mid(strUrl,1,Instr(8,strUrl,"/"))
DimRetrieval
SetRetrieval=Server.CreateObject("Microsoft.XMLHTTP")
WithRetrieval
.Open"Get",strUrl,False,"",""
.setRequestHeader"Referer",curlpath
.Send
GetWebData=.ResponseBody
EndWith
SetRetrieval=Nothing
EndFunction
'cache class
classCache
privateobj'cache content
privateexpireTime'Expiration Time
privateexpireTimeName'Expiration Time Application Name
privatecacheName'cache content application name
privatepath'url
privatesubclass_initialize()
path=request.servervariables("url")
path=left(path,instrRev(path,"/"))
endsub
privatesubclass_terminate()
endsub
publicpropertygetblEmpty
'Is it empty
ifsempty(obj)then
blEmpty=true
else
blEmpty=false
endif
endproperty
publicpropertygetvalid
'Whether it is available (expired)
ifsempty(obj)ornotisDate(expireTime)then
valid=false
elseifCDate(expireTime)<nowthen
valid=false
else
valid=true
endif