From ee1a930affa4d84e028a17f4cd2636f25350f9f1 Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Mon, 25 Oct 2021 12:12:04 +0800 Subject: [PATCH] fix: ignore invalid data for ipip.net --- backend/getInfo.php | 2 +- backend/ipip.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/getInfo.php b/backend/getInfo.php index a934c1f..6f107a7 100644 --- a/backend/getInfo.php +++ b/backend/getInfo.php @@ -128,4 +128,4 @@ function getVersion() { // 获取自身及数据库版本号 return $version; } -?> \ No newline at end of file +?> diff --git a/backend/ipip.php b/backend/ipip.php index 0de3bfd..e185e54 100644 --- a/backend/ipip.php +++ b/backend/ipip.php @@ -43,7 +43,14 @@ class IPDB { if ($node <= 0) { return NULL; } - return explode("\t", $this->getData($node)); + $data = explode("\t", $this->getData($node)); + foreach ($data as &$field) { + $field = trim($field); + } + if ($data[1] === '中国' && $data[2] === '中国') { + $data[1] = $data[2] = ''; + } + return $data; } private function getNode($ip) { // 获取节点编号 @@ -93,4 +100,4 @@ class IPDB { } } -?> \ No newline at end of file +?>