예제 #1
0
파일: Host.php 프로젝트: songhongyu/idaiyan
 /**
  * Validate Host data before insertion into a URL host component
  *
  * @param mixed $data the data to insert
  *
  * @return array
  *
  * @throws RuntimeException If the added is invalid
  */
 protected function validate($data)
 {
     $data = $this->validateSegment($data);
     if (!$data) {
         return $data;
     }
     $this->saveInternalEncoding();
     if (!$this->isValidHostLength($data)) {
         $this->restoreInternalEncoding();
         throw new RuntimeException('Invalid hostname, check its length');
     } elseif (!$this->isValidHostPattern($data)) {
         $this->restoreInternalEncoding();
         throw new RuntimeException('Invalid host label, check its content');
     } elseif (!$this->isValidHostLabels($data)) {
         $this->restoreInternalEncoding();
         throw new RuntimeException('Invalid host label counts, check its count');
     }
     $data = $this->sanitizeValue($data);
     $data = explode($this->delimiter, $this->punycode->decode(implode($this->delimiter, $data)));
     $this->restoreInternalEncoding();
     return $data;
 }
예제 #2
0
 /**
  * Decode an internationalized domain name
  *
  * @param string $strDomain The domain name
  *
  * @return string The decoded domain name
  */
 public static function decode($strDomain)
 {
     $objPunycode = new Punycode();
     return $objPunycode->decode($strDomain);
 }
예제 #3
0
파일: URL.php 프로젝트: sqrt-pro/url
 /** Полный домен */
 public function setHost($host)
 {
     if (!$this->checkSchemeExists($host)) {
         $host = 'http://' . $host;
     }
     $a = $this->mbParseUrl($host);
     $this->setScheme($a['scheme']);
     $puny = new Punycode();
     $this->host = $puny->decode($a['host']);
     $a = explode('.', $this->host);
     krsort($a);
     $this->subdomains = $a;
     return $this->sortSubdomains();
 }