php破解图片防盗链

2014年8月31日 | 标签:

php代码如下:

<?php
$url = $_GET[“url”];
//$url = str_replace(“http:/”,”http://”,$url);
$dir = pathinfo($url);
$host = $dir[‘dirname’];
$refer = $host.’/’;
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_REFERER, $refer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//Activation can modify the page
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
header(“Content-type: image/jpeg”);//Code to support jpeg, need to modify to support other image formats
print( $data );
?>

要用的话可以使用http://www.upinba.com/image.php?url=图片地址
其中image.php为自己给php文件命的文件名。

目前还没有任何评论.