From 3d8350564046a0c5e765a72ebc9b11ca3c741ff3 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 26 Oct 2022 14:42:08 +0800 Subject: [PATCH] perf: enhance cli mode check function --- nginx/kms.conf | 5 ++--- src/Route.php | 13 +++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/nginx/kms.conf b/nginx/kms.conf index 4fd157a..dff3d53 100644 --- a/nginx/kms.conf +++ b/nginx/kms.conf @@ -1,10 +1,9 @@ server { listen 1689; listen [::]:1689 ipv6only=on; - set $kms_dir '/kms-server'; location /assets { - root $kms_dir; + root /kms-server; } location / { @@ -15,6 +14,6 @@ server { set $cli_mode "true"; } fastcgi_param KMS_CLI $cli_mode; - fastcgi_param SCRIPT_FILENAME $kms_dir/src/Route.php; + fastcgi_param SCRIPT_FILENAME /kms-server/src/Route.php; } } diff --git a/src/Route.php b/src/Route.php index 7d2f13b..8f78597 100644 --- a/src/Route.php +++ b/src/Route.php @@ -5,23 +5,16 @@ require_once 'Check.php'; require_once 'KmsCli.php'; require_once 'KmsWeb.php'; -if (getenv("KMS_CLI") === 'true') { - echo "cli mode" . PHP_EOL; -} else { - echo "not cli mode" . PHP_EOL; -} -return; - $kmsHost = getHost(); // kms server address $kmsPort = getPort(); // kms server port $url = $_SERVER['DOCUMENT_URI']; // request url -$isCli = ($_GET['cli'] == 'true'); // shell or web browser +$isCli = (getenv("KMS_CLI") === 'true'); // shell or web browser if ($url == '/json') { // show keys in json format mimeJson(); echo json_encode(array( - 'win' => getKeys(false), - 'win-server' => getKeys(true), + 'win' => getKeys(), // win keys + 'win-server' => getKeys(true), // win-server keys )); return; // skip following process }