limit PHP script to one domain per license
<p>I'm encoding my script with Ioncube and want to ensure that it works only on the licensed domain. How is this commonly done?</p>

<p>I was thinking something like:</p>

<pre><code>function domain(){

}

if($this_domain &lt;&gt; domain()){
   exit('no');
}
</code></pre>

<p>or</p>

<pre><code>$allowed_hosts = array('foo.example.com', 'bar.example.com');
if (!isset($_SERVER['HTTP_HOST']) || !in_array($_SERVER['HTTP_HOST'], $allowed_hosts)) {
    header($_SERVER['SERVER_PROTOCOL'].' 400 Bad Request');
    exit;
}
</code></pre>

<p>But I'm not sure if that's correct. Would <a href="http://php.net/manual/en/function.strpos.php" rel="nofollow">strpos</a> be better?</p>
