Browse Source

feat: cli flag demo

master
Dnomd343 2 years ago
parent
commit
db7a958795
  1. 9
      nginx/kms.conf
  2. 7
      src/Route.php

9
nginx/kms.conf

@ -8,14 +8,13 @@ server {
}
location / {
set $query_param $query_string;
if ($http_user_agent ~* (curl|wget)) {
set $query_param $query_param&cli=true;
}
include kms_params;
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm.sock;
fastcgi_param QUERY_STRING $query_param;
if ($http_user_agent ~* (curl|wget)) {
set $cli_mode "true";
}
fastcgi_param KMS_CLI $cli_mode;
fastcgi_param SCRIPT_FILENAME $kms_dir/src/Route.php;
}
}

7
src/Route.php

@ -5,6 +5,13 @@ 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

Loading…
Cancel
Save