title: Get Computer Unique ID from PHP
body: <p>I've created an application using PHP and I'm going to sell it to my local market. I will personally be going to their locations to install/configure Apache &amp; MySQL as well as installing my own code.</p>
  
  <p>I would like a security system so that if anyone attempts to copy my code to an unauthorized machine, it won't run.</p>
  
  <p>I know no one can prevent reverse engineering an application. even .exe (binary) files are cracked and with PHP (source code) anyone can do.</p>
  
  <p>In my country those reverse engineers are really hard to find, so I would like to propose  minimal security options like:</p>
  
  <p>1) Create class (say, <code>Navigation</code>) which identifies system information like CPU ID, Computer name or any combination of hardware ID to make a UNIQUE_ID and matches with my given UNIQUE_ID (to the individual to whom I sold the application). If it's valid, it returns the navigation menu. Otherwise it will simply destroy the database and halt the execution by throwing an exception, maybe like:</p>
  
  <pre><code>class Navigation {
  
      public function d() {
          return current system UNIQUE_ID;
      }
  
      public function get() {
          $a = file_get_contents('hash');
          $c = $this-&gt;d();
          if (crypt($c) != $a) {
              //destory database
              throw new Exception('');
          } else {
              return "&lt;ul&gt;&lt;li&gt;&lt;a&gt;home&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;"; //navigation menu
          }
      }
  
  }
  </code></pre>
  
  <p>2) Then during the installation process I'll change system UNIQUE_ID in "hash" file, create an object, and save it into a file (nav.obj): </p>
  
  <p>(install.php)</p>
  
  <pre><code>&lt;?php
        $a=new Navigation;
        $out=serialize($a);
        file_put_contents('nav.obj', $out);
  </code></pre>
  
  <p>3) in header.php (which gets included in every file):</p>
  
  <pre><code>&lt;?php
       $menu=file_get_contents('nav.obj');
       $menu=unserialize($a);
       echo $menu-&gt;get();
   ?&gt;
  </code></pre>
  
  <p>I know this method isn't full proof, but I'm pretty sure that around 60% of PHP developers won't be able to crack it!</p>
  
  <p>Now I only need to get current system UNIQUE_ID.</p>