Example #1
0
 /**
  * @param $port   IPNetwork object
  **/
 static function showForIPNetwork(IPNetwork $port)
 {
     global $DB, $CFG_GLPI;
     $ID = $port->getID();
     if (!$port->can($ID, READ)) {
         return false;
     }
     $canedit = $port->canEdit($ID);
     $rand = mt_rand();
     $query = "SELECT `" . self::getTable() . "`.id as assocID,\n                       `glpi_vlans`.*\n                FROM `" . self::getTable() . "`\n                LEFT JOIN `glpi_vlans`\n                        ON (`" . self::getTable() . "`.`vlans_id` = `glpi_vlans`.`id`)\n                WHERE `ipnetworks_id` = '{$ID}'";
     $result = $DB->query($query);
     $vlans = array();
     $used = array();
     if ($number = $DB->numrows($result)) {
         while ($line = $DB->fetch_assoc($result)) {
             $used[$line["id"]] = $line["id"];
             $vlans[$line["assocID"]] = $line;
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>\n";
         echo "<form method='post' action='" . static::getFormURL() . "'>\n";
         echo "<table class='tab_cadre_fixe'>\n";
         echo "<tr><th>" . __('Associate a VLAN') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='center'>";
         echo "<input type='hidden' name='ipnetworks_id' value='{$ID}'>";
         Vlan::dropdown(array('used' => $used));
         echo "&nbsp;<input type='submit' name='add' value='" . _sx('button', 'Associate') . "' class='submit'>";
         echo "</td></tr>\n";
         echo "</table>\n";
         Html::closeForm();
         echo "</div>\n";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $number) {
         $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_top .= "</th>";
         $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= "</th>";
     }
     $header_end .= "<th>" . __('Name') . "</th>";
     $header_end .= "<th>" . __('Entity') . "</th>";
     $header_end .= "<th>" . __('ID TAG') . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     $used = array();
     foreach ($vlans as $data) {
         echo "<tr class='tab_bg_1'>";
         if ($canedit) {
             echo "<td>";
             Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
             echo "</td>";
         }
         $name = $data["name"];
         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
             $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
         }
         echo "<td class='center b'>\n               <a href='" . $CFG_GLPI["root_doc"] . "/front/vlan.form.php?id=" . $data["id"] . "'>" . $name . "</a>";
         echo "</td>";
         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]);
         echo "<td class='numeric'>" . $data["tag"] . "</td>";
         echo "</tr>";
     }
     if ($number) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
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 GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
$network = new IPNetwork();
if ($network->can($_POST['ipnetworks_id'], 'r')) {
    echo "<br>\n";
    echo "<a href='" . $network->getLinkURL() . "'>" . $network->fields['completename'] . "</a><br>\n";
    $address = $network->getAddress()->getTextual();
    $netmask = $network->getNetmask()->getTextual();
    $gateway = $network->getGateway()->getTextual();
    $start = new IPAddress();
    $end = new IPAddress();
    $network->computeNetworkRange($start, $end);
    //TRANS: %1$s is address, %2$s is netmask
    printf(__('IP network: %1$s/%2$s') . "<br>\n", $address, $netmask);
    printf(__('First/last addresses: %1$s/%2$s'), $start->getTextual(), $end->getTextual());
    if (!empty($gateway)) {
        echo "<br>\n";
        printf(__('Gateway: %s') . "\n", $gateway);
    }
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 GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
$network = new IPNetwork();
if ($network->can($_POST['ipnetworks_id'], READ)) {
    echo "<br>\n";
    echo "<a href='" . $network->getLinkURL() . "'>" . $network->fields['completename'] . "</a><br>\n";
    $address = $network->getAddress()->getTextual();
    $netmask = $network->getNetmask()->getTextual();
    $gateway = $network->getGateway()->getTextual();
    $start = new IPAddress();
    $end = new IPAddress();
    $network->computeNetworkRange($start, $end);
    //TRANS: %1$s is address, %2$s is netmask
    printf(__('IP network: %1$s/%2$s') . "<br>\n", $address, $netmask);
    printf(__('First/last addresses: %1$s/%2$s'), $start->getTextual(), $end->getTextual());
    if (!empty($gateway)) {
        echo "<br>\n";
        printf(__('Gateway: %s') . "\n", $gateway);
    }