This article mainly introduces the PHP anti-Leech implementation method, which is a very practical technique. if you need it, refer to anti-Leech as a very 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.