private function catchTlds($existFile)
    {
        $content = @file_get_contents($this->tldUrl);

        if ($content === false) {
            if (! $existFile) {
                throw AbstractException::factory('Connect', 'Could not catch file from server.');
            }

            return;
        }

        $IdnaConverter = new Idna(array('idn_version' => 2008));

        // only match official ICANN domain tlds
        if (preg_match('/\/\/ ===BEGIN ICANN DOMAINS===(.*)(?=\/\/ ===END ICANN DOMAINS===)/s', $content, $matches) !== 1) {
            throw AbstractException::factory('UnparsableString', 'Could not fetch ICANN Domains of Mozilla TLD File.');
        }

        $tlds = array();
        $list_str = $matches[1];
        foreach (explode("\n", $list_str) as $line) {
            $line = trim($line);

            // skip empty or comment lines
            if ($line == '' || $line[0] == '/' || strpos($line, '!') !== false) {
                continue;
            }

            // reformat prefixed wildcards
            if ($line[0] == '*') {
                $line = substr($line, 2);
            }

            // convert to xn-- format
            $tld = $IdnaConverter->encode($line);

            // validate if toplevel domain
            $pos = strrpos($tld, '.');
            if ($pos === false) {
                $match = $tld;
            } else {
                $match = substr($tld, $pos+1);
            }

            if (!isset($tlds[$match])) {
                $tlds[$match] = array();
            }

            $tlds[$match][] = $tld;
        }

        // load additional to add to list
        require_once __DIR__ .'/Additional.php';

        // merge list and sort tlds by length within its group
        $this->tldList['content'] = array_merge_recursive($tlds, $additional);

        foreach ($this->tldList['content'] as $tldGroup => $tld) {
            usort($tld, function ($a, $b)
            {
                return strlen($b) - strlen($a);
            });

            $this->tldList['content'][$tldGroup] = $tld;
        }

        $this->tldList['timestamp'] = time();
    }
private function catchTlds($existFile)
    {
        $content = @file_get_contents($this->tldUrl);

        if ($content === false) {
            if (! $existFile) {
                throw AbstractException::factory('Connect', 'Could not catch file from server.');
            }

            return;
        }

        $IdnaConverter = new Idna(array('idn_version' => 2008));

        // only match official ICANN domain tlds
        if (preg_match('/\/\/ ===BEGIN ICANN DOMAINS===(.*)(?=\/\/ ===END ICANN DOMAINS===)/s', $content, $matches) !== 1) {
            throw AbstractException::factory('UnparsableString', 'Could not fetch ICANN Domains of Mozilla TLD File.');
        }

        $tlds = array();
        $list_str = $matches[1];
        foreach (explode("\n", $list_str) as $line) {
            $line = trim($line);

            // skip empty or comment lines
            if ($line == '' || $line[0] == '/' || strpos($line, '!') !== false) {
                continue;
            }

            // reformat prefixed wildcards
            if ($line[0] == '*') {
                $line = substr($line, 2);
            }

            // convert to xn-- format
            $tld = $IdnaConverter->encode($line);

            // validate if toplevel domain
            $pos = strrpos($tld, '.');
            if ($pos === false) {
                $match = $tld;
            } else {
                $match = substr($tld, $pos+1);
            }

            if (!isset($tlds[$match])) {
                $tlds[$match] = array();
            }

            $tlds[$match][] = $tld;
        }

        // load additional to add to list
        require_once __DIR__ .'/Additional.php';

        // merge list and sort tlds by length within its group
        $this->tldList['content'] = array_merge_recursive($tlds, $additional);

        foreach ($this->tldList['content'] as $tldGroup => $tld) {
            usort($tld, function ($a, $b)
            {
                return strlen($b) - strlen($a);
            });

            $this->tldList['content'][$tldGroup] = $tld;
        }

        $this->tldList['timestamp'] = time();
    }
private function catchTlds ( $ existFile ) { $ content = @ file_get_contents ( $ this -> tldUrl ) ; if ( $ content === false ) { if ( ! $ existFile ) { throw AbstractException :: factory ( 'Connect' , 'Could not catch file from server.' ) ; } return ; } $ IdnaConverter = new Idna ( array ( 'idn_version' => 2008 ) ) ; // only match official ICANN domain tlds if ( preg_match ( '/\/\/ ===BEGIN ICANN DOMAINS===(.*)(?=\/\/ ===END ICANN DOMAINS===)/s' , $ content , $ matches ) !== 1 ) { throw AbstractException :: factory ( 'UnparsableString' , 'Could not fetch ICANN Domains of Mozilla TLD File.' ) ; } $ tlds = array ( ) ; $ list_str = $ matches [ 1 ] ; foreach ( explode ( "\n" , $ list_str ) as $ line ) { $ line = trim ( $ line ) ; // skip empty or comment lines if ( $ line == '' || $ line [ 0 ] == '/' || strpos ( $ line , '!' ) !== false ) { continue ; } // reformat prefixed wildcards if ( $ line [ 0 ] == '*' ) { $ line = substr ( $ line , 2 ) ; } // convert to xn-- format $ tld = $ IdnaConverter -> encode ( $ line ) ; // validate if toplevel domain $ pos = strrpos ( $ tld , '.' ) ; if ( $ pos === false ) { $ match = $ tld ; } else { $ match = substr ( $ tld , $ pos + 1 ) ; } if ( ! isset ( $ tlds [ $ match ] ) ) { $ tlds [ $ match ] = array ( ) ; } $ tlds [ $ match ] [ ] = $ tld ; } // load additional to add to list require_once __DIR__ . '/Additional.php' ; // merge list and sort tlds by length within its group $ this -> tldList [ 'content' ] = array_merge_recursive ( $ tlds , $ additional ) ; foreach ( $ this -> tldList [ 'content' ] as $ tldGroup => $ tld ) { usort ( $ tld , function ( $ a , $ b ) { return strlen ( $ b ) - strlen ( $ a ) ; } ) ; $ this -> tldList [ 'content' ] [ $ tldGroup ] = $ tld ; } $ this -> tldList [ 'timestamp' ] = time ( ) ; }
Catch list from server and parse them to array.

It only uses the official ICANN domain names and adds private
domains and missing official third-levels by using an additional hash.

The manual added list is not complete.

@throws ConnectErrorException
@see Novutec\Additional.php $additional
@param  boolean $existFile
@return void
Catch list from server and parse them to array .