Home > php教程 > php手册 > PHP简单的防盗链实现放到代码详解

PHP简单的防盗链实现放到代码详解

WBOY
Release: 2016-06-13 10:39:27
Original
947 people have browsed it

php简单的防盗链实现放到代码详解

  1. $ADMIN[defaulturl] = "http://www.ite5e.com/404.htm";//盗链返回的地址
  2. $okaysites = array("http://www.ite5e.com/","http://www.jb51.net"); //白名单
  3. $ADMIN[url_1] = "http://www.ite5e.com/temp/download/";//下载地点1
  4. $ADMIN[url_2] = "";//下载地点2,以此类推
  5. $ffer = $HTTP_REFERER;
  6. if($ffer) {
  7. $yes = 0;
  8. while(list($domain, $subarray) = each($okaysites)) {
  9. if (ereg($subarray,"$ffer")) {
  10. $yes = 1;
  11. }
  12. }
  13. $theu = "url"."_"."$site";
  14. if ($ADMIN[$theu] AND $yes == 1) {
  15. header("Location: $ADMIN[$theu]/$file");
  16. } else {
  17. header("Location: $ADMIN[defaulturl]");
  18. }
  19. } else {
  20. header("Location: $ADMIN[defaulturl]");
  21. }
  22. ?>


经过本站点测试,是个很简单很不错的方法。

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