diff --git a/agent/msofficekey.vbs b/agent/msofficekey.vbs index 7da7799..c6f30d0 100644 --- a/agent/msofficekey.vbs +++ b/agent/msofficekey.vbs @@ -41,6 +41,8 @@ For a = LBound(aOffID, 1) To UBound(aOffID, 1) schKey "SOFTWARE\Microsoft\Office\" & aOffID(a,1) & "\Registration", true Next +getOffice16Infos + Sub schKey97(regKey) oReg.GetStringValue HKEY_LOCAL_MACHINE, regKey & "Office\8.0", "BinDirPath", oDir97 If IsNull(oDir97) Then Exit Sub @@ -160,6 +162,88 @@ Sub writeXML(oVer,oProd,oProdID,oBit,oGUID,oInstall,oKey,oNote) "" End Sub +Sub getOffice16Infos + Dim WshShell, oExec + Dim mTab + Dim key, value + Set WshShell = WScript.CreateObject("WScript.Shell") + + result = WshShell.Run("cmd /c cscript ""C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS"" /dstatus > C:\output.txt", 0, true) + ' Debug : if 32 bits version available ? + ' WScript.Echo result + + ' If file not there command throw an error and return is 1 and abover + if result > 0 then + ' Try with the 64 bits version if available + result = WshShell.Run("cmd /c cscript ""C:\Program Files\Microsoft Office\Office16\OSPP.VBS"" /dstatus > C:\output.txt", 0, true) + ' Debug : if 64 bits version available ? + ' WScript.Echo result + end if + + ' Result = 0 if successfully executed + if result = 0 then + Set fso = CreateObject("Scripting.FileSystemObject") + Set file = fso.OpenTextFile("C:\output.txt", 1) + 'strData = file.ReadLine + + Do Until file.AtEndOfStream + ' Debug : echo each line + ' WScript.echo file.ReadLine + + str = file.ReadLine + ' Debug : Show string before split + ' WScript.Echo str + + mTab = Split(str, ":") + arrCount = uBound(mTab) + 1 + + if arrCount > 1 then + key = mTab(0) + value = mTab(1) + + Select Case key + Case "PRODUCT ID" + oProdID = mTab(1) + ' Debug : echo office data + ' WScript.echo "oProdId = " & oProdID + Case "SKU ID" + oGUID = mTab(1) + ' Debug : echo office data + ' WScript.echo "oGUID = " & oGUID + Case "LICENSE NAME" + oProd = mTab(1) + ' Debug : echo office data + ' WScript.echo "oProd = " & oProd + Case "LICENSE DESCRIPTION" + oVer = mTab(1) + ' Debug : echo office data + ' WScript.echo "oVer = " & oVer + Case "ERROR DESCRIPTION" + oNote = mTab(1) + ' Debug : echo office data + ' WScript.echo "oNote = " & oNote + Case "Last 5 characters of installed product key" + oKey = "XXXXX-XXXXX-XXXXX-XXXXX-" & mTab(1) + ' Debug : echo office data + ' WScript.echo "oKey = " & oKey + End Select + End If + + Loop + + oInstall = 1 + oBit = 1 + + file.Close + + writeXML oVer,oProd,oProdID,oBit,oGUID,oInstall,oKey,oNote + + end if + + + +End Sub + Function decodeKey(iValues) Dim arrDPID, foundKeys arrDPID = Array() diff --git a/ms_officepack.php b/ms_officepack.php index a9cb139..ea9dcf5 100644 --- a/ms_officepack.php +++ b/ms_officepack.php @@ -9,41 +9,114 @@ // Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt //==================================================================================== - if(AJAX){ - parse_str($protectedPost['ocs']['0'], $params); - $protectedPost+=$params; - ob_start(); - $ajax = true; - } - else{ - $ajax=false; - } - printEnTete("Office Key Manager"); - if (!isset($protectedPost['SHOW'])) - $protectedPost['SHOW'] = 'NOSHOW'; - $form_name="officekey"; - $table_name=$form_name; - $tab_options=$protectedPost; - $tab_options['form_name']=$form_name; - $tab_options['table_name']=$table_name; - echo open_form($form_name); - $list_fields=array( 'Product' => 'PRODUCT', - 'Office Version' => 'OFFICEVERSION', - 'Type' => 'TYPE', - 'Office Key' => 'OFFICEKEY', - ); - $list_col_cant_del=$list_fields; - $default_fields= $list_fields; - $sql=prepare_sql_tab($list_fields); - $sql['SQL'] .= "FROM officepack WHERE 1"; - array_push($sql['ARG'],$systemid); - $tab_options['ARG_SQL']=$sql['ARG']; - $tab_options['ARG_SQL_COUNT']=$systemid; - ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del); - echo close_form(); - if ($ajax){ - ob_end_clean(); - tab_req($list_fields,$default_fields,$list_col_cant_del,$sql['SQL'],$tab_options); - ob_start(); - } +if(AJAX){ + parse_str($protectedPost['ocs']['0'], $params); + $protectedPost+=$params; + ob_start(); + $ajax = true; +} +else{ + $ajax=false; +} +printEnTete("Office Key Manager"); +$form_name="officekey"; + +$data_on = array( + "1" => "Licenses number by version", + "2" => "Licenses by administrative data" +); + +if(!isset($protectedPost['onglet'])){ + $protectedPost['onglet'] = 1; +} + +$table_name=$form_name; +$tab_options=$protectedPost; +$tab_options['form_name']=$form_name; +$tab_options['table_name']=$table_name; + +echo open_form($form_name); +onglet($data_on, $form_name, "onglet", 2); + +if($protectedPost['onglet'] == 1){ + + $sql = "SELECT OFFICEVERSION,COUNT(*) as NUMBER FROM `officepack`GROUP BY OFFICEVERSION"; + + $list_fields=array( + 'Office Version' => 'OFFICEVERSION', + 'Number' => 'NUMBER', + ); + + $list_col_cant_del=$list_fields; + $default_fields= $list_fields; + + ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del); + +}else{ + + // select account info for sorting + $account_info_list_sql = "Select ID, COMMENT from accountinfo_config WHERE ACCOUNT_TYPE = 'COMPUTERS'"; + $account_info_list = mysql2_query_secure($account_info_list_sql, $_SESSION['OCS']["readServer"]); + + echo "

Accountinfo :

"; + + // Select which office version we want to see + $sql_office = "SELECT OFFICEVERSION FROM `officepack`GROUP BY OFFICEVERSION"; + $result = mysql2_query_secure($sql_office, $_SESSION['OCS']["readServer"]); + + echo "

Office version :

"; + + if( isset($protectedPost['accountinfo']) && isset($protectedPost['officeversion'])){ + $fields = "fields_".$protectedPost['accountinfo']; + if($protectedPost['accountinfo']){ + $fields = "TAG"; + } + $office = $protectedPost['officeversion']; + + $sql = "SELECT a.".$fields." as ACC , COUNT(".$fields.") as ACCNB FROM `accountinfo` as a INNER JOIN officepack as o ON a.hardware_id = o.hardware_id WHERE o.officeversion = '".$office."' GROUP BY ".$fields.""; + + $list_fields=array( + 'Accountinfo' => "ACC", + 'Licenses number' => 'ACCNB', + ); + + $list_col_cant_del=$list_fields; + $default_fields= $list_fields; + + ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del); + } + + +} + +echo close_form(); +if ($ajax){ + ob_end_clean(); + tab_req($list_fields,$default_fields,$list_col_cant_del,$sql,$tab_options); + ob_start(); +} + +function getAccountinfoNumber($id){ + +} + ?>