|
@ -1,29 +1,13 @@ |
|
|
<?php |
|
|
<?php |
|
|
|
|
|
|
|
|
class extractDomain { |
|
|
class extractDomain { |
|
|
private $tldDB = './db/allTlds.db'; // 顶级域名数据库 |
|
|
private $tldDB = './db/tldInfo.db'; // 顶级域名数据库 |
|
|
private $icpDB = './db/icpTlds.db'; // ICP备案数据库 |
|
|
|
|
|
|
|
|
|
|
|
private function getAllTlds() { // 获取所有顶级域 含次级域 |
|
|
private function getAllTlds() { // 获取所有顶级域 含次级域 |
|
|
$db = new SqliteDB($this->tldDB); |
|
|
$db = new SqliteDB($this->tldDB); |
|
|
$res = $db->query('SELECT tld FROM `tlds`;'); |
|
|
$res = $db->query('SELECT record FROM `list`;'); |
|
|
while ($row = $res->fetchArray(SQLITE3_ASSOC)) { |
|
|
while ($row = $res->fetchArray(SQLITE3_ASSOC)) { |
|
|
$tlds[] = $row['tld']; |
|
|
$tlds[] = $row['record']; |
|
|
} |
|
|
|
|
|
$tlds = array_merge($tlds, $this->getIcpTlds()); |
|
|
|
|
|
$tlds = array_unique($tlds); |
|
|
|
|
|
foreach ($tlds as $tld) { |
|
|
|
|
|
echo $tld . PHP_EOL; |
|
|
|
|
|
} |
|
|
|
|
|
return $tlds; // Unicode字符使用Punycode编码 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function getIcpTlds() { // 获取所有可ICP备案的顶级域 |
|
|
|
|
|
$db = new SqliteDB($this->icpDB); |
|
|
|
|
|
$punycode = new Punycode(); |
|
|
|
|
|
$res = $db->query('SELECT tld FROM `tlds`;'); |
|
|
|
|
|
while ($row = $res->fetchArray(SQLITE3_ASSOC)) { |
|
|
|
|
|
$tlds[] = $punycode->encode($row['tld']); // 转为Punycode编码 |
|
|
|
|
|
} |
|
|
} |
|
|
return $tlds; // Unicode字符使用Punycode编码 |
|
|
return $tlds; // Unicode字符使用Punycode编码 |
|
|
} |
|
|
} |
|
|