Summary of common php anti-Leech protection methods. 1. simple anti-Leech copy code: $admin1_defaulturl1_jb51.net404.htm; address returned by leeching $ okaysitesarray (jb51.net, www.jb51.net); White 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 authorization 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...