diff --git a/kms-cli.php b/kms-cli.php index 6dfac4e..e80a931 100644 --- a/kms-cli.php +++ b/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; diff --git a/kms-help.php b/kms-help.php index 91283d5..76288aa 100644 --- a/kms-help.php +++ b/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() { diff --git a/route.php b/route.php index eaf7732..373c422 100644 --- a/route.php +++ b/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'); + } +} ?> \ No newline at end of file