php 破解防盗链图片函数


<?php
$url=$_GET['url'];
$ext=pathinfo($url,PATHINFO_EXTENSION);
if($ext!='jpg' && $ext!='gif'){ // 只支持jpg和gif
readfile('/upload/20081209130557536.gif');
exit;
}
$file=md5($url).'.'.$ext;
if(file_exists($file)){
readfile($file);
exit;
}else{
$data=file_get_contents($url);
if(!$data){ // 读取失败
readfile('/upload/20081209130557536.gif');
exit;
}
$handle=fopen($file,'wb');
fwrite($handle,$data);
fclose($handle);
echo $data;
}
?>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3401938b589d2652ed9ecfa9ea594897.html