예제 #1
0
function generate_port_link($port, $text = NULL, $type = NULL)
{
    global $config;
    if (isset($port['humanized']) == FALSE) {
        humanize_port($port);
    }
    if (!$text) {
        $text = fixIfName($port['label']);
    }
    if ($type) {
        $port['graph_type'] = $type;
    }
    if (!isset($port['graph_type'])) {
        $port['graph_type'] = 'port_bits';
    }
    $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    if (!isset($port['os'])) {
        $port = array_merge($port, device_by_id_cache($port['device_id']));
    }
    $content = generate_device_link_header($port);
    $content .= generate_port_link_header($port);
    $content .= '<div style="width: 700px">';
    $graph_array['type'] = $port['graph_type'];
    $graph_array['legend'] = "yes";
    $graph_array['height'] = "100";
    $graph_array['width'] = "275";
    $graph_array['to'] = $config['time']['now'];
    $graph_array['from'] = $config['time']['day'];
    $graph_array['id'] = $port['port_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_port_url($port);
    if (port_permitted($port['port_id'], $port['device_id'])) {
        return overlib_link($url, $text, $content, $class);
    } else {
        return fixifName($text);
    }
}
function generate_port_popup($port, $text = NULL, $type = NULL)
{
    global $config;
    humanize_port($port);
    if (!$text) {
        $text = rewrite_ifname($port['label']);
    }
    if ($type) {
        $port['graph_type'] = $type;
    }
    if (!isset($port['graph_type'])) {
        $port['graph_type'] = 'port_bits';
    }
    $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    if (!isset($port['os'])) {
        $port = array_merge($port, device_by_id_cache($port['device_id']));
    }
    $content = generate_device_link_header($port);
    $content .= generate_port_link_header($port);
    $content .= '<div style="width: 700px">';
    $graph_array['type'] = $port['graph_type'];
    $graph_array['legend'] = "yes";
    $graph_array['height'] = "100";
    $graph_array['width'] = "275";
    $graph_array['to'] = $config['time']['now'];
    $graph_array['from'] = $config['time']['day'];
    $graph_array['id'] = $port['port_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>";
    return $content;
}