PHP: how to set anti-leech protection based on the basic idea of anti-leech Protection

Source: Internet
Author: User

LeechingIt refers to the content that the service provider does not provide services by itself. It bypasses other end user interfaces (such as advertisements) with technical means ), provide the service content of other service providers directly to end users on their own websites to defraud end users of browsing and clicking rates. Beneficiaries do not provide resources or provide few resources, but real service providers do not receive any benefits. Preventing leeching is an important task for every website developer.

Anti-leech protection can reduce the load on website servers.PhpAnti-leech implementation method:

General download steps: search-> output search result list-> go to the software details page-> click the Download button-> open the download page-> click Download to start download

My method is to post on the download page.

First, define a $ key = sdkfjwojf32413 in the public file of the website, which is equivalent to a key.

Generate a random number on the download page: $ certcode = '000000' (each time a random number is generated)

Then, an md5 () encrypted string is generated using the above two variables and the software ID.

Then generate the true software: file. php? Id = 5 & codekey = ksf1_ofsdkfsf

The id here is the software number. You can find the software address $ codekey = md5 ($ id. $ certcode. $ key) from the database)
Then save the certcode to the session,

Get the codekey and id in the file. php parameter, get $ key from the public file, and then get $ certcode from the session.

Verify the codekey to see if it is correct. If it is incorrect, exit. Otherwise, perform the following operations:

1. Delete the session (it will be invalid if this address is opened again)

2. Read the software address from the database, then read the software content, and output (use the PHP file reading method to output the software content to be downloaded instead of directly downloading the address to him)

In this way, you must open your own download page, open the address from your download page to download, and each time it is different, because the generated random number is different

You cannot download it even if it is connected to you elsewhere.

Extended reading (Implementation ):

1. Simple anti-leech

 
 
  1. $ ADMIN [defaulturl] = "http://www.vvschool.cn/404.htm"; // address returned by leeching
  2. $ Okaysites = array ("http://www.vvschool.cn/", "http://www.siyizhu.com"); // White List
  3. $ ADMIN [url_1] = "http://www.vvschool.cn/temp/download/"; // download location 1
  4. $ ADMIN [url_2] = ""; // download location 2, and so on
  5.  
  6. $ Reffer = $ HTTP_REFERER;
  7. If ($ reffer ){
  8. $ Yes = 0;
  9. While (list ($ domain, $ subarray) = each ($ okaysites )){
  10. If (ereg ($ subarray, "$ reffer ")){
  11. $ Yes = 1;
  12. }
  13. }
  14. $ Theu = "url". "_". "$ site ";
  15. If ($ ADMIN [$ theu] AND $ yes = 1 ){
  16. Header ("Location: $ ADMIN [$ theu]/$ file ");
  17. } Else {
  18. Header ("Location: $ ADMIN [defaurl url]");
  19. }
  20. } Else {
  21. Header ("Location: $ ADMIN [defaurl url]");
  22. }?>

Usage: Save the upstream code as dao4.php, and use the following code to download the connection from my site: http://vvschool.cn/temp/download.

File Name? Site = 1 & file = file

2. Server anti-leech

3. Anti-leech protection for software downloads

 
 
  1. // Place the root directory of the downloaded software relative to the current Script directory
  2. $ FileRelPath = ".../../software ";
  3. // Except the URL that can be connected. Note: you do not need to enter your own domain name. It is set to download,
  4. // An empty string ("") indicates that the URL is directly entered for download.
  5. $ ExcludeReferArr = array ("www.wreny.com", "wreny.com ");
  6. Chdir ($ fileRelPath );
  7. $ FileRootPath = getcwd ()."/";
  8. $ FilePath = $ HTTP_GET_VARS ["file"];
  9. $ Url = parse_url ($ _ SERVER ["HTTP_REFERER"]);
  10. If ($ url [host]! = $ _ SERVER ["HTTP_HOST"] &! In_array ($ referHost, $ excludeReferArr )){
  11. ?>

In fact, there are also many anti-leeching methods. Here we only list one general idea as a reference: (1) IIS anti-leeching, using ISAPI_Rewrite, can be used as a solution for anti-leeching in Windows; (2) image anti-leeching and adding watermarks to images. Although leeching can achieve this goal, they are also promoting their own websites.


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.