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-2020 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -21,7 +21,7 @@ print_versions();
$ua = detect_browser();
//r($ua);
register_html_resource('js', 'moment.min.js');
$tz = get_timezone();
$tz = get_timezone(TRUE); // Refresh timezone, for get system TZ
//r($tz);
?>
<div class="box box-solid">
@ -33,7 +33,7 @@ $tz = get_timezone();
<tbody>
<tr><td><b>User-Agent</b></td><td><?php echo $ua['user_agent']; ?></td></tr>
<tr><td><b>Browser</b></td><td><?php echo $ua['browser_full'] . ' (' . $ua['platform'] . ')'; ?></td></tr>
<tr><td><b>Screen Resolution</b></td><td><?php echo $ua['screen_resolution']; ?></td></tr>
<tr><td><b>Screen&nbsp;Resolution</b></td><td><?php echo $ua['screen_resolution']; ?></td></tr>
<tr><td><b>Timezone</b></td><td><?php echo $tz['system'] . ' (System), ' . $tz['php'] . ' (PHP), ' . $tz['mysql'] . ' (DB), '; ?><script>document.write(moment().format('Z') + ' (User)');</script></td></tr>
</tbody>
</table>
@ -82,14 +82,12 @@ $tz = get_timezone();
<?php
if (!$_SESSION['user_limited'])
{
if (!$_SESSION['user_limited']) {
$cache_item = get_cache_item('stats');
if (!ishit_cache_item($cache_item))
{
$stats = array();
if (!ishit_cache_item($cache_item)) {
$stats = [];
$stats['devices'] = dbFetchCell('SELECT COUNT(*) FROM `devices`');
$stats['ports'] = dbFetchCell('SELECT COUNT(*) FROM `ports`');
$stats['syslog'] = dbFetchCell('SELECT COUNT(*) FROM `syslog`');
@ -123,7 +121,7 @@ if (!$_SESSION['user_limited'])
$stats['db'] = get_db_size();
$stats['rrd'] = get_dir_size($config['rrd_dir']);
set_cache_item($cache_item, $stats, array('ttl' => 900)); // 15 min
set_cache_item($cache_item, $stats, [ 'ttl' => 900 ]); // 15 min
} else {
$stats = get_cache_data($cache_item);
}

View File

@ -6,11 +6,11 @@
*
* @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
*
*/
if ($_SESSION['userlevel'] < 10) {
if ($_SESSION['userlevel'] < 9) {
print_error_permission("You don't have the necessary privileges to add hosts.");
return;
}
@ -18,14 +18,10 @@ if ($_SESSION['userlevel'] < 10) {
//echo("<h2>Add Device</h2>");
if (get_var_true($vars['submit'], 'save') && $vars['hostname']) {
if (request_token_valid($vars)) {
if ($result = add_device_vars($vars)) {
$device_url = generate_device_url(array('device_id' => $result));
$device_link = '<a href="' . $device_url . '" class="entity-popup" data-eid="' . $result . '" data-etype="device">' . escape_html($vars['hostname']) . '</a>';
print_success("Device added (id = $result): $device_link");
}
if (request_token_valid($vars) && $result = add_device_vars($vars)) {
$device_url = generate_device_url([ 'device_id' => $result ]);
$device_link = '<a href="' . $device_url . '" class="entity-popup" data-eid="' . $result . '" data-etype="device">' . escape_html($vars['hostname']) . '</a>';
print_success("Device added (id = $result): $device_link");
}
} else {
// Defaults
@ -48,7 +44,7 @@ if (get_var_true($vars['submit'], 'save') && $vars['hostname']) {
register_html_title("Add Device");
// Add form
$transports = array();
$transports = [];
foreach ($config['snmp']['transports'] as $transport) {
$transports[$transport] = strtoupper($transport);
}
@ -79,215 +75,242 @@ $cryptoalgo = [
'AES-256-C' => [ 'name' => 'AES-256 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
];
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
//'title' => 'Add Device',
//'icon' => 'oicon-gear',
);
// top row div
$form['fieldset']['edit'] = array('div' => 'top',
'title' => 'Basic Configuration',
'class' => 'col-md-6');
$form['fieldset']['snmpv2'] = array('div' => 'top',
'title' => 'SNMP v1/v2c Authentication',
'class' => 'col-md-6 col-md-pull-0');
$form['fieldset']['snmpv3'] = array('div' => 'top',
'title' => 'SNMP v3 Authentication',
'class' => 'col-md-6 col-md-pull-0');
$form['fieldset']['extra'] = array('div' => 'top',
'title' => 'Extra Configuration',
'class' => 'col-sm-12 col-md-6 pull-right');
$form = [
'type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
//'title' => 'Add Device',
//'icon' => 'oicon-gear',
];
// bottom row div
$form['fieldset']['submit'] = array('div' => 'bottom',
'style' => 'padding: 0px;',
'class' => 'col-md-12');
// top row div
$form['fieldset']['edit'] = [
'div' => 'top',
'title' => 'Basic Configuration',
'class' => 'col-md-6'
];
$form['fieldset']['snmpv2'] = [
'div' => 'top',
'title' => 'SNMP v1/v2c Authentication',
'class' => 'col-md-6 col-md-pull-0'
];
$form['fieldset']['snmpv3'] = [
'div' => 'top',
'title' => 'SNMP v3 Authentication',
'class' => 'col-md-6 col-md-pull-0'
];
$form['fieldset']['extra'] = [
'div' => 'top',
'title' => 'Extra Configuration',
'class' => 'col-sm-12 col-md-6 pull-right'
];
//$form['row'][0]['editing'] = array(
// 'type' => 'hidden',
// 'value' => 'yes');
// left fieldset
$form['row'][0]['hostname'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Hostname',
'width' => '250px',
'value' => $vars['hostname']
);
if (OBS_DISTRIBUTED) {
$poller_list = [];
$poller_list[0] = [ 'name' => 'Default Poller' ];
if ($config['poller_id'] != 0) {
$poller_list[0]['group'] = 'External';
}
foreach(dbFetchRows("SELECT * FROM `pollers`") as $poller) {
$poller_list[$poller['poller_id']] = [
'name' => $poller['poller_name'],
'subtext' => $poller['host_id']
//'subtext' => $poller['host_uname']
];
if ($config['poller_id'] != $poller['poller_id']) {
$poller_list[$poller['poller_id']]['group'] = 'External';
}
}
$form['row'][1]['poller_id'] = array(
'community' => FALSE, // not available on community edition
'type' => 'select',
//'fieldset' => 'extra',
'fieldset' => 'edit',
'name' => 'Poller',
'width' => '250px',
'disabled' => !(count($poller_list) > 1),
'values' => $poller_list,
'value' => isset($vars['poller_id']) ? $vars['poller_id'] : $config['poller_id']
);
}
$form['row'][2]['ping_skip'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'fieldset' => 'edit',
'name' => 'Skip PING',
'placeholder' => 'Skip ICMP echo checks',
'value' => ''
);
$form['row'][3]['snmp_version'] = array(
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'values' => array('v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3'),
'value' => $vars['snmp_version'] ?: $config['snmp']['version']
);
$form['row'][4]['snmp_transport'] = array(
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'values' => $transports,
'value' => $vars['snmp_transport'] ?: $config['snmp']['transports'][0]
);
$form['row'][5]['snmp_port'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Port',
'placeholder' => '1-65535. Default 161.',
'width' => '250px',
'value' => $vars['snmp_port']
);
$form['row'][6]['snmp_timeout'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Timeout',
'placeholder' => '1-120 sec. Default 1 sec.',
'width' => '250px',
'value' => $vars['snmp_timeout']
);
$form['row'][7]['snmp_retries'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Retries',
'placeholder' => '1-10. Default 5.',
'width' => '250px',
'value' => $vars['snmp_retries']
);
$form['row'][8]['snmp_maxrep'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Max Repetitions',
'width' => '250px',
'placeholder' => '0-500. Default 10. 0 for disable snmpbulk.',
'value' => $vars['snmp_maxrep']
);
$form['row'][9]['ignorerrd'] = array(
'type' => 'checkbox',
'fieldset' => 'edit',
'name' => 'Ignore existing RRDs',
'placeholder' => 'Ignore pre-existing RRD directory and files',
'disabled' => $config['rrd_override'],
'value' => $config['rrd_override']
);
// bottom row div
$form['fieldset']['submit'] = [
'div' => 'bottom',
'style' => 'padding: 0px;',
'class' => 'col-md-12'
];
// Snmp v1/2c fieldset
$form['row'][16]['snmp_community'] = array(
'type' => 'text',
'fieldset' => 'snmpv2',
'name' => 'SNMP Community',
'width' => '250px',
'value' => $vars['snmp_community'] // FIXME. For passwords we should use filter instead escape!
);
//$form['row'][0]['editing'] = array(
// 'type' => 'hidden',
// 'value' => 'yes');
// Snmp v3 fieldset
$form['row'][17]['snmp_authlevel'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'values' => array('noAuthNoPriv' => 'noAuthNoPriv',
'authNoPriv' => 'authNoPriv',
'authPriv' => 'authPriv'),
'value' => $vars['snmp_authlevel']
);
$form['row'][18]['snmp_authname'] = array(
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'value' => $vars['snmp_authname']
);
$form['row'][19]['snmp_authpass'] = array(
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Auth Password',
'width' => '250px',
'value' => $vars['snmp_authpass'] // FIXME. For passwords we should use filter instead escape!
);
$form['row'][20]['snmp_authalgo'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'values' => $authalgo,
'value' => $vars['snmp_authalgo']
);
$form['row'][21]['snmp_cryptopass'] = array(
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Crypto Password',
'width' => '250px',
'value' => $vars['snmp_cryptopass'] // FIXME. For passwords we should use filter instead escape!
);
$form['row'][22]['snmp_cryptoalgo'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'values' => $cryptoalgo,
'value' => $vars['snmp_cryptoalgo']);
// left fieldset
$form['row'][0]['hostname'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Hostname',
'width' => '250px',
'value' => $vars['hostname']
];
$form['row'][25]['snmp_context'] = array(
'type' => 'text',
'fieldset' => 'extra',
'name' => 'SNMP Context',
'width' => '250px',
//'show_password' => !$readonly,
'placeholder' => '(Optional) Context',
'value' => $vars['snmp_context'] // FIXME. For passwords we should use filter instead escape!
);
if (OBS_DISTRIBUTED) {
$poller_list = [];
$poller_list[0] = [ 'name' => 'Default Poller' ];
if ($config['poller_id'] != 0) {
$poller_list[0]['group'] = 'External';
}
foreach(dbFetchRows("SELECT * FROM `pollers`") as $poller) {
$poller_list[$poller['poller_id']] = [
'name' => $poller['poller_name'],
'subtext' => $poller['host_id']
//'subtext' => $poller['host_uname']
];
if ($config['poller_id'] != $poller['poller_id']) {
$poller_list[$poller['poller_id']]['group'] = 'External';
}
}
$form['row'][1]['poller_id'] = [
'community' => FALSE, // not available on community edition
'type' => 'select',
//'fieldset' => 'extra',
'fieldset' => 'edit',
'name' => 'Poller',
'width' => '250px',
'disabled' => !(count($poller_list) > 1),
'values' => $poller_list,
'value' => isset($vars['poller_id']) ? $vars['poller_id'] : $config['poller_id']
];
}
$form['row'][30]['submit'] = array(
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Add device',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'save'
);
$form['row'][2]['ping_skip'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'fieldset' => 'edit',
'name' => 'Skip PING',
'placeholder' => 'Skip ICMP echo checks',
'value' => ''
];
$form['row'][3]['snmp_version'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'values' => [ 'v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3' ],
'value' => $vars['snmp_version'] ?: $config['snmp']['version']
];
$form['row'][4]['snmp_transport'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'values' => $transports,
'value' => $vars['snmp_transport'] ?: $config['snmp']['transports'][0]
];
$form['row'][5]['snmp_port'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Port',
'placeholder' => '1-65535. Default 161.',
'width' => '250px',
'value' => $vars['snmp_port']
];
$form['row'][6]['snmp_timeout'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Timeout',
'placeholder' => '1-120 sec. Default 1 sec.',
'width' => '250px',
'value' => $vars['snmp_timeout']
];
$form['row'][7]['snmp_retries'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Retries',
'placeholder' => '1-10. Default 5.',
'width' => '250px',
'value' => $vars['snmp_retries']
];
$form['row'][8]['snmp_maxrep'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Max Repetitions',
'width' => '250px',
'placeholder' => '0-500. Default 10. 0 for disable snmpbulk.',
'value' => $vars['snmp_maxrep']
];
$form['row'][9]['ignorerrd'] = [
'type' => 'checkbox',
'fieldset' => 'edit',
'name' => 'Ignore existing RRDs',
'placeholder' => 'Ignore pre-existing RRD directory and files',
'disabled' => $config['rrd_override'],
'value' => $config['rrd_override']
];
print_form_box($form);
unset($form);
// Snmp v1/2c fieldset
$form['row'][16]['snmp_community'] = [
'type' => 'text',
'fieldset' => 'snmpv2',
'name' => 'SNMP Community',
'width' => '250px',
'value' => $vars['snmp_community'] // FIXME. For passwords we should use filter instead escape!
];
// Snmp v3 fieldset
$form['row'][17]['snmp_authlevel'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'values' => [
'noAuthNoPriv' => 'noAuthNoPriv',
'authNoPriv' => 'authNoPriv',
'authPriv' => 'authPriv'
],
'value' => $vars['snmp_authlevel']
];
$form['row'][18]['snmp_authname'] = [
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'value' => $vars['snmp_authname']
];
$form['row'][19]['snmp_authpass'] = [
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Auth Password',
'width' => '250px',
'value' => $vars['snmp_authpass'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][20]['snmp_authalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'values' => $authalgo,
'value' => $vars['snmp_authalgo']
];
$form['row'][21]['snmp_cryptopass'] = [
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Crypto Password',
'width' => '250px',
'value' => $vars['snmp_cryptopass'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][22]['snmp_cryptoalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'values' => $cryptoalgo,
'value' => $vars['snmp_cryptoalgo']
];
$form['row'][24]['snmpable'] = [
'type' => 'text',
'fieldset' => 'extra',
'name' => 'SNMPable OIDs',
'width' => '250px',
//'show_password' => !$readonly,
'placeholder' => '(Optional) Numeric OIDs for check device availability',
'value' => $vars['snmpable']
];
$form['row'][25]['snmp_context'] = [
'type' => 'text',
'fieldset' => 'extra',
'name' => 'SNMP Context',
'width' => '250px',
//'show_password' => !$readonly,
'placeholder' => '(Optional) Context',
'value' => $vars['snmp_context'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][30]['submit'] = [
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Add device',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'save'
];
print_form_box($form);
unset($form);
?>

View File

@ -6,12 +6,11 @@
*
* @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
*
*/
if ($_SESSION['userlevel'] < 5)
{
if ($_SESSION['userlevel'] < 5) {
print_error_permission();
return;
}
@ -22,7 +21,10 @@ include($config['html_dir']."/includes/alerting-navbar.inc.php");
// Begin Actions
$readonly = $_SESSION['userlevel'] < 10; // Currently edit allowed only for Admins
$check = dbFetchRow("SELECT * FROM `alert_tests` WHERE `alert_test_id` = ?", array($vars['alert_test_id']));
if (!$check = dbFetchRow("SELECT * FROM `alert_tests` WHERE `alert_test_id` = ?", [ $vars['alert_test_id'] ])) {
print_error_permission();
return;
}
// Hardcode Device sysContact
if (!dbExist('alert_contacts', '`contact_method` = ?', [ 'syscontact' ])) {
@ -40,11 +42,9 @@ if (!dbExist('alert_contacts', '`contact_method` = ?', [ 'syscontact' ])) {
// FIXME: move all actions to separate include(s) with common options!
//if (!$readonly && isset($vars['action']))
if (!$readonly && $vars['action'])
{
if (!$readonly && $vars['action'] && request_token_valid($vars)) {
// We are editing. Lets see what we are editing.
if ($vars['action'] === "check_conditions")
{
if ($vars['action'] === "check_conditions") {
$conds = array(); $cond_array = array();
foreach (explode("\n", trim($vars['check_conditions'])) as $cond)
{
@ -53,11 +53,8 @@ if (!$readonly && $vars['action'])
}
$conds = json_encode($conds);
$rows_updated = dbUpdate(array('conditions' => $conds, 'and' => $vars['alert_and']), 'alert_tests', '`alert_test_id` = ?', array($vars['alert_test_id']));
}
elseif ($vars['action'] === "alert_details")
{
if ($entry = dbFetchRow('SELECT * FROM `alert_tests` WHERE `alert_test_id` = ?', array($vars['alert_test_id'])))
{
} elseif ($vars['action'] === "alert_details") {
if ($entry = dbFetchRow('SELECT * FROM `alert_tests` WHERE `alert_test_id` = ?', [ $vars['alert_test_id'] ])) {
//print_vars($entry);
$update_array = [
'alert_name' => $vars['alert_name'],
@ -273,10 +270,11 @@ humanize_alert_check($check);
</td>
<td><i>' . $check['status_numbers'] . '</i><br />';
if (count($contacts))
{
if (safe_count($contacts)) {
$content = "";
foreach($contacts as $contact) { $content .= '<span class="label">'.$contact['contact_method'].'</span> '.$contact['contact_descr'].'<br />'; }
foreach($contacts as $contact) {
$content .= '<span class="label">'.$contact['contact_method'].'</span> '.escape_html($contact['contact_descr']).'<br />';
}
echo generate_tooltip_link('', '<span class="label label-success">'.count($contacts).' Notifiers</span>', $content);
} else {
echo '<span class="label label-primary">Default Notifier</span>';
@ -1241,13 +1239,13 @@ echo generate_box_close(array('footer_content' => $footer_content));
// confirmation dialog
'attribs' => array('data-toggle' => 'confirmation', // Enable confirmation dialog
'data-confirm-placement' => 'left',
'data-confirm-content' => 'Delete contact \''.$contact['contact_descr'].'\'?'),
'data-confirm-content' => 'Delete contact \''.escape_html($contact['contact_descr']).'\'?'),
'value' => 'delete_alert_checker_contact');
echo '
<tr>
<td><span class="label">'.$contact['contact_method'].'</span></td>
<td>' . $contact['contact_descr'] . '</td>
<td>' . escape_html($contact['contact_descr']) . '</td>
<td>' . generate_form($form) . '</td>
</tr>';
unset($form);

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -205,8 +205,7 @@ foreach ($alert_check as $check)
echo('<td>');
if(!is_null($check['alert_assoc']))
{
if (!is_null($check['alert_assoc'])) {
$check['assoc'] = safe_json_decode($check['alert_assoc']);
echo render_qb_rules($check['entity_type'], $check['assoc']);
@ -274,10 +273,11 @@ foreach ($alert_check as $check)
echo '<br />';
if ($notifiers_count = safe_count($contacts[$check['alert_test_id']]))
{
if ($notifiers_count = safe_count($contacts[$check['alert_test_id']])) {
$content = "";
foreach($contacts[$check['alert_test_id']] as $contact) { $content .= '<span class="label">'.$contact['contact_method'].'</span> '.$contact['contact_descr'].'<br />'; }
foreach($contacts[$check['alert_test_id']] as $contact) {
$content .= '<span class="label">'.$contact['contact_method'].'</span> '.escape_html($contact['contact_descr']).'<br />';
}
echo generate_tooltip_link('', '<span class="label label-success">'.$notifiers_count.' Notifiers</span>', $content);
} else {
echo '<span class="label label-primary">Default Notifier</span>';

View File

@ -1,13 +1,12 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -47,7 +46,7 @@ $form['row'][0]['device_id'] = array(
// Add device_id limit for other fields
if (isset($vars['device_id']))
{
$where .= generate_query_values($vars['device_id'], 'device_id');
$where .= generate_query_values_and($vars['device_id'], 'device_id');
}
// Checkers Field

View File

@ -1,42 +1,40 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
/// FIXME. Unused anymore?
// Global write permissions required.
if ($_SESSION['userlevel'] < 10)
{
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
}
include($config['html_dir']."/includes/alerting-navbar.inc.php");
// Regenerate alerts
// Regenerate alerts
echo generate_box_open();
echo generate_box_open();
$checkers = cache_alert_rules();
$assocs = cache_alert_assoc();
foreach($assocs as $assoc)
{
$checkers[$assoc['alert_test_id']]['assocs'][] = $assoc;
foreach($assocs as $assoc) {
$checkers[$assoc['alert_test_id']]['assocs'][] = $assoc;
}
foreach($checkers as $alert)
{
foreach ($checkers as $alert) {
echo '<h3>Updating Alert <b>' . $alert['alert_name'] . '</b></h3>';
echo '<h3>Updating Alert <b>' . escape_html($alert['alert_name']) . '</b></h3>';
echo '<br />';
//r($alert);

View File

@ -1,13 +1,12 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -21,7 +20,7 @@ $graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
$graph_array['legend'] = "no";
foreach (dbFetchRows("SELECT * FROM `applications` WHERE 1 ".generate_query_values(array_keys($app_types), 'app_type').$GLOBALS['cache']['where']['devices_permitted'].' ORDER BY `app_type`;') as $app)
foreach (dbFetchRows("SELECT * FROM `applications` WHERE 1 ".generate_query_values_and(array_keys((array)$app_types), 'app_type').$GLOBALS['cache']['where']['devices_permitted'].' ORDER BY `app_type`;') as $app)
{
if (isset($cache['devices']['id'][$app['device_id']]))
{

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
*
*/
@ -144,7 +144,7 @@ if (count($contacts)) {
$form = array('type' => 'horizontal',
'userlevel' => 10, // Minimum user level for display form
'id' => 'modal-contact_delete_'.$contact['contact_id'],
'title' => 'Delete Contact "' . $contact['contact_descr'] .
'title' => 'Delete Contact "' . escape_html($contact['contact_descr']) .
'" (Id: '. $contact['contact_id'] . ', ' . $config['transports'][$contact['contact_method']]['name'] . ')',
//'modal_args' => $modal_args, // modal specific options
//'help' => 'This will delete the selected contact and any alert assocations.',

View File

@ -83,10 +83,19 @@ echo generate_box_open();
</thead>
<?php
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`") as $customer) {
$customer_name = $customer['port_descr_descr'];
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ?", array($customer['port_descr_descr'])) as $port) {
$customers = [];
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' ORDER BY `port_descr_descr`") as $customer) {
$customers[$customer['port_descr_descr']][] = $customer;
}
foreach($customers as $customer => $ports) {
$customer_name = $customer; // Set text name to use on first port.
foreach ($ports as $port) {
$device = device_by_id_cache($port['device_id']);
unset($class);
@ -122,7 +131,7 @@ foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GRO
$graph_array['type'] = "customer_bits";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = '"' . $customer['port_descr_descr'] . '"'; // use double quotes for prevent split var by commas
$graph_array['id'] = '"' . $port['port_descr_descr'] . '"'; // use double quotes for prevent split var by commas
print_graph_row($graph_array);

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -21,8 +21,8 @@ register_html_resource('js', 'gridstack.all.js');
register_html_resource('js', 'leaflet.js');
// IE (pre Edge) js fetch fix
$ua = detect_browser();
if ($ua['browser'] == 'MSIE' ||
($ua['browser'] == 'Firefox' && version_compare($ua['version'], '61', '<'))) // Also for FF ESR60 and older
if ($ua['browser'] === 'MSIE' ||
($ua['browser'] === 'Firefox' && version_compare($ua['version'], '61', '<'))) // Also for FF ESR60 and older
{
register_html_resource('js', 'js/compat/bluebird.min.js');
register_html_resource('js', 'js/compat/fetch.js');
@ -331,7 +331,7 @@ if (is_array($dashboard))
refreshAllUpdatableImages = function () {
// Add or replace nocache parameter on image src and then rewrite the image.
var pt = /\&nocache=.+/;
var pt = /\&nocache=\d+/;
$('.image-refresh').each(function () {
if (this.src) {
@ -642,9 +642,14 @@ if (is_array($dashboard))
<?php
if ($_SESSION['userlevel'] > 7)
{
if(isset($vars['edit'])) { $url = generate_url($vars, array('edit' => NULL)); $text = "Enable Editing Mode"; } else { $url = generate_url($vars, array('edit' => 'yes')); $text = "Disable Editing Mode"; }
if ($_SESSION['userlevel'] > 7) {
if (isset($vars['edit'])) {
$url = generate_url($vars, array('edit' => NULL));
$text = "Enable Editing Mode";
} else {
$url = generate_url($vars, array('edit' => 'yes'));
$text = "Disable Editing Mode";
}
$footer_entry = '<li><a href="' .$url. '"><i class="sprite-sliders"></i></a></li>';
$footer_entries[] = $footer_entry;
@ -652,9 +657,7 @@ if (is_array($dashboard))
}
else
{
} else {
print_error('Dashboard does not exist!');
}

View File

@ -6,19 +6,20 @@
*
* @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
*
*/
// Global write permissions required.
/* Global write permissions required.
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
}
*/
register_html_title("Delete devices");
if (is_intnum($vars['id'])) {
if (is_intnum($vars['id']) && is_entity_write_permitted($vars['id'], 'device')) {
$device = device_by_id_cache($vars['id']);
if ($device && get_var_true($vars['confirm'], 'confirm')) {
@ -60,7 +61,7 @@ if (is_intnum($vars['id'])) {
print_form($form);
unset($form);
}
} else {
} elseif ($_SESSION['userlevel'] > 9) {
$form_items['devices'] = generate_form_values('device', NULL, NULL, array('disabled' => TRUE));
@ -100,6 +101,8 @@ if (is_intnum($vars['id'])) {
print_form($form);
unset($form, $form_items);
} else {
print_error_permission();
}
// 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
*
*/
@ -530,11 +530,16 @@ if (isset($cache['devices']['id'][$vars['device']]) || safe_count($permit_tabs))
}
// Print the inventory tab if inventory is enabled and either entphysical or hrdevice tables have entries
//if (dbFetchCell('SELECT COUNT(*) FROM `entPhysical` WHERE `device_id` = ?', array($device['device_id'])) > 0)
if (dbExist('entPhysical', '`device_id` = ? AND `deleted` IS NULL', [ $device['device_id'] ])) {
$navbar['options']['entphysical'] = array('text' => 'Inventory', 'icon' => $config['icon']['inventory']);
} elseif (dbExist('hrDevice', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['hrdevice'] = array('text' => 'Inventory', 'icon' => $config['icon']['inventory']);
$navbar['options']['entphysical'] = [ 'text' => 'Inventory', 'icon' => $config['icon']['inventory'] ];
if ($device['os_group'] === 'unix' && is_device_mib($device, 'HOST-RESOURCES-MIB') &&
dbExist('hrDevice', '`device_id` = ?', [ $device['device_id'] ])) {
// Some unix OS can have both inventory tables, ie VMWare
$navbar['options']['hrdevice'] = [ 'text' => 'Resources', 'icon' => $config['icon']['inventory'] ];
}
} elseif (is_device_mib($device, 'HOST-RESOURCES-MIB') && dbExist('hrDevice', '`device_id` = ?', [ $device['device_id'] ])) {
$navbar['options']['hrdevice'] = [ 'text' => 'Resources', 'icon' => $config['icon']['inventory'] ];
}
if (isset($attribs['ps_list'])) {
@ -632,7 +637,7 @@ if (isset($cache['devices']['id'][$vars['device']]) || safe_count($permit_tabs))
$navbar['options']['tools']['suboptions']['connect'] = array('text' => 'Connect', 'icon' => 'sprite-config', 'url' => '#');
$navbar['options']['tools']['suboptions']['connect']['entries'] = $connect_entries;
$navbar['options']['tools']['suboptions']['divider_2'] = array('divider' => TRUE);
$navbar['options']['tools']['suboptions']['delete']['url'] = "#modal-delete_device";
$navbar['options']['tools']['suboptions']['delete']['text'] = 'Delete Device';
$navbar['options']['tools']['suboptions']['delete']['link_opts'] = 'data-toggle="modal"';

View File

@ -6,18 +6,17 @@
*
* @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
*
*/
if ($_SESSION['userlevel'] < 7 && !is_entity_write_permitted($device['device_id'], 'device'))
{
if ($_SESSION['userlevel'] < 7 && !is_entity_write_permitted($device['device_id'], 'device')) {
print_error_permission();
return;
}
// User level 7-9 only can see config
$readonly = $_SESSION['userlevel'] < 10;
//$readonly = $_SESSION['userlevel'] < 10;
// Allow write for users with write permission to this entity
$readonly = !is_entity_write_permitted($device['device_id'], 'device');

View File

@ -6,36 +6,26 @@
*
* @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
*
*/
if ($vars['editing'])
{
if ($readonly)
{
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
}
else if (get_db_version() < 169)
{
// FIXME. Remove this block in r7000
print_warning("DB scheme is old, must update first. Device Geolocation not changed.");
} else {
$updated = 0;
if ($vars['submit'] === 'save')
{
if ($vars['submit'] === 'save') {
if (get_var_true($vars['reset_geolocation'])) {
$updated = dbDelete('devices_locations', '`device_id` = ?', array($device['device_id']));
$updated = dbDelete('devices_locations', '`device_id` = ?', [ $device['device_id'] ]);
} elseif ((bool)$vars['location_manual']) {
// Set manual coordinates if present
$pattern = '/(?:^|[\[(])\s*(?<lat>[+-]?\d+(?:\.\d+)*)\s*[,; ]\s*(?<lon>[+-]?\d+(?:\.\d+)*)\s*(?:[\])]|$)/';
if (preg_match($pattern, $vars['coordinates'], $matches))
{
if (preg_match($pattern, $vars['coordinates'], $matches)) {
//r($matches);
if ($matches['lat'] >= -90 && $matches['lat'] <= 90 &&
$matches['lon'] >= -180 && $matches['lon'] <= 180)
{
$matches['lon'] >= -180 && $matches['lon'] <= 180) {
$update_geo['location_lat'] = $matches['lat'];
$update_geo['location_lon'] = $matches['lon'];
$update_geo['location_country'] = '';
@ -47,29 +37,28 @@ if ($vars['editing'])
//r($vars);
}
if ((bool)$device['location_manual'] && !(bool)$vars['location_manual'])
{
if ((bool)$device['location_manual'] && !(bool)$vars['location_manual']) {
// Reset manual flag, rediscover geo info
$update_geo['location_lat'] = array('NULL');
$update_geo['location_lon'] = array('NULL');
$update_geo['location_lat'] = [ 'NULL' ];
$update_geo['location_lon'] = [ 'NULL' ];
$update_geo['location_manual'] = 0;
$updated++;
}
if ($updated)
{
if ($updated) {
//r($update_geo);
dbUpdate($update_geo, 'devices_locations', '`location_id` = ?', array($device['location_id']));
$geo_db = dbFetchRow("SELECT * FROM `devices_locations` WHERE `device_id` = ?", array($device['device_id']));
if (count($geo_db))
{
if (!safe_empty($update_geo)) {
dbUpdate($update_geo, 'devices_locations', '`location_id` = ?', [ $device['location_id'] ]);
}
$geo_db = dbFetchRow("SELECT * FROM `devices_locations` WHERE `device_id` = ?", [ $device['device_id'] ]);
if (safe_count($geo_db)) {
if (get_var_true($vars['reset_geolocation'])) {
print_warning("Device Geo location dropped. Country/city will be updated on next poll.");
} else {
print_success("Device Geolocation updated. Country/city will be updated on next poll.");
}
}
$device = array_merge($device, $geo_db);
$device = array_merge($device, (array)$geo_db);
unset($updated, $update_geo, $geo_db);
} else {
print_warning("Some input data wrong. Device Geolocation not changed.");
@ -78,37 +67,32 @@ if ($vars['editing'])
}
}
$location = array('location_text' => $device['location']);
$location = [ 'location_text' => $device['location'] ];
$override_sysLocation_bool = get_dev_attrib($device,'override_sysLocation_bool');
if ($override_sysLocation_bool)
{
if ($override_sysLocation_bool) {
$override_sysLocation_string = get_dev_attrib($device,'override_sysLocation_string');
if ($override_sysLocation_string != $device['location'])
{
// Device not polled since location overrided
if ($override_sysLocation_string != $device['location']) {
// Device not polled since location override
$location['location_help'] = 'NOTE, device not polled since location overridden, Geolocation is old.';
$location['location_text'] = $override_sysLocation_string;
}
}
if ($location['location_text'] == '') { $location['location_text'] = OBS_VAR_UNSET; }
foreach (array('location_lat', 'location_lon', 'location_city', 'location_county', 'location_state', 'location_country',
'location_geoapi', 'location_status', 'location_manual', 'location_updated') as $param)
{
if (safe_empty($location['location_text'])) { $location['location_text'] = OBS_VAR_UNSET; }
foreach ([ 'location_lat', 'location_lon', 'location_city', 'location_county', 'location_state', 'location_country',
'location_geoapi', 'location_status', 'location_manual', 'location_updated' ] as $param) {
$location[$param] = $device[$param];
}
if (is_numeric($location['location_lat']) && is_numeric($location['location_lon']))
{
if (is_numeric($location['location_lat']) && is_numeric($location['location_lon'])) {
// Generate link to Google maps
// http://maps.google.com/maps?q=46.090271,6.657248+description+(name)
$location['coordinates'] = $location['location_lat'].','.$location['location_lon'];
$location['coordinates_manual'] = $location['coordinates'];
$location['location_link'] = '<a target="_blank" href="http://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="'.$config['icon']['map'].'"></i> View this location on a map</a>';
$location['location_link'] = '<a target="_blank" href="https://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="'.$config['icon']['map'].'"></i> View this location on a map</a>';
$location['location_geo'] = country_from_code($location['location_country']).' (Country), '.$location['location_state'].' (State), ';
$location['location_geo'] .= $location['location_county'] .' (County), ' .$location['location_city'] .' (City)';
switch ($location['location_geoapi'])
{
switch ($location['location_geoapi']) {
//case 'yandex':
// // Generate link to Yandex maps
// $location['location_link'] = '<a target="_blank" href="http://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="oicon-map"></i> View this location on a map</a>';
@ -122,8 +106,7 @@ if (is_numeric($location['location_lat']) && is_numeric($location['location_lon'
$location['coordinates_manual'] = $config['geocoding']['default']['lat'].','.$config['geocoding']['default']['lon'];
}
if ($updated && $update_message)
{
if ($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);

View File

@ -225,8 +225,7 @@ foreach ($snmp_errors as $mib => $entries)
}
$text_class = (count(explode(' ', $error_db['oid'])) > 3 ? '' : 'text-nowrap');
echo('<tr width="100%" class="'.$error_class2.'"><td style="width: 50%;" class="'.$text_class.'"><strong><i class="glyphicon glyphicon-exclamation-sign"></i>&nbsp;'.$error_db['oid'].'</strong></td>' . PHP_EOL);
$timediff = $GLOBALS['config']['time']['now'] - $error_db['updated'];
echo('<td style="width: 100px; white-space: nowrap; text-align: right;">'.generate_tooltip_link('', format_uptime($timediff, "short-3").' ago', format_unixtime($error_db['updated'])).'</td>' . PHP_EOL);
echo('<td style="width: 100px; white-space: nowrap; text-align: right;">'.generate_tooltip_time($error_db['updated'], 'ago').'</td>' . PHP_EOL);
echo('<td style="width: 80px; white-space: nowrap;"><span class="text-'.$error_class.'">'.$error_codes[$error_db['error_code']]['reason'].'</span></td>' . PHP_EOL);
echo('<td style="width: 40px; text-align: right;"><span class="label">'.$error_db['error_count'].'</span></td>' . PHP_EOL);
echo('<td style="width: 80px; text-align: right;"><span class="label">'.round($error_db['error_rate'], 2).'/poll</span></td>' . PHP_EOL);

View File

@ -6,16 +6,16 @@
*
* @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
*
*/
$ok = FALSE;
if ($vars['editing']) {
if (get_var_true($vars['editing']) && request_token_valid($vars)) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$update = array();
$update = [];
switch ($vars['snmp_version']) {
case 'v3':
switch ($vars['snmp_authlevel']) {
@ -55,9 +55,34 @@ if ($vars['editing']) {
}
break;
}
if ($ok && $snmpable = trim($vars['snmpable'])) {
$snmp_oids = [];
foreach (explode(' ', $snmpable) as $oid) {
if (preg_match(OBS_PATTERN_SNMP_OID_NUM, $oid)) {
$snmp_oids[] = $oid;
$oid_num = $oid;
} elseif (str_contains($oid, '::') && $oid_num = snmp_translate($oid)) {
// Named MIB::Oid which we can translate
$snmp_oids[] = $oid_num;
} else {
print_warning("Invalid or unknown OID: ".$oid);
break;
}
$data = snmp_get_oid($device, $oid_num);
if (!snmp_status()) {
print_warning("Device currently not respond by OID $oid!");
}
}
if (empty($snmp_oids)) {
$ok = FALSE;
$error = 'Incorrect or not numeric OIDs passed for check device availability';
}
}
if ($ok) {
$update['snmp_version'] = $vars['snmp_version'];
if (in_array($vars['snmp_transport'], $config['snmp']['transports'])) {
if (in_array($vars['snmp_transport'], $config['snmp']['transports'], TRUE)) {
$update['snmp_transport'] = $vars['snmp_transport'];
} else {
$update['snmp_transport'] = 'udp';
@ -72,13 +97,13 @@ if ($vars['editing']) {
$update['snmp_timeout'] = (int)$vars['snmp_timeout'];
} else {
if (strlen($vars['snmp_timeout'])) { print_warning('Passed incorrect SNMP timeout ('.$vars['snmp_timeout'].'). Should be between 1 and 120 sec.'); }
$update['snmp_timeout'] = array('NULL');
$update['snmp_timeout'] = [ 'NULL' ];
}
if (is_valid_param($vars['snmp_retries'], 'snmp_retries')) {
$update['snmp_retries'] = (int)$vars['snmp_retries'];
} else {
if (strlen($vars['snmp_retries'])) { print_warning('Passed incorrect SNMP retries ('.$vars['snmp_retries'].'). Should be between 1 and 10.'); }
$update['snmp_retries'] = array('NULL');
$update['snmp_retries'] = [ 'NULL' ];
}
// SNMPbulk max repetitions, allow 0 for disable snmpbulk(walk|get)
@ -89,13 +114,21 @@ if ($vars['editing']) {
$update['snmp_maxrep'] = [ 'NULL' ];
}
if ($snmpable) {
if ($device['snmpable'] !== $snmpable) {
$update['snmpable'] = $snmpable;
}
} elseif (!empty($device['snmpable'])) {
$update['snmpable'] = [ 'NULL' ];
}
if (strlen(trim($vars['snmp_context']))) {
$update['snmp_context'] = trim($vars['snmp_context']);
} else {
$update['snmp_context'] = [ 'NULL' ];
}
if (dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id']))) {
if (dbUpdate($update, 'devices', '`device_id` = ?', [ $device['device_id'] ])) {
print_success("Device SNMP configuration updated");
log_event('Device SNMP configuration changed.', $device['device_id'], 'device', $device['device_id'], 5);
} else {
@ -115,7 +148,7 @@ if ($vars['editing']) {
}
$device = device_by_id_cache($device['device_id'], $ok);
$transports = array();
$transports = [];
foreach ($config['snmp']['transports'] as $transport) {
$transports[$transport] = strtoupper($transport);
}
@ -146,172 +179,207 @@ $cryptoalgo = [
'AES-256-C' => [ 'name' => 'AES-256 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
];
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
//'title' => 'General',
//'class' => 'box',
);
$form = [
'type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
//'title' => 'General',
//'class' => 'box',
];
// top row div
$form['fieldset']['edit'] = array('div' => 'top',
'title' => 'Basic Configuration',
'class' => 'col-md-6');
$form['fieldset']['snmpv2'] = array('div' => 'top',
'title' => 'SNMP v1/v2c Authentication',
//'right' => TRUE,
'class' => 'col-md-6 col-md-pull-0');
$form['fieldset']['snmpv3'] = array('div' => 'top',
'title' => 'SNMP v3 Authentication',
//'right' => TRUE,
'class' => 'col-md-6 col-md-pull-0');
$form['fieldset']['snmpextra'] = array('div' => 'top',
'title' => 'Extra Configuration',
//'right' => TRUE,
'class' => 'col-sm-12 col-md-6 pull-right');
$form['fieldset']['edit'] = [
'div' => 'top',
'title' => 'Basic Configuration',
'class' => 'col-md-6'
];
$form['fieldset']['snmpv2'] = [
'div' => 'top',
'title' => 'SNMP v1/v2c Authentication',
//'right' => TRUE,
'class' => 'col-md-6 col-md-pull-0'
];
$form['fieldset']['snmpv3'] = [
'div' => 'top',
'title' => 'SNMP v3 Authentication',
//'right' => TRUE,
'class' => 'col-md-6 col-md-pull-0'
];
$form['fieldset']['snmpextra'] = [
'div' => 'top',
'title' => 'Extra Configuration',
//'right' => TRUE,
'class' => 'col-sm-12 col-md-6 pull-right'
];
// bottom row div
$form['fieldset']['submit'] = array('div' => 'bottom',
'style' => 'padding: 0px;',
'class' => 'col-md-12');
$form['fieldset']['submit'] = [
'div' => 'bottom',
'style' => 'padding: 0px;',
'class' => 'col-md-12'
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
];
// left fieldset
$form['row'][1]['snmp_version'] = array(
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'readonly' => $readonly,
'values' => array('v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3'),
'value' => $device['snmp_version']);
$form['row'][2]['snmp_transport'] = array(
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'readonly' => $readonly,
'values' => $transports,
'value' => $device['snmp_transport']);
$form['row'][3]['snmp_port'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Port',
'width' => '250px',
'placeholder' => '1-65535. Default 161.',
'readonly' => $readonly,
'value' => $device['snmp_port']);
$form['row'][4]['snmp_timeout'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Timeout',
'width' => '250px',
'placeholder' => '1-120 sec. Default 1 sec.',
'readonly' => $readonly,
'value' => $device['snmp_timeout']);
$form['row'][5]['snmp_retries'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Retries',
'width' => '250px',
'placeholder' => '1-10. Default 5.',
'readonly' => $readonly,
'value' => $device['snmp_retries']);
$form['row'][1]['snmp_version'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'readonly' => $readonly,
'values' => [ 'v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3' ],
'value' => $device['snmp_version']
];
$form['row'][2]['snmp_transport'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'readonly' => $readonly,
'values' => $transports,
'value' => $device['snmp_transport']
];
$form['row'][3]['snmp_port'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Port',
'width' => '250px',
'placeholder' => '1-65535. Default 161.',
'readonly' => $readonly,
'value' => $device['snmp_port']
];
$form['row'][4]['snmp_timeout'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Timeout',
'width' => '250px',
'placeholder' => '1-120 sec. Default 1 sec.',
'readonly' => $readonly,
'value' => $device['snmp_timeout']
];
$form['row'][5]['snmp_retries'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Retries',
'width' => '250px',
'placeholder' => '1-10. Default 5.',
'readonly' => $readonly,
'value' => $device['snmp_retries']
];
$form['row'][6]['snmp_maxrep'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Max Repetitions',
'width' => '250px',
'placeholder' => '0-500. Default 10. 0 for disable snmpbulk.',
'readonly' => $readonly,
'value' => $device['snmp_maxrep']
];
$form['row'][6]['snmp_maxrep'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Max Repetitions',
'width' => '250px',
'placeholder' => '0-500. Default 10. 0 for disable snmpbulk.',
'readonly' => $readonly,
'value' => $device['snmp_maxrep']);
// Snmp v1/2c fieldset
$form['row'][7]['snmp_community'] = array(
'type' => 'password',
'fieldset' => 'snmpv2',
'name' => 'SNMP Community',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_community']); // FIXME. For passwords we should use filter instead escape!
$form['row'][7]['snmp_community'] = [
'type' => 'password',
'fieldset' => 'snmpv2',
'name' => 'SNMP Community',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_community'] // FIXME. For passwords we should use filter instead escape!
];
// Snmp v3 fieldset
$form['row'][8]['snmp_authlevel'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'readonly' => $readonly,
'values' => array('noAuthNoPriv' => 'noAuthNoPriv',
'authNoPriv' => 'authNoPriv',
'authPriv' => 'authPriv'),
'value' => $device['snmp_authlevel']);
$form['row'][8]['snmp_authlevel'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'readonly' => $readonly,
'values' => [
'noAuthNoPriv' => 'noAuthNoPriv',
'authNoPriv' => 'authNoPriv',
'authPriv' => 'authPriv'
],
'value' => $device['snmp_authlevel']
];
$form['row'][9]['snmp_authname'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_authname']
];
$form['row'][10]['snmp_authpass'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_authpass'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][11]['snmp_authalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $authalgo,
'value' => $device['snmp_authalgo']
];
$form['row'][12]['snmp_cryptopass'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Crypto Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_cryptopass'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][13]['snmp_cryptoalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $cryptoalgo,
'value' => $device['snmp_cryptoalgo']
];
$form['row'][9]['snmp_authname'] = array(
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_authname']);
// Extra fields
$form['row'][14]['snmpable'] = [
'type' => 'text',
'fieldset' => 'snmpextra',
'name' => 'SNMPable OIDs',
'width' => '250px',
'readonly' => $readonly,
'placeholder' => '(Optional) Numeric OIDs for check device availability',
'value' => $device['snmpable']
];
$form['row'][15]['snmp_context'] = [
'type' => 'password',
'fieldset' => 'snmpextra',
'name' => 'SNMP Context',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'placeholder' => '(Optional) Context',
'value' => $device['snmp_context'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][10]['snmp_authpass'] = array(
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_authpass']); // FIXME. For passwords we should use filter instead escape!
$form['row'][11]['snmp_authalgo'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $authalgo,
'value' => $device['snmp_authalgo']);
$form['row'][12]['snmp_cryptopass'] = array(
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Crypto Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_cryptopass']); // FIXME. For passwords we should use filter instead escape!
$form['row'][13]['snmp_cryptoalgo'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $cryptoalgo,
'value' => $device['snmp_cryptoalgo']);
$form['row'][15]['snmp_context'] = array(
'type' => 'password',
'fieldset' => 'snmpextra',
'name' => 'SNMP Context',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'placeholder' => '(Optional) Context',
'value' => $device['snmp_context']); // FIXME. For passwords we should use filter instead escape!
$form['row'][20]['submit'] = array(
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form['row'][20]['submit'] = [
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
];
print_form_box($form);
unset($form);

View File

@ -1,16 +1,16 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$datas = array('overview' => array('icon' => $config['icon']['overview']));
$datas = [ 'overview' => [ 'icon' => $config['icon']['overview'] ] ];
if ($health_exist['processors']) { $datas['processor'] = array('icon' => $config['entities']['processor']['icon']); }
if ($health_exist['mempools']) { $datas['mempool'] = array('icon' => $config['entities']['mempool']['icon']); }
@ -19,13 +19,18 @@ if ($health_exist['diskio']) { $datas['diskio'] = array('icon' => $config
if ($health_exist['status']) { $datas['status'] = array('icon' => $config['entities']['status']['icon']); }
if ($health_exist['sensors'])
{
$sensors_device = dbFetchRows("SELECT DISTINCT `sensor_class` FROM `sensors` WHERE `device_id` = ? AND `sensor_deleted` = ?", array($device['device_id'], 0));
foreach ($sensors_device as $sensor)
{
if ($sensor['sensor_class'] == 'counter') { continue; } // DEVEL
$datas[$sensor['sensor_class']] = array('icon' => $config['sensor_types'][$sensor['sensor_class']]['icon']);
if ($health_exist['sensors']) {
// Keep sensors order for base types static
$sensor_types = [ 'temperature', 'humidity', 'fanspeed', 'airflow', 'current', 'voltage', 'power', 'apower', 'rpower', 'frequency' ];
$other_types = array_diff(array_keys($config['sensor_types']), $sensor_types);
$sensor_types = array_merge($sensor_types, $other_types);
//r($sensor_types);
$sensors_device = dbFetchColumn("SELECT DISTINCT `sensor_class` FROM `sensors` WHERE `device_id` = ? AND `sensor_deleted` = ?", [ $device['device_id'], 0 ]);
//r($sensors_device);
foreach (array_intersect($sensor_types, $sensors_device) as $sensor_type) {
//if ($sensor['sensor_class'] == 'counter') { continue; } // DEVEL
$datas[$sensor_type] = [ 'icon' => $config['sensor_types'][$sensor_type]['icon'] ];
}
}
@ -42,9 +47,11 @@ if ($health_exist['counter'])
}
*/
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'health');
$link_array = [
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'health'
];
if (!$vars['metric']) { $vars['metric'] = "overview"; }
if (!$vars['view']) { $vars['view'] = "details"; }

View File

@ -1,13 +1,12 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -26,7 +25,7 @@ $form = array('type' => 'rows',
'submit_by_key' => TRUE,
'url' => generate_url($vars));
$where = ' WHERE 1 ' . generate_query_values($device['device_id'], 'device_id');
$where = ' WHERE 1 ' . generate_query_values_and($device['device_id'], 'device_id');
// Checkers Field
$form_filter = dbFetchColumn('SELECT DISTINCT `alert_test_id` FROM `alert_log`' . $where);

View File

@ -6,11 +6,11 @@
*
* @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
*
*/
$where = ' WHERE 1 ' . generate_query_values($device['device_id'], 'device_id');
$where = ' WHERE 1 ' . generate_query_values_and($device['device_id'], 'device_id');
$timestamp_min = dbFetchCell('SELECT `timestamp` FROM `eventlog` '.$where.' ORDER BY `timestamp` LIMIT 0,1;');
$timestamp_max = dbFetchCell('SELECT `timestamp` FROM `eventlog` '.$where.' ORDER BY `timestamp` DESC LIMIT 0,1;');

View File

@ -6,11 +6,11 @@
*
* @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
*
*/
$where = ' WHERE 1 ' . generate_query_values($device['device_id'], 'device_id');
$where = ' WHERE 1 ' . generate_query_values_and($device['device_id'], 'device_id');
$timestamp_min = dbFetchCell('SELECT `timestamp` FROM `syslog` '.$where.' ORDER BY `timestamp` LIMIT 0,1;');
if ($timestamp_min)

View File

@ -6,35 +6,32 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
register_html_resource('css', 'simplemde.min.css');
register_html_resource('js', 'simplemde.min.js');
register_html_resource('css', 'easymde.min.css');
register_html_resource('js', 'easymde.min.js');
register_html_resource('js', 'purify.min.js');
if (($_SESSION['userlevel'] >= 7 || is_entity_write_permitted($device['device_id'], 'device')) &&
isset($vars['notes_text']) && is_string($vars['notes_text']) && request_token_valid($vars))
{
isset($vars['notes_text']) && is_string($vars['notes_text']) && request_token_valid($vars)) {
set_entity_attrib('device', $device['device_id'], 'notes', $vars['notes_text'], $device['device_id']);
unset($vars['notes_text']);
if (isset($attribs) && is_array($attribs))
{
if (isset($attribs) && is_array($attribs)) {
$attribs['notes'] = $vars['notes_text'];
}
}
$notes = get_entity_attrib('device', $device['device_id'], 'notes');
if ($vars['edit'])
{
if ($vars['edit']) {
echo generate_box_open();
echo '<form method="POST" id="edit" name="edit" action="'.generate_url($vars, array('edit' => NULL)).'" class="form form-horizontal" style="margin-bottom: 0px;">';
// Add CSRF Token
if (isset($_SESSION['requesttoken']))
{
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element([ 'type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken'] ]) . PHP_EOL;
}
//echo generate_form_element([ 'type' => 'textarea', 'id' => 'notes_text', 'value' => $notes ]) . PHP_EOL; // not know why, this broke form
@ -43,8 +40,9 @@ if ($vars['edit'])
echo generate_box_close();
echo ' <button id="submit" name="submit" type="submit" class="btn btn-primary text-nowrap pull-right" value="save"><i class="icon-ok icon-white" style="margin-right: 0px;"></i>&nbsp;&nbsp;Save Changes</button> ';
echo ' </form>';
register_html_resource('script', 'var simplemde = new SimpleMDE();');
// https://github.com/Ionaru/easy-markdown-editor
register_html_resource('script', 'const easyMDE = new EasyMDE({ renderingConfig: { singleLineBreaks: false, sanitizerFunction: (renderedHTML) => {return DOMPurify.sanitize(renderedHTML, {ALLOWED_TAGS: [\'b\']}) }, }, });');
} else {
@ -52,8 +50,7 @@ if ($vars['edit'])
echo get_markdown($notes);
echo generate_box_close();
if (($_SESSION['userlevel'] >= 7 || is_entity_write_permitted($device['device_id'], 'device')) )
{
if (($_SESSION['userlevel'] >= 7 || is_entity_write_permitted($device['device_id'], 'device')) ) {
echo '<a href="'.generate_url($vars, array('edit' => TRUE)).'" id="edit" name="edit" type="submit" class="btn btn-primary text-nowrap pull-right" value="edit"><i class="icon-ok icon-white" style="margin-right: 0px;"></i>&nbsp;&nbsp;Edit Notes</a>';
}

View File

@ -118,9 +118,11 @@ if ($device['state']['la']['5min']) {
} else {
$la_class = '';
}
echo('<tr>
echo('<tr>
<td class="entity">Load average</td>
<td class="'.$la_class.'">' . $device['state']['la']['1min'] . ', ' . $device['state']['la']['5min'] . ', ' . $device['state']['la']['15min'] . '</td>
<td class="'.$la_class.'">' . number_format((float)$device['state']['la']['1min'],2) . ', ' .
number_format((float)$device['state']['la']['5min'], 2) . ', ' .
number_format((float)$device['state']['la']['15min'], 2) . '</td>
</tr>');
}

View File

@ -128,7 +128,9 @@ if ($device['state']['la']['5min']) {
}
echo('<tr>
<td class="entity">Load average</td>
<td class="'.$la_class.'">' . $device['state']['la']['1min'] . ', ' . $device['state']['la']['5min'] . ', ' . $device['state']['la']['15min'] . '</td>
<td class="'.$la_class.'">' . number_format((float)$device['state']['la']['1min'],2) . ', ' .
number_format((float)$device['state']['la']['5min'], 2) . ', ' .
number_format((float)$device['state']['la']['15min'], 2) . '</td>
</tr>');
}

View File

@ -6,22 +6,40 @@
*
* @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
*
*/
$sensor_types = array_keys($config['sensor_types']);
// Keep sensors order for base types static
$sensor_types = [ 'temperature', 'humidity', 'fanspeed', 'airflow', 'current', 'voltage', 'power', 'apower', 'rpower', 'frequency' ];
$other_types = array_diff(array_keys($config['sensor_types']), $sensor_types);
$sensor_types = array_merge($sensor_types, $other_types);
//r($sensor_types);
$measured_entindex = []; // collect measured entities
$measured_ifindex = []; // collect measured entities (by ifindex)
$measured_multi = [];
$sensors_db = [];
//foreach ($sensor_types as $sensor_type) {
$sql = "SELECT * FROM `sensors`";
//$sql .= " WHERE `sensor_class` = ? AND `device_id` = ? AND `sensor_deleted` = 0 ORDER BY `sensor_type`, `entPhysicalIndex` * 1, `sensor_descr`"; // order numerically by entPhysicalIndex for ports
$sql .= " WHERE `device_id` = ? " . generate_query_values($sensor_types, 'sensor_class') .
$sql .= " WHERE `device_id` = ? " . generate_query_values_and($sensor_types, 'sensor_class') .
" AND `sensor_deleted` = 0 ORDER BY `entPhysicalIndex_measured` * 1, `entPhysicalIndex` * 1, `sensor_descr`"; // order numerically by entPhysicalIndex for ports
// Cache all sensors
foreach (dbFetchRows($sql, [ $device['device_id'] ]) as $entry) {
if (is_numeric($entry['measured_entity']) && strlen($entry['measured_class'])) {
if (is_numeric($entry['measured_entity']) && !safe_empty($entry['measured_class'])) {
// Collect entPhysical entities
if (!(isset($measured_entindex[$entry['measured_entity']]) || isset($measured_ifindex[$entry['measured_entity']]))) {
if ($entry['entPhysicalIndex']) {
$measured_entindex[$entry['measured_entity']] = $entry['entPhysicalIndex'];
} elseif ($entry['measured_class'] === 'port') {
// When not correct entPhysicalIndex stored
$port = get_port_by_id_cache($entry['measured_entity']);
$measured_ifindex[$entry['measured_entity']] = $port['ifIndex'];
}
}
// Sensors bounded with measured class, mostly ports
// array index -> ['measured']['port']['345'][] = sensor array
switch ($entry['measured_class']) {
@ -33,12 +51,16 @@ $measured_multi = [];
$lane = 0;
}
$sensors_db['measured'][$entry['measured_class']][$entry['measured_entity']][$entry['sensor_class']][] = $entry;
$measured_multi[$entry['measured_class']][$entry['measured_entity']][$lane][$entry['sensor_class']][] = $entry;
$measured_multi[$entry['measured_class']][$entry['measured_entity']][$lane][$entry['sensor_class']][] = $entry;
break;
default:
$sensors_db['measured'][$entry['measured_class']][$entry['measured_entity']][$entry['sensor_class']][] = $entry;
}
} elseif ($entry['measured_class'] === 'outlet' && !safe_empty($entry['measured_entity_label'])) {
// Outlet currently not have real entity associations
//r($entry);
$sensors_db['measured'][$entry['measured_class']][$entry['measured_entity_label']][$entry['sensor_class']][] = $entry;
} else {
$sensors_db[$entry['sensor_class']][$entry['sensor_id']] = $entry;
}
@ -47,84 +69,162 @@ $measured_multi = [];
//r($sensors_db['measured']);
//r($measured_multi);
// Print Multi sensors at single line for each entity
/* WiP
if (count($measured_multi)) {
$vars['measured_icon'] = FALSE; // Hide measured icons
foreach ($measured_multi as $measured_class => $measured_entity) {
$box_args = ['title' => nicecase($measured_class) . ' sensors',
'url' => generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => $measured_class . 's', 'view' => 'sensors']),
'icon' => $config['icon']['sensor']
];
echo generate_box_open($box_args);
echo ' <table class="table table-condensed table-striped">';
echo ' </table>';
echo generate_box_close();
}
}
*/
// Now print founded bundle (measured_class+sensor)
if (isset($sensors_db['measured'])) {
$vars['measured_icon'] = FALSE; // Hide measured icons
// Fetch entphysical serials and part/vendor names
$measured_entphysical = [];
if ($measured_entindex) {
foreach (dbFetchRows('SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `deleted` IS NULL' . generate_query_values_and($measured_entindex, 'entPhysicalIndex'), [ $device['device_id'] ]) as $entry) {
foreach ($measured_entindex as $entity_id => $entPhysicalIndex) {
if ($entPhysicalIndex === $entry['entPhysicalIndex']) {
if (empty($entry['entPhysicalModelName']) && empty($entry['entPhysicalSerialNum'])) {
// Containers.. try to get inside
//r($entry);
$tmp_entry = dbFetchRow('SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `deleted` IS NULL AND `entPhysicalIndex` = ?', [ $device['device_id'], $entry['entPhysicalContainedIn'] ]);
if (!empty($tmp_entry['entPhysicalModelName']) || !empty($tmp_entry['entPhysicalSerialNum'])) {
$entry = $tmp_entry;
//r($tmp_entry);
}
}
$measured_entphysical[$entity_id] = $entry;
unset($measured_entindex[$entity_id]);
break;
}
}
}
}
if ($measured_ifindex) {
foreach (dbFetchRows('SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `deleted` IS NULL' . generate_query_values_and($measured_ifindex, 'ifIndex'), [ $device['device_id'] ]) as $entry) {
foreach ($measured_ifindex as $entity_id => $ifIndex) {
if ($ifIndex === $entry['ifIndex']) {
$measured_entphysical[$entity_id] = $entry;
unset($measured_ifindex[$entity_id]);
break;
}
}
}
}
//r($measured_entphysical);
$show_compact = $config['sensors']['web_measured_compact'];
foreach ($sensors_db['measured'] as $measured_class => $measured_entity) {
$box_args = array('title' => nicecase($measured_class).' sensors',
'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => $measured_class.'s', 'view' => 'sensors')),
'icon' => $config['icon']['sensor']
);
$box_args = [
'title' => nicecase($measured_class).' sensors',
'url' => generate_url([ 'page' => 'device', 'device' => $device['device_id'], 'tab' => $measured_class.'s', 'view' => 'sensors' ]),
'icon' => $config['icon']['sensor']
];
$box_args['header-controls'] = [
'controls' => [
'compact' => [ 'text' => $show_compact ? 'Full View' : 'Compact View',
'icon' => $show_compact ? 'glyphicon-th-list' : 'glyphicon-th',
'config' => 'sensors|web_measured_compact', // check this config
'value' => $show_compact ? 'no' : 'yes', // toggle
]
]
];
echo generate_box_open($box_args);
echo ' <table class="table table-condensed table-striped">';
foreach ($measured_entity as $entity_id => $entry)
{
$entity = get_entity_by_id_cache($measured_class, $entity_id);
//r($entity);
$entity_link = generate_entity_link($measured_class, $entity);
$entity_type = entity_type_translate_array($measured_class);
// Remove port name from sensor description
$rename_from = [];
if ($measured_class === 'port') {
if (is_numeric($entity['port_label'])) {
$rename_from[] = $entity['port_label'].' ';
} else {
$rename_from[] = $entity['port_label'];
$rename_from[] = $entity['ifDescr'];
$rename_from[] = $entity['port_label_short'];
}
if (strlen($entity['port_label_base']) > 4) { $rename_from[] = $entity['port_label_base']; }
$rename_from = array_unique($rename_from);
//r($measured_entity);
foreach ($measured_entity as $entity_id => $entry) {
if ($measured_class === 'outlet') {
// Outlets not have real entities association
$entity = [];
$entity_link = $entity_id; // Just Outlet Label
$entity_type = [ 'icon' => 'outlet' ];
$entity_parts = '';
} else {
$rename_from[] = entity_rewrite($measured_class, $entity);
// Common known entities
$entity = get_entity_by_id_cache($measured_class, $entity_id);
//r($entity);
$entity_link = generate_entity_link($measured_class, $entity);
$entity_type = entity_type_translate_array($measured_class);
$entity_parts = '';
if ($measured_entphysical[$entity_id]) {
// Entity Vendor/PartNum/Serial
if ($measured_entphysical[$entity_id]['entPhysicalMfgName']) {
$entity_parts .= ' <span class="label label-info">' . $measured_entphysical[$entity_id]['entPhysicalMfgName'] . '</span>';
}
if ($measured_entphysical[$entity_id]['entPhysicalModelName']) {
$entity_parts .= ' <span class="label label-warning">' . $measured_entphysical[$entity_id]['entPhysicalModelName'] . '</span>';
}
if ($measured_entphysical[$entity_id]['entPhysicalSerialNum']) {
$entity_parts .= ' <span class="label label-primary">SN: ' . $measured_entphysical[$entity_id]['entPhysicalSerialNum'] . '</span>';
}
}
// Remove port name from sensor description
$rename_from = [];
if ($measured_class === 'port') {
if (is_numeric($entity['port_label'])) {
$rename_from[] = $entity['port_label'] . ' ';
} else {
$rename_from[] = $entity['port_label'];
$rename_from[] = $entity['ifDescr'];
$rename_from[] = $entity['port_label_short'];
}
if (strlen($entity['port_label_base']) > 4) {
$rename_from[] = $entity['port_label_base'];
}
$rename_from = array_unique($rename_from);
} else {
entity_rewrite($measured_class, $entity);
}
$entity['rename_from'] = $rename_from;
}
//r($rename_from);
//echo(' <tr class="'.$port['row_class'].'">
// <td class="state-marker"></td>
echo(' <tr>
<td colspan="6" class="entity">' . get_icon($entity_type['icon']) . '&nbsp;' . $entity_link . '</td></tr>');
<td colspan="6" class="entity">' . get_icon($entity_type['icon']) . '&nbsp;' . $entity_link . $entity_parts . '</td></tr>');
// order dom sensors always by temperature, voltage, current, dbm, power
$order = [];
if (safe_count($entry) > 0) {
$classes = array_keys($entry);
//r($types);
$order = array_intersect([ 'temperature', 'voltage', 'current', 'dbm', 'power' ], $classes);
$order = array_merge($order, array_diff($classes, $order));
//r($order);
}
foreach ($order as $class) {
foreach ($entry[$class] as $sensor) {
$sensor['sensor_descr'] = trim(str_ireplace($rename_from, '', $sensor['sensor_descr']), ":- \t\n\r\0\x0B");
if (empty($sensor['sensor_descr'])) {
// Some time sensor descriptions equals to entity name
$sensor['sensor_descr'] = nicecase($sensor['sensor_class']);
if ($show_compact && $measured_class !== 'outlet') {
// In compact view need multi-lane split
$lanes_count = safe_count($measured_multi[$measured_class][$entity_id]);
if ($lanes_count > 1) {
if (isset($measured_multi[$measured_class][$entity_id][0]) && $lanes_count === 5) {
// Multilane with separated voltage or others
for ($i = 1; $i <= 4; $i++) {
$measured_multi[$measured_class][$entity_id][$i] = array_merge($measured_multi[$measured_class][$entity_id][$i],
$measured_multi[$measured_class][$entity_id][0]);
}
unset($measured_multi[$measured_class][$entity_id][0]);
}
foreach ($measured_multi[$measured_class][$entity_id] as $lane => $lane_entry) {
echo '<tr><td style="width: 10px;" class="vertical-align"><span class="label">L'.$lane.'</span></td>' .
get_compact_sensors_line($measured_class, $lane_entry, $vars) . '</tr>';
}
} else {
echo '<tr><td style="width: 10px;"></td>' . get_compact_sensors_line($measured_class, $entry, $vars) . '</tr>';
}
} else {
// order dom sensors always by temperature, voltage, current, dbm, power
$order = [];
if (safe_count($entry) > 0) {
$classes = array_keys($entry);
//r($types);
$order = array_intersect([ 'temperature', 'voltage', 'current', 'dbm', 'power' ], $classes);
$order = array_merge($order, array_diff($classes, $order));
//r($order);
}
print_sensor_row($sensor, $vars);
foreach ($order as $class) {
foreach ($entry[$class] as $sensor) {
$sensor['sensor_descr'] = trim(str_ireplace($rename_from, '', $sensor['sensor_descr']), ":- \t\n\r\0\x0B");
if (empty($sensor['sensor_descr'])) {
// Some time sensor descriptions equals to entity name
$sensor['sensor_descr'] = nicecase($sensor['sensor_class']);
}
print_sensor_row($sensor, $vars);
}
}
}
//if ($show_compact) { echo '<tr>' . $line . '</tr>'; }
}
?>
@ -136,27 +236,23 @@ if (isset($sensors_db['measured'])) {
unset($sensors_db['measured']);
}
foreach ($sensors_db as $sensor_type => $sensors)
{
if ($sensor_type === 'measured') { continue; } // Just be on the safe side
foreach ($sensor_types as $sensor_type) {
if (safe_empty($sensors_db[$sensor_type])) { continue; }
if (count($sensors))
{
$box_args = array('title' => nicecase($sensor_type),
'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => $sensor_type)),
'icon' => $config['sensor_types'][$sensor_type]['icon'],
);
echo generate_box_open($box_args);
$box_args = [
'title' => nicecase($sensor_type),
'url' => generate_url([ 'page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => $sensor_type ]),
'icon' => $config['sensor_types'][$sensor_type]['icon'],
];
echo generate_box_open($box_args);
echo('<table class="table table-condensed table-striped">');
foreach ($sensors as $sensor)
{
print_sensor_row($sensor, $vars);
}
echo("</table>");
echo generate_box_close();
echo('<table class="table table-condensed table-striped">');
foreach ($sensors_db[$sensor_type] as $sensor) {
print_sensor_row($sensor, $vars);
}
echo("</table>");
echo generate_box_close();
}
// EOF

View File

@ -6,57 +6,50 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$graph_type = "storage_usage";
$sql = "SELECT * FROM `storage`";
//$sql .= " LEFT JOIN `storage-state` USING(`storage_id`)";
$sql .= " WHERE `device_id` = ?";
$sql .= " WHERE `device_id` = ? AND `storage_ignore` = ? AND `storage_deleted` = ?";
$drives = dbFetchRows($sql, array($device['device_id']));
$drives = dbFetchRows($sql, [ $device['device_id'], 0, 0 ]);
if (count($drives))
{
$drives = array_sort_by($drives, 'storage_descr', SORT_ASC, SORT_STRING);
if (!safe_empty($drives)) {
$drives = array_sort_by($drives, 'storage_mib', SORT_ASC, SORT_STRING,
'storage_descr', SORT_ASC, SORT_STRING);
$box_args = array('title' => 'Storage',
'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => 'storage')),
'icon' => $config['icon']['storage'],
);
$box_args = [
'title' => 'Storage',
'url' => generate_url([ 'page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => 'storage' ]),
'icon' => $config['icon']['storage'],
];
echo generate_box_open($box_args);
echo('<table class="table table-condensed table-striped">');
foreach ($drives as $drive)
{
foreach ($drives as $drive) {
$skipdrive = FALSE;
if ($device["os"] === "junos")
{
foreach ($config['ignore_junos_os_drives'] as $jdrive)
{
if (preg_match($jdrive, $drive["storage_descr"]))
{
if ($device["os"] === "junos") {
foreach ($config['ignore_junos_os_drives'] as $jdrive) {
if (preg_match($jdrive, $drive["storage_descr"])) {
$skipdrive = TRUE;
}
}
//$drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]);
}
if ($device['os'] === "freebsd")
{
foreach ($config['ignore_bsd_os_drives'] as $jdrive)
{
if (preg_match($jdrive, $drive["storage_descr"]))
{
if ($device['os'] === "freebsd") {
foreach ($config['ignore_bsd_os_drives'] as $jdrive) {
if (preg_match($jdrive, $drive["storage_descr"])) {
$skipdrive = TRUE;
}
}
}
if ($drive['storage_ignore']) { $skipdrive = TRUE; }
//if ($drive['storage_ignore']) { $skipdrive = TRUE; }
if ($skipdrive) { continue; }
@ -69,13 +62,13 @@ if (count($drives))
$used = formatStorage($drive['storage_used']);
$background = get_percentage_colours($percent);
$graph_array = array();
$graph_array = [];
$graph_array['height'] = "100";
$graph_array['width'] = "210";
$graph_array['to'] = $config['time']['now'];
$graph_array['to'] = get_time();
$graph_array['id'] = $drive['storage_id'];
$graph_array['type'] = $graph_type;
$graph_array['from'] = $config['time']['day'];
$graph_array['from'] = get_time('day');
$graph_array['legend'] = "no";
$link_array = $graph_array;
@ -85,7 +78,9 @@ if (count($drives))
$overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $drive['storage_descr']);
$graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00';
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
// $graph_array['style'][] = 'margin-top: -6px';
$minigraph = generate_graph_tag($graph_array);

View File

@ -17,13 +17,10 @@
<?php
$graph_array = array('type' => 'device_poller_perf',
'device' => $device['device_id']
);
?>
<?php
$graph_array = [
'type' => 'device_poller_perf',
'device' => $device['device_id']
];
echo generate_box_open(array('title' => 'Poller Performance'));
print_graph_row($graph_array);
@ -62,6 +59,9 @@ unset($navbar);
if (is_array($device['state']['poller_mod_perf'])) {
arsort($device['state']['poller_mod_perf']);
}
if (is_array($device['state']['discovery_mod_perf'])) {
arsort($device['state']['discovery_mod_perf']);
}
if ($vars['view'] === 'db')
{
@ -164,7 +164,7 @@ elseif ($vars['view'] === 'poller')
</div>
<div class="row">
<div class="col-md-6">
<div class="col-md-4">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Poller Module Times</h3>
@ -181,21 +181,18 @@ elseif ($vars['view'] === 'poller')
<tbody>
<?php
foreach ($device['state']['poller_mod_perf'] as $module => $time)
{
if ($time > 0.001)
{
foreach ($device['state']['poller_mod_perf'] as $module => $time) {
if ($time > 0.001) {
$perc = round(float_div($time, $device['last_polled_timetaken']) * 100, 2, 2);
echo(' <tr>
<td><strong>'.$module.'</strong></td>
<td style="width: 80px;">'.number_format($time, 4).'s</td>
<td style="width: 70px;">'.$perc.'%</td>
<td style="width: 70px;"><span style="color:'.percent_colour($perc).'">'.$perc.'%</span></td>
</tr>');
// Separate sub-module perf (ie ports)
foreach ($device['state']['poller_'.$module.'_perf'] as $submodule => $subtime)
{
foreach ($device['state']['poller_'.$module.'_perf'] as $submodule => $subtime) {
echo(' <tr>
<td>&nbsp;<i class="icon-share-alt icon-flip-vertical"></i><strong style="padding-left:1em"><i>'.$submodule.'</i></strong></td>
<td style="width: 80px;"><i>'.number_format($subtime, 4).'s</i></td>
@ -212,27 +209,26 @@ foreach ($device['state']['poller_mod_perf'] as $module => $time)
</div>
</div>
<div class="col-md-3">
<div class="col-md-2">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Poller Total Times</h3>
<h3 class="box-title">Poller Times</h3>
</div>
<div class="box-body no-padding">
<table class="table table-hover table-striped table-condensed ">
<thead>
<tr>
<th>Time</th>
<th>Duration</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$times = is_array($device['state']['poller_history']) ? array_slice($device['state']['poller_history'], 0, 30, TRUE) : [];
foreach ($times as $start => $duration)
{
foreach ($times as $start => $duration) {
echo(' <tr>
<td>'.format_unixtime($start).'</td>
<td>'.generate_tooltip_time($start, 'ago').'</td>
<td>'.format_uptime($duration).'</td>
</tr>');
}
@ -244,7 +240,57 @@ foreach ($times as $start => $duration)
</div>
</div>
<div class="col-md-3">
<div class="col-md-4">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Discovery Module Times</h3>
</div>
<div class="box-body no-padding">
<table class="table table-hover table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th colspan="2">Duration</th>
</tr>
</thead>
<tbody>
<?php
//r($device['state']);
foreach ($device['state']['discovery_mod_perf'] as $module => $time) {
if ($time > 0.001) {
$perc = round(float_div($time, $device['last_discovered_timetaken']) * 100, 2, 2);
echo(' <tr>
<td><strong>'.$module.'</strong></td>
<td style="width: 80px;">'.number_format($time, 4).'s</td>
<td style="width: 70px;"><span style="color:'.percent_colour($perc).'">'.$perc.'%</span></td>
</tr>');
// Separate sub-module perf (ie ports)
foreach ($device['state']['discovery_'.$module.'_perf'] as $submodule => $subtime) {
echo(' <tr>
<td>&nbsp;<i class="icon-share-alt icon-flip-vertical"></i><strong style="padding-left:1em"><i>'.$submodule.'</i></strong></td>
<td style="width: 80px;"><i>'.number_format($subtime, 4).'s</i></td>
<td style="width: 70px;"></td>
</tr>');
}
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-2">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Discovery Times</h3>
@ -254,20 +300,19 @@ foreach ($times as $start => $duration)
<thead>
<tr>
<th>Time</th>
<th>Duration</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$times = is_array($device['state']['discovery_history']) ? array_slice($device['state']['discovery_history'], 0, 30, TRUE) : [];
foreach ($times as $start => $duration)
{
echo(' <tr>
<td>'.format_unixtime($start).'</td>
$times = is_array($device['state']['discovery_history']) ? array_slice($device['state']['discovery_history'], 0, 30, TRUE) : [];
foreach ($times as $start => $duration) {
echo(' <tr>
<td>'.generate_tooltip_time($start, 'ago').'</td>
<td>'.format_uptime($duration).'</td>
</tr>');
}
}
?>
</tbody>

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
*
*/
@ -223,7 +223,7 @@ if ($vars['view'] === 'minigraphs') {
}
//$where = ' IN ('.implode(',', array_keys($port_cache)).')';
//$where = generate_query_values(array_keys($port_cache), 'port_id');
//$where = generate_query_values_and(array_keys($port_cache), 'port_id');
//$where = generate_query_permitted(array('ports', 'devices'));
foreach ($ext_tables as $table) {
// Here stored port_id!

View File

@ -1,53 +1,94 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
register_html_title("OSPF");
$navbar = array();
$navbar = [];
$navbar['brand'] = "OSPF";
$navbar['class'] = "navbar-narrow";
$ospf_instances = dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", array($device['device_id']));
echo generate_box_open();
echo '<table class="table table-hover table-striped table-condensed">';
// Loop Instances (There can only ever really be once instance at the moment, thanks to douchebags who decided we should use undiscoverable context names instead of just making tables.)
// There only 2 possible instances (V2/V3)
foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", [ $device['device_id'] ]) as $instance) {
foreach ($ospf_instances as $instance)
{
echo generate_box_open();
echo '<table class="table table-hover table-striped table-condensed">';
$area_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id']));
$port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ?", array($device['device_id']));
$port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id']));
$nbr_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ?", array($device['device_id']));
$ospf_version = $instance['ospfVersionNumber'];
$query = "SELECT * FROM `ipv4_addresses` WHERE `ipv4_address` = ? AND `device_id` = ?";
//$query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)";
//$query .= " AND I.device_id = ?";
$ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'], $device['device_id']));
$area_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ? AND `ospfVersionNumber` = ?", [ $device['device_id'], $ospf_version ]);
if ($ospf_version !== 'version3') {
$instance_id = $instance['ospfRouterId'];
if ($device_routing_count['ospf'] > 1) { $instance_id .= ' <span class="label label-success">V2</span>'; }
// V2 always have 5 part index, ie: 95.130.232.140.0
$port_params = [ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){4}$' ];
// V2 always have 5 part index, ie: .95.130.232.130.0
$nbr_params = [ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){4}$' ];
} else {
$instance_id = long2ip($instance['ospfRouterId']);
if ($device_routing_count['ospf'] > 1) { $instance_id .= ' <span class="label label-primary">V3</span>'; }
// V3 always have 2 part index, ie: 6.0
$port_params = [ $device['device_id'], '^[[:digit:]]+\.[[:digit:]]+$' ];
// V3 always have 3 part index, ie: .4.0.1602414725
$nbr_params = [ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){2}$' ];
}
$port_count = 0;
$port_count_enabled = 0;
$sql = 'SELECT `ospfIfAdminStat`, COUNT(*) AS `count` FROM `ospf_ports`' .
' WHERE `device_id` = ? AND `ospf_port_id` REGEXP ? GROUP BY `ospfIfAdminStat`';
foreach (dbFetchRows($sql, $port_params) as $entry) {
if ($entry['ospfIfAdminStat'] === 'enabled') {
$port_count_enabled = (int)$entry['count'];
}
$port_count += (int)$entry['count'];
}
$nbr_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` REGEXP ?", $nbr_params);
if ($instance['ospfAdminStat'] == "enabled") { $enabled = '<span class="green">enabled</span>';
$row_class = 'up'; } else { $enabled = '<span class="grey">disabled</span>';
$row_class = "disabled"; }
if ($instance['ospfAreaBdrRtrStatus'] == "true") { $abr = '<span class="green">yes</span>'; } else { $abr = '<span class="grey">no</span>'; }
if ($instance['ospfASBdrRtrStatus'] == "true") { $asbr = '<span class="green">yes</span>'; } else { $asbr = '<span class="grey">no</span>'; }
if ($instance['ospfAdminStat'] === "enabled") {
$enabled = '<span class="label label-success">enabled</span>';
$row_class = 'up';
} else {
$enabled = '<span class="label">disabled</span>';
$row_class = "disabled";
}
if ($instance['ospfAreaBdrRtrStatus'] === "true") {
$abr = '<span class="green">yes</span>';
} else {
$abr = '<span class="grey">no</span>';
}
if ($instance['ospfASBdrRtrStatus'] === "true") {
$asbr = '<span class="green">yes</span>';
} else {
$asbr = '<span class="grey">no</span>';
}
echo('<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr></thead>');
$cols = [
[ NULL, 'class="state-marker"' ],
[ 'Router Id', 'style="width: 160px;"' ],
'Status',
'ABR',
'ASBR',
'Areas',
'Ports',
'Neighbours'
//'descr' => array('Description', 'style="width: 400px;"'),
//'rule' => 'Rule',
];
echo get_table_header($cols, $vars);
//echo('<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr></thead>');
echo('<tr class="'.$row_class.'">');
echo(' <td class="state-marker"></td>');
echo(' <td class="entity-title">'.$instance['ospfRouterId'] . '</td>');
echo(' <td class="entity-title">' . $instance_id . '</td>');
echo(' <td>' . $enabled . '</td>');
echo(' <td>' . $abr . '</td>');
echo(' <td>' . $asbr . '</td>');
@ -64,22 +105,36 @@ foreach ($ospf_instances as $instance)
/// Global Areas Table
/// FIXME -- humanize_ospf_area()
echo generate_box_open(array('title' => 'Areas'));
echo generate_box_open([ 'title' => 'Areas' ]);
echo('<table class="table table-hover table-striped">');
echo('<thead><tr><th class="state-marker"></th><th>Area Id</th><th>Status</th><th>Auth Type</th><th>AS External</th><th>Area LSAs</th><th>Area Summary</th><th>Ports</th></tr></thead>');
$cols = [
[ NULL, 'class="state-marker"' ],
[ 'Area Id', 'style="width: 160px;"' ],
'Status',
'Auth Type',
'AS External',
'Area LSAs',
'Area Summary',
'Ports'
];
echo get_table_header($cols, $vars);
//echo('<thead><tr><th class="state-marker"></th><th>Area Id</th><th>Status</th><th>Auth Type</th><th>AS External</th><th>Area LSAs</th><th>Area Summary</th><th>Ports</th></tr></thead>');
/// Loop Areas
foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id'])) as $area)
{
foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ? AND `ospfVersionNumber` = ?", [ $device['device_id'], $ospf_version ]) as $area) {
$area_port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId']));
$area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId']));
$port_params[] = $area['ospfAreaId'];
$area_port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospf_port_id` REGEXP ? AND `ospfIfAreaId` = ?", $port_params);
$area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospf_port_id` REGEXP ? AND `ospfIfAreaId` = ?", $port_params);
$area_id = $ospf_version === 'version3' ? long2ip($area['ospfAreaId']) : $area['ospfAreaId'];
$area_row_class = $area['ospfAreaStatus'] === 'active' ? 'up' : 'disabled';
$enabled = $area['ospfAreaStatus'] === 'active' ? '<span class="label label-success">'.$area['ospfAreaStatus'].'</span>' : '<span class="label">'.$area['ospfAreaStatus'].'</span>';
echo('<tr class="'.$area_row_class.'">');
echo(' <td class="state-marker"></td>');
echo(' <td class="entity-title">'.$area['ospfAreaId'] . '</td>');
echo(' <td class="entity-title">' . $area_id . '</td>');
echo(' <td>' . $enabled . '</td>');
echo ' <td>' . $area['ospfAuthType'] . '</td>';
echo ' <td>' . $area['ospfImportAsExtern'] . '</td>';
@ -96,20 +151,28 @@ foreach ($ospf_instances as $instance)
echo generate_box_open();
echo('<table class="table table-hover table-striped table-condensed ">');
echo('<thead><tr><th class="state-marker"></th><th>Port</th><th>Status</th><th>Port Type</th><th>Port State</th></tr></thead>');
echo('<table class="table table-hover table-striped table-condensed">');
$cols = [
[ NULL, 'class="state-marker"' ],
[ 'Port', 'style="width: 160px;"' ],
[ 'Status', 'style="width: 160px;"' ],
'Port Type',
'Port State'
];
echo get_table_header($cols, $vars);
//echo('<thead><tr><th class="state-marker"></th><th>Port</th><th>Status</th><th>Port Type</th><th>Port State</th></tr></thead>');
///# Loop Ports
$p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id";
foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport)
{
// Loop Ports
$p_sql = 'SELECT * FROM `ospf_ports` LEFT JOIN `ports` USING (`device_id`, `port_id`)' .
' WHERE `device_id` = ? AND `ospf_port_id` REGEXP ? AND `ospfIfAreaId` = ? AND `ospfIfAdminStat` = \'enabled\'';
//$p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id";
foreach (dbFetchRows($p_sql, $port_params) as $ospfport) {
if ($ospfport['ospfIfAdminStat'] == "enabled")
{
$port_enabled = '<span class="green">enabled</span>';
if ($ospfport['ospfIfAdminStat'] === "enabled") {
$port_enabled = '<span class="label label-success">enabled</span>';
$port_row_class = 'up';
} else {
$port_enabled = '<span class="green">disabled</span>';
$port_enabled = '<span class="label">'.$ospfport['ospfIfAdminStat'].'</span>';
$port_row_class = 'disabled';
}
@ -120,8 +183,6 @@ foreach ($ospf_instances as $instance)
echo(' <td>' . $ospfport['ospfIfType'] . '</td>');
echo(' <td>' . $ospfport['ospfIfState'] . '</td>');
echo('</tr>');
$i_p++;
} // End loop Ports
echo('</table>');
@ -137,26 +198,41 @@ foreach ($ospf_instances as $instance)
/// Global Neighbour Table
/// FIXME -- humanize_ospf_neighbour()
echo generate_box_open(array('title' => 'Neighbours'));
echo generate_box_open([ 'title' => 'Neighbours' ]);
echo '<table class="table table-condensed table-hover table-striped">';
echo '<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Device</th><th>IP Address</th><th>Status</th></tr></thead>';
echo '<table class="table table-condensed table-hover table-striped">';
$cols = [
[ NULL, 'class="state-marker"' ],
[ 'Router Id', 'style="width: 160px;"' ],
[ 'Device', 'style="width: 160px;"' ],
'IP Address',
'Status'
];
echo get_table_header($cols, $vars);
//echo '<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Device</th><th>IP Address</th><th>Status</th></tr></thead>';
// Loop Neigbours
foreach (dbFetchRows("SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?", array($device['device_id'])) as $nbr)
{
$host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($nbr['ospfNbrRtrId']));
// Loop Neighbours
foreach (dbFetchRows("SELECT * FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` REGEXP ?", $nbr_params) as $nbr) {
if ($ospf_version !== 'version3') {
$nbr_router_id = $nbr['ospfNbrRtrId'];
} else {
$nbr_router_id = long2ip($nbr['ospfNbrRtrId']);
}
$host = dbFetchRow("SELECT `device_id`, `port_id` FROM `ipv4_addresses` WHERE `ipv4_address` = ?", [ $nbr_router_id ]);
if (is_array($host)) { $rtr_id = generate_device_link($host); } else { $rtr_id = "unknown"; }
if (is_array($host)) {
$rtr_id = generate_device_link($host);
} else {
$rtr_id = '<span class="label">unknown</span>';
}
echo('<tr class="' . $port_row_class . '">');
echo(' <td class="state-marker"></td>');
echo(' <td><span class="entity-title">' . $nbr['ospfNbrRtrId'] . '</span></td>');
echo(' <td><span class="entity-title">' . $nbr_router_id . '</span></td>');
echo(' <td>' . $rtr_id . '</td>');
echo(' <td>' . $nbr['ospfNbrIpAddr'] . '</td>');
echo(' <td>' . ip_compress($nbr['ospfNbrIpAddr']) . '</td>');
echo(' <td>');
switch ($nbr['ospfNbrState'])
{
switch ($nbr['ospfNbrState']) {
case 'full':
echo('<span class="green">'.$nbr['ospfNbrState'].'</span>');
break;

View File

@ -48,7 +48,7 @@ if ($device['type'] == 'wireless')
if ($vars['view'] == "graphs" || $vars['view'] == "services") { $table_class="table-striped-two"; } else { $table_class="table-striped"; }
echo generate_box_open();
echo '<table class="table table-striped table-condensed" style="margin-top: 10px;">';
echo '<table class="table table-striped table-condensed">';
echo ' <thead>';
echo ' <tr>';
echo ' <th class="state-marker"></th>';

View File

@ -12,21 +12,23 @@
*/
// Display devices as a list in detailed format
$header = [ 'state-marker' => '',
'',
[ 'hostname' => 'Hostname', 'domain' => 'Domain', 'location' => 'Location'],
'',
[ 'os' => 'Operating System', 'hardware' => 'Hardware Platform'],
[ 'uptime' => 'Uptime', 'sysName' => 'sysName']];
//r($table_header);
?>
<table class="table table-hover table-striped table-condensed ">
<thead>
<tr>
<th class="state-marker"></th>
<th></th>
<th>Device / Location</th>
<th></th>
<th>Operating System / Hardware Platform</th>
<th>Uptime / sysName</th>
</tr>
</thead>
<table class="table table-hover table-striped table-condensed ">
<?php
echo generate_table_header($header, $vars);
foreach ($devices as $device)
{
if (device_permitted($device['device_id']))

View File

@ -29,6 +29,8 @@ foreach ($devices as $device)
{
if (device_permitted($device['device_id']))
{
get_device_graphs($device);
if (!$location_filter || $device['location'] == $location_filter)
{
print_device_row($device, 'status');

View File

@ -1,13 +1,12 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -40,7 +39,7 @@ $form['row'][0]['device_id'] = array(
// Add device_id limit for other fields
if (isset($vars['device_id']))
{
$where .= generate_query_values($vars['device_id'], 'device_id');
$where .= generate_query_values_and($vars['device_id'], 'device_id');
}
// Message field

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
*
*/
@ -23,6 +23,7 @@ unset($vars['page']);
$thumb_width=113;
//}
// Timestamps from Graphs page form, convert to common from/to unixtime
if (isset($vars['timestamp_from']) && preg_match(OBS_PATTERN_TIMESTAMP, $vars['timestamp_from'])) {
$vars['from'] = strtotime($vars['timestamp_from']);
unset($vars['timestamp_from']);
@ -160,10 +161,15 @@ if (!$auth) {
foreach($vars as $var => $value) { if(in_array($var, $valid)) { $add_array[$var] = $value; } }
if (isset($vars['dash_add']) && dashboard_exists($vars['dash_add'])) {
$widget_id = dbInsert(array('dash_id' => $vars['dash_add'], 'widget_config' => json_encode($add_array), 'widget_type' => 'graph', 'x' => 0, 'y' => 99, 'width' => 3, 'height' => 2), 'dash_widgets');
$dash_add_key = 'widget_graph_'.$vars['dash_add'].'_'.var_encode($add_array); // prevent clone widget graphs
if (isset($vars['dash_add']) && empty($_SESSION[$dash_add_key]) && dashboard_exists($vars['dash_add'])) {
$widget_id = dbInsert([ 'dash_id' => $vars['dash_add'],
'widget_config' => safe_json_encode($add_array),
'widget_type' => 'graph',
'x' => 0, 'y' => 99, 'width' => 3, 'height' => 2 ], 'dash_widgets');
print_message('Graph widget added to dashboard.', 'info');
unset($vars['dash_add']);
session_set_var($dash_add_key, 1);
}
if (isset($vars['dash_add_widget'])) {
@ -276,13 +282,34 @@ if (!$auth) {
unset($form_vars['to']);
unset($form_vars['period']);
$form = array('type' => 'rows',
'space' => '5px',
'submit_by_key' => TRUE,
'url' => 'graphs'.generate_url($form_vars));
$form = [
'type' => 'rows',
'space' => '5px',
'submit_by_key' => TRUE,
'url' => 'graphs'.generate_url($form_vars)
];
if (is_numeric($vars['from']) && $vars['from'] < 0) { $text_from = time() + $vars['from']; } elseif(is_numeric($vars['from'])) { $text_from = date('Y-m-d H:i:s', $vars['from']); }
if (is_numeric($vars['to']) && $vars['to'] < 0) { $text_to = time() + $vars['to']; } elseif ($vars['to'] === 'now' || $vars['to'] === "NOW") { $text_to = time(); } elseif(is_numeric($vars['to'])) { $text_to = date('Y-m-d H:i:s', $vars['to']); }
if (is_numeric($vars['from']) && $vars['from'] < 0) {
$text_from = time() + $vars['from'];
} elseif (is_numeric($vars['from'])) {
$text_from = date('Y-m-d H:i:s', $vars['from']);
}
if (is_numeric($vars['to']) && $vars['to'] < 0) {
$text_to = time() + $vars['to'];
} elseif ($vars['to'] === 'now' || $vars['to'] === "NOW") {
$text_to = time();
} elseif (is_numeric($vars['to'])) {
$text_to = date('Y-m-d H:i:s', $vars['to']);
}
if ($vars['to'] === 'now' || $vars['to'] === "NOW") {
//$text_to = time() + $vars['to'];
$text_to = date('Y-m-d H:i:s');
} elseif (is_numeric($vars['to'])) {
$text_to = date('Y-m-d H:i:s', $vars['to']);
} else {
$text_to = $vars['to'];
}
if (isset($vars['period']) && (!isset($vars['from']) || !isset($vars['to']))) {
$text_to = date('Y-m-d H:i:s', time());
@ -305,14 +332,14 @@ if (is_numeric($vars['to']) && $vars['to'] < 0) { $text_to = time() + $vars['to'
'to' => $text_to);
$search_grid = 2;
if ($type == "port")
if ($type === "port")
{
if ($subtype == "bits")
if ($subtype === "bits")
{
$speed_list = array('auto' => 'Autoscale', 'speed' => 'Interface Speed ('.formatRates($port['ifSpeed'], 4, 4).')');
foreach ($config['graphs']['ports_scale_list'] as $entry)
{
$speed = intval(unit_string_to_numeric($entry, 1000));
$speed = (int)unit_string_to_numeric($entry, 1000);
$speed_list[$entry] = formatRates($speed, 4, 4);
}
$form['row'][0]['scale'] = array(
@ -364,45 +391,45 @@ unset($vars['command_only']);
// Print options navbar
$navbar = array();
$navbar = [];
$navbar['brand'] = "Options";
$navbar['class'] = "navbar-narrow";
$navbar['options']['legend'] = array('text' => 'Show Legend', 'inverse' => TRUE);
$navbar['options']['previous'] = array('text' => 'Graph Previous');
$navbar['options']['legend'] = [ 'text' => 'Show Legend', 'inverse' => TRUE ];
$navbar['options']['title'] = [ 'text' => 'Show Title' ];
$navbar['options']['force_autoscale'] = [ 'text' => 'Force Autoscale' ];
$navbar['options']['previous'] = [ 'text' => 'Graph Previous' ];
if (in_array('trend', $graph_return['valid_options'])) {
$navbar['options']['trend'] = array('text' => 'Graph Trend');
if (in_array('95th', (array)$graph_return['valid_options'])) {
$navbar['options']['95th'] = [ 'text' => '95th %ile', 'inverse' => TRUE ];
}
if (in_array('trend', (array)$graph_return['valid_options'])) {
$navbar['options']['trend'] = [ 'text' => 'Graph Trend' ];
}
//$navbar['options']['max'] = array('text' => 'Graph Maximum');
if (in_array('inverse', $graph_return['valid_options'])) {
$navbar['options']['inverse'] = array('text' => 'Invert Graph');
if (in_array('inverse', (array)$graph_return['valid_options'])) {
$navbar['options']['inverse'] = [ 'text' => 'Invert Graph' ];
}
if (in_array('line_graph', $graph_return['valid_options'])) {
$navbar['options']['line_graph'] = array('text' => 'Line Graph');
if (in_array('line_graph', (array)$graph_return['valid_options'])) {
$navbar['options']['line_graph'] = [ 'text' => 'Line Graph' ];
}
$navbar['options_right']['showcommand'] = [ 'text' => 'RRD Command' ];
$navbar['options_right']['showcommand'] = array('text' => 'RRD Command');
foreach (array('options' => $navbar['options'], 'options_right' => $navbar['options_right'] ) as $side => $options)
{
foreach ($options AS $option => $array)
{
if ($array['inverse'] == TRUE)
{
if ($vars[$option] == "no")
{
foreach ([ 'options' => $navbar['options'], 'options_right' => $navbar['options_right'] ] as $side => $options) {
foreach ($options as $option => $array) {
if ($array['inverse']) {
if (isset($vars[$option]) && get_var_false($vars[$option])) {
$navbar[$side][$option]['url'] = generate_url($vars, array('page' => "graphs", $option => NULL));
} else {
$navbar[$side][$option]['url'] = generate_url($vars, array('page' => "graphs", $option => 'no'));
$navbar[$side][$option]['class'] .= " active";
}
} else {
if ($vars[$option] == "yes")
{
if (get_var_true($vars[$option])) {
$navbar[$side][$option]['url'] = generate_url($vars, array('page' => "graphs", $option => NULL));
$navbar[$side][$option]['class'] .= " active";
} else {
@ -622,7 +649,7 @@ LINE1:d95thout#aa0000';
echo generate_box_close();
}
#print_vars($graph_return);
//r($graph_return);
if (isset($vars['showcommand']))
{
@ -639,9 +666,16 @@ LINE1:d95thout#aa0000';
echo generate_box_open(array('title' => 'RRDTool Files Used', 'padding' => TRUE));
if (is_array($graph_return['rrds']))
{
foreach ($graph_return['rrds'] as $rrd)
foreach ($graph_return['rrds'] as $key => $val)
{
echo "$rrd <br />";
if(is_array($val))
{
echo "$key [";
echo "[".implode("] [", $val)."]";
echo "]<br />";
} else {
echo "$val <br />";
}
}
} else {
echo "No RRD information returned. This may be because the graph module doesn't yet return this data. <br />";

View File

@ -13,7 +13,7 @@
if (!is_array($vars['type'])) { $vars['type'] = [ $vars['type'] ]; }
$where = 'WHERE 1';
$where .= generate_query_values($vars['type'], 'port_descr_type', 'LIKE');
$where .= generate_query_values_and($vars['type'], 'port_descr_type', 'LIKE');
$where .= generate_query_permitted([ 'port' ]);
//$where .= $cache['where']['ports_permitted'];
@ -48,6 +48,10 @@ if ($port_count) {
$graph_array['type'] = 'multi-port_bits_separate';
$graph_array['to'] = get_time();
$graph_array['id'] = $port_list;
if($port_count > 10)
{
$graph_array['legend'] = 'no';
}
if ($port_compress) {
$graph_array['compressed'] = 1;
}

View File

@ -1,13 +1,12 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -31,7 +30,7 @@ echo generate_box_open();
echo('<table class="table table-hover table-striped table-condensed ">'. PHP_EOL);
//$location_where = generate_query_values($vars['location'], 'location');
//$location_where = generate_query_values_and($vars['location'], 'location');
$cols = array(
array(NULL, 'class="state-marker"'),
@ -57,7 +56,7 @@ echo(' </tr>');
foreach (get_locations() as $location)
{
$location_where = ' WHERE 1 ' . generate_query_values($location, 'location');
$location_where = ' WHERE 1 ' . generate_query_values_and($location, 'location');
$location_where .= $GLOBALS['cache']['where']['devices_permitted'];
$num = dbFetchCell('SELECT COUNT(*) FROM `devices`' . $location_where);
@ -67,11 +66,10 @@ foreach (get_locations() as $location)
if ($location === '') { $location = OBS_VAR_UNSET; }
$value = var_encode($location);
$name = escape_html($location);
echo('<tr class="'.$row_class.'">
<td class="state-marker"></td>
<td class="entity">' . generate_link($name, array('page' => 'devices', 'location' => $value)) . '</td>
<td class="entity">' . generate_link($location, array('page' => 'devices', 'location' => $value)) . '</td>
<td style="text-align: right;"><strong class="label label-success">' . $num . '</strong></td>' . PHP_EOL);
foreach (array_keys($cache['device_types']) as $type)
{

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,469 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
register_html_resource("js", "popper.core.js");
register_html_resource("js", "tippy.js");
register_html_resource("js", "cytoscape.min.js");
//register_html_resource("js", "cola.min.js");
//register_html_resource("js", "cytoscape-cola.js");
register_html_resource("js", "shim.min.js");
register_html_resource("js", "layout-base.js");
register_html_resource("js", "cose-base.js");
//register_html_resource("js", "cytoscape-cose-bilkent.js");
register_html_resource("js", "cytoscape-fcose.js");
register_html_resource("js", "cytoscape-layout-utilities.js");
//register_html_resource("js", "cytoscape-dagre.js");
register_html_resource("js", "cytoscape-popper.js");
//register_html_resource("js", "cytoscape-qtip.js");
//register_html_resource("css", "tippy-translucent.css");
$navbar['class'] = 'navbar-narrow';
$navbar['brand'] = 'Traffic Map';
$options = [ 'port_labels' => 'Port Labels' ];
foreach ($options as $option => $label) {
if (isset($vars[$option]) && $vars[$option]) {
$navbar['options'][$option]['class'] = 'active';
$navbar['options'][$option]['url'] = generate_url($vars, [ $option => NULL ]);
} else {
$navbar['options'][$option]['url'] = generate_url($vars, [ $option => 'YES' ]);
}
$navbar['options'][$option]['text'] = $label;
$navbar['options'][$option]['icon'] = $config['icon']['cef'];
}
// 'Devices' navbar menu
$navbar['options']['devices']['text'] = 'Devices';
$navbar['options']['devices']['class'] = 'dropdown-scrollable';
$navbar['options']['devices']['icon'] = $config['icon']['network'];
foreach(generate_form_values('device') AS $device_id => $device) {
$navbar['options']['devices']['suboptions'][$device_id]['text'] = $device['name'];
$navbar['options']['devices']['suboptions'][$device_id]['url'] = generate_url($vars, ['group' => NULL, 'device_id' => $device_id]);
if($vars['device_id'] == $device_id) {
$navbar['options']['devices']['text'] .= ' ('.$device['name'].')';
$navbar['options']['devices']['suboptions'][$device_id]['class'] = 'active';
}
}
// 'Groups' navbar menu
$navbar['options']['groups']['text'] = 'Groups';
$navbar['options']['groups']['class'] = 'dropdown-scrollable';
$navbar['options']['groups']['icon'] = $config['icon']['group'];
$groups = get_groups_by_type('device');
foreach($groups['device'] AS $group_id => $group) {
$navbar['options']['groups']['suboptions'][$group_id]['text'] = $group['group_name'];
$navbar['options']['groups']['suboptions'][$group_id]['url'] = generate_url($vars, ['group_id' => $group_id, 'device_id' => NULL]);
if($vars['group_id'] == $group_id) {
$navbar['options']['groups']['text'] .= ' ('.$group['group_name'].')';
$navbar['options']['groups']['class'] = 'active';
}
}
print_navbar($navbar);
unset($navbar);
function get_neighbour_map($vars)
{
global $cache;
$where = [ generate_query_permitted('device') ];
if (isset($vars['group_id'])) {
$device_id_list = get_group_entities($vars['group_id'], 'device');
if (count($device_id_list) > 0) {
$where[] = '('.generate_query_values_ng($device_id_list, 'device_id') . ' OR '. generate_query_values_ng($device_id_list, 'remote_device_id') . ')';
}
} elseif (isset($vars['device_id']) && $vars['device_id']) {
//$where[] = "(`device_id` = '".dbEscape($vars['device_id'])."' OR `remote_device_id` = '".dbEscape($vars['device_id'])."')";
$where[] = '('.generate_query_values_ng($vars['device_id'], 'device_id') . ' OR '. generate_query_values_ng($vars['device_id'], 'remote_device_id') . ')';
}
//r($where);
$where = implode(" AND ", $where);
$query = "SELECT * FROM `neighbours` WHERE `active` = '1' " . $where;
//r($query);
$neighbours = dbFetchRows($query);
$nodes = [];
$edges = [];
// Build device_id and port_id lists for cache
foreach ($neighbours as $neighbour) {
$device_list[$neighbour['device_id']] = $neighbour['device_id'];
if(is_numeric($neighbour['remote_device_id'])) { $device_list[$neighbour['remote_device_id']] = $neighbour['remote_device_id']; }
$port_list[$neighbour['port_id']] = $neighbour['port_id'];
if(is_numeric($neighbour['remote_port_id'])) { $port_list[$neighbour['remote_port_id']] = $neighbour['remote_port_id']; }
}
// Pre-populate cache with device and port info
cache_entities_by_id('device', $device_list);
cache_entities_by_id('port', $port_list);
//r(count($cache['device']));
//r(count($cache['port']));
foreach ($neighbours as $neighbour) {
// Is this a link to a known device? Do we have it already?
if (is_numeric($neighbour['remote_port_id'])) {
$remote_port = get_port_by_id_cache($neighbour['remote_port_id']);
// Do we have this source device already?
if (!isset($devices[$neighbour['device_id']])) {
$devices[$neighbour['device_id']] = device_by_id_cache($neighbour['device_id']);
}
// Suppress links to unknown devices
//$neighbour['remote_device_id'] = get_device_id_by_port_id($neighbour['remote_port_id']);
if (!is_numeric($neighbour['remote_device_id'])) {
continue;
}
// Suppress links to self
if ($neighbour['remote_device_id'] == $neighbour['device_id']) {
continue;
}
// Suppress duplicate links from other protocols and from other end of link
if (isset($link_exists[$neighbour['remote_port_id'] . '-' . $neighbour['port_id']]) || isset($link_exists[$neighbour['port_id'] . '-' . $neighbour['remote_port_id']])) {
continue;
}
if (!isset($devices[$neighbour['remote_device_id']])) {
$devices[$neighbour['remote_device_id']] = device_by_id_cache($neighbour['remote_device_id']);
}
$port = get_port_by_id_cache($neighbour['port_id']);
if ($port['ifInOctets_perc'] > $port['ifOutOctets_perc']) {
$port['percent'] = $port['ifInOctets_perc'];
}
else {
$port['percent'] = $port['ifOutOctets_perc'];
}
// Labels as in/out traffic
//$in_label = format_number($port['ifInOctets_rate'] * 8);
//$out_label = format_number($port['ifOutOctets_rate'] * 8);
// labels as port_label_short
$out_label = $port['port_label_short'];
$in_label = $remote_port['port_label_short'];
$in_colour = percent_colour($port['ifInOctets_perc'], 160);
$out_colour = percent_colour($port['ifOutOctets_perc'], 160);
// Out is from perspective of local node
$gradient = $out_colour . ' ' . $out_colour . ' ' . $in_colour . ' ' . $in_colour;
$edges[$neighbour['neighbour_id']] = ['source' => 'd'.$neighbour['device_id'],
'target' => 'd'.$neighbour['remote_device_id'],
'percent' => $port['percent'],
'percentin' => $port['ifInOctets_perc'],
'percentout' => $port['ifOutOctets_perc'],
'gradient' => $gradient,
'colourin' => $in_colour,
'colourout' => $out_colour,
'labelin' => $in_label,
'labelout' => $out_label,
'popupurl' => 'ajax/entity_popup.php?entity_type=port&entity_id=' . $port['port_id'],
//'label' => $port['percent'].'%'
];
if(!isset($vars['port_labels'])) {
unset($edges[$neighbour['neighbour_id']]['labelin']);
unset($edges[$neighbour['neighbour_id']]['labelout']);
}
if (is_numeric($neighbour['remote_port_id'])) { $link_exists[$port['port_id'] . '-' . $neighbour['remote_port_id']] = TRUE; }
}
else {
$external_id = string_to_id($neighbour['remote_hostname']);
$externals[$external_id] = ['id' => $external_id,
'label' => $neighbour['remote_hostname']];
}
}
foreach($devices AS $device)
{
$id = 'd' . $device['device_id'];
$parent_id = 'l'.string_to_id($device['location']);
$nodes[$id] = [ 'id' => $id,
'label' => short_hostname($device['hostname']),
'popupurl' => 'ajax/entity_popup.php?entity_type=device&entity_id=' . $device['device_id'],
'parent' => $parent_id];
// Add parent nodes
if (!isset($parents[$parent_id])) {
$nodes[$parent_id] = [ 'id' => $parent_id,
'label' => $device['location']];
}
}
return [ 'nodes' => $nodes, 'edges' => $edges, 'external_nodes' => $externals ];
}
$map = get_neighbour_map($vars);
?>
<style>
.tippy-tooltip.translucent-theme {
background-color: tomato;
color: yellow;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function () {
var settings = {
name: 'fcose',
animate: 'end',
animationEasing: 'ease-in-out',
animationDuration: 250,
//randomize: true,
quality: "proof",
fit: true,
padding: 30,
nodeDimensionsIncludeLabels: true,
uniformNodeDimensions: false,
packComponents: true,
step: "all",
samplingType: true,
sampleSize: 25,
nodeSeparation: 100,
piTol: 0.0000001,
nodeRepulsion: node => 4500,
idealEdgeLength: edge => 45,
edgeElasticity: edge => 0.45,
nestingFactor: 0.1,
numIter: 4500,
tile: true,
tilingPaddingVertical: 10,
tilingPaddingHorizontal: 10,
gravity: 0.25,
gravityRangeCompound: 1.5,
gravityCompound: 1.0,
gravityRange: 1.8,
initialEnergyOnIncremental: 0.3,
};
var cy = window.cy = cytoscape({
container: document.getElementById('cy'),
layout: settings,
style: [
{
selector: 'node',
style: {
'label': 'data(id)',
}
},
{
selector: 'node:parent',
style: {
'padding': 10,
'shape': 'roundrectangle',
'border-width': 0,
'background-color': '#c5c5c5',
},
},
{
selector: 'node:parent',
css: {
'background-opacity': 0.333
}
},
{
selector: 'edge',
'style': {
'target-arrow-shape': 'square',
'source-arrow-shape': 'square',
'curve-style': 'bezier',
'edge-text-rotation': "autorotate",
'source-text-rotation': "autorotate",
'target-text-rotation': "autorotate",
'width': 4,
}
},
{
selector: '[colourin]',
style: {
'source-arrow-color': 'data(colourout)',
'target-arrow-color': 'data(colourin)',
}
},
{
selector: '[name]',
style: {
'label': 'data(name)'
}
},
{
selector: '[label]',
style: {
'label': 'data(label)',
'text-background-color': '#c5c5c5',
'edge-text-rotation': "autorotate"
}
},
{
selector: '[label]',
css: {
'text-background-opacity': '0.333',
'text-background-padding': '2px',
'text-background-shape': 'roundrectangle',
}
},
{
selector: "node:childless",
style: {
'background-fit': 'cover',
'background-image': '/img/router.png',
//'background-image-opacity': 0.25,
//'background-color': '#FF0000',
//'border-width': 2,
//'border-color': '#c5c5c5',
//'border-opacity': 0.5,
}
},
{
selector: "[labelin]",
style: {
'target-label': 'data(labelin)',
'target-text-offset': '30px',
'text-halign': 'right',
'text-valign': 'center',
//'text-margin-x': '-10px',
//'text-margin-y': '-10px',
//'text-background-color': '#c5c5c5',
//'text-background-opacity': '0.5',
//'text-background-padding': '2px',
//'text-background-shape': 'roundrectangle',
}
},
{
selector: "[labelout]",
style: {
'source-label': 'data(labelout)',
'source-text-offset': '30px',
'text-halign': 'right',
'text-valign': 'center',
//'text-margin-x': '-10px',
//'text-margin-y': '-10px',
//'text-background-color': '#c5c5c5',
//'text-background-opacity': '0.5',
//'text-background-padding': '2px',
//'text-background-shape': 'roundrectangle',
}
},
{
selector: 'edge',
style: {
'line-fill': 'linear-gradient',
'line-gradient-stop-colors': 'data(gradient)',
'line-gradient-stop-positions': '0% 40% 50% 100%',
//'text-background-opacity': '0.5',
//'text-background-color': '#555555',
'curve-style': 'bezier',
}
}
],
<?php
echo 'elements: {'.PHP_EOL;
echo " 'nodes': [ ".PHP_EOL;
foreach ($map['nodes'] as $node) {
echo "{ data: ".json_encode($node)." },".PHP_EOL;
}
echo "],".PHP_EOL;
echo " 'edges': [ ".PHP_EOL;
foreach ($map['edges'] as $edge) {
echo "{ data: ".json_encode($edge)." },".PHP_EOL;
}
echo '],'.PHP_EOL;
echo '}'.PHP_EOL;
?>
});
document.getElementById("rearrangeButton").addEventListener("click", function () {
var layout = cy.layout(settings);
layout.run();
});
function makePopper(ele) {
let ref = ele.popperRef();
// FIXME - need some delay, otherwise it floods requests when moving mouse over large network
if (ele.data('popupurl')) {
ele.tippy = tippy(document.createElement('div'), {
// popperInstance will be available onCreate
//theme: 'translucent',
allowHTML: true,
followCursor: 'true',
hideOnClick: false,
maxWidth: 'none',
//trigger: 'click',
onShow(instance) {
fetch(ele.data('popupurl'), {
method: 'post'
})
.then((response) => response.text())
.then((text) => {
instance.setContent(text);
})
.catch((error) => {
// Fallback if the network request failed
instance.setContent(`Request failed. ${error}`);
});
},
});
ele.tippy.setContent('Node ' + ele.id());
}
}
cy.ready(function () {
cy.elements().forEach(function (ele) {
makePopper(ele);
});
});
cy.elements().unbind('mouseover');
cy.elements().bind('mouseover', (event) => event.target.tippy.show());
cy.elements().unbind('mouseout');
cy.elements().bind('mouseout', (event) => event.target.tippy.hide());
cy.elements().unbind('drag');
cy.elements().bind('drag', (event) => event.target.tippy.popperInstance.update());
});
</script>
<button class="btn" id="rearrangeButton" type="button">Re-arrange</button>
<div id="cy" style="width: 100%; height: 1000px;"></div>

View File

@ -1,5 +1,4 @@
<?php
/**
* Observium
*
@ -7,14 +6,14 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$neighbours_ports = dbFetchColumn('SELECT DISTINCT `port_id` FROM `neighbours` WHERE 1' . $cache['where']['ports_permitted']);
$where = ' WHERE 1 ';
$where .= generate_query_values($neighbours_ports, 'port_id');
$where .= generate_query_values_and($neighbours_ports, 'port_id');
//r($where);
$form_items = array();
@ -24,9 +23,9 @@ $form_items['devices'] = generate_form_values('device', dbFetchColumn('SELECT DI
// If device IDs passed, limit ports to specified devices
if ($vars['device'])
{
$neighbours_ports = dbFetchColumn('SELECT DISTINCT `port_id` FROM `ports`' . $where . generate_query_values($vars['device'], 'device_id'));
$neighbours_ports = dbFetchColumn('SELECT DISTINCT `port_id` FROM `ports`' . $where . generate_query_values_and($vars['device'], 'device_id'));
$where = ' WHERE 1 ';
$where .= generate_query_values($neighbours_ports, 'port_id');
$where .= generate_query_values_and($neighbours_ports, 'port_id');
//r($where);
}

View File

@ -1,13 +1,12 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -18,7 +17,7 @@ foreach ($vars as $var => $value)
switch ($var)
{
case 'name':
$where .= generate_query_values($value, $var);
$where .= generate_query_values_and($value, $var);
break;
}
}

View File

@ -34,7 +34,7 @@ $where_array = build_ports_where_array($vars);
$where = ' WHERE 1 ';
if (!$config['web_show_disabled'] && safe_count($cache['devices']['disabled']) > 0) {
$where_array[] = generate_query_values($cache['devices']['disabled'], 'ports.device_id', '!=');
$where_array[] = generate_query_values_and($cache['devices']['disabled'], 'ports.device_id', '!=');
}
$where .= implode('', $where_array);
//r($where_array);

View File

@ -50,18 +50,19 @@ echo generate_box_open();
echo '<table class="' . OBS_CLASS_TABLE_STRIPED . ' table-hover">' . PHP_EOL;
$cols = array(
array(NULL, 'class="state-marker"'),
array(NULL, 'style="width: 1px;"'),
'device' => array('Device', 'style="width: 200px;"'),
'port' => array('Port', 'style="width: 350px;"'),
'traffic' => array('Traffic', 'style="width: 100px;"'),
'traffic_perc' => array('Traffic %', 'style="width: 90px;"'),
'packets' => array('Packets', 'style="width: 90px;"'),
'speed' => array('Speed', 'style="width: 90px;"'),
'mac' => array('MAC Address', 'style="width: 150px;"')
'state-marker' => '',
[ NULL, 'style' => "width: 1px;" ],
'device' => [ 'device' => 'Device', 'style' => "min-width: 150px;" ],
[ 'port' => 'Port Name', 'descr' => 'Description', 'errors' => 'Errors', 'style' => "min-width: 250px;" ],
[ 'traffic' => ['Bits', 'subfields' => ['traffic_in' => 'In', 'traffic_out' => 'Out']], 'style' => "width: 100px;" ],
[ 'traffic_perc' => ['%', 'subfields' => ['traffic_perc_in' => 'In', 'traffic_perc_out' => 'Out']], 'style' => "width: 110px;" ],
[ 'packets' => ['Pkts', 'subfields' => ['packets_in' => 'In', 'packets_out' => 'Out']], 'style' => "width: 90px;" ],
[ 'speed' => 'Speed', 'mtu' => 'MTU', 'style' => "width: 90px;" ],
[ 'media' => 'Media', 'mac' => 'MAC', 'style' =>"width: 150px;" ]
);
echo get_table_header($cols, $vars);
//echo get_table_header_old($cols, $vars);
echo generate_table_header($cols, $vars);
echo '<tbody>' . PHP_EOL;
$ports_disabled = 0; $ports_down = 0; $ports_up = 0; $ports_total = 0;

View File

@ -82,7 +82,7 @@ humanize_user($user_data); // Get level_label, level_real, row_class, etc
<?php
foreach($roles as $role) {
echo '<tr><td><b>'.$role['role_name'].'</td><td>'.$role['role_descr'].'</td></tr>';
echo '<tr><td><b>'.escape_html($role['role_name']).'</td><td>'.escape_html($role['role_descr']).'</td></tr>';
//print_vars($role);
}

View File

@ -10,11 +10,10 @@
*
*/
// print_r($permissions);
// print_vars($permissions);
// Global write permissions required.
if ($_SESSION['userlevel'] < 10)
{
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
}
@ -804,7 +803,7 @@ if (isset($vars['role_id'])) {
echo '<td>' . $role['role_id'] . '</td>';
echo '<td><strong><a href="' . $role['edit_url'] . '">' . escape_html($role['role_name']) . '</a></strong></td>';
echo '<td><label class="label">' . $role['count'] . '</label></td>';
echo '<td>' . $role['role_descr'] . '</td>';
echo '<td>' . escape_html($role['role_descr']) . '</td>';
echo '</tr>';
}

View File

@ -11,10 +11,10 @@
*/
//if ($_SESSION['permissions'] < '5')
if ($_SESSION['userlevel'] < '5') {
print_error_permission();
return;
}
//if ($_SESSION['userlevel'] < '5') {
// print_error_permission();
// return;
//}
$form_items = [];
$form_limit = 250; // Limit count for multiselect (use input instead)
@ -245,9 +245,6 @@ foreach ($types as $option => $text) {
print_navbar($navbar);
unset($navbar);
// Pagination
$vars['pagination'] = TRUE;
//r($cache['bgp']);
print_bgp_peer_table($vars);

View File

@ -1,44 +1,44 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
register_html_title("Search");
$sections = array('ipv4' => 'IPv4 Address', 'ipv6' => 'IPv6 Address', 'mac' => 'MAC Address', 'arp' => 'ARP/NDP Tables', 'fdb' => 'FDB Tables');
$sections = [ 'ipv4' => 'IPv4 Address', 'ipv6' => 'IPv6 Address', 'mac' => 'MAC Address', 'arp' => 'ARP/NDP Tables', 'fdb' => 'FDB Tables' ];
//if (dbFetchCell("SELECT COUNT(wifi_session_id) FROM wifi_sessions") > '0')
if (dbExist('wifi_sessions'))
{
if (dbExist('wifi_sessions')) {
$sections['dot1x'] = '.1x Sessions'; // Can be extended to include all dot1x sessions
}
$navbar['brand'] = "Search";
$navbar['class'] = "navbar-narrow";
foreach ($sections as $section => $text)
{
foreach ($sections as $section => $text) {
$type = strtolower($section);
if (!isset($vars['search'])) { $vars['search'] = $section; }
if (!isset($vars['search'])) {
$vars['search'] = $section;
}
if ($vars['search'] == $section) { $navbar['options'][$section]['class'] = "active"; }
$navbar['options'][$section]['url'] = generate_url(array('page' => 'search', 'search' => $section));
if ($vars['search'] == $section) {
$navbar['options'][$section]['class'] = "active";
}
$navbar['options'][$section]['url'] = generate_url([ 'page' => 'search', 'search' => $section ]);
$navbar['options'][$section]['text'] = $text;
}
print_navbar($navbar);
/// Little switch to provide some sanity checking.
switch ($vars['search'])
{
switch ($vars['search']) {
case 'ipv4':
case 'ipv6':
case 'mac':

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -56,6 +56,11 @@ if (($vars['submit'] === 'save' || $vars['action'] === 'save') && request_token_
// $set_attribs = array(); // set obs_attribs
//print_warning($param);
//r($entry);
//r([ $param, $entry]);
// fixme: unreadable: unroll via array of variable names
$$param = $entry;
}
@ -64,7 +69,7 @@ if (($vars['submit'] === 'save' || $vars['action'] === 'save') && request_token_
// Set fields that were submitted with custom value
if (safe_count($sets)) {
$query = 'SELECT * FROM `config` WHERE ' . generate_query_values(array_keys($sets), 'config_key', NULL, FALSE);
$query = 'SELECT * FROM `config` WHERE ' . generate_query_values_ng(array_keys($sets), 'config_key');
// Fetch current rows in config file so we know which one to UPDATE and which one to INSERT
$in_db = [];
foreach (dbFetchRows($query) as $row) {
@ -90,7 +95,9 @@ if (($vars['submit'] === 'save' || $vars['action'] === 'save') && request_token_
// Delete fields that were reset to default
if (safe_count($deletes)) {
dbDelete('config', generate_query_values($deletes, 'config_key', NULL, FALSE));
dbDelete('config', generate_query_values_ng($deletes, 'config_key'));
//r(generate_query_values_ng($deletes, 'config_key'));
//r(dbError());
$updates++;
}

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -39,11 +39,11 @@ $form['row'][0]['device_id'] = array(
'values' => $form_items['devices']);
// Add device_id limit for other fields
$query_devices = generate_query_values($form_devices, 'device_id'); // Convert NOT IN to IN for correctly use indexes
$query_devices = generate_query_values_and($form_devices, 'device_id'); // Convert NOT IN to IN for correctly use indexes
if (isset($vars['device_id']))
{
$query_devices .= generate_query_values($vars['device_id'], 'device_id');
$where .= generate_query_values($vars['device_id'], 'device_id');
$query_devices .= generate_query_values_and($vars['device_id'], 'device_id');
$where .= generate_query_values_and($vars['device_id'], 'device_id');
}
// Message field

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
*
*/
@ -77,223 +77,6 @@ if (!$readonly && isset($vars['action']) &&
print_syslog_rules_table($vars);
function print_syslog_rules_table($vars)
{
if (isset($vars['la_id']))
{
$las = dbFetchRows("SELECT * FROM `syslog_rules` WHERE `la_id` = ?", array($vars['la_id']));
} else {
$las = dbFetchRows("SELECT * FROM `syslog_rules` ORDER BY `la_name`");
}
if (is_array($las) && count($las))
{
$modals = '';
$string = generate_box_open();
$string .= '<table class="table table-striped table-hover table-condensed">' . PHP_EOL;
$cols = array(
array(NULL, 'class="state-marker"'),
'name' => array('Name', 'style="width: 160px;"'),
'descr' => array('Description', 'style="width: 400px;"'),
'rule' => 'Rule',
'severity' => array('Severity', 'style="width: 60px;"'),
'disabled' => array('Status', 'style="width: 60px;"'),
'controls' => array('', 'style="width: 60px;"'),
);
$string .= get_table_header($cols, $vars);
foreach($las as $la)
{
if ($la['disable'] == 0) { $la['html_row_class'] = "up"; } else { $la['html_row_class'] = "disabled"; }
$string .= '<tr class="' . $la['html_row_class'] . '">';
$string .= '<td class="state-marker"></td>';
$string .= ' <td><strong><a href="'.generate_url(array('page' => 'syslog_rules', 'la_id' => $la['la_id'])).'">' . escape_html($la['la_name']) . '</a></strong></td>' . PHP_EOL;
$string .= ' <td><a href="'.generate_url(array('page' => 'syslog_rules', 'la_id' => $la['la_id'])).'">' . escape_html($la['la_descr']) . '</a></td>' . PHP_EOL;
$string .= ' <td><code>' . escape_html($la['la_rule']) . '</code></td>' . PHP_EOL;
$string .= ' <td>' . escape_html($la['la_severity']) . '</td>' . PHP_EOL;
$string .= ' <td>' . ($la['la_disable'] ? '<span class="label label-error">disabled</span>' : '<span class="label label-success">enabled</span>') . '</td>' . PHP_EOL;
$string .= ' <td style="text-align: right;">';
if ($_SESSION['userlevel'] >= 10)
{
$string .= '
<div class="btn-group btn-group-xs" role="group" aria-label="Rule actions">
<a class="btn btn-default" role="group" title="Edit" href="#modal-edit_syslog_rule_'.$la['la_id'].'" data-toggle="modal"><i class="icon-cog text-muted"></i></a>
<a class="btn btn-danger" role="group" title="Delete" href="#modal-delete_syslog_rule_'.$la['la_id'].'" data-toggle="modal"><i class="icon-trash"></i></a>
</div>';
}
$string .= '</td>';
$string .= ' </tr>' . PHP_EOL;
// Delete Rule Modal
$modal_args = array(
'id' => 'modal-delete_syslog_rule_' . $la['la_id'],
'title' => 'Delete Syslog Rule "'.escape_html($la['la_descr']).'"',
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
//'class' => 'modal-md',
);
$form = array('type' => 'horizontal',
'id' => 'delete_syslog_rule_' . $la['la_id'],
'userlevel' => 10, // Minimum user level for display form
'modal_args' => $modal_args, // !!! This generate modal specific form
//'help' => 'This will completely delete the rule and all associations and history.',
'class' => '', // Clean default box class!
'url' => generate_url(array('page' => 'syslog_rules'))
);
$form['fieldset']['body'] = array('class' => 'modal-body'); // Required this class for modal body!
$form['fieldset']['footer'] = array('class' => 'modal-footer'); // Required this class for modal footer!
$form['row'][0]['la_id'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => $la['la_id']);
$form['row'][0]['action'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => 'delete_syslog_rule');
$form['row'][5]['confirm'] = array(
'type' => 'checkbox',
'fieldset' => 'body',
'name' => 'Confirm',
'placeholder' => 'Yes, please delete this rule.',
'onchange' => "javascript: toggleAttrib('disabled', 'delete_button_".$la['la_id']."'); showDiv(!this.checked, 'warning_".$la['la_id']."_div');",
'value' => 'confirm');
$form['row'][6]['warning_'.$la['la_id']] = array(
'type' => 'html',
'fieldset' => 'body',
'html' => '<h4 class="alert-heading"><i class="icon-warning-sign"></i> Warning!</h4>' .
' This rule and all history will be completely deleted!',
'div_class' => 'alert alert-warning',
'div_style' => 'display:none;');
$form['row'][8]['close'] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => array('data-dismiss' => 'modal',
'aria-hidden' => 'true'));
$form['row'][9]['delete_button_'.$la['la_id']] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Delete Rule',
'icon' => 'icon-trash icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE,
'value' => 'delete_syslog_rule');
$modals .= generate_form_modal($form);
unset($form);
// Edit Rule Modal
$modal_args = array(
'id' => 'modal-edit_syslog_rule_' . $la['la_id'],
'title' => 'Edit Syslog Rule "'.escape_html($la['la_descr']).'"',
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
'class' => 'modal-lg',
);
$form = array('type' => 'horizontal',
'id' => 'edit_syslog_rule_' . $la['la_id'],
'userlevel' => 10, // Minimum user level for display form
'modal_args' => $modal_args, // !!! This generate modal specific form
//'help' => 'This will completely delete the rule and all associations and history.',
'class' => '', // Clean default box class!
'url' => generate_url(array('page' => 'syslog_rules'))
);
$form['fieldset']['body'] = array('class' => 'modal-body'); // Required this class for modal body!
$form['fieldset']['footer'] = array('class' => 'modal-footer'); // Required this class for modal footer!
$form['row'][0]['la_id'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => $la['la_id']);
$form['row'][3]['la_name'] = array(
'type' => 'text',
'fieldset' => 'body',
'name' => 'Rule Name',
'class' => 'input-xlarge',
'value' => escape_html($la['la_name']));
$form['row'][4]['la_descr'] = array(
'type' => 'textarea',
'fieldset' => 'body',
'name' => 'Description',
'class' => 'input-xxlarge',
//'style' => 'margin-bottom: 10px;',
'value' => escape_html($la['la_descr']));
$form['row'][5]['la_rule'] = array(
'type' => 'textarea',
'fieldset' => 'body',
'name' => 'Regular Expression',
'class' => 'input-xxlarge',
'value' => escape_html($la['la_rule']));
$form['row'][6]['la_disable'] = array(
'type' => 'switch-ng',
'fieldset' => 'body',
'name' => 'Status',
'on-text' => 'Disabled',
'on-color' => 'danger',
'off-text' => 'Enabled',
'off-color' => 'success',
'size' => 'small',
'value' => $la['la_disable']);
$form['row'][8]['close'] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => array('data-dismiss' => 'modal',
'aria-hidden' => 'true'));
$form['row'][9]['action'] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'edit_syslog_rule');
$modals .= generate_form_modal($form);
unset($form);
}
$string .= '</table>';
$string .= generate_box_close();
echo $string;
} else {
print_warning("There are currently no Syslog alerting filters defined.");
}
echo $modals;
}
if (isset($vars['la_id']))
{
// Pagination

View File

@ -1,19 +1,17 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// Global write permissions required.
if ($_SESSION['userlevel'] < 10)
{
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
}
@ -22,28 +20,30 @@ include($config['html_dir'].'/includes/user_menu.inc.php');
register_html_title("Add User");
if (auth_usermanagement())
{
if ($vars['submit'] == 'add_user' && request_token_valid($vars))
{
if ($vars['new_username'])
{
if (auth_usermanagement()) {
if ($vars['submit'] === 'add_user' && request_token_valid($vars)) {
if ($vars['new_username']) {
$vars['new_username'] = strip_tags($vars['new_username']);
if (!auth_user_exists($vars['new_username']))
{
if (isset($vars['can_modify_passwd']))
{
if (!is_valid_param($vars['new_username'], 'username')) {
print_error('User name contain not allowed chars or longer than 256.');
} elseif (!auth_user_exists($vars['new_username'])) {
if (isset($vars['can_modify_passwd'])) {
$vars['can_modify_passwd'] = 1;
} else {
$vars['can_modify_passwd'] = 0;
}
if (!$vars['new_password'])
{
if (!$vars['new_password']) {
print_warning("Please enter a password!");
}
else if (adduser($vars['new_username'], $vars['new_password'], $vars['new_level'], $vars['new_email'], $vars['new_realname'], $vars['can_modify_passwd'], $vars['new_description']))
{
} elseif (!is_valid_param($vars['new_password'], 'password')) {
print_error('Password contain non printable chars.');
} elseif (adduser($vars['new_username'],
$vars['new_password'],
$vars['new_level'],
$vars['new_email'],
$vars['new_realname'],
$vars['can_modify_passwd'],
$vars['new_description'])) {
print_success('User ' . escape_html($vars['new_username']) . ' added!');
}
} else {
@ -54,87 +54,102 @@ include($config['html_dir'].'/includes/user_menu.inc.php');
}
}
$form = array('type' => 'horizontal',
'id' => 'add_user',
//'space' => '20px',
//'title' => 'Add User',
);
$form = [
'type' => 'horizontal',
'id' => 'add_user',
//'space' => '20px',
//'title' => 'Add User',
];
// top row div
$form['fieldset']['user'] = array('div' => 'top',
'title' => 'User Properties',
'icon' => $config['icon']['user-edit'],
'class' => 'col-md-6');
$form['fieldset']['info'] = array('div' => 'top',
'title' => 'Optional Information',
'icon' => $config['icon']['info'],
//'right' => TRUE,
'class' => 'col-md-6 col-md-pull-0');
$form['fieldset']['user'] = [
'div' => 'top',
'title' => 'User Properties',
'icon' => $config['icon']['user-edit'],
'class' => 'col-md-6'
];
$form['fieldset']['info'] = [
'div' => 'top',
'title' => 'Optional Information',
'icon' => $config['icon']['info'],
//'right' => TRUE,
'class' => 'col-md-6 col-md-pull-0'
];
// bottom row div
$form['fieldset']['submit'] = array('div' => 'bottom',
'style' => 'padding: 0px;',
'class' => 'col-md-12');
$form['fieldset']['submit'] = [
'div' => 'bottom',
'style' => 'padding: 0px;',
'class' => 'col-md-12'
];
//$form['row'][0]['editing'] = array(
// 'type' => 'hidden',
// 'value' => 'yes');
// left fieldset
$form['row'][1]['new_username'] = array(
'type' => 'text',
'fieldset' => 'user',
'name' => 'Username',
'width' => '250px',
'value' => escape_html($vars['new_username']));
$form['row'][2]['new_password'] = array(
'type' => 'password',
'fieldset' => 'user',
'name' => 'Password',
'width' => '250px',
'show_password' => TRUE,
'value' => escape_html($vars['new_password'])); // FIXME. For passwords we should use filter instead escape!
$form['row'][3]['can_modify_passwd'] = array(
'type' => 'toggle',
'view' => 'toggle',
'fieldset' => 'user',
'name' => '',
'placeholder' => 'Allow the user to change his password',
'value' => 1);
$form['row'][4]['new_realname'] = array(
'type' => 'text',
'fieldset' => 'user',
'name' => 'Real Name',
'width' => '250px',
'value' => escape_html($vars['new_realname']));
$form['row'][5]['new_level'] = array(
'type' => 'select',
'fieldset' => 'user',
'name' => 'User Level',
'width' => '250px',
'subtext' => TRUE,
'values' => $GLOBALS['config']['user_level'],
'value' => (isset($vars['new_level']) ? escape_html($vars['new_level']) : 1));
$form['row'][1]['new_username'] = [
'type' => 'text',
'fieldset' => 'user',
'name' => 'Username',
'width' => '250px',
'value' => $vars['new_username']
];
$form['row'][2]['new_password'] = [
'type' => 'password',
'fieldset' => 'user',
'name' => 'Password',
'width' => '250px',
'show_password' => TRUE,
'value' => $vars['new_password']
];
$form['row'][3]['can_modify_passwd'] = [
'type' => 'toggle',
'view' => 'toggle',
'fieldset' => 'user',
'name' => '',
'placeholder' => 'Allow the user to change his password',
'value' => 1
];
$form['row'][4]['new_realname'] = [
'type' => 'text',
'fieldset' => 'user',
'name' => 'Real Name',
'width' => '250px',
'value' => $vars['new_realname']
];
$form['row'][5]['new_level'] = [
'type' => 'select',
'fieldset' => 'user',
'name' => 'User Level',
'width' => '250px',
'subtext' => TRUE,
'values' => $GLOBALS['config']['user_level'],
'value' => isset($vars['new_level']) ? $vars['new_level'] : 1
];
// right fieldset
$form['row'][15]['new_email'] = array(
'type' => 'text',
'fieldset' => 'info',
'name' => 'E-mail',
'width' => '250px',
'value' => escape_html($vars['new_email']));
$form['row'][16]['new_description'] = array(
'type' => 'text',
'fieldset' => 'info',
'name' => 'Description',
'width' => '250px',
'value' => escape_html($vars['new_description']));
$form['row'][15]['new_email'] = [
'type' => 'text',
'fieldset' => 'info',
'name' => 'E-mail',
'width' => '250px',
'value' => $vars['new_email']
];
$form['row'][16]['new_description'] = [
'type' => 'text',
'fieldset' => 'info',
'name' => 'Description',
'width' => '250px',
'value' => $vars['new_description']
];
$form['row'][30]['submit'] = array(
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Add User',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'add_user');
$form['row'][30]['submit'] = [
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Add User',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'add_user'
];
print_form_box($form);
unset($form);

View File

@ -6,14 +6,13 @@
*
* @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
*
*/
register_html_title("Edit user");
if ($_SESSION['userlevel'] < 10)
{
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
}
@ -43,45 +42,51 @@ register_html_resource('js', 'observium-entities.js');
// FIXME, currently users list more than 1000 have troubles with memory use
// Do not generate this unusable dropdown form, need to switch ajax input
if (safe_count($user_list) <= 512) {
$item = array('id' => 'page',
'value' => 'user_edit');
$item = [
'id' => 'page',
'value' => 'user_edit'
];
echo(generate_form_element($item, 'hidden'));
$item = array('id' => 'user_id',
'title' => 'Select User',
'width' => '150px',
'onchange' => "location.href='user_edit/user_id=' + this.options[this.selectedIndex].value + '/';",
'values' => $user_list,
'value' => $vars['user_id']);
$item = [
'id' => 'user_id',
'title' => 'Select User',
'width' => '150px',
'onchange' => "location.href='user_edit/user_id=' + this.options[this.selectedIndex].value + '/';",
'values' => $user_list,
'value' => $vars['user_id']
];
echo(generate_form_element($item, 'select'));
}
echo('
</li>
</ul>');
if ($vars['user_id'])
{
if ($vars['user_id']) {
// Load the user's information
if (isset($user_list[$vars['user_id']]))
{
if (isset($user_list[$vars['user_id']])) {
$user_data = $user_list[$vars['user_id']];
} else {
$user_data = dbFetchRow("SELECT * FROM `users` WHERE `user_id` = ?", array($vars['user_id']));
$user_data = dbFetchRow("SELECT * FROM `users` WHERE `user_id` = ?", [ $vars['user_id'] ]);
}
$user_data['username'] = auth_username_by_id($vars['user_id']);
$user_data['level'] = auth_user_level($user_data['username']);
if (!isset($user_data['username'])) {
$user_data['username'] = auth_username_by_id($vars['user_id']);
}
if (!isset($user_data['level']) && !is_numeric($user_data['level'])) {
$user_data['level'] = auth_user_level($user_data['username']);
}
humanize_user($user_data); // Get level_label, level_real, row_class, etc
// Delete the selected user.
if (auth_usermanagement() && $vars['user_id'] !== $_SESSION['user_id'])
{
if (auth_usermanagement() && $vars['user_id'] !== $_SESSION['user_id']) {
echo('<ul class="nav pull-right">');
echo('<li><a href="'.generate_url(array('page' => 'user_edit',
'action' => 'deleteuser',
'user_id' => $vars['user_id'],
'confirm' => 'yes',
'requesttoken' => $_SESSION['requesttoken'])) . '"
echo('<li><a href="'.generate_url([ 'page' => 'user_edit',
'action' => 'deleteuser',
'user_id' => $vars['user_id'],
'confirm' => 'yes',
'requesttoken' => $_SESSION['requesttoken'] ]) . '"
data-toggle="confirmation"
data-confirm-content="You have requested deletion of the user <strong>'.$user_data['username'].'</strong>.<br />This action can not be reversed."
data-confirm-content="You have requested deletion of the user <strong>'.escape_html($user_data['username']).'</strong>.<br />This action can not be reversed."
data-confirm-placement="bottom">
<i class="'.$config['icon']['cancel'].'"></i> Delete User</a></li>');
echo('</ul>');
@ -98,45 +103,36 @@ register_html_resource('js', 'observium-entities.js');
</form>
<?php
if ($vars['user_id'])
{
if ($vars['user_id']) {
// Check if correct auth secret passed
$auth_secret_fail = empty($_SESSION['auth_secret']) || empty($vars['auth_secret']) || !hash_equals($_SESSION['auth_secret'], $vars['auth_secret']);
//print_vars($auth_secret_fail);
//$auth_secret_fail = TRUE;
if ($vars['action'] == "deleteuser" && request_token_valid($vars))
{
if ($vars['action'] == "deleteuser" && request_token_valid($vars)) {
include($config['html_dir']."/pages/edituser/deleteuser.inc.php");
} else {
// Perform actions if requested
if (auth_usermanagement() && isset($vars['action']) && request_token_valid($vars)) // Admins always can change user info & password
{
switch($vars['action'])
{
if (auth_usermanagement() && isset($vars['action']) && request_token_valid($vars)) { // Admins always can change user info & password
switch($vars['action']) {
case "changepass":
if ($vars['new_pass'] == "" || $vars['new_pass2'] == "")
{
if ($vars['new_pass'] == "" || $vars['new_pass2'] == "") {
print_warning("Password cannot be blank.");
}
elseif ($auth_secret_fail)
{
} elseif ($auth_secret_fail) {
// Incorrect auth secret, seems as someone try to hack system ;)
print_debug("Incorrect admin auth, get out from here nasty hacker.");
}
elseif ($vars['new_pass'] == $vars['new_pass2'])
{
} elseif ($vars['new_pass'] === $vars['new_pass2'] &&
is_valid_param($vars['new_pass'], 'password')) {
$status = auth_change_password($user_data['username'], $vars['new_pass']);
if ($status)
{
if ($status) {
print_success("Password Changed.");
} else {
print_error("Password not changed.");
}
} else {
print_error("Passwords don't match!");
print_error("Passwords don't match or contain non printable chars.");
}
break;
@ -145,15 +141,16 @@ register_html_resource('js', 'observium-entities.js');
// Incorrect auth secret, seems as someone try to hack system ;)
print_debug("Incorrect admin auth, get out from here nasty hacker.");
} else {
$update_array = array();
$update_array = [];
$vars['new_can_modify_passwd'] = (isset($vars['new_can_modify_passwd']) && $vars['new_can_modify_passwd'] ? 1 : 0);
foreach (array('realname', 'level', 'email', 'descr', 'can_modify_passwd') as $param) {
foreach ([ 'realname', 'level', 'email', 'descr', 'can_modify_passwd' ] as $param) {
if ($vars['new_' . $param] != $user_data[$param]) {
$update_array[$param] = $vars['new_' . $param];
}
}
$status = FALSE;
if (count($update_array)) {
$status = dbUpdate($update_array, 'users', '`user_id` = ?', array($vars['user_id']));
$status = dbUpdate($update_array, 'users', '`user_id` = ?', [ $vars['user_id'] ]);
}
if ($status) {
print_success("User Info Changed.");
@ -186,7 +183,7 @@ register_html_resource('js', 'observium-entities.js');
$vars['entity_id'] = $vars[$vars['entity_type'].'_entity_id'];
}
$where = '`user_id` = ? AND `entity_type` = ? AND `auth_mechanism` = ?' . generate_query_values($vars['entity_id'], 'entity_id');
$where = '`user_id` = ? AND `entity_type` = ? AND `auth_mechanism` = ?' . generate_query_values_and($vars['entity_id'], 'entity_id');
$params = [ $vars['user_id'], $vars['entity_type'], $config['auth_mechanism'] ];
//if (@dbFetchCell("SELECT COUNT(*) FROM `entity_permissions` WHERE " . $where, array($vars['user_id'], $vars['entity_type'])))
if (dbExist('entity_permissions', $where, $params))
@ -194,28 +191,25 @@ register_html_resource('js', 'observium-entities.js');
dbDelete('entity_permissions', $where, $params);
}
}
}
elseif (($vars['submit'] == "user_perm_add" || $vars['action'] == "user_perm_add") && request_token_valid($vars))
{
if ($auth_secret_fail)
{
} elseif (($vars['submit'] == "user_perm_add" || $vars['action'] == "user_perm_add") &&
request_token_valid($vars)) {
if ($auth_secret_fail) {
// Incorrect auth secret, seems as someone try to hack system ;)
print_debug("Incorrect admin auth, get out from here nasty hacker.");
} else {
if (isset($vars['entity_id'])) {} // use entity_id
elseif (isset($vars[$vars['entity_type'].'_entity_id'])) // use type_entity_id
{
if (isset($vars['entity_id'])) { // use entity_id
} elseif (isset($vars[$vars['entity_type'].'_entity_id'])) { // use type_entity_id
$vars['entity_id'] = $vars[$vars['entity_type'].'_entity_id'];
}
if (!is_array($vars['entity_id'])) { $vars['entity_id'] = array($vars['entity_id']); }
if (!is_array($vars['entity_id'])) {
$vars['entity_id'] = [ $vars['entity_id'] ];
}
foreach ($vars['entity_id'] as $entry)
{
foreach ($vars['entity_id'] as $entry) {
$where = '`user_id` = ? AND `entity_type` = ? AND `entity_id` = ? AND `auth_mechanism` = ?';
$params = [ $vars['user_id'], $vars['entity_type'], $entry, $config['auth_mechanism'] ];
if (get_entity_by_id_cache($vars['entity_type'], $entry) && // Skip not exist entities
!dbExist('entity_permissions', $where, $params))
{
!dbExist('entity_permissions', $where, $params)) {
dbInsert([ 'entity_id' => $entry, 'entity_type' => $vars['entity_type'], 'user_id' => $vars['user_id'], 'auth_mechanism' => $config['auth_mechanism'] ], 'entity_permissions');
}
}
@ -264,6 +258,10 @@ register_html_resource('js', 'observium-entities.js');
<th>Description</th>
<td><?php echo(escape_html($user_data['descr'])); ?></td>
</tr>
<tr>
<th>User Source</th>
<td><?php echo(get_type_class_label($user_data['type'], 'user_type')); ?></td>
</tr>
</table>
<div class="form-actions" style="margin: 0;">
@ -431,8 +429,8 @@ register_html_resource('js', 'observium-entities.js');
echo '<tr>';
echo '<td width="5"></td>';
echo '<td width="200" class="entity">' . $role['role_name'] . '</td>';
echo '<td>' . $role['role_descr'] . '</td>';
echo '<td width="200" class="entity">' . escape_html($role['role_name']) . '</td>';
echo '<td>' . escape_html($role['role_descr']) . '</td>';
echo '<td width="40">';
$form = array('type' => 'simple');
@ -1042,6 +1040,7 @@ register_html_resource('js', 'observium-entities.js');
echo('<td><i class="'.$user['icon'].'"></i> <span class="label label-'.$user['label_class'].'">'.$user['level_label'].'</span></td>');
echo('<td><strong>'.escape_html($user['realname']).'</strong></td>');
echo('<td><strong>'.escape_html($user['email']).'</strong></td>');
echo '<td>'.get_type_class_label($user['type'], 'user_type').'</td>';
echo('</tr>');
}

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
*
*/
@ -173,7 +173,7 @@ if ($_SESSION['userlevel'] < 5) {
$mac_list = array_column($macs, 'mac_address');
$sql = "SELECT * FROM ports, devices WHERE 1 ";
$sql .= generate_query_values($mac_list, 'ifPhysAddress');
$sql .= generate_query_values_and($mac_list, 'ifPhysAddress');
$sql .= " AND ports.device_id = devices.device_id";
$ports = [];

132
html/pages/wmap.inc.php Normal file
View File

@ -0,0 +1,132 @@
<?php
/*
<div class="navbar navbar-narrow" style="">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target="#nav-0uGMD3QMVHudRAti">
<span class="oicon-bar"></span>
</button>
<a class="brand ">Weathermap</a><div class="nav-collapse" id="nav-0uGMD3QMVHudRAti">
<ul class="nav">
<li class=""><a id="tb_newfile">Change File</a></li>
<li class=""><a id="tb_addnode">Add Node</a></li>
<li class=""><a id="tb_addlink">Add Link</a></li>
<li class=""><a id="tb_poslegend">Move Legend</a></li>
<li class=""><a id="tb_postime">Move Timestamp</a></li>
<li class=""><a id="tb_mapprops">Map Properties</a></li>
<li class=""><a id="tb_mapstyle">Map Style</a></li>
<!-- <li class=""><a id="tb_colours">Manage Colors</a></li> -->
<!-- <li class=""><a id="tb_manageimages">Manage Images</a></li> -->
<li class=""><a id="tb_prefs">Editor Settings</a></li>
<li class=""><a id="tb_coords">Position ----, ---</a></li>
<li class="tb_help"><span id="tb_help">or click a Node or Link to edit it's properties</span></li>
</div>
</div>
</div>
</div>
*/
if($_SESSION['userlevel'] > 5 && $config['weathermap']['enable']) {
$navbar['class'] = 'navbar-narrow';
$navbar['brand'] = 'Weathermaps';
// Allow use of wmap_id as well as mapname
if (isset($vars['wmap_id'])) {
$vars['mapname'] = dbFetchCell("SELECT `wmap_name` FROM `weathermaps` WHERE `wmap_id` = ?", array($vars['wmap_id']));
}
if (isset($vars['mapname']) && dbExist("weathermaps", "`wmap_name` = ?", array($vars['mapname']))) {
if ($_SESSION['userlevel'] > 7) {
$editing = TRUE;
}
} else {
unset($vars['mapname']);
}
//$editing = TRUE;
if ($editing === TRUE) {
$navbar['options']['add_node']['text'] = 'Add Node';
$navbar['options']['add_node']['id'] = 'tb_addnode';
$navbar['options']['add_link']['text'] = 'Add Link';
$navbar['options']['add_link']['id'] = 'tb_addlink';
/* Disabled for space reasons. Can move these by clicking the elements directly.
$navbar['options']['tb_poslegend']['text'] = 'Move Legend';
$navbar['options']['tb_poslegend']['id'] = 'tb_poslegend';
$navbar['options']['tb_postime']['text'] = 'Move Time';
$navbar['options']['tb_postime']['id'] = 'tb_postime';
*/
$navbar['options']['tb_mapprops']['text'] = 'Map Properties';
$navbar['options']['tb_mapprops']['id'] = 'tb_mapprops';
$navbar['options']['tb_mapstyle']['text'] = 'Map Style';
$navbar['options']['tb_mapstyle']['id'] = 'tb_mapstyle';
$navbar['options']['tb_prefs']['text'] = 'Settings';
$navbar['options']['tb_prefs']['id'] = 'tb_prefs';
$navbar['options_right']['help']['id'] = 'tb_help';
$navbar['options_right']['help']['text'] = '';
$navbar['options_right']['tb_coords']['text'] = 'Return to List';
$navbar['options_right']['tb_coords']['icon'] = 'sprite-return';
$navbar['options_right']['tb_coords']['url'] = generate_url(array('page' => "wmap"));
$navbar['options_right']['tb_coords']['id'] = 'tb_coords';
} else if (isset($vars['mapname'])) {
// $navbar['options_right']['edit']['text'] = 'Edit Map';
// $navbar['options_right']['edit']['icon'] = 'sprite-cog';
// $navbar['options_right']['edit']['url'] = generate_url(array('page' => "wmap", 'mapname' => $vars['mapname'], 'edit' => TRUE));
}
// Print out the navbar defined above
print_navbar($navbar);
unset($navbar);
if (isset($vars['mapname'])) {
if ($editing === TRUE) {
include($config['install_dir'] . "/includes/weathermap/editor.php");
} else {
echo '<div class="box box-solid">';
echo '<img src="/weathermap.php?mapname=' . htmlentities($vars['mapname']) . '&action=draw&unique=' . time() . '">';
echo '</div>';
}
} else {
echo '<div class="row">';
foreach (dbFetchRows("SELECT * FROM `weathermaps`") as $wmap) {
echo '
<div class="box box-solid" style="float: left; margin-left: 10px; margin-bottom: 10px; width:612px; min-width: 612px; max-width:612px; min-height:500px; max-height:500px;">
<div class="box-header with-border">
<a href="' . generate_url(array('page' => "wmap", 'mapname' => $wmap['wmap_name'])) . '"><h3 class="box-title">' . htmlentities($wmap['wmap_name']) . '</h3>
</a>
</div>
<div class="box-body">
<div style="position:absolute; width:100%; height:100%">
<a href="' . generate_url(array('page' => "wmap", 'mapname' => $wmap['wmap_name'])) . '">
<img src="/weathermap.php?mapname=' . htmlentities($wmap['wmap_name']) . '&action=draw&unique=' . time() . '&width=590&height=490">
</a>
</div>
</div>
</div>
';
}
echo '</div>';
}
} else {
print_error("Not Permitted");
}
?>