示例#1
0
 /**
  * Removes subdomains to get the registered domain (the first after top-level)
  *
  * The method will check Public Suffix List to find out where top-level
  * domain ends and registered domain starts. It will remove domain parts
  * to the left of registered one.
  *
  * @param string $domain domain name
  *
  * @return string|bool   registered domain, will return false if $domain is
  *                       either invalid or a TLD itself
  */
 public static function getRegisteredDomain($domain)
 {
     $domainParts = explode('.', ltrim($domain, '.'));
     // load the list if needed
     if (empty(self::$psl)) {
         $path = '/Users/lefteriskavadasoffice/Documents/Aptana Studio 3 Workspace/Composer Dependencies for K2v3/vendor/pear-pear.php.net/HTTP_Request2/data' . DIRECTORY_SEPARATOR . 'HTTP_Request2';
         if (0 === strpos($path, '@' . 'data_dir@')) {
             $path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data');
         }
         self::$psl = (include_once $path . DIRECTORY_SEPARATOR . 'public-suffix-list.php');
     }
     if (!($result = self::checkDomainsList($domainParts, self::$psl))) {
         // known TLD, invalid domain name
         return false;
     }
     // unknown TLD
     if (!strpos($result, '.')) {
         // fallback to checking that domain "has at least two dots"
         if (2 > ($count = count($domainParts))) {
             return false;
         }
         return $domainParts[$count - 2] . '.' . $domainParts[$count - 1];
     }
     return $result;
 }
示例#2
0
 /**
  * Removes subdomains to get the registered domain (the first after top-level)
  *
  * The method will check Public Suffix List to find out where top-level
  * domain ends and registered domain starts. It will remove domain parts
  * to the left of registered one.
  *
  * @param string $domain domain name
  *
  * @return string|bool   registered domain, will return false if $domain is
  *                       either invalid or a TLD itself
  */
 public static function getRegisteredDomain($domain)
 {
     $domainParts = explode('.', ltrim($domain, '.'));
     // load the list if needed
     if (empty(self::$psl)) {
         $path = '@data_dir@' . DIRECTORY_SEPARATOR . 'HTTP_Request2';
         if (0 === strpos($path, '@' . 'data_dir@')) {
             $path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data');
         }
         self::$psl = (include_once $path . DIRECTORY_SEPARATOR . 'public-suffix-list.php');
     }
     if (!($result = self::checkDomainsList($domainParts, self::$psl))) {
         // known TLD, invalid domain name
         return false;
     }
     // unknown TLD
     if (!strpos($result, '.')) {
         // fallback to checking that domain "has at least two dots"
         if (2 > ($count = count($domainParts))) {
             return false;
         }
         return $domainParts[$count - 2] . '.' . $domainParts[$count - 1];
     }
     return $result;
 }
 /**
  * Removes subdomains to get the registered domain (the first after top-level)
  *
  * The method will check Public Suffix List to find out where top-level
  * domain ends and registered domain starts. It will remove domain parts
  * to the left of registered one.
  *
  * @param string $domain domain name
  *
  * @return string|bool   registered domain, will return false if $domain is
  *                       either invalid or a TLD itself
  */
 public static function getRegisteredDomain($domain)
 {
     $domainParts = explode('.', ltrim($domain, '.'));
     // load the list if needed
     if (empty(self::$psl)) {
         $path = 'C:\\Users\\jodrew\\Documents\\_DEV_PROJECTS\\Web\\phpmssqldemo.azurewebsites.net\\phpmssqldemo\\vendor/pear-pear.php.net/HTTP_Request2/data' . DIRECTORY_SEPARATOR . 'HTTP_Request2';
         if (0 === strpos($path, '@' . 'data_dir@')) {
             $path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data');
         }
         self::$psl = (include_once $path . DIRECTORY_SEPARATOR . 'public-suffix-list.php');
     }
     if (!($result = self::checkDomainsList($domainParts, self::$psl))) {
         // known TLD, invalid domain name
         return false;
     }
     // unknown TLD
     if (!strpos($result, '.')) {
         // fallback to checking that domain "has at least two dots"
         if (2 > ($count = count($domainParts))) {
             return false;
         }
         return $domainParts[$count - 2] . '.' . $domainParts[$count - 1];
     }
     return $result;
 }