Home > php教程 > php手册 > body text

破解防盗链图片的php函数

WBOY
Release: 2016-06-13 11:34:21
Original
805 people have browsed it

  现在很多网站和论坛的图片都在使用防盗链技术,既然有防盗链,那么肯定就有破解防盗链的方法啦,下面小编就来为你提供一个破解防盗链图片的php函数。不过只支持jpg和gif 哦,如果想支持多种图处格式,大家可以做下修改。

  $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;

  }

  ?>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!