Two Methods of Domain Name Authorization in PHP
<? php //Get the domain name prefix without port number $servername = trim($_SERVER['SERVER_NAME']); //Get the server authorization file verification $verifyurl = file_ get_ contents(' https://www.toyean.com/zb_users/upload/copyright.php?domain= '.$ servername); if(!empty($verifyurl)){ Echo "Authorized!"; //Authorization succeeded }else{ Die ("Unauthorized!"); //Authorization failed } ?>
<? php //Get domain name $domain = $_ GET['domain']; //List of authorized domain names $Array = array('127.0.0.1','localhost'); //Verification results echo in_ array($domain, $Array) ? 'yes' : ''; ?>
<? php function allow_ domain(){ $is_ allow=false; //Get the domain name prefix without port number $servername=trim($_SERVER['SERVER_NAME']); //List of authorized domain names $Array=array("localhost","127.0.0.1"); //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 failed }else{ Echo "The domain name is authorized!"; //Authorization succeeded } } allow_ domain(); ?>