示例#1
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'] . "&from={$day}&to={$now}&width=400&height=100&type=" . $interface['graph_type'];
    $graph_url_month = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&from={$month}&to={$now}&width=400&height=100&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;
}
<?php

global $config;
if (!$graph_type) {
    $graph_type = $_GET['type'];
}
if (!$device) {
    $device['device_id'] = getifhost($interface['interface_id']);
}
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $now;
$graph_array['port'] = $interface['interface_id'];
$graph_array['type'] = $graph_type;
$periods = array('day', 'week', 'month', 'year');
foreach ($periods as $period) {
    $graph_array['from'] = ${$period};
    $graph_array_zoom = $graph_array;
    $graph_array_zoom['height'] = "150";
    $graph_array_zoom['width'] = "400";
    echo overlib_link($_SERVER['REQUEST_URI'], generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
}
示例#3
0
    ini_set('error_reporting', E_ALL);
}
include "../includes/defaults.inc.php";
include "../config.php";
include "../includes/common.php";
include "../includes/graphing.php";
include "../includes/rewrites.php";
include "includes/authenticate.inc.php";
#  if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
if ($_GET['device']) {
    $device_id = $_GET['device'];
} elseif ($_GET['if']) {
    $device_id = getifhost($_GET['if']);
    $ifIndex = getifindexbyid($_GET['if']);
} elseif ($_GET['port']) {
    $device_id = getifhost($_GET['port']);
    $ifIndex = getifindexbyid($_GET['port']);
} elseif ($_GET['peer']) {
    $device_id = getpeerhost($_GET['peer']);
}
if ($device_id) {
    $hostname = gethostbyid($device_id);
}
$from = mres($_GET['from']);
$to = mres($_GET['to']);
$width = mres($_GET['width']);
$height = mres($_GET['height']);
$title = mres($_GET['title']);
$vertical = mres($_GET['vertical']);
$type = mres($_GET['type']);
$graphfile = $config['temp_dir'] . "/" . strgen() . ".png";