mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
html pages cleanup
git-svn-id: http://www.observium.org/svn/observer/trunk@1902 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
53
html/map.php
53
html/map.php
@@ -10,31 +10,33 @@ include("../includes/functions.php");
|
||||
include("includes/functions.inc.php");
|
||||
include("includes/authenticate.inc.php");
|
||||
|
||||
if (is_array($config['branding'])) {
|
||||
if ($config['branding'][$_SERVER['SERVER_NAME']]) {
|
||||
foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) {
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
} else {
|
||||
foreach ($config['branding']['default'] as $confitem => $confval) {
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
}
|
||||
if (is_array($config['branding']))
|
||||
{
|
||||
if ($config['branding'][$_SERVER['SERVER_NAME']])
|
||||
{
|
||||
foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval)
|
||||
{
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
} else {
|
||||
foreach ($config['branding']['default'] as $confitem => $confval)
|
||||
{
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['device'])) { $where = "WHERE device_id = ".$_GET['device']; } else { $where = ""; }
|
||||
$deviceresult = mysql_query("SELECT * from devices $where");
|
||||
|
||||
if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
{
|
||||
|
||||
$map = "digraph G { sep=0.01; size=\"12,5.5\"; pack=100; bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=0;
|
||||
node [ fontname=\"helvetica\", fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false;];
|
||||
edge [ bgcolor=white; fontname=\"helvetica\"; fontstyle=bold; arrowhead=dot; arrowtail=dot];
|
||||
graph [bgcolor=transparent;];\n\n";
|
||||
|
||||
if(!$_SESSION['authenticated'])
|
||||
if (!$_SESSION['authenticated'])
|
||||
{
|
||||
$map .= "\"Not authenticated\" [fontsize=20 fillcolor=\"lightblue\" URL=\"/\" shape=box3d]\n";
|
||||
}
|
||||
@@ -42,7 +44,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
{
|
||||
while ($device = mysql_fetch_array($deviceresult))
|
||||
{
|
||||
if($device)
|
||||
if ($device)
|
||||
{
|
||||
$sql = "SELECT * from ports AS I, links AS L WHERE I.device_id = ".$device['device_id']." AND L.local_interface_id = I.interface_id ORDER BY L.remote_hostname";
|
||||
$links = mysql_query($sql);
|
||||
@@ -52,7 +54,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
$map .= "\"".$device['hostname']."\" [fontsize=20 fillcolor=\"lightblue\" URL=\"{$config['base_url']}/device/".$device['device_id']."/map/\" shape=box3d]\n";
|
||||
}
|
||||
|
||||
while($link = mysql_fetch_array($links))
|
||||
while ($link = mysql_fetch_array($links))
|
||||
{
|
||||
$local_interface_id = $link['local_interface_id'];
|
||||
$remote_interface_id = $link['remote_interface_id'];
|
||||
@@ -64,13 +66,13 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
$i++;
|
||||
}
|
||||
|
||||
if(!$done)
|
||||
if (!$done)
|
||||
{
|
||||
$linkdone[] = "$local_interface_id $remote_interface_id";
|
||||
|
||||
$links++;
|
||||
|
||||
if($link['ifSpeed'] >= "10000000000")
|
||||
if ($link['ifSpeed'] >= "10000000000")
|
||||
{
|
||||
$info = "color=red3 style=\"setlinewidth(6)\"";
|
||||
} elseif ($link['ifSpeed'] >= "1000000000") {
|
||||
@@ -84,7 +86,8 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
}
|
||||
|
||||
$src = $device['hostname'];
|
||||
if($remote_interface_id) {
|
||||
if ($remote_interface_id)
|
||||
{
|
||||
$dst = mysql_result(mysql_query("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.interface_id = '$remote_interface_id' AND D.device_id = I.device_id"),0);
|
||||
$dst_host = mysql_result(mysql_query("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.interface_id = '$remote_interface_id' AND D.device_id = I.device_id"),0);
|
||||
} else {
|
||||
@@ -93,7 +96,8 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
}
|
||||
|
||||
$sif = ifNameDescr(mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE `interface_id`=" . $link['local_interface_id'])),$device);
|
||||
if($remote_interface_id) {
|
||||
if ($remote_interface_id)
|
||||
{
|
||||
$dif = ifNameDescr(mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE `interface_id`=" . $link['remote_interface_id'])));
|
||||
} else {
|
||||
$dif['label'] = $link['remote_port'];
|
||||
@@ -109,7 +113,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
|
||||
$map .= "\"$dst\" [URL=\"{$config['base_url']}/device/$dst_host/map/\" fontsize=20 shape=box3d]\n";
|
||||
|
||||
if($dst_host == $device['device_id'] || $where == '') {
|
||||
if ($dst_host == $device['device_id'] || $where == '') {
|
||||
$map .= "\"" . $dif['interface_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/$dst_host/interface/$remote_interface_id/\"]\n";
|
||||
} else {
|
||||
$map .= "\"" . $dif['interface_id'] . "\" [label=\"" . $dif['label'] . " \", fontsize=12, fillcolor=lightgray, URL=\"{$config['base_url']}/device/$dst_host/interface/$remote_interface_id/\"]\n";
|
||||
@@ -142,17 +146,17 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
$_GET['format'] = 'png';
|
||||
}
|
||||
|
||||
if($links > 10) ### Unflatten if there are more than 10 links. beyond that it gets messy
|
||||
if ($links > 10) ### Unflatten if there are more than 10 links. beyond that it gets messy
|
||||
{
|
||||
$maptool = 'unflatten -f -l 5 |dot';
|
||||
} else {
|
||||
$maptool = 'dot';
|
||||
$maptool = 'dot';
|
||||
}
|
||||
|
||||
if ($where == '') { $maptool = 'neato -Gpack'; }
|
||||
|
||||
$img = shell_exec("echo \"".addslashes($map)."\" | $maptool -T".$_GET['format']."");
|
||||
if($_GET['format'] == "png") {
|
||||
if ($_GET['format'] == "png") {
|
||||
header("Content-type: image/".$_GET['format']);
|
||||
} elseif ($_GET['format'] == "svg") {
|
||||
header("Content-type: image/svg+xml");
|
||||
@@ -170,4 +174,5 @@ else
|
||||
</center>');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user