Beispiel #1
0
function makeshortif($if)
{
    global $rewrite_shortif;
    $if = fixifName($if);
    $if = strtolower($if);
    $if = array_str_replace($rewrite_shortif, $if);
    return $if;
}
Beispiel #2
0
function generate_ap_link($args, $text = null, $type = null)
{
    global $config;
    $args = ifNameDescr($args);
    if (!$text) {
        $text = fixIfName($args['label']);
    }
    if ($type) {
        $args['graph_type'] = $type;
    }
    if (!isset($args['graph_type'])) {
        $args['graph_type'] = 'port_bits';
    }
    if (!isset($args['hostname'])) {
        $args = array_merge($args, device_by_id_cache($args['device_id']));
    }
    $content = '<div class=list-large>' . $args['text'] . ' - ' . fixifName($args['label']) . '</div>';
    if ($args['ifAlias']) {
        $content .= $args['ifAlias'] . '<br />';
    }
    $content .= "<div style=\\'width: 850px\\'>";
    $graph_array = array();
    $graph_array['type'] = $args['graph_type'];
    $graph_array['legend'] = 'yes';
    $graph_array['height'] = '100';
    $graph_array['width'] = '340';
    $graph_array['to'] = $config['time']['now'];
    $graph_array['from'] = $config['time']['day'];
    $graph_array['id'] = $args['accesspoint_id'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['week'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['month'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['year'];
    $content .= generate_graph_tag($graph_array);
    $content .= '</div>';
    $url = generate_ap_url($args);
    if (port_permitted($args['interface_id'], $args['device_id'])) {
        return overlib_link($url, $text, $content, null);
    } else {
        return fixifName($text);
    }
}
Beispiel #3
0
$ifalias = $interface['name'];
if ($interface['ifPhysAddress']) {
    $mac = "{$interface['ifPhysAddress']}";
}
$color = "black";
if ($interface['ifAdminStatus'] == "down") {
    $status = "<span class='grey'>Disabled</span>";
}
if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "down") {
    $status = "<span class='red'>Enabled / Disconnected</span>";
}
if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "up") {
    $status = "<span class='green'>Enabled / Connected</span>";
}
$i = 1;
$inf = fixifName($ifname);
$bg = "#ffffff";
$show_all = 1;
echo "<div class=ifcell style='margin: 0px;'><table width=100% cellpadding=10 cellspacing=0>";
include "includes/print-interface.inc.php";
echo "</table></div>";
$pos = strpos(strtolower($ifname), "vlan");
if ($pos !== false) {
    $broke = yes;
}
$pos = strpos(strtolower($ifname), "loopback");
if ($pos !== false) {
    $broke = yes;
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '" . $interface['ifIndex'] . "' and `device_id` = '" . $device['device_id'] . "'"), 0)) {
    $pagp = " | <a href='" . $config['base_url'] . "/device/" . $device['device_id'] . "/interface/" . $interface['interface_id'] . "/pagp/'>PAgP</a>";
             $this_hostname = $new['hostname'];
             $this_ifname = fixifName($new['label']);
             $int_links[$this_ifid] = $this_ifid;
             $int_links_v4[$this_ifid] = 1;
         }
     }
     foreach (dbFetchRows("SELECT ipv6_network_id FROM ipv6_addresses WHERE port_id = ?", array($port['port_id'])) as $net) {
         $ipv6_network_id = $net['ipv6_network_id'];
         $sql = "SELECT I.port_id FROM ipv6_addresses AS A, ports AS I, devices AS D\n           WHERE A.port_id = I.port_id\n           AND A.ipv6_network_id = ? AND D.device_id = I.device_id\n           AND D.device_id != ? AND A.ipv6_origin != 'linklayer' AND A.ipv6_origin != 'wellknown'";
         $array = array($net['ipv6_network_id'], $device['device_id']);
         foreach (dbFetchRows($sql, $array) as $new) {
             echo $new['ipv6_network_id'];
             $this_ifid = $new['port_id'];
             $this_hostid = $new['device_id'];
             $this_hostname = $new['hostname'];
             $this_ifname = fixifName($new['label']);
             $int_links[$this_ifid] = $this_ifid;
             $int_links_v6[$this_ifid] = 1;
         }
     }
 }
 if ($port_details && $config['enable_port_relationship'] === TRUE) {
     foreach ($int_links as $int_link) {
         $link_if = dbFetchRow("SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.port_id = ?", array($int_link));
         echo "{$br}";
         if ($int_links_phys[$int_link]) {
             echo "<img align=absmiddle src='images/16/connect.png'> ";
         } else {
             echo "<img align=absmiddle src='images/16/bullet_go.png'> ";
         }
         echo "<b>" . generate_port_link($link_if, makeshortif($link_if['label'])) . " on " . generate_device_link($link_if, shorthost($link_if['hostname']));
Beispiel #5
0
function generateiflink($interface, $text = 0, $type = NULL)
{
    global $twoday;
    global $now;
    global $config;
    global $day;
    global $month;
    $interface = ifNameDescr($interface);
    if (!$text) {
        $text = fixIfName($interface['label']);
    }
    if (isset($type)) {
        $interface['graph_type'] = $type;
    } else {
        $interface['graph_type'] = 'port_bits';
    }
    if (!isset($interface['hostname'])) {
        $interface = array_merge($interface, device_by_id_cache($interface['device_id']));
    }
    $class = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']);
    $graph_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;from={$day}&amp;to={$now}&amp;width=400&amp;height=100&amp;type=" . $interface['graph_type'];
    $graph_url_month = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;from={$month}&amp;to={$now}&amp;width=400&amp;height=100&amp;type=" . $interface['graph_type'];
    $device_id = getifhost($interface['interface_id']);
    $url = $config['base_url'] . "/device/{$device_id}/interface/" . $interface['interface_id'] . "/";
    $contents = "<div class=list-large>" . $interface['hostname'] . " - " . fixifName($interface['label']) . "</div>";
    if ($interface['ifAlias']) {
        $contents .= htmlentities($interface['ifAlias'] . "<br />");
    }
    $contents .= "<img src=\\'{$graph_url}\\'><br /><img src=\\'{$graph_url_month}\\'>";
    $link = overlib_link($url, $text, $contents, $class);
    return $link;
}
function generate_ap_link($args, $text = NULL, $type = NULL)
{
    global $config;
    if (isset($args['humanized']) == false) {
        humanize_port($args);
    }
    if (!$text) {
        $text = fixIfName($args['label']);
    }
    if ($type) {
        $args['graph_type'] = $type;
    }
    if (!isset($args['graph_type'])) {
        $args['graph_type'] = 'port_bits';
    }
    if (!isset($args['hostname'])) {
        $args = array_merge($args, device_by_id_cache($args['device_id']));
    }
    $content = "<div class=entity-title>" . $args['text'] . " - " . fixifName($args['label']) . "</div>";
    if ($args['ifAlias']) {
        $content .= $args['ifAlias'] . "<br />";
    }
    $content .= "<div style=\\'width: 850px\\'>";
    $graph_array['type'] = $args['graph_type'];
    $graph_array['legend'] = "yes";
    $graph_array['height'] = "100";
    $graph_array['width'] = "340";
    $graph_array['to'] = $config['time']['now'];
    $graph_array['from'] = $config['time']['day'];
    $graph_array['id'] = $args['accesspoint_id'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['week'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['month'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['year'];
    $content .= generate_graph_tag($graph_array);
    $content .= "</div>";
    $url = generate_ap_url($args);
    if (port_permitted($args['interface_id'], $args['device_id'])) {
        return overlib_link($url, $text, $content, $class);
    } else {
        return fixifName($text);
    }
}
Beispiel #7
0
$interface_added = 0;
foreach (explode("\n", $ports) as $entry) {
    $entry = trim($entry);
    list($ifIndex, $ifDescr) = explode("||", $entry);
    if (!strstr($entry, "irtual")) {
        $if = trim(strtolower($ifDescr));
        $nullintf = 0;
        foreach ($config['bad_if'] as $bi) {
            if (strstr($if, $bi)) {
                $nullintf = 1;
            }
        }
        if ($device['os'] == "catos" && strstr($if, "vlan")) {
            $nullintf = 1;
        }
        $ifDescr = fixifName($ifDescr);
        if (preg_match('/serial[0-9]:/', $if)) {
            $nullintf = 1;
        }
        if (isset($config['allow_ng']) && !$config['allow_ng']) {
            if (preg_match('/ng[0-9]+$/', $if)) {
                $nullintf = 1;
            }
        }
        if ($debug) {
            echo "\n {$if} ";
        }
        if ($nullintf == 0) {
            if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '" . $device['device_id'] . "' AND `ifIndex` = '{$ifIndex}'"), 0) == '0') {
                mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('" . $device['device_id'] . "','{$ifIndex}','{$ifDescr}')");
                # Add Interface