Exemplo n.º 1
0
 static function checkRight($module, $right)
 {
     global $CFG_GLPI;
     if (!PluginFusioninventory::haveRight($module, $right)) {
         // Gestion timeout session
         if (!isset($_SESSION["glpiID"])) {
             glpi_header($CFG_GLPI["root_doc"] . "/index.php");
             exit;
         }
         displayRightError();
     }
 }
 function showForm($target, $ID = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     if ($ID != '') {
         $this->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     $CommonItem = new CommonItem();
     $ptcm = new PluginFusioninventoryConfigModules();
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr>";
     echo "<th colspan='4'>";
     echo $LANG['plugin_fusioninventory']["agents"][0];
     echo " :</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["common"][16] . " :</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='name' size='40' value='" . $this->fields["name"] . "'/>";
     echo "</td>";
     if ($ptcm->getValue('inventoryocs') == "1") {
         echo "<td>" . $LANG['plugin_fusioninventory']['config'][3] . " :</td>";
         echo "<td align='center'>";
         Dropdown::showYesNo("module_inventory", $this->fields["module_inventory"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']["agents"][5] . " :</td>";
     echo "<td align='center'>";
     echo $this->fields["fusioninventory_agent_version"];
     echo "</td>";
     if ($ptcm->getValue('netdiscovery') == "1") {
         echo "<td>" . $LANG['plugin_fusioninventory']['config'][4] . " :</td>";
         echo "<td align='center'>";
         Dropdown::showYesNo("module_netdiscovery", $this->fields["module_netdiscovery"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']["agents"][6] . " :</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("lock", $this->fields["lock"]);
     echo "</td>";
     if ($ptcm->getValue('snmp') == "1") {
         echo "<td>" . $LANG['plugin_fusioninventory']['config'][7] . " :</td>";
         echo "<td align='center'>";
         Dropdown::showYesNo("module_snmpquery", $this->fields["module_snmpquery"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']["agents"][23] . " :</td>";
     echo "<td align='center'>";
     if ($this->fields["on_device"] != "0" and $this->fields["on_device"] != "") {
         $CommonItem->getFromDB(COMPUTER_TYPE, $this->fields["on_device"]);
         echo $CommonItem->getLink(1);
         echo "<input type='hidden' name='on_device' value='" . $this->fields["on_device"] . "'/>";
     } else {
         Computer_Item::dropdownConnect(COMPUTER_TYPE, COMPUTER_TYPE, 'on_device', $_SESSION['glpiactive_entity']);
     }
     echo "</td>";
     if ($ptcm->getValue('wol') == "1") {
         echo "<td>" . $LANG['plugin_fusioninventory']['config'][6] . " :</td>";
         echo "<td align='center'>";
         Dropdown::showYesNo("module_wakeonlan", $this->fields["module_wakeonlan"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>Token :</td>";
     echo "<td align='center' colspan='3'>";
     echo $this->fields["token"];
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     if (PluginFusioninventory::haveRight("agents", "w")) {
         if ($ID == '') {
             echo "<td align='center' colspan='4'>";
             echo "<div align='center'><input type='submit' name='add' value=\"" . $LANG["buttons"][8] . "\" class='submit' >";
             echo "</td>";
         } else {
             echo "<td align='center' colspan='2'>";
             echo "<input type='hidden' name='ID' value='" . $ID . "'/>";
             echo "<div align='center'><input type='submit' name='update' value=\"" . $LANG["buttons"][7] . "\" class='submit' >";
             echo "</td>";
             echo "<td align='center' colspan='2'>";
             echo "<input type='submit' name='delete' value=\"" . $LANG["buttons"][6] . "\" class='submit'>";
             echo "</td>";
         }
     }
     echo "</tr>";
     echo "</table></form></div>";
 }
 function showForm($type, $target, $ID)
 {
     global $LANG;
     if (!PluginFusioninventory::haveRight("errors", "r")) {
         return false;
     }
     // preparing to display history
     if (!isset($_GET['start'])) {
         $_GET['start'] = 0;
     }
     $numrows = $this->countEntries($type, $ID);
     $parameters = "ID=" . $_GET["ID"] . "&onglet=" . $_SESSION["glpi_onglet"];
     echo "<br>";
     printPager($_GET['start'], $numrows, $_SERVER['PHP_SELF'], $parameters);
     if ($_SESSION["glpilist_limit"] < $numrows) {
         $limit = $_SESSION["glpilist_limit"];
     } else {
         $limit = $numrows;
     }
     // Get history
     if (!($data = $this->getEntries($type, $ID, $_GET['start'], $limit))) {
         return false;
     }
     // for $_GET['type'] (useful to check rights)
     if ($type == COMPUTER_TYPE) {
         echo "<div align='center'><form method='post' name='errors_form' id='errors_form'\n                    action=\"" . $target . "?type=" . COMPUTER_TYPE . "\">";
     } else {
         if ($type == NETWORKING_TYPE) {
             echo "<div align='center'><form method='post' name='errors_form' id='errors_form'\n                    action=\"" . $target . "?type=" . NETWORKING_TYPE . "\">";
         } else {
             // $type == PRINTER_TYPE
             echo "<div align='center'><form method='post' name='errors_form' id='errors_form'\n                    action=\"" . $target . "?type=" . PRINTER_TYPE . "\">";
         }
     }
     echo "<table class='tab_cadre' cellpadding='5'><tr><th colspan='5'>";
     echo $LANG['plugin_fusioninventory']["errors"][0] . " :</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th></th>";
     echo "<th>" . $LANG['plugin_fusioninventory']["errors"][1] . " :</th>";
     echo "<th>" . $LANG['plugin_fusioninventory']["errors"][2] . " :</th>";
     echo "<th>" . $LANG['plugin_fusioninventory']["errors"][3] . " :</th>";
     echo "<th>" . $LANG['plugin_fusioninventory']["errors"][4] . " :</th></tr>";
     for ($i = 0; $i < $limit; $i++) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>";
         echo "<input type='checkbox' name='checked_{$i}' value='1'>";
         echo "</td>";
         echo "<td align='center'>" . $data["{$i}"]['ifaddr'] . "</td>";
         echo "<td align='center'>" . $data["{$i}"]['description'] . "</td>";
         echo "<td align='center'>" . $data["{$i}"]['first_pb_date'] . "</td>";
         echo "<td align='center'>" . $data["{$i}"]['last_pb_date'] . "</td>";
         echo "</td></tr>";
         echo "<input type='hidden' name='ID_{$i}' value='" . $data["{$i}"]['ID'] . "'>";
     }
     if (!PluginFusioninventory::haveRight("errors", "w")) {
         return false;
     }
     echo "<input type='hidden' name='limit' value='" . $limit . "'>";
     echo "<tr class='tab_bg_1'><td colspan='5'>";
     echo "<div align='center'><a onclick= \"if ( markAllRows('errors_form') ) return false;\"\n                 href='" . $_SERVER['PHP_SELF'] . "?select=all'>" . $LANG["buttons"][18] . "</a>";
     echo " - <a onclick= \"if ( unMarkAllRows('errors_form') ) return false;\"\n                  href='" . $_SERVER['PHP_SELF'] . "?select=none'>" . $LANG["buttons"][19] . "</a> ";
     echo "<input type='submit' name='delete' value=\"" . $LANG["buttons"][6] . "\" class='submit' >\n            </div></td></tr>";
     echo "</table></form></div>";
 }
 function getPagesCount($id, $frequence, $date_end, $field)
 {
     global $DB;
     $dates = PluginFusioninventory::date(9, $frequence, $date_end);
     $query = "SELECT * \n                FROM `glpi_plugin_fusioninventory_printers_history`\n                WHERE `FK_printers`=" . $id . "\n                      AND `date` IN ('" . $dates[0] . " 00:00:00'";
     for ($i = 1; $i < count($dates); $i++) {
         $query .= ",'" . $dates[$i] . " 00:00:00'";
     }
     $query .= ") \n                ORDER BY `date` DESC\n                LIMIT 0,9";
     $dates_ex = $dates;
     for ($i = 0; $i < count($dates); $i++) {
         $dates[$i] = $dates[$i] . " 00:00:00";
         $page_scanned_counter[$i] = 0;
     }
     $dates_flip = array_flip($dates);
     $count = "";
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             $dates[$dates_flip[$data['date']]] = $data['date'];
             $page_scanned_counter[$dates_flip[$data['date']]] = $data[$field];
             if (!empty($data[$field]) and $count == "") {
                 $count = $data[$field];
             }
         }
     }
     for ($i = count($dates) - 1; $i >= 0; $i--) {
         if ($page_scanned_counter[$i] == "0" or empty($page_scanned_counter[$i])) {
             $page_scanned_counter[$i] = $count;
         }
         $count = $page_scanned_counter[$i];
     }
     $Array['dates'] = $dates;
     $Array['count'] = $page_scanned_counter;
     return $Array;
 }
 function showForm($target, $ID = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     PluginFusioninventoryAuth::checkRight("snmp_models", "r");
     if ($ID != '') {
         $this->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     $this->showTabs($ID, "", $_SESSION['glpi_tab']);
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'><tr><th colspan='2'>";
     echo $ID == '' ? $LANG['plugin_fusioninventory']["model_info"][7] : $LANG['plugin_fusioninventory']["model_info"][6];
     echo " :</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG["common"][16] . "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='name' value='" . $this->fields["name"] . "' size='35'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG["common"][17] . "</td>";
     echo "<td align='center'>";
     $selected_value = $this->fields["device_type"];
     echo "<select name='device_type'>\n";
     if ($selected_value == "0") {
         $selected = 'selected';
     } else {
         $selected = '';
     }
     echo "<option value='0' " . $selected . ">-----</option>\n";
     if ($selected_value == COMPUTER_TYPE) {
         $selected = 'selected';
     } else {
         $selected = '';
     }
     echo "<option value='" . COMPUTER_TYPE . "' " . $selected . ">" . $LANG["Menu"][0] . "</option>\n";
     if ($selected_value == NETWORKING_TYPE) {
         $selected = 'selected';
     } else {
         $selected = '';
     }
     echo "<option value='" . NETWORKING_TYPE . "' " . $selected . ">" . $LANG["Menu"][1] . "</option>\n";
     if ($selected_value == PRINTER_TYPE) {
         $selected = 'selected';
     } else {
         $selected = '';
     }
     echo "<option value='" . PRINTER_TYPE . "' " . $selected . ">" . $LANG["Menu"][2] . "</option>\n";
     if ($selected_value == PERIPHERAL_TYPE) {
         $selected = 'selected';
     } else {
         $selected = '';
     }
     echo "<option value='" . PERIPHERAL_TYPE . "' " . $selected . ">" . $LANG["Menu"][16] . "</option>\n";
     if ($selected_value == PHONE_TYPE) {
         $selected = 'selected';
     } else {
         $selected = '';
     }
     echo "<option value='" . PHONE_TYPE . "' " . $selected . ">" . $LANG["Menu"][34] . "</option>\n";
     echo "</select>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'><td colspan='2'>";
     if (PluginFusioninventory::haveRight("snmp_models", "w")) {
         if ($ID == '') {
             echo "<div align='center'><input type='submit' name='add' value=\"" . $LANG["buttons"][8] . "\" class='submit' >";
         } else {
             echo "<input type='hidden' name='ID' value='" . $ID . "'/>";
             echo "<div align='center'><input type='submit' name='update' value=\"" . $LANG["buttons"][7] . "\" class='submit' >";
             if (!$this->fields["deleted"]) {
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='delete' value=\"" . $LANG["buttons"][6] . "\" class='submit'>";
             } else {
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='restore' value=\"" . $LANG["buttons"][21] . "\" class='submit'>";
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='purge' value=\"" . $LANG["buttons"][22] . "\" class='submit'>";
             }
         }
     }
     echo "</td>";
     echo "</tr>";
     echo "</table></form></div>";
 }
 function showForm($target)
 {
     include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php";
     global $LANG, $DB, $FUSIONINVENTORY_MAPPING;
     echo "<form method='post' name='functionalities_form' id='functionalities_form' action='" . $target . "'>";
     echo "<table class='tab_cadre_fixe' cellpadding='2'>";
     echo "<tr>";
     echo "<th colspan='2'>";
     echo $LANG['plugin_fusioninventory']["functionalities"][28] . " :";
     echo "</th>";
     echo "</tr>";
     echo "<tr>";
     echo "<th>";
     echo $LANG['plugin_fusioninventory']["functionalities"][29];
     echo "</th>";
     echo "<th>";
     echo $LANG['plugin_fusioninventory']["functionalities"][9];
     echo "</th>";
     echo "</tr>";
     $days = array();
     $days[-1] = 'Jamais';
     $days[0] = 'Toujours';
     for ($i = 1; $i < 366; $i++) {
         $days[$i] = "{$i}";
     }
     $query = "SELECT *\n                FROM " . $this->table . ";";
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             echo "<tr class='tab_bg_1'>";
             echo "<td align='left'>";
             echo $FUSIONINVENTORY_MAPPING[NETWORKING_TYPE][$data['field']]['name'];
             echo "</td>";
             echo "<td align='center'>";
             Dropdown::showFromArray($data['ID'], $days, array('value' => $data['days']));
             echo "</td>";
             echo "</tr>";
         }
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td align='center' colspan='2'>";
     if (PluginFusioninventory::haveRight("configuration", "w")) {
         echo "<input type='hidden' name='tabs' value='history' />";
         echo "<input type='submit' name='update' value=\"" . $LANG["buttons"][2] . "\" class='submit' >";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "<br/>";
     echo "<table class='tab_cadre_fixe' cellpadding='2'>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='1' class='center' height='30'>";
     if (PluginFusioninventory::haveRight("configuration", "w")) {
         echo "<input type='submit' class=\"submit\" name='Clean_history' value='" . $LANG['buttons'][53] . "' >";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</form>";
 }
 function showForm($target, $ID)
 {
     global $LANG;
     if (!PluginFusioninventory::haveRight("snmp_printers", "r")) {
         return false;
     }
     // display stats
     if ($stats = $this->stats($ID)) {
         echo "<br><div align = 'center'>";
         echo "<table class='tab_cadre' cellpadding='5'><tr><th colspan='2'>";
         echo $LANG['plugin_fusioninventory']["prt_history"][10] . " " . $stats["num_days"] . " " . $LANG['plugin_fusioninventory']["prt_history"][11] . "</th></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['plugin_fusioninventory']["prt_history"][12] . " : </td>";
         echo "<td>" . $stats["num_pages"] . "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['plugin_fusioninventory']["prt_history"][13] . " : </td>";
         echo "<td>" . $stats["pages_per_day"] . "</td></tr>";
         echo "</table></div>";
     }
     // preparing to display history
     if (!isset($_GET['start'])) {
         $_GET['start'] = 0;
     }
     $numrows = $this->countAllEntries($ID);
     $parameters = "ID=" . $_GET["ID"] . "&onglet=" . $_SESSION["glpi_onglet"];
     echo "<br>";
     printPager($_GET['start'], $numrows, $_SERVER['PHP_SELF'], $parameters);
     if ($_SESSION["glpilist_limit"] < $numrows) {
         $limit = $_SESSION["glpilist_limit"];
     } else {
         $limit = $numrows;
     }
     // Get history
     if (!($data = $this->getEntries($ID, $_GET['start'], $limit))) {
         return false;
     }
     echo "<div align='center'><form method='post' name='printer_history_form'\n                 id='printer_history_form'  action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5'><tr><th colspan='3'>";
     echo $LANG['plugin_fusioninventory']["prt_history"][20] . " :</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th></th>";
     echo "<th>" . $LANG['plugin_fusioninventory']["prt_history"][21] . " :</th>";
     echo "<th>" . $LANG['plugin_fusioninventory']["prt_history"][22] . " :</th></tr>";
     for ($i = 0; $i < $limit; $i++) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>";
         echo "<input type='checkbox' name='checked_{$i}' value='1'>";
         echo "</td>";
         echo "<td align='center'>" . $data["{$i}"]['date'] . "</td>";
         echo "<td align='center'>" . $data["{$i}"]['pages'] . "</td>";
         echo "</td></tr>";
         echo "<input type='hidden' name='ID_{$i}' value='" . $data["{$i}"]['ID'] . "'>";
     }
     if (!PluginFusioninventory::haveRight("snmp_printers", "w")) {
         return false;
     }
     echo "<input type='hidden' name='limit' value='" . $limit . "'>";
     echo "<tr class='tab_bg_1'><td colspan='3'>";
     echo "<div align='center'><a onclick= \"if (markAllRows('printer_history_form')) \n                 return false;\"\n                 href='" . $_SERVER['PHP_SELF'] . "?select=all'>" . $LANG["buttons"][18] . "</a>";
     echo " - <a onclick= \"if ( unMarkAllRows('printer_history_form') ) return false;\"\n                  href='" . $_SERVER['PHP_SELF'] . "?select=none'>" . $LANG["buttons"][19] . "</a> ";
     echo "<input type='submit' name='delete' value=\"" . $LANG["buttons"][6] . "\" class='submit' >\n            </div></td></tr>";
     echo "</table></form></div>";
 }
 function showForm($p_target)
 {
     global $LANG, $DB, $LINK_ID_TABLE;
     $tableSelect = '';
     if (isset($_SESSION["glpi_plugin_fusioninventory_lockable_table"])) {
         $tableId = $_SESSION["glpi_plugin_fusioninventory_lockable_table"];
         if (isset($LINK_ID_TABLE[$tableId])) {
             $tableSelect = $LINK_ID_TABLE[$tableId];
         }
     }
     echo "<form method='post' name='setLockable_form' id='setLockable_form'\n                  action='" . $p_target . "'>";
     echo "<table class='tab_cadre_fixe' cellpadding='2'>";
     echo "<tr>";
     echo "<th colspan='4'>" . $LANG['plugin_fusioninventory']["functionalities"][70] . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']["functionalities"][72] . " :</td>";
     echo "<td>" . $LANG['plugin_fusioninventory']["functionalities"][71] . " :</td>";
     echo "<td></td><td>" . $LANG['plugin_fusioninventory']['functionalities'][7] . "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php";
     $options = "";
     $query = "SHOW TABLES;";
     $elements = array(0 => '-----');
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             $elements[$data[0]] = $data[0];
         }
     }
     $idSelect = 'dropdown_tableSelect' . Dropdown::showFromArray('tableSelect', $elements, array('value' => $tableSelect));
     $elements = array();
     echo "</td><td class='right'>";
     echo "<span id='columnsSelect'>&nbsp;";
     if ($tableSelect != '') {
         PluginFusioninventoryLockable::getColumnSelect($tableSelect);
     }
     echo "</span>\n";
     $params = array('tableSelect' => '__VALUE__');
     ajaxUpdateItemOnSelectEvent($idSelect, 'columnsSelect', GLPI_ROOT . "/plugins/fusioninventory/ajax/lockable.columns.php", $params);
     ajaxUpdateItemOnSelectEvent($idSelect, 'columnsLockable', GLPI_ROOT . "/plugins/fusioninventory/ajax/lockable.lockables.php", $params);
     echo "</td><td class='center'>";
     if (PluginFusioninventory::haveRight("configuration", "w")) {
         echo "<input type='submit'  class=\"submit\" name='plugin_fusioninventory_lockable_add' value='" . $LANG["buttons"][8] . " >>'>";
         echo "<br /><br />";
         echo "<input type='submit'  class=\"submit\" name='plugin_fusioninventory_lockable_delete' value='<< " . $LANG["buttons"][6] . "'>";
     }
     echo "</td><td class='left'>";
     echo "<span id='columnsLockable'>&nbsp;";
     if ($tableSelect != '') {
         PluginFusioninventoryLockable::getLockableSelect($tableSelect);
     }
     echo "</span>\n";
     echo "</table></form>";
 }
Exemplo n.º 9
0
 function showForm($target, $ID)
 {
     include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php";
     global $DB, $CFG_GLPI, $LANG, $FUSIONINVENTORY_MAPPING, $IMPORT_TYPES;
     if (!PluginFusioninventory::haveRight("snmp_models", "r")) {
         return false;
     } else {
         if (isset($ID) and !empty($ID)) {
             $query = "SELECT `device_type`\n                   FROM `glpi_plugin_fusioninventory_model_infos`\n                   WHERE `ID`='" . $ID . "';";
             $result = $DB->query($query);
             $data = $DB->fetch_assoc($result);
             $type_model = $data['device_type'];
             $query = "SELECT `glpi_plugin_fusioninventory_model_infos`.`device_type`,\n                          `glpi_plugin_fusioninventory_mib`.*\n                   FROM `glpi_plugin_fusioninventory_mib`\n                        LEFT JOIN `glpi_plugin_fusioninventory_model_infos`\n                        ON `glpi_plugin_fusioninventory_mib`.`FK_model_infos`=\n                           `glpi_plugin_fusioninventory_model_infos`.`ID`\n                   WHERE `glpi_plugin_fusioninventory_model_infos`.`ID`='" . $ID . "';";
             if ($result = $DB->query($query)) {
                 $object_used = array();
                 $linkoid_used = array();
                 echo "<br>";
                 echo "<div align='center'><form method='post' name='odi_list' id='oid_list'\n                       action=\"" . $target . "\">";
                 //echo "<table class='tab_cadre' cellpadding='5' width='800'><tr><th colspan='7'>";
                 $nb_col = 8;
                 if ($data['device_type'] == NETWORKING_TYPE) {
                     $nb_col++;
                 }
                 echo "<table class='tab_cadre_fixe'><tr><th colspan='" . $nb_col . "'>";
                 echo $LANG['plugin_fusioninventory']["mib"][5] . "</th></tr>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<th align='center'></th>";
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][1] . "</th>";
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][2] . "</th>";
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][3] . "</th>";
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][6] . "</th>";
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][7] . "</th>";
                 echo "<th align='center' width='250'>" . $LANG['plugin_fusioninventory']["mib"][8] . "</th>";
                 if ($data['device_type'] == NETWORKING_TYPE) {
                     echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][9] . "</th>";
                 }
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["model_info"][11] . "</th>";
                 echo "</tr>";
                 while ($data = $DB->fetch_array($result)) {
                     if ($data["activation"] == "0") {
                         echo "<tr class='tab_bg_1' style='color: grey; '>";
                     } else {
                         echo "<tr class='tab_bg_1'>";
                     }
                     echo "<td align='center'>";
                     echo "<input name='item_coche[]' value='" . $data["ID"] . "' type='checkbox'>";
                     echo "</td>";
                     echo "<td align='center'>";
                     echo Dropdown::getDropdownName("glpi_plugin_fusioninventory_mib_label", $data["FK_mib_label"]);
                     echo "</td>";
                     echo "<td align='center'>";
                     $object_used[] = $data["FK_mib_object"];
                     echo Dropdown::getDropdownName("glpi_plugin_fusioninventory_mib_object", $data["FK_mib_object"]);
                     echo "</td>";
                     echo "<td align='center'>";
                     echo Dropdown::getDropdownName("glpi_plugin_fusioninventory_mib_oid", $data["FK_mib_oid"]);
                     echo "</td>";
                     echo "<td align='center'>";
                     if ($data["oid_port_counter"] == "1") {
                         if ($data["activation"] == "1") {
                             echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark.png'/>";
                         } else {
                             if ($data["activation"] == "0") {
                                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/pics/bookmark_off.png'/>";
                             }
                         }
                     }
                     echo "</td>";
                     echo "<td align='center'>";
                     if ($data["oid_port_dyn"] == "1") {
                         if ($data["activation"] == "1") {
                             echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark.png'/>";
                         } else {
                             if ($data["activation"] == "0") {
                                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/pics/bookmark_off.png'/>";
                             }
                         }
                     }
                     echo "</td>";
                     echo "<td align='center'>";
                     if (isset($FUSIONINVENTORY_MAPPING[$data['mapping_type']][$data["mapping_name"]]['name'])) {
                         echo $FUSIONINVENTORY_MAPPING[$data['mapping_type']][$data["mapping_name"]]['name'] . " ( " . $data["mapping_name"] . " )";
                         $linkoid_used[$data['mapping_type'] . "||" . $data["mapping_name"]] = 1;
                     }
                     echo "</td>";
                     if ($data['device_type'] == NETWORKING_TYPE) {
                         echo "<td align='center'>";
                         if ($data["vlan"] == "1") {
                             if ($data["activation"] == "1") {
                                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark.png'/>";
                             } else {
                                 if ($data["activation"] == "0") {
                                     echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/pics/bookmark_off.png'/>";
                                 }
                             }
                         }
                         echo "</td>";
                     }
                     echo "<td align='center'>";
                     echo "<a href='" . $target . "?ID=" . $ID . "&activation=" . $data["ID"] . "'>";
                     if ($data["activation"] == "1") {
                         echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark.png'/>";
                     } else {
                         if ($data["activation"] == "0") {
                             echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/pics/bookmark_off.png'/>";
                         }
                     }
                     echo "</a>";
                     echo "</td>";
                     echo "</tr>";
                 }
                 echo "</table>";
                 echo "<div align='center'>";
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr>";
                 echo "<td><img src=\"" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png\" alt=''></td>\n                  <td align='center'><a onclick= \"if ( markCheckboxes('oid_list') ) return false;\"\n                      href='" . $_SERVER['PHP_SELF'] . "?select=all'>" . $LANG["buttons"][18] . "</a></td>";
                 echo "<td>/</td><td align='center'><a onclick= \"if ( unMarkCheckboxes('oid_list') ) \n                     return false;\" href='" . $_SERVER['PHP_SELF'] . "?select=none'>" . $LANG["buttons"][19] . "</a>";
                 echo "</td><td align='left' colspan='6' width='80%'>";
                 if (PluginFusioninventory::haveRight("snmp_models", "w")) {
                     echo "<input class='submit' type='submit' name='delete_oid' value='" . $LANG["buttons"][6] . "'>";
                 }
                 echo "</td>";
                 echo "</tr>";
                 echo "</table></div>";
                 // ********** Ajout d'un tableau pour ajouter nouveau OID ********** //
                 echo "<br/>";
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr class='tab_bg_1'><th colspan='7'>" . $LANG['plugin_fusioninventory']["mib"][4] . "</th></tr>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][1] . "</th>";
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][2] . "</th>";
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][3] . "</th>";
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][6] . "</th>";
                 echo "<th align='center'>" . $LANG['plugin_fusioninventory']["mib"][7] . "</th>";
                 echo "<th align='center' width='250'>" . $LANG['plugin_fusioninventory']["mib"][8] . "</th>";
                 if ($type_model == NETWORKING_TYPE) {
                     echo "<th align='center'>" . $LANG["networking"][56] . "</th>";
                 }
                 echo "</tr>";
                 echo "<td align='center'>";
                 Dropdown::show("PluginFusioninventoryMib_Label", array('name' => "FK_mib_label", 'value' => 0));
                 echo "</td>";
                 echo "<td align='center'>";
                 Dropdown::show("PluginFusioninventoryMib_Object", array('name' => "FK_mib_object", 'value' => 0));
                 echo "</td>";
                 echo "<td align='center'>";
                 Dropdown::show("PluginFusioninventoryMib_Oid", array('name' => "FK_mib_oid", 'value' => 0));
                 echo "</td>";
                 echo "<td align='center'>";
                 //echo "<input name='oid_port_counter' value='0' type='checkbox'>";
                 Dropdown::showYesNo("oid_port_counter");
                 echo "</td>";
                 echo "<td align='center'>";
                 //echo "<input name='oid_port_dyn' value='0' type='checkbox'>";
                 Dropdown::showYesNo("oid_port_dyn");
                 echo "</td>";
                 echo "<td align='center'>";
                 //echo "<select name='links_oid_fields' size='1'>";
                 $types = array();
                 $types[] = "-----";
                 foreach ($FUSIONINVENTORY_MAPPING as $type => $mapping43) {
                     if ($type_model == $type or $type_model == "0") {
                         if (isset($FUSIONINVENTORY_MAPPING[$type])) {
                             foreach ($FUSIONINVENTORY_MAPPING[$type] as $name => $mapping) {
                                 $types[$type . "||" . $name] = $FUSIONINVENTORY_MAPPING[$type][$name]["name"];
                             }
                         }
                     }
                 }
                 Dropdown::showFromArray("links_oid_fields", $types, array('used' => $linkoid_used));
                 echo "</td>";
                 if ($type_model == NETWORKING_TYPE) {
                     echo "<td align='center'>";
                     Dropdown::showYesNo("vlan");
                     echo "</td>";
                 }
                 echo "</tr>";
                 echo "<tr class='tab_bg_1'><td colspan='7' align='center'>";
                 if (PluginFusioninventory::haveRight("snmp_models", "w")) {
                     echo "<input type='hidden' name='FK_model_infos' value='" . $ID . "'/>";
                     echo "<input type='submit' name='add_oid' value=\"" . $LANG["buttons"][2] . "\" class='submit' >";
                 }
                 echo "</td>";
                 echo "</tr>";
                 echo "</table></form></div>";
             }
         }
     }
 }
