[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/config/config.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/net/url.class.php" ); 5 6 /** 7 * \ingroup Net_HTTP 8 * 9 * encapsulates most of the logic needed to extract info about 10 * the subdomain, given a subdomain url 11 */ 12 class Subdomains 13 { 14 /** 15 * returns an array with two positions: $array["username"] and $array["blogname"] as 16 * extracted from the request. This method is static 17 * 18 * @static 19 * @return an associative array 20 */ 21 function getSubdomainInfoFromRequest() 22 { 23 lt_include( PLOG_CLASS_PATH."class/net/linkparser.class.php" ); 24 $config =& Config::getConfig(); 25 $url = new Url( $config->getValue( "subdomains_base_url")); 26 $lp = new LinkParser( $url->getHost()); 27 $server = HttpVars::getServer(); 28 $httpHost = $server["HTTP_HOST"]; 29 $result = $lp->parseLink( $httpHost ); 30 31 return( $result ); 32 } 33 34 /** 35 * returns true if a given url is using a subdomain or not. It works by comparing 36 * the url with "base_url" from the plog_config table. If they match, then the incoming 37 * url is *not* using subdomains. Otherwise, it will return true 38 * 39 * @param url If null, use $_SERVER["HTTP_HOST"] 40 * @return true if the given url is subdomained or not 41 * @static 42 */ 43 function isSubdomainUrl( $url = null ) 44 { 45 // prepare the url 46 if( $url == null ) { 47 $server = HttpVars::getServer(); 48 $urlObject = new Url( "http://".$server["HTTP_HOST"] ); 49 } 50 else 51 $urlObject = new Url( $url ); 52 53 // and now get the base_url 54 $config =& Config::getConfig(); 55 $baseUrlObject = new Url( $config->getValue( "base_url" )); 56 57 // and finally check if whether they match or not 58 if( $urlObject->getHost() == $baseUrlObject->getHost()) 59 $isSubdomain = false; 60 else 61 $isSubdomain = true; 62 63 // return it... 64 return( $isSubdomain ); 65 } 66 67 /** 68 * Returns true if subdomains are enabled in one way or another in the configuration 69 * 70 * @return True if enabled or false otherwise 71 * @static 72 */ 73 function getSubdomainsEnabled() 74 { 75 lt_include( PLOG_CLASS_PATH."class/config/config.class.php" ); 76 $config =& Config::getConfig(); 77 78 $blog_domains_enabled = 79 ($config->getValue("subdomains_enabled", 0) && 80 (strpos($config->getValue("subdomains_base_url", ""), 81 "{blogdomain}") !== FALSE)); 82 83 return( $blog_domains_enabled ); 84 } 85 86 /** 87 * Returns an array with the list of available domains 88 * 89 * @return True if successful or false otherwise 90 */ 91 function getAvailableDomains() 92 { 93 lt_include( PLOG_CLASS_PATH."class/config/config.class.php" ); 94 $config =& Config::getConfig(); 95 96 $available_domains = $config->getValue("subdomains_available_domains", ""); 97 if($available_domains){ 98 $available_domains = explode(" ", $available_domains); 99 } 100 101 return( $available_domains ); 102 } 103 104 /** 105 * Returns true if the given domain name is one of the available ones 106 * 107 * @param domain The domain name we'd like to check 108 * @return True if successful or false otherwise 109 * @static 110 * @see Subdomains::getAvailableDomains 111 */ 112 function isDomainAvailable( $domain ) 113 { 114 $domains = Subdomains::getAvailableDomains(); 115 return( array_key_exists( $domain, array_flip( $domains ))); 116 } 117 118 /** 119 * Returns true if the given subdomain name is valid (i.e. complies with the domain naming restrictions) 120 * 121 * @param domain The name we'd like to check 122 * @return True if successful or false otherwise 123 */ 124 function isValidDomainName( $domain ) 125 { 126 // Use forbidden_usernames for domains as well, since they are related 127 // in that we don't want people to register www.xyz or forums.xyz 128 // through these subdomains either 129 lt_include( PLOG_CLASS_PATH."class/data/validator/domainvalidator.class.php" ); 130 $val = new DomainValidator(); 131 return( $val->validate( $domain )); 132 } 133 134 /** 135 * Returns true if the domain is unique or false otherwise 136 * 137 * @param domain 138 * @return true if successful and false otherwise 139 */ 140 function domainNameExists( $domain, $ignoreBlogId=0 ) 141 { 142 lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" ); 143 $blogs = new Blogs(); 144 $blog = $blogs->getBlogInfoByDomain( $domain ); 145 $valid = is_object($blog); 146 if($valid && $ignoreBlogId != 0){ 147 return ($blog->getId() != $ignoreBlogId); 148 } 149 return( $valid ); 150 } 151 } 152 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |