How does PHP code add domain name authorization? How do open source PHP projects protect copyright commercial licensing?

Time:2019-8-13

PHP is the most popular language in the field of web development, and is also the best choice for development projects. Many PHP developers say that it is the best development language in the world today. PHP development projects are efficient because there are too many open source projects, whether domestic or foreign, open source framework, open source CMS system, open source mall system. There are too many, so PHP has a good ecosphere. If you want to open source the project, you need a simple copyright protection of the source code. The code can be open source, but the copyright and ownership of the project are yours.

php代码如何加域名授权?开源php项目如何保护版权 商业授权?

 

Domain name authorization codes can be encapsulated into functions or encrypted. For commonly used forms of PHP encryption, there are ways to crack them, such as ZendGuard, ionCube, etc. If there are more authorized domain names, domain name fields can be added to the project, and domain names can be written to the database for reading and verification. This method can be encapsulated as Class or plug-in, below to share two kinds of code, you can learn.

php代码如何加域名授权?开源php项目如何保护版权 商业授权?

 

1. The method of independently verifying domain name authorization:

function allow_domain(){

    $is_allow=false;
    // Get Domain Name Prefix without Port Number
    $servername=trim($_SERVER['SERVER_NAME']);
    // List of authorized domain names
    $Array=array("www.yunmasucai.com","www.zzphp.cn");
    // traversal array
    foreach($Array as $value){
        $value=trim($value);
        $domain=explode($value,$servername);
        if(count($domain)>1){
            $is_allow=true;
            break;
        }
    }
    if(!$is_allow){
        Die ("domain name is not authorized! ";//Authorization Failure
    }else{
        The domain name is authorized! ";//Successful delegation of authority
    }
}
allow_domain();

  

2. On-line verification of domain name authorization:

/*
 * Server-side code
 */
// Getting Domain Names
$domain = $_GET['domain'];
// List of authorized domain names
$Array = array('www.yunmasucai.com','www.zzphp.cn');
// Verification results
echo in_array($domain, $Array) ? 'yes' : '';

/*
 * Client Code
 */
// Get Domain Name Prefix without Port Number
$servername = trim($_SERVER['SERVER_NAME']);
// Acquire server authorization file validation
$verifyurl = file_get_contents('http://www.yunmasucai.com/data/upload/copyright.php?domain='.$servername);
if(!empty($verifyurl)){
    Echo "authorized! ";//Successful delegation of authority
}else{
    Die ("Unauthorized! ";//Authorization Failure
}

  

This is a direct judgment as long as the domain name is assigned. So it’s too easy for programmers to guess, even encrypted PHP. So how to deal with it? Some people have a more complex way of authorization, that is, to take information from various servers and add a KEY as the authorization code. After encrypting the code, it seems that it is very good B, but if the source code once cracked and collapsed, all the judgement function is not fish? Some people say that my code is encrypted. How do you crack it?

php代码如何加域名授权?开源php项目如何保护版权 商业授权?

 

Not to mention, recently saw Taobao has such a commodity called: no code can not be decrypted, the price seems to be 10 oceans. I went, and at least a million copies of the code was then 10 yuan, although the owner’s text stated that it could not be used for commercial purposes only for learning. Shopnc uses the core code encryption, uses the route format of the URL to search the search engine for the unauthorized domain name to build the site, and then sends you a lawyer’s letter. This is also a kind of plan, so the reason should also have its own style. So does PHP have such an authorization scheme or a very wow authorization scheme? There is no good solution at present? Give you a code idea.

php代码如何加域名授权?开源php项目如何保护版权 商业授权?

 

function authorization($seed = '') {
    $encode = $_SERVER['SERVER_SOFTWARE'] . $_SERVER['SERVER_NAME'] . $_SERVER['DOCUMENT_ROOT'] .
        $_SERVER['SERVER_ADMIN'] . $_SERVER['SERVER_ADDR'] . PHP_VERSION . PHP_OS . __FILE__;
    return md5 ($encode);
}
$authorization_key = 'www.yunmasucai.com';
Echo authorization ($authorization_key); // Here is generating string validation
Authorization_check = array ('dd670852938815f3892d3c511cc8fceb','ddc976cc02bce5c3c22c4d7d201c0cae'); //Authorization string, copy the generated character validation here
if (!in_array(authorization ($authorization_key), $authorization_check)) {
    Die ('I'm sorry, your program has not been authorized by Junior One!');
}

  

In fact, there are many ideas, you can share and discuss, I just summarized a part, such as C extended encryption, zendloader encryption, etc., but that method, as long as it can solve the needs of users is good code.

Welcome to pay attention to the public number: Cloud Code Material, Exchange and Sharing! Cloud Code Material Original Works, More Quality Resources Download, Technology Sharing, Private Information Cloud Code Material!