Skip to content

Commit 30fc100

Browse files
committed
Update office for 2016 + add stats page
1 parent 7266a15 commit 30fc100

File tree

2 files changed

+194
-37
lines changed

2 files changed

+194
-37
lines changed

agent/msofficekey.vbs

+84
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ For a = LBound(aOffID, 1) To UBound(aOffID, 1)
4141
schKey "SOFTWARE\Microsoft\Office\" & aOffID(a,1) & "\Registration", true
4242
Next
4343

44+
getOffice16Infos
45+
4446
Sub schKey97(regKey)
4547
oReg.GetStringValue HKEY_LOCAL_MACHINE, regKey & "Office\8.0", "BinDirPath", oDir97
4648
If IsNull(oDir97) Then Exit Sub
@@ -160,6 +162,88 @@ Sub writeXML(oVer,oProd,oProdID,oBit,oGUID,oInstall,oKey,oNote)
160162
"</OFFICEPACK>"
161163
End Sub
162164

165+
Sub getOffice16Infos
166+
Dim WshShell, oExec
167+
Dim mTab
168+
Dim key, value
169+
Set WshShell = WScript.CreateObject("WScript.Shell")
170+
171+
result = WshShell.Run("cmd /c cscript ""C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS"" /dstatus > C:\output.txt", 0, true)
172+
' Debug : if 32 bits version available ?
173+
' WScript.Echo result
174+
175+
' If file not there command throw an error and return is 1 and abover
176+
if result > 0 then
177+
' Try with the 64 bits version if available
178+
result = WshShell.Run("cmd /c cscript ""C:\Program Files\Microsoft Office\Office16\OSPP.VBS"" /dstatus > C:\output.txt", 0, true)
179+
' Debug : if 64 bits version available ?
180+
' WScript.Echo result
181+
end if
182+
183+
' Result = 0 if successfully executed
184+
if result = 0 then
185+
Set fso = CreateObject("Scripting.FileSystemObject")
186+
Set file = fso.OpenTextFile("C:\output.txt", 1)
187+
'strData = file.ReadLine
188+
189+
Do Until file.AtEndOfStream
190+
' Debug : echo each line
191+
' WScript.echo file.ReadLine
192+
193+
str = file.ReadLine
194+
' Debug : Show string before split
195+
' WScript.Echo str
196+
197+
mTab = Split(str, ":")
198+
arrCount = uBound(mTab) + 1
199+
200+
if arrCount > 1 then
201+
key = mTab(0)
202+
value = mTab(1)
203+
204+
Select Case key
205+
Case "PRODUCT ID"
206+
oProdID = mTab(1)
207+
' Debug : echo office data
208+
' WScript.echo "oProdId = " & oProdID
209+
Case "SKU ID"
210+
oGUID = mTab(1)
211+
' Debug : echo office data
212+
' WScript.echo "oGUID = " & oGUID
213+
Case "LICENSE NAME"
214+
oProd = mTab(1)
215+
' Debug : echo office data
216+
' WScript.echo "oProd = " & oProd
217+
Case "LICENSE DESCRIPTION"
218+
oVer = mTab(1)
219+
' Debug : echo office data
220+
' WScript.echo "oVer = " & oVer
221+
Case "ERROR DESCRIPTION"
222+
oNote = mTab(1)
223+
' Debug : echo office data
224+
' WScript.echo "oNote = " & oNote
225+
Case "Last 5 characters of installed product key"
226+
oKey = "XXXXX-XXXXX-XXXXX-XXXXX-" & mTab(1)
227+
' Debug : echo office data
228+
' WScript.echo "oKey = " & oKey
229+
End Select
230+
End If
231+
232+
Loop
233+
234+
oInstall = 1
235+
oBit = 1
236+
237+
file.Close
238+
239+
writeXML oVer,oProd,oProdID,oBit,oGUID,oInstall,oKey,oNote
240+
241+
end if
242+
243+
244+
245+
End Sub
246+
163247
Function decodeKey(iValues)
164248
Dim arrDPID, foundKeys
165249
arrDPID = Array()

ms_officepack.php

+110-37
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,114 @@
99
// Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
1010
//====================================================================================
1111

