Browse Source

feat: GBK support

master
Dnomd343 3 years ago
parent
commit
1eee14b083
  1. 15
      kms-cli.php
  2. 3
      kms-help.php
  3. 20
      route.php

15
kms-cli.php

@ -4,7 +4,16 @@
require_once 'kms-keys.php';
function showVersion($title, $content) {
function show($str) { // GBK兼容
global $gbk;
if ($gbk) {
return iconv('utf-8', 'gb2312', $str);
} else {
return $str;
}
}
function showVersion($title, $content) { // 表格形式显示
$length = 0;
foreach ($content as $row) { // 获取最长的字符串长度
$strLength = strlen(iconv('utf-8', 'gb2312', $row['name']));
@ -13,11 +22,11 @@ function showVersion($title, $content) {
}
}
$strLength = strlen(iconv('utf-8', 'gb2312', $title)); // 获取标题长度
echo str_pad('', floor(($length - $strLength + 36) / 2), ' ') . $title . PHP_EOL; // 居中输出标题
echo str_pad('', floor(($length - $strLength + 36) / 2), ' ') . show($title) . PHP_EOL; // 居中输出标题
echo '┏' . str_pad('', $length + 34, '-') . '┓' . PHP_EOL;
foreach ($content as $row) { // 显示表格主体
$strLength = strlen(iconv('utf-8', 'gb2312', $row['name']));
echo '| ' . $row['name'] . str_pad('', $length - $strLength, ' ') . ' | ';
echo '| ' . show($row['name']) . str_pad('', $length - $strLength, ' ') . ' | ';
echo $row['key'] . ' |' . PHP_EOL;
}
echo '┗' . str_pad('', $length + 34, '-') . '┛' . PHP_EOL;

3
kms-help.php

@ -16,6 +16,9 @@ function showHelp() {
echo 'KMS_KEY -> http://' . $webSite . '/win' . PHP_EOL;
echo ' -> http://' . $webSite . '/win-server' . PHP_EOL;
echo PHP_EOL;
echo 'KMS_KEY(GBK) -> http://' . $webSite . '/win/gbk' . PHP_EOL;
echo ' -> http://' . $webSite . '/win-server/gbk' . PHP_EOL;
echo PHP_EOL;
}
function webHelp() {

20
route.php

@ -11,7 +11,7 @@ if (isset($_SERVER['HTTP_HOST'])) {
}
$url = $_SERVER['DOCUMENT_URI'];
$gbk = false;
if ($url == '/') {
if ($_GET['cli'] == 'true') {
showHelp();
@ -34,5 +34,23 @@ if ($url == '/win-server') {
}
}
if ($url == '/win/gbk') {
if ($_GET['cli'] == 'true') {
$gbk = true;
showWinKeys();
} else {
header('HTTP/1.1 302 Moved Temporarily');
header('Location: /win');
}
}
if ($url == '/win-server/gbk') {
if ($_GET['cli'] == 'true') {
$gbk = true;
showWinServerKeys();
} else {
header('HTTP/1.1 302 Moved Temporarily');
header('Location: /win-server');
}
}
?>
Loading…
Cancel
Save