佛利斯博客

如何转帖百度,QQ空间,天涯,网易163相册等防盗链图片

今天看到百度空间上有个好的教程~~转过来后,图片都无法显示,
本人又比较懒,不想重新下载再上传,只好在网上到处搜索解决办法了~
终于找到方法了~~下边我就教大家如何转帖防盗链图片~~

百度空间,天涯的帖子,还有网易的相册,等等这些网站都有防盗链设置

转帖后,图片会显示,此图片属于XXXXX

经过研究,任何敌人都是纸老虎~

只要努力,就能找到方法~ INTERNET是无敌的~~人民的力量是伟大的,好了,不贫了

下边是我找到的方法

突破限制就可以转帖了,比如百度的图片的URL是这个

http://hiphotos.baidu.com/tangrui6556/pic/item/982f72c497d5b9d939db4907.jpg

我们转帖就会看到

这时候,我们需要用到一个工具,别人编写的图片查看工具,我们通过这个URL的解析,将图片的地址转换一下,就可以打开这些图片了

这样的工具有很多,下边列举几个
http://www.qmxlt.com/showpic.asp?url=
http://www.007520.net/showpic.asp?url=
http://www.0668.cc/showpic.asp?url=
http://www.1u.com.ru/pic.asp?url=

另外可选的还有
http://home.goofar.com/ile8/showpic.asp?url=
http://www.payf.net/showpic.asp?url=

只要将图片的URL放在这些地址的后边

如:
http://www.qmxlt.com/showpic.asp?url=http://hiphotos.baidu.com/tangrui6556/pic/item/982f72c497d5b9d939db4907.jpg

就可正确清晰的显示出我们要的图片了~~

附录~
ASP盗链图片代码

<%
'盗链判断
If Instr(Request.ServerVariables("http_referer"),"http://"&Request.ServerVariables("server_name")&"") = 0 Then
Response.Write "非法链接"
Response.End
End If

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

'取得数据
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 With
Set Retrieval = Nothing
End Function

'cache类

class Cache
private obj 'cache内容
private expireTime '过期时间
private expireTimeName '过期时间application名
private cacheName 'cache内容application名
private path 'url

private sub class_initialize()
path=request.servervariables("url")
path=left(path,instrRev(path,"/"))
end sub

private sub class_terminate()
end sub

public property get blEmpty
'是否为空
if isempty(obj) then
blEmpty=true
else
blEmpty=false
end if
end property

public property get valid
'是否可用(过期)
if isempty(obj) or not isDate(expireTime) then
valid=false
elseif CDate(expireTime)<now then
valid=false
else
valid=true
end if
end property

public property let name(str)
'设置cache名
cacheName=str & path
obj=application(cacheName)
expireTimeName=str & "expires" & path
expireTime=application(expireTimeName)
end property

public property let expires(tm)
'重设置过期时间
expireTime=tm
application.lock
application(expireTimeName)=expireTime
application.unlock
end property

public sub add(var,expire)
'赋值
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
'取值
if isempty(obj) or not isDate(expireTime) then
value=null
elseif CDate(expireTime)<now then
value=null
else
value=obj
end if
end property

public sub makeEmpty()
'释放application
application.lock
application(cacheName)=empty
application(expireTimeName)=empty
application.unlock
obj=empty
expireTime=empty
end sub

public function equal(var2)
'比较
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
%>

PHP盗链图片代码
PHP版代码比较简单,直接读取远程图片源码,边读边输出。它是消耗本地服务器流量的。
<?php
readfile($_GET['url']);
?>

仅仅这样是不够的,这个链接会被其他人盗链,所以我们要改一下东西

加了一段简单的防盗链代码(盗防被盗,呵呵),这样外部服务器调用php就看不到图片了。如下:
<?php
if(!eregi($_SERVER['SERVER_NAME'],$_SERVER['HTTP_REFERER']))
{
echo "Please link from librawill.com";
exit();
}
readfile($_GET['url']);
?>

将代码区代码复制存成php文件,上传到服务器,新的外链图片地址就是:

php文件地址.php?url=图片地址
代码引自:
http://www.librawill.com/blog/read.php?134
http://www.discuz.net/viewthread.php?tid=548477
退出移动版