html pages cleanup

git-svn-id: http://www.observium.org/svn/observer/trunk@1902 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-17 11:48:03 +00:00
parent a14ae7e60a
commit a32bff3c81
6 changed files with 210 additions and 191 deletions

View File

@@ -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,7 +16,6 @@ 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']))

View File

@@ -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);
@@ -18,7 +19,8 @@ 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 (is_numeric($_GET['bill_id']))
{
if (bill_permitted($_GET['bill_id']))
{
$bill_id = $_GET['bill_id'];
@@ -65,7 +67,6 @@ $counttot = mysql_result($countsql,0);
$count = round($counttot / (($ysize - 100) * 2), 0);
if ($count <= 1) { $count = 2; }
#$count = 8;
#$count = round($counttot / 260, 0);
@@ -82,9 +83,9 @@ $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'];
@@ -107,31 +108,31 @@ while($row = mysql_fetch_array($data))
$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) {
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;
$hour = trim(date('g', $timestamp));
if($hour != $lasthour) {
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); }
@@ -147,7 +148,6 @@ while($row = mysql_fetch_array($data))
}
$iter++;
}
#print_r($ticks);
@@ -173,7 +173,8 @@ $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) {
$graph->xaxis->SetTextLabelInterval(2);
@@ -216,12 +217,14 @@ $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");
}
@@ -232,10 +235,14 @@ if($_GET['ave']) {
$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);
}

View File

@@ -4,7 +4,8 @@
ini_set('allow_url_fopen', 0);
ini_set('display_errors', 0);
if(strpos($_SERVER['REQUEST_URI'], "debug")) {
if (strpos($_SERVER['REQUEST_URI'], "debug"))
{
$debug = "1";
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
@@ -34,12 +35,15 @@ if(strpos($_SERVER['REQUEST_URI'], "debug")) {
# 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) {
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) {
foreach ($config['branding']['default'] as $confitem => $confval)
{
eval("\$config['" . $confitem . "'] = \$confval;");
}
}
@@ -64,7 +68,8 @@ 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');");
@@ -85,12 +90,15 @@ function popUp(URL) {
<div id="content" style="border: 1px none #ccc; min-height:650px;">
<div style="margin: 7px;"></div>
<?php
if($_SESSION['authenticated']) {
if ($_SESSION['authenticated'])
{
## Authenticated. Print a page.
if(isset($_GET['page']) && !strstr("..", $_GET['page']) && is_file("pages/" . $_GET['page'] . ".inc.php")) {
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'])) {
if (isset($config['front_page']) && is_file($config['front_page']))
{
include($config['front_page']);
} else {
include("pages/front/default.php");
@@ -132,4 +140,3 @@ function popUp(URL) {
?>
</body>
</html>

View File

@@ -10,25 +10,27 @@ 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) {
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) {
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];
@@ -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'];
@@ -170,4 +174,5 @@ else
</center>');
}
}
?>