Browse Source

feat: add office commands

master
dnomd343 2 years ago
parent
commit
38048d381d
  1. 23
      src/Basis.php
  2. 10
      src/KmsWeb.php
  3. 16
      src/kmsCli.php

23
src/Basis.php

@ -12,3 +12,26 @@ function getKeys(bool $isWinServer = false): array { // get kms keys asset
$keysAsset = json_decode(file_get_contents('../assets/kms-keys.json'), true);
return $isWinServer ? array_reverse($keysAsset['win-server']) : $keysAsset['win'];
}
function officeCommand(string $version, string $key, string $host): string {
$command = 'if exist "%ProgramFiles%\Microsoft Office\\' . $version . '\ospp.vbs" ';
$command .= 'cd /d "%ProgramFiles%\Microsoft Office\\' . $version . "\"\n";
$command .= 'if exist "%ProgramFiles(x86)%\Microsoft Office\\' . $version . '\ospp.vbs" ';
$command .= 'cd /d "%ProgramFiles(x86)%\Microsoft Office\\' . $version . "\"\n";
$command .= "cscript ospp.vbs /inpkey:$key\n";
$command .= "cscript ospp.vbs /sethst:$host\n";
$command .= "cscript ospp.vbs /act\n";
return $command . "cscript ospp.vbs /dstatus\n";
}
function osppCommand(string $host): array {
return array(
'/dstatus' => ['Displays license information for installed product keys.', '显示当前已安装产品密钥的许可证信息'],
'/dstatusall' => ['Displays license information for all installed licenses.', '显示当前已安装的所有许可证信息'],
'/unpkey:XXXXX' => ['Uninstalls an product key with the last five digits of it.', '卸载已安装的产品密钥(最后5位)'],
'/inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX' => ['Installs a product key with a user-provided product key.', '安装产品密钥'],
"/sethst:$host" => ['Sets a KMS host name with a user-provided host name.', '设置 KMS 主机名'],
'/remhst' => ['Removes KMS host name and sets port to default.', '删除 KMS 主机名'],
'/act' => ['Activates installed Office product keys.', '激活 Office'],
);
}

10
src/KmsWeb.php

@ -17,16 +17,16 @@ function showKeysWeb(array $kmsKeys, string $header): void { // show kms keys in
}
function showHelpWeb(string $site) {
function showHelpWeb(string $host) {
echo '<!DOCTYPE html><html><head><meta charset="utf-8">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
echo '<link rel="stylesheet" href="./assets/style.css" /></head>';
echo '<title>Windows Activation</title>';
echo '<body><div><h2>Windows KMS Activation</h2><pre>';
echo '<code> slmgr /upk\n slmgr /ipk KMS_KEY\n slmgr /skms ' . $site . '\n slmgr /ato\n slmgr /dlv </code>';
echo '</pre><p><a href="http://' . $site . '/office">KMS (Office)</a><br>';
echo '<a href="http://' . $site . '/win">KMS_KEY (Windows)</a><br>';
echo '<a href="http://' . $site . '/win-server">KMS_KEY (Windows Server)</a></p></div></body></html>';
echo '<code> slmgr /upk\n slmgr /ipk KMS_KEY\n slmgr /skms ' . $host . '\n slmgr /ato\n slmgr /dlv </code>';
echo '</pre><p><a href="http://' . $host . '/office">KMS (Office)</a><br>';
echo '<a href="http://' . $host . '/win">KMS_KEY (Windows)</a><br>';
echo '<a href="http://' . $host . '/win-server">KMS_KEY (Windows Server)</a></p></div></body></html>';
}
require_once 'Basis.php';

16
src/kmsCli.php

@ -19,19 +19,19 @@ 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 $site): void {
$length = strlen($site);
function showHelpCli(string $host): void {
$length = strlen($host);
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 $site |\n";
echo "| slmgr /skms $host |\n";
echo "| slmgr /ato" . genStr($length + 3) . "|\n";
echo "| slmgr /dlv" . genStr($length + 3) . "|\n";
echo "┗" . genStr($length + 14, '-') . "┛\n\n";
echo "Office -> http://$site/office\n\n";
echo "KMS_KEY -> http://$site/win\n";
echo " -> http://$site/win-server\n\n";
echo "KMS_KEY(GBK) -> http://$site/win/gbk\n";
echo " -> http://$site/win-server/gbk\n\n";
echo "Office -> http://$host/office\n\n";
echo "KMS_KEY -> http://$host/win\n";
echo " -> http://$host/win-server\n\n";
echo "KMS_KEY(GBK) -> http://$host/win/gbk\n";
echo " -> http://$host/win-server/gbk\n\n";
}

Loading…
Cancel
Save