Browse Source

fix: add china icp tld list

master
Dnomd343 3 years ago
parent
commit
e1237b658d
  1. BIN
      db/icpTlds.db
  2. 21
      functions/ExtractDomain.php
  3. 4
      models/icpQuery.php
  4. 4
      models/punycode.php

BIN
db/icpTlds.db

Binary file not shown.

21
functions/ExtractDomain.php

@ -6,6 +6,12 @@ class tldDB extends SQLite3 {
} }
} }
class icpDB extends SQLite3 {
function __construct() {
$this->open('./db/icpTlds.db'); // 顶级域名数据库
}
}
class extractDomain { class extractDomain {
private function getAllTlds() { // 获取所有顶级域 含次级域 private function getAllTlds() { // 获取所有顶级域 含次级域
$db = new tldDB; $db = new tldDB;
@ -13,6 +19,21 @@ class extractDomain {
while ($row = $res->fetchArray(SQLITE3_ASSOC)) { while ($row = $res->fetchArray(SQLITE3_ASSOC)) {
$tlds[] = $row['tld']; $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编码 return $tlds; // Unicode字符使用Punycode编码
} }

4
models/icpQuery.php

@ -98,10 +98,10 @@ class icpQueryEntry {
} }
$msg = '`' . $domain . '`' . PHP_EOL; $msg = '`' . $domain . '`' . PHP_EOL;
$msg .= '*类型:*' . $info['CompanyType'] . PHP_EOL; $msg .= '*类型:*' . $info['CompanyType'] . PHP_EOL;
if ($info['Owner'] != '') { // 负责人为空 if ($info['Owner'] != '') { // 负责人为空不显示
$msg .= '*负责人:*' . $info['Owner'] . PHP_EOL; $msg .= '*负责人:*' . $info['Owner'] . PHP_EOL;
} }
if ($info['Owner'] != $info['CompanyName']) { // 名称与负责人重复 if ($info['Owner'] != $info['CompanyName']) { // 名称与负责人重复时不显示
$msg .= '*名称:*' . $info['CompanyName'] . PHP_EOL; $msg .= '*名称:*' . $info['CompanyName'] . PHP_EOL;
} }
$msg .= '*主页:*'; $msg .= '*主页:*';

4
models/punycode.php

@ -41,7 +41,9 @@ class punycodeEntry {
} }
} }
if (isset($errMsg)) { // 存在警告 if (isset($errMsg)) { // 存在警告
$msg .= '*Warning:* ' . $errMsg; if (substr($rawParam, 0, 1) !== '.' && substr($rawParam, -1) !== '.') { // 首尾不为.
$msg .= '*Warning:* ' . $errMsg;
}
} }
tgApi::sendMessage(array( tgApi::sendMessage(array(
'parse_mode' => 'Markdown', 'parse_mode' => 'Markdown',

Loading…
Cancel
Save