Browse Source

update: perf route process

master
dnomd343 2 years ago
parent
commit
682e681f58
  1. 4
      src/Basis.php
  2. 1
      src/KmsWeb.php
  3. 22
      src/Route.php

4
src/Basis.php

@ -17,8 +17,8 @@ function getKeys(bool $isWinServer = false): array { // get kms keys asset
return $isWinServer ? array_reverse($keysAsset['win-server']) : $keysAsset['win'];
}
function getHost(): string { // TODO: get kms host
return 'kms.343.re';
function getHost(): string {
return $_SERVER['HTTP_HOST'] ?? 'KMS_HOST'; // TODO: remove port content
}
function officeInfo(): array { // office dir and kms key for different version

1
src/KmsWeb.php

@ -16,7 +16,6 @@ function showKeysHtml(array $kmsKeys, string $header): void { // show kms keys i
echo '</div></body></html>';
}
function showHelpHtml(string $host): void { // show help message in html
echo '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">';

22
src/Route.php

@ -9,25 +9,17 @@ $url = $_SERVER['DOCUMENT_URI']; // request url
$isCli = ($_GET['cli'] == 'true'); // shell or web browser
$isGbk = false; // utf-8 or gbk
if ($url == '/win/gbk') {
$url = '/win';
$isGbk = true;
}
if ($url == '/win-server/gbk') {
$url = '/win-server';
$isGbk = true;
}
$isJson = false; // json output
if ($url == '/win/json') {
$url = '/win';
$isJson = true;
if ($url == '/win/gbk' or $url == '/win-server/gbk') {
$url = ($url == '/win/gbk') ? '/win' : '/win-server'; // gbk mode
$isGbk = true;
}
if ($url == '/win-server/json') {
$url = '/win-server';
if ($url == '/win/json' or $url == '/win-server/json') {
$url = ($url == '/win/json') ? '/win' : '/win-server'; // json mode
$isJson = true;
}
// start route process
if ($url == '/' or $url == '/help') {
$isCli ? showHelpCli($kmsHost) : showHelpHtml($kmsHost); // show help message
} else if ($url == '/office') {
@ -49,6 +41,6 @@ if ($url == '/' or $url == '/help') {
echo "Illegal Request\n";
} else {
mimeJson();
echo '{"status":"error","message":"Illegal Request"}';
echo '{"success":false,"message":"Illegal Request"}';
}
}

Loading…
Cancel
Save