restructure/reindent/htmlfix html pages, remove dead code

git-svn-id: http://www.observium.org/svn/observer/trunk@1897 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-17 00:09:20 +00:00
parent 1a477eebbe
commit 834989df95
65 changed files with 1447 additions and 1510 deletions

View File

@@ -1,20 +1,22 @@
<?php
if($_SESSION['userlevel'] < 10) {
echo("<span class='alert'>You are not permitted to perform this function</span>");
exit;
if ($_SESSION['userlevel'] < 10)
{
# FIXME generic box?
echo("<span class='alert'>You are not permitted to perform this function</span>");
exit;
}
echo("<h2>Add Device</h2>");
if($_POST['hostname'] && $_POST['community']) {
if($_SESSION['userlevel'] > '5') {
if ($_POST['hostname'] && $_POST['community'])
{
if ($_SESSION['userlevel'] > '5')
{
$hostname = mres($_POST['hostname']);
$community = mres($_POST['community']);
$snmpver = mres($_POST['snmpver']);
if($_POST['port']) { $port = mres($_POST['port']); } else { $port = "161"; }
if ($_POST['port']) { $port = mres($_POST['port']); } else { $port = "161"; }
echo("<p class='messagebox'>");
echo("Adding host $hostname community $community port $port</p>");
$result = addHost($hostname, $community, $snmpver, $port);
@@ -22,10 +24,10 @@ if($_POST['hostname'] && $_POST['community']) {
} else {
echo("<p class='errorbox'><b>Error:</b> You don't have the necessary privileges to add hosts.</p>");
}
} elseif ( $_POST['hostname'] && !$_POST['community'] ) {
} elseif ($_POST['hostname'] && !$_POST['community'] ) {
echo("<p class='errorbox'><b>Error:</b> A community string is required.</p>");
} elseif ( !$_POST['hostname'] && $_POST['community'] ) {
echo("<p class='errorbox'><b>Error:</b> A hostname is required.</p>");
} elseif (!$_POST['hostname'] && $_POST['community'] ) {
echo("<p class='errorbox'><b>Error:</b> A hostname is required.</p>");
}
?>

View File

@@ -1,32 +1,41 @@
<?php
if($_SESSION['userlevel'] < '10') {
if ($_SESSION['userlevel'] < '10')
{
## FIXME generic "box" include?
echo("<span class='alert'>Insufficient privileges to perform this function.</span>");
} else {
if($_POST['addsrv']) {
if($_SESSION['userlevel'] == '10') {
include("includes/service-add.inc.php");
}
}
else
{
if ($_POST['addsrv'])
{
if ($_SESSION['userlevel'] == '10')
{
include("includes/service-add.inc.php");
}
}
if ($handle = opendir($config['install_dir'] . "/includes/services/")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && !strstr($file, ".")) {
$servicesform .= "<option value='$file'>$file</option>";
}
if ($handle = opendir($config['install_dir'] . "/includes/services/"))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && !strstr($file, "."))
{
$servicesform .= "<option value='$file'>$file</option>";
}
}
closedir($handle);
}
}
$query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`");
while($device = mysql_fetch_array($query)) {
$devicesform .= "<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>";
}
$query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`");
while ($device = mysql_fetch_array($query))
{
$devicesform .= "<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>";
}
if($updated) { print_message("Device Settings Saved"); }
if ($updated) { print_message("Device Settings Saved"); }
echo("
echo("
<h4>Add Service</h4>
<form id='addsrv' name='addsrv' method='post' action=''>
<input type=hidden name='addsrv' value='yes'>
@@ -70,6 +79,6 @@ echo("
</label>
</form>");
}
?>

View File

@@ -2,7 +2,7 @@
echo("<div style='margin: 10px;'>");
if($_SESSION['userlevel'] != '10')
if ($_SESSION['userlevel'] != '10')
{
include("includes/error-no-perm.inc.php");
}
@@ -12,9 +12,9 @@ else
if (auth_usermanagement())
{
if($_POST['action'] == "add")
if ($_POST['action'] == "add")
{
if($_POST['new_username'])
if ($_POST['new_username'])
{
if (!user_exists($_POST['new_username']))
{
@@ -40,7 +40,7 @@ else
?>
Password <input style='margin: 1px;' name='new_password' id='new_password' type=password /><br />
<?php
if($_POST['action'] == "add" && !$_POST['new_password'])
if ($_POST['action'] == "add" && !$_POST['new_password'])
{
echo("<span class=red>Please enter a password!</span><br />");
}

View File

@@ -1,71 +0,0 @@
<meta http-equiv="refresh" content="60">
<?php
# FIXME is this used anywhere??
if($_GET['del']) {
$id = mres($_GET['del']);
$query = "DELETE FROM `alerts` WHERE `id` = '$id'";
mysql_query($query);
}
$sql = "select *,DATE_FORMAT(time_logged, '%D %M %Y %T') as time, A.id as id, D.id as device_id from alerts AS A, devices as D WHERE A.device_id = D.id ORDER BY time_logged DESC LIMIT 100";
echo("
<table cellspacing=0 cellpadding=2 width=100%>
");
$query = mysql_query($sql);
while($event = mysql_fetch_array($query))
{
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
$type = $event[importance];
switch ($type) {
case "9":
$type = "<img src='images/16/flag_red.png'>";
break;
case "7":
$type = "<img src='images/16/flag_pink.png'>";
break;
case "2":
$type = "<img src='images/16/flag_blue.png'>";
break;
case "0":
$type = "<img src='images/16/flag_green.png'>";
break;
}
if(!$argh) {
echo("
<tr style=\"background-color: $bg;\">
<td width=10></td>
<td class=syslog width=200>
$event[time]
</td>
<td class=syslog width=200>
$event[hostname]
</td>
<td width=20>
$type
</td>
<td class=syslog align=left>
$event[message]
</td>
<td>
</td>
<td width=40>
<a href='?page=alerts&del=$event[id]'><img border=0 src='images/16/cross.png'" . overlibprint("Remove Alert") . "'></a>
<a href='?page=alerts&ack=$event[id]'><img border=0 src='images/16/tick.png' onmouseover=\"return overlib('Acknowledge Alert');\" onmouseout=\"return nd();\"></a>
</td>
</tr>
");
}
}
?>
</table>

View File

@@ -1,19 +1,17 @@
<?php
if($_SESSION['userlevel'] == '10') {
if ($_SESSION['userlevel'] == '10')
{
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250";
$data = mysql_query($query);
echo("<table cellspacing=0 cellpadding=1 width=100%>");
$data = mysql_query($query);
while ($entry = mysql_fetch_array($data))
{
if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
echo("<table cellspacing=0 cellpadding=1 width=100%>");
while($entry = mysql_fetch_array($data)) {
if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
echo("<tr style=\"background-color: $bg\">
echo("<tr style=\"background-color: $bg\">
<td class=syslog width=160>
" . $entry['datetime'] . "
</td>
@@ -28,16 +26,9 @@ while($entry = mysql_fetch_array($data)) {
</td>
<td></td>
");
}
}
echo("</table>");
} else {
echo("</table>");
}
?>

View File

@@ -11,7 +11,7 @@ else
$i = "1";
if($_GET['opta'] == "alerts") {
if ($_GET['opta'] == "alerts") {
$where = "AND (B.bgpPeerAdminStatus = 'start' or B.bgpPeerAdminStatus = 'running') AND B.bgpPeerState != 'established'";
} elseif ($_GET['opta'] == "external") {
$where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs";
@@ -19,24 +19,23 @@ else
$where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs";
}
$peer_query = mysql_query("select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id $where ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier");
while($peer = mysql_fetch_array($peer_query))
while ($peer = mysql_fetch_array($peer_query))
{
unset($bg_image);
if(!is_integer($i/2)) { $bg_colour = $list_colour_b; } else { $bg_colour = $list_colour_a; }
if (!is_integer($i/2)) { $bg_colour = $list_colour_b; } else { $bg_colour = $list_colour_a; }
if($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; if ($_GET['opta'] != "alerts") { $bg_image = "images/warning-background.png"; } }
if($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; }
if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; if ($_GET['opta'] != "alerts") { $bg_image = "images/warning-background.png"; } }
if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; }
if($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "<span style='color: #00f;'>iBGP</span>"; } else { $peer_type = "<span style='color: #0a0;'>eBGP</span>";
if($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "<span style='color: #f00;'>Priv eBGP</span>"; }
if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "<span style='color: #00f;'>iBGP</span>"; } else { $peer_type = "<span style='color: #0a0;'>eBGP</span>";
if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "<span style='color: #f00;'>Priv eBGP</span>"; }
}
$peerhost = mysql_fetch_array(mysql_query("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
if($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); }
if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); }
echo("<tr bgcolor=$bg_colour background=$bg_image>
<td></td>
@@ -50,41 +49,40 @@ else
Updates <img src='images/16/arrow_down.png' align=absmiddle> " . format_si($peer['bgpPeerInUpdates']) . "
<img src='images/16/arrow_up.png' align=absmiddle> " . format_si($peer['bgpPeerOutUpdates']) . "</td></tr>");
if($graphs) {
if ($graphs)
{
$graph_type = "bgpupdates";
$daily_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100";
$daily_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150";
$daily_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100";
$daily_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150";
$weekly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=210&height=100";
$weekly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150";
$weekly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=210&height=100";
$weekly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150";
$monthly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=210&height=100";
$monthly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150";
$monthly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=210&height=100";
$monthly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150";
$yearly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=210&height=100";
$yearly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150";
$yearly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=210&height=100";
$yearly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150";
echo("<tr><td colspan=6>");
echo("<tr><td colspan=6>");
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
<img src='$daily_traffic' border=0></a> ");
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
<img src='$weekly_traffic' border=0></a> ");
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
<img src='$monthly_traffic' border=0></a> ");
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
<img src='$yearly_traffic' border=0></a>");
echo("</td></tr>");
}
$i++;
}
echo("</table></div>");
}
?>

View File

@@ -2,13 +2,13 @@
$bill_id = mres($_GET['opta']);
if($_SESSION['userlevel'] == "10")
if ($_SESSION['userlevel'] == "10")
{
include("pages/bill/actions.inc.php");
}
if(bill_permitted($bill_id)) {
if (bill_permitted($bill_id))
{
$bi_q = mysql_query("SELECT * FROM bills WHERE bill_id = $bill_id");
$bill_data = mysql_fetch_array($bi_q);
@@ -39,14 +39,17 @@ if(bill_permitted($bill_id)) {
$total_data = $rate_data['total_data'];
$rate_average = $rate_data['rate_average'];
if ($rate_95th > $paid_kb) {
$over = $rate_95th - $paid_kb;
$bill_text = $over . "Kbit excess.";
$bill_color = "#cc0000";
} else {
$under = $paid_kb - $rate_95th;
$bill_text = $under . "Kbit headroom.";
$bill_color = "#0000cc";
if ($rate_95th > $paid_kb)
{
$over = $rate_95th - $paid_kb;
$bill_text = $over . "Kbit excess.";
$bill_color = "#cc0000";
}
else
{
$under = $paid_kb - $rate_95th;
$bill_text = $under . "Kbit headroom.";
$bill_color = "#0000cc";
}
$fromtext = mysql_result(mysql_query("SELECT DATE_FORMAT($datefrom, '%M %D %Y')"), 0);
@@ -59,40 +62,39 @@ if(bill_permitted($bill_id)) {
print_optionbar_start();
if(!$_GET['optb']) { $_GET['optb'] = "details"; }
if (!$_GET['optb']) { $_GET['optb'] = "details"; }
if($_GET['optb'] == "details") { echo("<strong>"); }
if ($_GET['optb'] == "details") { echo("<strong>"); }
echo("<a href='bill/".$bill_id."/details/'>Details</a>");
if($_GET['optb'] == "details") { echo("</strong>"); }
if ($_GET['optb'] == "details") { echo("</strong>"); }
if($_SESSION['userlevel'] == "10")
if ($_SESSION['userlevel'] == "10")
{
echo(" | ");
if($_GET['optb'] == "edit") { echo("<strong>"); }
if ($_GET['optb'] == "edit") { echo("<strong>"); }
echo("<a href='bill/".$bill_id."/edit/'>Edit</a>");
if($_GET['optb'] == "edit") { echo("</strong>"); }
if ($_GET['optb'] == "edit") { echo("</strong>"); }
echo(" | ");
if($_GET['optb'] == "delete") { echo("<strong>"); }
if ($_GET['optb'] == "delete") { echo("<strong>"); }
echo("<a href='bill/".$bill_id."/delete/'>Delete</a>");
if($_GET['optb'] == "delete") { echo("</strong>"); }
if ($_GET['optb'] == "delete") { echo("</strong>"); }
}
print_optionbar_end();
# echo("<table width=715 border=0 cellspace=0 cellpadding=0><tr><td>");
if($_GET['optb'] == "edit" && $_SESSION['userlevel'] == "10") {
if ($_GET['optb'] == "edit" && $_SESSION['userlevel'] == "10")
{
include("pages/bill/edit.inc.php");
} elseif($_GET['optb'] == "delete" && $_SESSION['userlevel'] == "10") {
}
elseif ($_GET['optb'] == "delete" && $_SESSION['userlevel'] == "10")
{
include("pages/bill/delete.inc.php");
} elseif($_GET['optb'] == "details") {
}
elseif ($_GET['optb'] == "details")
{
echo("<h3>Billed Ports</h3>");
@@ -100,16 +102,15 @@ if(bill_permitted($bill_id)) {
WHERE B.bill_id = '".$bill_id."' AND P.interface_id = B.port_id
AND D.device_id = P.device_id");
while ($port = mysql_fetch_array($ports)) {
echo(generate_port_link($port) . " on " . generate_device_link($port) . "<br />");
while ($port = mysql_fetch_array($ports))
{
echo(generate_port_link($port) . " on " . generate_device_link($port) . "<br />");
}
echo("<h3>Bill Summary</h3>");
if($bill_data['bill_type'] == "quota") {
if ($bill_data['bill_type'] == "quota")
{
// The Customer is billed based on a pre-paid quota
echo("<h4>Quota Bill</h4>");
@@ -122,27 +123,26 @@ if(bill_permitted($bill_id)) {
<br />Average rate " . formatRates($rate_average * 1000));
if ($percent > 100) { $perc = "100"; } else { $perc = $percent; }
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
} else { $left_background='9abf5b'; $right_background='bbd392'; }
echo("<p>".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $left_background, $percent . "%", "ffffff", $right_background)."</p>");
$type="&ave=yes";
} elseif($bill_data['bill_type'] == "cdr") {
}
elseif ($bill_data['bill_type'] == "cdr")
{
// The customer is billed based on a CDR with 95th%ile overage
echo("<h4>CDR / 95th Bill</h4>");
$unit = "kbps";
$cdr = $bill_data['bill_cdr'];
if($rate_95th > "1000") { $rate_95th = $rate_95th / 1000; $cdr = $cdr / 1000; $unit = "Mbps"; }
if($rate_95th > "1000") { $rate_95th = $rate_95th / 1000; $cdr = $cdr / 1000; $unit = "Gps"; }
if ($rate_95th > "1000") { $rate_95th = $rate_95th / 1000; $cdr = $cdr / 1000; $unit = "Mbps"; }
if ($rate_95th > "1000") { $rate_95th = $rate_95th / 1000; $cdr = $cdr / 1000; $unit = "Gps"; }
$rate_95th = round($rate_95th, 2);
$percent = round(($rate_95th) / $cdr * 100, 2);
@@ -153,15 +153,14 @@ if(bill_permitted($bill_id)) {
<br />Measured ".$rate_95th."$unit of ".$cdr."$unit (".$percent."%)");
if ($percent > 100) { $perc = "100"; } else { $perc = $percent; }
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
} else { $left_background='9abf5b'; $right_background='bbd392'; }
echo("<p>".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $left_background, $percent . "%", "ffffff", $right_background)."</p>");
# echo("<p>Billing Period : " . $fromtext . " to " . $totext . "<br />
# " . $paidrate_text . " <br />
# " . $total_data . "MB transfered in the current billing cycle. <br />
@@ -179,10 +178,9 @@ if(bill_permitted($bill_id)) {
# $bi = $bi . "&x=715&y=250";
# $bi = $bi . "$type'>";
$bi = "<img src='graph.php?type=bill_bits&id=" . $bill_id;
$bi = $bi . "&from=" . $unixfrom . "&to=" . $unixto;
$bi = $bi . "&width=715&height=200&total=1'>";
$bi = "<img src='graph.php?type=bill_bits&id=" . $bill_id;
$bi .= "&from=" . $unixfrom . "&to=" . $unixto;
$bi .= "&width=715&height=200&total=1'>";
$lastmonth = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"), 0);
$yesterday = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"), 0);
@@ -192,23 +190,23 @@ if(bill_permitted($bill_id)) {
# $di = $di . "&from=" . $yesterday . "&to=" . $rightnow . "&x=715&y=250";
# $di = $di . "$type'>";
$di = "<img src='graph.php?type=bill_bits&id=" . $bill_id;
$di = $di . "&from=" . $config['day'] . "&to=" . $config['now'];
$di = $di . "&width=715&height=200&total=1'>";
$di = "<img src='graph.php?type=bill_bits&id=" . $bill_id;
$di .= "&from=" . $config['day'] . "&to=" . $config['now'];
$di .= "&width=715&height=200&total=1'>";
# $mi = "<img src='billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
# $mi = $mi . "&from=" . $lastmonth . "&to=" . $rightnow . "&x=715&y=250";
# $mi = $mi . "$type'>";
$mi = "<img src='graph.php?type=bill_bits&id=" . $bill_id;
$mi = $mi . "&from=" . $lastmonth . "&to=" . $rightnow;
$mi = $mi . "&width=715&height=200&total=1'>";
$mi = "<img src='graph.php?type=bill_bits&id=" . $bill_id;
$mi .= "&from=" . $lastmonth . "&to=" . $rightnow;
$mi .= "&width=715&height=200&total=1'>";
if($null) {
echo("
if ($null)
{
echo("
<script type='text/javascript' src='js/calendarDateInput.js'>
</script>
@@ -231,32 +229,33 @@ if(bill_permitted($bill_id)) {
}
if ($_GET[all]) {
$ai = "<img src=\"billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
$ai = $ai . "&from=0&to=" . $rightnow;
$ai = $ai . "&x=715&y=250";
$ai = $ai . "&count=60\">";
echo("<h3>Entire Data View</h3>$ai");
} elseif ($_GET[custom]) {
$cg = "<img src=\"billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
$cg = $cg . "&from=" . $_GET['fromdate'] . "000000&to=" . $_GET['todate'] . "235959";
$cg = $cg . "&x=715&y=250";
$cg = $cg . "&count=60\">";
echo("<h3>Custom Graph</h3>$cg");
} else {
if ($_GET['all'])
{
$ai = "<img src=\"billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
$ai .= "&from=0&to=" . $rightnow;
$ai .= "&x=715&y=250";
$ai .= "&count=60\">";
echo("<h3>Entire Data View</h3>$ai");
}
elseif ($_GET['custom'])
{
$cg = "<img src=\"billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
$cg .= "&from=" . $_GET['fromdate'] . "000000&to=" . $_GET['todate'] . "235959";
$cg .= "&x=715&y=250";
$cg .= "&count=60\">";
echo("<h3>Custom Graph</h3>$cg");
}
else
{
echo("<h3>Billing View</h3>$bi<h3>24 Hour View</h3>$di");
echo("<h3>Monthly View</h3>$mi");
# echo("<br /><a href=\"rate.php?" . $_SERVER['QUERY_STRING'] . "&all=yes\">Graph All Data (SLOW)</a>");
}
} # End if details
} else {
}
else
{
include("includes/error-no-perm.inc.php");
}
?>

View File

@@ -1,9 +1,9 @@
<?php
if($_POST['action'] == "delete_bill" && $_POST['confirm'] == "confirm") {
if ($_POST['action'] == "delete_bill" && $_POST['confirm'] == "confirm") {
$port_query = mysql_query("SELECT * FROM `bill_ports` WHERE `bill_id` = '$bill_id'");
while($port_data = mysql_fetch_array($port_query)) {
while ($port_data = mysql_fetch_array($port_query)) {
mysql_query("DELETE FROM `port_in_measurements` WHERE `port_id` = '".mres($port_data['bill_id'])."'");
mysql_query("DELETE FROM `port_out_measurements` WHERE `port_id` = '".mres($port_data['bill_id'])."'");
}
@@ -20,9 +20,9 @@ if($_POST['action'] == "delete_bill" && $_POST['confirm'] == "confirm") {
}
if($_POST['action'] == "add_bill_port") { mysql_query("INSERT INTO `bill_ports` (`bill_id`, `port_id`) VALUES ('".mres($_POST['bill_id'])."','".mres($_POST['interface_id'])."')"); }
if($_POST['action'] == "delete_bill_port") { mysql_query("DELETE FROM `bill_ports` WHERE `bill_id` = '".mres($bill_id)."' AND `port_id` = '".mres($_POST['interface_id'])."'"); }
if($_POST['action'] == "update_bill") {
if ($_POST['action'] == "add_bill_port") { mysql_query("INSERT INTO `bill_ports` (`bill_id`, `port_id`) VALUES ('".mres($_POST['bill_id'])."','".mres($_POST['interface_id'])."')"); }
if ($_POST['action'] == "delete_bill_port") { mysql_query("DELETE FROM `bill_ports` WHERE `bill_id` = '".mres($bill_id)."' AND `port_id` = '".mres($_POST['interface_id'])."'"); }
if ($_POST['action'] == "update_bill") {
mysql_query("UPDATE `bills` SET `bill_name` = '".mres($_POST['bill_name'])."',
`bill_day` = '".mres($_POST['bill_day'])."',
`bill_gb` = '".mres($_POST['bill_gb'])."',
@@ -30,7 +30,7 @@ if($_POST['action'] == "update_bill") {
`bill_type` = '".mres($_POST['bill_type'])."'
WHERE `bill_id` = '".mres($bill_id)."'");
if(mysql_affected_rows())
if (mysql_affected_rows())
{
echo("<div class=infobox>Bill Properties Updated</div>");
}

View File

@@ -67,19 +67,19 @@ $ports_array = mysql_query("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devi
WHERE B.bill_id = '".$bill_data['bill_id']."' AND P.interface_id = B.port_id
AND D.device_id = P.device_id");
if(mysql_affected_rows())
if (mysql_affected_rows())
{
echo("<h3>Billed Ports</h3>");
echo("<table cellpadding=5 cellspacing=0>");
while($port = mysql_fetch_array($ports_array))
while ($port = mysql_fetch_array($ports_array))
{
if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
echo("<tr style=\"background-color: $bg\">");
echo("<td>");
echo(generate_device_link($port) . " - " . generate_port_link($port));
if($port['ifAlias']) { echo(" - " . $port['ifAlias']); }
if ($port['ifAlias']) { echo(" - " . $port['ifAlias']); }
echo("</td><td>");
echo("<form action='' method='post'><input type='hidden' name='action' value='delete_bill_port'>
<input type=hidden name=interface_id value='".$port['interface_id']."'>
@@ -100,10 +100,10 @@ if(mysql_affected_rows())
<option value=''>Select a device</option>");
$device_list = mysql_query("SELECT * FROM `devices` ORDER BY hostname");
while($device = mysql_fetch_array($device_list)) {
while ($device = mysql_fetch_array($device_list)) {
unset($done);
foreach($access_list as $ac) { if($ac == $device['device_id']) { $done = 1; } }
if(!$done) { echo("<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>"); }
foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } }
if (!$done) { echo("<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>"); }
}
echo("</select></td></tr><tr>

View File

@@ -1,8 +1,7 @@
<?php
if($_POST['addbill'] == "yes") {
if ($_POST['addbill'] == "yes")
{
$updated = '1';
$sql = "INSERT INTO `bills` (`bill_name`,`bill_type`,`bill_cdr`,`bill_day`,`bill_gb`, `bill_custid`, `bill_ref`, `bill_notes`)
@@ -16,13 +15,12 @@ if($_POST['addbill'] == "yes") {
$message .= $message_break . "Bill ".mres($_POST['bill_name'])." added!";
$message_break .= "<br />";
}
echo("<meta http-equiv='refresh' content='10000'>");
if($_GET['opta'] == "add") {
if ($_GET['opta'] == "add")
{
?>
<div style='padding:10px;font-size:20px; font-weight: bold;'>Add Bill</div>
@@ -74,12 +72,11 @@ if($_GET['opta'] == "add") {
<?php
} else {
print_optionbar_start('40');
print_optionbar_start('40');
?>
?>
<table cellpadding=7 cellspacing=0 class=devicetable width=100%>
<form method='post' action=''>
@@ -120,48 +117,51 @@ print_optionbar_start('40');
<?php
print_optionbar_end();
print_optionbar_end();
$sql = "SELECT * FROM `bills` ORDER BY `bill_name`";
$query = mysql_query($sql);
echo("<table border=0 cellspacing=0 cellpadding=5 class=devicetable width=100%>");
$i=1;
while($bill = mysql_fetch_array($query)) {
#echo("<pre>");
#print_r($permissions);
#echo("</pre>");
if(bill_permitted($bill['bill_id'])) {
unset($class);
$day_data = getDates($bill['bill_day']);
$datefrom = $day_data['0'];
$dateto = $day_data['1'];
$rate_data = getRates($bill['bill_id'],$datefrom,$dateto);
$rate_95th = $rate_data['rate_95th'];
$dir_95th = $rate_data['dir_95th'];
$total_data = $rate_data['total_data'];
$rate_average = $rate_data['rate_average'];
while ($bill = mysql_fetch_array($query))
{
#echo("<pre>");
#print_r($permissions);
#echo("</pre>");
if (bill_permitted($bill['bill_id']))
{
unset($class);
$day_data = getDates($bill['bill_day']);
$datefrom = $day_data['0'];
$dateto = $day_data['1'];
$rate_data = getRates($bill['bill_id'],$datefrom,$dateto);
$rate_95th = $rate_data['rate_95th'];
$dir_95th = $rate_data['dir_95th'];
$total_data = $rate_data['total_data'];
$rate_average = $rate_data['rate_average'];
if($bill['bill_type'] == "cdr") {
$type = "CDR";
$allowed = formatRates($bill['bill_cdr'] * 1000);
$used = formatRates($rate_data['rate_95th'] * 1000);
$percent = round(($rate_data['rate_95th'] / $bill['bill_cdr']) * 100,2);
} elseif ($bill['bill_type'] == "quota") {
$type = "Quota";
$allowed = formatStorage($bill['bill_gb']* 1024 * 1024 * 1024);
$used = formatStorage($rate_data['total_data'] * 1024 * 1024);
$percent = round(($rate_data['total_data'] / ($bill['bill_gb'] * 1024)) * 100,2);
}
if ($bill['bill_type'] == "cdr")
{
$type = "CDR";
$allowed = formatRates($bill['bill_cdr'] * 1000);
$used = formatRates($rate_data['rate_95th'] * 1000);
$percent = round(($rate_data['rate_95th'] / $bill['bill_cdr']) * 100,2);
} elseif ($bill['bill_type'] == "quota") {
$type = "Quota";
$allowed = formatStorage($bill['bill_gb']* 1024 * 1024 * 1024);
$used = formatStorage($rate_data['total_data'] * 1024 * 1024);
$percent = round(($rate_data['total_data'] / ($bill['bill_gb'] * 1024)) * 100,2);
}
if ($percent > 100) { $perc = "100"; } else { $perc = $percent; }
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
} else { $left_background='9abf5b'; $right_background='bbd392'; }
if ($percent > 100) { $perc = "100"; } else { $perc = $percent; }
if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; }
elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; }
elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; }
elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; }
else { $left_background='9abf5b'; $right_background='bbd392'; }
if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
echo("
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
echo("
<tr bgcolor='$row_colour'>
<td width='7'></td>
<td width='250'><a href='".$config['base_url']."/bill/".$bill['bill_id']."/'><span style='font-weight: bold;' class=interface>".$bill['bill_name']."</span></a></td>
@@ -173,8 +173,8 @@ print_optionbar_end();
<td width=60><a href='".$config['base_url']."/bill/".$bill['bill_id']."/edit/'><img src='images/16/wrench.png' align=absmiddle alt='Edit'> Edit</a></td>
</tr>
");
$i++;
} ### PERMITTED
$i++;
} ### PERMITTED
}
echo("</table>");
}

View File

@@ -19,8 +19,8 @@ echo("
$i = 1;
while($customer = mysql_fetch_array($cust_query)) {
while ($customer = mysql_fetch_array($cust_query))
{
$i++;
$port_sql = "SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = '".$customer['port_descr_descr']."'";
@@ -28,23 +28,22 @@ while($customer = mysql_fetch_array($cust_query)) {
$customer_name = $customer['port_descr_descr'];
if(!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
while($port = mysql_fetch_array($port_query)) {
$device = device_by_id_cache($port['device_id']);
while ($port = mysql_fetch_array($port_query))
{
$device = device_by_id_cache($port['device_id']);
unset($class);
$ifname = fixifname($device['ifDescr']);
$ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
if($device['os'] == "ios") {
if($port['ifTrunk']) { $vlan = "<span class=box-desc><span class=red>" . $port['ifTrunk'] . "</span></span>";
} elseif ($port['ifVlan']) { $vlan = "<span class=box-desc><span class=blue>VLAN " . $port['ifVlan'] . "</span></span>";
} else { $vlan = ""; }
if ($device['os'] == "ios")
{
if ($port['ifTrunk']) { $vlan = "<span class=box-desc><span class=red>" . $port['ifTrunk'] . "</span></span>"; }
elseif ($port['ifVlan']) { $vlan = "<span class=box-desc><span class=blue>VLAN " . $port['ifVlan'] . "</span></span>"; }
else { $vlan = ""; }
}
echo("
@@ -61,19 +60,16 @@ while($customer = mysql_fetch_array($cust_query)) {
unset($customer_name);
}
echo("<tr bgcolor='$bg_colour'><td></td><td colspan=6>
echo("<tr bgcolor='$bg_colour'><td></td><td colspan=6>
<img src='".$config['base_url']."/graph.php?id=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$day&to=$now&width=215&height=100'>
<img src='".$config['base_url']."/graph.php?id=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$week&to=$now&width=215&height=100'>
<img src='".$config['base_url']."/graph.php?id=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$month&to=$now&width=215&height=100'>
<img src='".$config['base_url']."/graph.php?id=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$year&to=$now&width=215&height=100'>
</td></tr>");
}
echo("</table>");
echo("</table>");
?>

View File

@@ -1,11 +1,13 @@
<?php
if($_SESSION['userlevel'] < 10) {
if ($_SESSION['userlevel'] < 10)
{
echo("<span class='alert'>You are not permitted to perform this function</span>");
exit;
}
if($_REQUEST['id']) {
if ($_REQUEST['id'])
{
echo(delete_device(mres($_REQUEST['id'])));
}
@@ -19,10 +21,9 @@ if($_REQUEST['id']) {
$query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`");
while($data = mysql_fetch_array($query)) {
while ($data = mysql_fetch_array($query))
{
echo("<option value='".$data['device_id']."'>".$data['hostname']."</option>");
}
?>
@@ -31,4 +32,3 @@ while($data = mysql_fetch_array($query)) {
<input type="submit" class="submit" name="Submit" value="Delete Host">
</p>
</form>

View File

@@ -1,21 +1,24 @@
<?php
if($_SESSION['userlevel'] < '5') {
if ($_SESSION['userlevel'] < '5')
{
print_error("Insufficient Privileges");
} else {
if($_POST['delsrv']) {
if($_SESSION['userlevel'] > "5") {
if ($_POST['delsrv'])
{
if ($_SESSION['userlevel'] > "5") {
include("includes/service-delete.inc.php");
}
}
$query = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname");
while($device = mysql_fetch_array($query)) {
while ($device = mysql_fetch_array($query))
{
$servicesform .= "<option value='" . $device[service_id] . "'>" . $device['service_id'] . "." . $device['hostname'] . " - " . $device['service_type'] . "</option>";
}
if($updated) { print_message("Service Deleted!"); }
if ($updated) { print_message("Service Deleted!"); }
echo("
<h4>Delete Service</h4>
@@ -36,6 +39,6 @@ echo("
<input type='submit' name='Submit' value='Delete' />
</form>");
}
?>

View File

@@ -2,24 +2,24 @@
echo("<div style='margin: 10px;'>");
if($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else
if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else
{
echo("<h3>Delete User</h3>");
if (auth_usermanagement())
{
if($_GET['action'] == "del")
if ($_GET['action'] == "del")
{
$delete_username = mysql_result(mysql_query("SELECT username FROM users WHERE user_id = '" . mres($_GET['user_id']) . "'"),0);
if($_GET['confirm'] == "yes")
if ($_GET['confirm'] == "yes")
{
mysql_query("DELETE FROM `devices_perms` WHERE `user_id` = '" . mres($_GET['user_id']) . "'");
# FIXME v sql query should be replaced by authmodule
mysql_query("DELETE FROM `users` WHERE `user_id` = '" . mres($_GET['user_id']) . "'");
if(mysql_affected_rows()) { echo("<span class=info>User '$delete_username' deleted!</span>"); }
if (mysql_affected_rows()) { echo("<span class=info>User '$delete_username' deleted!</span>"); }
}
else
@@ -31,7 +31,7 @@ if($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
# FIXME v mysql query should be replaced by authmodule
$userlist = mysql_query("SELECT * FROM `users`");
while($userentry = mysql_fetch_array($userlist))
while ($userentry = mysql_fetch_array($userlist))
{
$i++;
echo($i . ". " . $userentry['username'] . "

View File

@@ -22,7 +22,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
$select[$section] = "selected";
$device_query = mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $_GET['id'] . "'");
while($device = mysql_fetch_array($device_query))
while ($device = mysql_fetch_array($device_query))
{
if ($config['os'][$device['os']]['group']) { $device['os_group'] = $config['os'][$device['os']]['group']; }
@@ -140,7 +140,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
</a>
</li>');
}
elseif ( device_permitted($_GET['id']) && $config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `hrDevice` WHERE device_id = '".$_GET['id']."'"), 0) > '0')
elseif (device_permitted($_GET['id']) && $config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `hrDevice` WHERE device_id = '".$_GET['id']."'"), 0) > '0')
{
echo('<li class="' . $select['hrdevice'] . '">
<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/hrdevice/">
@@ -190,7 +190,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
if ($_SESSION['userlevel'] >= "7") {
if (!is_array($config['rancid_configs'])) { $config['rancid_configs'] = array($config['rancid_configs']); }
foreach($config['rancid_configs'] as $configs) {
foreach ($config['rancid_configs'] as $configs) {
if ($configs[strlen($configs)-1] != '/') { $configs .= '/'; }
if (is_file($configs . $device['hostname'])) { $device_config_file = $configs . $device['hostname']; }
}
@@ -227,4 +227,3 @@ else
include("includes/error-no-perm.inc.php");
}
?>

View File

@@ -112,7 +112,8 @@ print_optionbar_start(62);
print_optionbar_end();
$sql = "SELECT * FROM devices WHERE 1 $where ORDER BY `ignore`, `status`, `hostname`";
if ($_GET['status'] == "alerted") {
if ($_GET['status'] == "alerted")
{
$sql = "SELECT * FROM devices " . $device_alert_sql . " GROUP BY `device_id` ORDER BY `ignore`, `status`, `os`, `hostname`";
}
@@ -120,8 +121,10 @@ echo('<table cellpadding="7" cellspacing="0" class="devicetable" width="100%">
<tr class="tablehead"><th></th><th>Device</th><th></th><th>Operating System</th><th>Platform</th><th>Uptime</th></tr>');
$device_query = mysql_query($sql);
while ($device = mysql_fetch_array($device_query)) {
if ( device_permitted($device['device_id']) ) {
while ($device = mysql_fetch_array($device_query))
{
if (device_permitted($device['device_id']))
{
include("includes/hostbox.inc.php");
}
}

View File

@@ -4,181 +4,184 @@ include("includes/javascript-interfacepicker.inc.php");
echo("<div style='margin: 10px;'>");
if($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else {
if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else
{
if ($_GET['user_id'])
{
$user_data = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE user_id = '" . $_GET['user_id'] . "'"));
echo("<p><h2>" . $user_data['realname'] . "</h2><a href='?page=edituser'>Change...</a></p>");
// Perform actions if requested
if($_GET['user_id']) {
$user_data = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE user_id = '" . $_GET['user_id'] . "'"));
echo("<p><h2>" . $user_data['realname'] . "</h2><a href='?page=edituser'>Change...</a></p>");
// Perform actions if requested
if($_GET['action'] == "deldevperm") {
if(mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("DELETE FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
if ($_GET['action'] == "deldevperm")
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("DELETE FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
}
}
}
if($_GET['action'] == "adddevperm") {
if(!mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("INSERT INTO devices_perms (`device_id`, `user_id`) VALUES ('" . $_GET['device_id'] . "', '" . $_GET['user_id'] . "')");
if ($_GET['action'] == "adddevperm")
{
if (!mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("INSERT INTO devices_perms (`device_id`, `user_id`) VALUES ('" . $_GET['device_id'] . "', '" . $_GET['user_id'] . "')");
}
}
}
if($_GET['action'] == "delifperm") {
if(mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("DELETE FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
if ($_GET['action'] == "delifperm")
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("DELETE FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
}
}
}
if($_GET['action'] == "addifperm") {
if(!mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("INSERT INTO ports_perms (`interface_id`, `user_id`) VALUES ('" . $_GET['interface_id'] . "', '" . $_GET['user_id'] . "')");
if ($_GET['action'] == "addifperm")
{
if (!mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("INSERT INTO ports_perms (`interface_id`, `user_id`) VALUES ('" . $_GET['interface_id'] . "', '" . $_GET['user_id'] . "')");
}
}
}
if($_GET['action'] == "delbillperm") {
if(mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("DELETE FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
if ($_GET['action'] == "delbillperm")
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("DELETE FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
}
}
}
if($_GET['action'] == "addbillperm") {
if(!mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("INSERT INTO bill_perms (`bill_id`, `user_id`) VALUES ('" . $_GET['bill_id'] . "', '" . $_GET['user_id'] . "')");
if ($_GET['action'] == "addbillperm")
{
if (!mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
mysql_query("INSERT INTO bill_perms (`bill_id`, `user_id`) VALUES ('" . $_GET['bill_id'] . "', '" . $_GET['user_id'] . "')");
}
}
}
echo("<table width=100%><tr><td valign=top width=33%>");
// Display devices this users has access to
echo("<h3>Device Access</h3>");
echo("<table width=100%><tr><td valign=top width=33%>");
// Display devices this users has access to
echo("<h3>Device Access</h3>");
$device_perm_data = mysql_query("SELECT * from devices_perms as P, devices as D WHERE `user_id` = '" . $_GET['user_id'] . "' AND D.device_id = P.device_id");
while($device_perm = mysql_fetch_array($device_perm_data)) {
echo("<strong>" . $device_perm['hostname'] . " <a href='?page=edituser&action=deldevperm&user_id=" . $_GET['user_id'] . "&device_id=" . $device_perm['device_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></strong><br />");
$access_list[] = $device_perm['device_id'];
$permdone = "yes";
}
if(!$permdone) { echo("None Configured"); }
// Display devices this user doesn't have access to
echo("<h4>Grant access to new device</h4>");
echo("<form method='get' action=''>
<input type='hidden' value='" . $_GET['user_id'] . "' name='user_id'>
<input type='hidden' value='edituser' name='page'>
<input type='hidden' value='adddevperm' name='action'>
<select name='device_id' class=selector>");
$device_list = mysql_query("SELECT * FROM `devices` ORDER BY hostname");
while($device = mysql_fetch_array($device_list)) {
unset($done);
foreach($access_list as $ac) { if($ac == $device['device_id']) { $done = 1; } }
if(!$done) {
echo("<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>");
$device_perm_data = mysql_query("SELECT * from devices_perms as P, devices as D WHERE `user_id` = '" . $_GET['user_id'] . "' AND D.device_id = P.device_id");
while ($device_perm = mysql_fetch_array($device_perm_data))
{
echo("<strong>" . $device_perm['hostname'] . " <a href='?page=edituser&action=deldevperm&user_id=" . $_GET['user_id'] . "&device_id=" . $device_perm['device_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></strong><br />");
$access_list[] = $device_perm['device_id'];
$permdone = "yes";
}
}
echo("</select> <input type='submit' name='Submit' value='Add'></form>");
if (!$permdone) { echo("None Configured"); }
echo("</td><td valign=top width=33%>");
echo("<h3>Interface Access</h3>");
// Display devices this user doesn't have access to
echo("<h4>Grant access to new device</h4>");
echo("<form method='get' action=''>
<input type='hidden' value='" . $_GET['user_id'] . "' name='user_id'>
<input type='hidden' value='edituser' name='page'>
<input type='hidden' value='adddevperm' name='action'>
<select name='device_id' class=selector>");
$interface_perm_data = mysql_query("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = '" . $_GET['user_id'] .
"' AND I.interface_id = P.interface_id AND D.device_id = I.device_id");
while($interface_perm = mysql_fetch_array($interface_perm_data)) {
echo("<table><tr><td><strong>".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."</strong><br />".
"" . $interface_perm['ifAlias'] . "</td><td width=50>&nbsp;&nbsp;<a href='?page=edituser&action=delifperm&user_id=" . $_GET['user_id'] .
"&interface_id=" . $interface_perm['interface_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></td></tr></table>");
$ipermdone = "yes";
}
if(!$ipermdone) { echo("None Configured"); }
// Display devices this user doesn't have access to
echo("<h4>Grant access to new interface</h4>");
echo("<form action='' method='get'>
<input type='hidden' value='" . $_GET['user_id'] . "' name='user_id'>
<input type='hidden' value='edituser' name='page'>
<input type='hidden' value='addifperm' name='action'>
<table><tr><td>Device: </td>
<td><select id='device' class='selector' name='device' onchange='getInterfaceList(this)'>
<option value=''>Select a device</option>");
$device_list = mysql_query("SELECT * FROM `devices` ORDER BY hostname");
while($device = mysql_fetch_array($device_list)) {
unset($done);
foreach($access_list as $ac) { if($ac == $device['device_id']) { $done = 1; } }
if(!$done) { echo("<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>"); }
}
echo("</select></td></tr><tr>
<td>Interface: </td><td><select class=selector id='interface_id' name='interface_id'>
</select></td>
</tr><tr></table><input type='submit' name='Submit' value='Add'></form>");
echo("</td><td valign=top width=33%>");
echo("<h3>Bill Access</h3>");
$bill_perm_data = mysql_query("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = '" . $_GET['user_id'] .
"' AND P.bill_id = B.bill_id");
while($bill_perm = mysql_fetch_array($bill_perm_data)) {
echo("<table><tr><td><strong>".$bill_perm['bill_name']."</strong></td><td width=50>&nbsp;&nbsp;<a href='?page=edituser&action=delbillperm&user_id=" .
$_GET['user_id'] . "&bill_id=" . $bill_perm['bill_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></td></tr></table>");
$bill_access_list[] = $bill_perm['bill_id'];
$bpermdone = "yes";
}
if(!$bpermdone) { echo("None Configured"); }
// Display devices this user doesn't have access to
echo("<h4>Grant access to new bill</h4>");
echo("<form method='get' action=''>
<input type='hidden' value='" . $_GET['user_id'] . "' name='user_id'>
<input type='hidden' value='edituser' name='page'>
<input type='hidden' value='addbillperm' name='action'>
<select name='bill_id' class=selector>");
$bills = mysql_query("SELECT * FROM `bills` ORDER BY `bill_name`");
while($bill = mysql_fetch_array($bills)) {
unset($done);
foreach($bill_access_list as $ac) { if($ac == $bill['bill_id']) { $done = 1; } }
if(!$done) {
echo("<option value='" . $bill['bill_id'] . "'>" . $bill['bill_name'] . "</option>");
$device_list = mysql_query("SELECT * FROM `devices` ORDER BY hostname");
while ($device = mysql_fetch_array($device_list))
{
unset($done);
foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } }
if (!$done)
{
echo("<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>");
}
}
echo("</select> <input type='submit' name='Submit' value='Add'></form>");
echo("</td><td valign=top width=33%>");
echo("<h3>Interface Access</h3>");
$interface_perm_data = mysql_query("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = '" . $_GET['user_id'] .
"' AND I.interface_id = P.interface_id AND D.device_id = I.device_id");
while ($interface_perm = mysql_fetch_array($interface_perm_data))
{
echo("<table><tr><td><strong>".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."</strong><br />".
"" . $interface_perm['ifAlias'] . "</td><td width=50>&nbsp;&nbsp;<a href='?page=edituser&action=delifperm&user_id=" . $_GET['user_id'] .
"&interface_id=" . $interface_perm['interface_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></td></tr></table>");
$ipermdone = "yes";
}
if (!$ipermdone) { echo("None Configured"); }
// Display devices this user doesn't have access to
echo("<h4>Grant access to new interface</h4>");
echo("<form action='' method='get'>
<input type='hidden' value='" . $_GET['user_id'] . "' name='user_id'>
<input type='hidden' value='edituser' name='page'>
<input type='hidden' value='addifperm' name='action'>
<table><tr><td>Device: </td>
<td><select id='device' class='selector' name='device' onchange='getInterfaceList(this)'>
<option value=''>Select a device</option>");
$device_list = mysql_query("SELECT * FROM `devices` ORDER BY hostname");
while ($device = mysql_fetch_array($device_list))
{
unset($done);
foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } }
if (!$done) { echo("<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>"); }
}
echo("</select></td></tr><tr>
<td>Interface: </td><td><select class=selector id='interface_id' name='interface_id'>
</select></td>
</tr><tr></table><input type='submit' name='Submit' value='Add'></form>");
echo("</td><td valign=top width=33%>");
echo("<h3>Bill Access</h3>");
$bill_perm_data = mysql_query("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = '" . $_GET['user_id'] .
"' AND P.bill_id = B.bill_id");
while ($bill_perm = mysql_fetch_array($bill_perm_data))
{
echo("<table><tr><td><strong>".$bill_perm['bill_name']."</strong></td><td width=50>&nbsp;&nbsp;<a href='?page=edituser&action=delbillperm&user_id=" .
$_GET['user_id'] . "&bill_id=" . $bill_perm['bill_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></td></tr></table>");
$bill_access_list[] = $bill_perm['bill_id'];
$bpermdone = "yes";
}
if (!$bpermdone) { echo("None Configured"); }
// Display devices this user doesn't have access to
echo("<h4>Grant access to new bill</h4>");
echo("<form method='get' action=''>
<input type='hidden' value='" . $_GET['user_id'] . "' name='user_id'>
<input type='hidden' value='edituser' name='page'>
<input type='hidden' value='addbillperm' name='action'>
<select name='bill_id' class=selector>");
$bills = mysql_query("SELECT * FROM `bills` ORDER BY `bill_name`");
while ($bill = mysql_fetch_array($bills))
{
unset($done);
foreach ($bill_access_list as $ac) { if ($ac == $bill['bill_id']) { $done = 1; } }
if (!$done)
{
echo("<option value='" . $bill['bill_id'] . "'>" . $bill['bill_name'] . "</option>");
}
}
echo("</select> <input type='submit' name='Submit' value='Add'></form>");
echo("</td></table>");
} else {
$user_list = mysql_query("SELECT * FROM `users`");
echo("<h3>Select a user to edit</h3>");
echo("<form method='get' action=''>
<input type='hidden' value='edituser' name='page'>
<select name='user_id'>");
while ($user_entry = mysql_fetch_array($user_list))
{
echo("<option value='" . $user_entry['user_id'] . "'>" . $user_entry['username'] . "</option>");
}
echo("</select><input type='submit' name='Submit' value='Select'></form>");
}
echo("</select> <input type='submit' name='Submit' value='Add'></form>");
echo("</td></table>");
} else {
$user_list = mysql_query("SELECT * FROM `users`");
echo("<h3>Select a user to edit</h3>");
echo("<form method='get' action=''>
<input type='hidden' value='edituser' name='page'>
<select name='user_id'>");
while($user_entry = mysql_fetch_array($user_list)) {
echo("<option value='" . $user_entry['user_id'] . "'>" . $user_entry['username'] . "</option>");
}
echo("</select><input type='submit' name='Submit' value='Select'></form>");
}
}
echo("</div>");
?>

View File

@@ -1,8 +1,9 @@
<?php
if($_GET['opta'] == "expunge" && $_SESSION['userlevel'] >= '10') { mysql_query("TRUNCATE TABLE `eventlog`"); }
if ($_GET['opta'] == "expunge" && $_SESSION['userlevel'] >= '10') { mysql_query("TRUNCATE TABLE `eventlog`"); }
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,250";
} else {
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,250";
@@ -10,10 +11,10 @@ if($_SESSION['userlevel'] >= '5') {
$data = mysql_query($query);
echo('<table cellspacing="0" cellpadding="1" width="100%">');
while($entry = mysql_fetch_array($data)) {
while ($entry = mysql_fetch_array($data))
{
include("includes/print-event.inc");
}

View File

@@ -1,6 +1,7 @@
<?php
function generate_front_box ($background, $content) {
function generate_front_box ($background, $content)
{
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 117px; height: 85px; background: $background;'>
$content
</div>");
@@ -8,12 +9,13 @@ echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; fl
echo("<div style='padding: 3px 10px; background: #fff;'>");
if($_SESSION['userlevel'] == '10') {
if ($_SESSION['userlevel'] == '10')
{
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
} else {
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0'");
}
while($device = mysql_fetch_array($sql)){
while ($device = mysql_fetch_array($sql)){
generate_front_box("#ffaaaa", "<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span> <br />
@@ -22,7 +24,8 @@ while($device = mysql_fetch_array($sql)){
}
if($_SESSION['userlevel'] == '10') {
if ($_SESSION['userlevel'] == '10')
{
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
} else {
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
@@ -30,37 +33,40 @@ $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS
### These things need to become more generic, and more manageable across different frontpages... rewrite inc :>
while($interface = mysql_fetch_array($sql)){
if(!$interface['deleted']){
$interface = ifNameDescr($interface);
generate_front_box("#ffdd99", "<center><strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
while ($interface = mysql_fetch_array($sql))
{
if (!$interface['deleted'])
{
$interface = ifNameDescr($interface);
generate_front_box("#ffdd99", "<center><strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />
<!-- <img src='graph.php?type=bits&if=".$interface['interface_id']."&from=$day&to=$now&width=100&height=32' /> -->
<strong>".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."</strong> <br />
" . ($interface['ifAlias'] ? '<span class="body-date-1">'.truncate($interface['ifAlias'], 20, '').'</span>' : '') . "
</center>");
}
}
/* FIXME service permissions? seem nonexisting now.. */
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while($service = mysql_fetch_array($sql)){
generate_front_box("#ffaaaa", "<center><strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>
<strong>".$service['service_type']."</strong><br />
<span class=body-date-1>".truncate($interface['ifAlias'], 20)."</span>
</center>");
while ($service = mysql_fetch_array($sql))
{
generate_front_box("#ffaaaa", "<center><strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>
<strong>".$service['service_type']."</strong><br />
<span class=body-date-1>".truncate($interface['ifAlias'], 20)."</span>
</center>");
}
if (isset($config['enable_bgp']) && $config['enable_bgp'])
{
if($_SESSION['userlevel'] == '10') {
if ($_SESSION['userlevel'] == '10')
{
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
} else {
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
}
while($peer = mysql_fetch_array($sql))
while ($peer = mysql_fetch_array($sql))
{
generate_front_box("#ffaaaa", "<center><strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span>
@@ -70,12 +76,13 @@ if (isset($config['enable_bgp']) && $config['enable_bgp'])
}
}
if($_SESSION['userlevel'] == '10') {
if ($_SESSION['userlevel'] == '10')
{
$sql = mysql_query("SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime < '84600' AND D.ignore = 0");
} else {
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime < '84600' AND D.ignore = 0");
}
while($device = mysql_fetch_array($sql)){
while ($device = mysql_fetch_array($sql)){
generate_front_box("#aaffaa", "<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #009;'>Device<br />Rebooted</span><br />
<span class=body-date-1>".formatUptime($device['uptime'], 'short')."</span>
@@ -83,8 +90,8 @@ while($device = mysql_fetch_array($sql)){
}
if($config['enable_syslog']) {
if ($config['enable_syslog'])
{
## Open Syslog Div
echo("<div style='margin: 4px; clear: both; padding: 5px;'>
<h3>Recent Syslog Messages</h3>
@@ -93,7 +100,7 @@ if($config['enable_syslog']) {
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while($entry = mysql_fetch_array($query)) {
while ($entry = mysql_fetch_array($query)) {
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
include("includes/print-syslog.inc");
}
@@ -108,7 +115,8 @@ if($config['enable_syslog']) {
<h3>Recent Eventlog Entries</h3>
");
if($_SESSION['userlevel'] == '10') {
if ($_SESSION['userlevel'] == '10')
{
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15";
} else {
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host =
@@ -119,7 +127,7 @@ $data = mysql_query($query);
echo("<table cellspacing=0 cellpadding=1 width=100%>");
while($entry = mysql_fetch_array($data)) {
while ($entry = mysql_fetch_array($data)) {
include("includes/print-event.inc");
}

View File

@@ -8,7 +8,7 @@ $nodes = array();
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'");
while($device = mysql_fetch_array($sql)){
while ($device = mysql_fetch_array($sql)){
unset($already);
$i = 0;
while ($i <= count($nodes)) {
@@ -18,13 +18,13 @@ while($device = mysql_fetch_array($sql)){
}
$i++;
}
if(!$already) { $nodes[] = $device['device_id']; }
if (!$already) { $nodes[] = $device['device_id']; }
}
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
while($device = mysql_fetch_array($sql)){
if(device_permitted($device['device_id'])) {
while ($device = mysql_fetch_array($sql)){
if (device_permitted($device['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #d0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffbbbb;'>
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span><br />
@@ -33,11 +33,11 @@ while($device = mysql_fetch_array($sql)){
}
}
if($config['warn']['ifdown']) {
if ($config['warn']['ifdown']) {
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
while($interface = mysql_fetch_array($sql)){
if(port_permitted($interface['interface_id'])) {
while ($interface = mysql_fetch_array($sql)){
if (port_permitted($interface['interface_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />
@@ -50,8 +50,8 @@ while($interface = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while($service = mysql_fetch_array($sql)){
if(device_permitted($service['device_id'])) {
while ($service = mysql_fetch_array($sql)){
if (device_permitted($service['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span><br />
@@ -62,8 +62,8 @@ while($service = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id");
while($peer = mysql_fetch_array($sql)){
if(device_permitted($peer['device_id'])) {
while ($peer = mysql_fetch_array($sql)){
if (device_permitted($peer['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span><br />
@@ -74,8 +74,8 @@ while($peer = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'");
while($device = mysql_fetch_array($sql)){
if(device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) {
while ($device = mysql_fetch_array($sql)){
if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'>
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />
@@ -96,7 +96,7 @@ echo("
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from `syslog` ORDER BY seq DESC LIMIT 20";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while($entry = mysql_fetch_array($query))
while ($entry = mysql_fetch_array($query))
{
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
include("includes/print-syslog.inc");
@@ -119,7 +119,7 @@ echo("</div>
echo("<div style=' margin-bottom: 5px;'>");
if($ports['fileserver']) {
if ($ports['fileserver']) {
echo("<div style='width: 470px;'>");
echo("<div style='font-size: 16px; font-weight: bold; color: #555555;'>Central Fileserver</div>");

View File

@@ -11,22 +11,24 @@ $nodes = array();
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'");
while($device = mysql_fetch_array($sql)){
while ($device = mysql_fetch_array($sql))
{
unset($already);
$i = 0;
while ($i <= count($nodes)) {
while ($i <= count($nodes))
{
$thisnode = $device['device_id'];
if ($nodes[$i] == $thisnode) {
if ($nodes[$i] == $thisnode)
{
$already = "yes";
}
$i++;
}
if(!$already) { $nodes[] = $device['device_id']; }
if (!$already) { $nodes[] = $device['device_id']; }
}
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
while($device = mysql_fetch_array($sql)){
while ($device = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffbbbb; margin: 4px;'>
<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
@@ -37,7 +39,7 @@ while($device = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
while($interface = mysql_fetch_array($sql)){
while ($interface = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
@@ -49,7 +51,7 @@ while($interface = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while($service = mysql_fetch_array($sql)){
while ($service = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
@@ -61,7 +63,7 @@ while($service = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id");
while($peer = mysql_fetch_array($sql)){
while ($peer = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
@@ -73,7 +75,7 @@ while($peer = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '84600'");
while($device = mysql_fetch_array($sql)){
while ($device = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ddffdd; margin: 4px;'>
<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
@@ -83,8 +85,6 @@ while($device = mysql_fetch_array($sql)){
}
echo("
<div style='clear: both;'>$errorboxes</div> <div style='margin: 4px; clear: both;'>
@@ -96,7 +96,7 @@ echo("
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); }
while ($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); }
echo("</table>");
@@ -108,13 +108,13 @@ echo("</div>
/// this stuff can be customised to show whatever you want....
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5') {
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%";
$sql .= $config['mydomain'] . "' ORDER BY I.ifAlias";
$query = mysql_query($sql);
unset ($seperator);
while($interface = mysql_fetch_array($query)) {
while ($interface = mysql_fetch_array($query)) {
$ports['l2tp'] .= $seperator . $interface['interface_id'];
$seperator = ",";
}
@@ -123,7 +123,7 @@ if($_SESSION['userlevel'] >= '5') {
$sql .= $config['mydomain'] . "' ORDER BY I.ifAlias";
$query = mysql_query($sql);
unset ($seperator);
while($interface = mysql_fetch_array($query)) {
while ($interface = mysql_fetch_array($query)) {
$ports['transit'] .= $seperator . $interface['interface_id'];
$seperator = ",";
}
@@ -132,12 +132,12 @@ if($_SESSION['userlevel'] >= '5') {
$sql .= $config['mydomain'] . "' ORDER BY I.ifAlias";
$query = mysql_query($sql);
unset ($seperator);
while($interface = mysql_fetch_array($query)) {
while ($interface = mysql_fetch_array($query)) {
$ports['voip'] .= $seperator . $interface['interface_id'];
$seperator = ",";
}
if($ports['transit']) {
if ($ports['transit']) {
echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=multi_bits&ports=".$ports['transit'].
"&from=".$day."&to=".$now."&width=400&height=150\'>', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 18px; font-weight: bold;'>Internet Transit</div>".
@@ -145,7 +145,7 @@ if($_SESSION['userlevel'] >= '5') {
"&from=".$day."&to=".$now."&width=200&height=100'></a>");
}
if($ports['l2tp']) {
if ($ports['l2tp']) {
echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=multi_bits&ports=".$ports['l2tp'].
"&from=".$day."&to=".$now."&width=400&height=150\'>', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 18px; font-weight: bold;'>L2TP ADSL</div>".
@@ -153,7 +153,7 @@ if($_SESSION['userlevel'] >= '5') {
"&from=".$day."&to=".$now."&width=200&height=100'></a>");
}
if($ports['voip']) {
if ($ports['voip']) {
echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=multi_bits&ports=".$ports['voip'].
"&from=".$day."&to=".$now."&width=400&height=150\'>', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 18px; font-weight: bold;'>VoIP to PSTN</div>".

View File

@@ -8,7 +8,7 @@ $nodes = array();
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'");
while($device = mysql_fetch_array($sql)){
while ($device = mysql_fetch_array($sql)){
unset($already);
$i = 0;
while ($i <= count($nodes)) {
@@ -18,13 +18,13 @@ while($device = mysql_fetch_array($sql)){
}
$i++;
}
if(!$already) { $nodes[] = $device['device_id']; }
if (!$already) { $nodes[] = $device['device_id']; }
}
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
while($device = mysql_fetch_array($sql)){
if(device_permitted($device['device_id'])) {
while ($device = mysql_fetch_array($sql)){
if (device_permitted($device['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #d0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffbbbb;'>
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span><br />
@@ -33,11 +33,11 @@ while($device = mysql_fetch_array($sql)){
}
}
if($config['warn']['ifdown']) {
if ($config['warn']['ifdown']) {
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
while($interface = mysql_fetch_array($sql)){
if(port_permitted($interface['interface_id'])) {
while ($interface = mysql_fetch_array($sql)){
if (port_permitted($interface['interface_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />
@@ -50,8 +50,8 @@ while($interface = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while($service = mysql_fetch_array($sql)){
if(device_permitted($service['device_id'])) {
while ($service = mysql_fetch_array($sql)){
if (device_permitted($service['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span><br />
@@ -62,8 +62,8 @@ while($service = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id");
while($peer = mysql_fetch_array($sql)){
if(device_permitted($peer['device_id'])) {
while ($peer = mysql_fetch_array($sql)){
if (device_permitted($peer['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span><br />
@@ -74,8 +74,8 @@ while($peer = mysql_fetch_array($sql)){
}
$sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'");
while($device = mysql_fetch_array($sql)){
if(device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) {
while ($device = mysql_fetch_array($sql)){
if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'>
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />
@@ -96,7 +96,7 @@ echo("
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); }
while ($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); }
echo("</table>");
@@ -108,13 +108,13 @@ echo("</div>
/// this stuff can be customised to show whatever you want....
if($_SESSION['userlevel'] >= '5')
if ($_SESSION['userlevel'] >= '5')
{
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
$query = mysql_query($sql);
unset ($seperator);
while($interface = mysql_fetch_array($query)) {
while ($interface = mysql_fetch_array($query)) {
$ports['transit'] .= $seperator . $interface['interface_id'];
$seperator = ",";
}
@@ -122,7 +122,7 @@ if($_SESSION['userlevel'] >= '5')
$sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
$query = mysql_query($sql);
unset ($seperator);
while($interface = mysql_fetch_array($query)) {
while ($interface = mysql_fetch_array($query)) {
$ports['peering'] .= $seperator . $interface['interface_id'];
$seperator = ",";
}
@@ -136,7 +136,7 @@ if($_SESSION['userlevel'] >= '5')
echo("<div style=' margin-bottom: 5px;'>");
if($ports['peering'] && $ports['transit']) {
if ($ports['peering'] && $ports['transit']) {
echo("<div style='width: 235px; '>
<a href='internet/' onmouseover=\"return overlib('\
<img src=\'graph.php?type=multiport_bits_duo&id=".$ports['peering']."&idb=".$ports['transit']."&from=".$day."&to=".$now."&width=400&height=150\'>\
@@ -151,7 +151,7 @@ if($_SESSION['userlevel'] >= '5')
echo("<div style=' margin-bottom: 5px;'>");
if($ports['transit']) {
if ($ports['transit']) {
echo("<div style='width: 235px; float: left;'>
<a href='iftype/transit/' onmouseover=\"return overlib('\
<img src=\'graph.php?type=multiport_bits&id=".$ports['transit']."&from=".$day."&to=".$now."&width=400&height=150\'>\
@@ -162,7 +162,7 @@ if($_SESSION['userlevel'] >= '5')
"&from=".$day."&to=".$now."&width=155&height=100&legend=no'></a></div>");
}
if($ports['peering']) {
if ($ports['peering']) {
echo("<div style='width: 235px; float: right;'>
<a href='iftype/peering/' onmouseover=\"return overlib('\
<img src=\'graph.php?type=multiport_bits&id=".$ports['peering']."&from=".$day."&to=".$now."&width=400&height=150\'>\
@@ -177,7 +177,7 @@ if($_SESSION['userlevel'] >= '5')
echo("<div style=' margin-bottom: 5px;'>");
if($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) {
if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) {
echo("<div style='width: 466px; '>
<a href='broadband/' onmouseover=\"return overlib('\
<img src=\'graph.php?type=multiport_bits_trio&id=".$ports['broadband']."&idb=".$ports['new_broadband']."&idc=".$ports['wave_broadband']."&from=".$day."&to=".$now."&width=400&height=150&inverse=c\'>\
@@ -192,7 +192,7 @@ if($_SESSION['userlevel'] >= '5')
echo("<div style=' margin-bottom: 5px;'>");
if($ports['broadband']) {
if ($ports['broadband']) {
echo("<div style='width: 235px; float: left;'>
<a onmouseover=\"return overlib('\
<img src=\'graph.php?type=multiport_bits&id=".$ports['broadband']."&from=".$day."&to=".$now."&width=400&height=150\'>\
@@ -205,7 +205,7 @@ if($_SESSION['userlevel'] >= '5')
echo("<div style=' margin-bottom: 5px;'>");
if($ports['new_broadband']) {
if ($ports['new_broadband']) {
echo("<div style='width: 235px; float: left;'>
<a onmouseover=\"return overlib('\
<img src=\'graph.php?type=multiport_bits&id=".$ports['new_broadband']."&from=".$day."&to=".$now."&width=400&height=150&inverse=0\'>\
@@ -218,7 +218,7 @@ if($_SESSION['userlevel'] >= '5')
echo("</div>");
if($ports['wave_broadband']) {
if ($ports['wave_broadband']) {
echo("<div style='width: 235px; float: left;'>
<a onmouseover=\"return overlib('\
<img src=\'graph.php?type=port_bits&id=".$ports['wave_broadband']."&from=".$day."&to=".$now."&width=400&height=150&inverse=1&legend=1\'>\

View File

@@ -1,35 +1,33 @@
<?php
$id = $_GET['opta'];
$graph_type = $_GET['optb'];
if(is_numeric($_GET['optc'])) { $from = $_GET['optc']; } else { $from = $day; }
if(is_numeric($_GET['optd'])) { $to = $_GET['optd']; } else { $to = $now; }
if (is_numeric($_GET['optc'])) { $from = $_GET['optc']; } else { $from = $day; }
if (is_numeric($_GET['optd'])) { $to = $_GET['optd']; } else { $to = $now; }
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', mres($graph_type), $graphtype);
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', mres($graph_type), $graphtype);
$type = $graphtype['type'];
$subtype = $graphtype['subtype'];
$type = $graphtype['type'];
$subtype = $graphtype['subtype'];
if (isset($config['graph'][$type][$subtype])) { $descr = $config['graph'][$type][$subtype]; } else { $descr = $graph_type; }
if(isset($config['graph'][$type][$subtype])) { $descr = $config['graph'][$type][$subtype]; } else { $descr = $graph_type; }
#$descr = mysql_result(mysql_query("SELECT `graph_descr` FROM `graph_types` WHERE `graph_type` = '".$type."' AND `graph_subtype` = '".$subtype."'"),0);
#$descr = mysql_result(mysql_query("SELECT `graph_descr` FROM `graph_types` WHERE `graph_type` = '".$type."' AND `graph_subtype` = '".$subtype."'"),0);
$descr = $config['graph_types'][$type][$subtype]['descr'];
$descr = $config['graph_types'][$type][$subtype]['descr'];
if (is_file("includes/graphs/".$type."/auth.inc.php"))
{
include("includes/graphs/".$type."/auth.inc.php");
}
if(is_file("includes/graphs/".$type."/auth.inc.php"))
{
include("includes/graphs/".$type."/auth.inc.php");
}
if(!$auth)
{
include("includes/error-no-perm.inc.php");
} else {
if (!$auth)
{
include("includes/error-no-perm.inc.php");
} else {
# Do we really need to show the type? User does not have to see the type of graph (i.e. sensor_temperature)
# if(isset($config['graph'][$type][$subtype])) { $title .= " :: ".$config['graph'][$type][$subtype]; } else { $title .= " :: ".$graph_type; }
# if (isset($config['graph'][$type][$subtype])) { $title .= " :: ".$config['graph'][$type][$subtype]; } else { $title .= " :: ".$graph_type; }
$graph_array['height'] = "60";
$graph_array['width'] = "150";
@@ -40,12 +38,10 @@ if(is_numeric($_GET['optd'])) { $to = $_GET['optd']; } else { $to = $now; }
$graph_array['from'] = $day;
$graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400";
print_optionbar_start();
echo($title);
print_optionbar_end();
echo("<div style='margin: 0px 0px 0px 0px'>");
echo("<div style='width: 1200px; margin:10px;'>");
@@ -116,11 +112,7 @@ if(is_numeric($_GET['optd'])) { $to = $_GET['optd']; } else { $to = $now; }
echo("<div style='width:1150px; margin: auto;'>");
echo(generate_graph_tag($graph_array));
echo("</div>");
echo("</div>");
}
?>

View File

@@ -2,9 +2,8 @@
$datas = array('Processors','Memory','Storage','Temperatures', 'Humidity', 'Fanspeeds', 'Voltages', 'Frequencies', 'Current');
if(!$_GET['opta']) { $_GET['opta'] = "processors"; }
if(!$_GET['optb']) { $_GET['optb'] = "nographs"; }
if (!$_GET['opta']) { $_GET['opta'] = "processors"; }
if (!$_GET['optb']) { $_GET['optb'] = "nographs"; }
print_optionbar_start('', '');
@@ -26,26 +25,39 @@ foreach ($datas as $texttype)
if ($_GET['opta'] == $type) { echo("</strong>"); }
$sep = ' | ';
}
unset ($sep);
echo('<div style="float: right;">');
if($_GET['optb'] == "graphs") { echo('<strong>');
if ($_GET['optb'] == "graphs")
{
echo('<strong>');
echo('<img src="images/icons/graphs.png" class="optionicon" />');
} else {
echo('<img src="images/icons/greyscale/graphs.png" class="optionicon" />');
}
echo('<a href="health/'. $_GET['opta'].'/graphs/"> Graphs</a>');
if($_GET['optb'] == "graphs") { echo('</strong>'); }
if ($_GET['optb'] == "graphs")
{
echo('</strong>');
}
echo(' | ');
if($_GET['optb'] == "nographs") { echo('<strong>');
if ($_GET['optb'] == "nographs")
{
echo('<strong>');
echo('<img src="images/icons/nographs.png" class="optionicon" />');
} else {
echo('<img src="images/icons/greyscale/nographs.png" class="optionicon" />');
}
echo('<a href="health/'. $_GET['opta'].'/nographs/"> No Graphs</a>');
if($_GET['optb'] == "nographs") { echo('</strong>'); }
echo('<a href="health/'. $_GET['opta'].'/nographs/"> No Graphs</a>');
if ($_GET['optb'] == "nographs") { echo('</strong>'); }
echo('</div>');

View File

@@ -3,7 +3,8 @@
$graph_type = "sensor_current";
$unit = "A";
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='current' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr";
} else {
$sql = "SELECT * FROM `current` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='current' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr";
@@ -26,15 +27,15 @@ echo('<tr class=tablehead>
$row = 1;
while($sensor = mysql_fetch_array($query))
while ($sensor = mysql_fetch_array($query))
{
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$sensor_popup = "<a href=\"graphs/" . $sensor['sensor_id'] . "/".$graph_type."/\" onmouseover=\"return overlib('<img src=\'$weekly_sensor\'>', LEFT);\" onmouseout=\"return nd();\">
" . $sensor['sensor_descr'] . "</a>";
if($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
$sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$day&amp;to=$now&amp;width=300&amp;height=100";
$sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=300&amp;height=100";
@@ -56,40 +57,37 @@ while($sensor = mysql_fetch_array($query))
<td>" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "</td>
</tr>\n");
if($_GET['optb'] == "graphs") { ## If graphs
if ($_GET['optb'] == "graphs")
{ ## If graphs
echo("<tr bgcolor='$row_colour'><td colspan=7>");
echo("<tr bgcolor='$row_colour'><td colspan=7>");
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>");
echo("</td></tr>");
} # endif graphs
echo("</td></tr>");
} # endif graphs
$row++;
}
echo("</table>");
?>

View File

@@ -3,7 +3,8 @@
$graph_type = "sensor_fanspeed";
$unit = "rpm";
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='fanspeed' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr";
} else {
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='fanspeed' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr";
@@ -25,15 +26,15 @@ echo('<tr class=tablehead>
$row = 1;
while($sensor = mysql_fetch_array($query))
while ($sensor = mysql_fetch_array($query))
{
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$sensor_popup = "<a href=\"graphs/" . $sensor['sensor_id'] . "/".$graph_type."/\" onmouseover=\"return overlib('<img src=\'$weekly_sensor\'>', LEFT);\" onmouseout=\"return nd();\">
" . $sensor['sensor_descr'] . "</a>";
if($sensor['sensor_current'] <= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
if ($sensor['sensor_current'] <= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
$sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$day&amp;to=$now&amp;width=300&amp;height=100";
$sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=300&amp;height=100";
@@ -54,42 +55,38 @@ while($sensor = mysql_fetch_array($query))
<td>" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "</td>
</tr>\n");
if($_GET['optb'] == "graphs") { ## If graphs
if ($_GET['optb'] == "graphs")
{
echo("<tr bgcolor='$row_colour'><td colspan=6>");
echo("<tr bgcolor='$row_colour'><td colspan=6>");
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>");
echo("</td></tr>");
} # endif graphs
echo("</td></tr>");
} # endif graphs
$row++;
}
echo("</table>");
?>

View File

@@ -3,7 +3,8 @@
$graph_type = "sensor_frequency";
$unit = "Hz";
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$sql = "SELECT * FROM `sensors` AS V, `devices` AS D WHERE V.sensor_class='freq' AND V.device_id = D.device_id ORDER BY D.hostname, V.sensor_descr";
} else {
$sql = "SELECT * FROM `sensors` AS V, `devices` AS D, devices_perms as P WHERE V.sensor_class='freq' V.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, V.sensor_descr";
@@ -25,15 +26,15 @@ echo('<tr class=tablehead>
$row = 1;
while($sensor = mysql_fetch_array($query))
while ($sensor = mysql_fetch_array($query))
{
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$sensor_popup = "<a href=\"graphs/" . $sensor['sensor_id'] . "/".$graph_type."/\" onmouseover=\"return overlib('<img src=\'$weekly_sensor\'>', LEFT);\" onmouseout=\"return nd();\">
" . $sensor['sensor_descr'] . "</a>";
if($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
$sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$day&amp;to=$now&amp;width=300&amp;height=100";
$sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=300&amp;height=100";
@@ -54,39 +55,38 @@ while($sensor = mysql_fetch_array($query))
<td>" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "</td>
</tr>\n");
if($_GET['optb'] == "graphs") { ## If graphs
if ($_GET['optb'] == "graphs")
{
echo("<tr bgcolor='$row_colour'><td colspan=6>");
echo("<tr bgcolor='$row_colour'><td colspan=6>");
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>");
echo("</td></tr>");
echo("</td></tr>");
} # endif graphs
} # endif graphs
$row++;
}
echo("</table>");
?>

View File

@@ -3,7 +3,8 @@
$graph_type = "sensor_humidity";
$unit = "%";
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='humidity' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_index, S.sensor_descr";
} else {
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='humidity' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_index, S.sensor_descr";
@@ -25,9 +26,9 @@ echo('<tr class=tablehead>
$row = 1;
while($sensor = mysql_fetch_array($query))
while ($sensor = mysql_fetch_array($query))
{
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$sensor_popup = "<a href=\"graphs/" . $sensor['sensor_id'] . "/".$graph_type."/\" onmouseover=\"return overlib('<img src=\'$weekly_sensor\'>', LEFT);\" onmouseout=\"return nd();\">
@@ -38,7 +39,7 @@ while($sensor = mysql_fetch_array($query))
$sensor_perc = $sensor['sensor_current'] / $sensor['sensor_limit'] * 100;
$sensor_colour = percent_colour($sensor_perc);
if($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
$sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$day&amp;to=$now&amp;width=300&amp;height=100";
$sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=300&amp;height=100";
@@ -59,42 +60,37 @@ while($sensor = mysql_fetch_array($query))
<td>" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "</td>
</tr>\n");
if($_GET['optb'] == "graphs") { ## If graphs
if ($_GET['optb'] == "graphs")
{
echo("<tr bgcolor='$row_colour'><td colspan=7>");
echo("<tr bgcolor='$row_colour'><td colspan=7>");
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>");
echo("</td></tr>");
} # endif graphs
echo("</td></tr>");
} # endif graphs
$row++;
}
echo("</table>");
?>

View File

@@ -2,13 +2,15 @@
$graph_type = "mempool_usage";
echo("<div style='margin-top: 5px; padding: 0px;'>");
echo("<table width=100% cellpadding=6 cellspacing=0>");
$i = '1';
$mempools = mysql_query("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.device_id = M.device_id ORDER BY D.hostname");
while($mempool = mysql_fetch_array($mempools)) {
if(device_permitted($mempool['device_id'])) {
if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
echo("<div style='margin-top: 5px; padding: 0px;'>");
echo("<table width=100% cellpadding=6 cellspacing=0>");
$i = '1';
$mempools = mysql_query("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.device_id = M.device_id ORDER BY D.hostname");
while ($mempool = mysql_fetch_array($mempools))
{
if (device_permitted($mempool['device_id']))
{
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$proc_url = "?page=device/".$device['device_id']."/health/memory/";
@@ -27,11 +29,11 @@ $graph_type = "mempool_usage";
$perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100);
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
} else { $left_background='9abf5b'; $right_background='bbd392'; }
if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; }
elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; }
elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; }
elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; }
else { $left_background='9abf5b'; $right_background='bbd392'; }
echo("<tr bgcolor=$row_colour>
<td>".generate_device_link($mempool)."</td>
@@ -42,40 +44,39 @@ $graph_type = "mempool_usage";
</a></td>
<td width=50>".$perc."%</td>
</tr>");
if($_GET['optb'] == "graphs") { ## If graphs
echo("<tr bgcolor='$row_colour'><td colspan=5>");
if ($_GET['optb'] == "graphs")
{
echo("<tr bgcolor='$row_colour'><td colspan=5>");
$daily_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$daily_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>");
echo("</td></tr>");
echo("</td></tr>");
} # endif graphs
$i++;
}
}
echo("</table>");
echo("</div>");
}
echo("</table>");
echo("</div>");
?>

View File

@@ -2,15 +2,15 @@
$graph_type = "processor_usage";
echo("<div style='margin-top: 5px; padding: 0px;'>");
echo(" <table width=100% cellpadding=6 cellspacing=0>");
$i = '1';
$procs = mysql_query("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname");
while($proc = mysql_fetch_array($procs)) {
if(device_permitted($proc['device_id'])) {
if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
echo("<div style='margin-top: 5px; padding: 0px;'>");
echo(" <table width=100% cellpadding=6 cellspacing=0>");
$i = '1';
$procs = mysql_query("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname");
while ($proc = mysql_fetch_array($procs))
{
if (device_permitted($proc['device_id']))
{
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$device = $proc;
@@ -20,7 +20,6 @@ $graph_type = "processor_usage";
$text_descr = str_replace("Sub-Module", "Module ", $text_descr);
$text_descr = str_replace("DFC Card", "DFC", $text_descr);
$proc_url = "/device/".$device['device_id']."/health/processors/";
$mini_url = $config['base_url'] . "/graph.php?id=".$proc['processor_id']."&type=".$graph_type."&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4";
@@ -31,11 +30,11 @@ $graph_type = "processor_usage";
$perc = round($proc['processor_usage']);
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
} else { $left_background='9abf5b'; $right_background='bbd392'; }
if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; }
elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; }
elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; }
elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; }
else { $left_background='9abf5b'; $right_background='bbd392'; }
echo(" <tr bgcolor=\"$row_colour\">
<td>".generate_device_link($proc)."</td>
@@ -45,41 +44,40 @@ $graph_type = "processor_usage";
".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $left_background, (100 - $perc)."%" , "ffffff", $right_background).'</a></td>
</tr>');
if($_GET['optb'] == "graphs") { ## If graphs are requested, do them, else not!
if ($_GET['optb'] == "graphs")
{ ## If graphs are requested, do them, else not!
echo(' <tr bgcolor="'.$row_colour.'"><td colspan="5">');
echo(' <tr bgcolor="'.$row_colour.'"><td colspan="5">');
$daily_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$daily_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
echo(" <a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo(" <a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src=\"$daily_graph\" border=\"0\"></a> ");
echo(" <a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo(" <a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src=\"$weekly_graph\" border=\"0\"></a> ");
echo(" <a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo(" <a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src=\"$monthly_graph\" border=\"0\"></a> ");
echo(" <a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo(" <a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src=\"$yearly_graph\" border=\"0\"></a>");
echo(" </td>
echo(" </td>
</tr>");
} #end graphs if
} #end graphs if
$i++;
}
}
echo("</table>");
echo("</div>");
}
echo("</table>");
echo("</div>");
?>

View File

@@ -19,48 +19,53 @@ echo("<tr class=tablehead>
$row = 1;
while($drive = mysql_fetch_array($query)) {
if(device_permitted($drive['device_id'])){
while ($drive = mysql_fetch_array($query))
{
if (device_permitted($drive['device_id']))
{
$skipdrive = 0;
if ($drive["os"] == "junos") {
foreach ($config['ignore_junos_os_drives'] as $jdrive) {
if (preg_match($jdrive, $drive["storage_descr"])) {
$skipdrive = 1;
}
if ($drive["os"] == "junos")
{
foreach ($config['ignore_junos_os_drives'] as $jdrive)
{
if (preg_match($jdrive, $drive["storage_descr"]))
{
$skipdrive = 1;
}
$drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]);
}
$drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]);
}
if ($drive['os'] == "freebsd") {
foreach ($config['ignore_bsd_os_drives'] as $jdrive) {
if (preg_match($jdrive, $drive["storage_descr"])) {
$skipdrive = 1;
}
if ($drive['os'] == "freebsd")
{
foreach ($config['ignore_bsd_os_drives'] as $jdrive)
{
if (preg_match($jdrive, $drive["storage_descr"]))
{
$skipdrive = 1;
}
}
}
if ($skipdrive) { continue; }
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$perc = round($drive['storage_perc'], 0);
$total = formatStorage($drive['storage_size']);
$free = formatStorage($drive['storage_free']);
$used = formatStorage($drive['storage_used']);
$store_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=125";
$store_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=125";
$store_popup = "onmouseover=\"return overlib('<img src=\'$store_url\'>', LEFT);\" onmouseout=\"return nd();\"";
$mini_graph = $config['base_url'] . "/graph.php?id=".$drive['storage_id']."&type=".$graph_type."&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4";
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
} else { $left_background='9abf5b'; $right_background='bbd392'; }
if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; }
elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; }
elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; }
elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; }
else { $left_background='9abf5b'; $right_background='bbd392'; }
echo("<tr bgcolor='$row_colour'><td>" . generate_device_link($drive) . "</td><td class=tablehead>" . $drive['storage_descr'] . "</td>
<td><img src='$mini_graph'></td>
@@ -68,45 +73,39 @@ while($drive = mysql_fetch_array($query)) {
<a href='#' $store_popup>".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free, "ffffff", $right_background)."</a>
</td><td>$perc"."%</td></tr>");
if ($_GET['optb'] == "graphs")
{
if($_GET['optb'] == "graphs") { ## If graphs
echo("<tr bgcolor='$row_colour'><td colspan=5>");
echo("<tr bgcolor='$row_colour'><td colspan=5>");
$daily_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$daily_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>");
echo("</td></tr>");
echo("</td></tr>");
} # endif graphs
$row++;
}
}
echo("</table></div>");
?>

View File

@@ -3,7 +3,8 @@
$graph_type = "sensor_temperature";
$unit = "&deg;C";
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='temperature' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_index, S.sensor_descr";
} else {
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='temperature' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_index, S.sensor_descr";
@@ -25,9 +26,9 @@ echo('<tr class=tablehead>
$row = 1;
while($sensor = mysql_fetch_array($query))
while ($sensor = mysql_fetch_array($query))
{
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$sensor_popup = "<a href=\"graphs/" . $sensor['sensor_id'] . "/".$graph_type."/\" onmouseover=\"return overlib('<img src=\'$weekly_sensor\'>', LEFT);\" onmouseout=\"return nd();\">
@@ -38,7 +39,7 @@ while($sensor = mysql_fetch_array($query))
$sensor_perc = $sensor['sensor_current'] / $sensor['sensor_limit'] * 100;
$sensor_colour = percent_colour($sensor_perc);
if($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
$sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$day&amp;to=$now&amp;width=300&amp;height=100";
$sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=300&amp;height=100";
@@ -59,42 +60,36 @@ while($sensor = mysql_fetch_array($query))
<td>" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "</td>
</tr>\n");
if($_GET['optb'] == "graphs") { ## If graphs
if ($_GET['optb'] == "graphs")
{
echo("<tr bgcolor='$row_colour'><td colspan=7>");
echo("<tr bgcolor='$row_colour'><td colspan=7>");
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>");
echo("</td></tr>");
} # endif graphs
echo("</td></tr>");
} # endif graphs
$row++;
}
echo("</table>");
?>

View File

@@ -3,7 +3,8 @@
$graph_type = "sensor_voltage";
$unit = "V";
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='voltage' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr";
} else {
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='voltage' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr";
@@ -25,15 +26,15 @@ echo('<tr class=tablehead>
$row = 1;
while($sensor = mysql_fetch_array($query))
while ($sensor = mysql_fetch_array($query))
{
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$sensor_popup = "<a href=\"graphs/" . $sensor['sensor_id'] . "/".$graph_type."/\" onmouseover=\"return overlib('<img src=\'$weekly_sensor\'>', LEFT);\" onmouseout=\"return nd();\">
" . $sensor['sensor_descr'] . "</a>";
if($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
$sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$day&amp;to=$now&amp;width=300&amp;height=100";
$sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=300&amp;height=100";
@@ -54,43 +55,36 @@ while($sensor = mysql_fetch_array($query))
<td>" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "</td>
</tr>\n");
if($_GET['optb'] == "graphs") { ## If graphs
if ($_GET['optb'] == "graphs")
{
echo("<tr bgcolor='$row_colour'><td colspan=7>");
echo("<tr bgcolor='$row_colour'><td colspan=7>");
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>");
echo("</td></tr>");
} # endif graphs
echo("</td></tr>");
} # endif graphs
$row++;
}
echo("</table>");
?>

View File

@@ -5,7 +5,7 @@
if ($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
$type_where = " (";
foreach(split(",", $_GET['opta']) as $type)
foreach (split(",", $_GET['opta']) as $type)
{
$type_where .= " $or `port_descr_type` = '" . mres($type) . "' ";
$or = "OR";
@@ -16,7 +16,7 @@ $type_where .= ") ";
$sql = "SELECT * FROM `ports` as I, `devices` AS D WHERE $type_where AND I.device_id = D.device_id ORDER BY I.ifAlias";
$query = mysql_query($sql);
while($interface = mysql_fetch_array($query))
while ($interface = mysql_fetch_array($query))
{
$if_list .= $seperator . $interface['interface_id'];
$seperator = ",";
@@ -40,26 +40,26 @@ if ($if_list)
$sql = "select * from ports as I, devices as D WHERE $type_where AND I.device_id = D.device_id ORDER BY I.ifAlias";
$query = mysql_query($sql);
while($interface = mysql_fetch_array($query))
while ($interface = mysql_fetch_array($query))
{
$done = "yes";
unset($class);
$interface['ifAlias'] = str_ireplace($type . ": ", "", $interface['ifAlias']);
$interface['ifAlias'] = str_ireplace("[PNI]", "Private", $interface['ifAlias']);
$ifclass = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']);
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
if ($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
echo("<tr bgcolor='$bg'>
<td><span class=list-large>" . generate_port_link($interface,$interface['port_descr_descr']) . "</span><br />
<span class=interface-desc style='float: left;'>".generate_device_link($interface)." ".generate_port_link($interface)." </span>");
if(mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'"),0))
if (mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'"),0))
{
echo("<span style='float: right;'><a href='".$config['base_url']."/device/".$interface['device_id']."/interface/".$interface['interface_id']."/macaccounting/'><img src='/images/16/chart_curve.png' align='absmiddle'> MAC Accounting</a></span>");
}
echo("</td></tr><tr bgcolor='$bg'><td>");
if(file_exists($config['rrd_dir'] . "/" . $interface['hostname'] . "/port-" . $interface['ifIndex'] . ".rrd"))
if (file_exists($config['rrd_dir'] . "/" . $interface['hostname'] . "/port-" . $interface['ifIndex'] . ".rrd"))
{
$graph_type = "port_bits";
include("includes/print-interface-graphs.inc.php");
@@ -73,5 +73,6 @@ else
{
echo("<tr><td>None found.</td></tr>");
}
?>
</table>

View File

@@ -11,16 +11,17 @@
<option value="">All Parts</option>
<?php
$query = mysql_query("SELECT `entPhysicalModelName` FROM `entPhysical` GROUP BY `entPhysicalModelName` ORDER BY `entPhysicalModelName`");
while($data = mysql_fetch_array($query)) {
while ($data = mysql_fetch_array($query))
{
echo("<option value='".$data['entPhysicalModelName']."'");
if($data['entPhysicalModelName'] == $_POST['part']) { echo("selected"); }
if ($data['entPhysicalModelName'] == $_POST['part']) { echo("selected"); }
echo(">".$data['entPhysicalModelName']."</option>");
}
?>
</select>
</label>
<label><strong>Serial</strong>
<input type="text" name="serial" id="serial" value="<?php echo($_POST['serial']); ?>" />
<input type="text" name="serial" id="serial" value="<?php echo($_POST['serial']); ?>" />
</label>
<label>
<strong>Device</strong>
@@ -28,10 +29,11 @@
<option value="">All Devices</option>
<?php
$query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`");
while($data = mysql_fetch_array($query)) {
while ($data = mysql_fetch_array($query))
{
echo("<option value='".$data['device_id']."'");
if($data['device_id'] == $_POST['device']) { echo("selected"); }
if ($data['device_id'] == $_POST['device']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
@@ -45,27 +47,33 @@
print_optionbar_end();
if($_POST['string']) {
if ($_POST['string'])
{
$where .= " AND E.entPhysicalDescr LIKE '%".$_POST['string']."%'";
}
if($_POST['device_string']) {
if ($_POST['device_string'])
{
$where .= " AND D.hostname LIKE '%".$_POST['device_string']."%'";
}
if($_POST['part']) {
if ($_POST['part'])
{
$where .= " AND E.entPhysicalModelName = '".$_POST['part']."'";
}
if($_POST['serial']) {
if ($_POST['serial'])
{
$where .= " AND E.entPhysicalSerialNum LIKE '%".$_POST['serial']."%'";
}
if($_POST['device']) {
if ($_POST['device'])
{
$where .= " AND D.device_id = '".$_POST['device']."'";
}
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$sql = "SELECT * from entPhysical AS E, devices AS D WHERE E.device_id = D.device_id $where ORDER BY D.hostname";
} else {
$sql = "SELECT * from entPhysical AS E, devices AS D, devices_perms AS P
@@ -77,14 +85,13 @@ echo("<table cellspacing=0 cellpadding=2 width=100%>");
echo("<tr><th>Hostname</th><th>Description</th><th>Name</th><th>Part No</th><th>Serial No</th></tr>");
while($entry = mysql_fetch_array($query)) {
if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
echo("<tr style=\"background-color: $bg\"><td>" . generate_device_link($entry, shortHost($entry['hostname'])) . "</td><td>" . $entry['entPhysicalDescr'] .
while ($entry = mysql_fetch_array($query))
{
if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
echo("<tr style=\"background-color: $bg\"><td>" . generate_device_link($entry, shortHost($entry['hostname'])) . "</td><td>" . $entry['entPhysicalDescr'] .
"</td><td>" . $entry['entPhysicalName'] . "</td><td>" . $entry['entPhysicalModelName'] . "</td><td>" . $entry['entPhysicalSerialNum'] . "</td></tr>");
}
echo("</table>");
?>
</table>

View File

@@ -1,26 +1,27 @@
<?php print_optionbar_start(28); ?>
<table cellpadding=0 cellspacing=0 class=devicetable width=100%>
<table cellpadding="0" cellspacing="0" class="devicetable" width="100%">
<tr>
<form method='post' action=''>
<td width='200' style="padding: 1px;">
<select name='device_id' id='device_id'>
<option value=''>All Devices</option>
<?php
$query = mysql_query("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`");
while($data = mysql_fetch_array($query)) {
echo("<option value='".$data['device_id']."'");
if($data['device_id'] == $_POST['device_id']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
?>
<form method="post" action="">
<td width="200" style="padding: 1px;">
<select name="device_id" id="device_id">
<option value="">All Devices</option>
<?php
$query = mysql_query("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`");
while ($data = mysql_fetch_array($query))
{
echo('<option value="'.$data['device_id'].'"');
if ($data['device_id'] == $_POST['device_id']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
?>
</select>
</td>
<td width='200' style="padding: 1px;">
<select name='interface' id='interface'>
<option value=''>All Interfaces</option>
<option value='Loopback%' <?php if($_POST['interface'] == "Loopback%"){ echo("selected");} ?> >Loopbacks</option>
<option value='Vlan%' <?php if($_POST['interface'] == "Vlan%"){ echo("selected");} ?> >VLANs</option>
<td width="200" style="padding: 1px;">
<select name="interface" id="interface">
<option value="">All Interfaces</option>
<option value="Loopback%" <?php if ($_POST['interface'] == "Loopback%"){ echo("selected"); } ?> >Loopbacks</option>
<option value="Vlan%" <?php if ($_POST['interface'] == "Vlan%"){ echo("selected"); } ?> >VLANs</option>
</select>
</td>
<td>
@@ -37,60 +38,59 @@
print_optionbar_end();
echo("<table width=100% cellspacing=0 cellpadding=2>");
echo('<table width="100%" cellspacing="0" cellpadding="2">');
if($_POST['device_id']) { $where .= " AND I.device_id = '".$_POST['device_id']."'"; }
if($_POST['interface']) { $where .= " AND I.ifDescr LIKE '".$_POST['interface']."'"; }
# FIXME SQL INJECTION!!
if ($_POST['device_id']) { $where .= " AND I.device_id = '".$_POST['device_id']."'"; }
if ($_POST['interface']) { $where .= " AND I.ifDescr LIKE '".$_POST['interface']."'"; }
$sql = "SELECT * FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D, `ipv4_networks` AS N WHERE I.interface_id = A.interface_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id $where ORDER BY A.ipv4_address";
$query = mysql_query($sql);
echo("<tr class=tablehead><th>Device</a></th><th>Interface</th><th>Address</th><th>Description</th></tr>");
echo('<tr class="tablehead"><th>Device</a></th><th>Interface</th><th>Address</th><th>Description</th></tr>');
$row = 1;
while($interface = mysql_fetch_array($query)) {
if($_POST['address']) {
while ($interface = mysql_fetch_array($query))
{
if ($_POST['address'])
{
list($addy, $mask) = explode("/", $_POST['address']);
if(!$mask) { $mask = "32"; }
if (!$mask) { $mask = "32"; }
if (!match_network($addy . "/" . $mask, $interface['ipv4_address'] )) { $ignore = 1; }
}
if(!$ignore) {
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$speed = humanspeed($interface['ifSpeed']);
$type = humanmedia($interface['ifType']);
list($prefix, $length) = explode("/", $interface['ipv4_network']);
if($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
$error_img = generate_port_link($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
if( port_permitted($interface['interface_id']) )
if (!$ignore)
{
echo('<tr bgcolor="' . $row_colour . '">
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$speed = humanspeed($interface['ifSpeed']);
$type = humanmedia($interface['ifType']);
list($prefix, $length) = explode("/", $interface['ipv4_network']);
if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0)
{
$error_img = generate_port_link($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
if (port_permitted($interface['interface_id']))
{
echo('<tr bgcolor="' . $row_colour . '">
<td class="list-bold">' . generate_device_link($interface) . '</td>
<td class="list-bold">' . generate_port_link($interface, makeshortif(fixifname($interface['ifDescr']))) . ' ' . $error_img . '</td>
<td>' . $interface['ipv4_address'] . '/'.$length.'</td>
<td>' . $interface['ifAlias'] . "</td>
</tr>\n");
$row++;
$row++;
}
}
}
unset($ignore);
unset($ignore);
}
echo("</table>");
?>

View File

@@ -2,25 +2,26 @@
<table cellpadding=0 cellspacing=0 class=devicetable width=100%>
<tr>
<form method='post' action=''>
<td width='200'>
<select name='device_id' id='device_id'>
<option value=''>All Devices</option>
<?php
$query = mysql_query("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`");
while($data = mysql_fetch_array($query)) {
echo("<option value='".$data['device_id']."'");
if($data['device_id'] == $_POST['device_id']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
?>
<form method="post" action="">
<td width="200">
<select name="device_id" id="device_id">
<option value="">All Devices</option>
<?php
$query = mysql_query("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`");
while ($data = mysql_fetch_array($query))
{
echo('<option value="'.$data['device_id'].'"');
if ($data['device_id'] == $_POST['device_id']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
?>
</select>
</td>
<td width='200'>
<select name='interface' id='interface'>
<option value=''>All Interfaces</option>
<option value='Loopback%' <?php if($_POST['interface'] == "Loopback%"){ echo("selected");} ?> >Loopbacks</option>
<option value='Vlan%' <?php if($_POST['interface'] == "Vlan%"){ echo("selected");} ?> >VLANs</option>
<td width="200">
<select name="interface" id="interface">
<option value="">All Interfaces</option>
<option value="Loopback%" <?php if ($_POST['interface'] == "Loopback%"){ echo("selected"); } ?> >Loopbacks</option>
<option value="Vlan%" <?php if ($_POST['interface'] == "Vlan%"){ echo("selected"); } ?> >VLANs</option>
</select>
</td>
<td>
@@ -30,69 +31,66 @@
<input style="align:right;" type=submit class=submit value=Search></div>
</td>
</form>
</tr>
</table>
<?php print_optionbar_end(); ?>
<?php
echo("<table width=100% cellpadding=2 cellspacing=0>");
print_optionbar_end();
if($_POST['device_id']) { $where .= " AND I.device_id = '".$_POST['device_id']."'"; }
if($_POST['interface']) { $where .= " AND I.ifDescr LIKE '".$_POST['interface']."'"; }
echo('<table width="100%" cellspacing="0" cellpadding="2">');
# FIXME SQL INJECTION!!
if ($_POST['device_id']) { $where .= " AND I.device_id = '".$_POST['device_id']."'"; }
if ($_POST['interface']) { $where .= " AND I.ifDescr LIKE '".$_POST['interface']."'"; }
$sql = "SELECT * FROM `ipv6_addresses` AS A, `ports` AS I, `devices` AS D, `ipv6_networks` AS N WHERE I.interface_id = A.interface_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id $where ORDER BY A.ipv6_address";
$query = mysql_query($sql);
echo("<tr class=tablehead><td width=0></td><th>Device</a></th><th>Interface</th><th>Address</th><th>Description</th></tr>");
echo('<tr class="tablehead"><th>Device</a></th><th>Interface</th><th>Address</th><th>Description</th></tr>');
$row = 1;
while($interface = mysql_fetch_array($query)) {
if($_POST['address']) {
while ($interface = mysql_fetch_array($query))
{
if ($_POST['address'])
{
list($addy, $mask) = explode("/", $_POST['address']);
if(!$mask) { $mask = "128"; }
if(!Net_IPv6::isInNetmask ( $interface['ipv6_address'], $addy, $mask )) { $ignore = 1; } else { $ignore = 0;}
if (!$mask) { $mask = "128"; }
if (!Net_IPv6::isInNetmask($interface['ipv6_address'], $addy, $mask)) { $ignore = 1; } else { $ignore = 0; }
}
if(!$ignore) {
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$speed = humanspeed($interface['ifSpeed']);
$type = humanmedia($interface['ifType']);
list($prefix, $length) = explode("/", $interface['ipv6_network']);
if($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
$error_img = generate_port_link($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
if( port_permitted($interface['interface_id']) )
if (!$ignore)
{
echo("<tr bgcolor=$row_colour><td></td>
<td class=list-bold>" . generate_device_link($interface) . "</td>
<td class=list-bold>" . generate_port_link($interface, makeshortif(fixifname($interface['ifDescr']))) . " $error_img</td>
<td>" . Net_IPv6::compress($interface['ipv6_address']) . "/".$length."</td>
<td>" . $interface['ifAlias'] . "</td>
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$speed = humanspeed($interface['ifSpeed']);
$type = humanmedia($interface['ifType']);
list($prefix, $length) = explode("/", $interface['ipv6_network']);
if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0)
{
$error_img = generate_port_link($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
if (port_permitted($interface['interface_id']) )
{
echo('<tr bgcolor="' . $row_colour . '">
<td class="list-bold">' . generate_device_link($interface) . '</td>
<td class="list-bold">' . generate_port_link($interface, makeshortif(fixifname($interface['ifDescr']))) . ' ' . $error_img . '</td>
<td>' . Net_IPv6::compress($interface['ipv6_address']) . '/'.$length.'</td>
<td>' . $interface['ifAlias'] . "</td>
</tr>\n");
$row++;
$row++;
}
}
}
unset($ignore);
unset($ignore);
}
echo("</table>");
?>

View File

@@ -1,7 +1,7 @@
<?php
if($_GET['location']) { $where = "AND location = '$_GET[location]'"; }
if($_GET['location'] == "Unset") { $where = "AND location = ''"; }
if ($_GET['location']) { $where = "AND location = '$_GET[location]'"; }
if ($_GET['location'] == "Unset") { $where = "AND location = ''"; }
if ($_GET['type']) { $where = "AND type = '$_GET[type]'"; }
$sql = "select *, U.device_uptime as uptime from devices AS D, device_uptime AS U WHERE D.id = U.device_id $where ORDER BY `ignore`, `status`, `os`, `hostname`";
@@ -18,10 +18,9 @@ echo("<tr class=interface-desc bgcolor=#e5e5e5 style='font-weight:bold;'>
<td></td>
</tr>");
while($device = mysql_fetch_array($device_query)) {
while ($device = mysql_fetch_array($device_query))
{
include("includes/hostbox.inc.php");
}
echo("</table>");

View File

@@ -1,36 +1,38 @@
<?php
echo('<table cellpadding="7" cellspacing="0" class="devicetable" width="100%">');
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$sql = "SELECT `location` FROM `devices` GROUP BY `location` ORDER BY `location`";
} else {
$sql = "SELECT `location` FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' GROUP BY `location` ORDER BY `location`";
}
$device_query = mysql_query($sql);
while($device = mysql_fetch_array($device_query)) {
while ($device = mysql_fetch_array($device_query))
{
if (!isset($bg) || $bg == "#ffffff") { $bg = "#eeeeee"; } else { $bg="#ffffff"; }
if(!isset($bg) || $bg == "#ffffff") { $bg = "#eeeeee"; } else { $bg="#ffffff"; }
if($_SESSION['userlevel'] == '10') {
$num = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "'"),0);
$net = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'network'"),0);
$srv = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'server'"),0);
$fwl = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'firewall'"),0);
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND status = '0'"),0);
if ($_SESSION['userlevel'] == '10')
{
$num = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "'"),0);
$net = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'network'"),0);
$srv = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'server'"),0);
$fwl = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'firewall'"),0);
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND status = '0'"),0);
} else {
$num = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "'"),0);
$net = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND D.type = 'network'"),0);
$srv = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND type = 'server'"),0);
$fwl = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND type = 'firewall'"),0);
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE location = '" . $device['location'] . "' AND status = '0'"),0);
$num = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "'"),0);
$net = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND D.type = 'network'"),0);
$srv = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND type = 'server'"),0);
$fwl = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND type = 'firewall'"),0);
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE location = '" . $device['location'] . "' AND status = '0'"),0);
}
if($hostalerts) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
if ($hostalerts) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
if($device['location'] != "") {
echo(' <tr bgcolor="' . $bg . '">
if ($device['location'] != "")
{
echo(' <tr bgcolor="' . $bg . '">
<td class="interface" width="300"><a class="list-bold" href="?page=devices&amp;location=' . urlencode($device['location']) . '">' . $device['location'] . '</a></td>
<td width="100">' . $alert . '</td>
<td width="100">' . $num . ' devices</td>

View File

@@ -1,5 +1,4 @@
<div style="width: 470px; margin: auto; margin-top: 30px;">
<div style="margin: auto; width:650px; padding:5px;">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
@@ -25,7 +24,8 @@
<td colspan="2" align="right"><input class="submit" name="submit" type="submit" value="Login" /></td>
</tr>
<?php
if(isset($auth_message)) {
if (isset($auth_message))
{
echo('<tr><td colspan="2" style="font-weight: bold; color: #cc0000;">' . $auth_message . '</td></tr>');
}
?>
@@ -35,9 +35,8 @@ if(isset($auth_message)) {
</tr>
</table>
<?php
if(isset($config['login_message'])) {
if (isset($config['login_message']))
{
echo('<div style="margin-top: 10px;text-align: center; font-weight: bold; color: #cc0000; width: 470px;">'.$config['login_message'].'</div>');
}
?>

View File

@@ -1,10 +1,7 @@
<?php
#print_r($_GET);
$file = $config['install_dir'] . "/html/pages/ports/" . safename($_GET['opta']) . ".inc.php";
if(is_file($file)) { include($file); } else { include("ports/default.inc.php"); }
if (is_file($file)) { include($file); } else { include("ports/default.inc.php"); }
?>

View File

@@ -7,9 +7,9 @@
<option value=''>All Devices</option>
<?php
$query = mysql_query("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`");
while($data = mysql_fetch_array($query)) {
while ($data = mysql_fetch_array($query)) {
echo("<option value='".$data['device_id']."'");
if($data['device_id'] == $_POST['device_id']) { echo("selected"); }
if ($data['device_id'] == $_POST['device_id']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
?>
@@ -18,17 +18,17 @@
<td width='150'>
<select name='state' id='state'>
<option value=''>All States</option>
<option value='up' <?php if($_POST['state'] == "up") { echo("selected"); } ?>>Up</option>
<option value='down'<?php if($_POST['state'] == "down") { echo("selected"); } ?>>Down</option>
<option value='admindown' <?php if($_POST['state'] == "admindown") { echo("selected"); } ?>>Shutdown</option>
<option value='errors' <?php if($_POST['state'] == "errors") { echo("selected"); } ?>>Errors</option>
<option value='ignored' <?php if($_POST['state'] == "ignored") { echo("selected"); } ?>>Ignored</option>
<option value='ethernet' <?php if($_POST['state'] == "ethernet") { echo("selected"); } ?>>Ethernet</option>
<option value='l2vlan' <?php if($_POST['state'] == "l2vlan") { echo("selected"); } ?>>L2 VLAN</option>
<option value='sonet' <?php if($_POST['state'] == "sonet") { echo("selected"); } ?>>SONET</option>
<option value='propvirtual' <?php if($_POST['state'] == "propvirtual") { echo("selected"); } ?>>Virtual</option>
<option value='ppp' <?php if($_POST['state'] == "ppp") { echo("selected"); } ?>>PPP</option>
<option value='loopback' <?php if($_POST['state'] == "loopback") { echo("selected"); } ?>>Loopback</option>
<option value='up' <?php if ($_POST['state'] == "up") { echo("selected"); } ?>>Up</option>
<option value='down'<?php if ($_POST['state'] == "down") { echo("selected"); } ?>>Down</option>
<option value='admindown' <?php if ($_POST['state'] == "admindown") { echo("selected"); } ?>>Shutdown</option>
<option value='errors' <?php if ($_POST['state'] == "errors") { echo("selected"); } ?>>Errors</option>
<option value='ignored' <?php if ($_POST['state'] == "ignored") { echo("selected"); } ?>>Ignored</option>
<option value='ethernet' <?php if ($_POST['state'] == "ethernet") { echo("selected"); } ?>>Ethernet</option>
<option value='l2vlan' <?php if ($_POST['state'] == "l2vlan") { echo("selected"); } ?>>L2 VLAN</option>
<option value='sonet' <?php if ($_POST['state'] == "sonet") { echo("selected"); } ?>>SONET</option>
<option value='propvirtual' <?php if ($_POST['state'] == "propvirtual") { echo("selected"); } ?>>Virtual</option>
<option value='ppp' <?php if ($_POST['state'] == "ppp") { echo("selected"); } ?>>PPP</option>
<option value='loopback' <?php if ($_POST['state'] == "loopback") { echo("selected"); } ?>>Loopback</option>
</select>
</td>
<td width=110>
@@ -36,11 +36,11 @@
<option value=''>All Speeds</option>
<?php
$query = mysql_query("SELECT `ifSpeed` FROM `ports` GROUP BY `ifSpeed` ORDER BY `ifSpeed`");
while($data = mysql_fetch_array($query)) {
while ($data = mysql_fetch_array($query)) {
if ($data['ifSpeed'])
{
echo("<option value='".$data['ifSpeed']."'");
if($data['ifSpeed'] == $_POST['ifSpeed']) { echo("selected"); }
if ($data['ifSpeed'] == $_POST['ifSpeed']) { echo("selected"); }
echo(">".humanspeed($data['ifSpeed'])."</option>");
}
}
@@ -52,11 +52,11 @@
<option value=''>All Media</option>
<?php
$query = mysql_query("SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`");
while($data = mysql_fetch_array($query)) {
while ($data = mysql_fetch_array($query)) {
if ($data['ifType'])
{
echo("<option value='".$data['ifType']."'");
if($data['ifType'] == $_POST['ifType']) { echo("selected"); }
if ($data['ifType'] == $_POST['ifType']) { echo("selected"); }
echo(">".$data['ifType']."</option>");
}
}
@@ -65,7 +65,7 @@
</td>
<td>
<input type="text" name="ifAlias" id="ifAlias" size=40 value="<?php echo($_POST['ifAlias']); ?>" />
Deleted <input type=checkbox id="deleted" name="deleted" value=1 <?php if($_POST['deleted']) { echo("checked"); } ?> ></input>
Deleted <input type=checkbox id="deleted" name="deleted" value=1 <?php if ($_POST['deleted']) { echo("checked"); } ?> ></input>
</td>
<td style="text-align: right;">
<input style="align:right;" type=submit class=submit value=Search></div>
@@ -77,7 +77,6 @@
<table cellpadding=3 cellspacing=0 class=devicetable width=100%>
<?php
#if ($_SESSION['userlevel'] >= '5') {
@@ -86,8 +85,8 @@
# $sql = "SELECT * FROM `ports` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
#}
if($_GET['opta'] == "down" || $_GET['type'] == "down" || $_POST['state'] == "down") {
if ($_GET['opta'] == "down" || $_GET['type'] == "down" || $_POST['state'] == "down")
{
$where .= "AND I.ifAdminStatus = 'up' AND I.ifOperStatus = 'down' AND I.ignore = '0'";
} elseif ($_GET['opta'] == "admindown" || $_GET['type'] == "admindown" || $_POST['state'] == "admindown") {
$where .= "AND I.ifAdminStatus = 'down'";
@@ -111,34 +110,33 @@ if($_GET['opta'] == "down" || $_GET['type'] == "down" || $_POST['state'] == "dow
$where .= " AND I.ifType = 'ppp'";
}
if($_POST['device_id']) { $where .= " AND I.device_id = '".$_POST['device_id']."'"; }
if($_POST['ifType']) { $where .= " AND I.ifType = '".$_POST['ifType']."'"; }
if($_POST['ifSpeed']) { $where .= " AND I.ifSpeed = '".$_POST['ifSpeed']."'"; }
if($_POST['ifAlias']) { $where .= " AND I.ifAlias LIKE '%".$_POST['ifAlias']."%'"; }
if($_POST['deleted'] || $_GET['type'] == "deleted") { $where .= " AND I.deleted = '1'"; }
# FIXME SQL Injection!
if ($_POST['device_id']) { $where .= " AND I.device_id = '".$_POST['device_id']."'"; }
if ($_POST['ifType']) { $where .= " AND I.ifType = '".$_POST['ifType']."'"; }
if ($_POST['ifSpeed']) { $where .= " AND I.ifSpeed = '".$_POST['ifSpeed']."'"; }
if ($_POST['ifAlias']) { $where .= " AND I.ifAlias LIKE '%".$_POST['ifAlias']."%'"; }
if ($_POST['deleted'] || $_GET['type'] == "deleted") { $where .= " AND I.deleted = '1'"; }
$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where ORDER BY D.hostname, I.ifIndex";
$query = mysql_query($sql);
echo("<tr class=tablehead><td></td><th>Device</a></th><th>Interface</th><th>Speed</th><th>Media</th><th>Description</th></tr>");
$row = 1;
while($interface = mysql_fetch_array($query)) {
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
while ($interface = mysql_fetch_array($query))
{
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$speed = humanspeed($interface['ifSpeed']);
$type = humanmedia($interface['ifType']);
if($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0)
{
$error_img = generate_port_link($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
if( port_permitted($interface['interface_id'], $interface['device_id']) )
if (port_permitted($interface['interface_id'], $interface['device_id']))
{
$interface = ifLabel($interface, $device);
echo("<tr bgcolor=$row_colour>
@@ -151,13 +149,9 @@ while($interface = mysql_fetch_array($query)) {
</tr>\n");
$row++;
}
}
echo("</table>");
?>

View File

@@ -1,42 +1,43 @@
<?php
if($_GET['optb'] == "purge" && $_GET['optc'] == "all") {
if ($_GET['optb'] == "purge" && $_GET['optc'] == "all")
{
$sql = "SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id";
$query = mysql_query($sql);
while($interface = mysql_fetch_assoc($query)) {
if(port_permitted($interface['interface_id'], $interface['device_id'])){
while ($interface = mysql_fetch_assoc($query))
{
if (port_permitted($interface['interface_id'], $interface['device_id']))
{
delete_port($interface['interface_id']);
echo("<div class=infobox>Deleted ".generate_device_link($interface)." - ".generate_port_link($interface)."</div>");
}
}
} elseif($_GET['optb'] == "purge" && $_GET['optc']) {
} elseif ($_GET['optb'] == "purge" && $_GET['optc']) {
$interface = mysql_fetch_assoc(mysql_query("SELECT * from `ports` AS P, `devices` AS D WHERE `interface_id` = '".mres($_GET['optc'])."' AND D.device_id = P.device_id"));
if(port_permitted($interface['interface_id'], $interface['device_id']))
if (port_permitted($interface['interface_id'], $interface['device_id']))
delete_port($interface['interface_id']);
echo("<div class=infobox>Deleted ".generate_device_link($interface)." - ".generate_port_link($interface)."</div>");
}
$i_deleted = 1;
echo("<table cellpadding=5 cellspacing=0 border=0 width=100%>");
echo("<tr><td></td><td></td><td></td><td><a href='".$config['base_url'] . "/ports/deleted/purge/all/'><img src='images/16/cross.png' align=absmiddle></img> Purge All</a></td></tr>");
$sql = "SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id";
$query = mysql_query($sql);
while($interface = mysql_fetch_assoc($query)) {
while ($interface = mysql_fetch_assoc($query))
{
$interface = ifLabel($interface, $interface);
if(port_permitted($interface['interface_id'], $interface['device_id'])){
if(is_integer($i_deleted/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if (port_permitted($interface['interface_id'], $interface['device_id']))
{
if (is_integer($i_deleted/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
echo("<tr bgcolor=$row_colour>");
echo("<td width=250>".generate_device_link($interface)."</td>");
echo("<td width=250>".generate_port_link($interface)."</td>");
echo("<td></td>");
echo("<td width=100><a href='".$config['base_url'] . "/ports/deleted/purge/".$interface['interface_id']."/'><img src='images/16/cross.png' align=absmiddle></img> Purge</a></td>");
echo("<td width=250>".generate_device_link($interface)."</td>");
echo("<td width=250>".generate_port_link($interface)."</td>");
echo("<td></td>");
echo("<td width=100><a href='".$config['base_url'] . "/ports/deleted/purge/".$interface['interface_id']."/'><img src='images/16/cross.png' align=absmiddle></img> Purge</a></td>");
$i_deleted++;
}
@@ -44,5 +45,4 @@ while($interface = mysql_fetch_assoc($query)) {
echo("</table>");
?>

View File

@@ -2,15 +2,15 @@
echo("<div style='margin: 10px'>");
echo("<h3>User Preferences</h3>");
if($_POST['action'] == "changepass") {
if(authenticate($_SESSION['username'],$_POST['old_pass'])) {
if($_POST['new_pass'] == "" || $_POST['new_pass2'] == "")
if ($_POST['action'] == "changepass")
{
if (authenticate($_SESSION['username'],$_POST['old_pass']))
{
if ($_POST['new_pass'] == "" || $_POST['new_pass2'] == "")
{
$changepass_message = "Password must not be blank.";
}
elseif($_POST['new_pass'] == $_POST['new_pass2'])
elseif ($_POST['new_pass'] == $_POST['new_pass2'])
{
changepassword($_SESSION['username'],$_POST['new_pass']);
$changepass_message = "Password Changed.";
@@ -49,26 +49,23 @@ if (passwordscanchange())
echo("<div style='background-color: #e5e5e5; border: solid #e5e5e5 10px; margin-bottom:10px;'>");
echo("<div style='font-size: 18px; font-weight: bold; margin-bottom: 5px;'>Device Permissions</div>");
if($_SESSION['userlevel'] == '10') { echo("<strong class='blue'>Global Administrative Access</strong>"); }
if($_SESSION['userlevel'] == '5') { echo("<strong class='green'>Global Viewing Access</strong>"); }
if($_SESSION['userlevel'] == '1') {
if ($_SESSION['userlevel'] == '10') { echo("<strong class='blue'>Global Administrative Access</strong>"); }
if ($_SESSION['userlevel'] == '5') { echo("<strong class='green'>Global Viewing Access</strong>"); }
if ($_SESSION['userlevel'] == '1') {
$perms = mysql_query("SELECT * FROM `devices_perms` AS P, `devices` AS D WHERE `user_id` = '" . $user_id . "' AND P.device_id = D.device_id");
while($perm = mysql_fetch_array($perms)) {
while ($perm = mysql_fetch_array($perms))
{
echo("<a href='?page=device&id=" . $perm['device_id'] . "'>" . $perm['hostname'] . "</a><br />");
$dev_access = 1;
}
if(!$dev_access) { echo("No access!"); }
}
if (!$dev_access) { echo("No access!"); }
}
echo("</div>");
echo("</div>");
echo("</div>");
?>

View File

@@ -8,19 +8,21 @@ echo("<a href='".$config['base_url']."/pseudowires/'>Details</a> | Graphs :
print_optionbar_end();
list($opta, $optb, $optc, $optd, $opte) = explode("/", $_GET['opta']);
list($opta, $optb, $optc, $optd, $opte) = explode("/", $_GET['opta']);
echo("<table cellpadding=5 cellspacing=0 class=devicetable width=100%>");
$sql = "SELECT * FROM pseudowires AS P, ports AS I, devices AS D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id ORDER BY D.hostname,I.ifDescr";
$query = mysql_query($sql);
while($pw_a = mysql_fetch_array($query)) {
$i = 0;
while ($i < count($linkdone)) {
$thislink = $pw_a['device_id'] . $pw_a['interface_id'];
if ($linkdone[$i] == $thislink) { $skip = "yes"; }
$i++;
while ($pw_a = mysql_fetch_array($query))
{
$i = 0;
while ($i < count($linkdone))
{
$thislink = $pw_a['device_id'] . $pw_a['interface_id'];
if ($linkdone[$i] == $thislink) { $skip = "yes"; }
$i++;
}
$pw_b = mysql_fetch_array(mysql_query("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = '".$pw_a['peer_device_id']."' AND
@@ -28,56 +30,60 @@ while($pw_a = mysql_fetch_array($query)) {
P.cpwVcID = '".$pw_a['cpwVcID']."' AND
P.interface_id = I.interface_id"));
if(!port_permitted($pw_a['interface_id'])) { $skip = "yes"; }
if(!port_permitted($pw_b['interface_id'])) { $skip = "yes"; }
if (!port_permitted($pw_a['interface_id'])) { $skip = "yes"; }
if (!port_permitted($pw_b['interface_id'])) { $skip = "yes"; }
if($skip) {
if ($skip)
{
unset($skip);
} else {
if($bg == "ffffff") { $bg = "e5e5e5"; } else { $bg="ffffff"; }
if ($bg == "ffffff") { $bg = "e5e5e5"; } else { $bg="ffffff"; }
echo("<tr style=\"background-color: #$bg;\"><td rowspan=2 style='font-size:18px; padding:4px;'>".$pw_a['cpwVcID']."</td><td>".generate_device_link($pw_a)."</td><td>".generate_port_link($pw_a)."</td>
<td rowspan=2> <img src='".$config['base_url']."/images/16/arrow_right.png'> </td>
<td>".generate_device_link($pw_b)."</td><td>".generate_port_link($pw_b)."</td></tr>");
echo("<tr style=\"background-color: #$bg;\"><td colspan=2>".$pw_a['ifAlias']."</td><td colspan=2>".$pw_b['ifAlias']."</td></tr>");
if($opta == "graphs") {
if ($opta == "graphs")
{
echo("<tr style=\"background-color: #$bg;\"><td></td><td colspan=2>");
if(!$optb) { $optb = "mini"; }
if($pw_a) {
if (!$optb) { $optb = "mini"; }
if ($pw_a)
{
$pw_a['width'] = "150";
$pw_a['height'] = "30";
$pw_a['from'] = $day;
$pw_a['to'] = $now;
$pw_a['bg'] = $bg;
$types = array('bits','pkts','errors');
foreach($types as $graph_type) {
foreach ($types as $graph_type)
{
$pw_a['graph_type'] = $graph_type;
generate_port_thumbnail($pw_a);
}
}
echo("</td><td></td><td colspan=2>");
if($pw_b) {
if ($pw_b)
{
$pw_b['width'] = "150";
$pw_b['height'] = "30";
$pw_b['from'] = $day;
$pw_b['to'] = $now;
$pw_b['bg'] = $bg;
$types = array('bits','pkts','errors');
foreach($types as $graph_type) {
foreach ($types as $graph_type)
{
$pw_b['graph_type'] = $graph_type;
generate_port_thumbnail($pw_b);
}
}
echo("</td></tr>");
}
$linkdone[] = $pw_b['device_id'] . $pw_b['interface_id'];
}
}
echo("</table>");

View File

@@ -1,40 +1,45 @@
<?php
function delete_port($interface_id) {
$ipaddrs = mysql_query("SELECT * FROM `ipaddr` WHERE `interface_id` = '$interface_id'");
while($ipaddr = mysql_fetch_array($ipaddrs)) {
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv4 address " . $ipaddr['addr'] . "/" . $ipaddr['cidr'] );
mysql_query("DELETE FROM addr WHERE id = '".$addr['id']."'");
echo("</div>");
}
function delete_port($interface_id)
{
$ipaddrs = mysql_query("SELECT * FROM `ipaddr` WHERE `interface_id` = '$interface_id'");
while ($ipaddr = mysql_fetch_array($ipaddrs))
{
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv4 address " . $ipaddr['addr'] . "/" . $ipaddr['cidr'] );
mysql_query("DELETE FROM addr WHERE id = '".$addr['id']."'");
echo("</div>");
}
$ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'");
while($ip6addr = mysql_fetch_array($ip6addrs)) {
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen'] );
mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'");
echo("</div>");
}
$ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'");
while ($ip6addr = mysql_fetch_array($ip6addrs))
{
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen'] );
mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'");
echo("</div>");
}
$ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'");
while($ip6addr = mysql_fetch_array($ip6addrs)) {
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen'] );
mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'");
echo("</div>");
}
$ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'");
while ($ip6addr = mysql_fetch_array($ip6addrs))
{
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen'] );
mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'");
echo("</div>");
}
mysql_query("DELETE FROM `pseudowires` WHERE `interface_id` = '$interface_id'");
mysql_query("DELETE FROM `mac_accounting` WHERE `interface_id` = '$interface_id'");
mysql_query("DELETE FROM `links` WHERE `local_interface_id` = '$interface_id'");
mysql_query("DELETE FROM `links` WHERE `remote_interface_id` = '$interface_id'");
mysql_query("DELETE FROM `ports_perms` WHERE `interface_id` = '$interface_id'");
mysql_query("DELETE FROM `ports` WHERE `interface_id` = '$interface_id'");
}
mysql_query("DELETE FROM `pseudowires` WHERE `interface_id` = '$interface_id'");
mysql_query("DELETE FROM `mac_accounting` WHERE `interface_id` = '$interface_id'");
mysql_query("DELETE FROM `links` WHERE `local_interface_id` = '$interface_id'");
mysql_query("DELETE FROM `links` WHERE `remote_interface_id` = '$interface_id'");
mysql_query("DELETE FROM `ports_perms` WHERE `interface_id` = '$interface_id'");
mysql_query("DELETE FROM `ports` WHERE `interface_id` = '$interface_id'");
}
$ports = mysql_query("SELECT * FROM `ports` WHERE `deleted` = '1'");
while($port = mysql_fetch_array($ports)) {
echo("<div style='font-weight: bold;'>Deleting port " . $port['interface_id'] . " - " . $port['ifDescr'] );
delete_port($port['interface_id']);
echo("</div>");
}
$ports = mysql_query("SELECT * FROM `ports` WHERE `deleted` = '1'");
while ($port = mysql_fetch_array($ports))
{
echo("<div style='font-weight: bold;'>Deleting port " . $port['interface_id'] . " - " . $port['ifDescr'] );
delete_port($port['interface_id']);
echo("</div>");
}
?>

View File

@@ -1,34 +1,35 @@
<?php print_optionbar_start();
if(!$_GET['opta']) { $_GET['opta'] = "basic"; }
if (!$_GET['opta']) { $_GET['opta'] = "basic"; }
echo("<a href='".$config['base_url']."/services/basic/'>Basic</a> | ");
echo("<a href='".$config['base_url']."/services/details/'>Details</a>");
print_optionbar_end();
if($_GET['status'] == '0') { $where = " AND service_status = '0'"; } else { unset ($where); }
if ($_GET['status'] == '0') { $where = " AND service_status = '0'"; } else { unset ($where); }
echo("<div style='margin: 5px;'><table cellpadding=7 border=0 cellspacing=0 width=100%>");
//echo("<tr class=interface-desc bgcolor='#e5e5e5'><td>Device</td><td>Service</td><td>Status</td><td>Changed</td><td>Checked</td><td>Message</td></tr>");
if ($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$host_sql = "SELECT * FROM devices AS D, services AS S WHERE D.device_id = S.device_id GROUP BY D.hostname ORDER BY D.hostname";
} else {
$host_sql = "SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' $where GROUP BY D.hostname ORDER BY D.hostname";
}
$host_query = mysql_query($host_sql);
while($host_data = mysql_fetch_array($host_query)) {
while ($host_data = mysql_fetch_array($host_query))
{
$device_id = $host_data['device_id'];
$device_hostname = $host_data['hostname'];
$service_query = mysql_query("SELECT * FROM `services` WHERE `device_id` = '" . $host_data['device_id'] . "' $where");
while($service = mysql_fetch_array($service_query))
while ($service = mysql_fetch_array($service_query))
{
include("includes/print-service.inc");
# $samehost = 1;
if($_GET['opta'] == "details")
if ($_GET['opta'] == "details")
{
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $now;
@@ -39,8 +40,9 @@ if ($_SESSION['userlevel'] >= '5') {
echo('<tr style="background-color: '.$bg.'; padding: 5px;"><td colspan=6>');
foreach($periods as $period) {
$graph_array['from'] = $$period;
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));
}

View File

@@ -1,16 +1,12 @@
<?php
if($_SESSION['userlevel'] == '10') {
echo("<pre>");
print_r($config);
echo("</pre>");
if ($_SESSION['userlevel'] == '10')
{
echo("<pre>");
print_r($config);
echo("</pre>");
} else {
include("includes/error-no-perm.inc.php");
}
?>

View File

@@ -1,6 +1,7 @@
<?php
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5')
{
$sql = "SELECT * FROM `storage` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY D.hostname, S.storage_descr";
} else {
$sql = "SELECT * FROM `storage` AS S, `devices` AS D, devices_perms as P WHERE S.device_id = D.device_id AND ";
@@ -22,60 +23,63 @@ echo("<tr class=tablehead>
$row = 1;
while($drive = mysql_fetch_array($query)) {
while ($drive = mysql_fetch_array($query))
{
$skipdrive = 0;
$skipdrive = 0;
if ($drive["os"] == "junos") {
foreach ($config['ignore_junos_os_drives'] as $jdrive) {
if (preg_match($jdrive, $drive["storage_descr"])) {
$skipdrive = 1;
}
}
$drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]);
if ($drive["os"] == "junos")
{
foreach ($config['ignore_junos_os_drives'] as $jdrive)
{
if (preg_match($jdrive, $drive["storage_descr"]))
{
$skipdrive = 1;
}
}
if ($drive['os'] == "freebsd") {
foreach ($config['ignore_bsd_os_drives'] as $jdrive) {
if (preg_match($jdrive, $drive["storage_descr"])) {
$skipdrive = 1;
}
}
$drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]);
}
if ($drive['os'] == "freebsd")
{
foreach ($config['ignore_bsd_os_drives'] as $jdrive)
{
if (preg_match($jdrive, $drive["storage_descr"]))
{
$skipdrive = 1;
}
}
}
if ($skipdrive) { continue; }
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if ($skipdrive) { continue; }
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$perc = round($drive['storage_perc'], 0);
$total = formatStorage($drive['storage_size']);
$free = formatStorage($drive['storage_free']);
$used = formatStorage($drive['storage_used']);
$perc = round($drive['storage_perc'], 0);
$total = formatStorage($drive['storage_size']);
$free = formatStorage($drive['storage_free']);
$used = formatStorage($drive['storage_used']);
$store_url = "graph.php?id=" . $drive['storage_id'] . "&type=storage&from=$month&to=$now&width=400&height=125";
$store_popup = "onmouseover=\"return overlib('<img src=\'$store_url\'>', LEFT);\" onmouseout=\"return nd();\"";
$store_url = "graph.php?id=" . $drive['storage_id'] . "&type=storage&from=$month&to=$now&width=400&height=125";
$store_popup = "onmouseover=\"return overlib('<img src=\'$store_url\'>', LEFT);\" onmouseout=\"return nd();\"";
$mini_graph = $config['base_url'] . "/graph.php?id=".$drive['storage_id']."&type=storage&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4";
$mini_graph = $config['base_url'] . "/graph.php?id=".$drive['storage_id']."&type=storage&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4";
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
} else { $left_background='9abf5b'; $right_background='bbd392'; }
if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; }
elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; }
elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; }
elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; }
else { $left_background='9abf5b'; $right_background='bbd392'; }
echo("<tr bgcolor='$row_colour'><td>" . generate_device_link($drive) . "</td><td class=tablehead>" . $drive['storage_descr'] . "</td>
<td><img src='$mini_graph'></td>
<td>
<a href='#' $store_popup>".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, formatStorage($free), "ffffff", $right_background)."</a>
</td><td>$perc"."%</td></tr>");
echo("<tr bgcolor='$row_colour'><td>" . generate_device_link($drive) . "</td><td class=tablehead>" . $drive['storage_descr'] . "</td>
<td><img src='$mini_graph'></td>
<td>
<a href='#' $store_popup>".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, formatStorage($free), "ffffff", $right_background)."</a>
</td><td>$perc"."%</td></tr>");
$row++;
$row++;
}
echo("</table></div>");
?>

View File

@@ -1,8 +1,8 @@
<meta http-equiv="refresh" content="60">
<?php if($_GET['opta'] == "expunge" && $_SESSION['userlevel'] >= '10') { mysql_query("TRUNCATE TABLE `syslog`"); } ?>
<?php if ($_GET['opta'] == "expunge" && $_SESSION['userlevel'] >= '10') { mysql_query("TRUNCATE TABLE `syslog`"); } ?>
<?php print_optionbar_start('25'); ?>
<?php print_optionbar_start('25'); ?>
<form method="post" action="">
<label><strong>Search</strong>
@@ -14,9 +14,9 @@
<option value="">All Programs</option>
<?php
$query = mysql_query("SELECT `program` FROM `syslog` GROUP BY `program` ORDER BY `program`");
while($data = mysql_fetch_array($query)) {
while ($data = mysql_fetch_array($query)) {
echo("<option value='".$data['program']."'");
if($data['program'] == $_POST['program']) { echo("selected"); }
if ($data['program'] == $_POST['program']) { echo("selected"); }
echo(">".$data['program']."</option>");
}
?>
@@ -28,10 +28,10 @@
<option value="">All Devices</option>
<?php
$query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`");
while($data = mysql_fetch_array($query)) {
while ($data = mysql_fetch_array($query)) {
echo("<option value='".$data['device_id']."'");
if($data['device_id'] == $_POST['device']) { echo("selected"); }
if ($data['device_id'] == $_POST['device']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
@@ -47,19 +47,19 @@
print_optionbar_end();
if($_POST['string']) {
if ($_POST['string']) {
$where = " AND S.msg LIKE '%".$_POST['string']."%'";
}
if($_POST['program']) {
if ($_POST['program']) {
$where .= " AND S.program = '".$_POST['program']."'";
}
if($_POST['device']) {
if ($_POST['device']) {
$where .= " AND D.device_id = '".$_POST['device']."'";
}
if($_SESSION['userlevel'] >= '5') {
if ($_SESSION['userlevel'] >= '5') {
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog
WHERE 1 $where ORDER BY timestamp DESC LIMIT 1000";
} else {
@@ -69,7 +69,7 @@ if($_SESSION['userlevel'] >= '5') {
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while($entry = mysql_fetch_array($query)) {
while ($entry = mysql_fetch_array($query)) {
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
include("includes/print-syslog.inc");
}

View File

@@ -8,10 +8,12 @@ echo("
<a href='".$config['base_url']."/vrf/" . $_GET['id'] . "/graphs/pkts/'>Packets</a> |
<a href='".$config['base_url']."/vrf/" . $_GET['id'] . "/graphs/nupkts/'>NU Packets</a> |
<a href='".$config['base_url']."/vrf/" . $_GET['id'] . "/graphs/errors/'>Errors</a>
</div> ");
</div>");
if($_GET['opta'] == graphs ) {
if($_GET['optb']) {
if ($_GET['opta'] == 'graphs')
{
if ($_GET['optb'])
{
$graph_type = $_GET['optb'];
} else {
$graph_type = "bits";
@@ -19,45 +21,48 @@ if($_GET['opta'] == graphs ) {
$dographs = 1;
}
if($_GET['opta'] == "details" ) {
if ($_GET['opta'] == "details" )
{
$port_details = 1;
}
echo("<div style='background: $list_colour_b; padding: 10px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$vrf_query = mysql_query("SELECT * FROM `vrfs` WHERE mplsVpnVrfRouteDistinguisher = '".$_GET['id']."'");
$vrf = mysql_fetch_array($vrf_query);
echo("<tr valign=top bgcolor='$bg_colour'>");
echo("<td width=200 class=list-large><a href='vrf/".$vrf['mplsVpnVrfRouteDistinguisher']."/'>" . $vrf['vrf_name'] . "</a></td>");
echo("<td width=100 class=box-desc>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>");
echo("<td width=200 class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</td>");
echo("</table></div>");
echo("<div style='background: $list_colour_b; padding: 10px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$vrf_query = mysql_query("SELECT * FROM `vrfs` WHERE mplsVpnVrfRouteDistinguisher = '".$_GET['id']."'");
$vrf = mysql_fetch_array($vrf_query);
echo("<tr valign=top bgcolor='$bg_colour'>");
echo("<td width=200 class=list-large><a href='vrf/".$vrf['mplsVpnVrfRouteDistinguisher']."/'>" . $vrf['vrf_name'] . "</a></td>");
echo("<td width=100 class=box-desc>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>");
echo("<td width=200 class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</td>");
echo("</table></div>");
$devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id");
$x=1;
$devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id");
$x=1;
while($device = mysql_fetch_array($devices)) {
$hostname = $device['hostname'];
#if(!is_integer($x/2)) { $device_colour = $list_colour_a; } else { $device_colour = $list_colour_b; }
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
include("includes/device-header.inc.php");
echo("</table>");
$ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'");
unset($seperator);
echo("<table cellspacing=0 cellpadding=7>");
$i=1;
while($interface = mysql_fetch_array($ports)) {
if(!is_integer($x/2)) {
if(is_integer($i/2)) { $int_colour = $list_colour_a_a; } else { $int_colour = $list_colour_a_b; }
} else {
if(is_integer($i/2)) { $int_colour = $list_colour_b_b; } else { $int_colour = $list_colour_b_a; }
}
include("includes/print-interface.inc.php");
$i++;
}
$x++;
echo("</table>");
echo("<div style='height: 10px;'></div>");
}
while ($device = mysql_fetch_array($devices))
{
$hostname = $device['hostname'];
#if (!is_integer($x/2)) { $device_colour = $list_colour_a; } else { $device_colour = $list_colour_b; }
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
include("includes/device-header.inc.php");
echo("</table>");
$ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'");
unset($seperator);
echo("<table cellspacing=0 cellpadding=7>");
$i=1;
while ($interface = mysql_fetch_array($ports))
{
if (!is_integer($x/2))
{
if (is_integer($i/2)) { $int_colour = $list_colour_a_a; } else { $int_colour = $list_colour_a_b; }
} else {
if (is_integer($i/2)) { $int_colour = $list_colour_b_b; } else { $int_colour = $list_colour_b_a; }
}
include("includes/print-interface.inc.php");
$i++;
}
$x++;
echo("</table>");
echo("<div style='height: 10px;'></div>");
}
?>

View File

@@ -1,61 +1,65 @@
<?php
if($_SESSION['userlevel'] >= '5') {
print_optionbar_start();
echo("
if ($_SESSION['userlevel'] >= '5')
{
print_optionbar_start();
echo("
<a href='".$config['base_url']. "/vrfs/'>Basic</a> | Graphs :
<a href='".$config['base_url']. "/vrfs/bits/'>Bits</a> |
<a href='".$config['base_url']. "/vrfs/upkts/'>Packets</a> |
<a href='".$config['base_url']. "/vrfs/nupkts/'>NU Packets</a> |
<a href='".$config['base_url']. "/vrfs/errors/'>Errors</a>
");
print_optionbar_end();
print_optionbar_end();
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1";
$vrf_query = mysql_query("SELECT * FROM `vrfs` GROUP BY `mplsVpnVrfRouteDistinguisher`");
while ($vrf = mysql_fetch_array($vrf_query))
{
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
echo("<tr valign=top bgcolor='$bg_colour'>");
echo("<td width=240><a class=list-large href='vrf/".$vrf['mplsVpnVrfRouteDistinguisher']."/'>" . $vrf['vrf_name'] . "</a><br /><span class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</span></td>");
echo("<td width=100 class=box-desc>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>");
#echo("<td width=200 class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</td>");
echo("<td><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id");
$x=1;
while ($device = mysql_fetch_array($devices))
{
if (!is_integer($i/2))
{
if (!is_integer($x/2)) { $dev_colour = $list_colour_a_a; } else { $dev_colour = $list_colour_a_b; }
} else {
if (!is_integer($x/2)) { $dev_colour = $list_colour_b_b; } else { $dev_colour = $list_colour_b_a; }
}
echo("<tr bgcolor='$dev_colour'><td width=150>".generate_device_link($device, shorthost($device['hostname'])));
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1";
$vrf_query = mysql_query("SELECT * FROM `vrfs` GROUP BY `mplsVpnVrfRouteDistinguisher`");
while($vrf = mysql_fetch_array($vrf_query)) {
if ($device['vrf_name'] != $vrf['vrf_name']) { echo("<a href='#' onmouseover=\" return overlib('Expected Name : ".$vrf['vrf_name']."<br />Configured : ".$device['vrf_name']."', CAPTION, '<span class=list-large>VRF Inconsistency</span>' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> <img align=absmiddle src=images/16/exclamation.png></a>"); }
echo("</td><td>");
$ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'");
unset($seperator);
if(!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
echo("<tr valign=top bgcolor='$bg_colour'>");
echo("<td width=240><a class=list-large href='vrf/".$vrf['mplsVpnVrfRouteDistinguisher']."/'>" . $vrf['vrf_name'] . "</a><br /><span class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</span></td>");
echo("<td width=100 class=box-desc>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>");
#echo("<td width=200 class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</td>");
echo("<td><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id");
$x=1;
while($device = mysql_fetch_array($devices)) {
if(!is_integer($i/2)) {
if(!is_integer($x/2)) { $dev_colour = $list_colour_a_a; } else { $dev_colour = $list_colour_a_b; }
} else {
if(!is_integer($x/2)) { $dev_colour = $list_colour_b_b; } else { $dev_colour = $list_colour_b_a; }
}
echo("<tr bgcolor='$dev_colour'><td width=150>".generate_device_link($device, shorthost($device['hostname'])));
if($device['vrf_name'] != $vrf['vrf_name']) { echo("<a href='#' onmouseover=\" return overlib('Expected Name : ".$vrf['vrf_name']."<br />Configured : ".$device['vrf_name']."', CAPTION, '<span class=list-large>VRF Inconsistency</span>' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> <img align=absmiddle src=images/16/exclamation.png></a>"); }
echo("</td><td>");
$ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'");
unset($seperator);
while($port = mysql_fetch_array($ports)) {
$port = array_merge ($device, $port);
if($_GET['opta']) {
$port['width'] = "130";
$port['height'] = "30";
$port['from'] = $day;
$port['to'] = $now;
$port['bg'] = "#".$bg;
$port['graph_type'] = "port_".$_GET['opta'];
echo("<div style='display: block; padding: 3px; margin: 3px; min-width: 135px; max-width:135px; min-height:75px; max-height:75px;
while ($port = mysql_fetch_array($ports))
{
$port = array_merge ($device, $port);
if ($_GET['opta'])
{
$port['width'] = "130";
$port['height'] = "30";
$port['from'] = $day;
$port['to'] = $now;
$port['bg'] = "#".$bg;
$port['graph_type'] = "port_".$_GET['opta'];
echo("<div style='display: block; padding: 3px; margin: 3px; min-width: 135px; max-width:135px; min-height:75px; max-height:75px;
text-align: center; float: left; background-color: ".$list_colour_b_b.";'>
<div style='font-weight: bold;'>".makeshortif($port['ifDescr'])."</div>");
generate_port_thumbnail($port);
echo("<div style='font-size: 9px;'>".truncate(short_port_descr($port['ifAlias']), 22, '')."</div>
generate_port_thumbnail($port);
echo("<div style='font-size: 9px;'>".truncate(short_port_descr($port['ifAlias']), 22, '')."</div>
</div>");
} else {
echo($seperator.generate_port_link($port,makeshortif($port['ifDescr'])));
$seperator = ", ";
echo($seperator.generate_port_link($port,makeshortif($port['ifDescr'])));
$seperator = ", ";
}
}
echo("</td></tr>");
@@ -64,16 +68,14 @@ print_optionbar_end();
echo("</table></td>");
$i++;
}
echo("</table></div>");
} else {
include("includes/error-no-perm.inc.php");
include("includes/error-no-perm.inc.php");
} ## End Permission if
?>