From c70282f8dc5aa8afb139871bb229224021cfe2f7 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Tue, 17 Aug 2021 21:58:12 +0800 Subject: [PATCH] update: move some config to .env --- main.php | 2 ++ models/cfopPic.php | 7 ++++--- models/icpQuery.php | 4 ++-- models/ipInfo.php | 7 ++++++- models/kmsCheck.php | 7 ++++++- models/tldQuery.php | 4 ++-- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/main.php b/main.php index d5c24df..3e424e7 100644 --- a/main.php +++ b/main.php @@ -8,6 +8,8 @@ require_once 'functions/RedisCache.php'; require_once 'functions/TgInterface.php'; require_once 'functions/ExtractDomain.php'; +fastcgi_finish_request(); // 断开请求连接 + $env = loadEnv('.env'); // 载入环境变量 $apiToken = $env['BOT_TOKEN']; $botAccount = $env['BOT_NAME']; // 机器人用户名 diff --git a/models/cfopPic.php b/models/cfopPic.php index 112367c..0642895 100644 --- a/models/cfopPic.php +++ b/models/cfopPic.php @@ -34,13 +34,14 @@ class cfopPicEntry { } private function getPicId($type) { // 返回图片文件ID + global $env; switch ($type) { case 'gan': - return 'BQACAgUAAxkBAAIBtGEOLnr4Q6D4Z_80bgfXq5xsZMeWAAKtAwACWy55VOU-SGKqc7aMIAQ'; + return $env['CFOP_GAN']; case 'mfg': - return 'BQACAgUAAxkBAAIB3WEOVHKeYrrGhFo-GffB0W-tQRKlAALQAwACWy55VGny8ArGMkfoIAQ'; + return $env['CFOP_MFG']; case 'yx': - return 'BQACAgUAAxkBAAIB32EOVISFQbgmir2abj6QkgqaSX1WAALRAwACWy55VMEuU9lCYTYWIAQ'; + return $env['CFOP_YX']; } } diff --git a/models/icpQuery.php b/models/icpQuery.php index 228b18e..9e5814c 100644 --- a/models/icpQuery.php +++ b/models/icpQuery.php @@ -1,11 +1,11 @@ apiPath .= '?key=' . $env['ICP_KEY'] . '&domain='; + $this->apiPath = $env['ICP_API'] . '?key=' . $env['ICP_KEY'] . '&domain='; } private function getIcpInfo($domain) { // ICP备案查询 diff --git a/models/ipInfo.php b/models/ipInfo.php index c268e77..8d73e01 100644 --- a/models/ipInfo.php +++ b/models/ipInfo.php @@ -1,7 +1,12 @@ apiPath = $env['ECHOIP_API']; + } private function changeCoor($num) { // 转为时分秒格式 $stage_1 = floor($num); diff --git a/models/kmsCheck.php b/models/kmsCheck.php index 1cedcfb..560755b 100644 --- a/models/kmsCheck.php +++ b/models/kmsCheck.php @@ -34,7 +34,12 @@ class kmsKeys { } class kmsCheck { - private $api = 'https://kms.343.re/'; + private $api; + + public function __construct() { + global $env; + $this->api = $env['KMS_API']; + } public function kmsStatus($host, $port) { $server = $host . ':' . $port; diff --git a/models/tldQuery.php b/models/tldQuery.php index 77ccc62..b393de8 100644 --- a/models/tldQuery.php +++ b/models/tldQuery.php @@ -15,10 +15,10 @@ class tldQueryEntry { return $info; } - private function genMessage($info) { + private function genMessage($info) { // 生成返回消息 $msg = '`' . $info['tld'] . '` `(` `' . $info['type'] . '` `)`' . PHP_EOL; if (count($info['manager']) !== 0) { - $msg .= '*Manager:*' . PHP_EOL; + $msg .= '*Manager*' . PHP_EOL; foreach ($info['manager']['name'] as $row) { $msg .= ' ' . $row . PHP_EOL; }