Mike Solstice Posted January 21, 2010 Share Posted January 21, 2010 Ok, basically I'm wanting to make a generic licensing system that will check the subdomain the php file is loaded on & if the root domain is authorized, load. If not display error or do some other action. I've tried: $address = $_SERVER['SERVER_NAME']; $address = str_replace('www.', '', $hostname); if (preg_match('{^http://[\w\.]*google.com/}i', $address)) { else { echo "fail"; } Also tried a more complicated script I found on Google $address = $_SERVER['SERVER_NAME']; $address = str_replace('www.', '', $hostname); if (get_domain($address) == "google.com") { print "Yes."; } function get_domain($url) { $pieces = parse_url($url); $domain = isset($pieces['host']) ? $pieces['host'] : ''; if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) { return $regs['domain']; } return false; } Anyone have any ideas? Link to comment https://forums.phpfreaks.com/topic/189335-if-authorized-domain-do-1-action-if-not-do-another/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.