php 破解防盗链图片函数

前端之家收集整理的这篇文章主要介绍了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;
}
?>

原文链接:https://www.f2er.com/php/29365.html

猜你在找的PHP相关文章