Addressing is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Addressing is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Addressing. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: Alexandre DELAUNAY // Purpose of file: // ---------------------------------------------------------------------- include '../../../inc/includes.php'; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); if (!isset($_POST['ip'])) { exit; } $ip = $_POST['ip']; $config = new PluginAddressingConfig(); $config->getFromDB('1'); $system = $config->fields["used_system"]; $ping_equip = new PluginAddressingPing_Equipment(); echo $ping_response = $ping_equip->ping($system, $ip);
function displayReport(&$result, $PluginAddressingAddressing) { global $DB, $CFG_GLPI; $network = $PluginAddressingAddressing->fields["networks_id"]; $ping = $PluginAddressingAddressing->fields["use_ping"]; $PluginAddressingConfig = new PluginAddressingConfig(); $PluginAddressingConfig->getFromDB('1'); $system = $PluginAddressingConfig->fields["used_system"]; // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET["display_type"])) { $output_type = $_GET["display_type"]; } $header_num = 1; $nbcols = 6; $ping_response = 0; $parameters = "id="; $row_num = 1; echo Search::showHeader($output_type, 1, $nbcols, 1); echo $this->displaySearchNewLine($output_type); echo Search::showHeaderItem($output_type, __('IP'), $header_num); echo Search::showHeaderItem($output_type, __('Connected to'), $header_num); echo Search::showHeaderItem($output_type, _n('User', 'Users', 1), $header_num); echo Search::showHeaderItem($output_type, __('MAC address'), $header_num); echo Search::showHeaderItem($output_type, __('Item type'), $header_num); echo Search::showHeaderItem($output_type, __('Free Ip', 'addressing'), $header_num); // End Line for column headers echo Search::showEndLine($output_type); $user = new User(); foreach ($result as $num => $lines) { $ip = long2ip(substr($num, 2)); if (count($lines)) { if (count($lines) > 1) { $disp = $PluginAddressingAddressing->fields["double_ip"]; } else { $disp = $PluginAddressingAddressing->fields["alloted_ip"]; } if ($disp) { foreach ($lines as $line) { $row_num++; $item_num = 1; $name = $line["dname"]; $namep = $line["pname"]; // IP echo $this->displaySearchNewLine($output_type, count($lines) > 1 ? "double" : $row_num % 2); echo Search::showItem($output_type, $ip, $item_num, $row_num); // Device $item = new $line["itemtype"](); $link = Toolbox::getItemTypeFormURL($line["itemtype"]); if ($line["itemtype"] != 'NetworkEquipment') { if ($item->canView()) { $output_iddev = "<a href='" . $link . "?id=" . $line["on_device"] . "'>" . $name . (empty($name) || $_SESSION["glpiis_ids_visible"] ? " (" . $line["on_device"] . ")" : "") . "</a>"; } else { $output_iddev = $name . (empty($name) || $_SESSION["glpiis_ids_visible"] ? " (" . $line["on_device"] . ")" : ""); } } else { if ($item->canView()) { if (empty($namep)) { $linkp = ''; } else { $linkp = $namep . " - "; } $output_iddev = "<a href='" . $link . "?id=" . $line["on_device"] . "'>" . $linkp . $name . (empty($name) || $_SESSION["glpiis_ids_visible"] ? " (" . $line["on_device"] . ")" : "") . "</a>"; } else { $output_iddev = $namep . " - " . $name . (empty($name) || $_SESSION["glpiis_ids_visible"] ? " (" . $line["on_device"] . ")" : ""); } } echo Search::showItem($output_type, $output_iddev, $item_num, $row_num); // User if ($line["users_id"] && $user->getFromDB($line["users_id"])) { $username = formatUserName($user->fields["id"], $user->fields["name"], $user->fields["realname"], $user->fields["firstname"]); if ($user->canView()) { $output_iduser = "******" . $CFG_GLPI["root_doc"] . "/front/user.form.php?id=" . $line["users_id"] . "'>" . $username . "</a>"; } else { $output_iduser = $username; } echo Search::showItem($output_type, $output_iduser, $item_num, $row_num); } else { echo Search::showItem($output_type, " ", $item_num, $row_num); } // Mac if ($line["id"]) { if ($item->canView()) { $output_mac = "<a href='" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?id=" . $line["id"] . "'>" . $line["mac"] . "</a>"; } else { $output_mac = $line["mac"]; } echo Search::showItem($output_type, $output_mac, $item_num, $row_num); } else { echo Search::showItem($output_type, " ", $item_num, $row_num); } // Type echo Search::showItem($output_type, $item::getTypeName(), $item_num, $row_num); // Reserved if ($PluginAddressingAddressing->fields["reserved_ip"] && strstr($line["pname"], "reserv")) { echo Search::showItem($output_type, __('Reserved Address', 'addressing'), $item_num, $row_num); } else { echo Search::showItem($output_type, " ", $item_num, $row_num); } // End echo Search::showEndLine($output_type); } } } else { if ($PluginAddressingAddressing->fields["free_ip"]) { $row_num++; $item_num = 1; if (!$ping) { echo $this->displaySearchNewLine($output_type, "free"); echo Search::showItem($output_type, $ip, $item_num, $row_num); echo Search::showItem($output_type, " ", $item_num, $row_num); } else { if ($output_type == Search::HTML_OUTPUT) { Html::glpi_flush(); } if ($this->ping($system, $ip)) { $ping_response++; echo $this->displaySearchNewLine($output_type, "ping_off"); echo Search::showItem($output_type, $ip, $item_num, $row_num); echo Search::showItem($output_type, __('Ping: got a response - used Ip', 'addressing'), $item_num, $row_num); } else { echo $this->displaySearchNewLine($output_type, "ping_on"); echo Search::showItem($output_type, $ip, $item_num, $row_num); echo Search::showItem($output_type, __('Ping: no response - free Ip', 'addressing'), $item_num, $row_num); } } echo Search::showItem($output_type, " ", $item_num, $row_num); echo Search::showItem($output_type, " ", $item_num, $row_num); echo Search::showItem($output_type, " ", $item_num, $row_num); echo Search::showItem($output_type, " ", $item_num, $row_num); echo Search::showEndLine($output_type); } } } // Display footer echo Search::showFooter($output_type, $PluginAddressingAddressing->getTitle()); return $ping_response; }
function showForm($ID, $options = array()) { $this->initForm($ID, $options); $options['formoptions'] = "onSubmit='return plugaddr_Check(\"" . __('Invalid data !!', 'addressing') . "\")'"; $this->showFormHeader($options); $PluginAddressingConfig = new PluginAddressingConfig(); $PluginAddressingConfig->getFromDB('1'); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name"); echo "</td>"; if ($PluginAddressingConfig->fields["alloted_ip"]) { echo "<td>" . __('Assigned IP', 'addressing') . "</td><td>"; Dropdown::showYesNo('alloted_ip', $this->fields["alloted_ip"]); echo "</td>"; } else { echo "<td>"; echo Html::hidden('alloted_ip', array('value' => 0)); //echo "<input type='hidden' name='alloted_ip' value='0'></td><td></td>"; echo "</td><td></td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Select the network', 'addressing') . "</td>"; echo "<td>"; Dropdown::show('Network', array('name' => "networks_id", 'value' => $this->fields["networks_id"])); echo "</td>"; if ($PluginAddressingConfig->fields["free_ip"]) { echo "<td>" . __('Free Ip', 'addressing') . "</td><td>"; Dropdown::showYesNo('free_ip', $this->fields["free_ip"]); echo "</td>"; } else { echo "<td>"; echo Html::hidden('free_ip', array('value' => 0)); echo "</td><td></td>"; //echo "<td><input type='hidden' name='free_ip' value='0'></td><td></td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Detected subnet list', 'addressing') . "</td>"; echo "<td>"; $this->dropdownSubnet($ID > 0 ? $this->fields["entities_id"] : $_SESSION["glpiactive_entity"]); echo "</td>"; if ($PluginAddressingConfig->fields["double_ip"]) { echo "<td>" . __('Same IP', 'addressing') . "</td><td>"; Dropdown::showYesNo('double_ip', $this->fields["double_ip"]); echo "</td>"; } else { //echo "<td><input type='hidden' name='double_ip' value='0'></td><td></td>"; echo "<td>"; echo Html::hidden('double_ip', array('value' => 0)); echo "</td><td></td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('First IP', 'addressing') . "</td>"; // Subnet echo "<td>"; echo "<input type='text' id='plugaddr_ipdeb0' value='' name='_ipdeb0' size='3' " . "onChange='plugaddr_ChangeNumber(\"" . __('Invalid data !!', 'addressing') . "\");'>."; echo "<input type='text' id='plugaddr_ipdeb1' value='' name='_ipdeb1' size='3' " . "onChange='plugaddr_ChangeNumber(\"" . __('Invalid data !!', 'addressing') . "\");'>."; echo "<input type='text' id='plugaddr_ipdeb2' value='' name='_ipdeb2' size='3' " . "onChange='plugaddr_ChangeNumber(\"" . __('Invalid data !!', 'addressing') . "\");'>."; echo "<input type='text' id='plugaddr_ipdeb3' value='' name='_ipdeb3' size='3' " . "onChange='plugaddr_ChangeNumber(\"" . __('Invalid data !!', 'addressing') . "\");'>"; echo "</td>"; if ($PluginAddressingConfig->fields["reserved_ip"]) { echo "<td>" . __('Reserved IP', 'addressing') . "</td><td>"; Dropdown::showYesNo('reserved_ip', $this->fields["reserved_ip"]); echo "</td>"; } else { echo "<td>"; echo Html::hidden('reserved_ip', array('value' => 0)); echo "</td><td></td>"; //echo "<td><input type='hidden' name='reserved_ip' value='0'></td><td></td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Last IP', 'addressing') . "</td>"; // Mask echo "<td>"; echo "<input type='text' id='plugaddr_ipfin0' value='' name='_ipfin0' size='3' " . "onChange='plugaddr_ChangeNumber(\"" . __('Invalid data !!', 'addressing') . "\");'>."; echo "<input type='text' id='plugaddr_ipfin1' value='' name='_ipfin1' size='3' " . "onChange='plugaddr_ChangeNumber(\"" . __('Invalid data !!', 'addressing') . "\");'>."; echo "<input type='text' id='plugaddr_ipfin2' value='' name='_ipfin2' size='3' " . "onChange='plugaddr_ChangeNumber(\"" . __('Invalid data !!', 'addressing') . "\");'>."; echo "<input type='text' id='plugaddr_ipfin3' value='' name='_ipfin3' size='3' " . "onChange='plugaddr_ChangeNumber(\"" . __('Invalid data !!', 'addressing') . "\");'>"; echo "</td>"; if ($PluginAddressingConfig->fields["use_ping"]) { echo "<td>" . __('Ping free Ip', 'addressing') . "</td><td>"; Dropdown::showYesNo('use_ping', $this->fields["use_ping"]); echo "</td>"; } else { echo "<td>"; echo Html::hidden('use_ping', array('value' => 0)); echo "</td><td></td>"; //echo "<td><input type='hidden' name='use_ping' value='0'></td><td></td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Report for the IP Range', 'addressing') . "</td>"; // Mask echo "<td>"; echo "<input type='hidden' id='plugaddr_ipdeb' value='" . $this->fields["begin_ip"] . "' name='begin_ip'>"; echo "<input type='hidden' id='plugaddr_ipfin' value='" . $this->fields["end_ip"] . "' name='end_ip'>"; echo "<div id='plugaddr_range'>-</div>"; if ($ID > 0) { $js = "plugaddr_Init(\"" . __('Invalid data !!', 'addressing') . "\");"; echo Html::scriptBlock($js); } echo "</td>"; echo "<td></td>"; echo "<td></td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan = '4'>"; echo "<table cellpadding='2' cellspacing='2'><tr><td>"; echo __('Comments') . "</td></tr>"; echo "<tr><td class='center'>" . "<textarea cols='125' rows='3' name='comment'>" . $this->fields["comment"] . "</textarea>"; echo "</td></tr></table>"; echo "</td>"; $this->showFormButtons($options); return true; }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Addressing is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Addressing. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $plugin = new Plugin(); if ($plugin->isActivated("addressing")) { $PluginAddressingConfig = new PluginAddressingConfig(); Session::checkRight("config", "w"); if (isset($_POST["update"])) { $PluginAddressingConfig->update($_POST); Html::back(); } else { Html::header(PluginAddressingAddressing::getTypeName(2), '', "plugins", "addressing"); $PluginAddressingConfig->showForm(); Html::footer(); } } else { Html::header(__('Setup'), '', "config", "plugins"); echo "<div class='center'><br><br>" . "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt='warning'><br><br>"; echo "<b>" . __('Please activate the plugin', 'addressing') . "</b></div>"; Html::footer(); }