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:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
if ($_GET['debug']) {
|
||||
if ($_GET['debug'])
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
@@ -15,16 +16,15 @@ include("../includes/common.php");
|
||||
include("../includes/rewrites.php");
|
||||
include("includes/authenticate.inc.php");
|
||||
|
||||
|
||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
||||
|
||||
if (is_numeric($_GET['device_id']))
|
||||
{
|
||||
$ports = mysql_query("SELECT * FROM ports WHERE device_id = '".$_GET['device_id']."'");
|
||||
while($interface = mysql_fetch_array($ports))
|
||||
while ($interface = mysql_fetch_array($ports))
|
||||
{
|
||||
echo("obj.options[obj.options.length] = new Option('".$interface['ifDescr']." - ".$interface['ifAlias']."','".$interface['interface_id']."');\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
if($_GET['debug']) {
|
||||
if ($_GET['debug'])
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
@@ -13,29 +14,30 @@ include("../config.php");
|
||||
include("../includes/functions.php");
|
||||
include("includes/functions.inc.php");
|
||||
include("includes/authenticate.inc.php");
|
||||
if(!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
||||
require("includes/jpgraph/src/jpgraph.php");
|
||||
include("includes/jpgraph/src/jpgraph_line.php");
|
||||
include("includes/jpgraph/src/jpgraph_utils.inc.php");
|
||||
|
||||
if(is_numeric($_GET['bill_id'])){
|
||||
if(bill_permitted($_GET['bill_id']))
|
||||
{
|
||||
$bill_id = $_GET['bill_id'];
|
||||
} else {
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
}
|
||||
if (is_numeric($_GET['bill_id']))
|
||||
{
|
||||
if (bill_permitted($_GET['bill_id']))
|
||||
{
|
||||
$bill_id = $_GET['bill_id'];
|
||||
} else {
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start = $_GET[from];
|
||||
$end = $_GET[to];
|
||||
$xsize = $_GET[x];
|
||||
$ysize = $_GET[y];
|
||||
$count = $_GET[count];
|
||||
$start = $_GET[from];
|
||||
$end = $_GET[to];
|
||||
$xsize = $_GET[x];
|
||||
$ysize = $_GET[y];
|
||||
$count = $_GET[count];
|
||||
$count = $count + 0;
|
||||
$iter = 1;
|
||||
|
||||
@@ -43,7 +45,7 @@ if ($_GET[type]) { $type = $_GET[type]; } else { $type = "date"; }
|
||||
|
||||
$dur = $end - $start;
|
||||
|
||||
if($type == "date") { $date_format = "%d %b %H:%i"; $tickinterval = "2"; } else { $date_format = "%H"; $tickinterval = "1"; }
|
||||
if ($type == "date") { $date_format = "%d %b %H:%i"; $tickinterval = "2"; } else { $date_format = "%H"; $tickinterval = "1"; }
|
||||
|
||||
$datefrom = date('Ymt', $start) . "000000";
|
||||
$dateto = date('Ymt', $end) . "235959";
|
||||
@@ -51,13 +53,13 @@ $dateto = date('Ymt', $end) . "235959";
|
||||
$datefrom = mysql_result(mysql_query("SELECT FROM_UNIXTIME($start, '%Y%m%d')"),0) . "000000";
|
||||
$dateto = mysql_result(mysql_query("SELECT FROM_UNIXTIME($end, '%Y%m%d')"),0) . "235959";
|
||||
|
||||
$rate_data = getRates($bill_id,$datefrom,$dateto);
|
||||
$rate_95th = $rate_data['rate_95th'] * 1000;
|
||||
$rate_average = $rate_data['rate_average'] * 1000;
|
||||
$rate_data = getRates($bill_id,$datefrom,$dateto);
|
||||
$rate_95th = $rate_data['rate_95th'] * 1000;
|
||||
$rate_average = $rate_data['rate_average'] * 1000;
|
||||
|
||||
$bi_q = mysql_query("SELECT * FROM bills WHERE bill_id = $bill_id");
|
||||
$bi_a = mysql_fetch_array($bi_q);
|
||||
$bill_name = $bi_a['bill_name'];
|
||||
$bi_q = mysql_query("SELECT * FROM bills WHERE bill_id = $bill_id");
|
||||
$bi_a = mysql_fetch_array($bi_q);
|
||||
$bill_name = $bi_a['bill_name'];
|
||||
|
||||
$countsql = mysql_query("SELECT count(`delta`) FROM `bill_data` WHERE `bill_id` = '$bill_id' AND `timestamp` >= '$datefrom' AND `timestamp` <= '$dateto'");
|
||||
$counttot = mysql_result($countsql,0);
|
||||
@@ -65,89 +67,87 @@ $counttot = mysql_result($countsql,0);
|
||||
$count = round($counttot / (($ysize - 100) * 2), 0);
|
||||
if ($count <= 1) { $count = 2; }
|
||||
|
||||
|
||||
#$count = 8;
|
||||
|
||||
#$count = round($counttot / 260, 0);
|
||||
#if ($count <= 1) { $count = 2; }
|
||||
|
||||
$max = mysql_result(mysql_query("SELECT delta FROM bill_data WHERE bill_id = $bill_id AND timestamp >= $datefrom AND timestamp <= $dateto ORDER BY delta DESC LIMIT 0,1"),0);
|
||||
if($max > 1000000) { $div = "1000000"; $yaxis = "Mbit/sec"; } else { $div = "1000"; $yaxis = "Kbit/sec"; }
|
||||
if ($max > 1000000) { $div = "1000000"; $yaxis = "Mbit/sec"; } else { $div = "1000"; $yaxis = "Kbit/sec"; }
|
||||
|
||||
$i = '0';
|
||||
|
||||
#$start = mysql_result(mysql_query("SELECT *, UNIX_TIMESTAMP(timestamp) AS formatted_date FROM bill_data WHERE bill_id = $bill_id AND timestamp >=$datefrom AND timestamp <= $dateto ORDER BY timestamp ASC LIMIT 0,1"),0);
|
||||
#$end = mysql_result(mysql_query("SELECT *, UNIX_TIMESTAMP(timestamp) AS formatted_date FROM bill_data WHERE bill_id = $bill_id AND timestamp >=$datefrom AND timestamp <= $dateto ORDER BY timestamp DESC LIMIT 0,1"),0);
|
||||
$dur = $end - $start;
|
||||
$dur = $end - $start;
|
||||
|
||||
$sql = "SELECT *, UNIX_TIMESTAMP(timestamp) AS formatted_date FROM bill_data WHERE bill_id = $bill_id AND timestamp >= $datefrom AND timestamp <= $dateto ORDER BY timestamp ASC";
|
||||
$data = mysql_query($sql);
|
||||
while($row = mysql_fetch_array($data))
|
||||
{
|
||||
|
||||
@$timestamp = $row['formatted_date'];
|
||||
if (!$first) { $first = $timestamp; }
|
||||
@$delta = $row['delta'];
|
||||
@$period = $row['period'];
|
||||
@$in_delta = $row['in_delta'];
|
||||
@$out_delta = $row['out_delta'];
|
||||
@$in_value = round($in_delta * 8 / $period / $div, 2);
|
||||
@$out_value = round($out_delta * 8 / $period / $div, 2);
|
||||
while ($row = mysql_fetch_array($data))
|
||||
{
|
||||
@$timestamp = $row['formatted_date'];
|
||||
if (!$first) { $first = $timestamp; }
|
||||
@$delta = $row['delta'];
|
||||
@$period = $row['period'];
|
||||
@$in_delta = $row['in_delta'];
|
||||
@$out_delta = $row['out_delta'];
|
||||
@$in_value = round($in_delta * 8 / $period / $div, 2);
|
||||
@$out_value = round($out_delta * 8 / $period / $div, 2);
|
||||
|
||||
#@$data[] = $in_value + $out_value;
|
||||
#@$in_data[] = $in_value;
|
||||
#@$data[] = $in_value + $out_value;
|
||||
#@$in_data[] = $in_value;
|
||||
#@$out_data[] = $out_value;
|
||||
# @$ticks[] = $timestamp;
|
||||
#@$per_data[] = $rate_95th / 1000;
|
||||
#@$ave_data[] = $rate_average / 1000;
|
||||
# @$ticks[] = $timestamp;
|
||||
#@$per_data[] = $rate_95th / 1000;
|
||||
#@$ave_data[] = $rate_average / 1000;
|
||||
|
||||
@$last = $timestamp;
|
||||
@$last = $timestamp;
|
||||
|
||||
$iter_in = $iter_in + $in_delta;
|
||||
$iter_out = $iter_out + $out_delta;
|
||||
$iter_period = $iter_period + $period;
|
||||
$iter_in = $iter_in + $in_delta;
|
||||
$iter_out = $iter_out + $out_delta;
|
||||
$iter_period = $iter_period + $period;
|
||||
|
||||
if ($iter == $count) {
|
||||
if ($iter == $count)
|
||||
{
|
||||
$out_data[$i] = round($iter_out * 8 / $iter_period / $div, 2);
|
||||
$in_data[$i] = round($iter_in * 8 / $iter_period / $div, 2);
|
||||
$tot_data[$i] = $out_data[$i] + $in_data[$i];
|
||||
$ticks[$i] = date('M j g:ia', $timestamp);
|
||||
$ticks[$i] = $timestamp;
|
||||
|
||||
if ($dur < 172800)
|
||||
{
|
||||
$hour = date('h', $timestamp);
|
||||
if ($hour != $lasthour) { $tickPositions[] = $i; $tickLabels[] = date('ga', $timestamp); }
|
||||
$lasthour = $hour;
|
||||
} elseif ($dur < 604800) {
|
||||
$day = date('d', $timestamp);
|
||||
if ($day != $lastday) { $tickPositions[] = $i; $tickLabels[] = date('D', $timestamp); $h = 0; }
|
||||
$lastday = $day;
|
||||
|
||||
$out_data[$i] = round($iter_out * 8 / $iter_period / $div, 2);
|
||||
$in_data[$i] = round($iter_in * 8 / $iter_period / $div, 2);
|
||||
$tot_data[$i] = $out_data[$i] + $in_data[$i];
|
||||
$ticks[$i] = date('M j g:ia', $timestamp);
|
||||
$ticks[$i] = $timestamp;
|
||||
|
||||
if($dur < 172800) {
|
||||
$hour = date('h', $timestamp);
|
||||
if($hour != $lasthour) { $tickPositions[] = $i; $tickLabels[] = date('ga', $timestamp); }
|
||||
$lasthour = $hour;
|
||||
$hour = trim(date('g', $timestamp));
|
||||
if ($hour != $lasthour)
|
||||
{
|
||||
if ($hour == '12') { $tickMinPositions[] = $i; $h = 0; } $h++;
|
||||
}
|
||||
|
||||
} elseif ($dur < 604800) {
|
||||
$day = date('d', $timestamp);
|
||||
if($day != $lastday) { $tickPositions[] = $i; $tickLabels[] = date('D', $timestamp); $h = 0; }
|
||||
$lastday = $day;
|
||||
$lasthour = $hour;
|
||||
} else {
|
||||
$day = date('d', $timestamp);
|
||||
if ($day != $lastday) { $tickPositions[] = $i; $tickLabels[] = date('dS', $timestamp); }
|
||||
$lastday = $day;
|
||||
}
|
||||
|
||||
$hour = trim(date('g', $timestamp));
|
||||
if($hour != $lasthour) {
|
||||
if($hour == '12') {$tickMinPositions[] = $i; $h = 0; } $h++;
|
||||
}
|
||||
$lasthour = $hour;
|
||||
|
||||
|
||||
} else {
|
||||
$day = date('d', $timestamp);
|
||||
if($day != $lastday) { $tickPositions[] = $i; $tickLabels[] = date('dS', $timestamp); }
|
||||
$lastday = $day;
|
||||
}
|
||||
|
||||
$per_data[$i] = $rate_95th / $div;
|
||||
$ave_data[$i] = $rate_average / $div;
|
||||
$timestamps[$i] = $timestamp;
|
||||
$iter = "1";
|
||||
$i++;
|
||||
unset($iter_out, $iter_in, $iter_period);
|
||||
}
|
||||
|
||||
$iter++;
|
||||
$per_data[$i] = $rate_95th / $div;
|
||||
$ave_data[$i] = $rate_average / $div;
|
||||
$timestamps[$i] = $timestamp;
|
||||
$iter = "1";
|
||||
$i++;
|
||||
unset($iter_out, $iter_in, $iter_period);
|
||||
}
|
||||
|
||||
$iter++;
|
||||
}
|
||||
|
||||
#print_r($ticks);
|
||||
@@ -167,15 +167,16 @@ $graph->img->SetImgFormat("png");
|
||||
#$graph->img->SetAntiAliasing(true);
|
||||
$graph->SetScale( "intlin");
|
||||
#$graph->SetScale('intlin',0,0,$xmin,$xmax);
|
||||
$graph->title->Set("$graph_name");
|
||||
$graph->title->Set("$graph_name");
|
||||
$graph->title->SetFont(FF_FONT2,FS_BOLD,10);
|
||||
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
|
||||
|
||||
#$graph->xaxis->SetTickLabels($ticks);
|
||||
|
||||
if(count($tickPositions) > 24) {
|
||||
if (count($tickPositions) > 24)
|
||||
{
|
||||
$graph->xaxis->SetTextLabelInterval(6);
|
||||
}elseif(count($tickPositions) > 12) {
|
||||
} elseif (count($tickPositions) > 12) {
|
||||
$graph->xaxis->SetTextLabelInterval(2);
|
||||
}
|
||||
|
||||
@@ -187,9 +188,9 @@ $graph->yaxis->SetLabelAngle(0);
|
||||
$graph->xaxis->title->SetFont(FF_FONT1,FS_NORMAL,10);
|
||||
$graph->yaxis->title->SetFont(FF_FONT1,FS_NORMAL,10);
|
||||
$graph->yaxis->SetTitleMargin(50);
|
||||
$graph->xaxis->SetTitleMargin(30);
|
||||
$graph->xaxis->SetTitleMargin(30);
|
||||
#$graph->xaxis->HideLastTickLabel();
|
||||
#$graph->xaxis->HideFirstTickLabel();
|
||||
#$graph->xaxis->HideFirstTickLabel();
|
||||
#$graph->yaxis->scale->SetAutoMin(1);
|
||||
#$graph->xaxis->title->Set("$type");
|
||||
$graph->yaxis->title->Set("$yaxis");
|
||||
@@ -216,29 +217,35 @@ $lineplot_out = new LinePlot($out_data);
|
||||
#$lineplot_out->SetLegend("Traffic Out");
|
||||
$lineplot_out->SetColor("blue");
|
||||
|
||||
if($_GET['95th']) {
|
||||
if ($_GET['95th'])
|
||||
{
|
||||
$lineplot_95th = new LinePlot($per_data);
|
||||
$lineplot_95th ->SetColor("red");
|
||||
}
|
||||
|
||||
if($_GET['ave']) {
|
||||
if ($_GET['ave'])
|
||||
{
|
||||
$lineplot_ave = new LinePlot($ave_data);
|
||||
$lineplot_ave ->SetColor("red");
|
||||
}
|
||||
|
||||
#$graph->legend->SetLayout(LEGEND_HOR);
|
||||
#$graph->legend->Pos(0.52, 0.85, 'center');
|
||||
#$graph->legend->Pos(0.52, 0.85, 'center');
|
||||
|
||||
$graph->Add($lineplot);
|
||||
$graph->Add($lineplot_in);
|
||||
$graph->Add($lineplot_out);
|
||||
if($_GET['95th']) {
|
||||
|
||||
if ($_GET['95th'])
|
||||
{
|
||||
$graph->Add($lineplot_95th);
|
||||
}
|
||||
if($_GET['ave']) {
|
||||
|
||||
if ($_GET['ave'])
|
||||
{
|
||||
$graph->Add($lineplot_ave);
|
||||
}
|
||||
|
||||
$graph->stroke();
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
include("includes/graphs/graph.inc.php");
|
||||
|
||||
?>
|
||||
?>
|
||||
137
html/index.php
137
html/index.php
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
ob_start();
|
||||
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('display_errors', 0);
|
||||
ob_start();
|
||||
|
||||
if(strpos($_SERVER['REQUEST_URI'], "debug")) {
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('display_errors', 0);
|
||||
|
||||
if (strpos($_SERVER['REQUEST_URI'], "debug"))
|
||||
{
|
||||
$debug = "1";
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
@@ -18,32 +19,35 @@ if(strpos($_SERVER['REQUEST_URI'], "debug")) {
|
||||
ini_set('error_reporting', 0);
|
||||
}
|
||||
|
||||
include("../includes/defaults.inc.php");
|
||||
include("../config.php");
|
||||
include("../includes/functions.php");
|
||||
include("includes/functions.inc.php");
|
||||
include("includes/authenticate.inc.php");
|
||||
include("../includes/defaults.inc.php");
|
||||
include("../config.php");
|
||||
include("../includes/functions.php");
|
||||
include("includes/functions.inc.php");
|
||||
include("includes/authenticate.inc.php");
|
||||
|
||||
$start = utime();
|
||||
$now = time();
|
||||
$day = time() - (24 * 60 * 60);
|
||||
$twoday = time() - (2 * 24 * 60 * 60);
|
||||
$week = time() - (7 * 24 * 60 * 60);
|
||||
$month = time() - (31 * 24 * 60 * 60);
|
||||
$year = time() - (365 * 24 * 60 * 60);
|
||||
$start = utime();
|
||||
$now = time();
|
||||
$day = time() - (24 * 60 * 60);
|
||||
$twoday = time() - (2 * 24 * 60 * 60);
|
||||
$week = time() - (7 * 24 * 60 * 60);
|
||||
$month = time() - (31 * 24 * 60 * 60);
|
||||
$year = time() - (365 * 24 * 60 * 60);
|
||||
|
||||
# Load the settings for Multi-Tenancy.
|
||||
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;");
|
||||
}
|
||||
}
|
||||
# Load the settings for Multi-Tenancy.
|
||||
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;");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
@@ -54,7 +58,7 @@ if(strpos($_SERVER['REQUEST_URI'], "debug")) {
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
|
||||
<meta http-equiv="content-language" content="en-us" />
|
||||
<?php
|
||||
if($config['page_refresh']) { echo("<meta http-equiv='refresh' content='".$config['page_refresh']."'>"); }
|
||||
if ($config['page_refresh']) { echo("<meta http-equiv='refresh' content='".$config['page_refresh']."'>"); }
|
||||
?>
|
||||
<link href="<?php echo($config['stylesheet']); ?>" rel="stylesheet" type="text/css" />
|
||||
<link rel="shortcut icon" href="<?php echo($config['favicon']); ?>" />
|
||||
@@ -64,10 +68,11 @@ if(strpos($_SERVER['REQUEST_URI'], "debug")) {
|
||||
<script type="text/javascript" src="js/mktree.js"></script>
|
||||
<script type="text/javascript">
|
||||
<!-- Begin
|
||||
function popUp(URL) {
|
||||
function popUp(URL)
|
||||
{
|
||||
day = new Date();
|
||||
id = day.getTime();
|
||||
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600');");
|
||||
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600');");
|
||||
}
|
||||
// End -->
|
||||
</script>
|
||||
@@ -77,7 +82,7 @@ function popUp(URL) {
|
||||
|
||||
<?php include("includes/".$config['web_header']); ?>
|
||||
|
||||
<?php if($_SESSION['authenticated']) {include("includes/print-menubar.php");} else {echo('<hr color="#444444" />');} ?>
|
||||
<?php if ($_SESSION['authenticated']) {include("includes/print-menubar.php"); } else {echo('<hr color="#444444" />'); } ?>
|
||||
|
||||
<div class="clearer"></div>
|
||||
|
||||
@@ -85,51 +90,53 @@ function popUp(URL) {
|
||||
<div id="content" style="border: 1px none #ccc; min-height:650px;">
|
||||
<div style="margin: 7px;"></div>
|
||||
<?php
|
||||
if($_SESSION['authenticated']) {
|
||||
## Authenticated. Print a page.
|
||||
if(isset($_GET['page']) && !strstr("..", $_GET['page']) && is_file("pages/" . $_GET['page'] . ".inc.php")) {
|
||||
include("pages/" . $_GET['page'] . ".inc.php");
|
||||
} else {
|
||||
if(isset($config['front_page']) && is_file($config['front_page'])) {
|
||||
include($config['front_page']);
|
||||
} else {
|
||||
include("pages/front/default.php");
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SESSION['authenticated'])
|
||||
{
|
||||
## Authenticated. Print a page.
|
||||
if (isset($_GET['page']) && !strstr("..", $_GET['page']) && is_file("pages/" . $_GET['page'] . ".inc.php"))
|
||||
{
|
||||
include("pages/" . $_GET['page'] . ".inc.php");
|
||||
} else {
|
||||
## Not Authenticated. Print login.
|
||||
include("pages/logon.inc.php");
|
||||
exit;
|
||||
}
|
||||
if (isset($config['front_page']) && is_file($config['front_page']))
|
||||
{
|
||||
include($config['front_page']);
|
||||
} else {
|
||||
include("pages/front/default.php");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
## Not Authenticated. Print login.
|
||||
include("pages/logon.inc.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$end = utime(); $run = $end - $start;
|
||||
$gentime = substr($run, 0, 5);
|
||||
$end = utime(); $run = $end - $start;
|
||||
$gentime = substr($run, 0, 5);
|
||||
|
||||
echo('<br /> <br /> <br /> <br /> <div id="footer">' . (isset($config['footer']) ? $config['footer'] : ''));
|
||||
echo('<br />Powered by <a href="http://www.observium.org" target="_blank">Observium ' . $config['version']);
|
||||
echo('<br /> <br /> <br /> <br /> <div id="footer">' . (isset($config['footer']) ? $config['footer'] : ''));
|
||||
echo('<br />Powered by <a href="http://www.observium.org" target="_blank">Observium ' . $config['version']);
|
||||
|
||||
if (file_exists('.svn/entries'))
|
||||
{
|
||||
$svn = File('.svn/entries');
|
||||
echo('-SVN r' . trim($svn[3]));
|
||||
unset($svn);
|
||||
}
|
||||
if (file_exists('.svn/entries'))
|
||||
{
|
||||
$svn = File('.svn/entries');
|
||||
echo('-SVN r' . trim($svn[3]));
|
||||
unset($svn);
|
||||
}
|
||||
|
||||
echo('</a>. Copyright © 2006-'. date("Y"). ' by Adam Armstrong. All rights reserved.');
|
||||
echo('</a>. Copyright © 2006-'. date("Y"). ' by Adam Armstrong. All rights reserved.');
|
||||
|
||||
if ($config['page_gen'])
|
||||
{
|
||||
echo('<br />Generated in ' . $gentime . ' seconds.');
|
||||
}
|
||||
if ($config['page_gen'])
|
||||
{
|
||||
echo('<br />Generated in ' . $gentime . ' seconds.');
|
||||
}
|
||||
|
||||
echo('</div>');
|
||||
echo('</div>');
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
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>');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
?>
|
||||
@@ -39,9 +39,9 @@ if ($_GET['query'] && $_GET['cmd']) {
|
||||
} else {
|
||||
$cmd = $config['nmap'] . " $host";
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!empty($cmd))
|
||||
{
|
||||
$output = `$cmd`;
|
||||
|
||||
Reference in New Issue
Block a user