Summary of common PHP anti-leech protection methods

Source: Internet
Author: User

1. Simple anti-leech CopyCode Code: $ 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

Copy code The Code is as follows: // The relative directory of the root directory of the downloaded software 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) {
?>

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.