From ed2e024e46c372115f6045c60a6bf034d1fd4c71 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 1 Aug 2021 16:16:48 +0800 Subject: [PATCH] feat: office activation commands --- backend/kms-office.php | 54 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/backend/kms-office.php b/backend/kms-office.php index eab9566..9b02ff5 100644 --- a/backend/kms-office.php +++ b/backend/kms-office.php @@ -26,13 +26,13 @@ $osppDescriptionCn[] = '显示当前已安装的所有许可证信息'; $osppOption[] = '/unpkey:XXXXX'; $osppDescription[] = 'Uninstalls an product key with the last five digits of it.'; -$osppDescriptionCn[] = '卸载已安装的产品密钥,取密钥的最后 5 位数'; +$osppDescriptionCn[] = '卸载已安装的产品密钥(最后5位)'; $osppOption[] = '/inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX'; $osppDescription[] = 'Installs a product key with a user-provided product key.'; $osppDescriptionCn[] = '安装产品密钥'; -$osppOption[] = '/sethst:kms.XXX.XX'; +$osppOption[] = '/sethst:kms.xxx.xx'; $osppDescription[] = 'Sets a KMS host name with a user-provided host name.'; $osppDescriptionCn[] = '设置 KMS 主机名'; @@ -44,7 +44,7 @@ $osppOption[] = '/act'; $osppDescription[] = 'Activates installed Office product keys.'; $osppDescriptionCn[] = '激活 Office'; -function loadOfficeCmd() { +function loadOfficeCmd() { // 初始化Office激活命令 global $webSite, $office; $activeCmd = 'cscript ospp.vbs /sethst:' . $webSite . PHP_EOL . 'cscript ospp.vbs /act'; $activeCmd .= PHP_EOL . 'cscript ospp.vbs /dstatus' . PHP_EOL; @@ -53,22 +53,56 @@ function loadOfficeCmd() { } } -function showOfficeHelp() { +function showOfficeHelp() { // 命令行输出Office激活帮助 loadOfficeCmd(); - global $office; - $index = '2010'; + global $office, $osppOption, $osppDescription, $osppDescriptionCn; foreach ($office as $index => $officeKmsCmd) { echo str_pad('', 34, ' ') . 'Office Professional Plus ' . $index . ' VL Activation Command' . PHP_EOL; echo str_pad('', 120, '-') . PHP_EOL; echo $officeKmsCmd; echo str_pad('', 120, '-') . PHP_EOL . PHP_EOL; } - // TODO: Warning of VL version - // Usage of ospp.vbs + $length = 0; + $length_first = 0; + foreach ($osppOption as $index => $option) { // 获取最长的字符串长度 + $strLength = strlen($option) + strlen($osppDescription[$index]); + if ($length < $strLength) { + $length = $strLength; + $length_first = strlen($option); + } + } + $title = 'Common activation commands'; + echo str_pad('', floor(($length - strlen($title) + 26) / 2), ' ') . $title . PHP_EOL; + echo '┏' . str_pad('', $length + 24, '-') . '┓' . PHP_EOL; + foreach ($osppOption as $index => $option) { + echo '| cscript ospp.vbs ' . str_pad($osppOption[$index], $length_first, ' ') . ' | '; + echo str_pad($osppDescription[$index], $length - $length_first + 2, ' ') . ' |' . PHP_EOL; + } + echo '┗' . str_pad('', $length + 24, '-') . '┛' . PHP_EOL . PHP_EOL; + echo 'These commands are only applicable to the VL version of Office.' . PHP_EOL; + echo 'If it is a Retail version, please convert it to Volume first.' . PHP_EOL . PHP_EOL; } -function webOfficeHelp() { - // TODO: Web of Office KMS Activation +function webOfficeHelp() { // 网页输出Office激活帮助 + loadOfficeCmd(); + global $office, $osppOption, $osppDescription, $osppDescriptionCn; + echo ''; + echo ''; + echo 'Office KMS Server'; + echo '
'; + foreach ($office as $officeVersion => $officeKmsCmd) { + echo '

Office Professional Plus ' . $officeVersion . ' VL

' . PHP_EOL; + echo '
' . $officeKmsCmd . '
' . PHP_EOL; + } + echo '

常用激活命令

' . PHP_EOL; + echo ''; + foreach ($osppOption as $index => $option) { + echo ''; + echo ''; + } + echo '
命令说明
cscript ospp.vbs ' . $option . '' . $osppDescriptionCn[$index] . '

' . PHP_EOL; + echo '

以上命令仅用于激活VL版本的Office,如果当前为Retail版本,请先转化为批量授权版本。

' . PHP_EOL; + echo '
'; } ?> \ No newline at end of file