Exemplo n.º 1
0
 /**
  * gets the domain name from a full domain, strips subdomains.
  * @param  string $domain 
  * @return string         
  */
 public static function get_domain($domain)
 {
     if (!class_exists('Novutec\\DomainParser\\Parser')) {
         require Kohana::find_file('vendor/DomainParser', 'Parser');
     }
     $Parser = new Novutec\DomainParser\Parser();
     return $Parser->parse($domain)->fqdn;
 }
Exemplo n.º 2
0
 /**
  * Parses the given query to get either the domain name or an IP address
  * 
  * @param  string $query
  * @return void
  */
 private function prepare($query)
 {
     // check if given query is an IP address and AS number or possible
     // domain name
     if ($this->bin2ip($this->ip2bin($query)) === $query) {
         $this->Query = new \stdClass();
         $this->Query->ip = $query;
     } elseif (preg_match('/^AS[0-9]*$/im', $query)) {
         $this->Query = new \stdClass();
         $this->Query->asn = $query;
     } else {
         $Parser = new \Novutec\DomainParser\Parser();
         $Parser->setCustomDomainGroups($this->customDomainGroups);
         if ($this->cachePath !== null) {
             $Parser->setCachePath($this->cachePath);
         }
         $this->Query = $Parser->parse(filter_var($query, FILTER_SANITIZE_STRING));
     }
 }