commit version 22.12.12447

This commit is contained in:
2023-01-01 22:36:12 -05:00
parent af1b03d79f
commit b948283a96
744 changed files with 620715 additions and 27381 deletions

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -15,10 +15,10 @@ $results = dbFetchRows("SELECT * FROM `wifi_aps`
WHERE `ap_name` LIKE ? $query_permitted_device
ORDER BY `ap_name` LIMIT $query_limit", array($query_param));
if (safe_count($results)) {
if (!safe_empty($results)) {
$max_len = 35;
foreach ($results as $result) {
$name = $result['ap_name'];
if (strlen($name) > 35) { $name = substr($name, 0, 35) . "..."; }
$name = truncate($result['ap_name']);
/// FIXME: once we have alerting, colour this to the sensor's status
$tab_colour = '#194B7F'; // FIXME: This colour pulled from functions.inc.php humanize_device, maybe set it centrally in definitions?

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -25,23 +25,20 @@ $results = dbFetchRows("SELECT * FROM `devices`
WHERE $where $query_permitted_device
ORDER BY `hostname` LIMIT $query_limit", $params);
if (safe_count($results)) {
$max_len = 35;
foreach ($results as $result) {
humanize_device($result);
$name = $result['hostname'];
$max_len = 35;
if (strlen($name) > 35) {
$name = substr($name, 0, 35) . "...";
}
$name = truncate($result['hostname'], $max_len);
if ($_SESSION['userlevel'] >= 5 && !safe_empty($result['ip'])) {
$name .= ' ('.$result['ip'].')';
}
$num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($result['device_id']));
$num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?", [ $result['device_id'] ]);
$descr = '';
if ($result['hostname'] != $result['sysName'] && $result['sysName']) {
$descr .= strlen($result['sysName']) > 35 ? substr($result['sysName'], 0, 35) . "..." : $result['sysName'];
$descr .= truncate($result['sysName'], $max_len);
$descr .= ' | ';
}
if ($result['location']) {
@ -58,9 +55,9 @@ if (safe_count($results)) {
'row_class' => $result['row_class'],
'html_row_class' => $result['html_row_class'],
'icon' => get_device_icon($result),
'data' => array(
'data' => [
escape_html($result['hardware'] . ' | ' . $config['os'][$result['os']]['text'] . ' ' . $result['version']),
html_highlight(escape_html($descr), $queryString) . $num_ports . ' ports'),
html_highlight(escape_html($descr), $queryString) . $num_ports . ' ports' ],
);
}

View File

@ -1,5 +1,4 @@
<?php
/**
* Observium
*
@ -7,23 +6,23 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
/// SEARCH ACCESSPOINTS
$results = dbFetchRows("SELECT * FROM `groups`
/// Search Groups
$results = dbFetchRows('SELECT * FROM `groups`
WHERE `group_name` LIKE ? OR `group_descr` LIKE ?
ORDER BY `group_name` LIMIT $query_limit", array($query_param, $query_param));
ORDER BY `group_name` LIMIT ' . $query_limit, array($query_param, $query_param));
if (safe_count($results)) {
$group_search_results = [];
if (!safe_empty($results)) {
$max_len = 35;
foreach ($results as $result) {
$name = $result['group_name'];
if (strlen($name) > 35) {
$name = substr($name, 0, 35) . "...";
}
$name = truncate($result['group_name'], $max_len);
$entity_type = $config['entities'][$result['entity_type']];
$entity_type = $config['entities'][$result['entity_type']];
/// FIXME: always blue
$tab_colour = '#194B7F'; // FIXME: This colour pulled from functions.inc.php humanize_device, maybe set it centrally in definitions?

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -16,10 +16,14 @@ $results = dbFetchRows("SELECT * FROM `entPhysical`
WHERE `deleted` IS NULL AND (`entPhysicalSerialNum` LIKE ? OR `entPhysicalModelName` LIKE ?) $query_permitted_device
ORDER BY `entPhysicalName` LIMIT $query_limit", [ $query_param, $query_param ]);
if (safe_count($results)) {
if (!safe_empty($results)) {
$max_len = 35;
foreach ($results as $result) {
$name = $result['entPhysicalPhysicalName'];
if (strlen($name) > 35) { $name = substr($name, 0, 35) . "..."; }
$name = truncate($result['entPhysicalPhysicalName'], $max_len);
$device_name = truncate($result['hostname'], $max_len);
if ($result['hostname'] != $result['sysName'] && $result['sysName']) {
$device_name .= ' | ' . truncate($result['sysName'], $max_len);
}
if (strlen($result['entPhysicalModelName'])) {
$model = $result['entPhysicalModelName'];
@ -38,7 +42,7 @@ if (safe_count($results)) {
'name' => $name, 'colour' => $tab_colour,
'icon' => $config['icon']['inventory'],
'data' => array(
escape_html($result['hostname']),
escape_html($device_name),
html_highlight(escape_html($model) . ' | SN: ' . escape_html($result['entPhysicalSerialNum']), $queryString)
)
);

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -48,7 +48,8 @@ if (preg_match('/^(?:(?<both>\d+)|(?<ipv6>[\d\:abcdef]+)|(?<ipv4>[\d\.]+))$/i',
$results = array();
}
if (safe_count($results)) {
if (!safe_empty($results)) {
$max_len = 35;
foreach ($results as $result)
{
$port = get_port_by_id_cache($result['port_id']);
@ -60,18 +61,23 @@ if (safe_count($results)) {
$name = $result['ip_address'].'/'.$result['ip_prefixlen'];
if (strlen($name) > 35) { $name = substr($name, 0, 35) . "..."; }
$device_name = truncate($device['hostname'], $max_len);
if ($device['hostname'] != $device['sysName'] && $device['sysName']) {
$device_name .= ' | ' . truncate($device['sysName'], $max_len);
}
$tab_colour = '#194B7F'; // FIXME: This colour pulled from functions.inc.php humanize_device, maybe set it centrally in definitions?
$view = str_contains($result['ip_address'], '.') ? 'ipv4' : 'ipv6';
$ip_search_results[] = array(
$ip_search_results[] = [
'url' => $port ? generate_port_url($port) : generate_device_url($device, [ 'tab' => 'ports', 'view' => $view ]),
'name' => $name,
'colour' => $tab_colour,
'icon' => $config['icon'][$view],
'data' => array(
'| ' . escape_html($device['hostname']),
escape_html($descr)),
);
'data' => [
'| ' . escape_html($device_name),
escape_html($descr) ],
];
}
@ -79,7 +85,7 @@ if (safe_count($results)) {
// Counter data came from: foreach ($results as $result) {$addr_ports[$result['port_id']][] = $result; }
// echo('<li class="nav-header">IPs found: '.count($results).' (on '.count($addr_ports).' ports)</li>');
$search_results['ip-addresses'] = array('descr' => 'IPs found', 'results' => $ip_search_results);
$search_results['ip-addresses'] = [ 'descr' => 'IPs found', 'results' => $ip_search_results ];
}
// EOF

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -24,8 +24,9 @@ $sql = "SELECT * FROM `neighbours` WHERE `active` = ? AND (`remote_hostname` LIK
$params = [ 1, $query_param, $query_param, $query_param ];
$results = dbFetchRows($sql, $params);
if (safe_count($results)) {
if (!safe_empty($results)) {
$max_len = 35;
$protocol_classmap = [
'cdp' => 'success',
'lldp' => 'warning',
@ -39,12 +40,14 @@ if (safe_count($results)) {
$result_device = device_by_id_cache($result['device_id']);
$result_port = get_port_by_id_cache($result['port_id']);
$name = $result_device['hostname'];
if (strlen($name) > 35) { $name = substr($name, 0, 35) . "..."; }
$name = truncate($result_device['hostname'], $max_len);
if ($result_device['hostname'] != $result_device['sysName'] && $result_device['sysName']) {
$name .= ' | ' . truncate($result_device['sysName'], $max_len);
}
//$num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($result['device_id']));
$remote_host = strlen($result['remote_hostname']) > 35 ? substr($result['remote_hostname'], 0, 35) . "..." : $result['remote_hostname'];
$remote_host = truncate($result['remote_hostname'], $max_len);
$remote_host .= ' | ';
if ($result['remote_address'] && $result['remote_address'] !== '0.0.0.0') {
$remote_host .= $result['remote_address'] . ' | ';
@ -55,7 +58,7 @@ if (safe_count($results)) {
$remote_descr = $result['remote_platform'] . ' | ';
if ($len = strlen($result['remote_version'])) {
if ($len > 35) { $result['remote_version'] = substr($result['remote_version'], 0, 35) . "..."; }
$result['remote_version'] = truncate($result['remote_version'], 35);
$remote_descr .= $result['remote_version'] . ' | ';
}

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -14,8 +14,7 @@
$where = '`ifAlias` LIKE ? OR `port_label` LIKE ?';
$params = [ $query_param, $query_param ];
$by_mac = preg_match('/^[a-f0-9]{2}[a-f0-9\.\-:]{1,15}/i', $queryString);
if ($by_mac) // Check if query string is like mac-address (maximal 17 chars)
{
if ($by_mac) { // Check if query string is like mac-address (maximal 17 chars)
$where .= ' OR `ifPhysAddress` LIKE ?';
$params[] = '%' . str_replace([ '.', '-', ':' ], '', $queryString) . '%';
}
@ -24,33 +23,39 @@ $results = dbFetchRows("SELECT * FROM `ports`
WHERE ($where) $query_permitted_port
ORDER BY `ifDescr` LIMIT $query_limit", $params);
if (safe_count($results)) {
if (!safe_empty($results)) {
$max_len = 35;
foreach ($results as $result) {
humanize_port($result);
//FIXME - messy
$name = truncate($result['port_label'], 35);
$description = strlen($result['ifAlias']) ? truncate($result['ifAlias'], 80) : '';
$name = truncate($result['port_label'], $max_len);
$device_name = truncate($result['hostname'], $max_len);
if ($result['hostname'] != $result['sysName'] && $result['sysName']) {
$device_name .= ' | ' . truncate($result['sysName'], $max_len);
}
$descr = !safe_empty($result['ifAlias']) ? truncate($result['ifAlias'], 80) : '';
$type = rewrite_iftype($result['ifType']);
if (strlen($result['ifPhysAddress'])) {
if (!safe_empty($result['ifPhysAddress'])) {
$mac = ' | ' . html_highlight(format_mac($result['ifPhysAddress']), $queryString);
} else {
$mac = '';
}
$port_search_results[] = array(
$port_search_results[] = [
'url' => generate_port_url($result),
'name' => $name,
'colour' => $result['table_tab_colour'],
'icon' => $config['icon']['port'],
'data' => array(
'' . escape_html($result['hostname']),
$type . $mac . ' | ' . html_highlight(escape_html($description), $queryString)),
);
'data' => [
escape_html($device_name),
$type . $mac . ' | ' . html_highlight(escape_html($descr), $queryString) ],
];
}
$search_results['ports'] = array('descr' => 'Ports found', 'results' => $port_search_results);
}
$search_results['ports'] = [ 'descr' => 'Ports found', 'results' => $port_search_results ];
}
// EOF

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -14,12 +14,17 @@
$results = dbFetchRows("SELECT * FROM `sensors`
LEFT JOIN `devices` USING (`device_id`)
WHERE `sensor_descr` LIKE ? $query_permitted_device
ORDER BY `sensor_descr` LIMIT $query_limit", array($query_param));
ORDER BY `sensor_descr` LIMIT $query_limit", [ $query_param ]);
if (safe_count($results)) {
if (!safe_empty($results)) {
$max_len = 35;
foreach ($results as $result) {
$name = $result['sensor_descr'];
if (strlen($name) > 35) { $name = substr($name, 0, 35) . "..."; }
$name = truncate($result['sensor_descr'], $max_len);
$device_name = truncate($result['hostname'], $max_len);
if ($result['hostname'] != $result['sysName'] && $result['sysName']) {
$device_name .= ' | ' . truncate($result['sysName'], $max_len);
}
$descr = strlen($result['location']) ? escape_html($result['location']) . ' | ' : '';
$descr .= nicecase($result['sensor_class']).' sensor';
@ -30,13 +35,13 @@ if (safe_count($results)) {
'name' => $name,
'colour' => $tab_colour,
'icon' => $config['sensor_types'][$result['sensor_class']]['icon'],
'data' => array(
'| ' . escape_html($result['hostname']),
$descr)
'data' => [
'| ' . escape_html($device_name),
$descr ]
);
}
$search_results['sensors'] = array('descr' => 'Sensors found', 'results' => $sensor_search_results);
$search_results['sensors'] = [ 'descr' => 'Sensors found', 'results' => $sensor_search_results ];
}
// EOF

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -14,26 +14,32 @@
$results = dbFetchRows("SELECT * FROM `slas` LEFT JOIN `devices` USING (`device_id`) WHERE (`sla_target` LIKE ? OR `sla_index` LIKE ? OR `sla_tag` LIKE ?) $query_permitted_device ORDER BY `sla_target` LIMIT $query_limit", array($query_param, $query_param, $query_param));
if (count($results)) {
if (!safe_empty($results)) {
$max_len = 35;
foreach ($results as $result) {
humanize_sla($result);
$device_name = truncate($result['hostname'], $max_len);
if ($result['hostname'] != $result['sysName'] && $result['sysName']) {
$device_name .= ' | ' . truncate($result['sysName'], $max_len);
}
$descr = strlen($result['location']) ? escape_html($result['location']) . ' | ' : '';
$descr .= $result['rtt_label'];
$tab_colour = '#194B7F';
$sla_search_results[] = array('url' => generate_url(array('page' => 'device', 'device' => $result['device_id'], 'tab' => 'slas', 'id' => $result['sla_id'])),
'name' => $result['sla_descr'],
'colour' => $tab_colour,
'icon' => $config['icon']['sla'],
'data' => array(
'| ' . escape_html($result['hostname']),
$descr,
)
);
$sla_search_results[] = [
'url' => generate_url(array('page' => 'device', 'device' => $result['device_id'], 'tab' => 'slas', 'id' => $result['sla_id'])),
'name' => $result['sla_descr'],
'colour' => $tab_colour,
'icon' => $config['icon']['sla'],
'data' => [
'| ' . escape_html($device_name),
$descr,
]
];
}
$search_results['slas'] = array('descr' => 'SLAs found', 'results' => $sla_search_results);
$search_results['slas'] = [ 'descr' => 'SLAs found', 'results' => $sla_search_results ];
}
// EOF

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -16,28 +16,33 @@ $results = dbFetchRows("SELECT * FROM `status`
WHERE `status_descr` LIKE ? $query_permitted_device
ORDER BY `status_descr` LIMIT $query_limit", array($query_param));
if (safe_count($results)) {
if (!safe_empty($results)) {
$max_len = 35;
foreach ($results as $result) {
$name = $result['status_descr'];
if (strlen($name) > 35) { $name = substr($name, 0, 35) . "..."; }
$name = truncate($result['status_descr'], $max_len);
$device_name = truncate($result['hostname'], $max_len);
if ($result['hostname'] != $result['sysName'] && $result['sysName']) {
$device_name .= ' | ' . truncate($result['sysName'], $max_len);
}
$descr = strlen($result['location']) ? escape_html($result['location']) . ' | ' : '';
$descr .= nicecase($result['entPhysicalClass']) . ' status';
/// FIXME: once we have alerting, colour this to the sensor's status
$tab_colour = '#194B7F'; // FIXME: This colour pulled from functions.inc.php humanize_device, maybe set it centrally in definitions?
$status_search_results[] = array('url' => 'graphs/type=status_graph/id=' . $result['status_id'] . '/',
$status_search_results[] = [
'url' => 'graphs/type=status_graph/id=' . $result['status_id'] . '/',
'name' => $name,
'colour' => $tab_colour,
'icon' => $config['icon']['status'],
'data' => array(
'| ' . escape_html($result['hostname']),
$descr)
);
'data' => [
'| ' . escape_html($device_name),
$descr ]
];
}
$search_results['status'] = array('descr' => 'Status Indicators found', 'results' => $status_search_results);
$search_results['status'] = [ 'descr' => 'Status Indicators found', 'results' => $status_search_results ];
}
// EOF