Exemplo n.º 10
0
  You should have received a copy of the GNU General Public License
  along with GLPI; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  ------------------------------------------------------------------------
*/
// Original Author of file: David DURIEUX
// Purpose of file:
// ----------------------------------------------------------------------
if (!defined('GLPI_ROOT')) {
    define('GLPI_ROOT', '../../..');
}
//$NEEDED_ITEMS=array("fusioninventory");
$NEEDED_ITEMS = array("computer", "device", "printer", "networking", "peripheral", "monitor", "software", "infocom", "phone", "tracking", "enterprise", "reservation", "setup", "group", "registry", "rulesengine", "ocsng", "admininfo");
include GLPI_ROOT . "/inc/includes.php";
if (PluginFusioninventory::HaveRight("snmp_models", "r") or PluginFusioninventory::HaveRight("snmp_authentification", "r") or PluginFusioninventory::HaveRight("snmp_iprange", "r") or PluginFusioninventory::HaveRight("snmp_agent", "r") or PluginFusioninventory::HaveRight("snmp_scripts_infos", "r") or PluginFusioninventory::HaveRight("snmp_agent_infos", "r") or PluginFusioninventory::HaveRight("snmp_discovery", "r") or PluginFusioninventory::HaveRight("snmp_report", "r")) {
    if (plugin_fusioninventory_needUpdate() == 1) {
        commonHeader($LANG['plugin_fusioninventory']["setup"][4], $_SERVER["PHP_SELF"], "plugins", "fusioninventory");
        echo "<div align='center'>";
        echo "<table class='tab_cadre' cellpadding='5'>";
        echo "<tr><th>" . $LANG['plugin_fusioninventory']["setup"][3];
        echo "</th></tr>";
        echo "<tr class='tab_bg_1'><td>";
        echo "<a href='install.php'>" . $LANG['plugin_fusioninventory']["setup"][5] . "</a></td></tr>";
        echo "</table></div>";
    } else {
        commonHeader($LANG['plugin_fusioninventory']["title"][0], $_SERVER["PHP_SELF"], "plugins", "fusioninventory");
        PluginFusioninventoryDisplay::menu();
    }
} else {
    displayRightError();
Exemplo n.º 11
0
 function showForm($target, $ID)
 {
     global $LANG, $CFG_GLPI;
     echo "<form method='post' name='functionalities_form' id='functionalities_form'  action='" . $target . "'>";
     echo "<table class='tab_cadre_fixe' cellpadding='5'>";
     echo "<tr>";
     echo "<th colspan='4'>";
     echo $LANG['plugin_fusioninventory']["functionalities"][2] . "&nbsp;:";
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']["functionalities"][27] . "&nbsp;:</td>";
     echo "<td width='20%'>";
     Dropdown::showYesNo("ssl_only", $this->isActivated('ssl_only'));
     echo "</td>";
     echo "<td>" . $LANG['plugin_fusioninventory']["functionalities"][16] . "&nbsp;:</td>";
     echo "<td width='20%'>";
     $ArrayValues = array();
     $ArrayValues['DB'] = $LANG['plugin_fusioninventory']["functionalities"][17];
     $ArrayValues['file'] = $LANG['plugin_fusioninventory']["functionalities"][18];
     Dropdown::showFromArray('authsnmp', $ArrayValues, array('value' => $this->getValue('authsnmp')));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']['config'][0] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showInteger("inventory_frequence", $this->getValue('inventory_frequence'), 1, 240);
     echo "</td>";
     echo "<td>" . $LANG['plugin_fusioninventory']["functionalities"][32] . "</td>";
     echo "<td>";
     Dropdown::showInteger("delete_agent_process", $this->getValue('delete_agent_process'), 1, 240);
     echo " " . $LANG['gmt'][1];
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']["functionalities"][26] . " (ex : https://192.168.0.1/glpi)</td>";
     echo "<td>";
     echo "<input type='text' name='URL_agent_conf' size='30' value='" . $this->getValue('URL_agent_conf') . "' />";
     echo "</td>";
     echo "<td>";
     echo "</td>";
     echo "<td>";
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<th colspan='2'>";
     echo $LANG['plugin_fusioninventory']["discovery"][6] . "&nbsp;:";
     echo "</th>";
     echo "<th colspan='2'>";
     echo $LANG['plugin_fusioninventory']["discovery"][6] . " 2&nbsp;:";
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td width='500'>" . $LANG["networking"][14] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("criteria1_ip", $this->isActivated('criteria1_ip'));
     echo "</td>";
     echo "<td width='500'>" . $LANG["networking"][14] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("criteria2_ip", $this->isActivated('criteria2_ip'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["common"][16] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("criteria1_name", $this->isActivated('criteria1_name'));
     echo "</td>";
     echo "<td>" . $LANG["common"][16] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("criteria2_name", $this->isActivated('criteria2_name'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["common"][19] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("criteria1_serial", $this->isActivated('criteria1_serial'));
     echo "</td>";
     echo "<td>" . $LANG["common"][19] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("criteria2_serial", $this->isActivated('criteria2_serial'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['device_iface'][2] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("criteria1_macaddr", $this->isActivated('criteria1_macaddr'));
     echo "</td>";
     echo "<td>" . $LANG['device_iface'][2] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("criteria2_macaddr", $this->isActivated('criteria2_macaddr'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center' colspan='4'>";
     if (PluginFusioninventory::haveRight("configuration", "w")) {
         echo "<input type='hidden' name='tabs' value='config' />";
         echo "<input type='submit' name='update' value=\"" . $LANG["buttons"][2] . "\" class='submit' >";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table></form>";
 }
header("Content-Type: text/html; charset=UTF-8");
header_nocache();
if (!isset($_POST["ID"])) {
    exit;
}
if (!isset($_POST["sort"])) {
    $_POST["sort"] = "";
}
if (!isset($_POST["order"])) {
    $_POST["order"] = "";
}
if (!isset($_POST["withtemplate"])) {
    $_POST["withtemplate"] = "";
}
checkRight("config", "w");
if (PluginFusioninventory::haveRight("configuration", "r")) {
    switch ($_POST['glpi_tab']) {
        case -1:
            $config = new PluginFusioninventoryConfig();
            $config->showForm($_POST['target'], '1');
            $config_modules = new PluginFusioninventoryConfigModules();
            $config_modules->showForm($_POST['target'], '1');
            $history = new PluginFusioninventorySnmphistory();
            $history->showForm($_POST['target'], '1');
            $ptLockable = new PluginFusioninventoryLockable();
            $ptLockable->showForm($_POST['target']);
            break;
        case 2:
            $config_modules = new PluginFusioninventoryConfigModules();
            $config_modules->showForm($_POST['target'], '1');
            break;
 function showForm($target, $ID)
 {
     global $DB, $CFG_GLPI, $LANG;
     $history = new PluginFusioninventorySnmphistory();
     if (!PluginFusioninventory::haveRight("snmp_networking", "r")) {
         return false;
     }
     if (PluginFusioninventory::haveRight("snmp_networking", "w")) {
         $canedit = true;
     } else {
         $canedit = false;
     }
     include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php";
     $this->ID = $ID;
     $nw = new Netwire();
     $CommonItem = new CommonItem();
     $plugin_fusioninventory_snmp = new PluginFusioninventorySNMP();
     echo "<script type='text/javascript' src='" . GLPI_ROOT . "/lib/extjs/adapter/prototype/prototype.js'></script>";
     echo "<script type='text/javascript' src='" . GLPI_ROOT . "/lib/extjs/adapter/prototype/effects.js'></script>";
     if (!($data = $this->find("`FK_networking`='" . $ID . "'", '', 1))) {
         // Add in database if not exist
         $input['FK_networking'] = $ID;
         $ID_tn = $this->add($input);
         $this->getFromDB($ID_tn);
     } else {
         foreach ($data as $ID_tn => $datas) {
             $this->fields = $data[$ID_tn];
         }
     }
     $PID = $this->fields['last_PID_update'];
     // Form networking informations
     echo "<div align='center'>\n            <form method='post' name='snmp_form' id='snmp_form' action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='3'>";
     echo $LANG['plugin_fusioninventory']["snmp"][11];
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["profile"][24] . "</td>";
     echo "<td align='center'>";
     $query_models = "SELECT * \n                       FROM `glpi_plugin_fusioninventory_model_infos`\n                       WHERE `device_type`!='2'\n                             AND `device_type`!='0';";
     $result_models = $DB->query($query_models);
     $exclude_models = array();
     while ($data_models = $DB->fetch_array($result_models)) {
         $exclude_models[] = $data_models['ID'];
     }
     Dropdown::show("PluginFusioninventoryModelInfos", array('name' => "model_infos", 'value' => $this->fields['FK_model_infos'], 'comments' => 0, 'used' => $exclude_models));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["functionalities"][43] . "</td>";
     echo "<td align='center'>";
     PluginFusioninventorySNMP::auth_dropdown($this->fields['FK_snmp_connection']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td>";
     echo " <input type='submit' name='GetRightModel'\n              value='" . $LANG['plugin_fusioninventory']["model_info"][13] . "' class='submit'/></td>";
     echo "<td>";
     echo "<input type='hidden' name='ID' value='" . $ID . "'>";
     echo "<input type='submit' name='update' value=\"" . $LANG["buttons"][7] . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table></form>";
     // Remote action of agent
     $pfit = new PluginFusioninventoryTask();
     $pfit->RemoteStateAgent($target, $ID, NETWORKING_TYPE, array('INVENTORY' => 1));
     // SNMP Informations
     //		echo "<div align='center'>
     echo "<form method='post' name='snmp_form' id='snmp_form'  action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='3'>";
     echo $LANG['plugin_fusioninventory']["title"][1];
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td colspan='2' height='30'>";
     echo $LANG['plugin_fusioninventory']["snmp"][52] . ": " . convDateTime($this->fields['last_fusioninventory_update']);
     echo "</td>";
     echo "</tr>";
     // Get link field to detect if cpu, memory and uptime are get onthis network device
     $Array_Object_TypeNameConstant = $plugin_fusioninventory_snmp->GetLinkOidToFields($ID, NETWORKING_TYPE);
     $mapping_name = array();
     foreach ($Array_Object_TypeNameConstant as $object => $mapping_type_name) {
         $mapping_name[$mapping_type_name] = "1";
     }
     if (isset($mapping_name['uptime']) and $mapping_name['uptime'] == "1") {
         echo "<tr class='tab_bg_1 center'>";
         echo "<td>" . $LANG['plugin_fusioninventory']["snmp"][12] . "</td>";
         echo "<td>";
         $sysUpTime = $this->fields['uptime'];
         if (strstr($sysUpTime, "days")) {
             list($day, $hour, $minute, $sec, $ticks) = sscanf($sysUpTime, "%d days, %d:%d:%d.%d");
         } else {
             if (strstr($sysUpTime, "hours")) {
                 $day = 0;
                 list($hour, $minute, $sec, $ticks) = sscanf($sysUpTime, "%d hours, %d:%d.%d");
             } else {
                 if (strstr($sysUpTime, "minutes")) {
                     $day = 0;
                     $hour = 0;
                     list($minute, $sec, $ticks) = sscanf($sysUpTime, "%d minutes, %d.%d");
                 } else {
                     if ($sysUpTime == "0") {
                         $day = 0;
                         $hour = 0;
                         $minute = 0;
                         $sec = 0;
                     } else {
                         list($hour, $minute, $sec, $ticks) = sscanf($sysUpTime, "%d:%d:%d.%d");
                         $day = 0;
                     }
                 }
             }
         }
         echo "<b>{$day}</b> " . $LANG["stats"][31] . " ";
         echo "<b>{$hour}</b> " . $LANG["job"][21] . " ";
         echo "<b>{$minute}</b> " . $LANG["job"][22] . " ";
         echo " " . strtolower($LANG["rulesengine"][42]) . " <b>{$sec}</b> " . $LANG["stats"][34] . " ";
         echo "</td>";
         echo "</tr>";
     }
     if (isset($mapping_name['cpu']) and $mapping_name['cpu'] == "1" or isset($mapping_name['cpuuser']) and $mapping_name['cpuuser'] == "1" and (isset($mapping_name['cpusystem']) and $mapping_name['cpusystem'] == "1")) {
         echo "<tr class='tab_bg_1 center'>";
         echo "<td>" . $LANG['plugin_fusioninventory']["snmp"][13] . "</td>";
         echo "<td>";
         PluginFusioninventoryDisplay::bar($this->fields['cpu'], '', 'inverse');
         echo "</td>";
         echo "</tr>";
     }
     if (isset($mapping_name['memory']) and $mapping_name['memory'] == "1") {
         echo "<tr class='tab_bg_1 center'>";
         echo "<td>" . $LANG['plugin_fusioninventory']["snmp"][14] . "</td>";
         echo "<td>";
         $query2 = "SELECT *\n                    FROM `glpi_networking`\n                    WHERE `ID`='" . $ID . "';";
         $result2 = $DB->query($query2);
         $data2 = $DB->fetch_assoc($result2);
         if (empty($data2["ram"])) {
             $ram_pourcentage = 0;
         } else {
             $ram_pourcentage = ceil(100 * ($data2["ram"] - $this->fields['memory']) / $data2["ram"]);
         }
         PluginFusioninventoryDisplay::bar($ram_pourcentage, " (" . ($data2["ram"] - $this->fields['memory']) . " Mo / " . $data2["ram"] . " Mo)", 'inverse');
         echo "</td>";
         echo "</tr>";
     }
     echo "</table></form>";
     // ********************************************************************************************** //
     // *********************************** METTRE TABLEAU DES PORTS ********************************* //
     // ********************************************************************************************** //
     function ByteSize($bytes, $sizeoct = 1024)
     {
         $size = $bytes / $sizeoct;
         if ($size < $sizeoct) {
             $size = number_format($size, 0);
             $size .= ' K';
         } else {
             if ($size / $sizeoct < $sizeoct) {
                 $size = number_format($size / $sizeoct, 0);
                 $size .= ' M';
             } else {
                 if ($size / $sizeoct / $sizeoct < $sizeoct) {
                     $size = number_format($size / $sizeoct / $sizeoct, 0);
                     $size .= ' G';
                 } else {
                     if ($size / $sizeoct / $sizeoct / $sizeoct < $sizeoct) {
                         $size = number_format($size / $sizeoct / $sizeoct / $sizeoct, 0);
                         $size .= ' T';
                     }
                 }
             }
         }
         return $size;
     }
     $query = "\n\t\tSELECT *,glpi_plugin_fusioninventory_networking_ports.ifmac as ifmacinternal\n\t\t\n\t\tFROM glpi_plugin_fusioninventory_networking_ports\n\n\t\tLEFT JOIN glpi_networking_ports\n\t\tON glpi_plugin_fusioninventory_networking_ports.FK_networking_ports = glpi_networking_ports.ID \n\t\tWHERE glpi_networking_ports.on_device='" . $ID . "'\n\t\tORDER BY logical_number ";
     echo "<script  type='text/javascript'>\nfunction close_array(id){\n\tdocument.getElementById('plusmoins'+id).innerHTML = '<img src=\\'" . GLPI_ROOT . "/pics/collapse.gif\\''+\n      'onClick=\\'Effect.Fade(\"viewfollowup'+id+'\");appear_array('+id+');\\' />';\n} \nfunction appear_array(id){\n\tdocument.getElementById('plusmoins'+id).innerHTML = '<img src=\\'" . GLPI_ROOT . "/pics/expand.gif\\''+\n      'onClick=\\'Effect.Appear(\"viewfollowup'+id+'\");close_array('+id+');\\' />';\n}\t\t\n\t\t\n\t\t</script>";
     echo "<table class='tab_cadre' cellpadding='5' width='1100'>";
     echo "<tr class='tab_bg_1'>";
     $query_array = "SELECT *\n                      FROM `glpi_display`\n                      WHERE `type`='" . PLUGIN_FUSIONINVENTORY_SNMP_NETWORKING_PORTS . "'\n                            AND `FK_users`='0'\n                      ORDER BY `rank`;";
     $result_array = $DB->query($query_array);
     echo "<th colspan='" . (mysql_num_rows($result_array) + 2) . "'>";
     echo $LANG['plugin_fusioninventory']["snmp"][40];
     $result = $DB->query($query);
     echo ' (' . $DB->numrows($result) . ')';
     if ($_SESSION["glpilanguage"] == "fr_FR") {
         $url_legend = "https://forge.indepnet.net/wiki/fusioninventory/Fr_VI_visualisationsdonnees_2_reseau";
     } else {
         $url_legend = "https://forge.indepnet.net/wiki/fusioninventory/En_VI_visualisationsdonnees_2_reseau";
     }
     echo " <a href='" . $url_legend . "'>[ " . $LANG['plugin_fusioninventory']["functionalities"][6] . " ]</a>";
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo '<th><img alt="Sélectionnez les éléments à afficher par défaut" 
                  title="Sélectionnez les éléments à afficher par défaut"
                  src="' . GLPI_ROOT . '/pics/options_search.png" class="pointer"
                  onclick="var w = window.open(\'' . GLPI_ROOT . '/front/popup.php?popup=search_config&type=5157\' ,\'glpipopup\',
                     \'height=400,
                  width=1000, top=100, left=100, scrollbars=yes\' ); w.focus();"></th>';
     echo "<th>" . $LANG["common"][16] . "</th>";
     $query_array = "SELECT * \n                      FROM `glpi_display`\n                      WHERE `type`='5157'\n                             AND `FK_users`='0'\n                      ORDER BY `rank`;";
     $result_array = $DB->query($query_array);
     while ($data_array = $DB->fetch_array($result_array)) {
         echo "<th>";
         switch ($data_array['num']) {
             case 2:
                 echo $LANG['plugin_fusioninventory']["snmp"][42];
                 break;
             case 3:
                 echo $LANG['plugin_fusioninventory']["snmp"][43];
                 break;
             case 4:
                 echo $LANG['plugin_fusioninventory']["snmp"][44];
                 break;
             case 5:
                 echo $LANG['plugin_fusioninventory']["snmp"][45];
                 break;
             case 6:
                 echo $LANG['plugin_fusioninventory']["snmp"][46];
                 break;
             case 7:
                 echo $LANG['plugin_fusioninventory']["snmp"][47];
                 break;
             case 8:
                 echo $LANG['plugin_fusioninventory']["snmp"][48];
                 break;
             case 9:
                 echo $LANG['plugin_fusioninventory']["snmp"][49];
                 break;
             case 10:
                 echo $LANG['plugin_fusioninventory']["snmp"][51];
                 break;
             case 11:
                 echo $LANG['plugin_fusioninventory']["mapping"][115];
                 break;
             case 12:
                 echo $LANG["networking"][17];
                 break;
             case 13:
                 echo $LANG['plugin_fusioninventory']["snmp"][50];
                 break;
             case 14:
                 echo $LANG["networking"][56];
                 break;
             case 15:
                 echo $LANG['plugin_fusioninventory']["snmp"][41];
                 break;
         }
         echo "</th>";
     }
     echo "</tr>";
     // Fin de l'entête du tableau
     if ($result) {
         while ($data = $DB->fetch_array($result)) {
             $background_img = "";
             if ($data["trunk"] == "1" and (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1"))) {
                 $background_img = " style='background-image: url(\"" . GLPI_ROOT . "/plugins/fusioninventory/pics/port_trunk.png\"); '";
             } else {
                 if ($data["trunk"] == "-1" and (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1"))) {
                     $background_img = " style='background-image: url(\"" . GLPI_ROOT . "/plugins/fusioninventory/pics/multiple_mac_addresses.png\"); '";
                 } else {
                     if (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1")) {
                         $background_img = " style='background-image: url(\"" . GLPI_ROOT . "/plugins/fusioninventory/pics/connected_trunk.png\"); '";
                     }
                 }
             }
             echo "<tr class='tab_bg_1 center' height='40'" . $background_img . ">";
             echo "<td id='plusmoins" . $data["ID"] . "'><img src='" . GLPI_ROOT . "/pics/expand.gif' onClick='Effect.Appear(\"viewfollowup" . $data["ID"] . "\");close_array(" . $data["ID"] . ");' /></td>";
             echo "<td><a href='networking.port.php?ID=" . $data["ID"] . "'>" . $data["name"] . "</a></td>";
             $query_array = "SELECT *\n                            FROM `glpi_display`\n                            WHERE `type`='5157'\n                                  AND `FK_users`='0'\n                            ORDER BY `rank`;";
             $result_array = $DB->query($query_array);
             while ($data_array = $DB->fetch_array($result_array)) {
                 switch ($data_array['num']) {
                     case 2:
                         echo "<td>" . $data["ifmtu"] . "</td>";
                         break;
                     case 3:
                         echo "<td>" . ByteSize($data["ifspeed"], 1000) . "bps</td>";
                         break;
                     case 4:
                         echo "<td>";
                         if (strstr($data["ifstatus"], "up") or strstr($data["ifinternalstatus"], "1")) {
                             echo "<img src='" . GLPI_ROOT . "/pics/greenbutton.png'/>";
                         } else {
                             if (strstr($data["ifstatus"], "down") or strstr($data["ifinternalstatus"], "2")) {
                                 echo "<img src='" . GLPI_ROOT . "/pics/redbutton.png'/>";
                             } else {
                                 if (strstr($data["ifstatus"], "testing") or strstr($data["ifinternalstatus"], "3")) {
                                     echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/yellowbutton.png'/>";
                                 }
                             }
                         }
                         echo "</td>";
                         break;
                     case 5:
                         echo "<td>" . $data["iflastchange"] . "</td>";
                         break;
                     case 6:
                         echo "<td>";
                         if ($data["ifinoctets"] == "0") {
                             echo "-";
                         } else {
                             echo ByteSize($data["ifinoctets"], 1000) . "o";
                         }
                         echo "</td>";
                         break;
                     case 7:
                         if ($data["ifinerrors"] == "0") {
                             echo "<td>-";
                         } else {
                             echo "<td background='#cf9b9b' class='tab_bg_1_2'>";
                             echo $data["ifinerrors"];
                         }
                         echo "</td>";
                         break;
                     case 8:
                         echo "<td>";
                         if ($data["ifinoctets"] == "0") {
                             echo "-";
                         } else {
                             echo ByteSize($data["ifoutoctets"], 1000) . "o";
                         }
                         echo "</td>";
                         break;
                     case 9:
                         if ($data["ifouterrors"] == "0") {
                             echo "<td>-";
                         } else {
                             echo "<td background='#cf9b9b' class='tab_bg_1_2'>";
                             echo $data["ifouterrors"];
                         }
                         echo "</td>";
                         break;
                     case 10:
                         echo "<td>" . $data["portduplex"] . "</td>";
                         break;
                     case 11:
                         // ** internal mac
                         echo "<td>" . $data["ifmac"] . "</td>";
                         break;
                     case 12:
                         // ** Mac address and link to device which are connected to this port
                         $opposite_port = $nw->getOppositeContact($data["FK_networking_ports"]);
                         if ($opposite_port != "") {
                             $query_device = "SELECT * \n                                         FROM `glpi_networking_ports`\n                                         WHERE `ID`='" . $opposite_port . "';";
                             $result_device = $DB->query($query_device);
                             $data_device = $DB->fetch_assoc($result_device);
                             $CommonItem->getFromDB($data_device["device_type"], $data_device["on_device"]);
                             $link1 = $CommonItem->getLink(1);
                             $link = str_replace($CommonItem->getName(0), $data_device["ifmac"], $CommonItem->getLink());
                             $link2 = str_replace($CommonItem->getName(0), $data_device["ifaddr"], $CommonItem->getLink());
                             if ($data_device["device_type"] == PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN) {
                                 if ($CommonItem->getField("accepted") == "1") {
                                     echo "<td style='background:#bfec75'\n                                        class='tab_bg_1_2'>" . $link1;
                                 } else {
                                     echo "<td background='#cf9b9b'\n                                        class='tab_bg_1_2'>" . $link1;
                                 }
                                 if (!empty($link)) {
                                     echo "<br/>" . $link;
                                 }
                                 if (!empty($link2)) {
                                     echo "<br/>" . $link2;
                                 }
                                 echo "</td>";
                             } else {
                                 echo "<td>" . $link1;
                                 if (!empty($link)) {
                                     echo "<br/>" . $link;
                                 }
                                 if (!empty($link2)) {
                                     echo "<br/>" . $link2;
                                 }
                                 echo "</td>";
                             }
                         } else {
                             echo "<td></td>";
                         }
                         break;
                     case 13:
                         // ** Connection status
                         echo "<td>";
                         if (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1")) {
                             echo "<img src='" . GLPI_ROOT . "/pics/greenbutton.png'/>";
                         } else {
                             if (strstr($data["ifstatus"], "down") or strstr($data["ifstatus"], "2")) {
                                 echo "<img src='" . GLPI_ROOT . "/pics/redbutton.png'/>";
                             } else {
                                 if (strstr($data["ifstatus"], "testing") or strstr($data["ifstatus"], "3")) {
                                     echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/yellowbutton.png'/>";
                                 } else {
                                     if (strstr($data["ifstatus"], "dormant") or strstr($data["ifstatus"], "5")) {
                                         echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/orangebutton.png'/>";
                                     }
                                 }
                             }
                         }
                         echo "</td>";
                         break;
                     case 14:
                         echo "<td>";
                         $canedit = haveRight("networking", "w");
                         $used = array();
                         $query_vlan = "SELECT * FROM glpi_networking_vlan WHERE FK_port='" . $data["ID"] . "'";
                         $result_vlan = $DB->query($query_vlan);
                         if ($DB->numrows($result_vlan) > 0) {
                             echo "<table cellpadding='0' cellspacing='0'>";
                             while ($line = $DB->fetch_array($result_vlan)) {
                                 $used[] = $line["FK_vlan"];
                                 $a_vlan = Dropdown::getDropdownName("glpi_dropdown_vlan", $line["FK_vlan"], 1);
                                 echo "<tr><td>" . $a_vlan['name'] . " [" . $a_vlan['comments'] . "]";
                                 echo "</td><td>";
                                 if ($canedit) {
                                     echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?unassign_vlan=unassigned&amp;ID=" . $line["ID"] . "'>";
                                     echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/delete2.png\" alt='" . $LANG['buttons'][6] . "' title='" . $LANG['buttons'][6] . "'></a>";
                                 } else {
                                     echo "&nbsp;";
                                 }
                                 echo "</td></tr>";
                             }
                             echo "</table>";
                         } else {
                             echo "&nbsp;";
                         }
                         echo "</td>";
                         break;
                     case 15:
                         //Port description
                         echo "<td>" . $data["ifdescr"] . "</td>";
                         break;
                 }
             }
             echo "</tr>";
             // Historique
             echo "\n\t\t\t\t<tr style='display: none;' id='viewfollowup" . $data["ID"] . "'>\n\t\t\t\t\t<td colspan='" . (mysql_num_rows($result_array) + 2) . "'>" . PluginFusioninventorySnmphistory::showHistory($data["ID"]) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t";
         }
     }
     echo "</table>";
 }
Exemplo n.º 14
0
                        $importexport->importMass();
                        glpi_header($_SERVER['HTTP_REFERER']);
                    }
                }
            }
        }
    }
}
if (isset($_POST["add_oid"])) {
    PluginFusioninventoryAuth::checkRight("snmp_models", "w");
    $plugin_fusioninventory_mib_networking->add($_POST);
    glpi_header($_SERVER['HTTP_REFERER']);
}
if (PluginFusioninventory::HaveRight("snmp_models", "r")) {
    $importexport->showForm($_SERVER["PHP_SELF"]);
    $importexport->showFormMassImport($_SERVER["PHP_SELF"]);
}
$ID = "";
if (isset($_GET["ID"])) {
    $ID = $_GET["ID"];
}
if (!empty($_POST["item_coche"])) {
    PluginFusioninventoryAuth::checkRight("snmp_models", "w");
    $plugin_fusioninventory_mib_networking->deleteMib($_POST["item_coche"]);
    glpi_header($_SERVER['HTTP_REFERER']);
}
if (PluginFusioninventory::HaveRight("snmp_models", "r")) {
    $plugin_fusioninventory_model_infos->showForm($_SERVER["PHP_SELF"], $ID);
    $plugin_fusioninventory_mib_networking->showForm($_SERVER["PHP_SELF"], $ID);
}
commonFooter();
Exemplo n.º 15
0
 function RemoteStateAgent($target, $ID, $type, $a_modules = array())
 {
     global $LANG, $CFG_GLPI;
     $ptcm = new PluginFusioninventoryConfigModules();
     $pfia = new PluginFusioninventoryAgents();
     if (!$ptcm->isActivated('remotehttpagent') and !PluginFusioninventory::haveRight("remotecontrol", "w")) {
         return;
     }
     if ($type == PLUGIN_FUSIONINVENTORY_SNMP_AGENTS) {
         $pfia->getFromDB($ID);
         $on_device = $ID;
     } else {
         if ($type == COMPUTER_TYPE) {
             $agentlist = $pfia->find("on_device='" . $ID . "'", "", "1");
             foreach ($agentlist as $data) {
                 $pfia->getFromDB($data['ID']);
                 $on_device = $pfia->fields['on_device'];
             }
         } else {
             if ($type == NETWORKING_TYPE or $type == PRINTER_TYPE) {
                 $on_device = $ID;
             }
         }
     }
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.state.php\">";
     echo "<table  class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='2'>";
     echo $LANG['plugin_fusioninventory']["agents"][14];
     echo " : </th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' align='center'>";
     $array_actions = array();
     $array_actions[""] = "------";
     switch ($type) {
         case NETWORKING_TYPE:
         case PRINTER_TYPE:
             if (isset($a_modules["INVENTORY"]) and $ptcm->getValue("snmp") == '1') {
                 $array_actions["INVENTORY"] = $LANG['plugin_fusioninventory']['config'][3];
             }
             break;
         case PLUGIN_FUSIONINVENTORY_SNMP_AGENTS:
         case COMPUTER_TYPE:
             if (isset($a_modules["INVENTORY"]) and $ptcm->getValue("inventoryocs") == '1' and isset($pfia->fields['module_inventory']) and $pfia->fields['module_inventory'] == '1' or isset($a_modules["INVENTORY"]) and $ptcm->getValue("snmp") == '1' and isset($pfia->fields['module_snmpquery']) and $pfia->fields['module_snmpquery'] == '1') {
                 $array_actions["INVENTORY"] = $LANG['plugin_fusioninventory']['config'][3];
             }
             if (isset($a_modules["WAKEONLAN"]) and $ptcm->getValue("wol") == '1') {
                 // Code for PLUGIN_FUSIONINVENTORY_SNMP_AGENTS if  ($pfia->fields['module_wakeonlan'] == '1')
                 // so :
                 if ($type == COMPUTER_TYPE) {
                     $array_actions["WAKEONLAN"] = $LANG['plugin_fusioninventory']['config'][6];
                 }
             }
             break;
     }
     //      if ((isset($a_modules["NETDISCOVERY"])) AND ($ptcm->getValue("netdiscovery") == '1') AND ($pfia->fields['module_netdiscovery'] == '1')) {
     //         $array_actions["NETDISCOVERY"] = $LANG['plugin_fusioninventory']['config'][4];
     //      }
     //      if ((isset($a_modules["SNMPQUERY"])) AND ($ptcm->getValue("snmp") == '1') AND ($pfia->fields['module_snmpquery'] == '1')) {
     //         $array_actions["SNMPQUERY"] = $LANG['plugin_fusioninventory']['config'][7];
     //      }
     $rand = Dropdown::showFromArray("agentaction", $array_actions);
     echo "</td>";
     echo "</tr>";
     if (!isset($on_device)) {
         $on_device = $ID;
     }
     $params = array('action' => '__VALUE__', 'on_device' => $on_device, 'device_type' => $type);
     ajaxUpdateItemOnSelectEvent("dropdown_agentaction{$rand}", "updateAgentState_{$rand}", $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/ajax/agentsState.php", $params, false);
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' align='center'>";
     echo "<span id='updateAgentState_{$rand}'>\n";
     echo "&nbsp;";
     echo "</span>\n";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td align='center'>";
     echo "<input type='hidden' name='on_device' value='" . $ID . "'/>";
     echo "<input type='hidden' name='device_type' value='" . $type . "'/>";
     echo "<input type='submit' name='startagent' value=\"" . $LANG['plugin_fusioninventory']["task"][12] . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</form>";
     echo "</div>";
 }
PluginFusioninventoryAuth::checkRight("snmp_authentification", "r");
$plugin_fusioninventory_snmp_auth = new PluginFusioninventorySnmpauth();
$config = new PluginFusioninventoryConfig();
commonHeader($LANG['plugin_fusioninventory']["title"][0], $_SERVER["PHP_SELF"], "plugins", "fusioninventory", "snmp_auth");
PluginFusioninventoryDisplay::mini_menu();
if (isset($_POST["add"])) {
    PluginFusioninventoryAuth::checkRight("snmp_authentification", "w");
    if ($config->getValue("authsnmp") == "file") {
        $new_ID = $plugin_fusioninventory_snmp_auth->add_xml();
    } else {
        if ($config->getValue("authsnmp") == "DB") {
            $new_ID = $plugin_fusioninventory_snmp_auth->add($_POST);
        }
    }
    $_SESSION["MESSAGE_AFTER_REDIRECT"] = "Import effectué avec succès : <a href='snmp_auth.php?ID=" . $new_ID . "'>" . $_POST["name"] . "</a>";
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["update"])) {
        PluginFusioninventoryAuth::checkRight("snmp_authentification", "w");
        $plugin_fusioninventory_snmp_auth->update($_POST);
        glpi_header($_SERVER['HTTP_REFERER']);
    }
}
$ID = "";
if (isset($_GET["ID"])) {
    $ID = $_GET["ID"];
}
if (PluginFusioninventory::HaveRight("snmp_authentification", "r")) {
    $plugin_fusioninventory_snmp_auth->showForm($_SERVER["PHP_SELF"], $ID);
}
commonFooter();
 function showForm($target, $ID)
 {
     global $LANG, $CFG_GLPI;
     echo "<form method='post' name='functionalities_form' id='functionalities_form'  action='" . $target . "'>";
     echo "<table class='tab_cadre_fixe' cellpadding='5'>";
     echo "<tr>";
     echo "<th colspan='4'>";
     echo $LANG['plugin_fusioninventory']['config'][1] . "&nbsp;:";
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td width='30%'>" . $LANG['plugin_fusioninventory']['config'][2] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("snmp", $this->isActivated('snmp'));
     echo "</td>";
     echo "<td width='20%'>" . $LANG['plugin_fusioninventory']['config'][4] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("netdiscovery", $this->isActivated('netdiscovery'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']['config'][3] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("inventoryocs", $this->isActivated('inventoryocs'));
     echo "</td>";
     echo "<td>" . $LANG['plugin_fusioninventory']['config'][5] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("remotehttpagent", $this->isActivated('remotehttpagent'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']['config'][6] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("wol", $this->isActivated('wol'));
     echo "</td>";
     echo "<td colspan='2'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td align='center' colspan='4'>";
     if (PluginFusioninventory::haveRight("configuration", "w")) {
         echo "<input type='hidden' name='tabs' value='configmodules' />";
         echo "<input type='submit' name='update' value=\"" . $LANG["buttons"][2] . "\" class='submit' >";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table></form>";
 }
Exemplo n.º 18
0
function plugin_fusioninventory_haveTypeRight($type, $right)
{
    switch ($type) {
        case PLUGIN_FUSIONINVENTORY_ERROR_TYPE:
            return PluginFusioninventory::haveRight("errors", $right);
            break;
    }
    return true;
}
 function showForm($target, $ID)
 {
     global $LANG, $DB;
     echo "<form method='post' name='functionalities_form' id='functionalities_form'\n                  action='" . $target . "'>";
     echo "<table class='tab_cadre_fixe' cellpadding='2'>";
     echo "<tr>";
     echo "<th colspan='3'>";
     echo $LANG['plugin_fusioninventory']["functionalities"][28] . " :";
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='3'>";
     echo $LANG['plugin_fusioninventory']["functionalities"][29] . " :";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php";
     $options = "";
     foreach ($FUSIONINVENTORY_MAPPING as $type => $mapping43) {
         if (isset($FUSIONINVENTORY_MAPPING[$type])) {
             foreach ($FUSIONINVENTORY_MAPPING[$type] as $name => $mapping) {
                 $listName[$type . "-" . $name] = $FUSIONINVENTORY_MAPPING[$type][$name]["name"];
             }
         }
     }
     if (!empty($listName)) {
         asort($listName);
     }
     // Get list of fields configured for history
     $query = "SELECT *\n                FROM `glpi_plugin_fusioninventory_config_snmp_history`;";
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             list($type, $name) = explode("-", $data['field']);
             if (!isset($FUSIONINVENTORY_MAPPING[$type][$name]["name"])) {
                 $query_del = "DELETE FROM `glpi_plugin_fusioninventory_config_snmp_history`\n                  WHERE id='" . $data['id'] . "' ";
                 $DB->query($query_del);
             } else {
                 $options[$data['field']] = $FUSIONINVENTORY_MAPPING[$type][$name]["name"];
             }
             unset($listName[$data['field']]);
         }
     }
     if (!empty($options)) {
         asort($options);
     }
     echo "<td class='right' width='350'>";
     if (count($listName)) {
         echo "<select name='plugin_fusioninventory_extraction_to_add[]' multiple size='15'>";
         foreach ($listName as $key => $val) {
             //list ($item_type, $item) = explode("_", $key);
             echo "<option value='{$key}'>" . $val . "</option>\n";
         }
         echo "</select>";
     }
     echo "</td><td class='center'>";
     if (count($listName)) {
         if (PluginFusioninventory::haveRight("configuration", "w")) {
             echo "<input type='submit'  class=\"submit\" name='plugin_fusioninventory_extraction_add' value='" . $LANG["buttons"][8] . " >>'>";
         }
     }
     echo "<br /><br />";
     if (!empty($options)) {
         if (PluginFusioninventory::haveRight("configuration", "w")) {
             echo "<input type='submit'  class=\"submit\" name='plugin_fusioninventory_extraction_delete' value='<< " . $LANG["buttons"][6] . "'>";
         }
     }
     echo "</td><td class='left'>";
     if (!empty($options)) {
         echo "<select name='plugin_fusioninventory_extraction_to_delete[]' multiple size='15'>";
         foreach ($options as $key => $val) {
             //list ($item_type, $item) = explode("_", $key);
             echo "<option value='{$key}'>" . $val . "</option>\n";
         }
         echo "</select>";
     } else {
         echo "&nbsp;";
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<th colspan='3'>";
     echo $LANG['plugin_fusioninventory']["functionalities"][60] . " :";
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='3' class='center'>";
     if (PluginFusioninventory::haveRight("configuration", "w")) {
         echo "<input type='submit' class=\"submit\" name='Clean_history' value='" . $LANG['buttons'][53] . "' >";
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<th colspan='3'>";
     echo "&nbsp;";
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td align='center' colspan='3'>";
     if (PluginFusioninventory::haveRight("configuration", "w")) {
         echo "<input type='hidden' name='tabs' value='history' />";
         echo "<input type='submit' name='update' value=\"" . $LANG["buttons"][2] . "\" class='submit' >";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table></form>";
 }
 function showForm($target, $ID = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     PluginFusioninventoryAuth::checkRight("snmp_networking", "r");
     $CommonItem = new CommonItem();
     if ($ID != '') {
         $this->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . $target . "\">";
     echo "<table  class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>";
     echo $LANG['plugin_fusioninventory']["menu"][4] . " ( " . $LANG['plugin_fusioninventory']["unknown"][3] . " ";
     $CommonItem->getFromDB(PLUGIN_FUSIONINVENTORY_SNMP_AGENTS, $this->fields["FK_agent"]);
     echo $CommonItem->getLink(1);
     echo ") :</th></tr>";
     $datestring = $LANG["common"][26] . ": ";
     $date = convDateTime($this->fields["date_mod"]);
     echo "<tr>";
     echo "<th align='center' width='450' colspan='2'>";
     echo $LANG["common"][2] . " " . $this->fields["ID"];
     echo "</th>";
     echo "<th align='center' colspan='2' width='50'>";
     echo $datestring . $date;
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG["common"][16] . " :</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='name' value='" . $this->fields["name"] . "' size='35'/>";
     echo "</td>";
     if (isMultiEntitiesMode()) {
         echo "<td align='center'>" . $LANG['entity'][0] . " : </td>";
         echo "</td>";
         echo "<td align='center'>";
         Dropdown::show("Entity", array('name' => 'FK_entities', 'value' => $this->fields["FK_entities"]));
         echo "</td>";
         echo "</tr>";
         echo "</tr>";
     } else {
         echo "<td align='center'></td>";
         echo "</td>";
         echo "<td align='center'></td>";
         echo "</tr>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][0] . " :</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='dnsname' value='" . $this->fields["dnsname"] . "' size='35'/>";
     echo "</td>";
     echo "<td align='center'>" . $LANG['common'][18] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='contact' value='" . $this->fields["contact"] . "' size='35'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['common'][17] . " :</td>";
     echo "<td align='center'>";
     $type_list[] = COMPUTER_TYPE;
     $type_list[] = NETWORKING_TYPE;
     $type_list[] = PRINTER_TYPE;
     $type_list[] = PERIPHERAL_TYPE;
     $type_list[] = PHONE_TYPE;
     // GENERIC OBJECT : Search types in generic object
     $plugin = new Plugin();
     if ($plugin->isActivated('genericobject')) {
         if (TableExists("glpi_plugin_genericobject_types")) {
             $query = "SELECT * FROM `glpi_plugin_genericobject_types`\n                  WHERE `status`='1' ";
             if ($result = $DB->query($query)) {
                 while ($data = $DB->fetch_array($result)) {
                     $type_list[] = $data['device_type'];
                 }
             }
         }
     }
     // END GENERIC OBJECT
     Device::dropdownTypes('type', $this->fields["type"], $type_list);
     echo "</td>";
     echo "<td align='center'>" . $LANG['setup'][89] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     Dropdown::show("Domain", array('name' => "domain", 'value' => $this->fields["domain"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['common'][15] . " :</td>";
     echo "<td align='center'>";
     Dropdown::show("Location", array('name' => "location", 'value' => $this->fields["location"]));
     echo "</td>";
     echo "<td align='center'>" . $LANG['common'][19] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='serial' value='" . $this->fields["serial"] . "' size='35'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][2] . " :</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("accepted", $this->fields["accepted"]);
     echo "</td>";
     echo "<td align='center'>" . $LANG['common'][20] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='otherserial' value='" . $this->fields["otherserial"] . "' size='35'/>";
     echo "</td>";
     echo "</tr>";
     if (!empty($this->fields["ifaddr"]) or !empty($this->fields["ifmac"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>" . $LANG['networking'][14] . " :</td>";
         echo "<td align='center'>";
         echo "<input type='text' name='otherserial' value='" . $this->fields["ifaddr"] . "' size='35'/>";
         echo "</td>";
         echo "<td align='center'>" . $LANG['networking'][15] . " : </td>";
         echo "</td>";
         echo "<td align='center'>";
         echo "<input type='text' name='otherserial' value='" . $this->fields["ifmac"] . "' size='35'/>";
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["functionalities"][3] . " :</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("snmp", $this->fields["snmp"]);
     echo "</td>";
     if ($this->fields["snmp"] == "1") {
         echo "<td align='center'>" . $LANG['plugin_fusioninventory']["model_info"][4] . " : </td>";
         echo "</td>";
         echo "<td align='center'>";
         Dropdown::show("PluginFusioninventoryModelInfos", array('name' => "FK_model_infos", 'value' => $this->fields["FK_model_infos"]));
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>" . $LANG['plugin_fusioninventory']["model_info"][3] . " :</td>";
         echo "<td align='center'>";
         Dropdown::show("PluginFusioninventorySnmpauth", array('name' => "FK_snmp_connection", 'value' => $this->fields["FK_snmp_connection"]));
         echo "</td>";
     }
     echo "<td align='center'>" . $LANG['common'][25] . " : </td>";
     echo "</td>";
     echo "<td align='middle'>";
     echo "<textarea  cols='50' rows='5' name='comments' >" . $this->fields["comments"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][4] . " :</td>";
     echo "<td align='center'>";
     echo Dropdown::getYesNo($this->fields["hub"]);
     echo "</td>";
     echo "<td align='center' colspan='2'></td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td class='tab_bg_2' align='center' colspan='4'>\n";
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td width='33%' align='center'>";
     echo "<input type='hidden' name='ID' value={$ID}>";
     echo "<input type='submit' name='import' value=\"" . $LANG['buttons'][37] . "\" class='submit'>";
     echo "</td>";
     echo "<td width='33%' align='center'>";
     echo "<input type='hidden' name='ID' value={$ID}>";
     echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
     echo "</td>";
     echo "<td width='33%' align='center'>";
     echo "<input type='hidden' name='ID' value={$ID}>";
     echo "<div class='center'>";
     if (PluginFusioninventory::haveRight("unknowndevices", "w")) {
         if (!$this->fields["deleted"]) {
             echo "<input type='submit' name='delete' value=\"" . $LANG['buttons'][6] . "\" class='submit'>";
         } else {
             echo "<input type='submit' name='restore' value=\"" . $LANG['buttons'][21] . "\" class='submit'>";
             echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='purge' value=\"" . $LANG['buttons'][22] . "\" class='submit'>";
         }
     }
     echo "</div>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</td>";
     echo "</tr>";
     echo "</table></form></div>";
 }
 function showForm($target, $ID = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     if ($ID != '') {
         $this->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     $this->showTabs($ID, "", $_SESSION['glpi_tab']);
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'><tr><th colspan='2'>";
     echo $LANG['plugin_fusioninventory']["rangeip"][2];
     echo " :</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG["common"][16] . "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='name' value='" . $this->fields["name"] . "'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["rangeip"][0] . "</td>";
     echo "<td align='center'>";
     if (empty($this->fields["ifaddr_start"])) {
         $this->fields["ifaddr_start"] = "...";
     }
     $ipexploded = explode(".", $this->fields["ifaddr_start"]);
     $i = 0;
     foreach ($ipexploded as $ipnum) {
         if ($ipnum > 255) {
             $ipexploded[$i] = '';
         }
         $i++;
     }
     echo "<input type='text' value='" . $ipexploded[0] . "' name='ifaddr_start0' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[1] . "' name='ifaddr_start1' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[2] . "' name='ifaddr_start2' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[3] . "' name='ifaddr_start3' size='3' maxlength='3' >";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["rangeip"][1] . "</td>";
     echo "<td align='center'>";
     unset($ipexploded);
     if (empty($this->fields["ifaddr_end"])) {
         $this->fields["ifaddr_end"] = "...";
     }
     $ipexploded = explode(".", $this->fields["ifaddr_end"]);
     $i = 0;
     foreach ($ipexploded as $ipnum) {
         if ($ipnum > 255) {
             $ipexploded[$i] = '';
         }
         $i++;
     }
     echo "<input type='text' value='" . $ipexploded[0] . "' name='ifaddr_end0' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[1] . "' name='ifaddr_end1' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[2] . "' name='ifaddr_end2' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[3] . "' name='ifaddr_end3' size='3' maxlength='3' >";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["agents"][12] . "</td>";
     echo "<td align='center'>";
     Dropdown::show("PluginFusioninventoryAgents", array('name' => "FK_fusioninventory_agents_discover", 'value' => $this->fields["FK_fusioninventory_agents_discover"], 'comments' => false));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["agents"][13] . "</td>";
     echo "<td align='center'>";
     Dropdown::show("PluginFusioninventoryAgents", array('name' => "FK_fusioninventory_agents_query", 'value' => $this->fields["FK_fusioninventory_agents_query"], 'comments' => false));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["discovery"][3] . "</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("discover", $this->fields["discover"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["rangeip"][3] . "</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("query", $this->fields["query"]);
     echo "</td>";
     echo "</tr>";
     if (isMultiEntitiesMode()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>" . $LANG['entity'][0] . "</td>";
         echo "<td align='center'>";
         Dropdown::show('Entity', array('name' => 'FK_entities', 'value' => $this->fields["FK_entities"]));
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'><td align='center' colspan='3'>";
     if (PluginFusioninventory::haveRight("rangeip", "w")) {
         if ($ID == '') {
             echo "<div align='center'><input type='submit' name='add' value=\"" . $LANG["buttons"][8] . "\" class='submit' >";
         } else {
             echo "<input type='hidden' name='ID' value='" . $ID . "'/>";
             echo "<div align='center'><input type='submit' name='update' value=\"" . $LANG["buttons"][7] . "\" class='submit' >";
             echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='delete' value=\"" . $LANG["buttons"][6] . "\" class='submit'>";
         }
     }
     echo "</td></tr>";
     echo "</table></form></div>";
 }
 function showFormMassImport($target)
 {
     global $DB, $CFG_GLPI, $LANG;
     PluginFusioninventoryAuth::checkRight("snmp_models", "r");
     echo "<form action='" . $target . "?add=1' method='post' enctype='multipart/form-data'>";
     echo "<table class='tab_cadre' cellpadding='1' width='600'><tr><th>";
     echo $LANG['plugin_fusioninventory']["model_info"][15] . " :</th></tr>";
     echo "\t<tr class='tab_bg_1'>";
     echo "<td align='center'>";
     echo $LANG['plugin_fusioninventory']["model_info"][16] . "<br/>";
     echo "<input type='hidden' name='massimport' value='1'/>";
     if (PluginFusioninventory::haveRight("snmp_models", "w")) {
         echo "&nbsp;<input type='submit' value='" . $LANG["buttons"][37] . "' class='submit'/>";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</form>";
 }
 static function mini_menu()
 {
     global $CFG_GLPI, $LANG;
     $width = "50";
     echo "<div align='center'>\n         <table class='tab_cadre'>";
     //	echo "<tr><th colspan='8'>".$LANG['plugin_fusioninventory']["menu"][3]."</th></tr>";
     echo "<tr class='tab_bg_1'><td align='center' width='" . $width . "' height='40'>";
     if (PluginFusioninventory::haveRight("snmp_models", "r")) {
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/models.php'>\n            <img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/menu_mini_models.png'\n                onmouseout=\"cleanhide('menu_mini_models')\"\n                onmouseover=\"cleandisplay('menu_mini_models')\" /></a>";
     }
     echo "<span class='over_link' id='menu_mini_models'>" . $LANG['plugin_fusioninventory']["model_info"][4] . "</span>";
     echo "</td>";
     echo "<td align='center' width='" . $width . "' height='40'>";
     if (PluginFusioninventory::haveRight("snmp_authentification", "r")) {
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/snmp_auth.php'>\n            <img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/menu_mini_authentification.png'\n                onmouseout=\"cleanhide('menu_mini_authentification')\"\n                onmouseover=\"cleandisplay('menu_mini_authentification')\" /></a>";
     }
     echo "<span class='over_link' id='menu_mini_authentification'>" . $LANG['plugin_fusioninventory']["model_info"][3] . "</span>";
     echo "</td>";
     echo "<td align='center' width='" . $width . "' height='40'>";
     if (PluginFusioninventory::haveRight("rangeip", "r")) {
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/rangeip.php'>\n         <img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/menu_mini_rangeip.png'\n                onmouseout=\"cleanhide('menu_mini_rangeip')\"\n                onmouseover=\"cleandisplay('menu_mini_rangeip')\" /></a>";
     }
     echo "<span class='over_link' id='menu_mini_rangeip'>" . $LANG['plugin_fusioninventory']["menu"][2] . "</span>";
     echo "</td>";
     echo "<td align='center' width='" . $width . "' height='40'>";
     if (PluginFusioninventory::haveRight("agents", "r")) {
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/agents.php'>\n         <img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/menu_mini_agents.png'\n                onmouseout=\"cleanhide('menu_mini_agents')\"\n                onmouseover=\"cleandisplay('menu_mini_agents')\" /></a>";
     }
     echo "<span class='over_link' id='menu_mini_agents'>" . $LANG['plugin_fusioninventory']["menu"][1] . "</span>";
     echo "</td>";
     echo "<td align='center' width='" . $width . "' height='40'>";
     if (PluginFusioninventory::haveRight("remotecontrol", "r")) {
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/task.php'>\n            <img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/menu_mini_task.png'\n                onmouseout=\"cleanhide('menu_mini_task')\"\n                onmouseover=\"cleandisplay('menu_mini_task')\" /></a>";
     }
     echo "<span class='over_link' id='menu_mini_task'>" . $LANG['plugin_fusioninventory']["task"][1] . "</span>";
     echo "</td>";
     echo "<td align='center' width='" . $width . "' height='40'>";
     if (PluginFusioninventory::haveRight("agentsprocesses", "r")) {
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/agents.processes.form.php'>\n         <img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/menu_mini_info_agents.png'\n                onmouseout=\"cleanhide('menu_mini_info_agents')\"\n                onmouseover=\"cleandisplay('menu_mini_info_agents')\" /></a>";
     }
     echo "<span class='over_link' id='menu_mini_info_agents'>" . $LANG['plugin_fusioninventory']["processes"][19] . "</span>";
     echo "</td>";
     echo "<td align='center' width='" . $width . "' height='40'>";
     if (PluginFusioninventory::haveRight("unknowndevices", "r")) {
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/unknown.php'>\n            <img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/menu_mini_unknown_device.png'\n                onmouseout=\"cleanhide('menu_mini_unknown')\"\n                onmouseover=\"cleandisplay('menu_mini_unknown')\" /></a>";
     }
     echo "<span class='over_link' id='menu_mini_unknown'>" . $LANG['plugin_fusioninventory']["menu"][4] . "</span>";
     echo "</td>";
     echo "<td align='center' width='" . $width . "' height='40'>";
     if (PluginFusioninventory::haveRight("reports", "r")) {
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/report.php'>\n         <img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/menu_mini_rapports.png'\n                onmouseout=\"cleanhide('menu_mini_rapports')\"\n                onmouseover=\"cleandisplay('menu_mini_rapports')\" /></a>";
     }
     echo "<span class='over_link' id='menu_mini_rapports'>" . $LANG['plugin_fusioninventory']["processes"][20] . "</span>";
     echo "</td>";
     echo "</tr>";
     echo "</table></div>";
     echo "<table>\n         <tr>\n            <td height='2'></td>\n         </tr>\n      </table>";
 }
 function showForm($target, $ID = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     PluginFusioninventoryAuth::checkRight("snmp_authentification", "r");
     if ($ID != '') {
         $this->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     $this->showTabs($ID, "", $_SESSION['glpi_tab']);
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'><tr><th colspan='2'>";
     echo $ID == '' ? $LANG['plugin_fusioninventory']["model_info"][7] : $LANG['plugin_fusioninventory']["model_info"][3];
     echo " :</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG["common"][16] . "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='name' value='" . $this->fields["name"] . "'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["model_info"][2] . "</td>";
     echo "<td align='center'>";
     Dropdown::show("PluginFusioninventorySnmpversion", array('name' => "FK_snmp_version", 'value' => $this->fields["FK_snmp_version"], 'comments' => false));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["snmpauth"][1] . "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='community' value='" . $this->fields["community"] . "'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["snmpauth"][2] . "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='sec_name' value='" . $this->fields["sec_name"] . "'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["snmpauth"][4] . "</td>";
     echo "<td align='center'>";
     Dropdown::show("PluginFusioninventorySnmpprotocolauth", array('name' => "auth_protocol", 'value' => $this->fields["auth_protocol"], 'comments' => false));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["snmpauth"][5] . "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='auth_passphrase'\n                   value='" . $this->fields["auth_passphrase"] . "'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["snmpauth"][6] . "</td>";
     echo "<td align='center'>";
     Dropdown::show("PluginFusioninventorySnmpprotocolpriv", array('name' => "priv_protocol", 'value' => $this->fields["priv_protocol"], 'comments' => false));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["snmpauth"][7] . "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='priv_passphrase'\n                   value='" . $this->fields["priv_passphrase"] . "'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'><td colspan='2'>";
     if (PluginFusioninventory::haveRight("snmp_authentification", "w")) {
         if ($ID == '') {
             echo "<div align='center'><input type='submit' name='add'\n                       value=\"" . $LANG["buttons"][8] . "\" class='submit' >";
         } else {
             echo "<input type='hidden' name='ID' value='" . $ID . "'/>";
             echo "<div align='center'><input type='submit' name='update'\n                       value=\"" . $LANG["buttons"][7] . "\" class='submit' >";
             if (!$this->fields["deleted"]) {
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n                     <input type='submit' name='delete'\n                            value=\"" . $LANG["buttons"][6] . "\" class='submit'>";
             } else {
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n                     <input type='submit' name='restore'\n                            value=\"" . $LANG["buttons"][21] . "\" class='submit'>";
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n                     <input type='submit' name='purge'\n                            value=\"" . $LANG["buttons"][22] . "\" class='submit'>";
             }
         }
     }
     echo "</td>";
     echo "</tr>";
     echo "</table></form></div>";
 }
Exemplo n.º 25
0
function plugin_fusioninventory_MassiveActionsProcess($data)
{
    global $LANG;
    switch ($data['action']) {
        case "plugin_fusioninventory_get_model":
            if ($data['device_type'] == NETWORKING_TYPE) {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        $PluginFusioninventoryModelInfos = new PluginFusioninventoryModelInfos();
                        $PluginFusioninventoryModelInfos->getrightmodel($key, NETWORKING_TYPE);
                    }
                }
            } else {
                if ($data['device_type'] == PRINTER_TYPE) {
                    foreach ($data['item'] as $key => $val) {
                        if ($val == 1) {
                            $PluginFusioninventoryModelInfos = new PluginFusioninventoryModelInfos();
                            $PluginFusioninventoryModelInfos->getrightmodel($key, PRINTER_TYPE);
                        }
                    }
                }
            }
            break;
        case "plugin_fusioninventory_assign_model":
            if ($data['device_type'] == NETWORKING_TYPE) {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        PluginFusioninventoryMassiveaction::assign($key, NETWORKING_TYPE, "model", $data["snmp_model"]);
                    }
                }
            } else {
                if ($data['device_type'] == PRINTER_TYPE) {
                    foreach ($data['item'] as $key => $val) {
                        if ($val == 1) {
                            PluginFusioninventoryMassiveaction::assign($key, PRINTER_TYPE, "model", $data["snmp_model"]);
                        }
                    }
                }
            }
            break;
        case "plugin_fusioninventory_assign_auth":
            if ($data['device_type'] == NETWORKING_TYPE) {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        PluginFusioninventoryMassiveaction::assign($key, NETWORKING_TYPE, "auth", $data["FK_snmp_connection"]);
                    }
                }
            } else {
                if ($data['device_type'] == PRINTER_TYPE) {
                    foreach ($data['item'] as $key => $val) {
                        if ($val == 1) {
                            PluginFusioninventoryMassiveaction::assign($key, PRINTER_TYPE, "auth", $data["FK_snmp_connection"]);
                        }
                    }
                }
            }
            break;
        case "plugin_fusioninventory_manage_locks":
            if ($data['device_type'] == NETWORKING_TYPE or $data['device_type'] == PRINTER_TYPE) {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        if (isset($data["lockfield_fusioninventory"]) && count($data["lockfield_fusioninventory"])) {
                            $tab = PluginFusioninventoryLock::exportChecksToArray($data["lockfield_fusioninventory"]);
                            PluginFusioninventoryLock::setLockArray($data['type'], $key, $tab);
                        } else {
                            PluginFusioninventoryLock::setLockArray($data['type'], $key, array());
                        }
                    }
                }
            }
            break;
        case "plugin_fusioninventory_discovery_import":
            if (PluginFusioninventory::haveRight("unknowndevices", "w")) {
                $Import = 0;
                $NoImport = 0;
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        list($Import, $NoImport) = PluginFusioninventoryDiscovery::import($key, $Import, $NoImport);
                    }
                }
                addMessageAfterRedirect($LANG['plugin_fusioninventory']["discovery"][5] . " : " . $Import);
                addMessageAfterRedirect($LANG['plugin_fusioninventory']["discovery"][9] . " : " . $NoImport);
            }
            break;
    }
}