Browse Source

perf: enhance cli mode check function

master
Dnomd343 2 years ago
parent
commit
3d83505640
  1. 5
      nginx/kms.conf
  2. 13
      src/Route.php

5
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;
}
}

13
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
}

Loading…
Cancel
Save