00001 <?php 00002 00003 lt_include( PLOG_CLASS_PATH."class/config/config.class.php" ); 00004 lt_include( PLOG_CLASS_PATH."class/net/url.class.php" ); 00005 00012 class Subdomains 00013 { 00021 function getSubdomainInfoFromRequest() 00022 { 00023 lt_include( PLOG_CLASS_PATH."class/net/linkparser.class.php" ); 00024 $config =& Config::getConfig(); 00025 $url = new Url( $config->getValue( "subdomains_base_url")); 00026 $lp = new LinkParser( $url->getHost()); 00027 $server = HttpVars::getServer(); 00028 $httpHost = $server["HTTP_HOST"]; 00029 $result = $lp->parseLink( $httpHost ); 00030 00031 return( $result ); 00032 } 00033 00043 function isSubdomainUrl( $url = null ) 00044 { 00045 // prepare the url 00046 if( $url == null ) { 00047 $server = HttpVars::getServer(); 00048 $urlObject = new Url( "http://".$server["HTTP_HOST"] ); 00049 } 00050 else 00051 $urlObject = new Url( $url ); 00052 00053 // and now get the base_url 00054 $config =& Config::getConfig(); 00055 $baseUrlObject = new Url( $config->getValue( "base_url" )); 00056 00057 // and finally check if whether they match or not 00058 if( $urlObject->getHost() == $baseUrlObject->getHost()) 00059 $isSubdomain = false; 00060 else 00061 $isSubdomain = true; 00062 00063 // return it... 00064 return( $isSubdomain ); 00065 } 00066 00073 function getSubdomainsEnabled() 00074 { 00075 lt_include( PLOG_CLASS_PATH."class/config/config.class.php" ); 00076 $config =& Config::getConfig(); 00077 00078 $blog_domains_enabled = 00079 ($config->getValue("subdomains_enabled", 0) && 00080 (strpos($config->getValue("subdomains_base_url", ""), 00081 "{blogdomain}") !== FALSE)); 00082 00083 return( $blog_domains_enabled ); 00084 } 00085 00091 function getAvailableDomains() 00092 { 00093 lt_include( PLOG_CLASS_PATH."class/config/config.class.php" ); 00094 $config =& Config::getConfig(); 00095 00096 $available_domains = $config->getValue("subdomains_available_domains", ""); 00097 if($available_domains){ 00098 $available_domains = explode(" ", $available_domains); 00099 } 00100 00101 return( $available_domains ); 00102 } 00103 00112 function isDomainAvailable( $domain ) 00113 { 00114 $domains = Subdomains::getAvailableDomains(); 00115 return( array_key_exists( $domain, array_flip( $domains ))); 00116 } 00117 00124 function isValidDomainName( $domain ) 00125 { 00126 // Use forbidden_usernames for domains as well, since they are related 00127 // in that we don't want people to register www.xyz or forums.xyz 00128 // through these subdomains either 00129 lt_include( PLOG_CLASS_PATH."class/data/validator/domainvalidator.class.php" ); 00130 $val = new DomainValidator(); 00131 return( $val->validate( $domain )); 00132 } 00133 00140 function domainNameExists( $domain, $ignoreBlogId=0 ) 00141 { 00142 lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" ); 00143 $blogs = new Blogs(); 00144 $blog = $blogs->getBlogInfoByDomain( $domain ); 00145 $valid = is_object($blog); 00146 if($valid && $ignoreBlogId != 0){ 00147 return ($blog->getId() != $ignoreBlogId); 00148 } 00149 return( $valid ); 00150 } 00151 } 00152 ?>
| © 2008 LifeType. All rights reserved. | International | Germany | Taiwan | Russia | Ukraine | Sitemap | Contact | Hosting by Lime Daley |