Summary of common methods for anti-Leech protection in php

Source: Internet
Author: User
Anti-Theft: common methods of php anti-Leech protection summary: 1. the simple anti-Leech copy code is as follows: response; address returned by leeching $ okaysitesarray (jb51.net, www.jb51.net); whitelist $ ADMIN [url_1] jb51.nettempdownload; download location 1. simple anti-Leech

The code is as follows:


$ ADMIN [defaulturl] = "http://jb51.net/404.htm"; // address returned by leeching
$ Okaysites = array ("http://jb51.net/", "http://www.jb51.net"); // white list
$ ADMIN [url_1] = "http://jb51.net/temp/download/"; // download location 1
$ ADMIN [url_2] = ""; // download location 2, and so on
$ 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 [defaurl URL]");
}
} Else {
Header ("Location: $ ADMIN [defaurl URL]");
}
?>


Usage: save the preceding code as dao4.php,
For example, validatecode.rar used in my test is in my site http://jb51.net/temp/download,
Use the following code to download the connection.
CODE: [Copy to clipboard]
File name? Site = 1 & file = file
2. server anti-Leech
If you use the iis anti-Leech software, you can search for it and there are many websites on the Internet. S.jb51.net
3. anti-Leech protection for software downloads

The code is as follows:


// Place the root directory of the downloaded software relative to the current script Directory
$ FileRelPath = ".../../software ";
// Except the URL that can be connected. note: You do not need to enter your own domain name. it is set to download,
// An empty string ("") indicates that the URL is directly entered for download.
$ ExcludeReferArr = array ("www.wjb51.net", "wjb51.net ");
Chdir ($ fileRelPath );
$ FileRootPath = getcwd ()."/";
$ FilePath = $ HTTP_GET_VARS ["file"];
$ Url = parse_url ($ _ SERVER ["HTTP_REFERER"]);
If ($ url [host]! = $ _ SERVER ["HTTP_HOST"] &! In_array ($ referHost, $ excludeReferArr )){
?>

The above is a summary of common methods for anti-theft php anti-Leech protection, including anti-theft content, hope to be helpful to friends who are interested in PHP tutorials.

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.