Code for cracking image anti-Leech protection (asp/php) passed the test

Source: Internet
Author: User
Anti-Leech measures have been applied to many website images. common Sina blogs, NetEase albums, Baidu spaces, and QQ spaces cannot be used for external link images. if you want to save the images locally before uploading them, it seems troublesome. Php code is relatively simple:

The code is as follows:


$ P = $ _ GET ['P'];
$ Pics = file ($ p );
For ($ I = 0; $ I <count ($ pics); $ I ++)
{
Echo $ pics [$ I];
}
?>



Usage: Save the file as I. php and upload it to the root directory.
Change the image address that cannot be chained to http: // your domain name p. php? P = Image address

Asp

The code is as follows:


<%
Dim url, body, myCache
Url = Request. QueryString ("url ")
Set myCache = new cache
MyCache. name = "picindex" & url
If myCache. valid Then
Body = myCache. value
Else
Body = GetWebData (url)
MyCache. add body, dateadd ("d", 1, now)
End If
If Err. Number = 0 Then
Response. CharSet = "UTF-8"
Response. ContentType = "application/octet-stream"
Response. BinaryWrite body
Response. Flush
Else
Wscript. Echo Err. Description
End if
'Get data
Public Function GetWebData (ByVal strUrl)
Dim curlpath
Curlpath = Mid (strUrl, 1, Instr (8, strUrl ,"/"))
Dim Retrieval
Set Retrieval = Server. CreateObject ("Microsoft. XMLHTTP ")
With Retrieval
. Open "Get", strUrl, False ,"",""
. SetRequestHeader "Referer", curlpath
. Send
GetWebData =. ResponseBody
End
Set Retrieval = Nothing
End Function
'Cache class
Class Cache
Private obj 'cache content
Private expireTime 'expiration time
Private expireTimeName 'expiration Time application name
Private cacheName 'cache content application name
Private path 'URL
Private sub class_initialize ()
Path = request. servervariables ("url ")
Path = left (path, limit Rev (path ,"/"))
End sub
Private sub class_terminate ()
End sub
Public property get blEmpty
'Empty?
If isempty (obj) then
BlEmpty = true
Else
BlEmpty = false
End if
End property
Public property get valid
'Available (expired)
If isempty (obj) or not isDate (expireTime) then
Valid = false
Elseif CDate (expireTime) Valid = false
Else
Valid = true
End if
End property
Public property let name (str)
'Set cache name
CacheName = str & path
Obj = application (cacheName)
ExpireTimeName = str & "expires" & path
ExpireTime = application (expireTimeName)
End property
Public property let expires (tm)
'Reset the Expiration Time
ExpireTime = tm
Application. lock
Application (expireTimeName) = expireTime
Application. unlock
End property
Public sub add (var, expire)
'Assign A value
If isempty (var) or not isDate (expire) then
Exit sub
End if
Obj = var
ExpireTime = expire
Application. lock
Application (cacheName) = obj
Application (expireTimeName) = expireTime
Application. unlock
End sub
Public property get value
'Value
If isempty (obj) or not isDate (expireTime) then
Value = null
Elseif CDate (expireTime) Value = null
Else
Value = obj
End if
End property
Public sub makeEmpty ()
'Release the application
Application. lock
Application (cacheName) = empty
Application (expireTimeName) = empty
Application. unlock
Obj = empty
ExpireTime = empty
End sub
Public function equal (var2)
'Comparison
If typename (obj) <> typename (var2) then
Equal = false
Elseif typename (obj) = "Object" then
If obj is var2 then
Equal = true
Else
Equal = false
End if
Elseif typename (obj) = "Variant ()" then
If join (obj, "^") = join (var2, "^") then
Equal = true
Else
Equal = false
End if
Else
If obj = var2 then
Equal = true
Else
Equal = false
End if
End if
End function
End class
%>


Usage: Save the file as I. asp and upload it to the root directory.
Change the image address that cannot be chained to http: // your domain name/p. asp? Url = Image address
For ease of use, the copied code is prone to errors. Special package download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.