PluginsOCSInventory-NG / officepack

Retrieve microsoft office keys
GNU General Public License v2.0
15 stars 27 forks source link

Where I can find the Keys? #18

Closed tobiasroithmeier closed 4 years ago

tobiasroithmeier commented 7 years ago

I don't know if this is a real issue or it's just my mistake but I dont know where I can view the office license keys. I installed the Plugin and it showed me that there is installed office available. But I dont see where I can get the keys ? plugin_surface software_surface

alexel200 commented 7 years ago

tobiasroithmeier have you found something? I have exactly the same issue, I have just installed it on ocsreport 2.3, but I noticed I'm receiving the key because when I open the pc, in the software tab I can see the current office's key installed, however I haven't found how to obtain the consolidate report on officepack plugin.

Thank you in advance!

alexel200 commented 7 years ago

Ok I share the way as I solved the problem, first I don't know if this is the best way as I don't know ocsinventory core so deep, however that solved my problem and maybe some one else can resolve also. I think, source can be improved changing the conditional (IF) for one switch that let people to add portion of software at less in this pluging for not limiting the possibilities here:

So here is the way I solved:

  1. Go to ms_officepack folder (I have ubuntu server so the path in my case was (/usr/share/ocsinventory-reports/ocsreports/plugins/main_sections/ms_officepack)

  2. Add the new tab in the array ($data_on), "3" => "Licenses number by serial and key displaying" (this was the name I gave).

  3. Add new conditional, however I think we can replace it with one switch clause. elseif($protectedPost['onglet'] == 3){ $sql = "SELECT OFFICEVERSION, OFFICEKEY, COUNT(*) as NUMBER FROM officepackGROUP BY OFFICEVERSION, OFFICEKEY";

    $list_fields=array( 'Office Version' => 'OFFICEVERSION', 'Serial' => 'OFFICEKEY', '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); }

Here I paste the complete ms_officepack.php:

\<?php //==================================================================================== // OCS INVENTORY REPORTS // Copyleft Erwan GOALOU 2010 (erwan(at)ocsinventory-ng(pt)org) // Web: http://www.ocsinventory-ng.org // // This code is open source and may be copied and modified as long as the source // code is always made freely available. // 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"); $form_name="officekey";

$data_on = array( "1" => "Licenses number by version", "2" => "Licenses by administrative data", "3" => "Licenses number by serial and key displaying" );

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);

}elseif($protectedPost['onglet'] == 2){

// 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 "<p>Accountinfo : <select name='accountinfo' onchange='this.form.submit();'>";
while ($row = mysqli_fetch_object($account_info_list)) {
    $id = $row->ID;
    $str = $row->COMMENT;
    if(isset($protectedPost['accountinfo']) && $protectedPost['accountinfo'] == $row->ID){
        echo "<option value='$id' selected>$str</option> ";
    }else{
        echo "<option value='$id'>$str</option> ";
    }
}
echo "</select></p>";

// 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 "<p>Office version : <select name='officeversion' onchange='this.form.submit();'>";
while ($row = mysqli_fetch_object($result)) {
    $officeversion = $row->OFFICEVERSION;
    if(isset($protectedPost['officeversion']) && $protectedPost['officeversion'] == $row->OFFICEVERSION){
        echo "<option value='$officeversion' selected>$officeversion</option> ";
    }else{
        echo "<option value='$officeversion'>$officeversion</option> ";
    }
}
echo "</select></p>";

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);
}

}elseif($protectedPost['onglet'] == 3){ $sql = "SELECT OFFICEVERSION, OFFICEKEY, COUNT(*) as NUMBER FROM officepackGROUP BY OFFICEVERSION, OFFICEKEY";

$list_fields=array(
    'Office Version' => 'OFFICEVERSION',
'Serial' => 'OFFICEKEY',
    '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);

}

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){

}

\?>

charleneauger commented 4 years ago

Hi,

@tobiasroithmeier , the license keys are visible only on software tab on computer details. @alexel200 , your code is very interesting. Can you create a Pull Request for this feature ?

Best regards, Charlene Auger