diff --git a/kms.php b/kms.php index ab2dcd6..0f3ac26 100755 --- a/kms.php +++ b/kms.php @@ -3,7 +3,7 @@ # TODO: add PORT option -$version = 'v1.2.1'; +$version = 'v1.2.2'; require_once './src/Daemon.php'; require_once './src/Logger.php'; diff --git a/src/Basis.php b/src/Basis.php index f8fa046..09e018c 100644 --- a/src/Basis.php +++ b/src/Basis.php @@ -60,7 +60,8 @@ function getHost(): string { return 'KMS_HOST'; } $host = v6DelBracket($match[1][0]); // try to remove ipv6 bracket again - $host = ($host == '127.0.0.1' or $host == '::1') ? 'KMS_HOST' : $host; // ignore localhost forward + // TODO: recover $host param +// $host = ($host == '127.0.0.1' or $host == '::1') ? 'KMS_HOST' : $host; // ignore localhost forward return (isHost($host)) ? $host : 'KMS_HOST'; } diff --git a/src/KmsCli.php b/src/KmsCli.php index 9215786..8e079b5 100644 --- a/src/KmsCli.php +++ b/src/KmsCli.php @@ -19,13 +19,20 @@ function showKeysCli(array $kmsKeys, bool $isGbk = false): void { // show kms ke echo $isGbk ? iconv('utf-8', 'gb2312', $ret) : $ret; // utf-8 or gbk } -function showHelpCli(string $host): void { // show help message in shell - $length = strlen($host); +function showHelpCli(string $host, int $port): void { // show help message in shell + $kmsServer = $host; + if (isIPv6($host)) { // host without ipv6 bracket + $kmsServer = '[' . $host . ']'; + } + if ($port != 1688) { + $kmsServer = $kmsServer . ':' . $port; // add kms server port + } + $length = strlen($kmsServer); echo "\n" . genStr(floor(($length - 2) / 2)) . "Activation Command\n"; echo "┏" . genStr($length + 14, '-') . "┓\n"; echo "| slmgr /upk" . genStr($length + 3) . "|\n"; echo "| slmgr /ipk KMS_KEY" . genStr($length - 5) . "|\n"; - echo "| slmgr /skms $host |\n"; + echo "| slmgr /skms $kmsServer |\n"; echo "| slmgr /ato" . genStr($length + 3) . "|\n"; echo "| slmgr /dlv" . genStr($length + 3) . "|\n"; echo "┗" . genStr($length + 14, '-') . "┛\n\n"; diff --git a/src/KmsWeb.php b/src/KmsWeb.php index dcc07f1..698fb5b 100644 --- a/src/KmsWeb.php +++ b/src/KmsWeb.php @@ -16,13 +16,20 @@ function showKeysHtml(array $kmsKeys, string $header): void { // show kms keys i echo ''; } -function showHelpHtml(string $host): void { // show help message in html +function showHelpHtml(string $host, int $port): void { // show help message in html + $kmsServer = $host; + if (isIPv6($host)) { // host without ipv6 bracket + $kmsServer = '[' . $host . ']'; + } + if ($port != 1688) { + $kmsServer = $kmsServer . ':' . $port; // add kms server port + } echo ''; echo ''; echo ''; echo "Windows Activation\n"; echo '

Windows KMS Activation

';
-    echo " slmgr /upk\n slmgr /ipk KMS_KEY\n slmgr /skms $host\n slmgr /ato\n slmgr /dlv ";
+    echo " slmgr /upk\n slmgr /ipk KMS_KEY\n slmgr /skms $kmsServer\n slmgr /ato\n slmgr /dlv ";
     echo '

KMS (Office)
'; echo 'KMS_KEY (Windows)
'; echo 'KMS_KEY (Windows Server)

'; diff --git a/src/Route.php b/src/Route.php index c0e4787..ce0472b 100644 --- a/src/Route.php +++ b/src/Route.php @@ -5,6 +5,10 @@ require_once 'Check.php'; require_once 'KmsCli.php'; require_once 'KmsWeb.php'; +// TODO: get kms port from env +//$kmsPort = 1688; +$kmsPort = 1689; + $kmsHost = getHost(); // kms server address $url = $_SERVER['DOCUMENT_URI']; // request url $isCli = ($_GET['cli'] == 'true'); // shell or web browser @@ -22,7 +26,7 @@ if ($url == '/win/json' or $url == '/win-server/json') { // start route process if ($url == '/' or $url == '/help') { - $isCli ? showHelpCli($kmsHost) : showHelpHtml($kmsHost); // show help message + $isCli ? showHelpCli($kmsHost, $kmsPort) : showHelpHtml($kmsHost, $kmsPort); // show help message } else if ($url == '/office') { $isCli ? showOfficeCli($kmsHost) : showOfficeHtml($kmsHost); // show office commands } else if ($url == '/win' or $url == '/win-server') {