Resolved a large number index issues and update Console_Color to V2

This commit is contained in:
laf
2015-03-01 18:04:57 +00:00
parent 7dfbfd5c0e
commit c1ef9b6808
18 changed files with 168 additions and 160 deletions
-1
View File
@@ -16,7 +16,6 @@ include_once("../includes/defaults.inc.php");
include_once("../config.php");
include_once("../includes/definitions.inc.php");
include_once("../includes/common.php");
include_once("../includes/console_colour.php");
include_once("../includes/dbFacile.php");
include_once("../includes/rewrites.php");
include_once("includes/functions.inc.php");
+2
View File
@@ -54,6 +54,8 @@ include_once("includes/authenticate.inc.php");
include("includes/graphs/graph.inc.php");
$console_color = new Console_Color2();
$end = utime(); $run = $end - $start;;
if($debug) { echo("<br />Runtime ".$run." secs");
+2 -2
View File
@@ -547,7 +547,7 @@ function getlocations()
$ignore_dev_location[$row['device_id']] = 1;
}
# We can do this because of the ORDER BY, "bool" will be handled before "string"
elseif ($row['attrib_type'] == 'override_sysLocation_string' && $ignore_dev_location[$row['device_id']] == 1)
elseif ($row['attrib_type'] == 'override_sysLocation_string' && (isset($ignore_dev_location[$row['device_id']]) && $ignore_dev_location[$row['device_id']] == 1))
{
if (!in_array($row['attrib_value'],$locations)) { $locations[] = $row['attrib_value']; }
}
@@ -564,7 +564,7 @@ function getlocations()
foreach ($rows as $row)
{
# Only add it as a location if it wasn't overridden (and not already there)
if ($row['location'] != '' && !$ignore_dev_location[$row['device_id']])
if ($row['location'] != '' && !isset($ignore_dev_location[$row['device_id']]))
{
if (!in_array($row['location'],$locations)) { $locations[] = $row['location']; }
}
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
if ($bg == $list_colour_b) { $bg = $list_colour_a; } else { $bg = $list_colour_b; }
if (isset($bg) && $bg == $list_colour_b) { $bg = $list_colour_a; } else { $bg = $list_colour_b; }
if ($device['status'] == '0')
{
-2
View File
@@ -13,8 +13,6 @@ foreach (dbFetchRows("SELECT * FROM `devices` ORDER BY `hostname`") as $device)
$device['location'] = get_dev_attrib($device,'override_sysLocation_string');
}
$devices['count']++;
$cache['devices']['hostname'][$device['hostname']] = $device['device_id'];
$cache['devices']['id'][$device['device_id']] = $device;
-1
View File
@@ -14,7 +14,6 @@ if (!isset($alert_entry['device'])) {
</td>");
}
echo("<td>".$alert_entry['link']."</td>");
echo("<td>".htmlspecialchars($alert_entry['name']) . "</td>
</tr>");
+9 -7
View File
@@ -165,12 +165,12 @@ if ($_SESSION['userlevel'] >= '10')
<?php
if ($ports['errored'])
if (isset($ports['errored']))
{
echo(' <li><a href="ports/errors=1/"><img src="images/16/chart_curve_error.png" border="0" align="absmiddle" /> Errored ('.$ports['errored'].')</a></li>');
}
if ($ports['ignored'])
if (isset($ports['ignored']))
{
echo(' <li><a href="ports/ignore=1/"><img src="images/16/chart_curve_link.png" border="0" align="absmiddle" /> Ignored ('.$ports['ignored'].')</a></li>');
}
@@ -254,7 +254,7 @@ if ($menu_sensors)
foreach (array('fanspeed','humidity','temperature') as $item)
{
if ($menu_sensors[$item])
if (isset($menu_sensors[$item]))
{
echo(' <li><a href="health/metric='.$item.'/"><img src="images/icons/'.$item.'.png" border="0" align="absmiddle" /> '.nicecase($item).'</a></li>');
unset($menu_sensors[$item]);$sep++;
@@ -269,7 +269,7 @@ if ($sep)
foreach (array('current','frequency','power','voltage') as $item)
{
if ($menu_sensors[$item])
if (isset($menu_sensors[$item]))
{
echo(' <li><a href="health/metric='.$item.'/"><img src="images/icons/'.$item.'.png" border="0" align="absmiddle" /> '.nicecase($item).'</a></li>');
unset($menu_sensors[$item]);$sep++;
@@ -306,10 +306,12 @@ if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0")
$app_list = dbFetchRows("SELECT `app_type` FROM `applications` GROUP BY `app_type` ORDER BY `app_type`");
foreach ($app_list as $app)
{
$image = $config['html_dir']."/images/icons/".$row['app_type'].".png";
$icon = (file_exists($image) ? $row['app_type'] : "apps");
if (isset($row['app_type'])) {
$image = $config['html_dir']."/images/icons/".$row['app_type'].".png";
$icon = (file_exists($image) ? $row['app_type'] : "apps");
echo('
<li><a href="apps/app='.$app['app_type'].'/"><img src="images/icons/'.$icon.'.png" border="0" align="absmiddle" /> '.nicecase($app['app_type']).' </a></li>');
<li><a href="apps/app='.$app['app_type'].'/"><img src="images/icons/'.$icon.'.png" border="0" align="absmiddle" /> '.nicecase($app['app_type']).' </a></li>');
}
}
?>
</ul>
+4 -4
View File
@@ -132,7 +132,7 @@ if (isset($config['branding']) && is_array($config['branding']))
}
# page_title_prefix is displayed, unless page_title is set
if ($config['page_title']) { $config['page_title_prefix'] = $config['page_title']; }
if (isset($config['page_title'])) { $config['page_title_prefix'] = $config['page_title']; }
?>
<!DOCTYPE HTML>
@@ -185,7 +185,7 @@ if ($config['favicon']) { echo(' <link rel="shortcut icon" href="'.$config['fav
<?php
if (!$vars['bare'] == "yes") {
if ((isset($vars['bare']) && $vars['bare'] != "yes") || !isset($vars['bare'])) {
if ($_SESSION['authenticated'])
{
@@ -213,7 +213,7 @@ if ($_SESSION['authenticated'])
<?php
// To help debug the new URLs :)
if ($devel || $vars['devel'])
if (isset($devel) || isset($vars['devel']))
{
echo("<pre>");
print_r($_GET);
@@ -284,7 +284,7 @@ if ($config['page_gen'])
echo(' <br />Generated in ' . $gentime . ' seconds.');
}
if (is_array($pagetitle))
if (isset($pagetitle) && is_array($pagetitle))
{
# if prefix is set, put it in front
if ($config['page_title_prefix']) { array_unshift($pagetitle,$config['page_title_prefix']); }
+22 -16
View File
@@ -17,20 +17,20 @@ if(isset($vars['state']))
}
}
if ($vars['hostname']) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; }
if ($vars['os']) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; }
if ($vars['version']) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; }
if ($vars['hardware']) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; }
if ($vars['features']) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; }
if ($vars['type']) { $where .= " AND type = ?"; $sql_param[] = $vars['type']; }
if ($vars['state']) {
if (isset($vars['hostname'])) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; }
if (isset($vars['os'])) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; }
if (isset($vars['version'])) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; }
if (isset($vars['hardware'])) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; }
if (isset($vars['features'])) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; }
if (isset($vars['type'])) { $where .= " AND type = ?"; $sql_param[] = $vars['type']; }
if (isset($vars['state'])) {
$where .= " AND status= ?"; $sql_param[] = $state;
$where .= " AND disabled='0' AND `ignore`='0'"; $sql_param[] = '';
}
if ($vars['disabled']) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; }
if ($vars['ignore']) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; }
if ($vars['location'] == "Unset") { $location_filter = ''; }
if ($vars['location']) { $location_filter = $vars['location']; }
if (isset($vars['disabled'])) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; }
if (isset($vars['ignore'])) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; }
if (isset($vars['location']) && $vars['location'] == "Unset") { $location_filter = ''; }
if (isset($vars['location'])) { $location_filter = $vars['location']; }
$pagetitle[] = "Devices";
@@ -94,7 +94,7 @@ foreach ($menu_options as $option => $text)
<?php
if ($vars['searchbar'] == "hide")
if (isset($vars['searchbar']) && $vars['searchbar'] == "hide")
{
echo('<a href="'. generate_url($vars, array('searchbar' => '')).'">Restore Search</a>');
} else {
@@ -103,7 +103,7 @@ foreach ($menu_options as $option => $text)
echo(" | ");
if ($vars['bare'] == "yes")
if (isset($vars['bare']) && $vars['bare'] == "yes")
{
echo('<a href="'. generate_url($vars, array('bare' => '')).'">Restore Header</a>');
} else {
@@ -118,7 +118,7 @@ foreach ($menu_options as $option => $text)
print_optionbar_end();
print_optionbar_start();
if($vars['searchbar'] != "hide")
if(isset($vars['searchbar']) && $vars['searchbar'] != "hide")
{
?>
@@ -235,7 +235,13 @@ foreach (dbFetch('SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDE
print_optionbar_end();
$query = "SELECT * FROM `devices` WHERE 1 ".$where." ORDER BY hostname";
$query = "SELECT * FROM `devices` WHERE 1 ";
if (isset($where)) {
$query .= $where;
}
$query .= " ORDER BY hostname";
list($format, $subformat) = explode("_", $vars['format']);
@@ -291,7 +297,7 @@ if($format == "graph")
{
if (device_permitted($device['device_id']))
{
if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter)
if (!isset($location_filter) || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter)
|| $device['location'] == $location_filter))
{
$cell_click = 'onclick="location.href=\'device/device='.$device['device_id'].'/\'" style="cursor: pointer;"';
+3 -3
View File
@@ -63,7 +63,7 @@ echo('<div style="float: right;">');
<a href="<?php echo(generate_url($vars)); ?>" title="Update the browser URL to reflect the search criteria." >Update URL</a> |
<?php
if ($vars['searchbar'] == "hide")
if (isset($vars['searchbar']) && $vars['searchbar'] == "hide")
{
echo('<a href="'. generate_url($vars, array('searchbar' => '')).'">Search</a>');
} else {
@@ -72,7 +72,7 @@ echo('<div style="float: right;">');
echo(" | ");
if ($vars['bare'] == "yes")
if (isset($vars['bare']) && $vars['bare'] == "yes")
{
echo('<a href="'. generate_url($vars, array('bare' => '')).'">Header</a>');
} else {
@@ -84,7 +84,7 @@ echo('</div>');
print_optionbar_end();
print_optionbar_start();
if($vars['searchbar'] != "hide")
if(isset($vars['searchbar']) && $vars['searchbar'] != "hide")
{
?>
+2 -2
View File
@@ -15,7 +15,7 @@ $cols = array('device' => 'Device',
foreach ($cols as $sort => $col)
{
if ($vars['sort'] == $sort)
if (isset($vars['sort']) && $vars['sort'] == $sort)
{
echo('<th>'.$col.' *</th>');
} else {
@@ -42,7 +42,7 @@ foreach ($ports as $port)
$type = humanmedia($port['ifType']);
$ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
if ($port['in_errors'] > 0 || $port['out_errors'] > 0)
if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0))
{
$error_img = generate_port_link($port,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }