diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 40484ece90..fc0fef26bd 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1,5 +1,53 @@ "; + $output .= $text.""; + return $output; +} + +function generate_graph_popup($graph_array) +{ + global $config; + ## Take $graph_array and print day,week,month,year graps in overlib, hovered over graph + + $graph = generate_graph_tag($graph_array); + $content = "
".$graph_array['popup_title']."
"; + $content .= "
"; + $graph_array['legend'] = "yes"; + $graph_array['height'] = "100"; + $graph_array['width'] = "340"; + $graph_array['from'] = $config['day']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['week']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['month']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['year']; + $content .= generate_graph_tag($graph_array); + $content .= "
"; + return overlib_link($graph_array['link'], $graph, $content, NULL); + +} + +function print_graph_popup($graph_array) +{ + echo (generate_graph_popup($graph_array)); +} + + function permissions_cache($user_id) { $permissions = array(); $query = mysql_query("SELECT * FROM devices_perms WHERE user_id = '".$user_id."'"); @@ -76,23 +124,41 @@ function print_percentage_bar ($width, $height, $percent, $left_text, $left_colo return $output; } -function generate_if_link($args) +function generate_if_link($args, $text = NULL) { global $twoday; global $now; global $config; global $day; global $month; $args = ifNameDescr($args); - if(!$args['content']) { $args['content'] = fixIfName($args['label']); } - if(!$args['graph_type']) { $args['graph_type'] = 'bits'; } + if(!$text) { $text = fixIfName($args['label']); } + if(!$args['graph_type']) { $args['graph_type'] = 'port_bits'; } $class = ifclass($args['ifOperStatus'], $args['ifAdminStatus']); - $graph_url = $config['base_url'] . "/graph.php?if=" . $args['interface_id'] . "&from=$day&to=$now&width=400&height=100&type=" . $args['graph_type']; - $graph_url_month = $config['base_url'] . "/graph.php?if=" . $args['interface_id'] . "&from=$month&to=$now&width=400&height=100&type=" . $args['graph_type']; - $device_id = getifhost($args['interface_id']); - $link = ""; - if($args['ifAlias']) { $link .= "
" . $args['ifAlias']; } - $link .= "' "; - $link .= $config['overlib_defaults'].");\" onmouseout=\"return nd();\" >".$args['content']."
"; - return $link; + if(!isset($args['hostname'])) { $args = array_merge($args, device_by_id_cache($args['device_id'])); } + + $content = "
".$args['hostname']." - " . fixifName($args['label']) . "
"; + if($args['ifAlias']) { $content .= $args['ifAlias']."
"; } + $content .= "
"; + $graph_array['type'] = $args['graph_type']; + $graph_array['legend'] = "yes"; + $graph_array['height'] = "100"; + $graph_array['width'] = "340"; + $graph_array['from'] = $config['day']; + $graph_array['port'] = $args['interface_id']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['week']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['month']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['year']; + $content .= generate_graph_tag($graph_array); + $content .= "
"; + + $url = $config['base_url']."/device/".$args['device_id']."/interface/" . $args['interface_id'] . "/"; + + if(interfacepermitted($args['interface_id'])) { + return overlib_link($url, $text, $content, $class); + } else { + return fixifName($text); + } + } function generate_port_thumbnail($args) diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 5d415c8c01..42445e578a 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -49,8 +49,8 @@ if($ports['total']) { $ifsep = ""; while($data = mysql_fetch_array($query)) { $data = ifNameDescr($data); - $data['hostname'] = $device['hostname']; - echo("$ifsep" . generateiflink($data, makeshortif(strtolower($data['label'])))); + $data = array_merge($data, $device); + echo("$ifsep" . generate_if_link($data, makeshortif(strtolower($data['label'])))); $ifsep = ", "; } unset($ifsep); diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 4786f1d7ee..f518cf1485 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -116,14 +116,24 @@ echo(" echo("
"); if($ports['fileserver']) { - echo("
- \ - \ - ', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - "
Main Fileserver
". - "
"); + + echo("
"); + echo("
Central Fileserver
"); + + $graph_array['height'] = "100"; + $graph_array['width'] = "385"; + $graph_array['to'] = $now; + $graph_array['port'] = $ports['fileserver']; + $graph_array['type'] = "port_bits"; + $graph_array['from'] = $day; + $graph_array['legend'] = "no"; + + $graph_array['popup_title'] = "Central Fileserver"; + + print_graph_popup($graph_array); + + echo("
"); + } echo("
"); diff --git a/includes/functions.php b/includes/functions.php index 2787e248bf..9f4f12e260 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -224,39 +224,6 @@ function geteventicon ($message) if (isset($icon)) { return $icon; } else { return false; } } -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 = "
" . $interface['hostname'] . " - " . fixifName($interface['label']) . "
"; - if ($interface['ifAlias']) { $contents .= htmlentities($interface['ifAlias'] ."
" ); } - $contents .= "
"; - $link = overlib_link($url, $text, $contents, $class); - if(interfacepermitted($interface['interface_id'])) { - return $link; - } else { - return fixifName($interface['label']); - } -} - -function overlib_link($url, $text, $contents, $class) { - global $config; - $contents = str_replace("\"", "\'", $contents); - $output = ""; - $output .= $text.""; - return $output; -} - function generatedevicelink($device, $text=0, $start=0, $end=0) { global $twoday; global $day; global $now; global $config; diff --git a/includes/polling/bgpPeer.inc.php b/includes/polling/bgpPeer.inc.php index fdf2d67a72..ce339d1628 100755 --- a/includes/polling/bgpPeer.inc.php +++ b/includes/polling/bgpPeer.inc.php @@ -140,6 +140,7 @@ if ($device['os'] == "junos") $cbgp_cmd .= " cbgpPeerAdvertisedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; $cbgp_cmd .= " cbgpPeerSuppressedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; $cbgp_cmd .= " cbgpPeerWithdrawnPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; + if($debug) { echo("$cbgp_cmd\n"); } $cbgp_data = preg_replace("/^OID.*$/", "", trim(`$cbgp_cmd`)); if($debug) { echo("$cbgp_data\n"); } diff --git a/includes/static-config.php b/includes/static-config.php index fe5d268dc6..67fe906a5b 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -122,4 +122,12 @@ $week = time() - (7 * 24 * 60 * 60); $month = time() - (31 * 24 * 60 * 60); $year = time() - (365 * 24 * 60 * 60); +$config['now'] = $now; +$config['day'] = $day; +$config['twoday'] = $twoday; +$config['week'] = $week; +$config['month'] = $month; +$config['year'] = $year; + + ?>