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. %>
發佈了189 篇原創文章 · 獲贊 4 · 訪問量 15萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章