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
*
*/
@ -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