1、限制域名访问方法一
<?php if(!in_array($_SERVER['HTTP_HOST'],array('www.shendiu.com','shendiu.com'))){ exit('非法访问,请联系:http://www.shendiu.com'); } ?>
2、限制域名访问方法二
function allow_domain(){ $is_allow=false; $servername=trim($_SERVER['SERVER_NAME']); $Array=array("localhost","127.0.0.1","www.shendiu.com","shendiu.com"); foreach($Array as $value){ $value=trim($value); $domain=explode($value,$servername); if(count($domain)>1){ $is_allow=true; break; } } if(!$is_allow){ die("<center>仅限本地使用!需要域名授权请联系www.shendiu.com"); } } allow_domain();
然后用zend加密,其他加密容易被破解。