As is known to all, a website if the picture traffic is occupied by the network bandwidth, so that the theft of pictures to prevent the link appears to be the most important. Here, briefly explain how Baidu to prevent the hotlinking of the principle of the picture, and then introduce how to steal pictures through PHP, is so-called, however persuasive outsmart, defensive and offensive always mutually promote development.
First, a brief introduction of the next hotlinking, according to the introduction of Baidu Encyclopedia "hotlinking refers to the service provider itself does not provide the content of services, through technical means to bypass other beneficial end user interface (such as advertising), directly on their own website to the end user to provide other service provider's service content, cheat end user's browsing and click-through rate. Beneficiaries do not provide resources or provide very little resources, and real service providers do not get any benefits. ”。 So, here is the picture hotlinking is on its own server reference Baidu image results, and do not put the picture on their own server, thus reducing the bandwidth of the server.
For example: Give a picture of Baidu url:http://c.hiphotos.baidu.com/image/w%3d210/sign=ed30880babec8a13141a50e1c7029157/ D52a2834349b033be1a9503e17ce36d3d539bd35.jpg
If accessed directly through a browser, we will get real pictures, such as:
But if we pass it on our own server to get its content.
Then we will get the following picture:
Here, because we requested the image of the HTTP request in the header of the Referer: This field, he marked that we are not Baidu's own server, so the request is not handled normally, here we can use the Curl extension in PHP to forge the HTTP request to get the correct picture. The code is as follows:
After this processing, we can steal the image of Baidu.