asp破解图片盗链代码

 

源代码如下:

  1. <%
  2. '破解图片盗链
  3. '使用方法:tu.asp?url=
  4. 'tu.asp?url=http://hi.baidu.com/egergfdgregwe.jpg
  5. Dim url, body, myCache
  6. url = Request.QueryString("url")
  7.   Set myCache = new cache
  8.   myCache.name = "picindex"
  9.   If myCache.valid Then
  10.           body = myCache.value
  11.   Else
  12.           body = GetWebData(url)
  13.           myCache.add body,dateadd("d",1,now)
  14.   End If
  15.   If Err.Number = 0 Then
  16.         Response.CharSet = "UTF-8"
  17.         Response.ContentType = "application/octet-stream"
  18.         Response.BinaryWrite body
  19.         Response.Flush
  20.   Else
  21.         Wscript.Echo Err.Description
  22.   End if
  23. '取得数据
  24. Public Function GetWebData(ByVal strUrl)
  25. Dim curlpath
  26. curlpath = Mid(strUrl,1,Instr(8,strUrl,"/"))
  27. Dim Retrieval
  28. Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
  29. With Retrieval
  30. .Open "Get", strUrl, False,"",""
  31. .setRequestHeader "Referer", curlpath
  32. .Send
  33. GetWebData =.ResponseBody
  34. End With
  35. Set Retrieval = Nothing
  36. End Function
  37. 'cache类
  38. class Cache
  39.         private obj                                'cache内容
  40.         private expireTime                '过期时间
  41.         private expireTimeName        '过期时间application名
  42.         private cacheName                'cache内容application名
  43.         private path                        'url
  44.         
  45.         private sub class_initialize()
  46.                 path=request.servervariables("url")
  47.                 path=left(path,instrRev(path,"/"))
  48.         end sub
  49.         
  50.         private sub class_terminate()
  51.         end sub
  52.         
  53.         public property get blEmpty
  54.                 '是否为空
  55.                 if isempty(obj) then
  56.                         blEmpty=true
  57.                 else
  58.                         blEmpty=false
  59.                 end if
  60.         end property
  61.         
  62.         public property get valid
  63.                 '是否可用(过期)
  64.                 if isempty(obj) or not isDate(expireTime) then
  65.                         valid=false
  66.                 elseif CDate(expireTime)<now then
  67.                                 valid=false
  68.                 else
  69.                         valid=true
  70.                 end if
  71.         end property
  72.         
  73.         public property let name(str)
  74.                 '设置cache名
  75.                 cacheName=str & path
  76.                 obj=application(cacheName)
  77.                 expireTimeName=str & "expires" & path
  78.                 expireTime=application(expireTimeName)
  79.         end property
  80.         
  81.         public property let expires(tm)
  82.                 '重设置过期时间
  83.                 expireTime=tm
  84.                 application.lock
  85.                 application(expireTimeName)=expireTime
  86.                 application.unlock
  87.         end property
  88.         
  89.         public sub add(var,expire)
  90.                 '赋值
  91.                 if isempty(var) or not isDate(expire) then
  92.                         exit sub
  93.                 end if
  94.                 obj=var
  95.                 expireTime=expire
  96.                 application.lock
  97.                 application(cacheName)=obj
  98.                 application(expireTimeName)=expireTime
  99.                 application.unlock
  100.         end sub
  101.         
  102.         public property get value
  103.                 '取值
  104.                 if isempty(obj) or not isDate(expireTime) then
  105.                         value=null
  106.                 elseif CDate(expireTime)<now then
  107.                         value=null
  108.                 else
  109.                         value=obj
  110.                 end if
  111.         end property
  112.         
  113.         public sub makeEmpty()
  114.                 '释放application
  115.                 application.lock
  116.                 application(cacheName)=empty
  117.                 application(expireTimeName)=empty
  118.                 application.unlock
  119.                 obj=empty
  120.                 expireTime=empty
  121.         end sub
  122.         
  123.         public function equal(var2)
  124.                 '比较
  125.                 if typename(obj)<>typename(var2) then
  126.                         equal=false
  127.                 elseif typename(obj)="Object" then
  128.                         if obj is var2 then
  129.                                 equal=true
  130.                         else
  131.                                 equal=false
  132.                         end if
  133.                 elseif typename(obj)="Variant()" then
  134.                         if join(obj,"^")=join(var2,"^") then
  135.                                 equal=true
  136.                         else
  137.                                 equal=false
  138.                         end if
  139.                 else
  140.                         if obj=var2 then
  141.                                 equal=true
  142.                         else
  143.                                 equal=false
  144.                         end if
  145.                 end if
  146.         end function
  147. end class
  148. %>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值