commit version 22.12.12447
This commit is contained in:
@ -1,25 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) // Only valid forms from level 10 users
|
||||
{
|
||||
if (strlen($vars['role_name']) &&
|
||||
strlen($vars['role_descr']))
|
||||
{
|
||||
$oid_id = dbInsert('roles', array('role_descr' => $vars['role_descr'],
|
||||
'role_name' => $vars['role_name'])
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) { // Only valid forms from level 10 users
|
||||
if (!safe_empty($vars['role_name']) &&
|
||||
!safe_empty($vars['role_descr'])) {
|
||||
$oid_id = dbInsert('roles', [ 'role_descr' => $vars['role_descr'],
|
||||
'role_name' => $vars['role_name'] ]
|
||||
);
|
||||
|
||||
if ($oid_id)
|
||||
{
|
||||
if ($oid_id) {
|
||||
print_success("<strong>SUCCESS:</strong> Added role");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print_warning("<strong>WARNING:</strong> Role not added");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print_error("<strong>ERROR:</strong> All fields must be completed to add a new role.");
|
||||
}
|
||||
}
|
||||
@ -6,42 +6,45 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) // Only valid forms from level 10 users
|
||||
{
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) { // Only valid forms from level 10 users
|
||||
|
||||
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 $entity_id)
|
||||
{
|
||||
if (get_entity_by_id_cache($vars['entity_type'], $entity_id)) // Skip not exist entities
|
||||
{
|
||||
$changed = 0;
|
||||
foreach ($vars['entity_id'] as $entity_id) {
|
||||
if (get_entity_by_id_cache($vars['entity_type'], $entity_id)) { // Skip not exist entities
|
||||
if (!dbExist('roles_entity_permissions', '`role_id` = ? AND `entity_type` = ? AND `entity_id` = ?',
|
||||
array($vars['role_id'], $vars['entity_type'], $entity_id)
|
||||
))
|
||||
{
|
||||
[ $vars['role_id'], $vars['entity_type'], $entity_id ])) {
|
||||
|
||||
if(!in_array($vars['access'], array('ro', 'rw'))) { $vars['access'] = 'ro'; }
|
||||
if (!in_array($vars['access'], [ 'ro', 'rw' ])) {
|
||||
$vars['access'] = 'ro';
|
||||
}
|
||||
|
||||
dbInsert(array('entity_id' => $entity_id, 'entity_type' => $vars['entity_type'], 'role_id' => $vars['role_id'], 'access' => $vars['access']),
|
||||
'roles_entity_permissions'
|
||||
);
|
||||
dbInsert([ 'entity_id' => $entity_id, 'entity_type' => $vars['entity_type'], 'role_id' => $vars['role_id'], 'access' => $vars['access'] ],
|
||||
'roles_entity_permissions');
|
||||
$changed++;
|
||||
}
|
||||
} else { print_error('Error: Invalid Entity.'); }
|
||||
} else {
|
||||
print_error('Error: Invalid Entity.');
|
||||
}
|
||||
}
|
||||
|
||||
// Reset permissions cache
|
||||
if ($changed) { set_cache_clear('wui'); }
|
||||
unset($changed);
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
@ -6,32 +6,31 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) // Only valid forms from level 10 users
|
||||
{
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) { // Only valid forms from level 10 users
|
||||
|
||||
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'];
|
||||
}
|
||||
|
||||
$where = '`role_id` = ? AND `entity_type` = ?' . generate_query_values($vars['entity_id'], 'entity_id');
|
||||
$where = '`role_id` = ? AND `entity_type` = ?' . generate_query_values_and($vars['entity_id'], 'entity_id');
|
||||
//if (@dbFetchCell("SELECT COUNT(*) FROM `entity_permissions` WHERE " . $where, array($vars['user_id'], $vars['entity_type'])))
|
||||
if (dbExist('roles_entity_permissions', $where, array($vars['role_id'], $vars['entity_type'])))
|
||||
{
|
||||
if (dbExist('roles_entity_permissions', $where, [ $vars['role_id'], $vars['entity_type'] ])) {
|
||||
dbDelete('roles_entity_permissions', $where, array($vars['role_id'], $vars['entity_type']));
|
||||
|
||||
//print_vars(dbError());
|
||||
|
||||
} else { }
|
||||
// Reset permissions cache
|
||||
set_cache_clear('wui');
|
||||
}
|
||||
}
|
||||
|
||||
echo ("nope"); // Hrm?
|
||||
//echo ("nope"); // Hrm?
|
||||
|
||||
// EOF
|
||||
|
||||
@ -6,11 +6,10 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/// CONTACTS ACTIONS
|
||||
|
||||
$readonly = $_SESSION['userlevel'] < 10;
|
||||
@ -60,7 +59,7 @@ if (!$readonly)
|
||||
$exist_contacts = dbFetchColumn('SELECT `contact_id` FROM `alert_contacts_assoc` WHERE `aca_type` = ? AND `alert_checker_id` = ?', array('alert', $vars['alert_test_id']));
|
||||
//print_vars($exist_contacts);
|
||||
$sql = "SELECT `contact_id` FROM `alert_contacts` WHERE `contact_disabled` = 0 AND `contact_method` != 'syscontact'" .
|
||||
generate_query_values($exist_contacts, 'contact_id', '!='); // exclude exist contacts
|
||||
generate_query_values_and($exist_contacts, 'contact_id', '!='); // exclude exist contacts
|
||||
//print_vars($sql);
|
||||
foreach (dbFetchColumn($sql) as $contact_id)
|
||||
{
|
||||
|
||||
@ -262,4 +262,12 @@ function auth_user_info($username)
|
||||
}
|
||||
}
|
||||
|
||||
// Create placeholder user for users logged in via non-MySQL mechanisms to enable user list
|
||||
function create_mysql_user($username, $userid, $level = '1', $type = 'mysql')
|
||||
{
|
||||
if(isset($username) && isset($userid) && is_numeric($userid)) {
|
||||
dbInsert(array('username' => $username, 'user_id' => $userid, 'level' => $level, 'type' => $type), 'users');
|
||||
}
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage authentication
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -23,15 +23,19 @@ define('OBS_AJAX', (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SE
|
||||
|
||||
$debug_auth = FALSE; // Do not use this debug unless you Observium Developer ;)
|
||||
|
||||
if (PHP_VERSION_ID < 70100)
|
||||
{
|
||||
if (PHP_VERSION_ID < 70100) {
|
||||
// Use sha1 to generate the session ID (option removed in php 7.1)
|
||||
// session.sid_length (Number of session ID characters - 22 to 256.
|
||||
// session.sid_bits_per_character (Bits used per character - 4 to 6.
|
||||
@ini_set('session.hash_function', '1');
|
||||
}
|
||||
|
||||
@ini_set('session.referer_check', ''); // This config was causing so much trouble with Chrome
|
||||
@ini_set('session.name', 'OBSID'); // Session name
|
||||
if (OBS_API) {
|
||||
@ini_set('session.name', 'OBSAPI'); // Session name for API
|
||||
} else {
|
||||
@ini_set('session.name', 'OBSID'); // Session name for common Web UI
|
||||
}
|
||||
@ini_set('session.use_cookies', '1'); // Use cookies to store the session id on the client side
|
||||
@ini_set('session.use_only_cookies', '1'); // This prevents attacks involved passing session ids in URLs
|
||||
@ini_set('session.use_trans_sid', '0'); // Disable SID (no session id in url)
|
||||
@ -48,13 +52,13 @@ $cookie_httponly = FALSE;
|
||||
//$cookie_httponly = TRUE;
|
||||
|
||||
// Use custom session lifetime
|
||||
if (is_numeric($GLOBALS['config']['web_session_lifetime']) && $GLOBALS['config']['web_session_lifetime'] >= 0) {
|
||||
if (is_intnum($GLOBALS['config']['web_session_lifetime']) && $GLOBALS['config']['web_session_lifetime'] >= 0) {
|
||||
$lifetime = (int)$GLOBALS['config']['web_session_lifetime'];
|
||||
}
|
||||
|
||||
@ini_set('session.gc_maxlifetime', $lifetime); // Session lifetime (for non "remember me" sessions)
|
||||
if (PHP_VERSION_ID >= 70300)
|
||||
{
|
||||
|
||||
if (PHP_VERSION_ID >= 70300) {
|
||||
// Allows servers to assert that a cookie ought not to be sent along with cross-site requests.
|
||||
// Lax will sent the cookie for cross-domain GET requests, while Strict will not
|
||||
//@ini_set('session.cookie_samesite', 'Strict');
|
||||
@ -64,7 +68,7 @@ if (PHP_VERSION_ID >= 70300)
|
||||
'domain' => $cookie_domain,
|
||||
'secure' => $cookie_https,
|
||||
'httponly' => $cookie_httponly,
|
||||
'samesite' => 'Strict'
|
||||
'samesite' => 'Lax' // 'Strict' /// FIXME. Set this configurable? See: https://jira.observium.org/browse/OBS-4214
|
||||
];
|
||||
session_set_cookie_params($cookie_params);
|
||||
} else {
|
||||
@ -77,28 +81,24 @@ if (!session_is_active()) {
|
||||
session_regenerate();
|
||||
}
|
||||
|
||||
if ($debug_auth && empty($_SESSION['authenticated']))
|
||||
{
|
||||
if ($debug_auth && empty($_SESSION['authenticated'])) {
|
||||
logfile('debug_auth.log', __LINE__ . " NOT Authenticated!!!. IP=[" . get_remote_addr($config['web_session_ip_by_header']) . "]. URL=[" . $_SERVER['REQUEST_URI'] . "]");
|
||||
logfile('debug_auth.log', __LINE__ . ' ' . json_encode($_SESSION));
|
||||
}
|
||||
|
||||
// Fallback to MySQL auth as default - FIXME do this in sqlconfig file?
|
||||
if (!isset($config['auth_mechanism']))
|
||||
{
|
||||
if (!isset($config['auth_mechanism'])) {
|
||||
$config['auth_mechanism'] = "mysql";
|
||||
}
|
||||
|
||||
// Trust Apache authenticated user, if configured to do so and username is available
|
||||
if ($config['auth']['remote_user'] && $_SERVER['REMOTE_USER'] != '')
|
||||
{
|
||||
if ($config['auth']['remote_user'] && is_valid_param($_SERVER['REMOTE_USER'], 'username')) {
|
||||
session_set_var('username', $_SERVER['REMOTE_USER']);
|
||||
}
|
||||
|
||||
$auth_file = $config['html_dir'].'/includes/authentication/' . $config['auth_mechanism'] . '.inc.php';
|
||||
if (is_file($auth_file)) {
|
||||
if (isset($_SESSION['auth_mechanism']) && $_SESSION['auth_mechanism'] != $config['auth_mechanism'])
|
||||
{
|
||||
if (isset($_SESSION['auth_mechanism']) && $_SESSION['auth_mechanism'] != $config['auth_mechanism']) {
|
||||
// Logout if AUTH mechanism changed
|
||||
session_logout();
|
||||
reauth_with_message('Authentication mechanism changed, please log in again!');
|
||||
@ -123,14 +123,12 @@ if (is_file($auth_file)) {
|
||||
if ($_SESSION['authenticated'] && str_starts(ltrim($_SERVER['REQUEST_URI'], '/'), 'logout')) {
|
||||
// Do not use $vars and get_vars here!
|
||||
//print_vars($_SERVER['REQUEST_URI']);
|
||||
if (auth_can_logout())
|
||||
{
|
||||
if (auth_can_logout()) {
|
||||
// No need for a feedback message if user requested a logout
|
||||
session_logout(function_exists('auth_require_login'));
|
||||
|
||||
$redirect = auth_logout_url();
|
||||
if ($redirect)
|
||||
{
|
||||
if ($redirect) {
|
||||
redirect_to_url($redirect);
|
||||
exit();
|
||||
}
|
||||
@ -144,8 +142,7 @@ $user_unique_id = session_unique_id(); // Get unique user id and check if IP cha
|
||||
// Store logged remote IP with real proxied IP (if configured and available)
|
||||
$remote_addr = get_remote_addr();
|
||||
$remote_addr_header = get_remote_addr(TRUE); // Remote addr by http header
|
||||
if ($remote_addr_header && $remote_addr != $remote_addr_header)
|
||||
{
|
||||
if ($remote_addr_header && $remote_addr != $remote_addr_header) {
|
||||
$remote_addr = $remote_addr_header . ' (' . $remote_addr . ')';
|
||||
}
|
||||
|
||||
@ -156,15 +153,16 @@ if (isset($config['web_session_cidr']) && count($config['web_session_cidr'])) {
|
||||
}
|
||||
|
||||
if (!$_SESSION['authenticated']) {
|
||||
if (isset($_GET['username']) && isset($_GET['password']) &&
|
||||
is_string($_GET['username']) && is_string($_GET['password'])) {
|
||||
if (isset($_GET['username'], $_GET['password']) &&
|
||||
is_valid_param($_GET['username'], 'username') && is_valid_param($_GET['password'], 'password')) {
|
||||
|
||||
session_set_var('username', $_GET['username']);
|
||||
$auth_password = $_GET['password'];
|
||||
//r($_GET);
|
||||
//r($_SESSION);
|
||||
} elseif (isset($_POST['username']) && isset($_POST['password']) &&
|
||||
is_string($_POST['username']) && is_string($_POST['password']))
|
||||
{
|
||||
} elseif (isset($_POST['username'], $_POST['password']) &&
|
||||
is_valid_param($_POST['username'], 'username') && is_valid_param($_POST['password'], 'password')) {
|
||||
|
||||
session_set_var('username', $_POST['username']);
|
||||
$auth_password = $_POST['password'];
|
||||
} elseif (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||
@ -256,8 +254,7 @@ if (isset($_SESSION['username'])) {
|
||||
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
|
||||
'result' => 'Logged In'), 'authlog');
|
||||
// Generate keys for cookie auth
|
||||
if (isset($_POST['remember']) && OBS_ENCRYPT)
|
||||
{
|
||||
if (isset($_POST['remember']) && OBS_ENCRYPT) {
|
||||
$ckey = md5(strgen());
|
||||
$dkey = md5(strgen());
|
||||
$encpass = encrypt($auth_password, $dkey);
|
||||
@ -307,28 +304,15 @@ if (isset($_SESSION['username'])) {
|
||||
session_commit();
|
||||
|
||||
// Hardcoded level permissions
|
||||
/// FIXME. It's seems unused?..
|
||||
|
||||
$user_perms = array();
|
||||
$user_perms = [];
|
||||
|
||||
$perms[0] = [];
|
||||
$perms[1] = ['LOGIN'];
|
||||
$perms[2] = [];
|
||||
$perms[3] = [];
|
||||
$perms[5] = ['GLOBAL_READ'];
|
||||
$perms[6] = [];
|
||||
$perms[7] = [];
|
||||
$perms[8] = [];
|
||||
$perms[9] = [];
|
||||
$perms[10] = ['ADMIN'];
|
||||
|
||||
foreach($perms as $level => $array)
|
||||
{
|
||||
if($_SESSION['userlevel'] >= $level)
|
||||
{
|
||||
foreach($array AS $entry) { $user_perms[$entry] = $entry; }
|
||||
foreach ($config['user_level'] as $level => $array) {
|
||||
if ($_SESSION['userlevel'] >= $level) {
|
||||
foreach($array['roles'] as $entry) { $user_perms[$entry] = $entry; }
|
||||
}
|
||||
}
|
||||
|
||||
//print_vars($user_perms);
|
||||
|
||||
//print_vars($_SESSION);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage authentication
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -67,7 +67,7 @@ function ldap_search_user($ldap_group, $userdn, $depth = -1) {
|
||||
|
||||
$ldap_search = ldap_search($ds, trim($config['auth_ldap_groupbase'], ', '), $filter, array($config['auth_ldap_attr']['dn']));
|
||||
//r($filter);
|
||||
if (is_resource($ldap_search)) {
|
||||
if (ldap_internal_is_valid($ldap_search)) {
|
||||
$ldap_results = ldap_get_entries($ds, $ldap_search);
|
||||
|
||||
//r($ldap_results);
|
||||
@ -101,30 +101,30 @@ function ldap_search_user($ldap_group, $userdn, $depth = -1) {
|
||||
* Initializes the LDAP connection to the specified server(s). Cycles through all servers, throws error when no server can be reached.
|
||||
* Private function for this LDAP module only.
|
||||
*/
|
||||
function ldap_init()
|
||||
{
|
||||
function ldap_init() {
|
||||
global $ds, $config;
|
||||
|
||||
if (!is_resource($ds))
|
||||
{
|
||||
if (!ldap_internal_is_valid($ds)) {
|
||||
print_debug('LDAP[Connecting to ' . implode(' ',$config['auth_ldap_server']) . ']');
|
||||
$ds = @ldap_connect(implode(' ',$config['auth_ldap_server']), $config['auth_ldap_port']);
|
||||
if ($config['auth_ldap_port'] === 636) {
|
||||
print_debug('LDAP[Port 636. Prepending ldaps:// to server URI]');
|
||||
$ds = @ldap_connect(implode(' ',preg_filter('/^(ldaps:\/\/)?/', 'ldaps://', $config['auth_ldap_server'])), $config['auth_ldap_port']);
|
||||
} else {
|
||||
$ds = @ldap_connect(implode(' ',$config['auth_ldap_server']), $config['auth_ldap_port']);
|
||||
}
|
||||
print_debug("LDAP[Connected]");
|
||||
|
||||
if ($config['auth_ldap_starttls'] &&
|
||||
(in_array($config['auth_ldap_starttls'], [ 'optional', 'require', '1', 1, TRUE ], TRUE)))
|
||||
{
|
||||
(in_array($config['auth_ldap_starttls'], [ 'optional', 'require', '1', 1, TRUE ], TRUE))) {
|
||||
$tls = ldap_start_tls($ds);
|
||||
if ($config['auth_ldap_starttls'] === 'require' && !$tls)
|
||||
{
|
||||
if ($config['auth_ldap_starttls'] === 'require' && !$tls) {
|
||||
session_logout();
|
||||
print_error("Fatal error: LDAP TLS required but not successfully negotiated [" . ldap_error($ds) . "]");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ($config['auth_ldap_referrals'])
|
||||
{
|
||||
if ($config['auth_ldap_referrals']) {
|
||||
ldap_set_option($ds, LDAP_OPT_REFERRALS, $config['auth_ldap_referrals']);
|
||||
print_debug("LDAP[Referrals][Set to " . $config['auth_ldap_referrals'] . "]");
|
||||
} else {
|
||||
@ -132,8 +132,7 @@ function ldap_init()
|
||||
print_debug("LDAP[Referrals][Disabled]");
|
||||
}
|
||||
|
||||
if ($config['auth_ldap_version'])
|
||||
{
|
||||
if ($config['auth_ldap_version']) {
|
||||
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
|
||||
print_debug("LDAP[Version][Set to " . $config['auth_ldap_version'] . "]");
|
||||
}
|
||||
@ -385,11 +384,12 @@ function ldap_auth_user_id($username)
|
||||
$filter_params[] = ldap_filter_create('objectClass', $config['auth_ldap_objectclass']);
|
||||
$filter_params[] = ldap_filter_create($config['auth_ldap_attr']['uid'], $username);
|
||||
$filter = ldap_filter_combine($filter_params);
|
||||
|
||||
|
||||
print_debug("LDAP[Filter][$filter][" . trim($config['auth_ldap_suffix'], ', ') . "]");
|
||||
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ', '), $filter);
|
||||
$entries = is_resource($search) ? ldap_get_entries($ds, $search) : [];
|
||||
//print_vars($entries);
|
||||
//r($search);
|
||||
$entries = ldap_internal_is_valid($search) ? ldap_get_entries($ds, $search) : [];
|
||||
//r($entries);
|
||||
|
||||
if ($entries['count'])
|
||||
{
|
||||
@ -500,7 +500,7 @@ function ldap_auth_user_list($username = NULL) {
|
||||
//$group_filter .= '(memberof='.$group.')';
|
||||
$group_params[] = ldap_filter_create($config['auth_ldap_attr']['memberOf'], $group);
|
||||
}
|
||||
|
||||
|
||||
$filter_params[] = ldap_filter_combine($group_params, '|');
|
||||
|
||||
//$filter = '(&'.$filter.'(|'.$group_filter.'))';
|
||||
@ -566,7 +566,7 @@ function ldap_internal_user_entries($entries, &$userlist) {
|
||||
|
||||
$compare = ldap_search_user($ldap_group, $userdn);
|
||||
//print_warning("$username, $realname, ");
|
||||
//print_vars($compare);
|
||||
//r($compare);
|
||||
|
||||
if ($compare === -1) {
|
||||
print_debug("LDAP[UserList][Compare LDAP error: " . ldap_error($ds) . "]");
|
||||
@ -606,9 +606,9 @@ function ldap_internal_paged_entries($filter, $attributes)
|
||||
do {
|
||||
$search = ldap_search(
|
||||
$ds, trim($config['auth_ldap_suffix'], ', '), $filter, $attributes, 0, 0, 0, LDAP_DEREF_NEVER,
|
||||
[['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => $page_size, 'cookie' => $cookie]]]
|
||||
[['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => [ 'size' => $page_size, 'cookie' => $cookie ]]]
|
||||
);
|
||||
if (is_resource($search)) {
|
||||
if (ldap_internal_is_valid($search)) {
|
||||
ldap_parse_result($ds, $search, $errcode, $matcheddn, $errmsg, $referrals, $controls);
|
||||
print_debug(ldap_error($ds));
|
||||
$entries = array_merge($entries, ldap_get_entries($ds, $search));
|
||||
@ -642,7 +642,7 @@ function ldap_internal_paged_entries($filter, $attributes)
|
||||
|
||||
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ', '), $filter, $attributes);
|
||||
print_debug(ldap_error($ds));
|
||||
if (is_resource($search)) {
|
||||
if (ldap_internal_is_valid($search)) {
|
||||
$entries = array_merge($entries, ldap_get_entries($ds, $search));
|
||||
//print_vars($filter);
|
||||
//print_vars($search);
|
||||
@ -665,7 +665,7 @@ function ldap_internal_paged_entries($filter, $attributes)
|
||||
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ', '), $filter, $attributes);
|
||||
print_debug(ldap_error($ds));
|
||||
|
||||
if (is_resource($search)) {
|
||||
if (ldap_internal_is_valid($search)) {
|
||||
$entries = ldap_get_entries($ds, $search);
|
||||
//print_vars($filter);
|
||||
//print_vars($search);
|
||||
@ -800,6 +800,9 @@ function ldap_bind_dn($username = "", $password = "")
|
||||
*/
|
||||
function ldap_internal_dn_from_username($username)
|
||||
{
|
||||
|
||||
//r(debug_backtrace());
|
||||
|
||||
global $config, $ds, $cache;
|
||||
|
||||
if (!isset($cache['ldap']['dn'][$username]))
|
||||
@ -813,7 +816,11 @@ function ldap_internal_dn_from_username($username)
|
||||
print_debug("LDAP[Filter][$filter][" . trim($config['auth_ldap_suffix'], ', ') . "]");
|
||||
|
||||
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ', '), $filter);
|
||||
if (is_resource($search)) {
|
||||
|
||||
//r($search);
|
||||
//r(ldap_get_entries($ds, $search));
|
||||
|
||||
if (ldap_internal_is_valid($search)) {
|
||||
$entries = ldap_get_entries($ds, $search);
|
||||
|
||||
if ($entries['count']) {
|
||||
@ -1110,6 +1117,16 @@ function ldap_unescape_filter_value($values = array())
|
||||
return $values;
|
||||
}
|
||||
|
||||
function ldap_internal_is_valid($obj) {
|
||||
if (PHP_VERSION_ID >= 80100) {
|
||||
// ldap_bind() returns an LDAP\Connection instance in 8.1; previously, a resource was returned
|
||||
// ldap_search() returns an LDAP\Result instance in 8.1; previously, a resource was returned.
|
||||
return is_object($obj);
|
||||
}
|
||||
|
||||
return is_resource($obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all ASCII chars < 32 to "\HEX"
|
||||
*
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage authentication
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -23,7 +22,7 @@ function mysql_authenticate($username, $password)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$row = dbFetchRow("SELECT `username`, `password` FROM `users` WHERE `username` = ?", array($username));
|
||||
$row = dbFetchRow("SELECT `username`, `password` FROM `users` WHERE `username` = ? AND `type` = ?", [ $username, 'mysql' ]);
|
||||
if ($row['username'] && $row['username'] == $username)
|
||||
{
|
||||
if ($config['auth']['remote_user']) { return 1; }
|
||||
@ -78,12 +77,11 @@ function mysql_auth_can_change_password($username = "")
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ((empty($username) || !mysql_auth_user_exists($username)) && !$config['auth']['remote_user'])
|
||||
{
|
||||
if ((empty($username) || !mysql_auth_user_exists($username)) && !$config['auth']['remote_user']) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return dbFetchCell("SELECT `can_modify_passwd` FROM `users` WHERE `username` = ?", array($username)); // FIXME should return BOOL
|
||||
}
|
||||
|
||||
return dbFetchCell("SELECT `can_modify_passwd` FROM `users` WHERE `username` = ? AND `type` = ?", [ $username, 'mysql' ]); // FIXME should return BOOL
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,7 +97,7 @@ function mysql_auth_change_password($username,$password)
|
||||
|
||||
// $hash = crypt($password, '$1$' . strgen(8).'$'); // This is old hash, do not used anymore (keep for history)
|
||||
$hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
return dbUpdate(array('password' => $hash), 'users', '`username` = ?', array($username)); // FIXME should return BOOL
|
||||
return dbUpdate([ 'password' => $hash ], 'users', '`username` = ? AND `type` = ?', [ $username, 'mysql' ]); // FIXME should return BOOL
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,16 +122,22 @@ function mysql_auth_usermanagement()
|
||||
* @param string $description User's description
|
||||
* @return bool TRUE if user addition is successful, FALSE if it is not
|
||||
*/
|
||||
function mysql_adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd='1', $description = "")
|
||||
function mysql_adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd = '1', $description = "")
|
||||
{
|
||||
if (!mysql_auth_user_exists($username))
|
||||
{
|
||||
// $hash = crypt($password, '$1$' . strgen(8).'$'); // This is old hash, do not used anymore (keep for history)
|
||||
$hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
return dbInsert(array('username' => $username, 'password' => $hash, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description), 'users');
|
||||
} else {
|
||||
return FALSE;
|
||||
return dbInsert([ 'username' => $username,
|
||||
'password' => $hash,
|
||||
'level' => $level,
|
||||
'email' => $email,
|
||||
'realname' => $realname,
|
||||
'can_modify_passwd' => $can_modify_passwd,
|
||||
'descr' => $description ], 'users');
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,7 +149,7 @@ function mysql_adduser($username, $password, $level, $email = "", $realname = ""
|
||||
function mysql_auth_user_exists($username)
|
||||
{
|
||||
//return @dbFetchCell("SELECT COUNT(*) FROM `users` WHERE `username` = ?", array($username)); // FIXME should return BOOL
|
||||
return dbExist('users', '`username` = ?', array($username));
|
||||
return dbExist('users', '`username` = ? AND `type` = ?', [ $username, 'mysql' ]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,7 +160,7 @@ function mysql_auth_user_exists($username)
|
||||
*/
|
||||
function mysql_auth_username_by_id($user_id)
|
||||
{
|
||||
return dbFetchCell("SELECT `username` FROM `users` WHERE `user_id` = ?", array($user_id)); // FIXME should return FALSE if not found
|
||||
return dbFetchCell("SELECT `username` FROM `users` WHERE `user_id` = ? AND `type` = ?", [ $user_id, 'mysql' ]); // FIXME should return FALSE if not found
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,7 +171,7 @@ function mysql_auth_username_by_id($user_id)
|
||||
*/
|
||||
function mysql_auth_user_level($username)
|
||||
{
|
||||
return dbFetchCell("SELECT `level` FROM `users` WHERE `username` = ?", array($username));
|
||||
return dbFetchCell("SELECT `level` FROM `users` WHERE `username` = ? AND `type` = ?", [ $username, 'mysql' ]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,7 +182,7 @@ function mysql_auth_user_level($username)
|
||||
*/
|
||||
function mysql_auth_user_id($username)
|
||||
{
|
||||
return dbFetchCell("SELECT `user_id` FROM `users` WHERE `username` = ?", array($username));
|
||||
return dbFetchCell("SELECT `user_id` FROM `users` WHERE `username` = ? AND `type` = ?", [ $username, 'mysql' ]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -196,7 +200,7 @@ function mysql_deluser($username)
|
||||
dbDelete('users_prefs', "`user_id` = ?", array($user_id));
|
||||
dbDelete('users_ckeys', "`username` = ?", array($username));
|
||||
|
||||
return dbDelete('users', "`username` = ?", array($username)); // FIXME should return BOOL
|
||||
return dbDelete('users', "`username` = ? AND `type` = ?", [ $username, 'mysql' ]); // FIXME should return BOOL
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,7 +210,7 @@ function mysql_deluser($username)
|
||||
*/
|
||||
function mysql_auth_user_list()
|
||||
{
|
||||
return dbFetchRows("SELECT * FROM `users`"); // FIXME hardcode list of returned fields as in all other backends; array content should not depend on db changes/column names.
|
||||
return dbFetchRows("SELECT * FROM `users` WHERE `type` = ?", [ 'mysql' ]); // FIXME hardcode list of returned fields as in all other backends; array content should not depend on db changes/column names.
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,7 +221,7 @@ function mysql_auth_user_list()
|
||||
*/
|
||||
function mysql_auth_user_info($username)
|
||||
{
|
||||
return dbFetchRow("SELECT * FROM `users` WHERE `username` = ?", array($username));
|
||||
return dbFetchRow("SELECT * FROM `users` WHERE `username` = ? AND `type` = ?", [ $username, 'mysql' ]);
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage authentication
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -219,14 +218,14 @@ function radius_adduser($username, $password, $level, $email = "", $realname = "
|
||||
|
||||
/**
|
||||
* Check if a user, specified by username, exists in the user backend.
|
||||
* This is not currently possible using the RADIUS backend.
|
||||
* This will only return users that have logged in at least once and inserted into MySQL
|
||||
*
|
||||
* @param string $username Username to check
|
||||
* @return bool TRUE if the user exists, FALSE if they do not
|
||||
*/
|
||||
function radius_auth_user_exists($username)
|
||||
{
|
||||
return FALSE;
|
||||
return dbExist('users', '`username` = ? AND `type` = ?', [ $username, 'radius' ]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -246,7 +245,7 @@ function radius_auth_user_level($username)
|
||||
|
||||
if (!isset($cache['radius']['level'][$username]))
|
||||
{
|
||||
if ($config['auth_radius_groupmemberattr'] == 18 || strtolower($config['auth_radius_groupmemberattr']) == 'reply-message')
|
||||
if ($config['auth_radius_groupmemberattr'] == 18 || strtolower($config['auth_radius_groupmemberattr']) === 'reply-message')
|
||||
{
|
||||
// Reply-Message (18)
|
||||
$attribute = RADIUS_REPLY_MESSAGE;
|
||||
@ -285,7 +284,18 @@ function radius_auth_user_level($username)
|
||||
$rad_userlevel = 10;
|
||||
}
|
||||
}
|
||||
//r($rad_userlevel);
|
||||
|
||||
// If we don't already have an entry for this RADIUS user in the MySQL database, create one
|
||||
if (!radius_auth_user_exists($username)){
|
||||
$user_id = radius_auth_user_id($username);
|
||||
create_mysql_user($username, $user_id, $rad_userlevel, 'radius');
|
||||
} else {
|
||||
// Update the user's level in MySQL if it doesn't match. This is really informational only.
|
||||
if (dbFetchCell("SELECT `level` FROM `users` WHERE `username` = ? AND `type` = ?", [ $username, 'radius' ]) != $rad_userlevel) {
|
||||
$user_id = radius_auth_user_id($username);
|
||||
dbUpdate([ 'level' => $rad_userlevel, 'user_id' => $user_id ], 'users', '`username` = ? AND `type` = ?', [ $username, 'radius' ]);
|
||||
}
|
||||
}
|
||||
|
||||
return $rad_userlevel;
|
||||
}
|
||||
@ -324,8 +334,8 @@ function radius_deluser($username)
|
||||
*/
|
||||
function radius_auth_user_list()
|
||||
{
|
||||
$userlist = array();
|
||||
return $userlist;
|
||||
// Send list of users from MySQL
|
||||
return dbFetchRows("SELECT * FROM `users` WHERE `type` = ?", [ 'radius' ]);
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
@ -6,10 +6,11 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
$cache_data_start = microtime(TRUE);
|
||||
$cache_item = get_cache_item('data');
|
||||
//print_vars($cache_item->isHit());
|
||||
|
||||
@ -33,17 +34,22 @@ if (!ishit_cache_item($cache_item))
|
||||
// This means device_by_id_cache actually never has to do any queries by itself, it'll always get the
|
||||
// cached version when running from the web interface. From the commandline obviously we'll need to fetch
|
||||
// the data per-device. We pre-fetch the graphs list as well, much faster than a query per device obviously.
|
||||
$graphs_array = dbFetchRows("SELECT * FROM `device_graphs` FORCE INDEX (`graph`) ORDER BY `graph`;");
|
||||
//$graphs_array = dbFetchRows("SELECT * FROM `device_graphs` FORCE INDEX (`graph`) ORDER BY `graph`;");
|
||||
|
||||
foreach ($graphs_array as $graph)
|
||||
$cache['graphs'] = [];
|
||||
foreach(dbFetchRows("SELECT `graph` FROM `device_graphs` GROUP BY `graph` ORDER BY `graph`;") as $entry)
|
||||
{
|
||||
$cache['graphs'][$entry['graph']] = $entry['graph'];
|
||||
}
|
||||
|
||||
/*foreach ($graphs_array as $graph)
|
||||
{
|
||||
// Cache this per device_id so we can assign it to the correct (cached) device in the for loop below
|
||||
if ($graph['enabled'])
|
||||
{
|
||||
$device_graphs[$graph['device_id']][$graph['graph']] = $graph;
|
||||
}
|
||||
}
|
||||
$cache['graphs'] = array(); // All permitted graphs
|
||||
}*/
|
||||
|
||||
// Cache scheduled maintenance currently active
|
||||
$cache['maint'] = cache_alert_maintenance();
|
||||
@ -54,16 +60,18 @@ if (!ishit_cache_item($cache_item))
|
||||
} else {
|
||||
$devices_array = dbFetchRows("SELECT * FROM `devices` ORDER BY `hostname`;");
|
||||
}
|
||||
|
||||
foreach ($devices_array as $device)
|
||||
{
|
||||
if (device_permitted($device['device_id']))
|
||||
{
|
||||
// Process device and add all the human-readable stuff.
|
||||
humanize_device($device);
|
||||
// Very slow on larger systems (3s with 2000 devices)
|
||||
//humanize_device($device);
|
||||
|
||||
// Assign device graphs from array created above
|
||||
$device['graphs'] = (array)$device_graphs[$device['device_id']];
|
||||
$cache['graphs'] = array_unique(array_merge($cache['graphs'], array_keys($device['graphs']))); // Add to global array cache
|
||||
//$device['graphs'] = (array)$device_graphs[$device['device_id']];
|
||||
//$cache['graphs'] = array_unique(array_merge($cache['graphs'], array_keys($device['graphs']))); // Add to global array cache
|
||||
|
||||
$cache['devices']['permitted'][] = (int)$device['device_id']; // Collect IDs for permitted
|
||||
$cache['devices']['hostname'][$device['hostname']] = $device['device_id'];
|
||||
@ -184,10 +192,10 @@ if (!ishit_cache_item($cache_item))
|
||||
// Devices disabled
|
||||
if (isset($cache['devices']['disabled']) && count($cache['devices']['disabled']) > 0)
|
||||
{
|
||||
$cache['ports']['device_disabled'] = dbFetchColumn("SELECT `port_id` FROM `ports` WHERE 1 " . $where_permitted . generate_query_values($cache['devices']['disabled'], 'device_id'));
|
||||
$cache['ports']['device_disabled'] = dbFetchColumn("SELECT `port_id` FROM `ports` WHERE 1 " . $where_permitted . generate_query_values_and($cache['devices']['disabled'], 'device_id'));
|
||||
if (!$config['web_show_disabled'])
|
||||
{
|
||||
$where_hide .= generate_query_values($cache['devices']['disabled'], 'device_id', '!=');
|
||||
$where_hide .= generate_query_values_and($cache['devices']['disabled'], 'device_id', '!=');
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,9 +203,9 @@ if (!ishit_cache_item($cache_item))
|
||||
$where_devices_ignored = '';
|
||||
if (isset($cache['devices']['ignored']) && count($cache['devices']['ignored']) > 0)
|
||||
{
|
||||
$cache['ports']['device_ignored'] = dbFetchColumn("SELECT `port_id` FROM `ports` WHERE 1 " . $where_permitted . $where_hide . generate_query_values($cache['devices']['ignored'], 'device_id'));
|
||||
$where_hide .= generate_query_values($cache['devices']['ignored'], 'device_id', '!=');
|
||||
$where_devices_ignored = generate_query_values($cache['devices']['ignored'], 'device_id');
|
||||
$cache['ports']['device_ignored'] = dbFetchColumn("SELECT `port_id` FROM `ports` WHERE 1 " . $where_permitted . $where_hide . generate_query_values_and($cache['devices']['ignored'], 'device_id'));
|
||||
$where_hide .= generate_query_values_and($cache['devices']['ignored'], 'device_id', '!=');
|
||||
$where_devices_ignored = generate_query_values_and($cache['devices']['ignored'], 'device_id');
|
||||
}
|
||||
$cache['ports']['stat']['device_ignored'] = count($cache['ports']['device_ignored']);
|
||||
|
||||
@ -650,6 +658,8 @@ unset($cache_item);
|
||||
//print_vars(get_cache_items('__wui'));
|
||||
//print_vars(get_cache_stats());
|
||||
|
||||
$cache_data_time = microtime(TRUE) - $cache_data_start;
|
||||
|
||||
// EOF
|
||||
|
||||
|
||||
|
||||
@ -341,10 +341,10 @@ $("#contact_method").change(function() {
|
||||
} else {
|
||||
$script .= PHP_EOL . " } else if (select === '" . $transport . "') {" . PHP_EOL;
|
||||
}
|
||||
$script .= " \$('div[id^=\"contact_${transport}_\"]').show();" . PHP_EOL . " ";
|
||||
$script .= " \$('div[id^=\"contact_{$transport}_\"]').show();" . PHP_EOL . " ";
|
||||
foreach (array_keys($config['transports']) as $ltransport) {
|
||||
if ($transport != $ltransport) {
|
||||
$script .= " \$('div[id^=\"contact_${ltransport}_\"]').hide();";
|
||||
$script .= " \$('div[id^=\"contact_{$ltransport}_\"]').hide();";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -28,21 +28,21 @@ function build_cbqos_query($vars)
|
||||
switch ($var) {
|
||||
case "policy_name":
|
||||
case "object_name":
|
||||
$sql .= generate_query_values($value, $var);
|
||||
$sql .= generate_query_values_and($value, $var);
|
||||
break;
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'cbqos_id');
|
||||
$sql .= generate_query_values_and($values, 'cbqos_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'ports_cbqos.device_id');
|
||||
$sql .= generate_query_values_and($values, 'ports_cbqos.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'ports_cbqos.device_id');
|
||||
$sql .= generate_query_values_and($value, 'ports_cbqos.device_id');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,14 +6,14 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Humanize counter.
|
||||
*
|
||||
* Returns a the $counter array with processed information:
|
||||
* Returns a $counter array with processed information:
|
||||
* counter_state (TRUE: state counter, FALSE: normal counter)
|
||||
* human_value, counter_symbol, state_name, state_event, state_class
|
||||
*
|
||||
@ -164,42 +164,42 @@ function build_counter_query($vars, $query_count = FALSE)
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'counters.counter_id');
|
||||
$sql .= generate_query_values_and($values, 'counters.counter_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'counters.device_id');
|
||||
$sql .= generate_query_values_and($values, 'counters.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'counters.device_id');
|
||||
$sql .= generate_query_values_and($value, 'counters.device_id');
|
||||
break;
|
||||
case "id":
|
||||
case "counter_id":
|
||||
$sql .= generate_query_values($value, 'counters.counter_id');
|
||||
$sql .= generate_query_values_and($value, 'counters.counter_id');
|
||||
break;
|
||||
case "entity_id":
|
||||
$sql .= generate_query_values($value, 'counters.measured_entity');
|
||||
$sql .= generate_query_values_and($value, 'counters.measured_entity');
|
||||
break;
|
||||
case "entity_type":
|
||||
$sql .= generate_query_values($value, 'counters.measured_class');
|
||||
$sql .= generate_query_values_and($value, 'counters.measured_class');
|
||||
break;
|
||||
case 'entity_state':
|
||||
case "measured_state":
|
||||
$sql .= build_entity_measured_where('counter', ['measured_state' => $value]);
|
||||
$sql .= build_entity_measured_where('counter', [ 'measured_state' => $value ]);
|
||||
break;
|
||||
case 'class':
|
||||
case "counter_class":
|
||||
$sql .= generate_query_values($value, 'counter_class');
|
||||
$sql .= generate_query_values_and($value, 'counter_class');
|
||||
break;
|
||||
case "descr":
|
||||
case "counter_descr":
|
||||
$sql .= generate_query_values($value, 'counters.counter_descr', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'counters.counter_descr', '%LIKE%');
|
||||
break;
|
||||
case "event":
|
||||
case "counter_event":
|
||||
$sql .= generate_query_values($value, 'counter_event');
|
||||
$sql .= generate_query_values_and($value, 'counter_event');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -443,7 +443,7 @@ function generate_counter_row($counter, $vars)
|
||||
$counter['counter_class'],
|
||||
$config['counter_types'][$counter['counter_class']]['alt_units']) as $unit => $unit_value)
|
||||
{
|
||||
if (is_numeric($unit_value)) { $counter_tooltip .= "<br />${unit_value}${unit}"; }
|
||||
if (is_numeric($unit_value)) { $counter_tooltip .= "<br />{$unit_value}{$unit}"; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -14,29 +14,25 @@
|
||||
* Build devices where array
|
||||
*
|
||||
* This function returns an array of "WHERE" statements from a $vars array.
|
||||
* The returned array can be implode()d and used on the devices table.
|
||||
* The returned array can be imploded and used on the devices table.
|
||||
* Originally extracted from the /devices/ page
|
||||
*
|
||||
* @param array $vars
|
||||
* @return array
|
||||
*/
|
||||
function build_devices_where_array($vars)
|
||||
{
|
||||
function build_devices_where_array($vars) {
|
||||
$where_array = array();
|
||||
foreach ($vars as $var => $value)
|
||||
{
|
||||
if ($value != '')
|
||||
{
|
||||
switch ($var)
|
||||
{
|
||||
foreach ($vars as $var => $value) {
|
||||
if (!safe_empty($value)) {
|
||||
switch ($var) {
|
||||
case 'group':
|
||||
case 'group_id':
|
||||
$values = get_group_entities($value);
|
||||
$where_array[$var] = generate_query_values($values, 'device_id');
|
||||
$where_array[$var] = generate_query_values_and($values, 'device_id');
|
||||
break;
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where_array[$var] = generate_query_values($value, 'device_id');
|
||||
$where_array[$var] = generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case 'hostname':
|
||||
case 'sysname':
|
||||
@ -44,13 +40,15 @@ function build_devices_where_array($vars)
|
||||
case 'sysDescr':
|
||||
case 'serial':
|
||||
case 'purpose':
|
||||
$where_array[$var] = generate_query_values($value, $var, '%LIKE%');
|
||||
$condition = str_contains_array($value, [ '*', '?' ]) ? 'LIKE' : '%LIKE%';
|
||||
$where_array[$var] = generate_query_values_and($value, $var, $condition);
|
||||
break;
|
||||
case 'location_text':
|
||||
$where_array[$var] = generate_query_values($value, 'devices.location', '%LIKE%');
|
||||
$condition = str_contains_array($value, [ '*', '?' ]) ? 'LIKE' : '%LIKE%';
|
||||
$where_array[$var] = generate_query_values_and($value, 'devices.location', $condition);
|
||||
break;
|
||||
case 'location':
|
||||
$where_array[$var] = generate_query_values($value, 'devices.location');
|
||||
$where_array[$var] = generate_query_values_and($value, 'devices.location');
|
||||
break;
|
||||
case 'location_lat':
|
||||
case 'location_lon':
|
||||
@ -60,7 +58,7 @@ function build_devices_where_array($vars)
|
||||
case 'location_city':
|
||||
if ($GLOBALS['config']['geocoding']['enable'])
|
||||
{
|
||||
$where_array[$var] = generate_query_values($value, 'devices_locations.' . $var);
|
||||
$where_array[$var] = generate_query_values_and($value, 'devices_locations.' . $var);
|
||||
}
|
||||
break;
|
||||
case 'os':
|
||||
@ -74,10 +72,10 @@ function build_devices_where_array($vars)
|
||||
case 'distro':
|
||||
case 'ignore':
|
||||
case 'disabled':
|
||||
$where_array[$var] = generate_query_values($value, $var);
|
||||
$where_array[$var] = generate_query_values_and($value, $var);
|
||||
break;
|
||||
case 'graph':
|
||||
$where_array[$var] = generate_query_values(devices_with_graph($value), "devices.device_id");
|
||||
$where_array[$var] = generate_query_values_and(devices_with_graph($value), "devices.device_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,7 +101,6 @@ function devices_with_graph($graph)
|
||||
function build_devices_sort($vars)
|
||||
{
|
||||
$order = '';
|
||||
$desc_order = isset($vars['sort_desc']) && $vars['sort_desc'];
|
||||
switch ($vars['sort'])
|
||||
{
|
||||
case 'uptime':
|
||||
@ -112,13 +109,12 @@ function build_devices_sort($vars)
|
||||
case 'features':
|
||||
case 'type':
|
||||
case 'os':
|
||||
case 'sysName':
|
||||
case 'device_id':
|
||||
$order = ' ORDER BY `devices`.`'.$vars['sort'].'`';
|
||||
if ($desc_order)
|
||||
{
|
||||
$order .= " DESC";
|
||||
}
|
||||
if ($vars['sort_order'] == "desc") { $order .= " DESC";}
|
||||
break;
|
||||
|
||||
case 'domain':
|
||||
// Special order hostnames in Domain Order
|
||||
// SELECT `hostname`,
|
||||
@ -126,19 +122,18 @@ function build_devices_sort($vars)
|
||||
// SUBSTRING_INDEX(SUBSTRING_INDEX(`hostname`,'.',-2),'.',1) AS `middle`,
|
||||
// SUBSTRING_INDEX(`hostname`,'.',-1) AS `rightmost`
|
||||
// FROM `devices` ORDER by `middle`, `rightmost`, `leftmost`;
|
||||
if ($desc_order)
|
||||
if ($vars['sort_order'] == "desc")
|
||||
{
|
||||
$order = ' ORDER BY `middle` DESC, `rightmost` DESC, `leftmost` DESC';
|
||||
} else {
|
||||
$order = ' ORDER BY `middle`, `rightmost`, `leftmost`';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'hostname':
|
||||
default:
|
||||
$order = ' ORDER BY `devices`.`hostname`';
|
||||
if ($desc_order)
|
||||
{
|
||||
$order .= " DESC";
|
||||
}
|
||||
if ($vars['sort_order'] == "desc") { $order .= " DESC"; }
|
||||
break;
|
||||
}
|
||||
return $order;
|
||||
@ -150,27 +145,9 @@ function print_device_header($device, $args = array()) {
|
||||
|
||||
if (!is_array($device)) { print_error("Invalid device passed to print_device_header()!"); }
|
||||
|
||||
/* FIXME. Unused?
|
||||
if ($device['status'] == '0') { $class = "div-alert"; } else { $class = "div-normal"; }
|
||||
if ($device['ignore'] == '1')
|
||||
{
|
||||
$class = "div-ignore-alert";
|
||||
if ($device['status'] == '1')
|
||||
{
|
||||
$class = "div-ignore";
|
||||
}
|
||||
}
|
||||
|
||||
if ($device['disabled'] == '1')
|
||||
{
|
||||
$class = "div-disabled";
|
||||
}
|
||||
|
||||
$type = strtolower($device['os']);
|
||||
*/
|
||||
$div_class = 'box box-solid';
|
||||
if (!safe_empty($args['div-class'])) {
|
||||
$div_class .= " ${args['div-class']}";
|
||||
$div_class .= " " . $args['div-class'];
|
||||
}
|
||||
|
||||
echo '<div class="'.$div_class.'">
|
||||
@ -200,12 +177,12 @@ function print_device_header($device, $args = array()) {
|
||||
}
|
||||
|
||||
$graph_array = [];
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "310";
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
//$graph_array['height'] = "100";
|
||||
//$graph_array['width'] = "310";
|
||||
$graph_array['to'] = get_time();
|
||||
$graph_array['device'] = $device['device_id'];
|
||||
$graph_array['type'] = "device_bits";
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['from'] = get_time('day');
|
||||
$graph_array['legend'] = "no";
|
||||
|
||||
$graph_array['height'] = "45";
|
||||
@ -398,7 +375,7 @@ function print_device_row($device, $vars = array('view' => 'basic'), $link_vars
|
||||
|
||||
// Preprocess device graphs array
|
||||
$graphs_enabled = [];
|
||||
foreach ($GLOBALS['cache']['devices']['id'][$device['device_id']]['graphs'] as $graph)
|
||||
foreach ($device['graphs'] as $graph)
|
||||
{
|
||||
$graphs_enabled[] = $graph['graph'];
|
||||
}
|
||||
@ -515,50 +492,41 @@ function get_device_icon($device, $base_icon = FALSE, $dark = FALSE) {
|
||||
}
|
||||
|
||||
// Icon by vendor name
|
||||
if ($icon === 'generic' && ($config['os'][$device['os']]['vendor'] || $device['vendor']))
|
||||
{
|
||||
if ($device['vendor'])
|
||||
{
|
||||
if ($icon === 'generic' && ($config['os'][$device['os']]['vendor'] || $device['vendor'])) {
|
||||
if ($device['vendor']) {
|
||||
$vendor = $device['vendor'];
|
||||
} else {
|
||||
$vendor = rewrite_vendor($config['os'][$device['os']]['vendor']); // Compatibility, if device not polled for long time
|
||||
}
|
||||
|
||||
$vendor_safe = safename(strtolower($vendor));
|
||||
if (isset($config['vendors'][$vendor_safe]['icon']))
|
||||
{
|
||||
if (isset($config['vendors'][$vendor_safe]['icon'])) {
|
||||
$icon = $config['vendors'][$vendor_safe]['icon'];
|
||||
}
|
||||
elseif (is_file($config['html_dir'] . '/images/os/' . $vendor_safe . '.png'))
|
||||
{
|
||||
} elseif (is_file($config['html_dir'] . '/images/os/' . $vendor_safe . '.png')) {
|
||||
$icon = $vendor_safe;
|
||||
}
|
||||
elseif (isset($config['os'][$device['os']]['icons']))
|
||||
{
|
||||
} elseif (isset($config['os'][$device['os']]['icons'])) {
|
||||
// Fallback to os alternative icon
|
||||
$icon = array_values($config['os'][$device['os']]['icons'])[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Set dark mode by session
|
||||
if (isset($_SESSION['theme']))
|
||||
{
|
||||
if (isset($_SESSION['theme'])) {
|
||||
$dark = str_contains($_SESSION['theme'], 'dark');
|
||||
}
|
||||
|
||||
// Prefer dark variant of icon in dark mode
|
||||
if ($dark && is_file($config['html_dir'] . '/images/os/' . $icon . '-dark.png'))
|
||||
{
|
||||
if ($dark && is_file($config['html_dir'] . '/images/os/' . $icon . '-dark.png')) {
|
||||
$icon .= '-dark';
|
||||
}
|
||||
|
||||
if ($base_icon)
|
||||
{
|
||||
if ($base_icon) {
|
||||
// return base name for os icon
|
||||
return $icon;
|
||||
}
|
||||
|
||||
// return image html tag
|
||||
$base_url = rtrim($config['base_url'], '/');
|
||||
$srcset = '';
|
||||
// Now we always have 2x icon variant!
|
||||
//if (is_file($config['html_dir'] . '/images/os/' . $icon . '_2x.png')) // HiDPI image exist?
|
||||
@ -566,14 +534,13 @@ function get_device_icon($device, $base_icon = FALSE, $dark = FALSE) {
|
||||
// Detect allowed screen ratio for current browser
|
||||
$ua_info = detect_browser();
|
||||
|
||||
if ($ua_info['screen_ratio'] > 1)
|
||||
{
|
||||
$srcset = ' srcset="' .$config['base_url'] . '/images/os/' . $icon . '_2x.png'.' 2x"';
|
||||
if ($ua_info['screen_ratio'] > 1) {
|
||||
$srcset = ' srcset="' . $base_url . '/images/os/' . $icon . '_2x.png'.' 2x"';
|
||||
}
|
||||
//}
|
||||
|
||||
// Image tag -- FIXME re-engineer this code to do this properly. This is messy.
|
||||
return '<img src="' . $config['base_url'] . '/images/os/' . $icon . '.png"' . $srcset . ' alt="" />';
|
||||
return '<img src="' . $base_url . '/images/os/' . $icon . '.png"' . $srcset . ' alt="" />';
|
||||
}
|
||||
|
||||
// TESTME needs unit testing
|
||||
@ -638,8 +605,11 @@ function generate_device_popup($device, $vars = []) {
|
||||
}
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($graphs as $entry) {
|
||||
|
||||
if($count == 3) { break; }
|
||||
|
||||
if ($entry && in_array(str_replace('device_', '', $entry), $graphs_enabled, TRUE)) {
|
||||
// No text provided for the minigraph, fetch from array
|
||||
if (preg_match(OBS_PATTERN_GRAPH_TYPE, $entry, $graphtype)) {
|
||||
@ -664,17 +634,13 @@ function generate_device_popup($device, $vars = []) {
|
||||
|
||||
$content .= '<div style="width: 730px; white-space: nowrap;">';
|
||||
$content .= "<div class=entity-title><h4>" . $text . "</h4></div>";
|
||||
/*
|
||||
$content .= generate_box_open(array('title' => $text,
|
||||
'body-style' => 'white-space: nowrap;'));
|
||||
*/
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
|
||||
$graph_array['from'] = get_time('week');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
|
||||
$content .= '</div>';
|
||||
//$content .= generate_box_close();
|
||||
|
||||
$count++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -722,41 +688,6 @@ function generate_device_link_short($device, $vars = [], $short = TRUE) {
|
||||
return generate_device_link($device, NULL, $vars, TRUE, $short);
|
||||
}
|
||||
|
||||
function device_name($device, $max_len = FALSE) {
|
||||
global $config;
|
||||
|
||||
switch (strtolower($config['web_device_name'])) {
|
||||
case 'sysname':
|
||||
$name_field = 'sysName';
|
||||
break;
|
||||
case 'purpose':
|
||||
case 'descr':
|
||||
case 'description':
|
||||
$name_field = 'purpose';
|
||||
break;
|
||||
default:
|
||||
$name_field = 'hostname';
|
||||
}
|
||||
|
||||
if ($max_len && !is_intnum($max_len)) {
|
||||
$max_len = $config['short_hostname']['length'];
|
||||
}
|
||||
|
||||
if ($name_field !== 'hostname' && !safe_empty($device[$name_field])) {
|
||||
if ($name_field === 'sysName' && $max_len && $max_len > 3) {
|
||||
// short sysname when is valid hostname (do not escape here)
|
||||
return short_hostname($device[$name_field], $max_len, FALSE);
|
||||
}
|
||||
return $device[$name_field];
|
||||
}
|
||||
|
||||
if ($max_len && $max_len > 3) {
|
||||
// short hostname (do not escape here)
|
||||
return short_hostname($device['hostname'], $max_len, FALSE);
|
||||
}
|
||||
return $device['hostname'];
|
||||
}
|
||||
|
||||
function generate_device_form_values($form_filter = FALSE, $column = 'device_id', $options = array())
|
||||
{
|
||||
global $cache;
|
||||
|
||||
@ -54,6 +54,30 @@ function get_customoid_by_id($oid_id) {
|
||||
|
||||
} // end function get_customoid_by_id()
|
||||
|
||||
// DOCME needs phpdoc block
|
||||
// TESTME needs unit testing
|
||||
function get_application_by_id($application_id)
|
||||
{
|
||||
if (is_numeric($application_id))
|
||||
{
|
||||
$application = dbFetchRow("SELECT * FROM `applications` WHERE `app_id` = ?", array($application_id));
|
||||
}
|
||||
if (is_array($application))
|
||||
{
|
||||
return $application;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// DOCME needs phpdoc block
|
||||
// TESTME needs unit testing
|
||||
function accesspoint_by_id($ap_id, $refresh = '0')
|
||||
{
|
||||
$ap = dbFetchRow("SELECT * FROM `accesspoints` WHERE `accesspoint_id` = ?", array($ap_id));
|
||||
|
||||
return $ap;
|
||||
}
|
||||
|
||||
function generate_entity_popup_graphs($entity, $vars)
|
||||
{
|
||||
@ -376,8 +400,8 @@ function build_entity_measured_where($entity_type, $vars)
|
||||
{
|
||||
case 'port':
|
||||
case 'printersupply':
|
||||
$measure_sql = generate_query_values($measured_type, $column_measured_type, NULL, OBS_DB_NO_LEADING_AND);
|
||||
$measure_sql .= generate_query_values($entities, $column_measured_id);
|
||||
$measure_sql = generate_query_values_ng($measured_type, $column_measured_type);
|
||||
$measure_sql .= generate_query_values_and($entities, $column_measured_id);
|
||||
break;
|
||||
}
|
||||
if ($measure_sql) { $measure_array[] = $measure_sql; }
|
||||
@ -388,7 +412,7 @@ function build_entity_measured_where($entity_type, $vars)
|
||||
//$value = (array)$value;
|
||||
// Select all without measured entities
|
||||
if (in_array('none', $value)) {
|
||||
$measure_array[] = generate_query_values(1, $column_measured_id, 'NULL', OBS_DB_NO_LEADING_AND);
|
||||
$measure_array[] = generate_query_values_ng(1, $column_measured_id);
|
||||
$value = array_diff($value, [ 'none' ]);
|
||||
}
|
||||
if (count($value))
|
||||
@ -410,8 +434,8 @@ function build_entity_measured_where($entity_type, $vars)
|
||||
$entities = dbFetchColumn($entity_sql);
|
||||
//$entities = dbFetchColumn($entity_sql, NULL, TRUE);
|
||||
//r($entities);
|
||||
$measure_sql = generate_query_values($measured_type, $column_measured_type, NULL, OBS_DB_NO_LEADING_AND);
|
||||
$measure_sql .= generate_query_values($entities, $column_measured_id);
|
||||
$measure_sql = generate_query_values_ng($measured_type, $column_measured_type);
|
||||
$measure_sql .= generate_query_values_and($entities, $column_measured_id);
|
||||
break;
|
||||
case 'printersupply':
|
||||
break;
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -32,20 +32,20 @@ function build_mempool_query($vars)
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'mempools.mempool_id');
|
||||
$sql .= generate_query_values_and($values, 'mempools.mempool_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'mempools.device_id');
|
||||
$sql .= generate_query_values_and($values, 'mempools.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'mempools.device_id');
|
||||
$sql .= generate_query_values_and($value, 'mempools.device_id');
|
||||
break;
|
||||
case "descr":
|
||||
case "mempool_descr";
|
||||
$sql .= generate_query_values($value, 'mempool_descr', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'mempool_descr', '%LIKE%');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,15 +6,14 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
function generate_oid_template_link($entry)
|
||||
{
|
||||
$url = generate_url(array('page' => 'customoid', 'oid_id' => $entry['oid_id']));
|
||||
$link = '<a href="'.$url.'">'.$entry['oid_descr'].'</a>';
|
||||
return $link;
|
||||
return '<a href="'.$url.'">'.$entry['oid_descr'].'</a>';
|
||||
}
|
||||
|
||||
function build_oid_query($vars)
|
||||
@ -33,21 +32,21 @@ function build_oid_query($vars)
|
||||
case "oid_descr":
|
||||
case "oid":
|
||||
case "oid_name":
|
||||
$sql .= generate_query_values($value, $var);
|
||||
$sql .= generate_query_values_and($value, $var);
|
||||
break;
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'oid_entry_id');
|
||||
$sql .= generate_query_values_and($values, 'oid_entry_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'oids_entries.device_id');
|
||||
$sql .= generate_query_values_and($values, 'oids_entries.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'oids_entries.device_id');
|
||||
$sql .= generate_query_values_and($value, 'oids_entries.device_id');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -97,7 +96,7 @@ function print_oid_table_header($vars, $entries)
|
||||
$cols['event'] = array('Event', 'style="width: 60px;"');
|
||||
|
||||
if ($entries[0]['oid_autodiscover'] == '0' && $vars['page'] === "customoid") {
|
||||
$cols['actions'] = array('', 'style="width: 40px;"'); echo "derp";
|
||||
$cols['actions'] = array('', 'style="width: 40px;"');
|
||||
}
|
||||
|
||||
echo get_table_header($cols, $vars);
|
||||
@ -112,7 +111,6 @@ function print_oid_table($vars)
|
||||
$entries = dbFetchRows($sql);
|
||||
$count = count($entries);
|
||||
|
||||
|
||||
if (count($entries)) {
|
||||
|
||||
echo generate_box_open();
|
||||
|
||||
@ -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,16 +23,16 @@ function generate_p2pradio_query($vars)
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'radio_id');
|
||||
$sql .= generate_query_values_and($values, 'radio_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'p2p_radios.device_id');
|
||||
$sql .= generate_query_values_and($values, 'p2p_radios.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'device_id');
|
||||
$sql .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
* Build ports WHERE array
|
||||
*
|
||||
* This function returns an array of "WHERE" statements from a $vars array.
|
||||
* The returned array can be implode()d and used on the ports table.
|
||||
* The returned array can be imploded and used on the ports table.
|
||||
* Originally extracted from the /ports/ page
|
||||
*
|
||||
* @param array $vars
|
||||
@ -27,20 +27,20 @@ function build_ports_where_array($vars) {
|
||||
if (!safe_empty($value)) {
|
||||
switch ($var) {
|
||||
case 'location':
|
||||
$where[] = generate_query_values($value, $var);
|
||||
$where[] = generate_query_values_and($value, $var);
|
||||
break;
|
||||
case 'device_id':
|
||||
$where[] = generate_query_values($value, 'ports.device_id');
|
||||
$where[] = generate_query_values_and($value, 'ports.device_id');
|
||||
break;
|
||||
case 'group':
|
||||
case 'group_id':
|
||||
$values = get_group_entities($value);
|
||||
$where[] = generate_query_values($values, 'ports.port_id');
|
||||
$where[] = generate_query_values_and($values, 'ports.port_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$where[] = generate_query_values($values, 'ports.device_id');
|
||||
$where[] = generate_query_values_and($values, 'ports.device_id');
|
||||
break;
|
||||
case 'disable':
|
||||
$var = 'disabled';
|
||||
@ -49,25 +49,26 @@ function build_ports_where_array($vars) {
|
||||
case 'ignore':
|
||||
case 'ifSpeed':
|
||||
case 'ifType':
|
||||
case 'ifVlan':
|
||||
case 'port_id':
|
||||
$where[] = generate_query_values($value, 'ports.'.$var);
|
||||
$where[] = generate_query_values_and($value, 'ports.'.$var);
|
||||
break;
|
||||
case 'hostname':
|
||||
case 'ifAlias':
|
||||
case 'ifDescr': // FIXME, probably better always use port_label instead ifDescr for search
|
||||
$where[] = generate_query_values($value, $var, '%LIKE%');
|
||||
$where[] = generate_query_values_and($value, $var, '%LIKE%');
|
||||
break;
|
||||
case 'label':
|
||||
case 'port_label':
|
||||
$where[] = generate_query_values($value, 'port_label', '%LIKE%');
|
||||
$where[] = generate_query_values_and($value, 'port_label', '%LIKE%');
|
||||
break;
|
||||
case 'mac':
|
||||
case 'ifPhysAddress':
|
||||
$value = str_replace([ '.', '-', ':' ], '', $value);
|
||||
$where[] = generate_query_values($value, 'ifPhysAddress', '%LIKE%');
|
||||
$where[] = generate_query_values_and($value, 'ifPhysAddress', '%LIKE%');
|
||||
break;
|
||||
case 'port_descr_type':
|
||||
$where[] = generate_query_values($value, $var, 'LIKE');
|
||||
$where[] = generate_query_values_and($value, $var, 'LIKE');
|
||||
break;
|
||||
case 'errors':
|
||||
if (get_var_true($value)) {
|
||||
@ -88,13 +89,13 @@ function build_ports_where_array($vars) {
|
||||
foreach ((array)$value as $state) {
|
||||
if ($state === "down") {
|
||||
$state_where[] = '`ifAdminStatus` = "up" AND `ifOperStatus` IN ("lowerLayerDown", "down")';
|
||||
//$state_where[] = generate_query_values('up', 'ifAdminStatus', NULL, FALSE) . generate_query_values(['down', 'lowerLayerDown'], 'ifOperStatus');
|
||||
//$state_where[] = generate_query_values_ng('up', 'ifAdminStatus') . generate_query_values_and(['down', 'lowerLayerDown'], 'ifOperStatus');
|
||||
} elseif ($state === "up") {
|
||||
$state_where[] = '`ifAdminStatus` = "up" AND `ifOperStatus` IN ("up", "testing", "monitoring")';
|
||||
//$state_where[] = generate_query_values('up', 'ifAdminStatus', NULL, FALSE) . generate_query_values(['up', 'testing', 'monitoring'], 'ifOperStatus');
|
||||
//$state_where[] = generate_query_values_ng('up', 'ifAdminStatus') . generate_query_values_and(['up', 'testing', 'monitoring'], 'ifOperStatus');
|
||||
} elseif ($state === "admindown" || $state === "shutdown") {
|
||||
$state_where[] = '`ifAdminStatus` = "down"';
|
||||
//$state_where[] = generate_query_values('down', 'ifAdminStatus', NULL, FALSE);
|
||||
//$state_where[] = generate_query_values_ng('down', 'ifAdminStatus');
|
||||
}
|
||||
}
|
||||
switch (count($state_where)) {
|
||||
@ -110,12 +111,12 @@ function build_ports_where_array($vars) {
|
||||
break;
|
||||
case 'cbqos':
|
||||
if ($value && $value !== 'no') {
|
||||
$where[] = generate_query_values($GLOBALS['cache']['ports']['cbqos'], 'ports.port_id');
|
||||
$where[] = generate_query_values_and($GLOBALS['cache']['ports']['cbqos'], 'ports.port_id');
|
||||
}
|
||||
break;
|
||||
case 'mac_accounting':
|
||||
if ($value && $value !== 'no') {
|
||||
$where[] = generate_query_values($GLOBALS['cache']['ports']['mac_accounting'], 'ports.port_id');
|
||||
$where[] = generate_query_values_and($GLOBALS['cache']['ports']['mac_accounting'], 'ports.port_id');
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -194,24 +195,26 @@ function generate_port_popup($port, $text = NULL, $type = NULL)
|
||||
$content = generate_device_popup_header($port);
|
||||
$content .= generate_port_popup_header($port);
|
||||
|
||||
$content .= '<div style="width: 700px">';
|
||||
//$content .= generate_box_open(array('body-style' => 'width: 700px;'));
|
||||
$graph_array['type'] = $port['graph_type'];
|
||||
$graph_array['legend'] = "yes";
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "275";
|
||||
$graph_array['to'] = $time['now'];
|
||||
$graph_array['from'] = $time['day'];
|
||||
$graph_array['id'] = $port['port_id'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $time['week'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $time['month'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $time['year'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= "</div>";
|
||||
//$content .= generate_box_close();
|
||||
if($type != "none") {
|
||||
$content .= '<div style="width: 700px">';
|
||||
//$content .= generate_box_open(array('body-style' => 'width: 700px;'));
|
||||
$graph_array['type'] = $port['graph_type'];
|
||||
$graph_array['legend'] = "yes";
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "275";
|
||||
$graph_array['to'] = $time['now'];
|
||||
$graph_array['from'] = $time['day'];
|
||||
$graph_array['id'] = $port['port_id'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $time['week'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $time['month'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $time['year'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= "</div>";
|
||||
//$content .= generate_box_close();
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
@ -454,7 +457,7 @@ function generate_port_row($port, $vars = array())
|
||||
if (!isset($cache['ports_option']['ipv4_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv4_addresses'])) {
|
||||
$sql = "SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?";
|
||||
// Do not exclude IPv4 link-local
|
||||
$sql .= generate_query_values(array_diff($ignore_type, [ 'link-local' ]), 'ipv4_type', '!='); // Do not show ignored ip types
|
||||
$sql .= generate_query_values_and(array_diff($ignore_type, [ 'link-local' ]), 'ipv4_type', '!='); // Do not show ignored ip types
|
||||
foreach (dbFetchRows($sql, array($port['port_id'])) as $ip)
|
||||
{
|
||||
$string .= $break . generate_popup_link('ip', $ip['ipv4_address'].'/'.$ip['ipv4_prefixlen'], NULL, 'small');
|
||||
@ -464,7 +467,7 @@ function generate_port_row($port, $vars = array())
|
||||
if (!isset($cache['ports_option']['ipv6_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv6_addresses']))
|
||||
{
|
||||
$sql = "SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?";
|
||||
$sql .= generate_query_values($ignore_type, 'ipv6_type', '!='); // Do not show ignored ip types
|
||||
$sql .= generate_query_values_and($ignore_type, 'ipv6_type', '!='); // Do not show ignored ip types
|
||||
foreach (dbFetchRows($sql, array($port['port_id'])) as $ip6)
|
||||
{
|
||||
$string .= $break . generate_popup_link('ip', $ip6['ipv6_address'].'/'.$ip6['ipv6_prefixlen'], NULL, 'small');
|
||||
|
||||
@ -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,28 +23,28 @@ function build_printersupplies_query($vars)
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'printersupplies.supply_id');
|
||||
$sql .= generate_query_values_and($values, 'printersupplies.supply_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'printersupplies.device_id');
|
||||
$sql .= generate_query_values_and($values, 'printersupplies.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'printersupplies.device_id');
|
||||
$sql .= generate_query_values_and($value, 'printersupplies.device_id');
|
||||
break;
|
||||
case "supply":
|
||||
case "supply_type";
|
||||
$sql .= generate_query_values($value, 'printersupplies.supply_type');
|
||||
$sql .= generate_query_values_and($value, 'printersupplies.supply_type');
|
||||
break;
|
||||
case "colour":
|
||||
case "supply_colour";
|
||||
$sql .= generate_query_values($value, 'supply_colour');
|
||||
$sql .= generate_query_values_and($value, 'supply_colour');
|
||||
break;
|
||||
case "descr":
|
||||
case "supply_descr";
|
||||
$sql .= generate_query_values($value, 'supply_descr', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'supply_descr', '%LIKE%');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -27,20 +27,20 @@ function generate_processor_query($vars)
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'processor_id');
|
||||
$sql .= generate_query_values_and($values, 'processor_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'processors.device_id');
|
||||
$sql .= generate_query_values_and($values, 'processors.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'processors.device_id');
|
||||
$sql .= generate_query_values_and($value, 'processors.device_id');
|
||||
break;
|
||||
case "descr":
|
||||
case "processor_descr";
|
||||
$sql .= generate_query_values($value, 'processor_descr', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'processor_descr', '%LIKE%');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -24,42 +23,42 @@ function generate_pseudowire_query($vars)
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'pseudowire_id');
|
||||
$sql .= generate_query_values_and($values, 'pseudowire_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'device_id');
|
||||
$sql .= generate_query_values_and($values, 'device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'device_id');
|
||||
$sql .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case "port":
|
||||
case "port_id":
|
||||
$sql .= generate_query_values($value, 'port_id');
|
||||
$sql .= generate_query_values_and($value, 'port_id');
|
||||
break;
|
||||
case "id":
|
||||
$sql .= generate_query_values($value, 'pseudowire_id');
|
||||
$sql .= generate_query_values_and($value, 'pseudowire_id');
|
||||
break;
|
||||
case "pwid":
|
||||
case "pwID":
|
||||
$sql .= generate_query_values($value, 'pwID');
|
||||
$sql .= generate_query_values_and($value, 'pwID');
|
||||
break;
|
||||
case "pwtype":
|
||||
$sql .= generate_query_values($value, 'pwType');
|
||||
$sql .= generate_query_values_and($value, 'pwType');
|
||||
break;
|
||||
case "psntype":
|
||||
$sql .= generate_query_values($value, 'pwPsnType');
|
||||
$sql .= generate_query_values_and($value, 'pwPsnType');
|
||||
break;
|
||||
case "peer_id":
|
||||
$sql .= generate_query_values($value, 'peer_device_id');
|
||||
$sql .= generate_query_values_and($value, 'peer_device_id');
|
||||
break;
|
||||
case "peer_addr":
|
||||
$sql .= generate_query_values($value, 'peer_addr');
|
||||
$sql .= generate_query_values_and($value, 'peer_addr');
|
||||
break;
|
||||
case "event":
|
||||
$sql .= generate_query_values($value, 'event');
|
||||
$sql .= generate_query_values_and($value, 'event');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -130,7 +129,7 @@ function get_pseudowire_table($vars)
|
||||
|
||||
if (!is_array($cache_pseudowires['ips'][$peer_addr]))
|
||||
{
|
||||
$cache_pseudowires['ips'][$peer_addr]['port_id'] = dbFetchCell('SELECT `port_id` FROM `'.$peer_addr_type.'_addresses` WHERE `'.$peer_addr_type.'_address` = ? '.generate_query_values($GLOBALS['cache']['ports']['pseudowires'], 'port_id').' LIMIT 1;', array($peer_addr));
|
||||
$cache_pseudowires['ips'][$peer_addr]['port_id'] = dbFetchCell('SELECT `port_id` FROM `'.$peer_addr_type.'_addresses` WHERE `'.$peer_addr_type.'_address` = ? '.generate_query_values_and($GLOBALS['cache']['ports']['pseudowires'], 'port_id').' LIMIT 1;', array($peer_addr));
|
||||
if (!is_numeric($cache_pseudowires['ips'][$peer_addr]['port_id']))
|
||||
{
|
||||
// Separate entry for find correct port
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -121,30 +121,30 @@ function build_sensor_query($vars, $query_count = FALSE) {
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'sensors.sensor_id');
|
||||
$sql .= generate_query_values_and($values, 'sensors.sensor_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'sensors.device_id');
|
||||
$sql .= generate_query_values_and($values, 'sensors.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'sensors.device_id');
|
||||
$sql .= generate_query_values_and($value, 'sensors.device_id');
|
||||
break;
|
||||
case "id":
|
||||
case "sensor_id":
|
||||
$sql .= generate_query_values($value, 'sensors.sensor_id');
|
||||
$sql .= generate_query_values_and($value, 'sensors.sensor_id');
|
||||
break;
|
||||
case "entity_id":
|
||||
$sql .= generate_query_values($value, 'sensors.measured_entity');
|
||||
$sql .= generate_query_values_and($value, 'sensors.measured_entity');
|
||||
break;
|
||||
case "entity_type":
|
||||
$sql .= generate_query_values($value, 'sensors.measured_class');
|
||||
$sql .= generate_query_values_and($value, 'sensors.measured_class');
|
||||
break;
|
||||
case 'entity_state':
|
||||
case "measured_state":
|
||||
$sql .= build_entity_measured_where('sensor', ['measured_state' => $value]);
|
||||
$sql .= build_entity_measured_where('sensor', [ 'measured_state' => $value ]);
|
||||
break;
|
||||
case "metric":
|
||||
// old metric param not allow array
|
||||
@ -153,19 +153,19 @@ function build_sensor_query($vars, $query_count = FALSE) {
|
||||
}
|
||||
case 'class':
|
||||
case "sensor_class":
|
||||
$sql .= generate_query_values($value, 'sensor_class');
|
||||
$sql .= generate_query_values_and($value, 'sensor_class');
|
||||
break;
|
||||
case "descr":
|
||||
case "sensor_descr":
|
||||
$sql .= generate_query_values($value, 'sensors.sensor_descr', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'sensors.sensor_descr', '%LIKE%');
|
||||
break;
|
||||
case "type":
|
||||
case "sensor_type":
|
||||
$sql .= generate_query_values($value, 'sensor_type', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'sensor_type', '%LIKE%');
|
||||
break;
|
||||
case "event":
|
||||
case "sensor_event":
|
||||
$sql .= generate_query_values($value, 'sensor_event');
|
||||
$sql .= generate_query_values_and($value, 'sensor_event');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -304,6 +304,126 @@ function print_sensor_table_header($vars) {
|
||||
echo('<tbody>' . PHP_EOL);
|
||||
}
|
||||
|
||||
function generate_sensor_line($sensor, $vars) {
|
||||
global $config;
|
||||
|
||||
humanize_sensor($sensor);
|
||||
|
||||
$graph_array = [];
|
||||
$graph_array['to'] = get_time();
|
||||
$graph_array['id'] = $sensor['sensor_id'];
|
||||
$graph_array['type'] = "sensor_graph";
|
||||
$graph_array['width'] = 80;
|
||||
$graph_array['height'] = 20;
|
||||
$graph_array['bg'] = 'ffffff00';
|
||||
$graph_array['from'] = get_time('day');
|
||||
$graph_array['style'] = 'margin-top: 5px';
|
||||
|
||||
if ($sensor['sensor_event'] && is_numeric($sensor['sensor_value'])) {
|
||||
$mini_graph = generate_graph_tag($graph_array);
|
||||
} else {
|
||||
// Do not show "Draw Error" minigraph
|
||||
$mini_graph = '';
|
||||
}
|
||||
|
||||
/*
|
||||
$sensor_tooltip = $sensor['event_descr'];
|
||||
// Append value in alternative units to tooltip
|
||||
if (isset($config['sensor_types'][$sensor['sensor_class']]['alt_units'])) {
|
||||
foreach (value_to_units($sensor['sensor_value'],
|
||||
$config['sensor_types'][$sensor['sensor_class']]['symbol'],
|
||||
$sensor['sensor_class'],
|
||||
$config['sensor_types'][$sensor['sensor_class']]['alt_units']) as $unit => $unit_value) {
|
||||
if (is_numeric($unit_value)) { $sensor_tooltip .= "<br />{$unit_value}{$unit}"; }
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//r($sensor);
|
||||
$text = '<span class="'. $sensor['event_class'].'">' . $sensor['human_value'] . $sensor['sensor_symbol'] . '</span>';
|
||||
|
||||
//$line = '<td class="state-marker"></td>';
|
||||
$line = '<td class="entity '.$sensor['row_class'].'">';
|
||||
//$btn_class = str_replace('label', 'btn', $sensor['event_class']); // FIXME Need button-outline-* class from bs4+
|
||||
if (get_var_true($vars['compact'])) {
|
||||
$line .= '<button class="btn btn-default" style="width: 105px; text-align: right;">';
|
||||
} else {
|
||||
// fixed button size for keep size without images
|
||||
$line .= '<button class="btn btn-default" style="width: 105px; height: 55px;">';
|
||||
}
|
||||
|
||||
$icon = get_icon($config['sensor_types'][$sensor['sensor_class']]['icon']);
|
||||
if ($sensor['sensor_class'] === 'power' || $sensor['sensor_class'] === 'dbm') {
|
||||
if (str_icontains_array($sensor['sensor_descr'], [ ' Rx', 'Rx ', 'Receive' ])) {
|
||||
// rx
|
||||
$icon = get_icon('glyphicon-arrow-down text-primary').' ';
|
||||
} elseif (str_icontains_array($sensor['sensor_descr'], [ ' Tx', 'Tx ', 'Trans' ])) {
|
||||
// tx
|
||||
$icon = get_icon('glyphicon-arrow-up text-danger').' ';
|
||||
}
|
||||
}
|
||||
|
||||
$line .= $icon.' ';
|
||||
$line .= generate_entity_link('sensor', $sensor, $text, NULL, FALSE);
|
||||
if (!get_var_true($vars['compact'])) {
|
||||
$line .= '<br />' .generate_entity_link('sensor', $sensor, $mini_graph, NULL, FALSE);
|
||||
}
|
||||
//$line .= '<strong>' . generate_tooltip_link('', $sensor['human_value'] . $sensor['sensor_symbol'], $sensor_tooltip, $sensor['event_class']) . '</strong>';
|
||||
$line .= '</button>';
|
||||
$line .= '</td>';
|
||||
|
||||
//r($line);
|
||||
return $line;
|
||||
}
|
||||
|
||||
function get_compact_sensors_line($measured_class, $entry, $vars) {
|
||||
|
||||
// order dom sensors always by temperature, voltage, current, dbm, power
|
||||
$order = [];
|
||||
if (safe_count($entry) > 0) {
|
||||
$classes = array_keys($entry);
|
||||
//r($types);
|
||||
if ($measured_class === 'port') {
|
||||
// always display all classes for dom (also if not exist)
|
||||
$order = [ 'temperature', 'voltage', 'current', /* 'dbm', 'power' */ ];
|
||||
// or dbm or power
|
||||
if (in_array('dbm', $classes, TRUE)) {
|
||||
$order[] = 'dbm';
|
||||
} elseif (in_array('power', $classes, TRUE)) {
|
||||
$order[] = 'power';
|
||||
} else {
|
||||
$order[] = 'dbm';
|
||||
}
|
||||
} else {
|
||||
$order = array_intersect([ 'temperature', 'voltage', 'current', 'dbm', 'power' ], $classes);
|
||||
}
|
||||
$order = array_merge($order, array_diff($classes, $order));
|
||||
//r($order);
|
||||
}
|
||||
$line = '';
|
||||
foreach ($order as $class) {
|
||||
if (!isset($entry[$class])) {
|
||||
// Add empty columns for port entities (for correct align)
|
||||
$line .= '<td class="entity"></td>';
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
*/
|
||||
|
||||
// Compact view per entity/lane
|
||||
$line .= generate_sensor_line($sensor, $vars);
|
||||
}
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
|
||||
function print_sensor_row($sensor, $vars)
|
||||
{
|
||||
echo generate_sensor_row($sensor, $vars);
|
||||
@ -404,7 +524,7 @@ function generate_sensor_row($sensor, $vars)
|
||||
$sensor['sensor_class'],
|
||||
$config['sensor_types'][$sensor['sensor_class']]['alt_units']) as $unit => $unit_value)
|
||||
{
|
||||
if (is_numeric($unit_value)) { $sensor_tooltip .= "<br />${unit_value}${unit}"; }
|
||||
if (is_numeric($unit_value)) { $sensor_tooltip .= "<br />{$unit_value}{$unit}"; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -23,38 +23,38 @@ function generate_sla_query($vars)
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'slas.sla_id');
|
||||
$sql .= generate_query_values_and($values, 'slas.sla_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'storage.device_id');
|
||||
$sql .= generate_query_values_and($values, 'storage.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'slas.device_id');
|
||||
$sql .= generate_query_values_and($value, 'slas.device_id');
|
||||
break;
|
||||
case "id":
|
||||
case "sla_id":
|
||||
$sql .= generate_query_values($value, 'slas.sla_id');
|
||||
$sql .= generate_query_values_and($value, 'slas.sla_id');
|
||||
break;
|
||||
case "owner":
|
||||
$sql .= generate_query_values($value, 'slas.sla_owner');
|
||||
$sql .= generate_query_values_and($value, 'slas.sla_owner');
|
||||
break;
|
||||
case "target":
|
||||
case "sla_target":
|
||||
$sql .= generate_query_values($value, 'slas.sla_target', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'slas.sla_target', '%LIKE%');
|
||||
break;
|
||||
case "sla_tag":
|
||||
$sql .= generate_query_values($value, 'slas.sla_tag');
|
||||
$sql .= generate_query_values_and($value, 'slas.sla_tag');
|
||||
break;
|
||||
case "rtt_type":
|
||||
case "rtt_sense":
|
||||
$sql .= generate_query_values($value, 'slas.'.$var);
|
||||
$sql .= generate_query_values_and($value, 'slas.'.$var);
|
||||
break;
|
||||
case "event":
|
||||
case "rtt_event":
|
||||
$sql .= generate_query_values($value, 'slas.rtt_event');
|
||||
$sql .= generate_query_values_and($value, 'slas.rtt_event');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -74,26 +74,26 @@ function generate_status_query($vars, $query_count = FALSE) {
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value, 'status');
|
||||
$sql .= generate_query_values($values, 'status.status_id');
|
||||
$sql .= generate_query_values_and($values, 'status.status_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'status.device_id');
|
||||
$sql .= generate_query_values_and($values, 'status.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'status.device_id');
|
||||
$sql .= generate_query_values_and($value, 'status.device_id');
|
||||
break;
|
||||
case "id":
|
||||
case 'status_id':
|
||||
$sql .= generate_query_values($value, 'status.status_id');
|
||||
$sql .= generate_query_values_and($value, 'status.status_id');
|
||||
break;
|
||||
case "entity_id":
|
||||
$sql .= generate_query_values($value, 'measured_entity');
|
||||
$sql .= generate_query_values_and($value, 'measured_entity');
|
||||
break;
|
||||
case "entity_type":
|
||||
$sql .= generate_query_values($value, 'measured_class');
|
||||
$sql .= generate_query_values_and($value, 'measured_class');
|
||||
break;
|
||||
case 'entity_state':
|
||||
case "measured_state":
|
||||
@ -101,23 +101,23 @@ function generate_status_query($vars, $query_count = FALSE) {
|
||||
break;
|
||||
case "class":
|
||||
case 'entPhysicalClass':
|
||||
$sql .= generate_query_values($value, 'entPhysicalClass');
|
||||
$sql .= generate_query_values_and($value, 'entPhysicalClass');
|
||||
break;
|
||||
case "event":
|
||||
case "status_event":
|
||||
$sql .= generate_query_values($value, 'status_event');
|
||||
$sql .= generate_query_values_and($value, 'status_event');
|
||||
break;
|
||||
case "status":
|
||||
case "status_name":
|
||||
$sql .= generate_query_values($value, 'status_name');
|
||||
$sql .= generate_query_values_and($value, 'status_name');
|
||||
break;
|
||||
case "descr":
|
||||
case "status_descr":
|
||||
$sql .= generate_query_values($value, 'status_descr', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'status_descr', '%LIKE%');
|
||||
break;
|
||||
case 'type':
|
||||
case "status_type":
|
||||
$sql .= generate_query_values($value, 'status_type', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'status_type', '%LIKE%');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -323,7 +323,7 @@ function generate_status_row($status, $vars) {
|
||||
$row .= '<td style="width: 90px; text-align: right;">' . generate_entity_link('status', $status, $mini_graph, NULL, FALSE) . '</td>';
|
||||
if ($vars['tab'] !== "overview")
|
||||
{
|
||||
$row .= '<td style="white-space: nowrap">' . generate_tooltip_link('', format_uptime((get_time() - $status['status_last_change']), 'short-2') . ' ago', format_unixtime($status['status_last_change'])) . '</td>
|
||||
$row .= '<td style="white-space: nowrap">' . generate_tooltip_time($status['status_last_change'], 'ago') . '</td>
|
||||
<td style="text-align: right;"><strong>' . generate_tooltip_link('', $status['status_event'], $status['event_descr'], $status['event_class']) . '</strong></td>';
|
||||
$table_cols++;
|
||||
$table_cols++;
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -30,23 +30,23 @@ function generate_storage_query($vars)
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'storage.storage_id');
|
||||
$sql .= generate_query_values_and($values, 'storage.storage_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'storage.device_id');
|
||||
$sql .= generate_query_values_and($values, 'storage.device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'storage.device_id');
|
||||
$sql .= generate_query_values_and($value, 'storage.device_id');
|
||||
break;
|
||||
case "descr":
|
||||
case "storage_descr";
|
||||
$sql .= generate_query_values($value, 'storage_descr', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'storage_descr', '%LIKE%');
|
||||
break;
|
||||
case 'ignored':
|
||||
$sql .= generate_query_values($value, 'storage.storage_ignore');
|
||||
$sql .= generate_query_values_and($value, 'storage.storage_ignore');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -92,8 +92,7 @@ function generate_storage_query($vars)
|
||||
|
||||
}
|
||||
|
||||
function print_storage_table($vars)
|
||||
{
|
||||
function print_storage_table($vars) {
|
||||
|
||||
global $cache, $config;
|
||||
|
||||
@ -101,13 +100,16 @@ function print_storage_table($vars)
|
||||
|
||||
$sql = generate_storage_query($vars);
|
||||
|
||||
$storages = array();
|
||||
$storages = [];
|
||||
foreach (dbFetchRows($sql) as $storage)
|
||||
{
|
||||
if (isset($cache['devices']['id'][$storage['device_id']]))
|
||||
{
|
||||
$storage['hostname'] = $cache['devices']['id'][$storage['device_id']]['hostname'];
|
||||
$storage['html_row_class'] = $cache['devices']['id'][$storage['device_id']]['html_row_class'];
|
||||
|
||||
// FIXME. Should be part of humanize_storage()
|
||||
$storage['human_type'] = array_preg_replace($config['rewrites']['storage_type_regexp'], $storage['storage_type']);
|
||||
$storages[] = $storage;
|
||||
}
|
||||
}
|
||||
@ -152,19 +154,19 @@ function print_storage_table_header($vars)
|
||||
}
|
||||
|
||||
echo('<table class="' . $table_class . '">' . PHP_EOL);
|
||||
$cols = array(
|
||||
array(NULL, 'class="state-marker"'),
|
||||
'device' => array('Device', 'style="width: 250px;"'),
|
||||
'mountpoint' => array('Mountpoint'),
|
||||
'size' => array('Size', 'style="width: 100px;"'),
|
||||
'used' => array('Used', 'style="width: 100px;"'),
|
||||
'free' => array('Free', 'style="width: 100px;"'),
|
||||
array('', 'style="width: 100px;"'),
|
||||
'usage' => array('Usage %', 'style="width: 200px;"'),
|
||||
);
|
||||
$cols = [
|
||||
[ NULL, 'class="state-marker"' ],
|
||||
'device' => [ 'Device', 'style="width: 250px;"' ],
|
||||
'mountpoint' => [ 'Mountpoint' ],
|
||||
'fstype' => [ 'FS Type', 'style="width: 90px;"' ],
|
||||
'size' => [ 'Size', 'style="width: 100px;"' ],
|
||||
'used' => [ 'Used', 'style="width: 100px;"' ],
|
||||
'free' => [ 'Free', 'style="width: 100px;"' ],
|
||||
[ '', 'style="width: 100px;"' ],
|
||||
'usage' => [ 'Usage %', 'style="width: 200px;"' ],
|
||||
];
|
||||
|
||||
if ($vars['page'] === "device")
|
||||
{
|
||||
if ($vars['page'] === "device") {
|
||||
unset($cols['device']);
|
||||
}
|
||||
|
||||
@ -182,10 +184,10 @@ function generate_storage_row($storage, $vars) {
|
||||
|
||||
global $config;
|
||||
|
||||
$table_cols = 8;
|
||||
$table_cols = 9;
|
||||
if ($vars['page'] !== "device" && $vars['popup'] != TRUE) { $table_cols++; } // Add a column for device.
|
||||
|
||||
if(isset($vars['graph_type']) && $vars['graph_type'] == "perc")
|
||||
if(isset($vars['graph_type']) && $vars['graph_type'] === "perc")
|
||||
|
||||
$graph_array = array();
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
@ -225,6 +227,7 @@ function generate_storage_row($storage, $vars) {
|
||||
if ($vars['page'] !== "device" && $vars['popup'] != TRUE) { $row .= '<td class="entity">' . generate_device_link($storage) . '</td>'; }
|
||||
|
||||
$row .= ' <td class="entity">'.generate_entity_link('storage', $storage).'</td>
|
||||
<td>'.$storage['human_type'].'</td>
|
||||
<td>'.$total.'</td>
|
||||
<td>'.$used.'</td>
|
||||
<td>'.$free.'</td>
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -23,28 +22,28 @@ function generate_vm_query($vars)
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$sql .= generate_query_values($values, 'vm_id');
|
||||
$sql .= generate_query_values_and($values, 'vm_id');
|
||||
break;
|
||||
case 'device_group_id':
|
||||
case 'device_group':
|
||||
$values = get_group_entities($value, 'device');
|
||||
$sql .= generate_query_values($values, 'device_id');
|
||||
$sql .= generate_query_values_and($values, 'device_id');
|
||||
break;
|
||||
case "device":
|
||||
case "device_id":
|
||||
$sql .= generate_query_values($value, 'device_id');
|
||||
$sql .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case "os":
|
||||
$sql .= generate_query_values($value, 'vm_guestos');
|
||||
$sql .= generate_query_values_and($value, 'vm_guestos');
|
||||
break;
|
||||
case "state":
|
||||
$sql .= generate_query_values($value, 'vm_state');
|
||||
$sql .= generate_query_values_and($value, 'vm_state');
|
||||
break;
|
||||
case "memory":
|
||||
$sql .= generate_query_values($value, 'vm_memory');
|
||||
$sql .= generate_query_values_and($value, 'vm_memory');
|
||||
break;
|
||||
case "cpu":
|
||||
$sql .= generate_query_values($value, 'vm_cpucount');
|
||||
$sql .= generate_query_values_and($value, 'vm_cpucount');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -162,9 +162,10 @@ function get_vars($vars_order = [], $auth = FALSE) {
|
||||
// <sCrIpT> < / s c r i p t >
|
||||
// javascript:alert("Hello world");/
|
||||
// <svg onload=alert(document.domain)>
|
||||
// <style/onload=alert(document.domain)>
|
||||
$prevent_xss = '!(^\s*(J\s*A\s*V\s*A\s*)?S\s*C\s*R\s*I\s*P\s*T\s*:'.
|
||||
'|<\s*/?\s*S\s*C\s*R\s*I\s*P\s*T\s*>'.
|
||||
'|(<\s*s\s*v\s*g.*(o\s*n\s*l\s*o\s*a\s*d|s\s*c\s*r\s*i\s*p\s*t))'.
|
||||
'|(<\s*\w+.*[\s\/&](o\s*n\s*l\s*o\s*a\s*d|s\s*c\s*r\s*i\s*p\s*t))'.
|
||||
'|<\s*i\s*m\s*g.*o\s*n\s*e\s*r\s*r\s*o\s*r)!i';
|
||||
|
||||
// Allow using var_decode(), this prevents to use potentially unsafe serialize functions
|
||||
@ -216,7 +217,6 @@ function get_vars($vars_order = [], $auth = FALSE) {
|
||||
|
||||
//sr($segments);
|
||||
//r($_SERVER['REQUEST_URI']);
|
||||
|
||||
foreach ($segments as $pos => $segment) {
|
||||
//$segment = urldecode($segment);
|
||||
if ($pos == "0" && !str_contains_array($segment, '=')) {
|
||||
@ -236,12 +236,12 @@ function get_vars($vars_order = [], $auth = FALSE) {
|
||||
if (!isset($value) || $value === '') {
|
||||
$vars[$name] = 'yes';
|
||||
} else {
|
||||
//r($value);
|
||||
if ($compressed && $value_uncompress = str_decompress($value)) {
|
||||
$value = $value_uncompress;
|
||||
unset($value_uncompress);
|
||||
} else {
|
||||
$value = str_replace('%7F', '/', urldecode($value)); // %7F (DEL, delete) - not defined in HTML 4 standard
|
||||
// rawurldecode() instead of urldecode() to translate %n and not mangle +
|
||||
$value = str_replace('%7F', '/', rawurldecode($value)); // %7F (DEL, delete) - not defined in HTML 4 standard
|
||||
}
|
||||
if (preg_match($prevent_xss, $value)) {
|
||||
// Prevent any <script> html tag inside vars, exclude any possible XSS with scripts
|
||||
@ -250,6 +250,7 @@ function get_vars($vars_order = [], $auth = FALSE) {
|
||||
|
||||
// Better to understand quoted vars
|
||||
$vars[$name] = get_var_csv($value, $auth);
|
||||
|
||||
if (is_string($vars[$name]) && preg_match($prevent_xss, $vars[$name])) {
|
||||
// Prevent any <script> html tag inside vars, exclude any possible XSS with scripts
|
||||
unset($vars[$name]);
|
||||
@ -273,7 +274,8 @@ function get_vars($vars_order = [], $auth = FALSE) {
|
||||
$value = $value_uncompress;
|
||||
unset($value_uncompress);
|
||||
} else {
|
||||
$value = str_replace('%7F', '/', urldecode($value)); // %7F (DEL, delete) - not defined in HTML 4 standard
|
||||
// rawurldecode() instead of urldecode() to translate %n and not mangle +
|
||||
$value = str_replace('%7F', '/', rawurldecode($value)); // %7F (DEL, delete) - not defined in HTML 4 standard
|
||||
}
|
||||
if (preg_match($prevent_xss, $value)) {
|
||||
// Prevent any <script> html tag inside vars, exclude any possible XSS with scripts
|
||||
@ -310,7 +312,6 @@ function get_vars($vars_order = [], $auth = FALSE) {
|
||||
}
|
||||
}
|
||||
|
||||
//r($vars);
|
||||
return($vars);
|
||||
}
|
||||
|
||||
@ -523,12 +524,10 @@ function detect_browser_type()
|
||||
* screen_size - initial size of browser window (if exist)
|
||||
*/
|
||||
// TESTME! needs unit testing
|
||||
function detect_browser($user_agent = NULL)
|
||||
{
|
||||
function detect_browser($user_agent = NULL) {
|
||||
$ua_custom = !is_null($user_agent); // Used custom user agent?
|
||||
|
||||
if (!$ua_custom && isset($GLOBALS['cache']['detect_browser']))
|
||||
{
|
||||
if (!$ua_custom && isset($GLOBALS['cache']['detect_browser'])) {
|
||||
//if (isset($_COOKIE['observium_screen_ratio']) && !isset($GLOBALS['cache']['detect_browser']['screen_resolution']))
|
||||
//{
|
||||
// r($_COOKIE);
|
||||
@ -539,8 +538,7 @@ function detect_browser($user_agent = NULL)
|
||||
|
||||
$detect = new Mobile_Detect;
|
||||
|
||||
if ($ua_custom)
|
||||
{
|
||||
if ($ua_custom) {
|
||||
// Set custom User-Agent
|
||||
$detect->setUserAgent($user_agent);
|
||||
} else {
|
||||
@ -550,13 +548,11 @@ function detect_browser($user_agent = NULL)
|
||||
// Default type and icon
|
||||
$type = 'generic';
|
||||
$icon = 'icon-laptop';
|
||||
if ($detect->isMobile())
|
||||
{
|
||||
if ($detect->isMobile()) {
|
||||
// Any phone device (exclude tablets).
|
||||
$type = 'mobile';
|
||||
$icon = 'glyphicon glyphicon-phone';
|
||||
if ($detect->isTablet())
|
||||
{
|
||||
if ($detect->isTablet()) {
|
||||
// Any tablet device.
|
||||
$type = 'tablet';
|
||||
$icon = 'icon-tablet';
|
||||
@ -565,8 +561,7 @@ function detect_browser($user_agent = NULL)
|
||||
|
||||
// Detect Browser name, version and platform
|
||||
$ua_info = [];
|
||||
if (!empty($user_agent))
|
||||
{
|
||||
if (!empty($user_agent)) {
|
||||
|
||||
//$ua_info = parse_user_agent($user_agent);
|
||||
$parser = new \donatj\UserAgent\UserAgentParser();
|
||||
@ -574,22 +569,23 @@ function detect_browser($user_agent = NULL)
|
||||
//r($ua);
|
||||
$ua_info['browser'] = $ua->browser();
|
||||
$ua_info['version'] = $ua->browserVersion();
|
||||
$ua_info['platform'] = $ua->platform();
|
||||
$ua_info['platform'] = str_replace('Macintosh', 'MacOS', $ua->platform());
|
||||
$ua_info['browser_full'] = $ua_info['browser'] . ' ' . preg_replace('/^([^\.]+(?:\.[^\.]+)?).*$/', '\1', $ua_info['version']);
|
||||
//r($ua_info);
|
||||
}
|
||||
|
||||
$detect_browser = array('user_agent' => $user_agent,
|
||||
'type' => $type,
|
||||
'icon' => $icon,
|
||||
'browser_full' => $ua_info['browser_full'],
|
||||
'browser' => $ua_info['browser'],
|
||||
'version' => $ua_info['version'],
|
||||
'platform' => $ua_info['platform']);
|
||||
$detect_browser = [
|
||||
'user_agent' => $user_agent,
|
||||
'type' => $type,
|
||||
'icon' => $icon,
|
||||
'browser_full' => $ua_info['browser_full'],
|
||||
'browser' => $ua_info['browser'],
|
||||
'version' => $ua_info['version'],
|
||||
'platform' => $ua_info['platform']
|
||||
];
|
||||
|
||||
// For custom UA, do not cache and return only base User-Agent info
|
||||
if ($ua_custom)
|
||||
{
|
||||
if ($ua_custom) {
|
||||
return $detect_browser;
|
||||
}
|
||||
|
||||
@ -600,15 +596,12 @@ function detect_browser($user_agent = NULL)
|
||||
register_html_resource('js', 'observium-screen.js');
|
||||
|
||||
// Additional browser info (screen_ratio, screen_size, svg)
|
||||
if ($ua_info['browser'] === 'Firefox' && version_compare($ua_info['version'], '47.0') < 0)
|
||||
{
|
||||
if ($ua_info['browser'] === 'Firefox' && version_compare($ua_info['version'], '47.0') < 0) {
|
||||
// Do not use srcset in FF, while issue open:
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1149357
|
||||
// Update, seems as in 47.0 partially fixed
|
||||
$zoom = 1;
|
||||
}
|
||||
else if (isset($_COOKIE['observium_screen_ratio']))
|
||||
{
|
||||
} elseif (isset($_COOKIE['observium_screen_ratio'])) {
|
||||
// Note, Opera uses ratio 1.5
|
||||
$zoom = round($_COOKIE['observium_screen_ratio']); // Use int zoom
|
||||
} else {
|
||||
@ -617,8 +610,7 @@ function detect_browser($user_agent = NULL)
|
||||
}
|
||||
$detect_browser['screen_ratio'] = $zoom;
|
||||
//$detect_browser['svg'] = ($ua_info['browser'] == 'Firefox'); // SVG supported or allowed
|
||||
if (isset($_COOKIE['observium_screen_resolution']))
|
||||
{
|
||||
if (isset($_COOKIE['observium_screen_resolution'])) {
|
||||
$detect_browser['screen_resolution'] = $_COOKIE['observium_screen_resolution'];
|
||||
//$detect_browser['screen_size'] = $_COOKIE['observium_screen_size'];
|
||||
}
|
||||
@ -677,34 +669,29 @@ function generate_link($text, $vars, $new_vars = array(), $escape = TRUE)
|
||||
|
||||
// TESTME needs unit testing
|
||||
// DOCME needs phpdoc block
|
||||
function pagination(&$vars, $total, $return_vars = FALSE)
|
||||
{
|
||||
$pagesizes = array(10,20,50,100,500,1000,10000,50000); // Permitted pagesizes
|
||||
if (is_numeric($vars['pagesize']))
|
||||
{
|
||||
function pagination(&$vars, $total, $options = array()) {
|
||||
|
||||
// Compatibility with pre-options
|
||||
if($options === TRUE) { $options = []; $options['return_vars'] = TRUE; }
|
||||
|
||||
$pagesizes = [ 10, 20, 50, 100, 500, 1000, 10000, 50000 ]; // Permitted pagesizes
|
||||
if (is_numeric($vars['pagesize'])) {
|
||||
$per_page = (int)$vars['pagesize'];
|
||||
}
|
||||
else if (isset($_SESSION['pagesize']))
|
||||
{
|
||||
} elseif (isset($_SESSION['pagesize'])) {
|
||||
$per_page = $_SESSION['pagesize'];
|
||||
} else {
|
||||
$per_page = $GLOBALS['config']['web_pagesize'];
|
||||
}
|
||||
if (!$vars['short'])
|
||||
{
|
||||
|
||||
if (!$vars['short']) {
|
||||
// Permit fixed pagesizes only (except $vars['short'] == TRUE)
|
||||
foreach ($pagesizes as $pagesize)
|
||||
{
|
||||
foreach ($pagesizes as $pagesize) {
|
||||
if ($per_page <= $pagesize) { $per_page = $pagesize; break; }
|
||||
}
|
||||
if (isset($vars['pagesize']) && $vars['pagesize'] != $_SESSION['pagesize'])
|
||||
{
|
||||
if ($vars['pagesize'] != $GLOBALS['config']['web_pagesize'])
|
||||
{
|
||||
if (isset($vars['pagesize']) && $vars['pagesize'] != $_SESSION['pagesize']) {
|
||||
if ($vars['pagesize'] != $GLOBALS['config']['web_pagesize']) {
|
||||
session_set_var('pagesize', $per_page); // Store pagesize in session only if changed default
|
||||
}
|
||||
else if (isset($_SESSION['pagesize']))
|
||||
{
|
||||
} elseif (isset($_SESSION['pagesize'])) {
|
||||
session_unset_var('pagesize'); // Reset pagesize from session
|
||||
}
|
||||
}
|
||||
@ -713,11 +700,14 @@ function pagination(&$vars, $total, $return_vars = FALSE)
|
||||
|
||||
$page = (int)$vars['pageno'];
|
||||
$lastpage = ceil($total/$per_page);
|
||||
if ($page < 1) { $page = 1; }
|
||||
else if (!$return_vars && $lastpage < $page) { $page = (int)$lastpage; }
|
||||
if ($page < 1) {
|
||||
$page = 1;
|
||||
} elseif (!$options['return_vars'] && $lastpage < $page) {
|
||||
$page = (int)$lastpage;
|
||||
}
|
||||
$vars['pageno'] = $page; // Return back current pageno
|
||||
|
||||
if ($return_vars) { return ''; } // Silent exit (needed for detect default pagesize/pageno)
|
||||
if ($options['return_vars'] == TRUE) { return ''; } // Silent exit (needed for detect default pagesize/pageno)
|
||||
|
||||
$start = ($page - 1) * $per_page;
|
||||
$prev = $page - 1;
|
||||
@ -728,13 +718,14 @@ function pagination(&$vars, $total, $return_vars = FALSE)
|
||||
$pagination = '';
|
||||
|
||||
// Show pagination if total > 99, total > page size, or web_always_paginate is set.
|
||||
if ($total > 99 || $total > $per_page || ( isset($GLOBALS['config']['web_always_paginate']) && $GLOBALS['config']['web_always_paginate'] === 1))
|
||||
{
|
||||
|
||||
|
||||
|
||||
if($total > 9999) { $total_text = format_si($total); } else { $total_text = $total; }
|
||||
if ($total > 99 || $total > $per_page ||
|
||||
(isset($GLOBALS['config']['web_always_paginate']) && $GLOBALS['config']['web_always_paginate'] === 1)) {
|
||||
|
||||
if ($total > 9999) {
|
||||
$total_text = format_si($total);
|
||||
} else {
|
||||
$total_text = $total;
|
||||
}
|
||||
|
||||
$pagination .= '<div class="row">' . PHP_EOL .
|
||||
' <div class="col-lg-1 col-md-2 col-sm-2" style="display: inline-block;">' . PHP_EOL .
|
||||
@ -744,32 +735,23 @@ function pagination(&$vars, $total, $return_vars = FALSE)
|
||||
' <div class="col-lg-10 col-md-8 col-sm-8">' . PHP_EOL .
|
||||
' <div class="pagination pagination-centered"><ul>' . PHP_EOL;
|
||||
|
||||
if ($prev)
|
||||
{
|
||||
if ($prev) {
|
||||
//$pagination .= ' <li><a href="'.generate_url($vars, array('pageno' => 1)).'">First</a></li>' . PHP_EOL;
|
||||
$pagination .= ' <li><a href="'.generate_url($vars, array('pageno' => $prev)).'">Prev</a></li>' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ($lastpage < 7 + ($adjacents * 2))
|
||||
{
|
||||
for ($counter = 1; $counter <= $lastpage; $counter++)
|
||||
{
|
||||
if ($counter == $page)
|
||||
{
|
||||
if ($lastpage < 7 + ($adjacents * 2)) {
|
||||
for ($counter = 1; $counter <= $lastpage; $counter++) {
|
||||
if ($counter == $page) {
|
||||
$pagination.= "<li class='active'><a>$counter</a></li>";
|
||||
} else {
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => $counter))."'>$counter</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => $counter ])."'>$counter</a></li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($lastpage > 5 + ($adjacents * 2))
|
||||
{
|
||||
if ($page < 1 + ($adjacents * 2))
|
||||
{
|
||||
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
|
||||
{
|
||||
if ($counter == $page)
|
||||
{
|
||||
} elseif ($lastpage > 5 + ($adjacents * 2)) {
|
||||
if ($page < 1 + ($adjacents * 2)) {
|
||||
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) {
|
||||
if ($counter == $page) {
|
||||
$pagination .= "<li class='active'><a>$counter</a></li>";
|
||||
} else {
|
||||
$class = '';
|
||||
@ -781,37 +763,31 @@ function pagination(&$vars, $total, $return_vars = FALSE)
|
||||
//{
|
||||
// $class = ' class="hidden-sm hidden-xs"';
|
||||
//}
|
||||
$pagination .= "<li$class><a href='".generate_url($vars, array('pageno' => $counter))."'>$counter</a></li>";
|
||||
$pagination .= "<li$class><a href='".generate_url($vars, [ 'pageno' => $counter ])."'>$counter</a></li>";
|
||||
}
|
||||
}
|
||||
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => $lpm1))."'>$lpm1</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => $lastpage))."'>$lastpage</a></li>";
|
||||
}
|
||||
elseif ($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
|
||||
{
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => '1'))."'>1</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => '2'))."'>2</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => $lpm1 ])."'>$lpm1</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => $lastpage ])."'>$lastpage</a></li>";
|
||||
} elseif ($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) {
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => '1' ])."'>1</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => '2' ])."'>2</a></li>";
|
||||
|
||||
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
|
||||
{
|
||||
if ($counter == $page)
|
||||
{
|
||||
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) {
|
||||
if ($counter == $page) {
|
||||
$pagination.= "<li class='active'><a>$counter</a></li>";
|
||||
} else {
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => $counter))."'>$counter</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => $counter ])."'>$counter</a></li>";
|
||||
}
|
||||
}
|
||||
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => $lpm1))."'>$lpm1</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => $lastpage))."'>$lastpage</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => $lpm1 ])."'>$lpm1</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => $lastpage ])."'>$lastpage</a></li>";
|
||||
} else {
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => '1'))."'>1</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => '2'))."'>2</a></li>";
|
||||
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
|
||||
{
|
||||
if ($counter == $page)
|
||||
{
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => '1' ])."'>1</a></li>";
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => '2' ])."'>2</a></li>";
|
||||
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) {
|
||||
if ($counter == $page) {
|
||||
$pagination.= "<li class='active'><a>$counter</a></li>";
|
||||
} else {
|
||||
$class = '';
|
||||
@ -823,20 +799,17 @@ function pagination(&$vars, $total, $return_vars = FALSE)
|
||||
//{
|
||||
// $class = ' class="hidden-sm hidden-xs"';
|
||||
//}
|
||||
$pagination.= "<li$class><a href='".generate_url($vars, array('pageno' => $counter))."'>$counter</a></li>";
|
||||
$pagination.= "<li$class><a href='".generate_url($vars, [ 'pageno' => $counter ])."'>$counter</a></li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($page < $counter - 1)
|
||||
{
|
||||
$pagination.= "<li><a href='".generate_url($vars, array('pageno' => $next))."'>Next</a></li>";
|
||||
if ($page < $counter - 1) {
|
||||
$pagination.= "<li><a href='".generate_url($vars, [ 'pageno' => $next ])."'>Next</a></li>";
|
||||
# No need for "Last" as we don't have "First", 1, 2 and the 2 last pages are always in the list.
|
||||
#$pagination.= "<li><a href='".generate_url($vars, array('pageno' => $lastpage))."'>Last</a></li>";
|
||||
}
|
||||
else if ($lastpage > 1)
|
||||
{
|
||||
} elseif ($lastpage > 1) {
|
||||
$pagination.= "<li class='active'><a>Next</a></li>";
|
||||
#$pagination.= "<li class='active'><a>Last</a></li>";
|
||||
}
|
||||
@ -844,21 +817,22 @@ function pagination(&$vars, $total, $return_vars = FALSE)
|
||||
$pagination.= "</ul></div></div>";
|
||||
|
||||
//$values = array('' => array('name'))
|
||||
foreach ($pagesizes as $pagesize)
|
||||
{
|
||||
$value = generate_url($vars, array('pagesize' => $pagesize, 'pageno' => floor($start / $pagesize)));
|
||||
$name = ($pagesize == $GLOBALS['config']['web_pagesize'] ? "[ $pagesize ]" : $pagesize);
|
||||
$values[$value] = array('name' => $name, 'class' => 'text-center');
|
||||
foreach ($pagesizes as $pagesize) {
|
||||
$value = generate_url($vars, [ 'pagesize' => $pagesize, 'pageno' => floor(fdiv($start, $pagesize)) ]);
|
||||
$name = $pagesize == $GLOBALS['config']['web_pagesize'] ? "[ $pagesize ]" : $pagesize;
|
||||
$values[$value] = [ 'name' => $name, 'class' => 'text-center' ];
|
||||
}
|
||||
$element = array('type' => 'select',
|
||||
'class' => 'pagination',
|
||||
'id' => 'pagesize',
|
||||
'name' => '# '.$per_page,
|
||||
'width' => '90px',
|
||||
'onchange' => "window.open(this.options[this.selectedIndex].value,'_top')",
|
||||
'value' => $per_page,
|
||||
'data-style' => 'box',
|
||||
'values' => $values);
|
||||
$element = [
|
||||
'type' => 'select',
|
||||
'class' => 'pagination',
|
||||
'id' => 'pagesize',
|
||||
'name' => '# '.$per_page,
|
||||
'width' => '90px',
|
||||
'onchange' => "window.open(this.options[this.selectedIndex].value,'_top')",
|
||||
'value' => $per_page,
|
||||
'data-style' => 'box',
|
||||
'values' => $values
|
||||
];
|
||||
|
||||
$pagination.= '
|
||||
<div class="col-lg-1 col-md-2 col-sm-2">
|
||||
@ -1130,6 +1104,28 @@ function generate_popup_link($type, $text = NULL, $vars = array(), $class = NULL
|
||||
return '<a href="'.$url.'" class="entity-popup'.($class ? " $class" : '').'" data-eid="'.$data.'" data-etype="'.$type.'">'.$text.'</a>';
|
||||
}
|
||||
|
||||
function generate_tooltip_time($timestamp, $text = '') {
|
||||
if (is_numeric($timestamp) && $timestamp > OBS_MIN_UNIXTIME) {
|
||||
// Unixtime
|
||||
$timediff = get_time() - $timestamp;
|
||||
$timetext = format_uptime($timediff, "short-3");
|
||||
if (!safe_empty($text)) {
|
||||
$timetext .= " $text";
|
||||
}
|
||||
|
||||
return generate_tooltip_link('', $timetext, format_unixtime($timestamp), NULL);
|
||||
}
|
||||
|
||||
// Timestamp
|
||||
$timediff = get_time() - strtotime($timestamp);
|
||||
$timetext = format_uptime($timediff, "short-3");
|
||||
if (!safe_empty($text)) {
|
||||
$timetext .= " $text";
|
||||
}
|
||||
|
||||
return generate_tooltip_link('', $timetext, format_timestamp($timestamp), NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate mouseover links with static tooltip from URL, link text, contents and a class.
|
||||
*
|
||||
@ -1146,21 +1142,19 @@ function generate_popup_link($type, $text = NULL, $vars = array(), $class = NULL
|
||||
* @return string
|
||||
*/
|
||||
// TESTME needs unit testing
|
||||
function generate_tooltip_link($url, $text, $contents = '', $class = NULL, $attribs = [], $escape = FALSE)
|
||||
{
|
||||
function generate_tooltip_link($url, $text, $contents = '', $class = NULL, $attribs = [], $escape = FALSE) {
|
||||
global $config, $link_iter;
|
||||
|
||||
$link_iter++;
|
||||
|
||||
$href = (strlen($url) ? 'href="' . $url . '"' : '');
|
||||
$href = !safe_empty($url) ? 'href="' . $url . '"' : '';
|
||||
if ($escape) { $text = escape_html($text); }
|
||||
|
||||
$attribs['class'] = array_merge((array)$class, (array)$attribs['class']);
|
||||
|
||||
// Allow the Grinch to disable popups and destroy Christmas.
|
||||
$allow_mobile = (in_array(detect_browser_type(), array('mobile', 'tablet')) ? $config['web_mouseover_mobile'] : TRUE);
|
||||
if ($config['web_mouseover'] && strlen($contents) && $allow_mobile)
|
||||
{
|
||||
$allow_mobile = !in_array(detect_browser_type(), [ 'mobile', 'tablet' ]) || $config['web_mouseover_mobile'];
|
||||
if ($config['web_mouseover'] && $allow_mobile && !safe_empty($contents)) {
|
||||
$attribs['style'] = 'cursor: pointer;';
|
||||
$attribs['data-rel'] = 'tooltip';
|
||||
$attribs['data-tooltip'] = $contents;
|
||||
@ -1387,26 +1381,29 @@ function print_graph_popup($graph_array)
|
||||
|
||||
// TESTME needs unit testing
|
||||
// DOCME needs phpdoc block
|
||||
function permissions_cache($user_id)
|
||||
{
|
||||
$permissions = array();
|
||||
function permissions_cache($user_id) {
|
||||
|
||||
$cache_key = 'permissions_'.$GLOBALS['config']['auth_mechanism'].$user_id;
|
||||
$cache_item = get_cache_item($cache_key);
|
||||
if (ishit_cache_item($cache_item)) {
|
||||
return get_cache_data($cache_item);
|
||||
}
|
||||
|
||||
$permissions = [];
|
||||
|
||||
// Get permissions from user-specific and role tables.
|
||||
$permission_where = '`user_id` = ? AND `auth_mechanism` = ?';
|
||||
$permission_params = [ $user_id, $GLOBALS['config']['auth_mechanism'] ];
|
||||
$entity_permissions = dbFetchRows("SELECT * FROM `entity_permissions` WHERE " . $permission_where, $permission_params);
|
||||
$roles_entity_permissions = dbFetchRows("SELECT * FROM `roles_entity_permissions` LEFT JOIN `roles_users` USING (`role_id`) WHERE " . $permission_where, $permission_params);
|
||||
foreach (array_merge((array)$entity_permissions, (array)$roles_entity_permissions) as $entity)
|
||||
{
|
||||
foreach (array_merge((array)$entity_permissions, (array)$roles_entity_permissions) as $entity) {
|
||||
// Set access to ro if it's not in the defined list.
|
||||
$access = (in_array($entity['access'], array('ro', 'rw')) ? $entity['access'] : 'ro');
|
||||
|
||||
switch ($entity['entity_type'])
|
||||
{
|
||||
switch ($entity['entity_type']) {
|
||||
case "group": // this is a group, so expand its members into an array
|
||||
$group = get_group_by_id($entity['entity_id']);
|
||||
foreach (get_group_entities($entity['entity_id']) as $group_entity_id)
|
||||
{
|
||||
foreach (get_group_entities($entity['entity_id']) as $group_entity_id) {
|
||||
$permissions[$group['entity_type']][$group_entity_id] = $access;
|
||||
}
|
||||
//break; // And also store self group permission in cache
|
||||
@ -1425,20 +1422,22 @@ function permissions_cache($user_id)
|
||||
|
||||
// Alerts
|
||||
// FIXME - this seems like it would be slow on very large installs
|
||||
$alert = array();
|
||||
foreach (dbFetchRows('SELECT `alert_table_id`, `device_id`, `entity_id`, `entity_type` FROM `alert_table`') as $alert_table_entry)
|
||||
{
|
||||
$alert = [];
|
||||
foreach (dbFetchRows('SELECT `alert_table_id`, `device_id`, `entity_id`, `entity_type` FROM `alert_table`') as $alert_table_entry) {
|
||||
//r($alert_table_entry);
|
||||
if (is_entity_permitted($alert_table_entry['entity_id'], $alert_table_entry['entity_type'], $alert_table_entry['device_id'], $permissions))
|
||||
{
|
||||
if (is_entity_permitted($alert_table_entry['entity_id'], $alert_table_entry['entity_type'], $alert_table_entry['device_id'], $permissions)) {
|
||||
$alert[$alert_table_entry['alert_table_id']] = TRUE;
|
||||
}
|
||||
}
|
||||
if (count($alert))
|
||||
{
|
||||
if (count($alert)) {
|
||||
$permissions['alert'] = $alert;
|
||||
}
|
||||
|
||||
set_cache_item($cache_item, $permissions);
|
||||
|
||||
// Clear expired cache
|
||||
del_cache_expired();
|
||||
|
||||
return $permissions;
|
||||
|
||||
}
|
||||
@ -1882,11 +1881,11 @@ function get_locations($filter = array()) {
|
||||
case 'location_city':
|
||||
// Check geo params only when GEO enabled globally
|
||||
if ($GLOBALS['config']['geocoding']['enable']) {
|
||||
$where_array[$var] = generate_query_values($value, $var);
|
||||
$where_array[$var] = generate_query_values_and($value, $var);
|
||||
}
|
||||
break;
|
||||
case 'location':
|
||||
$where_array[$var] = generate_query_values($value, $var);
|
||||
$where_array[$var] = generate_query_values_and($value, $var);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2209,13 +2208,16 @@ function generate_query_permitted($type_array = [ 'device' ], $options = []) {
|
||||
if (!isset($options['port_null']) || !$options['port_null']) {
|
||||
//$query_permitted[] = "($column != '' AND $column IS NOT NULL)";
|
||||
$query_permitted[] = "$column IS NOT NULL";
|
||||
} elseif (!$user_limited) {
|
||||
} elseif (!$user_limited && safe_count($query_permitted)) {
|
||||
// FIXME. derp code, need rewrite
|
||||
$query_permitted[] = safe_count($query_permitted) ? "OR $column IS NULL" : "$column IS NULL";
|
||||
//$query_permitted[] = safe_count($query_permitted) ? "OR $column IS NULL" : "$column IS NULL";
|
||||
$query_permitted[] = "OR $column IS NULL";
|
||||
}
|
||||
$query_permitted = implode(" AND ", (array)$query_permitted);
|
||||
|
||||
$query_part[] = str_replace(" AND OR ", ' OR ', $query_permitted);
|
||||
if (!safe_empty($query_permitted)) {
|
||||
$query_part[] = str_replace(" AND OR ", ' OR ', $query_permitted);
|
||||
}
|
||||
unset($query_permitted);
|
||||
|
||||
break;
|
||||
@ -2384,7 +2386,7 @@ function load_user_config(&$load_config, $user_id) {
|
||||
if (!isset($config_variable[$item['pref']]['useredit']) ||
|
||||
!$config_variable[$item['pref']]['useredit']) {
|
||||
// Load only permitted settings
|
||||
print_debug("User [$user_id] setting '${item['pref']}' not permitted by definitions.");
|
||||
print_debug("User [$user_id] setting '{$item['pref']}' not permitted by definitions.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2628,11 +2630,10 @@ function get_smokeping_files($rdebug = 0)
|
||||
|
||||
if ($rdebug) { echo('- Recursing through ' . $config['smokeping']['dir'] . '<br />'); }
|
||||
|
||||
if (isset($config['smokeping']['master_hostname']))
|
||||
{
|
||||
if (isset($config['smokeping']['master_hostname'])) {
|
||||
$master_hostname = $config['smokeping']['master_hostname'];
|
||||
} else {
|
||||
$master_hostname = $config['own_hostname'];
|
||||
$master_hostname = $config['own_hostname'] ?: get_localhost();
|
||||
}
|
||||
|
||||
if (is_dir($config['smokeping']['dir']))
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,21 +6,22 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if (is_numeric($vars['id']))
|
||||
{
|
||||
if (is_numeric($vars['id'])) {
|
||||
|
||||
$data = dbFetchRow("SELECT * FROM `bgpPeers` WHERE `bgpPeer_id` = ?", array($vars['id']));
|
||||
$data = dbFetchRow("SELECT * FROM `bgpPeers` WHERE `bgpPeer_id` = ?", [ $vars['id'] ]);
|
||||
|
||||
if (is_numeric($data['device_id']) && ($auth || device_permitted($data['device_id'])))
|
||||
{
|
||||
if (is_numeric($data['device_id']) && ($auth || device_permitted($data['device_id']))) {
|
||||
$device = device_by_id_cache($data['device_id']);
|
||||
|
||||
$graph_title = $device['hostname'];
|
||||
$graph_title .= " :: AS" . ($config['web_show_bgp_asdot'] ? bgp_asplain_to_asdot($data['bgpPeerRemoteAs']) : $data['bgpPeerRemoteAs']);
|
||||
if (!safe_empty($data['astext'])) {
|
||||
$graph_title .= ' (' . truncate($data['astext']) . ')';
|
||||
}
|
||||
$auth = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,18 +51,22 @@ if ($vars['inverse']) {
|
||||
$inverse = FALSE;
|
||||
}
|
||||
|
||||
|
||||
if ($vars['legend'] === 'no') {
|
||||
$rrd_options .= ' -g';
|
||||
$legend = 'no';
|
||||
}
|
||||
|
||||
if (get_var_true($vars['title']) && !safe_empty($graph_title)) {
|
||||
$rrd_options .= " --title='" . rrdtool_escape($graph_title) . "' ";
|
||||
// Note, do not escape title by rrdtool escape
|
||||
//$rrd_options .= " --title='" . rrdtool_escape($graph_title) . "' ";
|
||||
$rrd_options .= " --title=" . escapeshellarg($graph_title) . " ";
|
||||
}
|
||||
|
||||
if (isset($vars['graph_title'])) {
|
||||
$rrd_options .= " --title='" . rrdtool_escape($vars['graph_title']) . "' ";
|
||||
// Note, do not escape title by rrdtool escape
|
||||
//$rrd_options .= " --title='" . rrdtool_escape($vars['graph_title']) . "' ";
|
||||
$rrd_options .= " --title=" . escapeshellarg($vars['graph_title']) . " ";
|
||||
}
|
||||
|
||||
// Vertical label
|
||||
if (!safe_empty($graph_label)) {
|
||||
// Note, do not escape title by rrdtool escape
|
||||
$rrd_options .= " --vertical-label=" . escapeshellarg($graph_label) . " ";
|
||||
}
|
||||
|
||||
if (isset($log_y)) {
|
||||
@ -90,7 +94,9 @@ if (isset($vars['style']) && $vars['style']) {
|
||||
}
|
||||
|
||||
// Autoscale
|
||||
if (!isset($scale_min) && !isset($scale_max)) {
|
||||
if(isset($vars['force_autoscale']) && in_array($vars['force_autoscale'], ['yes', 'true', 1])) {
|
||||
$rrd_options .= ' -A';
|
||||
} elseif (!isset($scale_min) && !isset($scale_max)) {
|
||||
if ($graph_style === 'mrtg' && !isset($log_y)) { // Don't use this if we're doing logarithmic scale, else it breaks.
|
||||
$rrd_options .= ' --alt-autoscale-max';
|
||||
} else {
|
||||
@ -137,19 +143,14 @@ if (!$config['graphs']['always_draw_max']) {
|
||||
}
|
||||
}
|
||||
|
||||
$rrd_options .= ' --start ' . rrdtool_escape($from) .
|
||||
' --end ' . rrdtool_escape($to) .
|
||||
' --width ' . rrdtool_escape($width) .
|
||||
' --height ' . rrdtool_escape($height) . ' ';
|
||||
|
||||
// Parse pango markup. Breaks chevrons and other stuff.
|
||||
//$rrd_options .= ' -P ';
|
||||
|
||||
if ($config['themes'][$_SESSION['theme']]['type'] === 'dark') {
|
||||
$rrd_options .= str_replace(" ", " ", $config['rrdgraph']['dark']);
|
||||
$rrd_options .= ' ' .str_replace(" ", " ", $config['rrdgraph']['dark']);
|
||||
$nan_colour = "#FF000020";
|
||||
} else {
|
||||
$rrd_options .= str_replace(" ", " ", $config['rrdgraph']['light']);
|
||||
$rrd_options .= ' '. str_replace(" ", " ", $config['rrdgraph']['light']);
|
||||
$nan_colour = "#FFAAAA20";
|
||||
}
|
||||
|
||||
@ -169,8 +170,11 @@ if ($width <= '350') {
|
||||
$rrd_options .= " --font LEGEND:8:'" . $config['mono_font'] . "' --font AXIS:7:'" . $config['mono_font'] . "'";
|
||||
}
|
||||
|
||||
//$rrd_options .= ' --font-render-mode normal --dynamic-labels'; // dynamic-labels not supported in rrdtool < 1.4
|
||||
$rrd_options .= ' --font-render-mode normal';
|
||||
if ($config['graphs']['dynamic_labels']) {
|
||||
// dynamic-labels not supported in rrdtool < 1.4
|
||||
$rrd_options .= ' --dynamic-labels';
|
||||
}
|
||||
|
||||
if ($step != TRUE) {
|
||||
$rrd_options .= ' -E';
|
||||
|
||||
@ -20,7 +20,7 @@ foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_des
|
||||
$rrd_list[] = [ 'filename' => $rrd_filename,
|
||||
'descr' => $port['hostname'] ."-". $port['ifDescr'],
|
||||
'descr_in' => device_name($port, TRUE),
|
||||
'descr_out' => short_ifname($port['ifDescr'], NULL, FALSE) ]; // Options sets for skip htmlentities
|
||||
'descr_out' => short_ifname($port['port_label'], NULL, FALSE) ]; // Options sets for skip htmlentities
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
$ds_in = "INOCTETS";
|
||||
$ds_out = "OUTOCTETS";
|
||||
|
||||
$graph_return = array('descr' => 'Device total traffic in bits/sec.');
|
||||
$graph_return['descr'] = 'Device total traffic in bits/sec.';
|
||||
|
||||
// init
|
||||
$i = 0;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,14 +6,14 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$sql = "SELECT * FROM `processors` WHERE `processor_type` != 'hr-average' AND `device_id` = ?";
|
||||
if (isset($vars['filter_id']))
|
||||
{
|
||||
$sql .= generate_query_values($vars['filter_id'], 'processor_id');
|
||||
$sql .= generate_query_values_and($vars['filter_id'], 'processor_id');
|
||||
}
|
||||
$procs = dbFetchRows($sql, array($device['device_id']));
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -164,8 +163,6 @@ $rrd_options .= $rrd_options_lc;
|
||||
$rrd_options .= $rrd_options_bg;
|
||||
|
||||
$rrd_options .= " COMMENT:'\l'"; # matt.ayre: annotation showing smokeping parameters
|
||||
$rrd_options .= " COMMENT:'probes\:\t$pings ICMP Echo Pings ($description) every ${interval}s\l'";
|
||||
|
||||
$rrd_options .= " COMMENT:'probes\:\t$pings ICMP Echo Pings ($description) every {$interval}s\l'";
|
||||
|
||||
|
||||
?>
|
||||
// EOF
|
||||
|
||||
@ -15,18 +15,22 @@ $scale_max = "100";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
if($width > 500)
|
||||
if($width > 350)
|
||||
{
|
||||
$descr_len = 22;
|
||||
$padding = 45;
|
||||
$text_width = 7;
|
||||
} else {
|
||||
$descr_len = 12;
|
||||
$padding = 39;
|
||||
$text_width = 6;
|
||||
}
|
||||
$descr_len += round(($width - 250) / 8);
|
||||
$legend_len = ($vars['width'] + $padding) / $text_width;
|
||||
$descr_len = $legend_len - 31;
|
||||
|
||||
$iter = 0;
|
||||
$colours = 'mixed-10c';
|
||||
$rrd_options .= " COMMENT:'".str_pad('Size Used %used', $descr_len+31, ' ', STR_PAD_LEFT)."\\l'";
|
||||
//$rrd_options .= " COMMENT:' Size Used %age\\l'";
|
||||
$rrd_options .= " COMMENT:'".str_pad('Size Used % Used', $legend_len, ' ', STR_PAD_LEFT)."\\l'";
|
||||
$graph_return['legend_lines'] = 1;
|
||||
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM storage where device_id = ?", array($device['device_id'])) as $storage)
|
||||
{
|
||||
@ -47,7 +51,14 @@ foreach (dbFetchRows("SELECT * FROM storage where device_id = ?", array($device[
|
||||
$rrd_options .= " GPRINT:".$storage['storage_id']."used:LAST:%6.2lf%sB";
|
||||
$rrd_options .= " GPRINT:".$storage['storage_id']."perc:LAST:%5.2lf%%\\l";
|
||||
$iter++;
|
||||
$graph_return['legend_lines']++;
|
||||
$graph_return['rrds'][] = $rrd;
|
||||
} else {
|
||||
$graph_return['missing_rrds'][] = $rrd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// EOF
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -17,12 +16,13 @@
|
||||
include($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$graph_return['valid_options'][] = "previous";
|
||||
//$graph_return['valid_options'][] = "total";
|
||||
$graph_return['valid_options'][] = "95th";
|
||||
$graph_return['valid_options'][] = "trend";
|
||||
$graph_return['valid_options'][] = "inverse";
|
||||
|
||||
switch ($format)
|
||||
{
|
||||
$do_95th = !(isset($vars['95th']) && get_var_false($vars['95th']));
|
||||
|
||||
switch ($format) {
|
||||
case 'octets':
|
||||
case 'bytes':
|
||||
//$units = "Bps";
|
||||
@ -58,14 +58,12 @@ if ($format == "octets" || $format == "bytes")
|
||||
$i = 0;
|
||||
$unit_text = rrdtool_escape($unit_text, 9);
|
||||
|
||||
if (!$noheader)
|
||||
{
|
||||
$rrd_options .= " COMMENT:'$unit_text Last Avg Max 95th \\n'";
|
||||
if (!$noheader) {
|
||||
$rrd_options .= " COMMENT:'$unit_text Last Avg Max" . ($do_95th ? " 95th" : "") . " \\n'";
|
||||
}
|
||||
|
||||
// Alternative style
|
||||
if ($graph_style == 'mrtg')
|
||||
{
|
||||
if ($graph_style == 'mrtg') {
|
||||
$out_scale = 1;
|
||||
} else {
|
||||
$out_scale = -1;
|
||||
@ -200,7 +198,8 @@ $rrd_options .= ":'In '";
|
||||
$rrd_options .= " GPRINT:in".$format.":LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:in".$format.":AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:in".$format."_max:MAX:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:95thin:%6.2lf%s\\n";
|
||||
if ($do_95th) { $rrd_options .= " GPRINT:95thin:%6.2lf%s"; }
|
||||
$rrd_options .= " COMMENT:\\n";
|
||||
|
||||
if ($graph_max)
|
||||
{
|
||||
@ -222,27 +221,32 @@ $rrd_options .= " LINE1.25:dout".$format."#".$config['colours']['graphs']['data'
|
||||
$rrd_options .= " GPRINT:out".$format.":LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:out".$format.":AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:out".$format."_max:MAX:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:95thout:%6.2lf%s\\n";
|
||||
if ($do_95th) { $rrd_options .= " GPRINT:95thout:%6.2lf%s"; }
|
||||
$rrd_options .= " COMMENT:\\n";
|
||||
|
||||
if ($config['rrdgraph_real_95th'])
|
||||
{
|
||||
$rrd_options .= " HRULE:95thhigh#FF0000:'Highest'";
|
||||
$rrd_options .= " GPRINT:95thhigh:%30.2lf%s\\n";
|
||||
} else {
|
||||
//$rrd_options .= " LINE1:95thin#aa0000";
|
||||
//$rrd_options .= " LINE1:d95thout#bb0000";
|
||||
$rrd_options .= " HRULE:95thin#aa0000";
|
||||
$rrd_options .= " HRULE:d95thout#aa0000";
|
||||
if ($do_95th) {
|
||||
if ($config['rrdgraph_real_95th']) {
|
||||
$rrd_options .= " HRULE:95thhigh#FF0000:'Highest'";
|
||||
$rrd_options .= " GPRINT:95thhigh:%30.2lf%s\\n";
|
||||
} else {
|
||||
$rrd_options .= " HRULE:95thin#aa0000";
|
||||
$rrd_options .= " HRULE:d95thout#aa0000";
|
||||
}
|
||||
}
|
||||
|
||||
$rrd_options .= " GPRINT:tot:'Total %6.2lf%s'";
|
||||
$rrd_options .= " GPRINT:totin:'(In %6.2lf%s'";
|
||||
$rrd_options .= " GPRINT:totout:'Out %6.2lf%s)\\l'";
|
||||
|
||||
$graph_return['legend_lines'] = 4;
|
||||
|
||||
if ($vars['previous'] == "yes")
|
||||
{
|
||||
$rrd_options .= " LINE1.25:in".$format."X#009900:'Prev In \\n'";
|
||||
$rrd_options .= " LINE1.25:dout".$format."X#000099:'Prev Out'";
|
||||
|
||||
$graph_return['legend_lines'] += 2;
|
||||
|
||||
} else {
|
||||
$rrd_options .= " AREA:wrongin".$nan_colour;
|
||||
$rrd_options .= " AREA:wrongout".$nan_colour;
|
||||
@ -267,7 +271,7 @@ if ($vars['trend'])
|
||||
// $midnight = strtotime('today midnight');
|
||||
// for ($i = 1; $i <= 2; $i++)
|
||||
// {
|
||||
// $rrd_options .= " VRULE:${midnight}#FF0000";
|
||||
// $rrd_options .= " VRULE:{$midnight}#FF0000";
|
||||
// $midnight -= 86400;
|
||||
// }
|
||||
//}
|
||||
|
||||
@ -12,6 +12,12 @@
|
||||
|
||||
$graph_def = $config['graph_types'][$type][$subtype];
|
||||
|
||||
$graph_return['legend_lines'] = 0;
|
||||
|
||||
if(isset($graph_def['descr'])) {
|
||||
$graph_return['descr'] = $graph_def['descr'];
|
||||
}
|
||||
|
||||
// Set some defaults and convert $graph_def values to global values for use by common.inc.php.
|
||||
// common.inc.php needs converted to use $graph_def so we can remove this.
|
||||
|
||||
@ -149,6 +155,8 @@ foreach ($graph_def['ds'] as $ds_name => $ds)
|
||||
$cmd_def .= " CDEF:".$ds_name."_max=".$ds_name;
|
||||
}
|
||||
|
||||
//$graph_return['rrds'][$ds['file']][] = $ds_name;
|
||||
|
||||
if (!empty($ds['cdef']))
|
||||
{
|
||||
$ds_name = $ds_name."_c";
|
||||
@ -217,6 +225,7 @@ foreach ($graph_def['ds'] as $ds_name => $ds)
|
||||
}
|
||||
}
|
||||
$cmd_graph .= " COMMENT:'\\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
if ($ds['line']) {
|
||||
if (is_numeric($ds['line'])) {
|
||||
|
||||
@ -184,7 +184,7 @@ $rrd_options .= " HRULE:0#999999";
|
||||
// $midnight = strtotime('today midnight');
|
||||
// for ($i = 1; $i <= 2; $i++)
|
||||
// {
|
||||
// $rrd_options .= " VRULE:${midnight}#FF0000";
|
||||
// $rrd_options .= " VRULE:{$midnight}#FF0000";
|
||||
// $midnight -= 86400;
|
||||
// }
|
||||
//}
|
||||
|
||||
@ -117,7 +117,7 @@ if ($i)
|
||||
|
||||
if ($vars['previous'] == "yes")
|
||||
{
|
||||
$rrd_options .= " AREA:inbitsX#9999966:";
|
||||
$rrd_options .= " AREA:inbitsX#99999966:";
|
||||
$rrd_options .= " AREA:doutbitsX#99999966:";
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,8 @@ $graph_return['valid_options'][] = "previous";
|
||||
$graph_return['valid_options'][] = "total";
|
||||
$graph_return['valid_options'][] = "trend";
|
||||
|
||||
$graph_return['legend_lines'] = 0;
|
||||
|
||||
// Here we scale the number of numerical columns shown to make sure we keep the text.
|
||||
|
||||
if ($width > 600) {
|
||||
@ -74,6 +76,9 @@ if ($legend != 'no')
|
||||
if (in_array("max", $data_show)) { $rrd_options .= " COMMENT:' Max'"; }
|
||||
if (in_array("tot", $data_show)) { $rrd_options .= " COMMENT:' Total'"; }
|
||||
$rrd_options .= " COMMENT:'\\l'";
|
||||
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
@ -150,18 +155,20 @@ foreach ($rrd_list as $rrd)
|
||||
if (in_array("min", $data_show)) { $rrd_options .= " GPRINT:inbits".$i.":MIN:%6.2lf%s"; }
|
||||
if (in_array("max", $data_show)) { $rrd_options .= " GPRINT:inbits".$i.":MAX:%6.2lf%s"; }
|
||||
if (in_array("tot", $data_show)) { $rrd_options .= " GPRINT:totinB".$i.":%6.2lf%s".$total_units; }
|
||||
|
||||
$rrd_options .= " COMMENT:'\\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
|
||||
$rrd_optionsb .= " AREA:outbits".$i."_neg#" . $colour_out . ":".$stack;
|
||||
$rrd_options .= " HRULE:999999999999999#" . $colour_out . ":'" . rrdtool_escape($rrd['descr_out'], $descr_len - 3) . " Tx'";
|
||||
|
||||
if (in_array("lst", $data_show)) { $rrd_options .= " GPRINT:outbits".$i.":LAST:%6.2lf%s"; }
|
||||
if (in_array("avg", $data_show)) { $rrd_options .= " GPRINT:outbits".$i.":AVERAGE:%6.2lf%s"; }
|
||||
if (in_array("min", $data_show)) { $rrd_options .= " GPRINT:outbits".$i.":MIN:%6.2lf%s"; }
|
||||
if (in_array("max", $data_show)) { $rrd_options .= " GPRINT:outbits".$i.":MAX:%6.2lf%s"; }
|
||||
if (in_array("tot", $data_show)) { $rrd_options .= " GPRINT:totoutB".$i.":%6.2lf%s".$total_units; }
|
||||
|
||||
$rrd_options .= " COMMENT:'\\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
$i++; $iter++;
|
||||
}
|
||||
|
||||
@ -208,6 +215,7 @@ if (in_array("tot", $data_show))
|
||||
$rrd_options .= " VDEF:tot=octets,TOTAL";
|
||||
|
||||
$rrd_options .= " COMMENT:' \\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
$rrd_options .= " HRULE:999999999999999#FFFFFF:'" . rrdtool_escape("Total", $descr_len - 3) . " Rx'";
|
||||
if (in_array("lst", $data_show)) { $rrd_options .= " GPRINT:inbits:LAST:%6.2lf%s"; }
|
||||
@ -216,6 +224,7 @@ if (in_array("tot", $data_show))
|
||||
if (in_array("max", $data_show)) { $rrd_options .= " GPRINT:inbits:MAX:%6.2lf%s"; }
|
||||
if (in_array("tot", $data_show)) { $rrd_options .= " GPRINT:totin:%6.2lf%s".$total_units; }
|
||||
$rrd_options .= " COMMENT:'\\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
$rrd_options .= " HRULE:999999999999999#FFFFFF:'" . rrdtool_escape("", $descr_len - 3) . " Tx'";
|
||||
if (in_array("lst", $data_show)) { $rrd_options .= " GPRINT:outbits:LAST:%6.2lf%s"; }
|
||||
@ -224,6 +233,7 @@ if (in_array("tot", $data_show))
|
||||
if (in_array("max", $data_show)) { $rrd_options .= " GPRINT:outbits:MAX:%6.2lf%s"; }
|
||||
if (in_array("tot", $data_show)) { $rrd_options .= " GPRINT:totout:%6.2lf%s".$total_units; }
|
||||
$rrd_options .= " COMMENT:'\\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
$rrd_options .= " HRULE:999999999999999#FFFFFF:'" . rrdtool_escape("", $descr_len - 4) . " Agg'";
|
||||
if (in_array("lst", $data_show)) { $rrd_options .= " GPRINT:bits:LAST:%6.2lf%s"; }
|
||||
@ -232,6 +242,7 @@ if (in_array("tot", $data_show))
|
||||
if (in_array("max", $data_show)) { $rrd_options .= " GPRINT:bits:MAX:%6.2lf%s"; }
|
||||
if (in_array("tot", $data_show)) { $rrd_options .= " GPRINT:tot:%6.2lf%s".$total_units; }
|
||||
$rrd_options .= " COMMENT:'\\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
if ($vars['trend'])
|
||||
{
|
||||
@ -251,6 +262,7 @@ if (in_array("tot", $data_show) && $vars['previous'] == "yes")
|
||||
$rrd_options .= " VDEF:totoutX=outBX,TOTAL";
|
||||
$rrd_options .= " VDEF:totX=octetsX,TOTAL";
|
||||
$rrd_options .= " COMMENT:' \\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
$rrd_options .= " HRULE:999999999999999#AAAAAA:'" . rrdtool_escape("Prev Total", $descr_len - 3) . " Rx'";
|
||||
if (in_array("lst", $data_show)) { $rrd_options .= " GPRINT:inbitsX:LAST:%6.2lf%s"; }
|
||||
@ -259,6 +271,7 @@ if (in_array("tot", $data_show) && $vars['previous'] == "yes")
|
||||
if (in_array("max", $data_show)) { $rrd_options .= " GPRINT:inbitsX:MAX:%6.2lf%s"; }
|
||||
if (in_array("tot", $data_show)) { $rrd_options .= " GPRINT:totinX:%6.2lf%s".$total_units; }
|
||||
$rrd_options .= " COMMENT:'\\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
$rrd_options .= " HRULE:999999999999999#AAAAAA:'" . rrdtool_escape("", $descr_len - 3) . " Tx'";
|
||||
if (in_array("lst", $data_show)) { $rrd_options .= " GPRINT:outbitsX:LAST:%6.2lf%s"; }
|
||||
@ -267,6 +280,7 @@ if (in_array("tot", $data_show) && $vars['previous'] == "yes")
|
||||
if (in_array("max", $data_show)) { $rrd_options .= " GPRINT:outbitsX:MAX:%6.2lf%s"; }
|
||||
if (in_array("tot", $data_show)) { $rrd_options .= " GPRINT:totoutX:%6.2lf%s".$total_units; }
|
||||
$rrd_options .= " COMMENT:'\\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
$rrd_options .= " HRULE:999999999999999#AAAAAA:'" . rrdtool_escape("", $descr_len - 4) . " Agg'";
|
||||
if (in_array("lst", $data_show)) { $rrd_options .= " GPRINT:bitsX:LAST:%6.2lf%s"; }
|
||||
@ -275,6 +289,7 @@ if (in_array("tot", $data_show) && $vars['previous'] == "yes")
|
||||
if (in_array("max", $data_show)) { $rrd_options .= " GPRINT:bitsX:MAX:%6.2lf%s"; }
|
||||
if (in_array("tot", $data_show)) { $rrd_options .= " GPRINT:totX:%6.2lf%s".$total_units; }
|
||||
$rrd_options .= " COMMENT:'\\l'";
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -25,14 +25,15 @@ $graph_return['valid_options'][] = "trend";
|
||||
|
||||
include($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$unit_text = str_pad(truncate($unit_text,18,''),18);
|
||||
$line_text = str_pad(truncate($line_text,12,''),12);
|
||||
// Fix length before escaping for layout purposes
|
||||
$unit_text = rrdtool_escape(str_pad(truncate($unit_text,17,''),17));
|
||||
$line_text = rrdtool_escape(str_pad(truncate($line_text,11,''),11));
|
||||
|
||||
if (isset($unit_integer) && $unit_integer)
|
||||
{
|
||||
$ds_format = '"%6.0lf "'; //NOTE. max value 999999
|
||||
$ds_format = '"%6.0lf"'; //NOTE. max value 999999
|
||||
} else {
|
||||
$ds_format = '"%6.2lf%s"';
|
||||
$ds_format = '"%5.1lf%s"';
|
||||
}
|
||||
|
||||
if ($multiplier)
|
||||
@ -98,13 +99,13 @@ if ($vars['previous'] == "yes")
|
||||
if ($graph_max) {
|
||||
$rrd_options .= " CDEF:" . $ds . "_minmax=" . $ds . "_max," . $ds . "_min,-";
|
||||
$rrd_options .= " AREA:" . $ds . "_min#ffffff00";
|
||||
$rrd_options .= " AREA:" . $ds . "_minmax#" . $colour_line . "60:STACK";
|
||||
$rrd_options .= " AREA:" . $ds . "_minmax#" . $colour_line . "30:STACK";
|
||||
} else {
|
||||
$rrd_options .= " AREA:".$ds."#".$colour_area.":";
|
||||
}
|
||||
//}
|
||||
|
||||
$rrd_options .= " COMMENT:'".$unit_text."Now Avg Max ";
|
||||
$rrd_options .= " COMMENT:'".$unit_text."Now Avg Min Max";
|
||||
|
||||
if ($percentile)
|
||||
{
|
||||
@ -119,7 +120,7 @@ $rrd_options .= " GPRINT:".$ds.":AVERAGE:".$ds_format;
|
||||
|
||||
// if ($print_min || TRUE)
|
||||
// {
|
||||
// $rrd_options .= " GPRINT:".$ds."_min:MIN:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:".$ds."_min:MIN:".$ds_format;
|
||||
// }
|
||||
|
||||
$rrd_options .= " GPRINT:".$ds."_max:MAX:".$ds_format;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -43,7 +43,7 @@ if (isset($vars['format']) && array_key_exists($vars['format'], $config['graph_f
|
||||
|
||||
$graphfile = $config['temp_dir'] . "/" . strgen() . "." . $extension;
|
||||
|
||||
if (OBS_DEBUG) { print_vars($graphtype); }
|
||||
if (OBS_DEBUG) { print_vars($vars); print_vars($graphtype); }
|
||||
|
||||
if (isset($graphtype['type']) && isset($graphtype['subtype'])) {
|
||||
$type = $graphtype['type'];
|
||||
@ -76,22 +76,26 @@ if (preg_match(OBS_PATTERN_RRDTIME, $vars['to'])) { $to = $vars['to']; }//
|
||||
if (preg_match(OBS_PATTERN_RRDTIME, $vars['from'])) { $from = $vars['from']; }// else { $from = $config['time']['day']; }
|
||||
|
||||
if (isset($vars['period']) && is_numeric($vars['period'])) {
|
||||
$to = time();
|
||||
$from = time() - $vars['period'];
|
||||
$to = get_time();
|
||||
$from = get_time() - $vars['period'];
|
||||
$period = $vars['period'];
|
||||
} elseif(preg_match('/[\-]*\d+[s|w|m|d|y|h]/', $vars['from'])) {
|
||||
} elseif (preg_match('/[\-]*\d+[s|w|m|d|y|h]/', $vars['from'])) {
|
||||
// It seems we have AT-style/timespec. Just pass it through (some features will break because we can't calculate period)
|
||||
$from = $vars['from'];
|
||||
if(preg_match('/[\-]*\d+[s|w|m|d|y|h]/', $vars['to'])) { $to = $vars['to']; } else { $to = 'NOW'; }
|
||||
if (preg_match('/[\-]*\d+[s|w|m|d|y|h]/', $vars['to'])) {
|
||||
$to = $vars['to'];
|
||||
} else {
|
||||
$to = 'now';
|
||||
}
|
||||
} else {
|
||||
$from = (isset($vars['from'])) ? $vars['from'] : time() - 86400;
|
||||
$to = (isset($vars['to'])) ? $vars['to'] : time();
|
||||
$from = (isset($vars['from']) && is_numeric($vars['from'])) ? $vars['from'] : get_time() - 86400;
|
||||
$to = (isset($vars['to']) && is_numeric($vars['to'])) ? $vars['to'] : time();
|
||||
if ($from < 0) { $from = $to + $from; }
|
||||
$period = $to - $from;
|
||||
}
|
||||
|
||||
// Set prev_from & prev_to if we have a period
|
||||
if(isset($period)) {
|
||||
if (isset($period)) {
|
||||
$prev_from = $from - $period;
|
||||
$prev_to = $from;
|
||||
}
|
||||
@ -100,41 +104,62 @@ $graph_include = FALSE;
|
||||
$definition_include = FALSE;
|
||||
//print_message("Graph type: $type, subtype: $subtype");
|
||||
|
||||
if (is_file($config['html_dir'] . "/includes/graphs/$type/$subtype.inc.php"))
|
||||
{
|
||||
if (is_file($config['html_dir'] . "/includes/graphs/$type/$subtype.inc.php")) {
|
||||
$graph_include = $config['html_dir'] . "/includes/graphs/$type/$subtype.inc.php";
|
||||
}
|
||||
elseif (is_array($config['graph_types'][$type][$subtype]['ds']))
|
||||
{
|
||||
} elseif (is_array($config['graph_types'][$type][$subtype]['ds'])) {
|
||||
// Init tags array
|
||||
$tags = [];
|
||||
|
||||
// Additional include with define some graph variables like $unit_text, $graph_title
|
||||
// Currently only for indexed definitions
|
||||
if ($config['graph_types'][$type][$subtype]['index'] &&
|
||||
is_file($config['html_dir'] . "/includes/graphs/$type/definition.inc.php"))
|
||||
{
|
||||
is_file($config['html_dir'] . "/includes/graphs/$type/definition.inc.php")) {
|
||||
$definition_include = $config['html_dir'] . "/includes/graphs/$type/definition.inc.php";
|
||||
}
|
||||
$graph_include = $config['html_dir'] . "/includes/graphs/generic_definition.inc.php";
|
||||
}
|
||||
elseif (is_file($config['html_dir'] . "/includes/graphs/$type/graph.inc.php"))
|
||||
{
|
||||
} elseif (is_file($config['html_dir'] . "/includes/graphs/$type/graph.inc.php")) {
|
||||
$graph_include = $config['html_dir'] . "/includes/graphs/$type/graph.inc.php";
|
||||
}
|
||||
|
||||
if ($graph_include)
|
||||
{
|
||||
if ($graph_include) {
|
||||
include($config['html_dir'] . "/includes/graphs/$type/auth.inc.php");
|
||||
|
||||
if (isset($auth) && $auth)
|
||||
{
|
||||
if ($definition_include)
|
||||
{
|
||||
if (isset($auth) && $auth) {
|
||||
if ($definition_include) {
|
||||
include_once($definition_include);
|
||||
}
|
||||
|
||||
include($graph_include);
|
||||
|
||||
// Requested a rigid height graph, probably for the dashboard.
|
||||
// If we don't know the legend height, turn off legend.
|
||||
// If we know the height and it won't fit, turn it off.
|
||||
|
||||
if ( !(isset($vars['legend']) && $vars['legend'] == 'no') &&
|
||||
(isset($vars['rigid_height']) && $vars['rigid_height'] == 'yes') ) {
|
||||
$line_height = ($width > 350 ? 14 : 12); // Set line height based on font size chosen by width
|
||||
if (!isset($graph_return['legend_lines'])) { // Don't know legend length
|
||||
print_debug('no legend height');
|
||||
$vars['legend'] = 'no';
|
||||
}
|
||||
else if (($graph_return['legend_lines'] * $line_height) > ($height - 100)) { // Legend too long
|
||||
print_debug('legend too tall: ' . $graph_return['legend_lines'] * $line_height);
|
||||
$vars['legend'] = 'no';
|
||||
}
|
||||
else { // Legend fits
|
||||
$height = $height - ($graph_return['legend_lines'] * $line_height);
|
||||
}
|
||||
}
|
||||
|
||||
$rrd_options .= ' --start ' . rrdtool_escape($from) .
|
||||
' --end ' . rrdtool_escape($to) .
|
||||
' --width ' . rrdtool_escape($width) .
|
||||
' --height ' . rrdtool_escape($height) . ' ';
|
||||
|
||||
if ($vars['legend'] === 'no') {
|
||||
$rrd_options .= ' -g';
|
||||
$legend = 'no';
|
||||
}
|
||||
|
||||
}
|
||||
} elseif(!isset($vars['command_only'])) {
|
||||
graph_error('no '. $type.'_'.$subtype.''); // Graph Template Missing
|
||||
|
||||
@ -65,6 +65,9 @@ if ($legend != 'no')
|
||||
if (in_array("max", $data_show)) { $rrd_options .= " COMMENT:' Max'"; }
|
||||
if (in_array("tot", $data_show)) { $rrd_options .= " COMMENT:' Total'"; }
|
||||
$rrd_options .= " COMMENT:'\\l'";
|
||||
|
||||
$graph_return['legend_lines']++;
|
||||
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
61
html/includes/graphs/multi-oid-entry/auth.inc.php
Normal file
61
html/includes/graphs/multi-oid-entry/auth.inc.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
// FIXME - expand $vars['data']['groups'] for auth. For now only allow for >5
|
||||
// FIXME - do special handling of descriptions if all oid are identical or all devices are identical
|
||||
// remove device/oid from descr if all identical
|
||||
// arrange device/oid into aligned columns if the graph is wide enough
|
||||
|
||||
if (!is_array($vars['id'])) { $vars['id'] = array($vars['id']); }
|
||||
|
||||
$is_permitted = FALSE;
|
||||
|
||||
$oids = [];
|
||||
$rrd_list = [];
|
||||
|
||||
foreach ($vars['id'] as $oid_entry_id) {
|
||||
|
||||
$sql = "SELECT *";
|
||||
$sql .= " FROM `oids_entries`";
|
||||
$sql .= " LEFT JOIN `oids` USING(`oid_id`)";
|
||||
$sql .= " LEFT JOIN `devices` USING(`device_id`)";
|
||||
$sql .= " WHERE `oid_entry_id` = ?";
|
||||
|
||||
$oid = dbFetchRow($sql, array($oid_entry_id));
|
||||
if (is_numeric($oid['device_id']) && ($auth || device_permitted($oid['device_id']))) {
|
||||
$oids[] = $oid;
|
||||
$is_permitted = TRUE;
|
||||
|
||||
$rrd_file = get_rrd_path($oid, "oid-" . $oid['oid'] . "-" . $oid['oid_type'] . ".rrd");
|
||||
if (rrd_is_file($rrd_file, TRUE)) {
|
||||
$rrd_list[] = [ 'filename' => $rrd_file,
|
||||
'descr' => $oid['hostname'] . ' ' . $oid['oid_name'],
|
||||
'ds' => 'value'];
|
||||
}
|
||||
|
||||
} else {
|
||||
// Bail on first rejection
|
||||
$is_permitted = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($auth || $is_permitted || $_SESSION['userlevel'] >= 5) {
|
||||
$title_array = array();
|
||||
$title_array[] = array('text' => 'Multiple OIDs');
|
||||
$title_array[] = array('text' => safe_count($vars['id']) . ' Entries');
|
||||
$auth = TRUE;
|
||||
}
|
||||
|
||||
unset($is_permitted);
|
||||
|
||||
// EOF
|
||||
25
html/includes/graphs/multi-oid-entry/line.inc.php
Normal file
25
html/includes/graphs/multi-oid-entry/line.inc.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$units = '';
|
||||
$unit_text = $oid['oid_unit'];
|
||||
$total_units = '';
|
||||
|
||||
if ($oid['oid_logy'] == 1) { $log_y = TRUE; }
|
||||
if ($oid['oid_kibi'] == 1) { $kibi = 1; }
|
||||
|
||||
$colours='mixed';
|
||||
|
||||
//$scale_min = "0";
|
||||
$nototal = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_multi_line.inc.php");
|
||||
24
html/includes/graphs/multi-oid-entry/stacked.inc.php
Normal file
24
html/includes/graphs/multi-oid-entry/stacked.inc.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$units = '';
|
||||
$unit_text = ''; // Multiple OIDs can have different units.
|
||||
$total_units = '';
|
||||
|
||||
$i = 1;
|
||||
|
||||
$scale_min = "0";
|
||||
$colours='mixed-q12';
|
||||
$nototal = 1;
|
||||
$show_aggregate = TRUE;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_multi_simplex_separated.inc.php");
|
||||
@ -62,6 +62,12 @@ if (is_numeric($vars['id']) && ($auth || port_permitted($vars['id'])))
|
||||
$title_array[] = array('text' => escape_html($port['port_label']) . (strlen($port['ifAlias']) ? " (".escape_html($port['ifAlias']).")" : ''), 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'port', 'port' => $port['port_id'])));
|
||||
|
||||
$graph_title = device_name($device, TRUE) . " :: " . $port['port_label_short'];
|
||||
|
||||
// check if the port has an alias available and add it to the title
|
||||
if(!empty($port['ifAlias'])) {
|
||||
$graph_title = $graph_title . " :: " . $port['ifAlias'];
|
||||
}
|
||||
|
||||
$rrd_filename = get_port_rrdfilename($port, NULL, TRUE);
|
||||
|
||||
if ($vars['type'] == 'port_bits')
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%3.0lfCFM";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%3.0lfCFM\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Air flow sensor measured in CFM.';
|
||||
|
||||
// EOF
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " -A ";
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename_escape:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename_escape:sensor:MIN";
|
||||
|
||||
$rrd_options .= " AREA:sensor_max#c5c5c5";
|
||||
$rrd_options .= " AREA:sensor_min#ffffffff";
|
||||
|
||||
#$rrd_options .= " AREA:sensor#FFFF99";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],22)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%6.2lfW";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%6.2lfW\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Apparent power sensor measured in voltampere.';
|
||||
|
||||
// EOF
|
||||
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'], 22);
|
||||
|
||||
$colour_line = "cc3300";
|
||||
$colour_area = "FFBBBB";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$graph_max = 1;
|
||||
$unit_text = "ppm";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
//if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
//if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Concentration in ppm.';
|
||||
|
||||
// EOF
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " -A ";
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename_escape:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename_escape:sensor:MIN";
|
||||
|
||||
$rrd_options .= " AREA:sensor_max#c5c5c5";
|
||||
$rrd_options .= " AREA:sensor_min#ffffffff";
|
||||
|
||||
#$rrd_options .= " AREA:sensor#FFFF99";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],22)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%6.2lf";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%6.2lf\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Crest Factor';
|
||||
|
||||
// EOF
|
||||
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Min Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor$current_id:MIN:%5.2lfA";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%5.2lfA";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%5.2lfA\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
if (get_var_true($vars['previous']))
|
||||
{
|
||||
$rrd_options .= " DEF:sensorX=$rrd_filename_escape:sensor:AVERAGE:start=".$prev_from.":end=".$from;
|
||||
$rrd_options .= " LINE1.5:sensorX#0000cc:'Prev " . rrdtool_escape($sensor['sensor_descr'],18)."'";
|
||||
$rrd_options .= " SHIFT:sensorX:$period";
|
||||
$rrd_options .= " GPRINT:sensorX$current_id:MIN:%5.2lfA";
|
||||
$rrd_options .= " GPRINT:sensorX:LAST:%5.2lfA";
|
||||
$rrd_options .= " GPRINT:sensorX:MAX:%5.2lfA\\l";
|
||||
}
|
||||
|
||||
$graph_return['descr'] = 'Current sensor measured in Amperes.';
|
||||
$graph_return['valid_options'] = array('previous');
|
||||
|
||||
// EOF
|
||||
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
$scale_max = "60";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Min Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename_escape:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename_escape:sensor:MIN";
|
||||
$rrd_options .= " CDEF:sensor_diff=sensor_max,sensor_min,-";
|
||||
$rrd_options .= " AREA:sensor_min";
|
||||
$rrd_options .= " AREA:sensor_diff#c5c5c5::STACK";
|
||||
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor_min:MIN:%4.1lfdB";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%4.1lfdB";
|
||||
$rrd_options .= " GPRINT:sensor_max:MAX:%4.1lfdB\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
#wtfbroken code.
|
||||
if (get_var_true($vars['previous'])) {
|
||||
$rrd_options .= " DEF:sensorX=$rrd_filename_escape:sensor:AVERAGE:start=".$prev_from.":end=".$from;
|
||||
$rrd_options .= " LINE1.5:sensorX#0000cc:'Prev " . rrdtool_escape($sensor['sensor_descr'],18)."'";
|
||||
$rrd_options .= " SHIFT:sensorX:$period";
|
||||
$rrd_options .= " GPRINT:sensorX$current_id:MIN:%5.2lfA";
|
||||
$rrd_options .= " GPRINT:sensorX:LAST:%5.2lfA";
|
||||
$rrd_options .= " GPRINT:sensorX:MAX:%5.2lfA\\l";
|
||||
}
|
||||
|
||||
$graph_return['descr'] = nicecase($sensor['sensor_class']).' sensor measured in db.';
|
||||
|
||||
// EOF
|
||||
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Min Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor$current_id:MIN:%5.2lfdBm";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%5.2lfdBm";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%5.2lfdBm\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'dBm sensor.';
|
||||
|
||||
// EOF
|
||||
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
$scale_max = "60";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Min Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename_escape:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename_escape:sensor:MIN";
|
||||
$rrd_options .= " CDEF:sensor_diff=sensor_max,sensor_min,-";
|
||||
$rrd_options .= " AREA:sensor_min";
|
||||
$rrd_options .= " AREA:sensor_diff#c5c5c5::STACK";
|
||||
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor_min:MIN:%4.1lfC";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%4.1lfC";
|
||||
$rrd_options .= " GPRINT:sensor_max:MAX:%4.1lfC\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
#wtfbroken code.
|
||||
if (get_var_true($vars['previous']))
|
||||
{
|
||||
$rrd_options .= " DEF:sensorX=$rrd_filename_escape:sensor:AVERAGE:start=".$prev_from.":end=".$from;
|
||||
$rrd_options .= " LINE1.5:sensorX#0000cc:'Prev " . rrdtool_escape($sensor['sensor_descr'],18)."'";
|
||||
$rrd_options .= " SHIFT:sensorX:$period";
|
||||
$rrd_options .= " GPRINT:sensorX$current_id:MIN:%5.2lfC";
|
||||
$rrd_options .= " GPRINT:sensorX:LAST:%5.2lfC";
|
||||
$rrd_options .= " GPRINT:sensorX:MAX:%5.2lfC\\l";
|
||||
}
|
||||
|
||||
$graph_return['descr'] = 'Dew point measured in celsius.';
|
||||
|
||||
// EOF
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'], 22);
|
||||
|
||||
$colour_line = "cc1100";
|
||||
$colour_area = "FFFF99";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$scale_min = 0;
|
||||
$graph_max = 1;
|
||||
$unit_text = "m";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit']."#99999960::dashes"; }
|
||||
if (is_numeric($sensor['sensor_limit_low'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#99999960::dashes"; }
|
||||
|
||||
$graph_return['descr'] = 'Distance sensor measured in m.';
|
||||
|
||||
// EOF
|
||||
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'], 22);
|
||||
|
||||
$colour_line = "cc0000";
|
||||
$colour_area = "FFBBBB";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$graph_max = 1;
|
||||
$unit_text = "mg/M3";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
//if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
//if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Dust';
|
||||
|
||||
// EOF
|
||||
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%3.0lfrpm";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%3.0lfrpm\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Rotational fan speed sensor measured in RPM.';
|
||||
|
||||
// EOF
|
||||
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%6.2lf%sHz";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%6.2lf%sHz\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Frequency sensor measured in hertz';
|
||||
|
||||
// EOF
|
||||
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'], 20);
|
||||
|
||||
$colour_line = "cc0000";
|
||||
$colour_area = "FFBBBB";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$graph_max = 1;
|
||||
$unit_text = "Gauge";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
$graph_return['descr'] = 'Gauges.';
|
||||
|
||||
// EOF
|
||||
@ -6,31 +6,55 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
/// FIXME. To unify all sensor graphs.
|
||||
$include = $config['html_dir'] . "/includes/graphs/$type/";
|
||||
// Some Class specific options
|
||||
switch ($sensor['sensor_class']) {
|
||||
case 'humidity':
|
||||
case 'capacity':
|
||||
case 'load':
|
||||
case 'progress':
|
||||
include($include."percent.inc.php");
|
||||
$scale_min = "0";
|
||||
$scale_max = "100";
|
||||
break;
|
||||
case 'snr':
|
||||
case 'attenuation':
|
||||
case 'sound':
|
||||
include($include."db.inc.php");
|
||||
$scale_min = "0";
|
||||
$scale_max = "60";
|
||||
break;
|
||||
default:
|
||||
if (is_file($include.$sensor['sensor_class'].".inc.php")) {
|
||||
include($include.$sensor['sensor_class'].".inc.php");
|
||||
} else {
|
||||
graph_error($type.'_'.$subtype); // Graph Template Missing;
|
||||
}
|
||||
}
|
||||
unset($include);
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$sensor_type = $config['sensor_types'][$sensor['sensor_type']];
|
||||
|
||||
$line_text = $sensor['sensor_descr'];
|
||||
|
||||
$colour_line = "cc0000";
|
||||
$colour_area = "FFBBBB";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$graph_max = 1;
|
||||
if (isset($sensor_type['graph_unit'])) {
|
||||
$unit_text = $sensor_type['graph_unit'];
|
||||
} else {
|
||||
$unit_text = $sensor_type['symbol'];
|
||||
}
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) {
|
||||
$rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
}
|
||||
if (is_numeric($sensor['sensor_limit_low'])) {
|
||||
$rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
}
|
||||
|
||||
$graph_return['descr'] = $sensor_type['descr'];
|
||||
|
||||
|
||||
// EOF
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'], 22);
|
||||
|
||||
$colour_line = "cc0000";
|
||||
$colour_area = "FFFF99";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$scale_min = 0;
|
||||
$graph_max = 1;
|
||||
$unit_text = "lux";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; }
|
||||
if (is_numeric($sensor['sensor_limit_low'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; }
|
||||
|
||||
$graph_return['descr'] = 'Illuminance sensor measured in lux.';
|
||||
|
||||
// EOF
|
||||
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Min Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor$current_id:MIN:%5.2lfΩ";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%5.2lfΩ";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%5.2lfΩ\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Resistance sensor.';
|
||||
|
||||
// EOF
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
$scale_max = "100";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Min Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename_escape:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename_escape:sensor:MIN";
|
||||
$rrd_options .= " CDEF:sensor_diff=sensor_max,sensor_min,-";
|
||||
$rrd_options .= " AREA:sensor_min";
|
||||
$rrd_options .= " AREA:sensor_diff#c5c5c5::STACK";
|
||||
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor_min:MIN:%4.1lf%%";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%4.1lf%%";
|
||||
$rrd_options .= " GPRINT:sensor_max:MAX:%4.1lf%%\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = nicecase($sensor['sensor_class']).' sensor measured in percent.';
|
||||
|
||||
// EOF
|
||||
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'],8);
|
||||
|
||||
$colour_line = "cc0000";
|
||||
$colour_area = "FFBBBB";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$graph_max = 1;
|
||||
$unit_text = "Watts";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
//if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
//if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Power sensor measured in watts.';
|
||||
|
||||
// EOF
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " -A ";
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename_escape:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename_escape:sensor:MIN";
|
||||
|
||||
$rrd_options .= " AREA:sensor_max#c5c5c5";
|
||||
$rrd_options .= " AREA:sensor_min#ffffffff";
|
||||
|
||||
#$rrd_options .= " AREA:sensor#FFFF99";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],22)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%6.2lf";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%6.2lf\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Power Factor';
|
||||
|
||||
// EOF
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'], 22);
|
||||
|
||||
$colour_line = "cc0000";
|
||||
$colour_area = "FFFF99";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$graph_max = 1;
|
||||
$unit_text = "Pa";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; }
|
||||
if (is_numeric($sensor['sensor_limit_low'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; }
|
||||
|
||||
$graph_return['descr'] = 'Pressure sensor measured in Pascal.';
|
||||
|
||||
// EOF
|
||||
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Min Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor$current_id:MIN:%5.2lfΩ";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%5.2lfΩ";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%5.2lfΩ\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Resistance sensor.';
|
||||
|
||||
// EOF
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " -A ";
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename_escape:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename_escape:sensor:MIN";
|
||||
|
||||
$rrd_options .= " AREA:sensor_max#c5c5c5";
|
||||
$rrd_options .= " AREA:sensor_min#ffffffff";
|
||||
|
||||
#$rrd_options .= " AREA:sensor#FFFF99";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],22)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%6.2lfW";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%6.2lfW\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Reactive power sensor measured in voltampere reactive.';
|
||||
|
||||
// EOF
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " -A ";
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename_escape:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename_escape:sensor:MIN";
|
||||
|
||||
$rrd_options .= " AREA:sensor_max#c5c5c5";
|
||||
$rrd_options .= " AREA:sensor_min#ffffffff";
|
||||
|
||||
#$rrd_options .= " AREA:sensor#FFFF99";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],22)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%6.2lf%smin";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%6.2lf%smin\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Runtime sensor measured in minutes.';
|
||||
|
||||
// EOF
|
||||
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%3.0lf";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%3.0lf\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
// EOF
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'], 22);
|
||||
|
||||
$colour_line = "CC0000";
|
||||
$colour_minmax = "FF5555";
|
||||
|
||||
$scale_min = 0;
|
||||
$graph_max = 60;
|
||||
$unit_text = "C";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; }
|
||||
if (is_numeric($sensor['sensor_limit_low'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; }
|
||||
|
||||
$graph_return['descr'] = 'Temperature sensor measured in celsius.';
|
||||
|
||||
// EOF
|
||||
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'], 22);
|
||||
|
||||
$colour_line = "cc0000";
|
||||
$colour_area = "FFFF99";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$scale_min = 0;
|
||||
$graph_max = 1;
|
||||
$unit_text = "m/s";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit']."#99999960::dashes"; }
|
||||
if (is_numeric($sensor['sensor_limit_low'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#99999960::dashes"; }
|
||||
|
||||
$graph_return['descr'] = 'Velocity sensor measured in m/s.';
|
||||
|
||||
// EOF
|
||||
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " -A ";
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename_escape:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename_escape:sensor:MIN";
|
||||
|
||||
$rrd_options .= " CDEF:sensor_minmax=sensor_max,sensor_min,-";
|
||||
|
||||
$rrd_options .= " AREA:sensor_min#00000000";
|
||||
$rrd_options .= " AREA:sensor_minmax#ff333360:STACK";
|
||||
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],22)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%6.2lfV";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%6.2lfV\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Potential sensor measured in volts.';
|
||||
|
||||
// EOF
|
||||
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'], 22);
|
||||
|
||||
$colour_line = "cc0000";
|
||||
$colour_area = "FFBBBB";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$graph_max = 1;
|
||||
$unit_text = "Litres";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
//if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
//if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Volume.';
|
||||
|
||||
// EOF
|
||||
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include_once($config['html_dir']."/includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename_escape:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%3.0lfl/min";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%3.0lfl/min\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
$graph_return['descr'] = 'Water flow sensor measured in l/min.';
|
||||
|
||||
// EOF
|
||||
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$ds = "sensor";
|
||||
|
||||
$line_text = rrdtool_escape($sensor['sensor_descr'], 22);
|
||||
|
||||
$colour_line = "cc0000";
|
||||
$colour_area = "FFFF99";
|
||||
$colour_minmax = "c5c5c5";
|
||||
|
||||
$scale_min = 0;
|
||||
$graph_max = 1;
|
||||
$unit_text = "nm";
|
||||
$print_min = 1;
|
||||
|
||||
include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; }
|
||||
if (is_numeric($sensor['sensor_limit_low'])) { $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; }
|
||||
|
||||
$graph_return['descr'] = 'Wavelength sensor measured in nm.';
|
||||
|
||||
// EOF
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -46,11 +45,10 @@ $target = $device['hostname'];
|
||||
if($config['smokeping']['suffix']) $target = str_replace($config['smokeping']['suffix'],"",$target);
|
||||
if($config['smokeping']['split_char']) $target = str_replace(".", $config['smokeping']['split_char'],$target);
|
||||
|
||||
if (isset($config['smokeping']['master_hostname']))
|
||||
{
|
||||
if (isset($config['smokeping']['master_hostname'])) {
|
||||
$master_hostname = $config['smokeping']['master_hostname'];
|
||||
} else {
|
||||
$master_hostname = $config['own_hostname'];
|
||||
$master_hostname = $config['own_hostname'] ?: get_localhost();
|
||||
}
|
||||
|
||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['smokeping']['dir'])) as $filename_dir)
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage graphs
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -46,11 +45,10 @@ $target=$dest['hostname'];
|
||||
if($config['smokeping']['suffix']) $target = str_replace($config['smokeping']['suffix'],"",$target);
|
||||
if($config['smokeping']['split_char']) $target = str_replace(".", $config['smokeping']['split_char'],$target);
|
||||
|
||||
if (isset($config['smokeping']['master_hostname']))
|
||||
{
|
||||
if (isset($config['smokeping']['master_hostname'])) {
|
||||
$master_hostname = $config['smokeping']['master_hostname'];
|
||||
} else {
|
||||
$master_hostname = $config['own_hostname'];
|
||||
$master_hostname = $config['own_hostname'] ?: get_localhost();
|
||||
}
|
||||
|
||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['smokeping']['dir'])) as $filename_dir)
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -37,27 +37,24 @@ $menu_start = utime();
|
||||
|
||||
// Dashboards
|
||||
|
||||
$dashboards = dbFetchRows("SELECT * FROM `dashboards`");
|
||||
|
||||
$entries = array();
|
||||
|
||||
if (safe_count($dashboards))
|
||||
{
|
||||
//$navbar['observium']['dash']['text'] = "Dashboards";
|
||||
foreach ($dashboards as $dash)
|
||||
{
|
||||
$entries[] = array('text' => $dash['dash_name'], 'url' => generate_url(array('page' => "dashboard", 'dash' => $dash['dash_id'])), 'icon' => $config['icon']['overview']);
|
||||
}
|
||||
}
|
||||
|
||||
$entries[] = array('divider' => TRUE);
|
||||
|
||||
if ($_SESSION['userlevel'] > 7)
|
||||
{
|
||||
|
||||
$dashboards = dbFetchRows("SELECT * FROM `dashboards`");
|
||||
|
||||
$entries = array();
|
||||
|
||||
if (safe_count($dashboards))
|
||||
{
|
||||
//$navbar['observium']['dash']['text'] = "Dashboards";
|
||||
foreach ($dashboards as $dash)
|
||||
{
|
||||
$entries[] = array('text' => $dash['dash_name'], 'url' => generate_url(array('page' => "dashboard", 'dash' => $dash['dash_id'])), 'icon' => $config['icon']['overview']);
|
||||
}
|
||||
}
|
||||
|
||||
$entries[] = array('divider' => TRUE);
|
||||
|
||||
|
||||
$entries[] = array('title' => 'Create Dashboard', 'url' => generate_url(array('page' => 'dashboard_add')), 'icon' => $config['icon']['plus']);
|
||||
|
||||
}
|
||||
|
||||
$navbar['observium']['entries'][] = array('title' => 'Dashboard', 'url' => generate_url(array('page' => 'dashboard')), 'icon' => $config['icon']['overview'], 'entries' => $entries);
|
||||
@ -106,7 +103,7 @@ $menu_start = utime();
|
||||
$ids[] = $group['group_id'];
|
||||
}
|
||||
}
|
||||
foreach (dbFetchRows("SELECT COUNT(*) AS `count`, `group_id` FROM `group_table` WHERE 1" . generate_query_values($ids, 'group_id') . " GROUP BY `group_id`") as $entry) {
|
||||
foreach (dbFetchRows("SELECT COUNT(*) AS `count`, `group_id` FROM `group_table` WHERE " . generate_query_values_ng($ids, 'group_id') . " GROUP BY `group_id`") as $entry) {
|
||||
$groups_count[$entry['group_id']] = $entry['count'];
|
||||
}
|
||||
unset($ids);
|
||||
@ -204,15 +201,14 @@ $menu_start = utime();
|
||||
}
|
||||
|
||||
$navbar['observium']['entries'][] = array('title' => 'Network Map', 'url' => generate_url(array('page' => 'map')), 'icon' => $config['icon']['netmap']);
|
||||
|
||||
$navbar['observium']['entries'][] = array('title' => 'Network Traffic Map', 'url' => generate_url(array('page' => 'map_traffic')), 'icon' => $config['icon']['map']);
|
||||
|
||||
$navbar['observium']['entries'][] = array('title' => 'Event Log', 'url' => generate_url(array('page' => 'eventlog')), 'icon' => $config['icon']['eventlog']);
|
||||
|
||||
|
||||
$navbar['observium']['entries'][] = array('divider' => TRUE);
|
||||
|
||||
if ($_SESSION['userlevel'] >= 7)
|
||||
{
|
||||
if ($_SESSION['userlevel'] >= 7) {
|
||||
// Print Contacts
|
||||
$counts['contacts'] = dbFetchCell("SELECT COUNT(*) FROM `alert_contacts`");
|
||||
|
||||
@ -220,31 +216,30 @@ $menu_start = utime();
|
||||
$navbar['observium']['entries'][] = array('divider' => TRUE);
|
||||
}
|
||||
|
||||
if (OBSERVIUM_EDITION !== 'community' && $_SESSION['userlevel'] >= 5)
|
||||
{
|
||||
if (OBSERVIUM_EDITION !== 'community' && $_SESSION['userlevel'] >= 5) {
|
||||
// Custom OIDs
|
||||
|
||||
$oids = dbFetchRows("SELECT `oids`.*, COUNT(*) AS `count` FROM `oids` JOIN `oids_entries` ON `oids`.`oid_id` = `oids_entries`.`oid_id` WHERE 1 GROUP BY `oids`.`oid_id`");
|
||||
|
||||
$oid_count = safe_count($oids);
|
||||
|
||||
foreach ($oids AS $oid)
|
||||
{
|
||||
$oids_menu[] = array('title' => $oid['oid_descr'], 'url' => generate_url(array('page' => 'customoid', 'oid_id' => $oid['oid_id'])), 'count' => $oid['count'], 'icon' => $config['icon']['customoid']);
|
||||
$oids_menu = [];
|
||||
foreach ($oids as $oid) {
|
||||
$oids_menu[] = [ 'title' => $oid['oid_descr'], 'url' => generate_url([ 'page' => 'customoid', 'oid_id' => $oid['oid_id'] ]), 'count' => $oid['count'], 'icon' => $config['icon']['customoid'] ];
|
||||
}
|
||||
|
||||
$navbar['observium']['entries'][] = array('title' => 'Custom OIDs', 'url' => generate_url(array('page' => 'customoids')), 'count' => $oid_count, 'icon' => $config['icon']['customoid'], 'entries' => $oids_menu);
|
||||
$navbar['observium']['entries'][] = [ 'title' => 'Custom OIDs', 'url' => generate_url([ 'page' => 'customoids' ]), 'count' => $oid_count, 'icon' => $config['icon']['customoid'], 'entries' => $oids_menu ];
|
||||
//$navbar['observium']['entries'][] = array('divider' => TRUE);
|
||||
|
||||
$navbar['observium']['entries'][] = array('title' => 'Probes', 'url' => generate_url(array('page' => 'probes')), 'icon' => $config['icon']['status']);
|
||||
$navbar['observium']['entries'][] = array('divider' => TRUE);
|
||||
// Probes
|
||||
$navbar['observium']['entries'][] = [ 'title' => 'Probes', 'url' => generate_url([ 'page' => 'probes' ]), 'icon' => $config['icon']['status'] ];
|
||||
$navbar['observium']['entries'][] = [ 'divider' => TRUE ];
|
||||
|
||||
}
|
||||
|
||||
$navbar['observium']['entries'][] = array('title' => 'Hardware Inventory', 'url' => generate_url(array('page' => 'inventory')), 'icon' => $config['icon']['inventory']);
|
||||
|
||||
if ($cache['packages']['count'])
|
||||
{
|
||||
if ($cache['packages']['count']) {
|
||||
$navbar['observium']['entries'][] = array('title' => 'Software Packages', 'url' => generate_url(array('page' => 'packages')), 'icon' => $config['icon']['packages']);
|
||||
}
|
||||
|
||||
@ -568,12 +563,12 @@ $menu_start = utime();
|
||||
|
||||
//r($cache['sensor_types']);
|
||||
|
||||
$menu_items[0] = array('fanspeed', 'humidity', 'temperature', 'airflow');
|
||||
$menu_items[1] = array('current', 'voltage', 'power', 'apower', 'rpower', 'frequency');
|
||||
$menu_items[0] = [ 'temperature', 'humidity', 'fanspeed', 'airflow' ];
|
||||
$menu_items[1] = [ 'current', 'voltage', 'power', 'apower', 'rpower', 'frequency' ];
|
||||
$menu_items[2] = array_diff(array_keys((array)$cache['sensors']['types']), $menu_items[0], $menu_items[1]);
|
||||
|
||||
foreach ($menu_items as $items) {
|
||||
if (is_array($items)) { sort($items); }
|
||||
foreach ($menu_items as $key => $items) {
|
||||
if ($key > 1 && is_array($items)) { sort($items); } // Do not sort first basic health entities
|
||||
|
||||
foreach ($items as $item)
|
||||
{
|
||||
@ -753,7 +748,7 @@ $menu_start = utime();
|
||||
|
||||
echo(' <li class="dropdown">' . PHP_EOL);
|
||||
echo(' <a href="' . $dropdown['url'] . '" class="visible-lg visible-xl dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">' . PHP_EOL);
|
||||
echo(' <' . $element . ' class="' . $dropdown['icon'] . '"></' . $element . '> ' . $dropdown['title'] . ' <b class="caret"></b></a>' . PHP_EOL);
|
||||
echo(' <' . $element . ' class="' . $dropdown['icon'] . '"></' . $element . '> ' . escape_html($dropdown['title']) . ' <b class="caret"></b></a>' . PHP_EOL);
|
||||
echo(' <a href="' . $dropdown['url'] . '" class="visible-xs visible-sm visible-md dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">' . PHP_EOL);
|
||||
echo(' <' . $element . ' class="' . $dropdown['icon'] . '" style="margin-right: 5px;"></i></a>' . PHP_EOL);
|
||||
echo(' <ul role="menu" class="dropdown-menu">' . PHP_EOL);
|
||||
@ -944,6 +939,10 @@ $(function() {
|
||||
echo(' <li><a href="' . generate_url(array('page' => 'settings')) . '"><i class="' . $config['icon']['settings-change'] . '"></i> Edit</a></li>');
|
||||
echo(' <li><a href="' . generate_url(array('page' => 'settings', 'format' => 'config')) . '"><i class="' . $config['icon']['config'] . '"></i> Full Dump</a></li>');
|
||||
echo(' <li><a href="' . generate_url(array('page' => 'settings', 'format' => 'changed_config')) . '"><i class="' . $config['icon']['config'] . '"></i> Changed Dump</a></li>');
|
||||
if (OBS_DISTRIBUTED) {
|
||||
echo(' <li class="divider"></li>');
|
||||
echo(' <li><a href="' . generate_url([ 'page' => 'pollers' ]) . '"><i class="' . $config['icon']['pollers'] . '"></i> Pollers</a></li>');
|
||||
}
|
||||
echo(' </ul>');
|
||||
echo('</li>');
|
||||
}
|
||||
@ -992,7 +991,9 @@ $(function() {
|
||||
$('#suggestions').fadeOut(); // Hide the suggestions box
|
||||
} else {
|
||||
key_count_global++;
|
||||
setTimeout("lookupwait(" + key_count_global + ",\"" + inputString + "\")", 300); // Added timeout 0.3s before send query
|
||||
// Added timeout 0.3s before send query
|
||||
// Prevent use quotes in query string, for do not use XSS attacks
|
||||
setTimeout("lookupwait(" + key_count_global + ",\"" + inputString.replace(/"/g, '\\x22').replace(/'/g, '\\x27') + "\")", 300);
|
||||
}
|
||||
key_press_time = Date.now()
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ $alerts_item = get_cache_item('alerts');
|
||||
if (!ishit_cache_item($notifications_item) || !ishit_cache_item($alerts_item)) {
|
||||
// Generate/collect notifications/alerts
|
||||
|
||||
|
||||
if ($_SESSION['userlevel'] > 7) {
|
||||
$latest = [];
|
||||
$latest['version'] = get_obs_attrib('latest_ver');
|
||||
@ -39,17 +40,6 @@ if (!ishit_cache_item($notifications_item) || !ishit_cache_item($alerts_item)) {
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
if (version_compare(PHP_VERSION, OBS_MIN_PHP_VERSION, '<')) {
|
||||
$notifications[] = array('text' => '<h4>Your PHP version is too old.</h4>
|
||||
Your currently installed PHP version <b>' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION . '</b>
|
||||
is older than the required minimum.
|
||||
Please upgrade your version of PHP to prevent possible incompatibilities and security problems.<br/>
|
||||
Currently recommended version(s): <b>7.2.x</b> and newer.',
|
||||
'severity' => 'danger',
|
||||
'unixtime' => $config['time']['now']);
|
||||
}
|
||||
|
||||
//if (!function_exists('hash_exists'))
|
||||
//{
|
||||
// $alerts[] = array('text' => '<b>The PHP `hash` module is missing</b> This will cause editing and other forms to fail. Please install it.', 'severity' => 'danger');
|
||||
@ -63,8 +53,7 @@ if (!ishit_cache_item($notifications_item) || !ishit_cache_item($alerts_item)) {
|
||||
}
|
||||
|
||||
// Warning about web_url config, only for ssl
|
||||
if (is_ssl() && preg_match('/^http:/', $config['web_url']))
|
||||
{
|
||||
if (is_ssl() && preg_match('/^http:/', $config['web_url'])) {
|
||||
$notifications[] = array('text' => 'Setting \'web_url\' for "External Web URL" not set or incorrect, please update on ' . generate_link('Global Settings Edit', array('page' => 'settings', 'section' => 'wui')) . ' page.', 'severity' => 'warning',
|
||||
'unixtime' => $config['time']['now']);
|
||||
}
|
||||
@ -94,15 +83,6 @@ if (!ishit_cache_item($notifications_item) || !ishit_cache_item($alerts_item)) {
|
||||
'text' => $entry['message'],
|
||||
'severity' => $entry['severity']);
|
||||
}
|
||||
|
||||
// Warning about obsolete config on some pages
|
||||
if (OBS_DEBUG ||
|
||||
in_array($vars['tab'], array('data', 'perf', 'edit', 'showtech')) ||
|
||||
in_array($vars['page'], array('pollerlog', 'settings', 'preferences')))
|
||||
{
|
||||
// FIXME move to notification center?
|
||||
print_obsolete_config();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['alerts']['suppress']) && $config['alerts']['suppress']) {
|
||||
@ -142,6 +122,53 @@ if (!ishit_cache_item($notifications_item) || !ishit_cache_item($alerts_item)) {
|
||||
$alerts = array_merge(get_cache_data($alerts_item), $alerts);
|
||||
}
|
||||
|
||||
// Admin level notifications on settings/perf pages
|
||||
if ($_SESSION['userlevel'] >= 10 && (in_array($vars['tab'], [ 'data', 'perf', 'edit', 'showtech' ]) ||
|
||||
in_array($vars['page'], [ 'about', 'pollerlog', 'settings', 'preferences' ]))) {
|
||||
|
||||
if (version_compare(PHP_VERSION, OBS_MIN_PHP_VERSION, '<')) {
|
||||
$notifications[] = array('text' => '<h4>Your PHP version is too old.</h4>
|
||||
Your currently installed PHP version <b>' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION . '</b>
|
||||
is older than the required minimum.
|
||||
Please upgrade your version of PHP to prevent possible incompatibilities and security problems.<br/>
|
||||
Currently recommended version(s): <b>7.2.x</b> and newer.',
|
||||
'severity' => 'danger',
|
||||
'unixtime' => $config['time']['now']);
|
||||
$alerts[] = [
|
||||
'title' => 'PHP version is old',
|
||||
'text' => 'Your currently installed PHP version <b>' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION .
|
||||
"</b> is older than the recommended minimum <b>7.2.x</b>.",
|
||||
'severity' => 'alert'
|
||||
];
|
||||
}
|
||||
|
||||
// Same for MySQL/MariaDB
|
||||
$versions = get_versions();
|
||||
if ($versions['mysql_old']) {
|
||||
$mysql_recommented = $versions['mysql_name'] === 'MariaDB' ? OBS_MIN_MARIADB_VERSION : OBS_MIN_MYSQL_VERSION;
|
||||
|
||||
$notifications[] = array('text' => '<h4>Your '.$versions['mysql_name'].' version is old.</h4>
|
||||
Your currently installed '.$versions['mysql_name'].' version <b>' . $versions['mysql_version'] . '</b>
|
||||
is older than the recommended minimum.
|
||||
Please upgrade your version of '.$versions['mysql_name'].' to prevent possible incompatibilities and security problems.<br/>
|
||||
Currently recommended version is <b>'.$mysql_recommented.'</b> and newer.',
|
||||
'severity' => 'warning',
|
||||
'unixtime' => $config['time']['now']);
|
||||
$alerts[] = [
|
||||
'title' => $versions['mysql_name'].' version is old',
|
||||
'text' => 'Your currently installed '.$versions['mysql_name'].' version <b>' . $versions['mysql_version'] .
|
||||
"</b> is older than the recommended minimum <b>$mysql_recommented</b>.",
|
||||
'severity' => 'warning'
|
||||
];
|
||||
}
|
||||
|
||||
// Warning about obsolete config on some pages
|
||||
if (OBS_DEBUG) {
|
||||
// FIXME move to notification center?
|
||||
print_obsolete_config();
|
||||
}
|
||||
|
||||
}
|
||||
// Sort by unixtime
|
||||
$notifications = array_sort_by($notifications, 'unixtime', SORT_DESC, SORT_NUMERIC);
|
||||
|
||||
|
||||
@ -57,6 +57,9 @@ switch ($vars['sort']) {
|
||||
case 'mac':
|
||||
$select .= ',`ifPhysAddress`';
|
||||
break;
|
||||
case 'mtu':
|
||||
$select .= ',`ifMtu`';
|
||||
break;
|
||||
case 'device':
|
||||
$select .= ',`devices`.`hostname`';
|
||||
break;
|
||||
|
||||
@ -64,6 +64,9 @@ switch ($vars['sort']) {
|
||||
case 'media':
|
||||
$ports = array_sort_by($ports, 'ifType', $sort_order, SORT_STRING);
|
||||
break;
|
||||
case 'mtu':
|
||||
$ports = array_sort_by($ports, 'ifMtu', $sort_order, SORT_NUMERIC);
|
||||
break;
|
||||
case 'descr':
|
||||
$ports = array_sort_by($ports, 'ifAlias', $sort_order, SORT_STRING);
|
||||
break;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -51,15 +50,15 @@ function print_addresses($vars)
|
||||
{
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'A.device_id');
|
||||
$where_netscaler .= generate_query_values($value, 'N.device_id');
|
||||
$where .= generate_query_values_and($value, 'A.device_id');
|
||||
$where_netscaler .= generate_query_values_and($value, 'N.device_id');
|
||||
break;
|
||||
case 'interface':
|
||||
$where .= generate_query_values($value, 'I.ifDescr', 'LIKE%');
|
||||
$where .= generate_query_values_and($value, 'I.ifDescr', 'LIKE%');
|
||||
$join_ports = TRUE;
|
||||
break;
|
||||
case 'type':
|
||||
$where .= generate_query_values($value, 'A.ip_type');
|
||||
$where .= generate_query_values_and($value, 'A.ip_type');
|
||||
break;
|
||||
case 'network':
|
||||
if (!is_array($value))
|
||||
@ -69,7 +68,7 @@ function print_addresses($vars)
|
||||
if ($ids = get_entity_ids_ip_by_network($address_type, $value))
|
||||
{
|
||||
// Full network with prefix
|
||||
$where .= generate_query_values($ids, 'A.ip_address_id');
|
||||
$where .= generate_query_values_and($ids, 'A.ip_address_id');
|
||||
} else {
|
||||
// Part of network string
|
||||
$where .= ' AND 0'; // Nothing!
|
||||
@ -87,16 +86,16 @@ function print_addresses($vars)
|
||||
}
|
||||
if ($ids = get_entity_ids_ip_by_network($address_type, $addr)) {
|
||||
// Full network with prefix
|
||||
$where .= generate_query_values($ids, 'A.ip_address_id');
|
||||
$where .= generate_query_values_and($ids, 'A.ip_address_id');
|
||||
} else {
|
||||
$where .= ' AND 0'; // Nothing!
|
||||
}
|
||||
/// FIXME. Netscaller hack
|
||||
if (count($addr) && get_ip_version($addr[0])) {
|
||||
// Netscaller for valid IP address
|
||||
$where_netscaler .= generate_query_values($addr, 'N.vsvr_ip');
|
||||
$where_netscaler .= generate_query_values_and($addr, 'N.vsvr_ip');
|
||||
} else {
|
||||
$where_netscaler .= generate_query_values($addr, 'N.vsvr_ip', '%LIKE%');
|
||||
$where_netscaler .= generate_query_values_and($addr, 'N.vsvr_ip', '%LIKE%');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -30,18 +30,18 @@ function build_alert_table_query($vars) {
|
||||
switch ($var) {
|
||||
// Search by device_id if we have a device or device_id
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'device_id');
|
||||
$where .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case 'entity_type':
|
||||
if ($value !== 'all') {
|
||||
$where .= generate_query_values($value, 'entity_type');
|
||||
$where .= generate_query_values_and($value, 'entity_type');
|
||||
}
|
||||
break;
|
||||
case 'entity_id':
|
||||
$where .= generate_query_values($value, 'entity_id');
|
||||
$where .= generate_query_values_and($value, 'entity_id');
|
||||
break;
|
||||
case 'alert_test_id':
|
||||
$where .= generate_query_values($value, 'alert_test_id');
|
||||
$where .= generate_query_values_and($value, 'alert_test_id');
|
||||
break;
|
||||
case 'status':
|
||||
if ($value === 'failed_delayed') {
|
||||
|
||||
@ -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,35 +77,42 @@ function print_alert_log($vars)
|
||||
// Functionize?
|
||||
|
||||
// Set colours and classes based on the status of the alert
|
||||
if ($entry['log_type'] == 'OK')
|
||||
{
|
||||
$entry['class'] = "green"; $entry['html_row_class'] = "success";
|
||||
} else if ($entry['log_type'] == 'RECOVER_NOTIFY') {
|
||||
$entry['class'] = "green"; $entry['html_row_class'] = "info";
|
||||
} else if ($entry['log_type'] == 'ALERT_NOTIFY') {
|
||||
$entry['class'] = "red"; $entry['html_row_class'] = "error";
|
||||
} elseif($entry['log_type'] == 'FAIL') {
|
||||
$entry['class'] = "red"; $entry['html_row_class'] = "error";
|
||||
} elseif($entry['log_type'] == 'FAIL_DELAYED') {
|
||||
$entry['class'] = "purple"; $entry['html_row_class'] = "warning";
|
||||
} elseif($entry['log_type'] == 'FAIL_SUPPRESSED') {
|
||||
$entry['class'] = "purple"; $entry['html_row_class'] = "suppressed";
|
||||
} elseif($entry['log_type'] == 'RECOVER_SUPPRESSED') {
|
||||
$entry['class'] = "purple"; $entry['html_row_class'] = "suppressed";
|
||||
} else {
|
||||
// Anything else set the colour to grey and the class to disabled.
|
||||
$entry['class'] = "gray"; $entry['html_row_class'] = "disabled";
|
||||
switch ($entry['log_type']) {
|
||||
case 'OK':
|
||||
$entry['class'] = "green";
|
||||
$entry['html_row_class'] = "success";
|
||||
break;
|
||||
case 'RECOVER_NOTIFY':
|
||||
$entry['class'] = "green";
|
||||
$entry['html_row_class'] = "info";
|
||||
break;
|
||||
case 'ALERT_NOTIFY':
|
||||
case 'FAIL':
|
||||
$entry['class'] = "red";
|
||||
$entry['html_row_class'] = "error";
|
||||
break;
|
||||
case 'FAIL_DELAYED':
|
||||
$entry['class'] = "purple";
|
||||
$entry['html_row_class'] = "warning";
|
||||
break;
|
||||
case 'FAIL_SUPPRESSED':
|
||||
case 'RECOVER_SUPPRESSED':
|
||||
$entry['class'] = "purple";
|
||||
$entry['html_row_class'] = "suppressed";
|
||||
break;
|
||||
default:
|
||||
// Anything else set the colour to grey and the class to disabled.
|
||||
$entry['class'] = "gray";
|
||||
$entry['html_row_class'] = "disabled";
|
||||
}
|
||||
|
||||
$string .= ' <tr class="'.$entry['html_row_class'].'">' . PHP_EOL;
|
||||
|
||||
$string .= '<td class="state-marker"></td>' . PHP_EOL;
|
||||
|
||||
if ($events['short'])
|
||||
{
|
||||
$string .= ' <td class="syslog" style="white-space: nowrap">';
|
||||
$timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
|
||||
$string .= generate_tooltip_link('', format_uptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
|
||||
if ($events['short']) {
|
||||
$string .= ' <td class="syslog text-nowrap">';
|
||||
$string .= generate_tooltip_time($entry['timestamp']) . '</td>' . PHP_EOL;
|
||||
} else {
|
||||
$string .= ' <td>';
|
||||
$string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
|
||||
@ -217,26 +224,26 @@ function get_alert_log($vars)
|
||||
switch ($var)
|
||||
{
|
||||
// case 'alert_entry':
|
||||
// $where .= generate_query_values($value, 'alert_table_id');
|
||||
// $where .= generate_query_values_and($value, 'alert_table_id');
|
||||
// break;
|
||||
case 'log_type':
|
||||
$where .= generate_query_values($value, 'log_type');
|
||||
$where .= generate_query_values_and($value, 'log_type');
|
||||
break;
|
||||
case 'alert_test_id':
|
||||
$where .= generate_query_values($value, 'alert_test_id');
|
||||
$where .= generate_query_values_and($value, 'alert_test_id');
|
||||
break;
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'device_id');
|
||||
$where .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case 'entity_id':
|
||||
$where .= generate_query_values($value, 'entity_id');
|
||||
$where .= generate_query_values_and($value, 'entity_id');
|
||||
break;
|
||||
case 'entity_type':
|
||||
$where .= generate_query_values($value, 'entity_type');
|
||||
$where .= generate_query_values_and($value, 'entity_type');
|
||||
break;
|
||||
case 'message':
|
||||
$where .= generate_query_values($value, 'message', '%LIKE%');
|
||||
$where .= generate_query_values_and($value, 'message', '%LIKE%');
|
||||
break;
|
||||
case 'timestamp_from':
|
||||
$where .= ' AND `timestamp` >= ?';
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -38,33 +38,32 @@ function print_arptable($vars)
|
||||
{
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'device_id');
|
||||
$where .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case 'port':
|
||||
case 'port_id':
|
||||
$where .= generate_query_values($value, 'I.port_id');
|
||||
$where .= generate_query_values_and($value, 'I.port_id');
|
||||
break;
|
||||
case 'ip_version':
|
||||
$where .= generate_query_values($value, 'ip_version');
|
||||
$where .= generate_query_values_and($value, 'ip_version');
|
||||
break;
|
||||
case 'address':
|
||||
if (isset($vars['searchby']) && $vars['searchby'] == 'ip')
|
||||
if (isset($vars['searchby']) && $vars['searchby'] === 'ip')
|
||||
{
|
||||
$value = trim($value);
|
||||
if (strpos($value, ':') !== FALSE)
|
||||
{
|
||||
if (Net_IPv6::checkIPv6($value))
|
||||
if (str_contains($value, ':')) {
|
||||
if (get_ip_version($value) === 5)
|
||||
{
|
||||
$value = Net_IPv6::uncompress($value, TRUE);
|
||||
$value = ip_uncompress($value);
|
||||
} else {
|
||||
// FIXME. Need another conversion ("2001:b08:b08" -> "2001:0b08:0b08") -- mike
|
||||
}
|
||||
}
|
||||
$where .= generate_query_values($value, 'ip_address', '%LIKE%');
|
||||
$where .= generate_query_values_and($value, 'ip_address', '%LIKE%');
|
||||
} else {
|
||||
// MAC Addresses
|
||||
$value = str_replace(array(':', ' ', '-', '.', '0x'), '', $value);
|
||||
$where .= generate_query_values($value, 'mac_address', '%LIKE%');
|
||||
$value = str_replace([ ':', ' ', '-', '.', '0x' ], '', $value);
|
||||
$where .= generate_query_values_and($value, 'mac_address', '%LIKE%');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -150,20 +149,20 @@ function generate_authlog_where($vars)
|
||||
case "user":
|
||||
case "username":
|
||||
if ($value == '') { continue 2; }
|
||||
$sql .= generate_query_values($value, 'user');
|
||||
$sql .= generate_query_values_and($value, 'user');
|
||||
break;
|
||||
case "address":
|
||||
case "ip":
|
||||
if ($value == '') { continue 2; }
|
||||
$sql .= generate_query_values($value, 'address', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'address', '%LIKE%');
|
||||
break;
|
||||
case "useragent":
|
||||
case "user_agent":
|
||||
$sql .= generate_query_values($value, 'user_agent', '%LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'user_agent', '%LIKE%');
|
||||
break;
|
||||
case "result":
|
||||
//case "action":
|
||||
$sql .= generate_query_values($value, 'result', 'LIKE%');
|
||||
$sql .= generate_query_values_and($value, 'result', 'LIKE%');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,6 +211,114 @@ function print_refresh($vars)
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This generates an HTML <thead> element based on the contents of the $header array, modified by the current request $vars
|
||||
*
|
||||
* @param array $header Array with table header definition including columns and classes.
|
||||
* @param array $vars Array with current selected column ID and/or variables for generate column link
|
||||
* @return string $string
|
||||
*/
|
||||
|
||||
function generate_table_header($header = [], $vars = []) {
|
||||
|
||||
// Store current $vars sort variables
|
||||
$sort = $vars['sort'];
|
||||
$sort_order = strtolower($vars['sort_order']);
|
||||
if (!in_array($sort_order, array('asc', 'desc', 'reset'))) {
|
||||
$sort_order = 'asc';
|
||||
}
|
||||
|
||||
// Reset current $vars sort variables
|
||||
unset($vars['sort'], $vars['sort_order']);
|
||||
|
||||
$output = '<thead'.(isset($header['class']) ? ' class="'.$header['class'].'"' : '').
|
||||
(isset($header['style']) ? ' style="'.$header['style'].'"' : '').
|
||||
(isset($vars['show_header']) && !$vars['show_header'] ? 'style="line-height: 0; visibility: collapse;"' : '') . '>';
|
||||
|
||||
$output .= ' <tr>' . PHP_EOL;
|
||||
|
||||
//r($header);
|
||||
|
||||
// Loop each column generating a <th> element
|
||||
foreach($header AS $id => $col)
|
||||
{
|
||||
|
||||
//if (in_array($id, ['class', 'group', 'style'])) { continue; } // skip html metadata
|
||||
|
||||
if ($id === 'class' || $id === 'style') { continue; } // skip html data
|
||||
|
||||
$fields = []; // Empty array for fields
|
||||
|
||||
if(empty($col) || !is_array($col)) { $col = [ $id => $col ]; } // If col is not an array, make it one
|
||||
|
||||
if($id == 'state-marker') { $col['class'] = 'state-marker'; } // Hard code handling of state-marker
|
||||
|
||||
// Loop each field and generate an <a> element
|
||||
foreach ($col as $field_id => $field) {
|
||||
|
||||
if ($field_id === 'class' || $field_id === 'style' || $field_id == 'subfields') { continue; } // skip html data
|
||||
|
||||
$header_field = generate_table_header_field($field_id, $field, $vars, $sort, $sort_order);
|
||||
|
||||
if(strlen($header_field) > 0) {
|
||||
$fields[] = $header_field;
|
||||
}
|
||||
|
||||
}
|
||||
$output .= ' <th'.( isset($col['class']) ? ' class="'.$col['class'].'"' : '').'>';
|
||||
$output .= implode(' / ', $fields);
|
||||
$output .= '</th>' . PHP_EOL;
|
||||
}
|
||||
|
||||
$output .= ' </tr>' . PHP_EOL;
|
||||
$output .= ' </thead>' . PHP_EOL;
|
||||
|
||||
return $output;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function generate_table_header_field($field_id, $field, $vars, $sort, $sort_order)
|
||||
{
|
||||
|
||||
if(empty($field)) { // No label, generate empty column header.
|
||||
$return = '';
|
||||
} elseif ( is_numeric($field_id) && !is_array($field)) { // Label without id, generate simple column header
|
||||
$return = $field;
|
||||
} else {
|
||||
if(!is_array($field)) { $field = [ 'label' => $field ]; }
|
||||
if(!isset($field['label'])) { $field['label'] = $field[0]; }
|
||||
|
||||
if($sort == $field_id) {
|
||||
$field['label'] = '<span class="text-primary" style="font-style: italic">'.$field['label'].'</span>';
|
||||
if($sort_order == 'asc') {
|
||||
$new_vars = [ 'sort' => $field_id, 'sort_order' => 'desc' ];
|
||||
$field['caret'] = ' <i class="text-primary small glyphicon glyphicon-arrow-up"></i>';
|
||||
} else {
|
||||
$new_vars = [ 'sort' => NULL, 'sort_order' => NULL ];
|
||||
$field['caret'] = ' <i class="text-primary small glyphicon glyphicon-arrow-down"></i>';
|
||||
}
|
||||
} else {
|
||||
$new_vars = [ 'sort' => $field_id ];
|
||||
}
|
||||
$return = '<a href="'.generate_url($vars, $new_vars).'">'.$field['label'].$field['caret'].'</a>';
|
||||
|
||||
// Generate slash separated links for subfields
|
||||
if(isset($field['subfields']))
|
||||
{
|
||||
foreach($field['subfields'] as $subfield_id => $subfield)
|
||||
{
|
||||
//r($subfield); r($subfield_id);
|
||||
$subfields[] = generate_table_header_field($subfield_id, $subfield, $vars, $sort, $sort_order);
|
||||
}
|
||||
$return .= ' ['.implode(" / ", $subfields).']';
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for generate table header with sort links
|
||||
* This used in other print_* functions
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -37,19 +36,19 @@ function print_dot1xtable($vars)
|
||||
{
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'device_id');
|
||||
$where .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case 'address':
|
||||
if (isset($vars['searchby']) && $vars['searchby'] == 'ip')
|
||||
if (isset($vars['searchby']) && $vars['searchby'] === 'ip')
|
||||
{
|
||||
$value = trim($value);
|
||||
$where .= generate_query_values($value, 'ipv4_addr', '%LIKE%');
|
||||
} else if (isset($vars['searchby']) && $vars['searchby'] == 'mac') {
|
||||
$value = str_replace(array(':', ' ', '-', '.', '0x'), '', $value);
|
||||
$where .= generate_query_values($value, 'M.mac_addr', '%LIKE%');
|
||||
$where .= generate_query_values_and($value, 'ipv4_addr', '%LIKE%');
|
||||
} elseif (isset($vars['searchby']) && $vars['searchby'] === 'mac') {
|
||||
$value = str_replace([ ':', ' ', '-', '.', '0x' ], '', $value);
|
||||
$where .= generate_query_values_and($value, 'M.mac_addr', '%LIKE%');
|
||||
} else {
|
||||
$value = trim($value);
|
||||
$where .= generate_query_values($value, 'username', '%LIKE%');
|
||||
$where .= generate_query_values_and($value, 'username', '%LIKE%');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -90,9 +90,8 @@ function print_events($vars) {
|
||||
$string .= '<td class="state-marker"></td>' . PHP_EOL;
|
||||
|
||||
if ($events['short']) {
|
||||
$string .= ' <td class="syslog" style="white-space: nowrap">';
|
||||
$timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
|
||||
$string .= generate_tooltip_link('', format_uptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
|
||||
$string .= ' <td class="syslog text-nowrap">';
|
||||
$string .= generate_tooltip_time($entry['timestamp']) . '</td>' . PHP_EOL;
|
||||
} else {
|
||||
$string .= ' <td style="width: 160px">';
|
||||
$string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
|
||||
@ -215,22 +214,22 @@ function get_events_array($vars)
|
||||
{
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'device_id');
|
||||
$where .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case 'port':
|
||||
case 'entity':
|
||||
case 'entity_id':
|
||||
$where .= generate_query_values($value, 'entity_id');
|
||||
$where .= generate_query_values_and($value, 'entity_id');
|
||||
break;
|
||||
case 'severity':
|
||||
$where .= generate_query_values($value, 'severity');
|
||||
$where .= generate_query_values_and($value, 'severity');
|
||||
break;
|
||||
case 'type':
|
||||
case 'entity_type':
|
||||
$where .= generate_query_values($value, 'entity_type');
|
||||
$where .= generate_query_values_and($value, 'entity_type');
|
||||
break;
|
||||
case 'message':
|
||||
$where .= generate_query_values($value, 'message', '%LIKE%');
|
||||
$where .= generate_query_values_and($value, 'message', '%LIKE%');
|
||||
break;
|
||||
case 'timestamp_from':
|
||||
$where .= ' AND `timestamp` >= ?';
|
||||
@ -243,8 +242,8 @@ function get_events_array($vars)
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$where .= generate_query_values($values, 'entity_id');
|
||||
$where .= generate_query_values(get_group_entity_type($value), 'entity_type');
|
||||
$where .= generate_query_values_and($values, 'entity_id');
|
||||
$where .= generate_query_values_and(get_group_entity_type($value), 'entity_type');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
*
|
||||
*/
|
||||
function print_fdbtable($vars) {
|
||||
//r($vars);
|
||||
$entries = get_fdbtable_array($vars);
|
||||
|
||||
if (!$entries['count']) {
|
||||
@ -27,8 +28,13 @@ function print_fdbtable($vars) {
|
||||
}
|
||||
|
||||
$list = array('device' => FALSE, 'port' => FALSE);
|
||||
if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] === 'search') { $list['device'] = TRUE; }
|
||||
if (!isset($vars['port']) || empty($vars['port']) || $vars['page'] === 'search') { $list['port'] = TRUE; }
|
||||
|
||||
|
||||
|
||||
if (!isset($vars['device']) || is_array($vars['device']) || empty($vars['device']) || $vars['page'] === 'search') { $list['device'] = TRUE; }
|
||||
if (!isset($vars['port']) || is_array($vars['port']) || empty($vars['port']) || $vars['page'] === 'search') { $list['port'] = TRUE; }
|
||||
|
||||
//r($list);
|
||||
|
||||
$string = generate_box_open();
|
||||
|
||||
@ -119,50 +125,54 @@ function get_fdbtable_array($vars) {
|
||||
// Do not show deleted entries by default
|
||||
$vars['deleted'] = 0;
|
||||
}
|
||||
//r($vars);
|
||||
|
||||
foreach ($vars as $var => $value) {
|
||||
if ($value != '') {
|
||||
switch ($var) {
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'F.device_id');
|
||||
break;
|
||||
case 'port':
|
||||
case 'port_id':
|
||||
$where .= generate_query_values($value, 'F.port_id');
|
||||
break;
|
||||
case 'interface':
|
||||
case 'port_name':
|
||||
$where .= generate_query_values($value, 'I.ifDescr', 'LIKE%');
|
||||
|
||||
// Skip empty variables (and array with empty first entry) when building query
|
||||
if ($value == '' || (is_array($value) && count($value) == 1 && $value[0] == '')) { continue; }
|
||||
|
||||
switch ($var) {
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values_and($value, 'F.device_id');
|
||||
break;
|
||||
case 'port':
|
||||
case 'port_id':
|
||||
$where .= generate_query_values_and($value, 'F.port_id');
|
||||
break;
|
||||
case 'interface':
|
||||
case 'port_name':
|
||||
$where .= generate_query_values_and($value, 'I.ifDescr', 'LIKE%');
|
||||
$join_ports = TRUE;
|
||||
break;
|
||||
case 'trunk':
|
||||
if (get_var_true($value)) {
|
||||
$where .= " AND (`I`.`ifTrunk` IS NOT NULL AND `I`.`ifTrunk` != '')";
|
||||
$join_ports = TRUE;
|
||||
break;
|
||||
case 'trunk':
|
||||
if (get_var_true($value)) {
|
||||
$where .= " AND (`I`.`ifTrunk` IS NOT NULL AND `I`.`ifTrunk` != '')";
|
||||
$join_ports = TRUE;
|
||||
} elseif (in_array($value, [ 'none', 'no', '0' ])) {
|
||||
$where .= " AND (`I`.`ifTrunk` IS NULL OR `I`.`ifTrunk` = '')";
|
||||
$join_ports = TRUE;
|
||||
}
|
||||
break;
|
||||
case 'vlan_id':
|
||||
$where .= generate_query_values($value, 'F.vlan_id');
|
||||
break;
|
||||
case 'vlan_name':
|
||||
$where .= generate_query_values($value, 'V.vlan_name');
|
||||
break;
|
||||
case 'address':
|
||||
if (str_contains_array($value, [ '*', '?' ])) {
|
||||
$like = 'LIKE';
|
||||
} else {
|
||||
$like = '%LIKE%';
|
||||
}
|
||||
$where .= generate_query_values(str_replace([ ':', ' ', '-', '.', '0x' ],'', $value), 'F.mac_address', $like);
|
||||
break;
|
||||
case 'deleted':
|
||||
$where .= ' AND `deleted` = ?';
|
||||
$params[] = $value;
|
||||
}
|
||||
}
|
||||
else if (in_array($value, ['none', 'no', '0'])) {
|
||||
$where .= " AND (`I`.`ifTrunk` IS NULL OR `I`.`ifTrunk` = '')";
|
||||
$join_ports = TRUE;
|
||||
}
|
||||
break;
|
||||
case 'vlan_id':
|
||||
$where .= generate_query_values_and($value, 'F.vlan_id');
|
||||
break;
|
||||
case 'vlan_name':
|
||||
$where .= generate_query_values_and($value, 'V.vlan_name');
|
||||
break;
|
||||
case 'address':
|
||||
if (str_contains_array($value, ['*', '?'])) {
|
||||
$like = 'LIKE';
|
||||
}
|
||||
else {
|
||||
$like = '%LIKE%';
|
||||
}
|
||||
$where .= generate_query_values_and(str_replace([':', ' ', '-', '.', '0x'], '', $value), 'F.mac_address', $like);
|
||||
break;
|
||||
case 'deleted':
|
||||
$where .= ' AND `deleted` = ?';
|
||||
$params[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,6 +216,9 @@ function get_fdbtable_array($vars) {
|
||||
$query .= $sort;
|
||||
$query .= " LIMIT $start,$pagesize";
|
||||
|
||||
//r($query);
|
||||
//r($params);
|
||||
|
||||
// Query addresses
|
||||
//$array['entries'] = dbFetchRows($query, $params, TRUE);
|
||||
$array['entries'] = dbFetchRows($query, $params);
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -28,31 +28,31 @@ function generate_inventory_query($vars) {
|
||||
{
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'device_id');
|
||||
$where .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case 'os':
|
||||
$where .= generate_query_values($value, 'os');
|
||||
$where .= generate_query_values_and($value, 'os');
|
||||
$select[] = 'devices.os';
|
||||
$devices = TRUE;
|
||||
break;
|
||||
case 'parts':
|
||||
case 'entPhysicalModelName':
|
||||
$where .= generate_query_values($value, 'entPhysicalModelName', 'LIKE');
|
||||
$where .= generate_query_values_and($value, 'entPhysicalModelName', 'LIKE');
|
||||
break;
|
||||
case 'serial':
|
||||
case 'entPhysicalSerialNum':
|
||||
$where .= generate_query_values($value, 'entPhysicalSerialNum', '%LIKE%');
|
||||
$where .= generate_query_values_and($value, 'entPhysicalSerialNum', '%LIKE%');
|
||||
break;
|
||||
case 'description':
|
||||
case 'entPhysicalDescr':
|
||||
$where .= generate_query_values($value, 'entPhysicalDescr', '%LIKE%');
|
||||
$where .= generate_query_values_and($value, 'entPhysicalDescr', '%LIKE%');
|
||||
break;
|
||||
case 'class':
|
||||
case 'entPhysicalClass':
|
||||
$where .= generate_query_values($value, 'entPhysicalClass', '%LIKE%');
|
||||
$where .= generate_query_values_and($value, 'entPhysicalClass', '%LIKE%');
|
||||
break;
|
||||
case 'deleted':
|
||||
$where .= generate_query_values($value, 'deleted', 'NOT NULL');
|
||||
$where .= generate_query_values_and($value, 'deleted', 'NOT NULL');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -371,15 +371,15 @@ relay
|
||||
|
||||
// vendor + model + hw
|
||||
$ent_model = '';
|
||||
if ($ent['entPhysicalModelName'] && !in_array($ent['entPhysicalModelName'], [ 'N/A' ])) {
|
||||
if ($ent['entPhysicalMfgName'] && !in_array($ent['entPhysicalMfgName'], [ 'N/A' ])) {
|
||||
if ($ent['entPhysicalModelName'] && is_valid_param($ent['entPhysicalModelName'], 'hardware')) {
|
||||
if ($ent['entPhysicalMfgName'] && is_valid_param($ent['entPhysicalMfgName'], 'vendor')) {
|
||||
$ent_model .= $ent['entPhysicalMfgName'];
|
||||
}
|
||||
|
||||
$ent_model .= ' ' . $ent['entPhysicalModelName'];
|
||||
|
||||
if ($ent['entPhysicalHardwareRev'] && !in_array($ent['entPhysicalHardwareRev'], [ 'N/A' ])) {
|
||||
$ent_model .= " ${ent['entPhysicalHardwareRev']}";
|
||||
if ($ent['entPhysicalHardwareRev'] && is_valid_param($ent['entPhysicalHardwareRev'], 'revision')) {
|
||||
$ent_model .= " " . $ent['entPhysicalHardwareRev'];
|
||||
}
|
||||
$ent_model = trim($ent_model);
|
||||
}
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -113,17 +113,17 @@ function get_logalert_log($vars)
|
||||
switch ($var)
|
||||
{
|
||||
case 'la_id':
|
||||
$where .= generate_query_values($value, 'la_id');
|
||||
$where .= generate_query_values_and($value, 'la_id');
|
||||
break;
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'device_id');
|
||||
$where .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case 'program':
|
||||
$where .= generate_query_values($value, 'program', '%LIKE%');
|
||||
$where .= generate_query_values_and($value, 'program', '%LIKE%');
|
||||
break;
|
||||
case 'message':
|
||||
$where .= generate_query_values($value, 'message', '%LIKE%');
|
||||
$where .= generate_query_values_and($value, 'message', '%LIKE%');
|
||||
break;
|
||||
case 'timestamp_from':
|
||||
$where .= ' AND `timestamp` >= ?';
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -39,14 +38,14 @@ function print_mac_addresses($vars)
|
||||
{
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'device_id');
|
||||
$where .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case 'interface':
|
||||
$where .= generate_query_values($value, 'ifDescr', 'LIKE');
|
||||
$where .= generate_query_values_and($value, 'ifDescr', 'LIKE');
|
||||
break;
|
||||
case 'address':
|
||||
$value = str_replace(array(':', ' ', '-', '.', '0x'), '', $value);
|
||||
$where .= generate_query_values($value, 'ifPhysAddress', '%LIKE%');
|
||||
$value = str_replace([ ':', ' ', '-', '.', '0x' ], '', $value);
|
||||
$where .= generate_query_values_and($value, 'ifPhysAddress', '%LIKE%');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -312,13 +312,12 @@ function navbar_location_menu($array) {
|
||||
}
|
||||
|
||||
// DOCME needs phpdoc block
|
||||
function navbar_submenu($entry, $level = 1)
|
||||
{
|
||||
function navbar_submenu($entry, $level = 1) {
|
||||
|
||||
if(isset($entry['text'])) { $entry['title'] = $entry['text']; }
|
||||
if (isset($entry['text'])) { $entry['title'] = $entry['text']; }
|
||||
|
||||
// autoscroll set by navbar-narrow + dropdown-menu, but override max-height
|
||||
echo(str_pad('',($level-1)*2) . ' <li class="dropdown-submenu">' . generate_menu_link($entry['url'], '<i class="' . $entry['icon'] . '"></i> ' . $entry['title'], $entry['count'], 'label', NULL, $entry['alert_count']) . PHP_EOL);
|
||||
echo(str_pad('',($level-1)*2) . ' <li class="dropdown-submenu">' . generate_menu_link($entry['url'], '<i class="' . $entry['icon'] . '"></i> ' . escape_html($entry['title']), $entry['count'], 'label', NULL, $entry['alert_count']) . PHP_EOL);
|
||||
echo(str_pad('',($level-1)*2) . ' <ul role="menu" class="dropdown-menu" style="max-height: 85vh;">' . PHP_EOL);
|
||||
|
||||
foreach ($entry['entries'] as $subentry) {
|
||||
@ -369,14 +368,20 @@ function navbar_entry($entry, $level = 1) {
|
||||
}
|
||||
|
||||
if (isset($entry['title'])) {
|
||||
$entry_text .= $entry['title'];
|
||||
$entry_text .= escape_html($entry['title']);
|
||||
} elseif (isset($entry['text'])) {
|
||||
$entry_text .= $entry['text'];
|
||||
$entry_text .= escape_html($entry['text']);
|
||||
}
|
||||
|
||||
if (isset($entry['class'])) {
|
||||
$entry_class = ' class="'.$entry['class'].'"';
|
||||
} else {
|
||||
$entry_class = '';
|
||||
}
|
||||
|
||||
$entry['text'] = $entry_text;
|
||||
|
||||
echo(str_pad('',($level-1)*2) . ' <li>' . generate_menu_link_new($entry) . '</li>' . PHP_EOL);
|
||||
echo(str_pad('',($level-1)*2) . ' <li '.$entry_class.'>' . generate_menu_link_new($entry) . '</li>' . PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -177,31 +176,33 @@ function get_neighbours_array($vars)
|
||||
if ($value != '') {
|
||||
switch ($var) {
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
case 'device_a':
|
||||
$where .= generate_query_values($value, 'device_id');
|
||||
$where .= generate_query_values_and($value, 'device_id');
|
||||
break;
|
||||
case 'port':
|
||||
case 'port_id':
|
||||
case 'port_a':
|
||||
$where .= generate_query_values($value, 'port_id');
|
||||
$where .= generate_query_values_and($value, 'port_id');
|
||||
break;
|
||||
case 'device_b':
|
||||
$where .= generate_query_values($value, 'remote_hostname');
|
||||
$where .= generate_query_values_and($value, 'remote_hostname');
|
||||
break;
|
||||
case 'port_b':
|
||||
$where .= generate_query_values($value, 'remote_port');
|
||||
$where .= generate_query_values_and($value, 'remote_port');
|
||||
break;
|
||||
case 'protocol':
|
||||
$where .= generate_query_values($value, 'protocol');
|
||||
$where .= generate_query_values_and($value, 'protocol');
|
||||
break;
|
||||
case 'platform':
|
||||
$where .= generate_query_values($value, 'remote_platform');
|
||||
$where .= generate_query_values_and($value, 'remote_platform');
|
||||
break;
|
||||
case 'version':
|
||||
$where .= generate_query_values($value, 'remote_version');
|
||||
$where .= generate_query_values_and($value, 'remote_version');
|
||||
break;
|
||||
case 'active':
|
||||
$value = $value && $value != 'no' ? '1' : '0';
|
||||
$where .= generate_query_values($value, 'active');
|
||||
$value = !get_var_false($value, 'no') ? '1' : '0';
|
||||
$where .= generate_query_values_and($value, 'active');
|
||||
break;
|
||||
case 'remote_port_id':
|
||||
if ($value === 'NULL' || $value == 0) {
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -26,211 +26,198 @@
|
||||
*
|
||||
*/
|
||||
function print_bgp_peer_table($vars) {
|
||||
// Get bgp peers array
|
||||
$entries = get_bgp_array($vars);
|
||||
//r($entries);
|
||||
|
||||
if (!$entries['count']) {
|
||||
// There have been no entries returned. Print the warning.
|
||||
print_warning('<h4>No BGP peers found!</h4>');
|
||||
return;
|
||||
$entries = get_bgp_array($vars);
|
||||
//r($entries);
|
||||
|
||||
if (!$entries['count']) {
|
||||
// There have been no entries returned. Print the warning.
|
||||
print_warning('<h4>No BGP peers found!</h4>');
|
||||
return;
|
||||
}
|
||||
|
||||
// Entries have been returned. Print the table.
|
||||
$list = [ 'device' => FALSE ];
|
||||
if ($vars['page'] !== 'device') {
|
||||
$list['device'] = TRUE;
|
||||
}
|
||||
|
||||
switch ($vars['graph']) {
|
||||
case 'prefixes_ipv4unicast':
|
||||
case 'prefixes_ipv4multicast':
|
||||
case 'prefixes_ipv4vpn':
|
||||
case 'prefixes_ipv6unicast':
|
||||
case 'prefixes_ipv6multicast':
|
||||
case 'macaccounting_bits':
|
||||
case 'macaccounting_pkts':
|
||||
case 'updates':
|
||||
$table_class = 'table-striped-two';
|
||||
$list['graph'] = TRUE;
|
||||
break;
|
||||
default:
|
||||
$table_class = 'table-striped';
|
||||
$list['graph'] = FALSE;
|
||||
}
|
||||
|
||||
$string = generate_box_open();
|
||||
|
||||
$string .= '<table class="table ' . $table_class . ' table-hover table-condensed ">' . PHP_EOL;
|
||||
|
||||
$cols = [
|
||||
[ NULL, 'class="state-marker"' ],
|
||||
[ NULL, 'style="width: 1px;"' ],
|
||||
'device' => [ 'Local address', 'style="width: 150px;"' ],
|
||||
'local_as' => [ 'Local AS / VRF', 'style="width: 110px;"' ],
|
||||
[ NULL, 'style="width: 20px;"' ],
|
||||
'peer_ip' => [ 'Peer address', 'style="width: 150px;"' ],
|
||||
'peer_as' => [ 'Remote AS', 'style="width: 90px;"' ],
|
||||
'type' => [ 'Type', 'style="width: 50px;"' ],
|
||||
[ 'Family', 'style="width: 50px;"' ],
|
||||
'state' => 'State',
|
||||
'uptime' => 'Uptime / Updates',
|
||||
];
|
||||
//if (!$list['device']) { unset($cols['device']); }
|
||||
$string .= get_table_header($cols, $vars);
|
||||
|
||||
$string .= ' <tbody>' . PHP_EOL;
|
||||
|
||||
foreach ($entries['entries'] as $peer) {
|
||||
$local_dev = device_by_id_cache($peer['device_id']);
|
||||
$local_as = ($list['device'] ? ' (AS' . $peer['human_local_as'] . ')' : '');
|
||||
$local_name = generate_device_link_short($local_dev, [ 'tab' => 'routing', 'proto' => 'bgp' ], 18);
|
||||
$local_ip = generate_device_link($local_dev, $peer['human_localip'] . $local_as, [ 'tab' => 'routing', 'proto' => 'bgp' ]);
|
||||
$peer_as = 'AS' . $peer['human_remote_as'];
|
||||
if ($peer['peer_device_id']) {
|
||||
$peer_dev = device_by_id_cache($peer['peer_device_id']);
|
||||
$peer_name = generate_device_link_short($peer_dev, [ 'tab' => 'routing', 'proto' => 'bgp' ], 18);
|
||||
} else {
|
||||
$peer_name = $peer['reverse_dns'];
|
||||
}
|
||||
$peer_ip = generate_entity_link("bgp_peer", $peer, $peer['human_remoteip']);
|
||||
$peer_afis = &$entries['afisafi'][$peer['device_id']][$peer['bgpPeer_id']];
|
||||
$peer_afis_html = [];
|
||||
|
||||
// Generate AFI/SAFI labels
|
||||
foreach ($peer_afis as $peer_afi) {
|
||||
// $peer_afi_html = '<span class="label-group">';
|
||||
if (isset($GLOBALS['config']['routing_afis_name'][$peer_afi['afi']])) {
|
||||
$afi_num = $GLOBALS['config']['routing_afis_name'][$peer_afi['afi']];
|
||||
$afi_class = $GLOBALS['config']['routing_afis'][$afi_num]['class'];
|
||||
} else {
|
||||
$afi_class = 'default';
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['config']['routing_safis_name'][$peer_afi['safi']])) {
|
||||
// Named SAFI
|
||||
$safi_num = $GLOBALS['config']['routing_safis_name'][$peer_afi['safi']];
|
||||
$safi_class = $GLOBALS['config']['routing_safis'][$safi_num]['class'];
|
||||
|
||||
} elseif (isset($GLOBALS['config']['routing_safis'][$peer_afi['safi']])) {
|
||||
// Numeric SAFI
|
||||
$safi_num = $peer_afi['safi'];
|
||||
$peer_afi['safi'] = $GLOBALS['config']['routing_safis'][$safi_num]['name'];
|
||||
$safi_class = $GLOBALS['config']['routing_safis'][$safi_num]['class'];
|
||||
} else {
|
||||
$safi_class = 'default';
|
||||
}
|
||||
|
||||
$peer_afi_items = [
|
||||
[ 'event' => $afi_class, 'text' => $peer_afi['afi'] ],
|
||||
[ 'event' => $safi_class, 'text' => $peer_afi['safi'] ],
|
||||
];
|
||||
$peer_afi_html = get_label_group($peer_afi_items);
|
||||
//r($peer_afi_html);
|
||||
$peer_afis_html[] = $peer_afi_html;
|
||||
}
|
||||
|
||||
// Entries have been returned. Print the table.
|
||||
$list = array('device' => FALSE);
|
||||
if ($vars['page'] !== 'device') {
|
||||
$list['device'] = TRUE;
|
||||
$string .= ' <tr class="' . $peer['html_row_class'] . '">' . PHP_EOL;
|
||||
$string .= ' <td class="state-marker"></td>' . PHP_EOL;
|
||||
$string .= ' <td></td>' . PHP_EOL;
|
||||
$string .= ' <td style="white-space: nowrap" class="entity">' . $local_ip . '<br />' . $local_name . '</td>' . PHP_EOL;
|
||||
$string .= ' <td><strong><span class="label label-' . $peer['peer_local_class'] . '">AS' . $peer['human_local_as'] . '</span></strong>';
|
||||
if (!safe_empty($peer['virtual_name'])) {
|
||||
$vitual_type = isset($GLOBALS['config']['os'][$local_dev['os']]['snmp']['virtual_type']) ? nicecase($GLOBALS['config']['os'][$local_dev['os']]['snmp']['virtual_type']) : 'VRF';
|
||||
$string .= '<br /><span class="label">'.$vitual_type.': '.$peer['virtual_name'].'</span>';
|
||||
}
|
||||
|
||||
switch ($vars['graph']) {
|
||||
case 'prefixes_ipv4unicast':
|
||||
case 'prefixes_ipv4multicast':
|
||||
case 'prefixes_ipv4vpn':
|
||||
case 'prefixes_ipv6unicast':
|
||||
case 'prefixes_ipv6multicast':
|
||||
case 'macaccounting_bits':
|
||||
case 'macaccounting_pkts':
|
||||
case 'updates':
|
||||
$table_class = 'table-striped-two';
|
||||
$list['graph'] = TRUE;
|
||||
break;
|
||||
default:
|
||||
$table_class = 'table-striped';
|
||||
$list['graph'] = FALSE;
|
||||
}
|
||||
|
||||
$string = generate_box_open();
|
||||
|
||||
$string .= '<table class="table ' . $table_class . ' table-hover table-condensed ">' . PHP_EOL;
|
||||
|
||||
$cols = array(
|
||||
array(NULL, 'class="state-marker"'),
|
||||
array(NULL, 'style="width: 1px;"'),
|
||||
'device' => array('Local address', 'style="width: 150px;"'),
|
||||
'local_as' => [ 'Local AS / VRF', 'style="width: 110px;"' ],
|
||||
array(NULL, 'style="width: 20px;"'),
|
||||
'peer_ip' => array('Peer address', 'style="width: 150px;"'),
|
||||
'peer_as' => [ 'Remote AS', 'style="width: 90px;"' ],
|
||||
'type' => array('Type', 'style="width: 50px;"'),
|
||||
array('Family', 'style="width: 50px;"'),
|
||||
'state' => 'State',
|
||||
'uptime' => 'Uptime / Updates',
|
||||
);
|
||||
//if (!$list['device']) { unset($cols['device']); }
|
||||
$string .= get_table_header($cols, $vars);
|
||||
|
||||
$string .= ' <tbody>' . PHP_EOL;
|
||||
|
||||
foreach ($entries['entries'] as $peer)
|
||||
{
|
||||
$local_dev = device_by_id_cache($peer['device_id']);
|
||||
$local_as = ($list['device'] ? ' (AS' . $peer['human_local_as'] . ')' : '');
|
||||
$local_name = generate_device_link_short($local_dev, [ 'tab' => 'routing', 'proto' => 'bgp' ], 18);
|
||||
$local_ip = generate_device_link($local_dev, $peer['human_localip'] . $local_as, array('tab' => 'routing', 'proto' => 'bgp'));
|
||||
$peer_as = 'AS' . $peer['human_remote_as'];
|
||||
if ($peer['peer_device_id']) {
|
||||
$peer_dev = device_by_id_cache($peer['peer_device_id']);
|
||||
$peer_name = generate_device_link_short($peer_dev, [ 'tab' => 'routing', 'proto' => 'bgp' ], 18);
|
||||
} else {
|
||||
$peer_name = $peer['reverse_dns'];
|
||||
}
|
||||
$peer_ip = generate_entity_link("bgp_peer", $peer, $peer['human_remoteip']);
|
||||
$peer_afis = &$entries['afisafi'][$peer['device_id']][$peer['bgpPeer_id']];
|
||||
$peer_afis_html = array();
|
||||
|
||||
// Generate AFI/SAFI labels
|
||||
foreach ($peer_afis as $peer_afi)
|
||||
{
|
||||
// $peer_afi_html = '<span class="label-group">';
|
||||
if (isset($GLOBALS['config']['routing_afis_name'][$peer_afi['afi']]))
|
||||
{
|
||||
$afi_num = $GLOBALS['config']['routing_afis_name'][$peer_afi['afi']];
|
||||
$afi_class = $GLOBALS['config']['routing_afis'][$afi_num]['class'];
|
||||
} else {
|
||||
$afi_class = 'default';
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['config']['routing_safis_name'][$peer_afi['safi']]))
|
||||
{
|
||||
// Named SAFI
|
||||
$safi_num = $GLOBALS['config']['routing_safis_name'][$peer_afi['safi']];
|
||||
$safi_class = $GLOBALS['config']['routing_safis'][$safi_num]['class'];
|
||||
}
|
||||
else if (isset($GLOBALS['config']['routing_safis'][$peer_afi['safi']]))
|
||||
{
|
||||
// Numeric SAFI
|
||||
$safi_num = $peer_afi['safi'];
|
||||
$peer_afi['safi'] = $GLOBALS['config']['routing_safis'][$safi_num]['name'];
|
||||
$safi_class = $GLOBALS['config']['routing_safis'][$safi_num]['class'];
|
||||
} else {
|
||||
$safi_class = 'default';
|
||||
}
|
||||
|
||||
// $peer_afi_html .= '<span class="label label-' . $afi_class . '">' . $peer_afi['afi'] . '</span>';
|
||||
// $peer_afi_html .= '<span class="label label-' . $safi_class . '">' . $peer_afi['safi'] . '</span>';
|
||||
// $peer_afi_html .= '</span>';
|
||||
|
||||
$peer_afi_items = [
|
||||
['event' => $afi_class, 'text' => $peer_afi['afi']],
|
||||
['event' => $safi_class, 'text' => $peer_afi['safi']],
|
||||
];
|
||||
$peer_afi_html = get_label_group($peer_afi_items);
|
||||
//r($peer_afi_html);
|
||||
$peer_afis_html[] = $peer_afi_html;
|
||||
}
|
||||
|
||||
$string .= ' <tr class="' . $peer['html_row_class'] . '">' . PHP_EOL;
|
||||
$string .= ' <td class="state-marker"></td>' . PHP_EOL;
|
||||
$string .= ' <td></td>' . PHP_EOL;
|
||||
$string .= ' <td style="white-space: nowrap" class="entity">' . $local_ip . '<br />' . $local_name . '</td>' . PHP_EOL;
|
||||
$string .= ' <td><strong><span class="label label-' . $peer['peer_local_class'] . '">AS' . $peer['human_local_as'] . '</span></strong>';
|
||||
if (!safe_empty($peer['virtual_name'])) {
|
||||
$vitual_type = isset($GLOBALS['config']['os'][$local_dev['os']]['snmp']['virtual_type']) ? nicecase($GLOBALS['config']['os'][$local_dev['os']]['snmp']['virtual_type']) : 'VRF';
|
||||
$string .= '<br /><span class="label">'.$vitual_type.': '.$peer['virtual_name'].'</span>';
|
||||
}
|
||||
$string .= '</td>' . PHP_EOL;
|
||||
$string .= ' <td><span class="text-success"><i class="glyphicon glyphicon-arrow-right"></i></span></td>' . PHP_EOL;
|
||||
$string .= ' <td style="white-space: nowrap" class="entity">' . $peer_ip . '<br />' . $peer_name . '</td>' . PHP_EOL;
|
||||
$string .= ' <td><strong>' . $peer_as . '</strong><br />' . $peer['astext'] . '</td>' . PHP_EOL;
|
||||
$string .= ' <td><span class="label label-' . $peer['peer_type_class'] . '">' . $peer['peer_type'] . '</span></td>' . PHP_EOL;
|
||||
$string .= ' <td>' . implode('<br />', $peer_afis_html) . '</td>' . PHP_EOL;
|
||||
$string .= ' <td><strong><span class=" label label-' . $peer['admin_class'] . '">' . $peer['bgpPeerAdminStatus'] . '</span><br /><span class="label label-' . $peer['state_class'] . '">' . $peer['bgpPeerState'] . '</span></strong></td>' . PHP_EOL;
|
||||
$string .= ' <td style="white-space: nowrap">' . format_uptime($peer['bgpPeerFsmEstablishedTime']) . '<br />
|
||||
$string .= '</td>' . PHP_EOL;
|
||||
$string .= ' <td><span class="text-success"><i class="glyphicon glyphicon-arrow-right"></i></span></td>' . PHP_EOL;
|
||||
$string .= ' <td style="white-space: nowrap" class="entity">' . $peer_ip . '<br />' . $peer_name . '</td>' . PHP_EOL;
|
||||
$string .= ' <td><strong>' . $peer_as . '</strong><br />' . $peer['astext'] . '</td>' . PHP_EOL;
|
||||
$string .= ' <td><span class="label label-' . $peer['peer_type_class'] . '">' . $peer['peer_type'] . '</span></td>' . PHP_EOL;
|
||||
$string .= ' <td>' . implode('<br />', $peer_afis_html) . '</td>' . PHP_EOL;
|
||||
$string .= ' <td><strong><span class=" label label-' . $peer['admin_class'] . '">' . $peer['bgpPeerAdminStatus'] . '</span><br /><span class="label label-' . $peer['state_class'] . '">' . $peer['bgpPeerState'] . '</span></strong></td>' . PHP_EOL;
|
||||
$string .= ' <td style="white-space: nowrap">' . format_uptime($peer['bgpPeerFsmEstablishedTime']) . '<br />
|
||||
Updates: <i class="icon-circle-arrow-down text-success"></i> ' . format_si($peer['bgpPeerInUpdates']) . ' <i class="icon-circle-arrow-up text-primary"></i> ' . format_si($peer['bgpPeerOutUpdates']) . '</td>' . PHP_EOL;
|
||||
$string .= ' </tr>' . PHP_EOL;
|
||||
$string .= ' </tr>' . PHP_EOL;
|
||||
|
||||
// Graphs
|
||||
$peer_graph = FALSE;
|
||||
switch ($vars['graph']) {
|
||||
case 'prefixes_ipv4unicast':
|
||||
case 'prefixes_ipv4multicast':
|
||||
case 'prefixes_ipv4vpn':
|
||||
case 'prefixes_ipv6unicast':
|
||||
case 'prefixes_ipv6multicast':
|
||||
$afisafi = preg_replace('/prefixes_(ipv[46])(\w+)/', '$1.$2', $vars['graph']); // prefixes_ipv6unicast ->> ipv6.unicast
|
||||
if (isset($peer_afis[$afisafi]) && $peer['bgpPeer_id'])
|
||||
{
|
||||
$graph_array['type'] = 'bgp_' . $vars['graph'];
|
||||
$graph_array['id'] = $peer['bgpPeer_id'];
|
||||
$peer_graph = TRUE;
|
||||
}
|
||||
break;
|
||||
case 'updates':
|
||||
if ($peer['bgpPeer_id'])
|
||||
{
|
||||
$graph_array['type'] = 'bgp_updates';
|
||||
$graph_array['id'] = $peer['bgpPeer_id'];
|
||||
$peer_graph = TRUE;
|
||||
}
|
||||
break;
|
||||
case 'macaccounting_bits':
|
||||
case 'macaccounting_pkts':
|
||||
//FIXME. I really still not know it works or not? -- mike
|
||||
// This part copy-pasted from old code as is
|
||||
$acc = dbFetchRow("SELECT * FROM `mac_accounting` AS M
|
||||
// Graphs
|
||||
$peer_graph = FALSE;
|
||||
switch ($vars['graph']) {
|
||||
case 'prefixes_ipv4unicast':
|
||||
case 'prefixes_ipv4multicast':
|
||||
case 'prefixes_ipv4vpn':
|
||||
case 'prefixes_ipv6unicast':
|
||||
case 'prefixes_ipv6multicast':
|
||||
$afisafi = preg_replace('/prefixes_(ipv[46])(\w+)/', '$1.$2', $vars['graph']); // prefixes_ipv6unicast ->> ipv6.unicast
|
||||
if (isset($peer_afis[$afisafi]) && $peer['bgpPeer_id']) {
|
||||
$graph_array['type'] = 'bgp_' . $vars['graph'];
|
||||
$graph_array['id'] = $peer['bgpPeer_id'];
|
||||
$peer_graph = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'updates':
|
||||
if ($peer['bgpPeer_id']) {
|
||||
$graph_array['type'] = 'bgp_updates';
|
||||
$graph_array['id'] = $peer['bgpPeer_id'];
|
||||
$peer_graph = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'macaccounting_bits':
|
||||
case 'macaccounting_pkts':
|
||||
// FIXME. I really still not know it works or not? -- mike
|
||||
// This part copy-pasted from old code as is
|
||||
$acc = dbFetchRow("SELECT * FROM `mac_accounting` AS M
|
||||
LEFT JOIN `ip_mac` AS I ON M.mac = I.mac_address
|
||||
LEFT JOIN `ports` AS P ON P.port_id = M.port_id
|
||||
LEFT JOIN `devices` AS D ON D.device_id = P.device_id
|
||||
WHERE I.ip_address = ?", array($peer['bgpPeerRemoteAddr']));
|
||||
$database = get_rrd_path($device, "cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
|
||||
if (is_array($acc) && is_file($database))
|
||||
{
|
||||
$peer_graph = TRUE;
|
||||
$graph_array['id'] = $acc['ma_id'];
|
||||
$graph_array['type'] = $vars['graph'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($peer_graph) {
|
||||
$graph_array['to'] = get_time();
|
||||
$string .= ' <tr class="' . $peer['html_row_class'] . '">' . PHP_EOL;
|
||||
$string .= ' <td class="state-marker"></td><td colspan="10" style="white-space: nowrap">' . PHP_EOL;
|
||||
|
||||
$string .= generate_graph_row($graph_array);
|
||||
|
||||
$string .= ' </td>' . PHP_EOL . ' </tr>' . PHP_EOL;
|
||||
}
|
||||
elseif ($list['graph'])
|
||||
{
|
||||
// Empty row for correct view class table-striped-two
|
||||
$string .= ' <tr class="' . $peer['html_row_class'] . '"><td class="state-marker"></td><td colspan="10"></td></tr>' . PHP_EOL;
|
||||
$database = get_rrd_path($device, "cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
|
||||
if (is_array($acc) && is_file($database)) {
|
||||
$peer_graph = TRUE;
|
||||
$graph_array['id'] = $acc['ma_id'];
|
||||
$graph_array['type'] = $vars['graph'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$string .= ' </tbody>' . PHP_EOL;
|
||||
$string .= '</table>';
|
||||
if ($peer_graph) {
|
||||
$graph_array['to'] = get_time();
|
||||
$string .= ' <tr class="' . $peer['html_row_class'] . '">' . PHP_EOL;
|
||||
$string .= ' <td class="state-marker"></td><td colspan="10" style="white-space: nowrap">' . PHP_EOL;
|
||||
|
||||
$string .= generate_box_close();
|
||||
$string .= generate_graph_row($graph_array);
|
||||
|
||||
// Print pagination header
|
||||
if ($entries['pagination_html'])
|
||||
{
|
||||
$string = $entries['pagination_html'] . $string . $entries['pagination_html'];
|
||||
$string .= ' </td>' . PHP_EOL . ' </tr>' . PHP_EOL;
|
||||
} elseif ($list['graph']) {
|
||||
// Empty row for correct view class table-striped-two
|
||||
$string .= ' <tr class="' . $peer['html_row_class'] . '"><td class="state-marker"></td><td colspan="10"></td></tr>' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
// Print
|
||||
echo $string;
|
||||
$string .= ' </tbody>' . PHP_EOL;
|
||||
$string .= '</table>';
|
||||
|
||||
$string .= generate_box_close();
|
||||
|
||||
// Print pagination header
|
||||
if ($entries['pagination_html']) {
|
||||
$string = $entries['pagination_html'] . $string . $entries['pagination_html'];
|
||||
}
|
||||
|
||||
// Print
|
||||
echo $string;
|
||||
|
||||
}
|
||||
|
||||
@ -240,156 +227,172 @@ function print_bgp_peer_table($vars) {
|
||||
* pagination, pageno, pagesize
|
||||
* device, type, adminstatus, state
|
||||
*/
|
||||
function get_bgp_array($vars)
|
||||
{
|
||||
$array = [];
|
||||
function get_bgp_array($vars) {
|
||||
$array = [];
|
||||
|
||||
// With pagination? (display page numbers in header)
|
||||
$array['pagination'] = (isset($vars['pagination']) && $vars['pagination']);
|
||||
pagination($vars, 0, TRUE); // Get default pagesize/pageno
|
||||
$array['pageno'] = $vars['pageno'];
|
||||
$array['pagesize'] = $vars['pagesize'];
|
||||
$start = $array['pagesize'] * $array['pageno'] - $array['pagesize'];
|
||||
$pagesize = $array['pagesize'];
|
||||
// With pagination? (display page numbers in header)
|
||||
//$array['pagination'] = (isset($vars['pagination']) && $vars['pagination']);
|
||||
$array['pagination'] = TRUE;
|
||||
pagination($vars, 0, TRUE); // Get default pagesize/pageno
|
||||
$array['pageno'] = $vars['pageno'];
|
||||
$array['pagesize'] = $vars['pagesize'];
|
||||
$start = $array['pagesize'] * $array['pageno'] - $array['pagesize'];
|
||||
$pagesize = $array['pagesize'];
|
||||
|
||||
// Require cached IDs from html/includes/cache-data.inc.php
|
||||
$cache_bgp = &$GLOBALS['cache']['bgp'];
|
||||
// Require cached IDs from html/includes/cache-data.inc.php
|
||||
$cache_bgp = &$GLOBALS['cache']['bgp'];
|
||||
|
||||
// Begin query generate
|
||||
$param = array();
|
||||
$where = ' WHERE 1 ';
|
||||
foreach ($vars as $var => $value) {
|
||||
if ($value != '') {
|
||||
switch ($var) {
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$where .= generate_query_values($values, 'bgpPeer_id');
|
||||
break;
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where .= generate_query_values($value, 'device_id');
|
||||
break;
|
||||
case 'peer':
|
||||
case 'peer_id':
|
||||
$where .= generate_query_values($value, 'peer_device_id');
|
||||
break;
|
||||
case 'local_ip':
|
||||
$where .= generate_query_values(ip_uncompress($value), 'bgpPeerLocalAddr');
|
||||
break;
|
||||
case 'peer_ip':
|
||||
$where .= generate_query_values(ip_uncompress($value), 'bgpPeerRemoteAddr');
|
||||
break;
|
||||
case 'local_as':
|
||||
$where .= generate_query_values(bgp_asdot_to_asplain($value), 'local_as');
|
||||
break;
|
||||
case 'peer_as':
|
||||
$where .= generate_query_values(bgp_asdot_to_asplain($value), 'bgpPeerRemoteAs');
|
||||
break;
|
||||
case 'type':
|
||||
if ($value === 'external' || $value === 'ebgp') {
|
||||
$where .= generate_query_values($cache_bgp['external'], 'bgpPeer_id');
|
||||
} elseif ($value === 'internal' || $value === 'ibgp') {
|
||||
$where .= generate_query_values($cache_bgp['internal'], 'bgpPeer_id');
|
||||
}
|
||||
break;
|
||||
case 'adminstatus':
|
||||
if ($value === 'stop') {
|
||||
$where .= generate_query_values($cache_bgp['start'], 'bgpPeer_id', '!='); // NOT IN
|
||||
} elseif ($value === 'start') {
|
||||
$where .= generate_query_values($cache_bgp['start'], 'bgpPeer_id');
|
||||
}
|
||||
break;
|
||||
case 'state':
|
||||
if ($value === 'down') {
|
||||
$where .= generate_query_values($cache_bgp['up'], 'bgpPeer_id', '!='); // NOT IN
|
||||
} elseif ($value === 'up') {
|
||||
$where .= generate_query_values($cache_bgp['up'], 'bgpPeer_id');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Begin query generate
|
||||
$param = [];
|
||||
$where = [];
|
||||
foreach ($vars as $var => $value) {
|
||||
if (!safe_empty($value)) {
|
||||
switch ($var) {
|
||||
case "group":
|
||||
case "group_id":
|
||||
$values = get_group_entities($value);
|
||||
$where[] = generate_query_values_ng($values, 'bgpPeer_id');
|
||||
break;
|
||||
|
||||
// Show peers only for permitted devices
|
||||
$query_permitted = generate_query_values($cache_bgp['permitted'], 'bgpPeer_id');
|
||||
case 'device':
|
||||
case 'device_id':
|
||||
$where[] = generate_query_values_ng($value, 'device_id');
|
||||
break;
|
||||
|
||||
$query = 'FROM `bgpPeers`';
|
||||
$query_count = 'SELECT COUNT(*) ' . $query . $where . $query_permitted; // Use only bgpPeer_id and device_id in query!
|
||||
case 'peer':
|
||||
case 'peer_id':
|
||||
$where[] = generate_query_values_ng($value, 'peer_device_id');
|
||||
break;
|
||||
|
||||
$query .= ' JOIN `devices` USING (`device_id`) ';
|
||||
case 'local_ip':
|
||||
$where[] = generate_query_values_ng(ip_uncompress($value), 'bgpPeerLocalAddr');
|
||||
break;
|
||||
|
||||
//$query .= ' LEFT JOIN `bgpPeers-state` AS S ON `bgpPeer_id` = S.`bgpPeer_id`';
|
||||
//$query .= ' LEFT JOIN `devices` AS D ON `device_id` = D.`device_id`';
|
||||
$query .= $where . $query_permitted;
|
||||
case 'peer_ip':
|
||||
$where[] = generate_query_values_ng(ip_uncompress($value), 'bgpPeerRemoteAddr');
|
||||
break;
|
||||
|
||||
$query = 'SELECT `hostname`, `bgpLocalAs`, bgpPeers.* ' . $query;
|
||||
|
||||
$sort_dir = $vars['sort_order'] === 'desc' ? ' DESC' : '';
|
||||
case 'local_as':
|
||||
$where[] = generate_query_values_ng(bgp_asdot_to_asplain($value), 'local_as');
|
||||
break;
|
||||
|
||||
switch($vars['sort']) {
|
||||
case "device":
|
||||
$sort = " ORDER BY `hostname`".$sort_dir;
|
||||
break;
|
||||
case 'peer_as':
|
||||
if (is_string($value) && preg_match_all('/AS(?<as>[\d\.]+):/', $value, $matches)) {
|
||||
//r($matches);
|
||||
$value = $matches['as'];
|
||||
}
|
||||
$where[] = generate_query_values_ng(bgp_asdot_to_asplain($value), 'bgpPeerRemoteAs');
|
||||
break;
|
||||
|
||||
case "local_as":
|
||||
$sort = " ORDER BY `local_as`$sort_dir, `virtual_name`$sort_dir";
|
||||
break;
|
||||
case 'type':
|
||||
if ($value === 'external' || $value === 'ebgp') {
|
||||
$where[] = generate_query_values_ng($cache_bgp['external'], 'bgpPeer_id');
|
||||
} elseif ($value === 'internal' || $value === 'ibgp') {
|
||||
$where[] = generate_query_values_ng($cache_bgp['internal'], 'bgpPeer_id');
|
||||
}
|
||||
break;
|
||||
|
||||
case "peer_ip":
|
||||
$sort = " ORDER BY `bgpPeerRemoteAddr`".$sort_dir;
|
||||
break;
|
||||
|
||||
case "peer_as":
|
||||
$sort = " ORDER BY `bgpPeerRemoteAs`".$sort_dir;
|
||||
break;
|
||||
case 'adminstatus':
|
||||
if ($value === 'stop') {
|
||||
$where[] = generate_query_values_ng($cache_bgp['start'], 'bgpPeer_id', '!='); // NOT IN
|
||||
} elseif ($value === 'start') {
|
||||
$where[] = generate_query_values_ng($cache_bgp['start'], 'bgpPeer_id');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'state':
|
||||
$sort = " ORDER BY `bgpPeerAdminStatus`".$sort_dir.", `bgpPeerState`".$sort_dir;
|
||||
break;
|
||||
|
||||
case 'uptime':
|
||||
$sort = " ORDER BY `bgpPeerFsmEstablishedTime`".$sort_dir;
|
||||
break;
|
||||
|
||||
default:
|
||||
$sort = " ORDER BY `hostname`".$sort_dir.", `bgpPeerRemoteAs`".$sort_dir.", `bgpPeerRemoteAddr`".$sort_dir;
|
||||
if ($value === 'down') {
|
||||
$where[] = generate_query_values_ng($cache_bgp['up'], 'bgpPeer_id', '!='); // NOT IN
|
||||
} elseif ($value === 'up') {
|
||||
$where[] = generate_query_values_ng($cache_bgp['up'], 'bgpPeer_id');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query .= $sort;
|
||||
$query .= " LIMIT $start,$pagesize";
|
||||
// Show peers only for permitted devices
|
||||
if ($_SESSION['userlevel'] < 5) {
|
||||
$where[] = generate_query_values_ng($cache_bgp['permitted'], 'bgpPeer_id');
|
||||
} elseif (!$GLOBALS['config']['web_show_disabled'] && $GLOBALS['cache']['devices']['stat']['disabled']) {
|
||||
// Exclude disabled devices for Global Read+
|
||||
$where[] = generate_query_values_ng($GLOBALS['cache']['devices']['disabled'], 'device_id', '!=');
|
||||
}
|
||||
|
||||
$peer_devices = array();
|
||||
// Query BGP
|
||||
foreach (dbFetchRows($query, $param) as $entry)
|
||||
{
|
||||
humanize_bgp($entry);
|
||||
if (!safe_empty($where)) {
|
||||
$where = 'WHERE ' . implode(' AND ', $where);
|
||||
} else {
|
||||
$where = '';
|
||||
}
|
||||
//r($where);
|
||||
|
||||
// Collect peer devices for AFI/SAFI
|
||||
$peer_devices[$entry['device_id']] = 1;
|
||||
$query_count = 'SELECT COUNT(*) FROM `bgpPeers` ' . $where; // Use only bgpPeer_id and device_id in query!
|
||||
$array['count'] = dbFetchCell($query_count, $param);
|
||||
//$array['count'] = dbFetchCell($query_count, $param, TRUE);
|
||||
|
||||
$array['entries'][] = $entry;
|
||||
// Pagination
|
||||
$array['pagination_html'] = pagination($vars, $array['count']);
|
||||
|
||||
$query = 'SELECT `hostname`, `bgpLocalAs`, `bgpPeers`.*';
|
||||
$query .= ' FROM `bgpPeers`';
|
||||
$query .= ' JOIN `devices` USING (`device_id`) ';
|
||||
$query .= $where;
|
||||
|
||||
$sort_dir = $vars['sort_order'] === 'desc' ? ' DESC' : '';
|
||||
|
||||
switch($vars['sort']) {
|
||||
case "device":
|
||||
$sort = " ORDER BY `hostname`".$sort_dir;
|
||||
break;
|
||||
|
||||
case "local_as":
|
||||
$sort = " ORDER BY `local_as`$sort_dir, `virtual_name`$sort_dir";
|
||||
break;
|
||||
|
||||
case "peer_ip":
|
||||
$sort = " ORDER BY `bgpPeerRemoteAddr`".$sort_dir;
|
||||
break;
|
||||
|
||||
case "peer_as":
|
||||
$sort = " ORDER BY `bgpPeerRemoteAs`".$sort_dir;
|
||||
break;
|
||||
|
||||
case 'state':
|
||||
$sort = " ORDER BY `bgpPeerAdminStatus`".$sort_dir.", `bgpPeerState`".$sort_dir;
|
||||
break;
|
||||
|
||||
case 'uptime':
|
||||
$sort = " ORDER BY `bgpPeerFsmEstablishedTime`".$sort_dir;
|
||||
break;
|
||||
|
||||
default:
|
||||
$sort = " ORDER BY `hostname`".$sort_dir.", `bgpPeerRemoteAs`".$sort_dir.", `bgpPeerRemoteAddr`".$sort_dir;
|
||||
}
|
||||
|
||||
$query .= $sort;
|
||||
$query .= " LIMIT $start,$pagesize";
|
||||
|
||||
$peer_devices = [];
|
||||
// Query BGP
|
||||
foreach (dbFetchRows($query, $param) as $entry) {
|
||||
humanize_bgp($entry);
|
||||
|
||||
// Collect peer devices for AFI/SAFI
|
||||
$peer_devices[$entry['device_id']] = 1;
|
||||
|
||||
$array['entries'][] = $entry;
|
||||
}
|
||||
|
||||
// Query AFI/SAFI
|
||||
if (!safe_empty($peer_devices)) {
|
||||
$query_afi = 'SELECT * FROM `bgpPeers_cbgp` WHERE 1' . generate_query_values_and(array_keys($peer_devices), 'device_id');
|
||||
|
||||
foreach (dbFetchRows($query_afi) as $entry) {
|
||||
$array['afisafi'][$entry['device_id']][$entry['bgpPeer_id']][$entry['afi'] . '.' . $entry['safi']] = [ 'afi' => $entry['afi'], 'safi' => $entry['safi'] ];
|
||||
}
|
||||
}
|
||||
|
||||
// Query AFI/SAFI
|
||||
if (count($peer_devices))
|
||||
{
|
||||
$query_afi = 'SELECT * FROM `bgpPeers_cbgp` WHERE 1' . generate_query_values(array_keys($peer_devices), 'device_id');
|
||||
foreach (dbFetchRows($query_afi) as $entry)
|
||||
{
|
||||
$array['afisafi'][$entry['device_id']][$entry['bgpPeer_id']][$entry['afi'] . '.' . $entry['safi']] = array('afi' => $entry['afi'], 'safi' => $entry['safi']);
|
||||
}
|
||||
}
|
||||
|
||||
// Query BGP peers count
|
||||
if ($array['pagination']) {
|
||||
$array['count'] = dbFetchCell($query_count, $param);
|
||||
$array['pagination_html'] = pagination($vars, $array['count']);
|
||||
} else {
|
||||
$array['count'] = safe_count($array['entries']);
|
||||
}
|
||||
|
||||
return $array;
|
||||
return $array;
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -26,39 +26,54 @@ function generate_box_open($args = []) {
|
||||
if (isset($args['title'])) {
|
||||
$return .= ' <div class="box-header' . ($args['header-border'] ? ' with-border' : '') . '">'.PHP_EOL;
|
||||
if (isset($args['url'])) { $return .= '<a href="'.$args['url'].'">'; }
|
||||
if (isset($args['icon'])) { $return .= '<i class="'.$args['icon'].'"></i>'; }
|
||||
if (isset($args['icon'])) { $return .= get_icon($args['icon']); }
|
||||
$return .= '<' . (isset($args['title-element']) ? $args['title-element'] : 'h3').' class="box-title"';
|
||||
$return .= isset($args['title-style']) ? ' style="'.$args['title-style'].'"' : '';
|
||||
$return .= '>';
|
||||
$return .= $args['title'].'</' . (isset($args['title-element']) ? $args['title-element'] : 'h3').'>'.PHP_EOL;
|
||||
$return .= escape_html($args['title']).'</' . (isset($args['title-element']) ? $args['title-element'] : 'h3').'>'.PHP_EOL;
|
||||
if (isset($args['url'])) { $return .= '</a>'; }
|
||||
|
||||
if (isset($args['header-controls']) && is_array($args['header-controls']['controls'])) {
|
||||
$return .= ' <div class="box-tools pull-right">';
|
||||
|
||||
foreach($args['header-controls']['controls'] as $control) {
|
||||
if (isset($control['anchor']) && $control['anchor'] == TRUE) {
|
||||
$anchor = (isset($control['anchor']) && $control['anchor']) ||
|
||||
(isset($control['config']) && !empty($control['config']));
|
||||
if ($anchor) {
|
||||
$return .= ' <a role="button"';
|
||||
} else {
|
||||
$return .= '<button type="button"';
|
||||
}
|
||||
if (isset($control['url']) && $control['url'] !== '#' && !empty($control['url'])) {
|
||||
$return .= ' href="'.$control['url'].'"';
|
||||
$return .= ' href="' . $control['url'] . '"';
|
||||
} elseif (isset($control['config']) && !empty($control['config'])) {
|
||||
// Check/get config option
|
||||
$return .= ' href="#"'; // set config url
|
||||
if (empty($control['data']) && isset($control['value'])) {
|
||||
$control['data'] = [ 'onclick' => "ajax_settings('".$control['config']."', '".$control['value']."');" ];
|
||||
}
|
||||
} else {
|
||||
//$return .= ' onclick="return false;"';
|
||||
}
|
||||
|
||||
// Additional class
|
||||
$return .= ' class="btn btn-box-tool';
|
||||
if (isset($control['class'])) { $return .= ' '.$control['class']; }
|
||||
if (isset($control['class'])) {
|
||||
$return .= ' ' . escape_html($control['class']);
|
||||
}
|
||||
$return .= '"';
|
||||
|
||||
if (isset($control['data'])) { $return .= ' '.$control['data']; }
|
||||
// Additional params (raw string or array with params
|
||||
if (isset($control['data'])) {
|
||||
$params = is_array($control['data']) ? generate_html_attribs($control['data']) : $control['data'];
|
||||
$return .= ' '.$params;
|
||||
}
|
||||
$return .= '>';
|
||||
|
||||
if (isset($control['icon'])) { $return .= '<i class="'.$control['icon'].'"></i> '; }
|
||||
if (isset($control['icon'])) { $return .= get_icon($control['icon']).' '; }
|
||||
if (isset($control['text'])) { $return .= $control['text']; }
|
||||
|
||||
if (isset($control['anchor']) && $control['anchor'] == TRUE) {
|
||||
if ($anchor) {
|
||||
$return .= '</a>';
|
||||
} else {
|
||||
$return .= '</button>';
|
||||
@ -455,7 +470,7 @@ SCRIPT;
|
||||
foreach ($content as $key => $value) {
|
||||
echo('<div id="'.$htmlname.'_clone_row" class="control-group text-nowrap" style="margin: 10px 0 10px 0;">'.PHP_EOL);
|
||||
$item = [
|
||||
'id' => "${htmlname}[key][]",
|
||||
'id' => "{$htmlname}[key][]",
|
||||
'name' => 'Key',
|
||||
//'width' => '500px',
|
||||
'class' => 'input-large',
|
||||
@ -470,7 +485,7 @@ SCRIPT;
|
||||
}
|
||||
echo(generate_form_element($item));
|
||||
$item = [
|
||||
'id' => "${htmlname}[value][]",
|
||||
'id' => "{$htmlname}[value][]",
|
||||
'name' => 'Value',
|
||||
//'width' => '500px',
|
||||
'class' => 'input-xlarge',
|
||||
@ -509,9 +524,9 @@ SCRIPT;
|
||||
// https://metallurgical.github.io/jquery-metal-clone/
|
||||
register_html_resource('js', 'jquery.metalClone.js'); // jquery.metalClone.min.js
|
||||
register_html_resource('css', 'metalClone.css');
|
||||
$clone_target = "${htmlname}_clone_row";
|
||||
$clone_button = "${htmlname}[add]";
|
||||
$clone_remove = "${htmlname}[remove]";
|
||||
$clone_target = "{$htmlname}_clone_row";
|
||||
$clone_button = "{$htmlname}[add]";
|
||||
$clone_remove = "{$htmlname}[remove]";
|
||||
$remove_text = ''; //'Remove';
|
||||
if ($readonly || (bool)$locked) {
|
||||
$clone_disabled = 'disabled: \'1\',';
|
||||
@ -531,26 +546,26 @@ SCRIPT;
|
||||
//console.log(element);
|
||||
var regex = /(metalElement\d{0,})/g;
|
||||
var eclass = element.attr('class');
|
||||
var others = \$('[id=${clone_target}]').not(element);
|
||||
var others = \$('[id={$clone_target}]').not(element);
|
||||
$.each(others, function () {
|
||||
\$(this).addClass(eclass);
|
||||
|
||||
// Add button icon
|
||||
//console.log(\$(this).find('#${clone_button}'));
|
||||
\$(this).find('[id=\"${clone_button}\"]').prepend(' ').prepend(\$('<i/>', { class: '${icon_add}' }));
|
||||
//console.log(\$(this).find('#{$clone_button}'));
|
||||
\$(this).find('[id=\"{$clone_button}\"]').prepend(' ').prepend(\$('<i/>', { class: '{$icon_add}' }));
|
||||
|
||||
// Remove button
|
||||
\$(this).append(\$('<button/>', {
|
||||
id: '${clone_remove}',
|
||||
id: '{$clone_remove}',
|
||||
type: 'button',
|
||||
${clone_disabled}
|
||||
{$clone_disabled}
|
||||
class: eclass.match(regex) + 'BtnRemove metal-btn-remove btn btn-danger',
|
||||
text: ' ${remove_text}',
|
||||
text: ' {$remove_text}',
|
||||
'data-metal-ref': '.' + element.attr('class').match(regex)
|
||||
}));
|
||||
|
||||
// Remove button icon
|
||||
\$(this).find('.metal-btn-remove').prepend(\$('<i/>', { class: '${icon_remove}' }));
|
||||
\$(this).find('.metal-btn-remove').prepend(\$('<i/>', { class: '{$icon_remove}' }));
|
||||
});
|
||||
}";
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ function print_search($data, $title = NULL, $button = 'search', $url = NULL)
|
||||
$string .= '<div class="navbar">' . PHP_EOL;
|
||||
$string .= '<div class="navbar-inner">';
|
||||
$string .= '<div class="container">';
|
||||
if (isset($title)) { $string .= ' <a class="brand">' . $title . '</a>' . PHP_EOL; }
|
||||
if (isset($title)) { $string .= ' <a class="brand">' . escape_html($title) . '</a>' . PHP_EOL; }
|
||||
|
||||
$string .= '<div class="nav" style="margin: 5px 0 5px 0;">';
|
||||
|
||||
@ -209,15 +209,13 @@ function generate_form_box($data)
|
||||
*
|
||||
* @return NULL
|
||||
*/
|
||||
function print_form($data, $return = FALSE)
|
||||
{
|
||||
function print_form($data, $return = FALSE) {
|
||||
// Just return if safety requirements are not fulfilled
|
||||
if (isset($data['userlevel']) && $data['userlevel'] > $_SESSION['userlevel']) { return; }
|
||||
|
||||
// Return if the user doesn't have write permissions to the relevant entity
|
||||
if (isset($data['entity_write_permit']) &&
|
||||
!is_entity_write_permitted($data['entity_write_permit']['entity_id'], $data['entity_write_permit']['entity_type']))
|
||||
{
|
||||
!is_entity_write_permitted($data['entity_write_permit']['entity_id'], $data['entity_write_permit']['entity_type'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -235,25 +233,22 @@ function print_form($data, $return = FALSE)
|
||||
|
||||
$form_id = (isset($data['id']) ? $data['id'] : 'form-'.strgen());
|
||||
$form_class = 'form form-inline'; // default for rows and simple
|
||||
if (isset($data['style']))
|
||||
{
|
||||
if (isset($data['style'])) {
|
||||
$form_style = ' style="'.$data['style'].'"';
|
||||
} else {
|
||||
$form_style = ' style="margin-bottom: 0px;"';
|
||||
}
|
||||
$base_class = (array_key_exists('class', $data) ? $data['class'] : OBS_CLASS_BOX);
|
||||
$base_space = ($data['space'] ? $data['space'] : '5px');
|
||||
$used_vars = array();
|
||||
$base_class = array_key_exists('class', $data) ? $data['class'] : OBS_CLASS_BOX;
|
||||
$base_space = $data['space'] ?: '5px';
|
||||
$used_vars = [];
|
||||
|
||||
// Cache permissions to session var
|
||||
permissions_cache_session();
|
||||
//r($_SESSION['cache']);
|
||||
|
||||
if ($data['submit_by_key'])
|
||||
{
|
||||
if ($data['submit_by_key']) {
|
||||
$action = '';
|
||||
if ($data['url'])
|
||||
{
|
||||
if ($data['url']) {
|
||||
$action .= 'this.form.prop(\'action\', form_to_path(\'' . $form_id . '\'));';
|
||||
}
|
||||
register_html_resource('script', '$(function(){$(\'form#' . $form_id . '\').each(function(){$(this).find(\'input\').keypress(function(e){if(e.which==10||e.which==13){'.$action.'this.form.submit();}});});});');
|
||||
@ -410,7 +405,7 @@ function print_form($data, $return = FALSE)
|
||||
{
|
||||
$div_begin .= ' <div class="title">';
|
||||
$div_begin .= get_icon($data['icon']);
|
||||
$div_begin .= ' '.$data['title'].'</div>' . PHP_EOL;
|
||||
$div_begin .= ' '.escape_html($data['title']).'</div>' . PHP_EOL;
|
||||
}
|
||||
$div_end = '</div>' . PHP_EOL;
|
||||
}
|
||||
@ -582,7 +577,7 @@ function print_form($data, $return = FALSE)
|
||||
$row_elements .= '
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<h3>'.$entry['title'].'</h3>
|
||||
<h3>'.escape_html($entry['title']).'</h3>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
@ -622,11 +617,10 @@ function print_form($data, $return = FALSE)
|
||||
}
|
||||
|
||||
// Add CSRF Token
|
||||
if (!in_array('requesttoken', $used_vars) && isset($_SESSION['requesttoken']))
|
||||
{
|
||||
$string_elements .= generate_form_element(array('type' => 'hidden',
|
||||
'id' => 'requesttoken',
|
||||
'value' => $_SESSION['requesttoken'])) . PHP_EOL;
|
||||
if (!in_array('requesttoken', $used_vars) && isset($_SESSION['requesttoken'])) {
|
||||
$string_elements .= generate_form_element([ 'type' => 'hidden',
|
||||
'id' => 'requesttoken',
|
||||
'value' => $_SESSION['requesttoken'] ]) . PHP_EOL;
|
||||
$used_vars[] = 'requesttoken';
|
||||
}
|
||||
|
||||
@ -636,22 +630,29 @@ function print_form($data, $return = FALSE)
|
||||
$used_vars[] = 'pagesize';
|
||||
|
||||
// Remove old vars from url
|
||||
if ($data['url'])
|
||||
{
|
||||
foreach ($used_vars as $var)
|
||||
{
|
||||
if ($data['url']) {
|
||||
foreach ($used_vars as $var) {
|
||||
$data['url'] = preg_replace('/'.$var.'=[^\/]+\/?/', '', $data['url']);
|
||||
}
|
||||
}
|
||||
|
||||
// Form header
|
||||
if (isset($data['right']) && $data['right'])
|
||||
{
|
||||
if (isset($data['right']) && $data['right']) {
|
||||
$form_class .= ' pull-right';
|
||||
}
|
||||
|
||||
// auto add some common html attribs
|
||||
$form_attribs = [ 'class' => $form_class ];
|
||||
foreach ([ 'onchange', 'oninput', 'onclick', 'ondblclick', 'onfocus', 'onsubmit' ] as $attrib) {
|
||||
if (isset($data[$attrib])) {
|
||||
$form_attribs[$attrib] = $data[$attrib];
|
||||
}
|
||||
}
|
||||
|
||||
$string = PHP_EOL . "<!-- START $form_id -->" . PHP_EOL;
|
||||
$string .= $div_begin;
|
||||
$string .= '<form method="POST" id="'.$form_id.'" name="'.$form_id.'" action="'.$data['url'].'" class="'.$form_class.'"'.$form_style.'>' . PHP_EOL;
|
||||
$string .= '<form method="POST" id="' . $form_id . '" name="' . $form_id . '" action="' .$data['url'] . '" ' .
|
||||
generate_html_attribs($form_attribs) . $form_style.'>' . PHP_EOL;
|
||||
if ($data['brand']) { $string .= ' <a class="brand">' . $data['brand'] . '</a>' . PHP_EOL; }
|
||||
if ($data['help']) { $string .= ' <span class="help-block">' . $data['help'] . '</span>' . PHP_EOL; }
|
||||
|
||||
@ -725,7 +726,7 @@ function print_form_box($data, $return = FALSE)
|
||||
$header = '';
|
||||
if (isset($data['title']))
|
||||
{
|
||||
$header .= ' <h2>' . $data['title'] . '</h2>' . PHP_EOL;
|
||||
$header .= ' <h2>' . escape_html($data['title']) . '</h2>' . PHP_EOL;
|
||||
}
|
||||
|
||||
// Form elements
|
||||
@ -1057,8 +1058,7 @@ function print_form_box($data, $return = FALSE)
|
||||
* @param string $type Type of form element, also can passed as $item['type']
|
||||
* @return string Generated form element
|
||||
*/
|
||||
function generate_form_element($item, $type = '')
|
||||
{
|
||||
function generate_form_element($item, $type = '') {
|
||||
// Check community edition
|
||||
if (isset($item['community']) && !$item['community'] && OBSERVIUM_EDITION === 'community') {
|
||||
return '';
|
||||
@ -1066,8 +1066,7 @@ function generate_form_element($item, $type = '')
|
||||
|
||||
$value_isset = isset($item['value']);
|
||||
if (!$value_isset) { $item['value'] = ''; }
|
||||
if (is_array($item['value']))
|
||||
{
|
||||
if (is_array($item['value'])) {
|
||||
// Passed from URI comma values always converted to array, re-implode it
|
||||
$item['value_escaped'] = escape_html(implode(',', $item['value']));
|
||||
} else {
|
||||
@ -1499,37 +1498,33 @@ SCRIPT;
|
||||
// Convert to data attribs and recursive call to checkbox
|
||||
$item['attribs']['data-toggle'] = 'toggle';
|
||||
// Convert switch style attr to toggle
|
||||
$item_attribs = ['on-icon' => 'icon-check', 'on-text' => 'label-check', 'off-icon' => 'icon-uncheck', 'off-text' => 'label-uncheck'];
|
||||
$item_attribs = [ 'on-icon' => 'icon-check', 'on-text' => 'label-check', 'off-icon' => 'icon-uncheck', 'off-text' => 'label-uncheck' ];
|
||||
foreach($item_attribs as $attr => $data_attr)
|
||||
{
|
||||
if (isset($item[$attr]) && !isset($item[$data_attr])) { $item[$data_attr] = $item[$attr]; }
|
||||
}
|
||||
// Move placeholder to label
|
||||
if (isset($item['placeholder']) && is_string($item['placeholder']))
|
||||
{
|
||||
if (isset($item['placeholder']) && is_string($item['placeholder'])) {
|
||||
$item['attribs']['data-tt-label'] = get_markdown($item['placeholder'], TRUE, TRUE);
|
||||
unset($item['placeholder']);
|
||||
}
|
||||
$item_attribs = array('size', 'palette', 'group', 'label', 'icon-check', 'label-check', 'icon-uncheck', 'label-uncheck');
|
||||
foreach($item_attribs as $attr)
|
||||
{
|
||||
$item_attribs = [ 'size', 'palette', 'group', 'label', 'icon-check', 'label-check', 'icon-uncheck', 'label-uncheck' ];
|
||||
foreach($item_attribs as $attr) {
|
||||
if (isset($item[$attr])) { $item['attribs']['data-tt-'.$attr] = $item[$attr]; }
|
||||
}
|
||||
// Types: http://tinytoggle.simonerighi.net/#types
|
||||
if (in_array($item['view'], array('toggle', 'check', 'circle', 'square', 'square_v', 'power', 'dot', 'like', 'watch', 'star', 'lock', 'heart', 'smile')))
|
||||
{
|
||||
if (in_array($item['view'], [ 'toggle', 'check', 'circle', 'square', 'square_v', 'power',
|
||||
'dot', 'like', 'watch', 'star', 'lock', 'heart', 'smile' ])) {
|
||||
$item['attribs']['data-tt-type'] = $item['view'];
|
||||
} else {
|
||||
$item['attribs']['data-tt-type'] = 'square'; // default type
|
||||
}
|
||||
// Onchange target id
|
||||
if ($item['onchange-id'])
|
||||
{
|
||||
if ($item['onchange-id']) {
|
||||
$item['attribs']['data-onchange-id'] = $item['onchange-id'];
|
||||
}
|
||||
// tiny-toggle not support readonly
|
||||
if (isset($item['readonly']))
|
||||
{
|
||||
if (isset($item['readonly'])) {
|
||||
$item['disabled'] = $item['readonly'] || $item['disabled'];
|
||||
//unset($item['readonly']);
|
||||
}
|
||||
@ -1542,30 +1537,23 @@ SCRIPT;
|
||||
case 'checkbox':
|
||||
$string = ' <input type="checkbox" ';
|
||||
$string .= ' name="'.$item['id'] . '" id="' .$item['id'] . '" ' . $item_switch;
|
||||
if ($item['title'])
|
||||
{
|
||||
if ($item['title']) {
|
||||
$string .= ' data-rel="tooltip" data-tooltip="'.escape_html($item['title']).'" title="'.escape_html($item['title']).'"';
|
||||
}
|
||||
if (get_var_true($item['value']))
|
||||
{
|
||||
$string .= ' value="1"';
|
||||
if (get_var_true($item['value'])) {
|
||||
$string .= ' checked';
|
||||
}
|
||||
if ($item['disabled'])
|
||||
{
|
||||
if ($item['disabled']) {
|
||||
$string .= ' disabled="1"';
|
||||
}
|
||||
elseif ($item['readonly'])
|
||||
{
|
||||
} elseif ($item['readonly']) {
|
||||
$string .= ' readonly="1" onclick="return false"';
|
||||
}
|
||||
if ($item['class'])
|
||||
{
|
||||
if ($item['class']) {
|
||||
$string .= ' class="' . trim($item['class']) . '"';
|
||||
}
|
||||
$string .= $element_data; // Add custom data- attribs
|
||||
$string .= ' value="1" />';
|
||||
if (is_string($item['placeholder']))
|
||||
{
|
||||
$string .= $element_data . ' />'; // Add custom data- attribs
|
||||
if (is_string($item['placeholder'])) {
|
||||
// add placeholder text at right of the element
|
||||
$string .= ' <label for="' . $item['id'] . '" class="help-inline" style="margin-top: 4px;">' .
|
||||
get_markdown($item['placeholder'], TRUE, TRUE) . '</label>' . PHP_EOL;
|
||||
@ -1752,8 +1740,8 @@ SCRIPT;
|
||||
$string .= ' <select multiple data-toggle="tagsinput" name="'.$item['id'].'[]" ';
|
||||
$string .= 'id="'.$item['id'].'" ';
|
||||
|
||||
if ($item['title']) { $string .= 'title="' . $item['title'] . '" '; }
|
||||
else if (isset($item['name'])) { $string .= 'title="' . $item['name'] . '" '; }
|
||||
if ($item['title']) { $string .= 'title="' . escape_html($item['title']) . '" '; }
|
||||
elseif (isset($item['name'])) { $string .= 'title="' . escape_html($item['name']) . '" '; }
|
||||
if (isset($item['placeholder']) && $item['placeholder'] !== FALSE)
|
||||
{
|
||||
if ($item['placeholder'] === TRUE)
|
||||
@ -1873,8 +1861,8 @@ SCRIPT;
|
||||
$string .= ' <select name="'.$item['id'].'" ';
|
||||
}
|
||||
$string .= 'id="'.$item['id'].'" ';
|
||||
if ($item['title']) { $string .= 'title="' . $item['title'] . '" '; }
|
||||
else if (isset($item['name'])) { $string .= 'title="' . $item['name'] . '" '; }
|
||||
if ($item['title']) { $string .= 'title="' . escape_html($item['title']) . '" '; }
|
||||
elseif (isset($item['name'])) { $string .= 'title="' . escape_html($item['name']) . '" '; }
|
||||
|
||||
$data_width = ($item['width']) ? ' data-width="'.$item['width'].'"' : ' data-width="auto"';
|
||||
$data_size = (is_numeric($item['size'])) ? ' data-size="'.$item['size'].'"' : ' data-size="15"';
|
||||
@ -2263,7 +2251,7 @@ function generate_modal_open(&$args)
|
||||
|
||||
$string .= '<div class="' . $base_class . '" id="' . $args['id'] . '" tabindex="-1"';
|
||||
|
||||
if ($args['role'] == 'dialog')
|
||||
if ($args['role'] === 'dialog')
|
||||
{
|
||||
$string .= ' role="dialog" aria-labelledby="' . $args['id'] . '_label">' . PHP_EOL;
|
||||
} else {
|
||||
@ -2282,7 +2270,7 @@ function generate_modal_open(&$args)
|
||||
{
|
||||
$string .= get_icon($args['icon']) . ' ';
|
||||
}
|
||||
$string .= $args['title'] . '</h3>' . PHP_EOL;
|
||||
$string .= escape_html($args['title']) . '</h3>' . PHP_EOL;
|
||||
}
|
||||
$string .= ' </div>' . PHP_EOL;
|
||||
|
||||
@ -2307,43 +2295,40 @@ function generate_modal_close($args)
|
||||
}
|
||||
|
||||
// Modal specific form
|
||||
function generate_form_modal($form)
|
||||
{
|
||||
function generate_form_modal($form) {
|
||||
// Just return if safety requirements are not fulfilled
|
||||
if (isset($form['userlevel']) && $form['userlevel'] > $_SESSION['userlevel']) { return; }
|
||||
if (isset($form['userlevel']) && $form['userlevel'] > $_SESSION['userlevel']) { return ''; }
|
||||
|
||||
// Return if the user doesn't have write permissions to the relevant entity
|
||||
if (isset($form['entity_write_permit']) &&
|
||||
!is_entity_write_permitted($form['entity_write_permit']['entity_id'], $form['entity_write_permit']['entity_type']))
|
||||
{
|
||||
return;
|
||||
!is_entity_write_permitted($form['entity_write_permit']['entity_id'], $form['entity_write_permit']['entity_type'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Generate only main modal form except header and close
|
||||
$form_only = isset($form['form_only']) && $form['form_only'];
|
||||
|
||||
// Time our form filling.
|
||||
$form_start = microtime(TRUE);
|
||||
|
||||
// Use modal with form
|
||||
if (isset($form['modal_args']))
|
||||
{
|
||||
if (isset($form['modal_args'])) {
|
||||
$modal_args = $form['modal_args'];
|
||||
unset($form['modal_args']);
|
||||
} else {
|
||||
$modal_args = array();
|
||||
$modal_args = [];
|
||||
}
|
||||
|
||||
if (!isset($modal_args['id']) && isset($form['id']))
|
||||
{
|
||||
if (!isset($modal_args['id']) && isset($form['id'])) {
|
||||
// Generate modal id from form id
|
||||
if (str_starts($form['id'], 'modal-'))
|
||||
{
|
||||
if (str_starts($form['id'], 'modal-')) {
|
||||
$modal_args['id'] = $form['id'];
|
||||
$form['id'] = substr($form['id'], 6);
|
||||
} else {
|
||||
$modal_args['id'] = 'modal-' . $form['id'];
|
||||
}
|
||||
}
|
||||
if (!isset($modal_args['title']) && isset($form['title']))
|
||||
{
|
||||
if (!isset($modal_args['title']) && isset($form['title'])) {
|
||||
// Move form title to modal header
|
||||
$modal_args['title'] = $form['title'];
|
||||
unset($form['title']);
|
||||
@ -2353,7 +2338,7 @@ function generate_form_modal($form)
|
||||
$form['fieldset']['body']['class'] = 'modal-body'; // Required this class for modal body!
|
||||
$form['fieldset']['footer']['class'] = 'modal-footer'; // Required this class for modal footer!
|
||||
|
||||
$modal = generate_modal_open($modal_args);
|
||||
$modal = !$form_only ? generate_modal_open($modal_args) : '';
|
||||
|
||||
// Save generation time for profiling
|
||||
$GLOBALS['form_time'] += utime() - $form_start;
|
||||
@ -2363,7 +2348,9 @@ function generate_form_modal($form)
|
||||
// Time our form filling.
|
||||
$form_start = microtime(TRUE);
|
||||
|
||||
$modal .= generate_modal_close($modal_args);
|
||||
if (!$form_only) {
|
||||
$modal .= generate_modal_close($modal_args);
|
||||
}
|
||||
|
||||
// Save generation time for profiling
|
||||
$GLOBALS['form_time'] += utime() - $form_start;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user