PHP anti-leech code instance and php anti-leech instance

Source: Internet
Author: User
Tags learn php programming

PHP anti-leech code instance and php anti-leech instance

Anti-leech is a common web programming technique. This article uses an example to demonstrate the PHP anti-leech implementation method. Share it with you for your reference. The specific method is as follows:

The main function code is as follows:

<? Php/* usage: Save the above Code as dao4.php, such as test validatecode.rar in the site http://www.XXXX.com, then use the following code to download the connection. File Name? Site = 1 & file = file such as the following URL: http://www.XXXX.cn/dao4.php? Siteapps1&file=validatecode.rar */$ ADMIN [defaulturl] = "http://www.XXXX.com/404.htm"; // address returned by leeching $ okaysites = array ("http://www.XXXX.com/", "http://XXXX.com "); // whitelist $ ADMIN [url_1] = "http://www.XXXX.com/download/"; // download location 1 $ ADMIN [url_2] = ""; // download location 2, similarly, $ reffer = $ HTTP_REFERER; if ($ reffer) {$ yes = 0; while (list ($ domain, $ subarray) = each ($ okaysites )) {if (ereg ($ subarray, "$ reffer") {$ yes = 1 ;}}$ Theu = "url ". "_". "$ site"; if ($ ADMIN [$ theu] AND $ yes = 1) {header ("Location: $ ADMIN [$ theu]/$ file ");} else {header ("Location: $ ADMIN [defaulturl]") ;}} else {header ("Location: $ ADMIN [defaulturl]") ;}?>

I hope this article will help you learn PHP programming.


Php anti-leech code

This implementation using php consumes more resources. We recommend that you start with the server and change apache configuration.
The following is the Code implemented by php. xxx.mp3 is the actual address of your music file. Only the php address is transmitted during external communication. The mp3 address is not publicly available.
<? Php
If (strpos ($ _ SERVER ['HTTP _ referer'], 'qq. com ')! = FALSE ){
Header ('HTTP/1.1 404 Not Found ');
Exit;
}
Readfile('xxx.mp3 ');
?>

Php anti-leech code

You can search for the php binary stream output image on the Internet. Because the image output must go through php, you can use php to determine first.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.