12-
if(AJAX){
13-
parse_str($protectedPost['ocs']['0'], $params);
14-
$protectedPost+=$params;
15-
ob_start();
16-
$ajax = true;
17-
}
18-
else{
19-
$ajax=false;
20-
}
21-
printEnTete("Office Key Manager");
22-
if (!isset($protectedPost['SHOW']))
23-
$protectedPost['SHOW'] = 'NOSHOW';
24-
$form_name="officekey";
25-
$table_name=$form_name;
26-
$tab_options=$protectedPost;
27-
$tab_options['form_name']=$form_name;
28-
$tab_options['table_name']=$table_name;
29-
echo open_form($form_name);
30-
$list_fields=array( 'Product' => 'PRODUCT',
31-
'Office Version' => 'OFFICEVERSION',
32-
'Type' => 'TYPE',
33-
'Office Key' => 'OFFICEKEY',
34-
);
35-
$list_col_cant_del=$list_fields;
36-
$default_fields= $list_fields;
37-
$sql=prepare_sql_tab($list_fields);
38-
$sql['SQL'] .= "FROM officepack WHERE 1";
39-
array_push($sql['ARG'],$systemid);
40-
$tab_options['ARG_SQL']=$sql['ARG'];
41-
$tab_options['ARG_SQL_COUNT']=$systemid;
42-
ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del);
43-
echo close_form();
44-
if ($ajax){
45-
ob_end_clean();
46-
tab_req($list_fields,$default_fields,$list_col_cant_del,$sql['SQL'],$tab_options);
47-
ob_start();
48-
}
12+
if(AJAX){
13+
parse_str($protectedPost['ocs']['0'], $params);
14+
$protectedPost+=$params;
15+
ob_start();
16+
$ajax = true;
17+
}
18+
else{
19+
$ajax=false;
20+
}
21+
printEnTete("Office Key Manager");
22+
$form_name="officekey";
23+
24+
$data_on = array(
25+
"1" => "Licenses number by version",
26+
"2" => "Licenses by administrative data"
27+
);
28+
29+
if(!isset($protectedPost['onglet'])){
30+
$protectedPost['onglet'] = 1;
31+
}
32+
33+
$table_name=$form_name;
34+
$tab_options=$protectedPost;
35+
$tab_options['form_name']=$form_name;
36+
$tab_options['table_name']=$table_name;
37+
38+
echo open_form($form_name);
39+
onglet($data_on, $form_name, "onglet", 2);
40+
41+
if($protectedPost['onglet'] == 1){
42+
43+
$sql = "SELECT OFFICEVERSION,COUNT(*) as NUMBER FROM `officepack`GROUP BY OFFICEVERSION";
44+
45+
$list_fields=array(
46+
'Office Version' => 'OFFICEVERSION',
47+
'Number' => 'NUMBER',
48+
);
49+
50+
$list_col_cant_del=$list_fields;
51+
$default_fields= $list_fields;
52+
53+
ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del);
54+
55+
}else{
56+
57+
// select account info for sorting
58+
$account_info_list_sql = "Select ID, COMMENT from accountinfo_config WHERE ACCOUNT_TYPE = 'COMPUTERS'";
59+
$account_info_list = mysql2_query_secure($account_info_list_sql, $_SESSION['OCS']["readServer"]);
60+
61+
echo "<p>Accountinfo : <select name='accountinfo' onchange='this.form.submit();'>";
62+
while ($row = mysqli_fetch_object($account_info_list)) {
63+
$id = $row->ID;
64+
$str = $row->COMMENT;
65+
if(isset($protectedPost['accountinfo']) && $protectedPost['accountinfo'] == $row->ID){
66+
echo "<option value='$id' selected>$str</option> ";
67+
}else{
68+
echo "<option value='$id'>$str</option> ";
69+
}
70+
}
71+
echo "</select></p>";
72+
73+
// Select which office version we want to see
74+
$sql_office = "SELECT OFFICEVERSION FROM `officepack`GROUP BY OFFICEVERSION";
75+
$result = mysql2_query_secure($sql_office, $_SESSION['OCS']["readServer"]);
76+
77+
echo "<p>Office version : <select name='officeversion' onchange='this.form.submit();'>";
78+
while ($row = mysqli_fetch_object($result)) {
79+
$officeversion = $row->OFFICEVERSION;
80+
if(isset($protectedPost['officeversion']) && $protectedPost['officeversion'] == $row->OFFICEVERSION){
81+
echo "<option value='$officeversion' selected>$officeversion</option> ";
82+
}else{
83+
echo "<option value='$officeversion'>$officeversion</option> ";
84+
}
85+
}
86+
echo "</select></p>";
87+
88+
if( isset($protectedPost['accountinfo']) && isset($protectedPost['officeversion'])){
89+
$fields = "fields_".$protectedPost['accountinfo'];
90+
if($protectedPost['accountinfo']){
91+
$fields = "TAG";
92+
}
93+
$office = $protectedPost['officeversion'];
94+
95+
$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."";
96+
97+
$list_fields=array(
98+
'Accountinfo' => "ACC",
99+
'Licenses number' => 'ACCNB',
100+
);
101+
102+
$list_col_cant_del=$list_fields;
103+
$default_fields= $list_fields;
104+
105+
ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del);
106+
}
107+
108+
109+
}
110+
111+
echo close_form();
112+
if ($ajax){
113+
ob_end_clean();
114+
tab_req($list_fields,$default_fields,$list_col_cant_del,$sql,$tab_options);
115+
ob_start();
116+
}
117+
118+
function getAccountinfoNumber($id){
119+
120+
}
121+
49122
?>

0 commit comments

Comments
 (0)