From fa9a236a13f6c161a0b061a21ccbca31ea74a916 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Mon, 8 Mar 2021 17:23:46 +0800 Subject: [PATCH] refactor: rebuild the query section --- backend/getIP.php | 17 ----------------- backend/getInfo.php | 6 +++--- backend/queryInfo.php | 26 +++++--------------------- 3 files changed, 8 insertions(+), 41 deletions(-) delete mode 100644 backend/getIP.php diff --git a/backend/getIP.php b/backend/getIP.php deleted file mode 100644 index 23de256..0000000 --- a/backend/getIP.php +++ /dev/null @@ -1,17 +0,0 @@ - diff --git a/backend/getInfo.php b/backend/getInfo.php index e639eff..2db3f85 100644 --- a/backend/getInfo.php +++ b/backend/getInfo.php @@ -2,7 +2,7 @@ include("getCountry.php"); -function getIPInfo($ip, $is_cli) { +function getIPInfo($ip) { $specialIpInfo = getSpecialIpInfo($ip); if (is_string($specialIpInfo)) { $info['ip'] = $ip; @@ -15,7 +15,6 @@ function getIPInfo($ip, $is_cli) { $info['isp'] = $specialIpInfo; } else { $rawIspInfo = getIspInfo($ip); - $info['ip'] = $ip; $info['as'] = getAS($rawIspInfo); $info['city'] = $rawIspInfo['city']; @@ -27,7 +26,7 @@ function getIPInfo($ip, $is_cli) { $info['country'] .= "(".get_country($rawIspInfo['country'])['cn'].")"; } - if ($is_cli == true) { + if ($_GET['cli'] == "true") { $cli = "IP: ".$info['ip'].PHP_EOL; $cli = $cli."AS: ".$info['as'].PHP_EOL; $cli = $cli."City: ".$info['city'].PHP_EOL; @@ -39,6 +38,7 @@ function getIPInfo($ip, $is_cli) { return $cli; } + header('Content-Type: application/json; charset=utf-8'); return json_encode($info); } diff --git a/backend/queryInfo.php b/backend/queryInfo.php index bd6b0d8..feeb80c 100644 --- a/backend/queryInfo.php +++ b/backend/queryInfo.php @@ -1,30 +1,14 @@