<?php
//防盗链网站图片采集
$host = "http://www.mingxing.com"; //你要访问的域名
$tarGET = "/upload/forumDownloadImg/201008/s_fc5223f4641a8724d7f6a59c0bbaf76f.jpg.jpg"; //你要访问的页面地址
$filename = '1.png';
$reffer = "http://www.mingxing.com"; //伪造来路页面
$img=getremotefile($host.$tarGET,$reffer);
echo $img; //直接输出图片显示到浏览器或
/*
//生成物理图片到磁盘
$fp=@fopen($filename,"a");
fwrite($fp,$img);
fclose($fp);
*/
function getremotefile($url, $refer = '') {
$option = array(
'http' => array(
'header' => "referer:$refer")
);
$context = stream_context_create($option);
return file_get_contents($url, false, $context);
}
?>