diff --git a/db/icpTlds.db b/db/icpTlds.db new file mode 100644 index 0000000..2b5682d Binary files /dev/null and b/db/icpTlds.db differ diff --git a/functions/ExtractDomain.php b/functions/ExtractDomain.php index 69c1d7d..1c70a7c 100644 --- a/functions/ExtractDomain.php +++ b/functions/ExtractDomain.php @@ -6,6 +6,12 @@ class tldDB extends SQLite3 { } } +class icpDB extends SQLite3 { + function __construct() { + $this->open('./db/icpTlds.db'); // 顶级域名数据库 + } +} + class extractDomain { private function getAllTlds() { // 获取所有顶级域 含次级域 $db = new tldDB; @@ -13,6 +19,21 @@ class extractDomain { while ($row = $res->fetchArray(SQLITE3_ASSOC)) { $tlds[] = $row['tld']; } + $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 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编码 } diff --git a/models/icpQuery.php b/models/icpQuery.php index 4e478a0..87b5c02 100644 --- a/models/icpQuery.php +++ b/models/icpQuery.php @@ -98,10 +98,10 @@ class icpQueryEntry { } $msg = '`' . $domain . '`' . PHP_EOL; $msg .= '*类型:*' . $info['CompanyType'] . PHP_EOL; - if ($info['Owner'] != '') { // 负责人不为空 + if ($info['Owner'] != '') { // 负责人为空不显示 $msg .= '*负责人:*' . $info['Owner'] . PHP_EOL; } - if ($info['Owner'] != $info['CompanyName']) { // 名称与负责人不重复 + if ($info['Owner'] != $info['CompanyName']) { // 名称与负责人重复时不显示 $msg .= '*名称:*' . $info['CompanyName'] . PHP_EOL; } $msg .= '*主页:*'; diff --git a/models/punycode.php b/models/punycode.php index c5eb65f..d280cf9 100644 --- a/models/punycode.php +++ b/models/punycode.php @@ -41,7 +41,9 @@ class punycodeEntry { } } if (isset($errMsg)) { // 存在警告 - $msg .= '*Warning:* ' . $errMsg; + if (substr($rawParam, 0, 1) !== '.' && substr($rawParam, -1) !== '.') { // 首尾不为. + $msg .= '*Warning:* ' . $errMsg; + } } tgApi::sendMessage(array( 'parse_mode' => 'Markdown',