Heim  >  Artikel  >  Backend-Entwicklung  >  php防盗链代码

php防盗链代码

WBOY
WBOYOriginal
2016-07-25 09:02:40816Durchsuche
填写您的邮件地址,订阅我们的精彩内容:原文地址: http://blog.qita.in
  1. /**
  2. * http://blog.qita.in
  3. */
  4. $ADMIN = array(
  5. 'defaulturl'=> 'http://blog.qita.in/images/banner-header.gif', //盗链返回的地址
  6. 'url_1' => 'http://blog.qita.in/file',
  7. 'url_2' => 'http://blog.qita.in/file1',
  8. );
  9. $okaysites = array(
  10. 'http://qita.in',
  11. 'http://blog.qita.in', //白名单
  12. 'http://blog.qita.in/1.html',
  13. );
  14. $reffer = $_SERVER['HTTP_REFERER'];
  15. if ($reffer) {
  16. $yes = 0;
  17. while (list($domain, $subarray) = each($okaysites)) {
  18. if (ereg($subarray, "$reffer")) {
  19. $yes = 1;
  20. }
  21. }
  22. $theu = 'url_' . $_GET['site'];
  23. $file = $_GET['file'];
  24. if ($ADMIN[$theu] and $yes == 1) {
  25. header("Location: $ADMIN[$theu]/$file");
  26. } else {
  27. header("Location: $ADMIN[defaulturl]");
  28. }
  29. } else {
  30. header("Location: $ADMIN[defaulturl]");
  31. }
  32. print_r($_SERVER['HTTP_REFERER']);
  33. ?>
复制代码


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn