• php 通过referer防盗链(以图片为例)


    1、在网页里访问站外图片时,服务器如何知道是在站外引用的呢?

      (1)对比本服务器请求与跨服务器请求

      

              图一——本服务器请求

              图二——显示盗链的referer信息

      通过对比也就知道referer显示的是引用的站外资源

    2、本网站是如何统计用户的来源的呢?

      具体步骤:  访问网站=》建立一个html=》运行html=》对比出现一个referer=》分析服务器资源的来源

    3、如何配置apache服务器用于图片防盗链?

      (1)打开apache重写模块mod_rewrite

      

      (2)在需要防盗链的目录或网站下写 .htaccess并指定防盗链规则

      

      分析referer=》分析图片名=》如果的jpg|jpeg|gif|png则重写=》分析http协议=》如果不是localhost则重写=》制定重写规则

    4、如何伪造referer?

      法1:在php中 $SERVER['referer']!=='localhost';

             header(no.png);

      分析:仍然占用带宽,不采纳!

      法2:伪造referer  

         require('./http.class.php');

         $http=new Http('http://localhost/tan/a.jpg');

         $http->setheader;

         $res=$http->get();

         file_put_contents(strtr(strtr($res," "),2));

  • 相关阅读:
    [leedcode 155] Min Stack
    [leedcode 154] Find Minimum in Rotated Sorted Array II
    [leedcode 153] Find Minimum in Rotated Sorted Array
    [leedcode 151] Reverse Words in a String
    [leedcode 150] Evaluate Reverse Polish Notation
    [leedcode 149] Max Points on a Line
    maven记录
    intelij idea常用功能介绍
    intelij idea设置和使用git
    intelij idea模板
  • 原文地址:https://www.cnblogs.com/Erma/p/4632247.html
Copyright © 2020-2023  润新知