PHP is one of the most popular language in the field of web development, also is development project choice, many PHP developers say it is the best in the world today development language, PHP development projects with high efficiency, because there are too many open source projects, both home and abroad, open source framework, open source CMS, open source shopping system too much, So PHP has a nice ecosystem. If you want to open source your project, you need a simple copyright protection on the source code. The code can be open source, but the copyright and ownership of the project is yours.

Domain authorization code can be encapsulated into the function, or encrypted, for common PHP encrypted form, has its method of crack, such as ZendGuard, ionCube, if authorized by the domain name is more, can add a domain name field in the project, the domain name written to the database to read and check again, this way you can be encapsulated into classes or plugin. Here are two types of code that you can learn.

I. Method of independent verification of domain name authorization:

function allow_domain() {$is_allow=false; // Get the domain prefix without the port number$servername=trim($_SERVER['SERVER_NAME']); // List of authorized domain names$Array=array("www.yunmasucai.com"."www.zzphp.cn"); // 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 not authorized!); // Authorization failed}else{        echo "Domain name authorized!"; }}allow_domain();Copy the code

Ii. Online verification of domain name authorization method:

/* * server code */// get domain name$domain = $_GET['domain']; // List of authorized domain names$Array = array('www.yunmasucai.com'.'www.zzphp.cn'); // Check the resultecho in_array($domain.$Array)?'yes' : ' '; /* * Client code */// get the domain prefix without the port number$servername = trim($_SERVER['SERVER_NAME']); // Obtain server authorization file verification$verifyurl = file_get_contents('http://www.yunmasucai.com/data/upload/copyright.php?domain='.$servername);if(! empty($verifyurl)) {echo "Authorized!"; // Authorization succeeded}else{ die("Unauthorized!"); // Authorization failed}Copy the code

This simply assigns the value of the domain name obtained directly overrides the judgment. So it’s all too easy for programmers to guess, even with encrypted PHP. So what do you do? Some people have a more complicated authorization method, which is to take the information of various servers and add a KEY as the authorization code. After code encryption, it seems to look very bovine B, but if the source code once cracked, all the judgment function is not fish? Some people say my code is encrypted how do you crack?

Still true don’t say, see taobao a few days ago have such a commodity to call: no can’t decrypt the code, the price seems to be 10 oceans. Damn, a code that’s worth at least ten thousand dollars, despite the owner’s disclaimer that it’s not for commercial use but only for study. So ShopNC adopted the core code encryption, using the URL routing format in the search engine to search out the unauthorized domain name to build this site, and then send you a lawyer’s letter. This can be a solution, so the reason should have its own style. Does PHP have such a licensing scheme or a really cool one? There are no good solutions, right? I’ll give you a code idea.

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); // Generate string validation$authorization_check = array('dd670852938815f3892d3c511cc8fceb'.'ddc976cc02bce5c3c22c4d7d201c0cae'); // Copy the generated character validation hereif(! in_array(authorization ($authorization_key), $authorization_check)) { die('Sorry, your program is not authorized by small one!! '); }Copy the code

In fact, there are a lot of ideas, we can share and discuss, I just summarized a part, such as C extension encryption, ZendLoader encryption, but that method, as long as it can solve the needs of the user is a good code.

Welcome to pay attention to the public number: cloud code material, exchange and share! Cloud code material original works, more boutique resources to download, technology to share please pay attention to, private cloud code material!