Compare commits

...

1 Commits

Author SHA1 Message Date
fa8a702a67 commit version 23.9.13005 2023-11-29 23:53:32 -05:00
4133 changed files with 2121180 additions and 965181 deletions

213
.phpcs.xml Normal file
View File

@ -0,0 +1,213 @@
<?xml version="1.0"?>
<ruleset name="Observium ruleset">
<description>Observium rules for PHP CodeSniffer</description>
<arg value="sp"/>
<arg name="extensions" value="php"/>
<file>.</file>
<!-- <arg name="report" value="xml"/>
<arg name="report-file" value="phpcs-report.xml"/> -->
<!-- Exclude unused code. -->
<exclude-pattern>*/attic/*</exclude-pattern>
<!-- Exclude devel code. -->
<exclude-pattern>*/devel/*</exclude-pattern>
<!-- Exclude Composer vendor directory. -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- Weathermap exclude -->
<exclude-pattern>*/weathermap/*</exclude-pattern>
<!-- Self PHPCompatibility exclude -->
<exclude-pattern>tests/php-compatibility/*</exclude-pattern>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>
<!-- Check up to 8 files simultanously. -->
<arg name="parallel" value="8"/>
<!-- PHPCompatibility standard path -->
<!-- <config name="installed_paths" value="tests/php-compatibility"/> -->
<!-- Check for cross-version support for PHP 5.6 and higher. -->
<config name="testVersion" value="5.6-"/>
<!-- Run against the PHPCompatibility ruleset -->
<rule ref="PHPCompatibility">
<exclude-pattern>irc\.php$</exclude-pattern>
<exclude-pattern>*/weathermap/*</exclude-pattern>
<!-- random_bytes() already exist by compatibility lib -->
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.random_bytesFound"/>
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.random_intFound"/>
<!-- array_key_first() already exist by compatibility -->
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.array_key_firstFound"/>
</rule>
<!-- Whitelist the mysql_to_rfc3339() and mysql_another_function() functions. -->
<rule ref="PHPCompatibility.Extensions.RemovedExtensions">
<properties>
<property name="functionWhitelist" type="array" value="mysql_authenticate,mysql_auth_can_logout,mysql_auth_can_change_password,mysql_auth_change_password,mysql_auth_usermanagement,mysql_adduser,mysql_auth_user_exists,mysql_auth_username_by_id,mysql_auth_user_level,mysql_auth_user_id,mysql_deluser,mysql_auth_user_list,mysql_auth_user_info"/>
</properties>
</rule>
<!-- random_compat lib -->
<rule ref="PHPCompatibility.Classes.NewClasses.typeerrorFound">
<exclude-pattern>libs/random_compat/*</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Classes.NewClasses.errorFound">
<exclude-pattern>libs/random_compat/*</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated">
<exclude-pattern>libs/random_compat/*</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_create_ivDeprecatedRemoved">
<exclude-pattern>libs/random_compat/*</exclude-pattern>
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_dev_urandomDeprecatedRemoved">
<exclude-pattern>libs/random_compat/*</exclude-pattern>
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<!-- pear chap lib excludes -->
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_module_openDeprecatedRemoved">
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_desDeprecatedRemoved">
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_enc_get_iv_sizeDeprecatedRemoved">
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_randDeprecatedRemoved">
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_generic_initDeprecatedRemoved">
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_genericDeprecatedRemoved">
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_generic_deinitDeprecatedRemoved">
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_module_closeDeprecatedRemoved">
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<!-- pear net socket excludes -->
<rule ref="PHPCompatibility.IniDirectives.RemovedIniDirectives.track_errorsDeprecated">
<exclude-pattern>libs/pear/Net/Socket\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.php_errormsgDeprecated">
<exclude-pattern>libs/pear/Net/Socket\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.error_clear_lastFound">
<exclude-pattern>libs/pear/Net/Socket\.php</exclude-pattern>
</rule>
<!-- Exclude shiff on specific patterns -->
<rule ref="PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection">
<exclude-pattern>includes/common\.inc\.php</exclude-pattern>
<exclude-pattern>libs/Fabiang/Xmpp/*</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Miscellaneous.ValidIntegers.HexNumericStringFound">
<exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>libs/pear/*</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.IniDirectives.RemovedIniDirectives.magic_quotes_runtimeDeprecatedRemoved">
<exclude-pattern>libs/pear/Mail/mime*</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.NewConstants.json_preserve_zero_fractionFound">
<exclude-pattern>includes/definitions\.inc\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved">
<exclude-pattern>includes/db/mysql\.inc\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.IniDirectives.RemovedIniDirectives.session_hash_functionRemoved">
<exclude-pattern>html/includes/authenticate\.inc\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretbox_keybytesFound">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretbox_noncebytesFound">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_padFound">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_secretboxFound">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Classes.NewClasses.sodiumexceptionFound">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_secretbox_openFound">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Extensions.RemovedExtensions.mcryptDeprecatedRemoved">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
<exclude-pattern>libs/random_compat/*</exclude-pattern>
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_encryptDeprecatedRemoved">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_decryptDeprecatedRemoved">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_rijndael_256DeprecatedRemoved">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_mode_ecbDeprecatedRemoved">
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_gpcDeprecated">
<exclude-pattern>html/includes/collectd/functions.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.session_create_idFound">
<exclude-pattern>html/includes/authenticate.inc.php</exclude-pattern>
</rule>
<!-- compatability fixed in code -->
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.ldap_control_paged_resultDeprecated">
<exclude-pattern>html/includes/authentication/ldap.inc.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.ldap_control_paged_result_responseDeprecated">
<exclude-pattern>html/includes/authentication/ldap.inc.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.NewFunctionParameters.ldap_search_serverctrlsFound">
<exclude-pattern>html/includes/authentication/ldap.inc.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionUse.NewFunctionParameters.ldap_parse_result_serverctrlsFound">
<exclude-pattern>html/includes/authentication/ldap.inc.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.NewConstants.ldap_control_pagedresultsFound">
<exclude-pattern>html/includes/authentication/ldap.inc.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Miscellaneous.ValidIntegers.HexNumericStringFound">
<exclude-pattern>includes/entities/sensor.inc.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.NewConstants.mysqli_client_ssl_dont_verify_server_certFound">
<exclude-pattern>includes/db/mysqli.inc.php</exclude-pattern>
</rule>
<!-- Run against a second ruleset -->
<!-- <rule ref="PSR2"/> -->
</ruleset>

View File

@ -1 +1 @@
Observium CE 22.12
Observium CE 23.9

View File

@ -5,9 +5,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
@ -16,230 +16,240 @@
chdir(dirname($argv[0]));
$options = getopt("dhpt");
if (isset($options['d'])) { array_shift($argv); }
if (isset($options['d'])) {
array_shift($argv);
}
include("includes/sql-config.inc.php");
include("includes/observium.inc.php");
include("includes/discovery/functions.inc.php");
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WAdd Device(s)%n\n", 'color');
if (OBS_DEBUG) { print_versions(); }
if (OBS_DEBUG) {
print_versions();
}
if (isset($options['h'])) { print_help(OBS_SCRIPT_NAME); exit; }
if (isset($options['h'])) {
print_help(OBS_SCRIPT_NAME);
exit;
}
$snmp_options = array();
$snmp_options = [];
// Just test, do not add device
if (isset($options['t'])) {
$snmp_options['test'] = TRUE;
array_shift($argv);
$snmp_options['test'] = TRUE;
array_shift($argv);
}
// Add skip pingable checks if argument -p passed
if (isset($options['p'])) {
$snmp_options['ping_skip'] = 1;
array_shift($argv);
$snmp_options['ping_skip'] = 1;
array_shift($argv);
}
$added = 0;
if (!empty($argv[1])) {
$add_array = array();
if (is_file($argv[1])) {
// Parse file into array with devices to add
foreach (new SplFileObject($argv[1]) as $line) {
$d = preg_split('/\s/', $line, -1, PREG_SPLIT_NO_EMPTY);
if (empty($d) || strpos(reset($d), '#') === 0) { continue; }
$add_array[] = $d;
}
} else {
$add_array[0] = $argv;
array_shift($add_array[0]);
}
// Save base SNMP v3 credentials and v2c/v1 community
$snmp_config_v3 = $config['snmp']['v3'];
$snmp_config_community = $config['snmp']['community'];
foreach ($add_array as $add) {
$hostname = strtolower($add[0]);
$snmp_community = $add[1];
$snmp_version = strtolower($add[2]);
$snmp_port = 161;
if (str_contains($hostname, ':') && get_ip_version($hostname) !== 6) {
// Allow pass common hostname:port
list($host_tmp, $port_tmp) = explode(':', $hostname, 2);
if (is_valid_param($port_tmp, 'port')) {
$hostname = $host_tmp;
$snmp_port = $port_tmp;
}
unset($host_tmp, $port_tmp);
}
$snmp_transport = 'udp';
if ($snmp_version === "v3") {
$config['snmp']['v3'] = $snmp_config_v3; // Restore base SNMP v3 credentials
$snmp_v3_seclevel = $snmp_community;
// These values are the same as in defaults.inc.php
$snmp_v3_auth = [
'authlevel' => "noAuthNoPriv",
'authname' => "observium",
'authpass' => "",
'authalgo' => "MD5",
'cryptopass' => "",
'cryptoalgo' => "AES"
];
$add_context = FALSE; // Derp, last arg after transport is context
if ($snmp_v3_seclevel === "nanp" || $snmp_v3_seclevel === "any" || $snmp_v3_seclevel === "noAuthNoPriv") {
$snmp_v3_auth['authlevel'] = "noAuthNoPriv";
$snmp_v3_args = array_slice($add, 3);
while ($arg = array_shift($snmp_v3_args)) {
// parse all remaining args
if (is_valid_param($arg, 'port')) {
$snmp_port = $arg;
} elseif (preg_match('/^(' . implode("|", $config['snmp']['transports']) . ')$/', $arg)) {
$snmp_transport = $arg;
$add_context = TRUE; // Derp, last arg after transport is context
} elseif ($add_context && strlen($arg)) {
$snmp_context = $arg;
break;
} else {
// FIXME: should add a sanity check of chars allowed in user
$user = $arg;
}
$add_array = [];
if (is_file($argv[1])) {
// Parse file into array with devices to add
foreach (new SplFileObject($argv[1]) as $line) {
$d = preg_split('/\s/', $line, -1, PREG_SPLIT_NO_EMPTY);
if (empty($d) || strpos(reset($d), '#') === 0) {
continue;
}
$add_array[] = $d;
}
if ($snmp_v3_seclevel !== "any") {
$config['snmp']['v3'] = [ $snmp_v3_auth ];
}
} elseif ($snmp_v3_seclevel === "anp" || $snmp_v3_seclevel === "authNoPriv") {
$snmp_v3_auth['authlevel'] = "authNoPriv";
$snmp_v3_args = array_slice($argv, 4);
$snmp_v3_auth['authname'] = array_shift($snmp_v3_args);
$snmp_v3_auth['authpass'] = array_shift($snmp_v3_args);
while ($arg = array_shift($snmp_v3_args)) {
// parse all remaining args
if (is_valid_param($arg, 'port')) {
$snmp_port = $arg;
} elseif (preg_match('/^(' . implode("|", $config['snmp']['transports']) . ')$/i', $arg)) {
$snmp_transport = $arg;
$add_context = TRUE; // Derp, last arg after transport is context
} elseif (is_valid_param($arg, 'snmp_authalgo')) {
$snmp_v3_auth['authalgo'] = $arg;
} elseif ($add_context && strlen($arg)) {
$snmp_context = $arg;
break;
}
}
$config['snmp']['v3'] = [ $snmp_v3_auth ];
} elseif ($snmp_v3_seclevel === "ap" || $snmp_v3_seclevel === "authPriv") {
$snmp_v3_auth['authlevel'] = "authPriv";
$snmp_v3_args = array_slice($argv, 4);
$snmp_v3_auth['authname'] = array_shift($snmp_v3_args);
$snmp_v3_auth['authpass'] = array_shift($snmp_v3_args);
$snmp_v3_auth['cryptopass'] = array_shift($snmp_v3_args);
while ($arg = array_shift($snmp_v3_args)) {
// parse all remaining args
if (is_valid_param($arg, 'port')) {
$snmp_port = $arg;
} elseif (preg_match('/^(' . implode("|", $config['snmp']['transports']) . ')$/i', $arg)) {
$snmp_transport = $arg;
$add_context = TRUE; // Derp, last arg after transport is context
} elseif (is_valid_param($arg, 'snmp_authalgo')) {
$snmp_v3_auth['authalgo'] = $arg;
} elseif (is_valid_param($arg, 'snmp_cryptoalgo')) {
$snmp_v3_auth['cryptoalgo'] = $arg;
} elseif ($add_context && strlen($arg)) {
$snmp_context = $arg;
break;
}
}
$config['snmp']['v3'] = [ $snmp_v3_auth ];
}
//print_debug_vars($snmp_v3_auth);
//print_debug_vars($config['snmp']['v3']);
} else {
// v1 or v2c
$snmp_v2_args = array_slice($argv, 2);
$add_array[0] = $argv;
array_shift($add_array[0]);
}
$add_context = FALSE; // Derp, last arg after transport is context
while ($arg = array_shift($snmp_v2_args)) {
// parse all remaining args
if (is_valid_param($arg, 'port')) {
$snmp_port = $arg;
} elseif (preg_match('/(' . implode("|", $config['snmp']['transports']) . ')/i', $arg)) {
$snmp_transport = $arg;
$add_context = TRUE; // Derp, last arg after transport is context
} elseif (preg_match('/^(v1|v2c)$/i', $arg)) {
$snmp_version = $arg;
} elseif ($add_context && strlen($arg)) {
$snmp_context = $arg;
break;
// Save base SNMP v3 credentials and v2c/v1 community
$snmp_config_v3 = $config['snmp']['v3'];
$snmp_config_community = $config['snmp']['community'];
foreach ($add_array as $add) {
$hostname = strtolower($add[0]);
$snmp_community = $add[1];
$snmp_version = strtolower($add[2]);
$snmp_port = 161;
if (str_contains($hostname, ':') && get_ip_version($hostname) !== 6) {
// Allow pass common hostname:port
[$host_tmp, $port_tmp] = explode(':', $hostname, 2);
if (is_valid_param($port_tmp, 'port')) {
$hostname = $host_tmp;
$snmp_port = $port_tmp;
}
unset($host_tmp, $port_tmp);
}
}
$snmp_transport = 'udp';
$config['snmp']['community'] = ($snmp_community ? array($snmp_community) : $snmp_config_community);
}
if ($snmp_version === "v3") {
$config['snmp']['v3'] = $snmp_config_v3; // Restore base SNMP v3 credentials
$snmp_v3_seclevel = $snmp_community;
// Add snmp context to params
if (isset($snmp_context)) {
$snmp_options['snmp_context'] = $snmp_context;
unset($snmp_context);
}
// These values are the same as in defaults.inc.php
$snmp_v3_auth = [
'authlevel' => "noAuthNoPriv",
'authname' => "observium",
'authpass' => "",
'authalgo' => "MD5",
'cryptopass' => "",
'cryptoalgo' => "AES"
];
print_message("Try to add $hostname:");
if (in_array($snmp_version, array('v1', 'v2c', 'v3'))) {
// If snmp version passed in arguments, then use the exact version
$device_id = add_device($hostname, $snmp_version, $snmp_port, $snmp_transport, $snmp_options);
} else {
// If snmp version unknown check all possible snmp versions and auth options
$device_id = add_device($hostname, NULL, $snmp_port, $snmp_transport, $snmp_options);
}
$add_context = FALSE; // Derp, last arg after transport is context
if ($snmp_v3_seclevel === "nanp" || $snmp_v3_seclevel === "any" || $snmp_v3_seclevel === "noAuthNoPriv") {
$snmp_v3_auth['authlevel'] = "noAuthNoPriv";
$snmp_v3_args = array_slice($add, 3);
if ($device_id) {
if (!isset($options['t'])) {
$device = device_by_id_cache($device_id);
print_success("Added device " . $device['hostname'] . " (" . $device_id . ").");
} // Else this is device testing, success message already written by add_device()
$added++;
while ($arg = array_shift($snmp_v3_args)) {
// parse all remaining args
if (is_valid_param($arg, 'port')) {
$snmp_port = $arg;
} elseif (preg_match('/^(' . implode("|", $config['snmp']['transports']) . ')$/', $arg)) {
$snmp_transport = $arg;
$add_context = TRUE; // Derp, last arg after transport is context
} elseif ($add_context && strlen($arg)) {
$snmp_context = $arg;
break;
} else {
// FIXME: should add a sanity check of chars allowed in user
$user = $arg;
}
}
if ($snmp_v3_seclevel !== "any") {
$config['snmp']['v3'] = [$snmp_v3_auth];
}
} elseif ($snmp_v3_seclevel === "anp" || $snmp_v3_seclevel === "authNoPriv") {
$snmp_v3_auth['authlevel'] = "authNoPriv";
$snmp_v3_args = array_slice($argv, 4);
$snmp_v3_auth['authname'] = array_shift($snmp_v3_args);
$snmp_v3_auth['authpass'] = array_shift($snmp_v3_args);
while ($arg = array_shift($snmp_v3_args)) {
// parse all remaining args
if (is_valid_param($arg, 'port')) {
$snmp_port = $arg;
} elseif (preg_match('/^(' . implode("|", $config['snmp']['transports']) . ')$/i', $arg)) {
$snmp_transport = $arg;
$add_context = TRUE; // Derp, last arg after transport is context
} elseif (is_valid_param($arg, 'snmp_authalgo')) {
$snmp_v3_auth['authalgo'] = $arg;
} elseif ($add_context && strlen($arg)) {
$snmp_context = $arg;
break;
}
}
$config['snmp']['v3'] = [$snmp_v3_auth];
} elseif ($snmp_v3_seclevel === "ap" || $snmp_v3_seclevel === "authPriv") {
$snmp_v3_auth['authlevel'] = "authPriv";
$snmp_v3_args = array_slice($argv, 4);
$snmp_v3_auth['authname'] = array_shift($snmp_v3_args);
$snmp_v3_auth['authpass'] = array_shift($snmp_v3_args);
$snmp_v3_auth['cryptopass'] = array_shift($snmp_v3_args);
while ($arg = array_shift($snmp_v3_args)) {
// parse all remaining args
if (is_valid_param($arg, 'port')) {
$snmp_port = $arg;
} elseif (preg_match('/^(' . implode("|", $config['snmp']['transports']) . ')$/i', $arg)) {
$snmp_transport = $arg;
$add_context = TRUE; // Derp, last arg after transport is context
} elseif (is_valid_param($arg, 'snmp_authalgo')) {
$snmp_v3_auth['authalgo'] = $arg;
} elseif (is_valid_param($arg, 'snmp_cryptoalgo')) {
$snmp_v3_auth['cryptoalgo'] = $arg;
} elseif ($add_context && strlen($arg)) {
$snmp_context = $arg;
break;
}
}
$config['snmp']['v3'] = [$snmp_v3_auth];
}
//print_debug_vars($snmp_v3_auth);
//print_debug_vars($config['snmp']['v3']);
} else {
// v1 or v2c
$snmp_v2_args = array_slice($argv, 2);
$add_context = FALSE; // Derp, last arg after transport is context
while ($arg = array_shift($snmp_v2_args)) {
// parse all remaining args
if (is_valid_param($arg, 'port')) {
$snmp_port = $arg;
} elseif (preg_match('/(' . implode("|", $config['snmp']['transports']) . ')/i', $arg)) {
$snmp_transport = $arg;
$add_context = TRUE; // Derp, last arg after transport is context
} elseif (preg_match('/^(v1|v2c)$/i', $arg)) {
$snmp_version = $arg;
} elseif ($add_context && strlen($arg)) {
$snmp_context = $arg;
break;
}
}
$config['snmp']['community'] = ($snmp_community ? [$snmp_community] : $snmp_config_community);
}
// Add snmp context to params
if (isset($snmp_context)) {
$snmp_options['snmp_context'] = $snmp_context;
unset($snmp_context);
}
print_message("Try to add $hostname:");
if (in_array($snmp_version, ['v1', 'v2c', 'v3'])) {
// If snmp version passed in arguments, then use the exact version
$device_id = add_device($hostname, $snmp_version, $snmp_port, $snmp_transport, $snmp_options);
} else {
// If snmp version unknown check all possible snmp versions and auth options
$device_id = add_device($hostname, NULL, $snmp_port, $snmp_transport, $snmp_options);
}
if ($device_id) {
if (!isset($options['t'])) {
$device = device_by_id_cache($device_id);
print_success("Added device " . $device['hostname'] . " (" . $device_id . ").");
} // Else this is device testing, success message already written by add_device()
$added++;
}
}
}
}
$count = safe_count($add_array);
$count = safe_count($add_array);
$failed = $count - $added;
if ($added) {
print_message("\nDevices success: $added.");
if ($failed) {
print_message("Devices failed: $failed.");
}
print_message("\nDevices success: $added.");
if ($failed) {
print_message("Devices failed: $failed.");
}
} else {
if ($count) {
print_message("Devices failed: $failed.");
}
print_help(OBS_SCRIPT_NAME);
if ($count) {
print_message("Devices failed: $failed.");
}
print_help(OBS_SCRIPT_NAME);
}
function print_help($scriptname) {
global $config;
function print_help($scriptname)
{
global $config;
$snmp_version = get_versions('snmp');
if (version_compare($snmp_version, '5.8', '<')) {
$snmpv3_auth = '[md5|sha]';
$snmpv3_crypto = '[des|aes]';
} else {
$snmpv3_auth = '[md5|sha|sha-224|sha-256|sha-384|sha-512]';
$snmpv3_crypto = '[des|aes|aes-192|aes-192-c|aes-256|aes-256-c]';
}
$snmp_transports = '[' . implode("|", $config['snmp']['transports']) . ']';
print_message("%n
$snmp_version = get_versions('snmp');
if (version_compare($snmp_version, '5.8', '<')) {
$snmpv3_auth = '[md5|sha]';
$snmpv3_crypto = '[des|aes]';
} else {
$snmpv3_auth = '[md5|sha|sha-224|sha-256|sha-384|sha-512]';
$snmpv3_crypto = '[des|aes|aes-192|aes-192-c|aes-256|aes-256-c]';
}
$snmp_transports = '[' . implode("|", $config['snmp']['transports']) . ']';
print_message("%n
USAGE:
$scriptname <hostname> [community] [v1|v2c] [port] $snmp_transports
$scriptname <hostname> [any|nanp|anp|ap] [v3] [user] [password] [enckey] $snmpv3_auth $snmpv3_crypto [port] $snmp_transports

View File

@ -5,52 +5,52 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
chdir(dirname($argv[0]));
$options = getopt("d");
if (isset($options['d'])) { array_shift($argv); } // for compatibility
if (isset($options['d'])) {
array_shift($argv);
} // for compatibility
include("includes/sql-config.inc.php");
include("includes/observium.inc.php");
print_message("%g".OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION."\n%WAdd User%n\n", 'color');
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WAdd User%n\n", 'color');
if (OBS_DEBUG) { print_versions(); }
$auth_file = $config['html_dir'].'/includes/authentication/' . $config['auth_mechanism'] . '.inc.php';
if (is_file($auth_file))
{
include($auth_file);
// Include base auth functions calls
include($config['html_dir'].'/includes/authenticate-functions.inc.php');
} else {
print_error("ERROR: no valid auth_mechanism defined.");
exit();
if (OBS_DEBUG) {
print_versions();
}
if (auth_usermanagement())
{
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]))
{
if (!auth_user_exists($argv[1]))
{
if (adduser($argv[1], $argv[2], $argv[3], @$argv[4]))
{
print_success("User ".$argv[1]." added successfully.");
} else {
print_error("User ".$argv[1]." creation failed!");
}
$auth_file = $config['html_dir'] . '/includes/authentication/' . $config['auth_mechanism'] . '.inc.php';
if (is_file($auth_file)) {
// Include base auth functions calls
include_once($config['html_dir'] . '/includes/sessions.inc.php');
include_once($config['html_dir'] . '/includes/authenticate-functions.inc.php');
include_once($auth_file);
} else {
print_error("ERROR: no valid auth_mechanism defined.");
exit();
}
if (auth_usermanagement()) {
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3])) {
if (!auth_user_exists($argv[1])) {
if (adduser($argv[1], $argv[2], $argv[3], @$argv[4])) {
print_success("User " . $argv[1] . " added successfully.");
} else {
print_error("User " . $argv[1] . " creation failed!");
}
} else {
print_warning("User " . $argv[1] . " already exists!");
}
} else {
print_warning("User ".$argv[1]." already exists!");
}
} else {
$msg = "%n
$msg = "%n
USAGE:
$scriptname <username> <password> <level 1-10> [email]
@ -59,16 +59,15 @@ EXAMPLE:
USER LEVELS:" . PHP_EOL;
foreach($GLOBALS['config']['user_level'] as $level => $entry)
{
$msg .= ' '.$level.' - %W'.$entry['name'].'%n ('.$entry['subtext'].')'. PHP_EOL;
}
$msg .= PHP_EOL . "%rInvalid arguments!%n";
foreach ($GLOBALS['config']['user_level'] as $level => $entry) {
$msg .= ' ' . $level . ' - %W' . $entry['name'] . '%n (' . $entry['subtext'] . ')' . PHP_EOL;
}
$msg .= PHP_EOL . "%rInvalid arguments!%n";
print_message($msg, 'color', FALSE);
}
print_message($msg, 'color', FALSE);
}
} else {
print_error("Auth module does not allow adding users!");
print_error("Auth module does not allow adding users!");
}
// EOF

View File

@ -5,9 +5,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
@ -15,7 +15,7 @@ chdir(dirname($argv[0]));
$options = getopt("h:p:dqrsV");
include("includes/sql-config.inc.php");
include("includes/observium.inc.php");
include("includes/polling/functions.inc.php");
include("html/includes/functions.inc.php");
@ -23,43 +23,43 @@ include("html/includes/functions.inc.php");
$start = utime();
if (isset($options['V'])) {
print_message(OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION);
exit;
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
exit;
}
if (isset($options['s'])) {
// User has asked for spam. LETS MAKE THE SPAM. (sends alerts even if they have already been sent)
$spam = TRUE;
// User has asked for spam. LETS MAKE THE SPAM. (sends alerts even if they have already been sent)
$spam = TRUE;
}
if (!isset($options['q'])) {
print_cli_banner();
print_cli_banner();
}
if ($options['h'] === "all") {
$where = " ";
$doing = "all";
$where = " ";
$doing = "all";
} elseif ($options['h']) {
$params = [];
if (is_numeric($options['h'])) {
$where = "AND `device_id` = ?";
$doing = $options['h'];
$params[] = $options['h'];
} else {
$where = "AND `hostname` LIKE ?";
$doing = $options['h'];
$params[] = str_replace('*','%', $options['h']);
}
$params = [];
if (is_numeric($options['h'])) {
$where = "AND `device_id` = ?";
$doing = $options['h'];
$params[] = $options['h'];
} else {
$where = "AND `hostname` LIKE ?";
$doing = $options['h'];
$params[] = str_replace('*', '%', $options['h']);
}
}
if (isset($options['p'])) {
print_cli_heading("%WConstrained to poller partition id ".$options['p']);
$where .= ' AND `poller_id` = ?';
$params[] = $options['p'];
print_cli_heading("%WConstrained to poller partition id " . $options['p']);
$where .= ' AND `poller_id` = ?';
$params[] = $options['p'];
}
if (!$where) {
print_message("%n
print_message("%n
USAGE:
$scriptname [-drqV] [-p poller_id] [-h device]
@ -82,10 +82,10 @@ DEBUGGING OPTIONS:
-dd More verbose debugging output.
%rInvalid arguments!%n", 'color');
exit;
exit;
}
print_cli_heading("%WStarting alerter run at ".date("Y-m-d H:i:s"), 0);
print_cli_heading("%WStarting alerter run at " . date("Y-m-d H:i:s"), 0);
$polled_devices = 0;
@ -102,17 +102,17 @@ $_SESSION['userlevel'] = 10;
$query = "SELECT * FROM `devices` WHERE `disabled` = 0 $where ORDER BY `device_id` ASC";
foreach (dbFetchRows($query, $params) as $device) {
humanize_device($device);
humanize_device($device);
process_alerts($device);
if ($config['poller-wrapper']['notifications'] || $spam) {
process_notifications([ 'device_id' => $device['device_id'] ]); // Send all notifications (also for syslog from queue)
}
process_alerts($device);
if ($config['poller-wrapper']['notifications'] || $spam) {
process_notifications(['device_id' => $device['device_id']]); // Send all notifications (also for syslog from queue)
}
dbUpdate([ 'last_alerter' => [ 'NOW()' ] ], 'devices', '`device_id` = ?', [ $device['device_id'] ]);
dbUpdate(['last_alerter' => ['NOW()']], 'devices', '`device_id` = ?', [$device['device_id']]);
}
print_cli_heading("%WFinished alerter run at ".date("Y-m-d H:i:s"), 0);
print_cli_heading("%WFinished alerter run at " . date("Y-m-d H:i:s"), 0);
// EOF

View File

@ -5,51 +5,52 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
chdir(dirname($argv[0]));
$options = getopt("d");
if (isset($options['d'])) { array_shift($argv); } // for compatibility
if (isset($options['d'])) {
array_shift($argv);
} // for compatibility
include("includes/sql-config.inc.php");
include("includes/observium.inc.php");
// Check all of our interface RRD files for errors
if ($argv[1]) { $where = "AND `port_id` = ?"; $params = array($argv[1]); }
if ($argv[1]) {
$where = "AND `port_id` = ?";
$params = [$argv[1]];
}
$i = 0;
$i = 0;
$errored = 0;
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where", $params) as $interface)
{
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
if ($errors > '1')
{
$errored[] = generate_device_link($interface, $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta']);
$errored++;
}
$i++;
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where", $params) as $interface) {
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
if ($errors > '1') {
$errored[] = generate_device_link($interface, $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta']);
$errored++;
}
$i++;
}
echo("Checked $i interfaces\n");
if (is_array($errored))
{ // If there are errored ports
$i = 0;
$msg = "Interfaces with errors : \n\n";
if (is_array($errored)) { // If there are errored ports
$i = 0;
$msg = "Interfaces with errors : \n\n";
foreach ($errored as $int)
{
$msg .= "$int\n"; // Add a line to the report email warning about them
$i++;
}
// Send the alert email
//notify($device, "Observium detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg);
foreach ($errored as $int) {
$msg .= "$int\n"; // Add a line to the report email warning about them
$i++;
}
// Send the alert email
//notify($device, "Observium detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg);
}
echo("$errored interfaces with errors over the past 5 minutes.\n");

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
@ -17,18 +17,18 @@ chdir(dirname($argv[0]));
// Get options before definitions!
$options = getopt("o:d");
require_once("includes/sql-config.inc.php");
require_once("includes/observium.inc.php");
if (is_cli()) {
if (isset($options['o'])) {
// get filtered options
get_config_json($options['o']);
//print_vars($options);
} else {
// All config options
get_config_json();
//print(safe_json_encode($config));
}
if (isset($options['o'])) {
// get filtered options
get_config_json($options['o']);
//print_vars($options);
} else {
// All config options
get_config_json();
//print(safe_json_encode($config));
}
}
// EOF

View File

@ -5,41 +5,40 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
chdir(dirname($argv[0]));
$options = getopt("d");
if (isset($options['d'])) { array_shift($argv); } // for compatibility
if (isset($options['d'])) {
array_shift($argv);
} // for compatibility
include("includes/sql-config.inc.php");
include("includes/observium.inc.php");
print_message("%g".OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION."\n%WRemove Device%n\n", 'color');
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WRemove Device%n\n", 'color');
// Remove a host and all related data from the system
if ($argv[1])
{
$host = strtolower($argv[1]);
if (is_numeric($host))
{
$id = $host;
} else {
$id = get_device_id_by_hostname($host);
}
$delete_rrd = isset($argv[2]) && strtolower($argv[2]) === 'rrd';
if ($argv[1]) {
$host = strtolower($argv[1]);
if (is_numeric($host)) {
$id = $host;
} else {
$id = get_device_id_by_hostname($host);
}
$delete_rrd = isset($argv[2]) && strtolower($argv[2]) === 'rrd';
// Test if a valid id was fetched from get_device_id_by_hostname()
if (isset($id) && is_numeric($id))
{
print_warning(delete_device($id, $delete_rrd));
print_success("Device $host removed.");
} else {
print_error("Device $host doesn't exist!");
}
// Test if a valid id was fetched from get_device_id_by_hostname()
if (isset($id) && is_numeric($id)) {
print_warning(delete_device($id, $delete_rrd));
print_success("Device $host removed.");
} else {
print_error("Device $host doesn't exist!");
}
} else {
print_message("%n

View File

@ -5,9 +5,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
@ -16,120 +16,126 @@ chdir(dirname($argv[0]));
// Get options before definitions!
$options = getopt("h:i:m:n:p:U:dquaMV");
include("includes/sql-config.inc.php");
include("includes/observium.inc.php");
include("includes/discovery/functions.inc.php");
$cli = TRUE;
//if (is_cron()) { $options['q'] = TRUE; } // Set quiet for cron
$start = utime();
$runtime_stats = array();
$start = utime();
$runtime_stats = [];
if (isset($options['V'])) {
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
if (is_array($options['V'])) { print_versions(); }
exit;
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
if (is_array($options['V'])) {
print_versions();
}
exit;
}
if (isset($options['M'])) {
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
print_message('Enabled discovery modules:');
$m_disabled = array();
foreach ($config['discovery_modules'] as $module => $ok) {
if ($ok) {
print_message(' ' . $module);
} else {
$m_disabled[] = $module;
print_message('Enabled discovery modules:');
$m_disabled = [];
foreach ($config['discovery_modules'] as $module => $ok) {
if ($ok) {
print_message(' ' . $module);
} else {
$m_disabled[] = $module;
}
}
}
if (count($m_disabled)) {
print_message('Disabled discovery modules:');
print_message(' ' . implode("\n ", $m_disabled));
}
exit;
if (count($m_disabled)) {
print_message('Disabled discovery modules:');
print_message(' ' . implode("\n ", $m_disabled));
}
exit;
}
if (!isset($options['q'])) {
print_cli_banner();
print_cli_banner();
if (OBS_DEBUG) { print_versions(); }
if (OBS_DEBUG) {
print_versions();
}
// Warning about obsolete configs.
if (print_obsolete_config()) { echo PHP_EOL; }
// Warning about obsolete configs.
if (print_obsolete_config()) {
echo PHP_EOL;
}
}
if (isset($options['u']) || isset($options['U']) ||
(isset($options['h']) && in_array($options['h'], [ 'all', 'odd', 'even', 'none' ]))) {
$options['u'] = TRUE;
(isset($options['h']) && in_array($options['h'], ['all', 'odd', 'even', 'none']))) {
$options['u'] = TRUE;
include($config['install_dir'] . '/includes/update/update.php');
include($config['install_dir'] . '/includes/update/update.php');
} elseif (!isset($options['q'])) {
// Warn about need DB schema update
$db_version = get_db_version();
$db_version = sprintf("%03d", $db_version + 1);
if (is_file($config['install_dir'] . "/update/$db_version.sql") || is_file($config['install_dir'] . "/update/$db_version.php")) {
print_warning("Your database schema is old and needs updating. Run from console:\n " . $config['install_dir'] . "/discovery.php -u");
}
unset($db_version);
// Warn about need DB schema update
$db_version = get_db_version();
$db_version = sprintf("%03d", $db_version + 1);
if (is_file($config['install_dir'] . "/update/$db_version.sql") || is_file($config['install_dir'] . "/update/$db_version.php")) {
print_warning("Your database schema is old and needs updating. Run from console:\n " . $config['install_dir'] . "/discovery.php -u");
}
unset($db_version);
}
$where = '';
if (isset($options['h'])) {
$params = array();
switch ($options['h']) {
case 'odd':
$options['n'] = 1;
$options['i'] = 2;
break;
case 'even':
$options['n'] = 0;
$options['i'] = 2;
break;
case 'all':
$where = ' ';
$doing = 'all';
break;
case 'new':
$where = ' AND (`last_discovered` IS NULL OR `last_discovered` = ? OR `force_discovery` = ?)';
$params[] = '0000-00-00 00:00:00';
$params[] = 1;
$doing = 'new';
$params = [];
switch ($options['h']) {
case 'odd':
$options['n'] = 1;
$options['i'] = 2;
break;
case 'even':
$options['n'] = 0;
$options['i'] = 2;
break;
case 'all':
$where = ' ';
$doing = 'all';
break;
case 'new':
$where = ' AND (`last_discovered` IS NULL OR `last_discovered` = ? OR `force_discovery` = ?)';
$params[] = '0000-00-00 00:00:00';
$params[] = 1;
$doing = 'new';
// add new devices on remote poller from actions queue
if (OBS_DISTRIBUTED && function_exists('run_action_queue')) {
run_action_queue('device_add');
//run_action_queue('device_rename');
//run_action_queue('device_delete');
// add new devices on remote poller from actions queue
if (OBS_DISTRIBUTED && function_exists('run_action_queue')) {
run_action_queue('device_add');
//run_action_queue('device_rename');
//run_action_queue('device_delete');
// Update alert and group tables
run_action_queue('tables_update');
}
break;
case 'none':
//$options['u'] = TRUE;
break;
default:
$doing = $options['h'];
if (is_numeric($options['h'])) {
$where = ' AND `device_id` = ?';
$params[] = $options['h'];
} else {
$where = ' AND `hostname` LIKE ?';
$params[] = str_replace('*', '%', $options['h']);
}
}
// Update alert and group tables
run_action_queue('tables_update');
}
break;
case 'none':
//$options['u'] = TRUE;
break;
default:
$doing = $options['h'];
if (is_numeric($options['h'])) {
$where = ' AND `device_id` = ?';
$params[] = $options['h'];
} else {
$where = ' AND `hostname` LIKE ?';
$params[] = str_replace('*', '%', $options['h']);
}
}
}
if (isset($options['i'], $options['n']) && $options['i']) {
$where .= ' AND MOD(device_id,' . $options['i'] . ') = ?';
$params[] = $options['n'];
$doing = $options['n'] . '/' . $options['i'];
$where .= ' AND MOD(device_id,' . $options['i'] . ') = ?';
$params[] = $options['n'];
$doing = $options['n'] . '/' . $options['i'];
}
if (!$where && !$options['u'] && !isset($options['a'])) {
print_message("%n
print_message("%n
USAGE:
$scriptname [-dquV] [-i instances] [-n number] [-m module] [-h device]
@ -162,100 +168,108 @@ DEBUGGING OPTIONS:
}
if ($config['version_check'] && ($options['h'] !== 'new' || $options['u'])) {
include($config['install_dir'] . '/includes/versioncheck.inc.php');
include($config['install_dir'] . '/includes/versioncheck.inc.php');
}
if (!$where) {
// Only update Group/Alert tables
if (isset($options['a'])) {
// Only update Group/Alert tables
if (isset($options['a'])) {
if (OBS_DISTRIBUTED && function_exists('run_action_queue')) {
//run_action_queue('device_add');
//run_action_queue('device_rename');
//run_action_queue('device_delete');
if (OBS_DISTRIBUTED && function_exists('run_action_queue')) {
//run_action_queue('device_add');
//run_action_queue('device_rename');
//run_action_queue('device_delete');
// Update alert and group tables
run_action_queue('tables_update');
} else {
$silent = isset($options['q']);
if (function_exists('update_group_tables')) { update_group_tables($silent); } // Not exist in CE
if (function_exists('update_alert_tables')) { update_alert_tables($silent); }
// Update alert and group tables
run_action_queue('tables_update');
} else {
$silent = isset($options['q']);
if (function_exists('update_group_tables')) {
update_group_tables($silent);
} // Not exist in CE
if (function_exists('update_alert_tables')) {
update_alert_tables($silent);
}
}
}
}
exit;
exit;
}
// For not new devices discovery, skip down devices
if ($options['h'] !== 'new') {
$where .= ' AND `status` = ?';
$params[] = 1;
$where .= ' AND `status` = ?';
$params[] = 1;
}
$discovered_devices = 0;
print_cli_heading("%WStarting discovery run at " . date("Y-m-d H:i:s"), 0);
$where .= ' AND `poller_id` = ?';
$where .= ' AND `poller_id` = ?';
$params[] = $config['poller_id'];
foreach (dbFetchRows("SELECT * FROM `devices` WHERE `disabled` = 0 $where ORDER BY `last_discovered_timetaken` ASC", $params) as $device) {
// Additional check if device SNMPable, because during
// discovery many devices (long time), the some device can be switched off
if ($options['h'] === 'new' || isSNMPable($device)) {
discover_device($device, $options);
} else {
$string = "Device '" . $device['hostname'] . "' skipped, because switched off during runtime discovery process.";
print_debug($string);
logfile($argv[0] . ": $string");
}
// Additional check if device SNMPable, because during
// discovery many devices (long time), the some device can be switched off
if ($options['h'] === 'new' || is_snmpable($device)) {
discover_device($device, $options);
} else {
$string = "Device '" . $device['hostname'] . "' skipped, because switched off during runtime discovery process.";
print_debug($string);
logfile($argv[0] . ": $string");
}
}
print_cli_heading("%WFinished discovery run at " . date("Y-m-d H:i:s"), 0);
$end = utime();
$run = $end - $start;
$end = utime();
$run = $end - $start;
$discovery_time = substr($run, 0, 5);
// Update Group/Alert tables
if (($discovered_devices && !isset($options['m'])) || isset($options['a'])) {
$silent = isset($options['q']);
if (OBS_DISTRIBUTED && !isset($options['a']) && function_exists('add_action_queue') &&
$action_id = add_action_queue('tables_update', 'discovery', [ 'silent' => $silent ])) {
print_message("Update alert and group tables added to queue [$action_id].");
//log_event("Device with hostname '$hostname' added to queue [$action_id] for addition on remote Poller [{$vars['poller_id']}].", NULL, 'info', NULL, 7);
} else {
if (function_exists('update_group_tables')) { update_group_tables($silent); } // Not exist in CE
if (function_exists('update_alert_tables')) { update_alert_tables($silent); }
}
$silent = isset($options['q']);
if (OBS_DISTRIBUTED && !isset($options['a']) && function_exists('add_action_queue') &&
$action_id = add_action_queue('tables_update', 'discovery', ['silent' => $silent])) {
print_message("Update alert and group tables added to queue [$action_id].");
//log_event("Device with hostname '$hostname' added to queue [$action_id] for addition on remote Poller [{$vars['poller_id']}].", NULL, 'info', NULL, 7);
} else {
if (function_exists('update_group_tables')) {
update_group_tables($silent);
} // Not exist in CE
if (function_exists('update_alert_tables')) {
update_alert_tables($silent);
}
}
}
if ($discovered_devices) {
// Single device ID convert to hostname for log
if (is_numeric($doing)) {
$doing = $device['hostname'];
// Single device ID convert to hostname for log
if (is_numeric($doing)) {
$doing = $device['hostname'];
// This discovery passed from wrapper and with process id
if ($config['poller_id'] > 0 &&
$poller = dbFetchRow('SELECT * FROM `pollers` WHERE `poller_id` = ?', [ $config['poller_id'] ])) {
print_debug_vars($poller, 1);
$host_id = get_local_id();
$update = [];
if ($poller['host_id'] != $host_id) {
$update['host_id'] = $host_id;
log_event("Poller ".$config['poller_id']." host ID changed: '".$poller['host_id']."' -> '".$host_id."'");
}
if ($poller['host_uname'] != php_uname()) {
$update['host_uname'] = php_uname();
log_event("Poller ".$config['poller_id']." host uname changed: '".$poller['host_uname']."' -> '".$update['host_uname']."'");
}
if (count($update)) {
dbUpdate($update, 'pollers', '`poller_id` = ?', [ $config['poller_id'] ]);
}
// This discovery passed from wrapper and with process id
if ($config['poller_id'] > 0 &&
$poller = dbFetchRow('SELECT * FROM `pollers` WHERE `poller_id` = ?', [$config['poller_id']])) {
print_debug_vars($poller, 1);
$host_id = get_local_id();
$update = [];
if ($poller['host_id'] != $host_id) {
$update['host_id'] = $host_id;
log_event("Poller " . $config['poller_id'] . " host ID changed: '" . $poller['host_id'] . "' -> '" . $host_id . "'");
}
if ($poller['host_uname'] != php_uname()) {
$update['host_uname'] = php_uname();
log_event("Poller " . $config['poller_id'] . " host uname changed: '" . $poller['host_uname'] . "' -> '" . $update['host_uname'] . "'");
}
if (count($update)) {
dbUpdate($update, 'pollers', '`poller_id` = ?', [$config['poller_id']]);
}
}
}
}
} elseif (!isset($options['q']) && !$options['u']) {
print_warning("WARNING: 0 devices discovered." . ($options['h'] !== 'new' ? " Did you specify a device that does not exist?" : ''));
print_warning("WARNING: 0 devices discovered." . ($options['h'] !== 'new' ? " Did you specify a device that does not exist?" : ''));
}
$string = $argv[0] . ": $doing - $discovered_devices devices discovered in $discovery_time secs";
@ -264,42 +278,43 @@ logfile($string);
// Clean stale observium processes
$process_sql = "SELECT * FROM `observium_processes` WHERE `poller_id` = ? AND `process_start` < ?";
foreach (dbFetchRows($process_sql, [ $config['poller_id'], $config['time']['fourhour'] ]) as $process) {
// We found processes in DB, check if it exist on system
print_debug_vars($process);
$pid_info = get_pid_info($process['process_pid']);
if (is_array($pid_info) && str_contains($pid_info['COMMAND'], $process['process_name'])) {
// Process still running
} else {
// Remove stalled DB entries
dbDelete('observium_processes', '`process_id` = ?', array($process['process_id']));
print_debug("Removed stale process entry from DB (cmd: '" . $process['process_command'] . "', PID: '" . $process['process_pid'] . "')");
}
foreach (dbFetchRows($process_sql, [$config['poller_id'], $config['time']['fourhour']]) as $process) {
// We found processes in DB, check if it exist on system
print_debug_vars($process);
$pid_info = get_pid_info($process['process_pid']);
if (is_array($pid_info) && str_contains($pid_info['COMMAND'], $process['process_name'])) {
// Process still running
} else {
// Remove stalled DB entries
dbDelete('observium_processes', '`process_id` = ?', [$process['process_id']]);
print_debug("Removed stale process entry from DB (cmd: '" . $process['process_command'] . "', PID: '" . $process['process_pid'] . "')");
}
}
if (!isset($options['q'])) {
if ($config['snmp']['hide_auth']) {
print_debug("NOTE, \$config['snmp']['hide_auth'] is set to TRUE, snmp community and snmp v3 auth hidden from debug output.");
}
if ($config['snmp']['hide_auth']) {
print_debug("NOTE, \$config['snmp']['hide_auth'] is set to TRUE, snmp community and snmp v3 auth hidden from debug output.");
}
print_cli_data('Devices Discovered', $discovered_devices, 0);
print_cli_data('Discovery Time', $discovery_time . " secs", 0);
print_cli_data('Memory usage', formatStorage(memory_get_usage(TRUE), 2, 4) .
' (peak: ' . formatStorage(memory_get_peak_usage(TRUE), 2, 4) . ')', 0);
print_cli_data('MySQL Usage', 'Cell[' . ($db_stats['fetchcell'] + 0) . '/' . round($db_stats['fetchcell_sec'] + 0, 3) . 's]' .
' Row[' . ($db_stats['fetchrow'] + 0) . '/' . round($db_stats['fetchrow_sec'] + 0, 3) . 's]' .
' Rows[' . ($db_stats['fetchrows'] + 0) . '/' . round($db_stats['fetchrows_sec'] + 0, 3) . 's]' .
' Column[' . ($db_stats['fetchcol'] + 0) . '/' . round($db_stats['fetchcol_sec'] + 0, 3) . 's]' .
' Update[' . ($db_stats['update'] + 0) . '/' . round($db_stats['update_sec'] + 0, 3) . 's]' .
' Insert[' . ($db_stats['insert'] + 0) . '/' . round($db_stats['insert_sec'] + 0, 3) . 's]' .
' Delete[' . ($db_stats['delete'] + 0) . '/' . round($db_stats['delete_sec'] + 0, 3) . 's]', 0);
print_cli_data('Devices Discovered', $discovered_devices, 0);
print_cli_data('Discovery Time', $discovery_time . " secs", 0);
print_cli_data('Definitions', $defs_time . " secs", 0);
print_cli_data('Memory usage', format_bytes(memory_get_usage(TRUE), 2, 4) .
' (peak: ' . format_bytes(memory_get_peak_usage(TRUE), 2, 4) . ')', 0);
print_cli_data('MySQL Usage', 'Cell[' . ($db_stats['fetchcell'] + 0) . '/' . round($db_stats['fetchcell_sec'] + 0, 3) . 's]' .
' Row[' . ($db_stats['fetchrow'] + 0) . '/' . round($db_stats['fetchrow_sec'] + 0, 3) . 's]' .
' Rows[' . ($db_stats['fetchrows'] + 0) . '/' . round($db_stats['fetchrows_sec'] + 0, 3) . 's]' .
' Column[' . ($db_stats['fetchcol'] + 0) . '/' . round($db_stats['fetchcol_sec'] + 0, 3) . 's]' .
' Update[' . ($db_stats['update'] + 0) . '/' . round($db_stats['update_sec'] + 0, 3) . 's]' .
' Insert[' . ($db_stats['insert'] + 0) . '/' . round($db_stats['insert_sec'] + 0, 3) . 's]' .
' Delete[' . ($db_stats['delete'] + 0) . '/' . round($db_stats['delete_sec'] + 0, 3) . 's]', 0);
$rrd_times = [];
foreach ($GLOBALS['rrdtool'] as $cmd => $data) {
$rrd_times[] = $cmd . "[" . $data['count'] . "/" . round($data['time'], 3) . "s]";
}
$rrd_times = [];
foreach ($GLOBALS['rrdtool'] as $cmd => $data) {
$rrd_times[] = $cmd . "[" . $data['count'] . "/" . round($data['time'], 3) . "s]";
}
print_cli_data('RRDTool Usage', implode(" ", $rrd_times), 0);
print_cli_data('RRDTool Usage', implode(" ", $rrd_times), 0);
}
// EOF

View File

@ -5,9 +5,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
@ -15,61 +15,83 @@ chdir(dirname($argv[0]));
$options = getopt("A:VyaselurpdbiT");
include("includes/sql-config.inc.php");
include("includes/observium.inc.php");
$cli = is_cli();
if (isset($options['V'])) {
print_message(OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION);
if (is_array($options['V'])) { print_versions(); }
exit;
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
if (is_array($options['V'])) {
print_versions();
}
exit;
}
/* Prevent run housekeeping on remote pollers (that not needed)
// Prevent running housekeeping on remote pollers (not needed, won't work properly, potential data loss vector)
if ($config['poller_id'] !== 0) {
print_message("%yHouseKeeping only needs to be run on the main node.%n\n", 'color');
exit;
print_message("%yHousekeeping only needs to be run on the main node. Do not run housekeeping on partitioned pollers.%n\n", 'color');
exit;
}
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WHouseKeeping%n\n", 'color');
if (OBS_DEBUG) {
print_versions();
}
*/
print_message("%g".OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION."\n%WHouseKeeping%n\n", 'color');
if (OBS_DEBUG) { print_versions(); }
// For interactive prompt/answer checks
// if it is started from crontab - prompt disabled and answer always 'yes'
if (is_cron()) {
$prompt = FALSE;
$prompt = FALSE;
} else {
$prompt = !isset($options['y']);
$prompt = !isset($options['y']);
}
$answer = TRUE;
$modules = array();
$modules = [];
if (isset($options['a']) || isset($options['s'])) { $modules[] = 'syslog'; }
if (isset($options['a']) || isset($options['e'])) { $modules[] = 'eventlog'; }
if (isset($options['a']) || isset($options['l'])) { $modules[] = 'alertlog'; }
if (isset($options['a']) || isset($options['u'])) { $modules[] = 'authlog'; }
if (isset($options['a']) || isset($options['p'])) { $modules[] = 'ports'; }
if (isset($options['a']) || isset($options['b'])) { $modules[] = 'staledb'; }
if (isset($options['a']) || isset($options['i'])) { $modules[] = 'inventory'; }
if (isset($options['a']) || isset($options['r'])) { $modules[] = 'rrd'; }
if (isset($options['a']) || isset($options['s'])) {
$modules[] = 'syslog';
}
if (isset($options['a']) || isset($options['e'])) {
$modules[] = 'eventlog';
}
if (isset($options['a']) || isset($options['l'])) {
$modules[] = 'alertlog';
}
if (isset($options['a']) || isset($options['u'])) {
$modules[] = 'authlog';
}
if (isset($options['a']) || isset($options['p'])) {
$modules[] = 'ports';
}
if (isset($options['a']) || isset($options['b'])) {
$modules[] = 'staledb';
}
if (isset($options['a']) || isset($options['i'])) {
$modules[] = 'inventory';
}
if (isset($options['a']) || isset($options['r'])) {
$modules[] = 'rrd';
}
// Get age from command line
if (isset($options['A'])) {
$age = age_to_seconds($options['A']);
if ($age) {
foreach ($modules as $module) {
if ($module === 'ports') { $module = 'deleted_ports'; }
$config['housekeeping'][$module]['age'] = $age;
$age = age_to_seconds($options['A']);
if ($age) {
foreach ($modules as $module) {
if ($module === 'ports') {
$module = 'deleted_ports';
}
$config['housekeeping'][$module]['age'] = $age;
}
} else {
print_debug("Invalid age specified '" . $options['A'] . "', skipped.");
}
} else {
print_debug("Invalid age specified '" . $options['A'] . "', skipped.");
}
unset($age, $module);
unset($age, $module);
}
if (!count($modules)) {
print_message("%n
print_message("%n
USAGE:
$scriptname [-Vyaselrptdbu] [-A <age>]
@ -102,18 +124,22 @@ EXAMPLES:
$scriptname -ya Clean up by all modules without prompts
%rInvalid arguments!%n", 'color', FALSE);
exit;
exit;
}
$test = isset($options['T']);
foreach ($modules as $module) {
if (is_file($config['install_dir'] . "/includes/housekeeping/$module.inc.php")) {
include($config['install_dir'] . "/includes/housekeeping/$module.inc.php");
if (!$test) { set_obs_attrib("housekeeping_lastrun_$module", time()); }
} else {
print_warning("Housekeeping module not found: $module");
}
if (is_file($config['install_dir'] . "/includes/housekeeping/$module.inc.php")) {
include($config['install_dir'] . "/includes/housekeeping/$module.inc.php");
if (!$test) {
set_obs_attrib("housekeeping_lastrun_$module", time());
}
} else {
print_warning("Housekeeping module not found: $module");
}
}
if (!$test) {
set_obs_attrib("housekeeping_lastrun", time());
}
if (!$test) { set_obs_attrib("housekeeping_lastrun", time()); }
// EOF

View File

@ -3,9 +3,10 @@
Options FollowSymlinks Multiviews
ErrorDocument 404 /error.php?404
RedirectMatch 404 /\.
RewriteEngine on
RewriteEngine On
RewriteBase /
#Block access to hidden files/dirs
RewriteRule ^\..*$ - [F,L]

View File

@ -6,286 +6,249 @@
*
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
$config['install_dir'] = "../..";
include_once("../../includes/observium.inc.php");
include_once("../../includes/sql-config.inc.php");
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
if (!$_SESSION['authenticated'])
{
print_json_status('failed', 'Unauthorized.');
exit();
if (!$_SESSION['authenticated']) {
print_json_status('failed', 'Unauthorized.');
exit();
}
$vars = get_vars([ 'JSON', 'POST' ]); // Got a JSON payload. Replace $var.
$readonly = $_SESSION['userlevel'] < 7;
$readonly = $_SESSION['userlevel'] < 7;
$limitwrite = $_SESSION['userlevel'] >= 9;
$readwrite = $_SESSION['userlevel'] >= 10;
switch ($vars['action']) {
case "theme":
$pref = 'web_theme_default';
if ($vars['value'] === 'reset') {
session_unset_var("theme");
if ($config['web_theme_default'] === 'system') {
// Override default
session_unset_var("theme_default");
}
case "theme":
$pref = 'web_theme_default';
if ($vars['value'] === 'reset') {
session_unset_var("theme");
if ($config['web_theme_default'] === 'system') {
// Override default
session_unset_var("theme_default");
}
if (del_user_pref($_SESSION['user_id'], $pref)) {
print_json_status('ok', 'Theme reset.');
}
} elseif (isset($config['themes'][$vars['value']]) || $vars['value'] === 'system') {
if (set_user_pref($_SESSION['user_id'], $pref, serialize($vars['value']))) {
print_json_status('ok', 'Theme set.');
}
} else {
print_json_status('failed', 'Invalid theme.');
}
break;
if (del_user_pref($_SESSION['user_id'], $pref)) {
print_json_status('ok', 'Theme reset.');
}
} elseif (isset($config['themes'][$vars['value']]) || $vars['value'] === 'system') {
if (set_user_pref($_SESSION['user_id'], $pref, serialize($vars['value']))) {
print_json_status('ok', 'Theme set.');
}
} else {
print_json_status('failed', 'Invalid theme.');
}
break;
case "big_graphs":
$pref = 'graphs|size';
if (set_user_pref($_SESSION['user_id'], $pref, serialize('big'))) {
print_json_status('ok', 'Big graphs set.');
session_unset_var("big_graphs"); // clear old
}
//session_set_var("big_graphs", TRUE);
//print_json_status('ok', 'Big graphs set.');
break;
case "big_graphs":
$pref = 'graphs|size';
if (set_user_pref($_SESSION['user_id'], $pref, serialize('big'))) {
print_json_status('ok', 'Big graphs set.');
session_unset_var("big_graphs"); // clear old
}
break;
case "normal_graphs":
$pref = 'graphs|size';
if (set_user_pref($_SESSION['user_id'], $pref, serialize('normal'))) {
print_json_status('ok', 'Normal graphs set.');
session_unset_var("big_graphs"); // clear old
}
//session_unset_var("big_graphs");
//print_json_status('ok', 'Small graphs set.');
break;
case "normal_graphs":
$pref = 'graphs|size';
if (set_user_pref($_SESSION['user_id'], $pref, serialize('normal'))) {
print_json_status('ok', 'Normal graphs set.');
session_unset_var("big_graphs"); // clear old
}
break;
case "touch_on":
session_set_var("touch", TRUE);
print_json_status('ok', 'Touch mode enabled.');
break;
case "touch_on":
session_set_var("touch", TRUE);
print_json_status('ok', 'Touch mode enabled.');
break;
case "touch_off":
session_unset_var("touch");
print_json_status('ok', 'Touch mode disabled.');
break;
case "touch_off":
session_unset_var("touch");
print_json_status('ok', 'Touch mode disabled.');
break;
case "set_refresh":
session_set_var("dark_mode", TRUE);
print_json_status('ok', 'Dark mode set.');
break;
case "save_grid": // Save current layout of dashboard grid
case "alert_assoc_edit":
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
// Currently edit allowed only for Admins
if (!$readwrite) {
print_json_status('failed', 'Action not allowed.');
exit();
}
foreach ($vars['grid'] as $w) {
dbUpdate(['x' => $w['x'], 'y' => $w['y'], 'width' => $w['width'], 'height' => $w['height'],], 'dash_widgets',
'`widget_id` = ?', [$w['id']]
);
}
break;
if (dbFetchRow("SELECT * FROM `alert_tests` WHERE `alert_test_id` = ?", array($vars['alert_test_id']))) {
case "add_widget": // Add widget of 'widget_type' to dashboard 'dash_id'
$rows_updated = dbUpdate([ 'alert_assoc' => $vars['alert_assoc'] ], 'alert_tests', '`alert_test_id` = ?', [ $vars['alert_test_id'] ]);
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
if ($rows_updated) {
update_alert_table($vars['alert_test_id']);
print_json_status('ok', '', [ 'id' => $vars['alert_test_id'],
'redirect' => generate_url([ 'page' => 'alert_check', 'alert_test_id' => $vars['alert_test_id'] ]) ]);
} else {
print_json_status('failed', 'Database was not updated.');
}
} else {
print_json_status('failed', 'Alert Checker does not exist: [' . $vars['alert_test_id'] . ']');
}
break;
if (isset($vars['dash_id']) && isset($vars['widget_type'])) {
$widget_id = dbInsert(['dash_id' => $vars['dash_id'], 'widget_config' => json_encode([]), 'widget_type' => $vars['widget_type']],
'dash_widgets'
);
}
case "save_grid": // Save current layout of dashboard grid
if ($widget_id) {
print_json_status('ok', '', ['id' => $widget_id]);
} else {
//print_r($vars); // For debugging
}
break;
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
case "delete_ap":
foreach ($vars['grid'] as $w) {
dbUpdate(array('x' => $w['x'], 'y' => $w['y'], 'width' => $w['width'], 'height' => $w['height'],), 'dash_widgets',
'`widget_id` = ?', array($w['id'])
);
}
break;
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
case "add_widget": // Add widget of 'widget_type' to dashboard 'dash_id'
if (is_numeric($vars['id'])) {
$rows_deleted = dbDelete('wifi_aps', '`wifi_ap_id` = ?', [$vars['id']]);
}
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
if ($rows_deleted) {
print_json_status('ok', 'AP Deleted', ['id' => $vars['id']]);
}
if (isset($vars['dash_id']) && isset($vars['widget_type'])) {
$widget_id = dbInsert(array('dash_id' => $vars['dash_id'], 'widget_config' => json_encode(array()), 'widget_type' => $vars['widget_type']),
'dash_widgets'
);
}
break;
if ($widget_id) {
print_json_status('ok', '', [ 'id' => $widget_id ]);
} else {
//print_r($vars); // For debugging
}
break;
case "del_widget":
case "delete_ap":
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
if (is_numeric($vars['widget_id'])) {
$rows_deleted = dbDelete('dash_widgets', '`widget_id` = ?', [$vars['widget_id']]);
}
if (is_numeric($vars['id'])) {
$rows_deleted = dbDelete('wifi_aps', '`wifi_ap_id` = ?', array($vars['id']));
}
if ($rows_deleted) {
print_json_status('ok', 'Widget Deleted.', ['id' => $vars['widget_id']]);
}
break;
if ($rows_deleted) {
print_json_status('ok', 'AP Deleted', [ 'id' => $vars['id'] ]);
}
case "dash_rename":
break;
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
case "del_widget":
if (is_numeric($vars['dash_id'])) {
$rows_updated = dbUpdate(['dash_name' => $vars['dash_name']], 'dashboards', '`dash_id` = ?', [$vars['dash_id']]);
} else {
print_json_status('failed', 'Invalid Dashboard ID.');
}
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
if ($rows_updated) {
print_json_status('ok', 'Dashboard Name Updated.', ['id' => $vars['dash_id']]);
} else {
print_json_status('failed', 'Update Failed.');
}
if (is_numeric($vars['widget_id'])) {
$rows_deleted = dbDelete('dash_widgets', '`widget_id` = ?', array($vars['widget_id']));
}
break;
if ($rows_deleted) {
print_json_status('ok', 'Widget Deleted.', [ 'id' => $vars['widget_id'] ]);
}
break;
case "dash_delete":
case "dash_rename":
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
if (is_numeric($vars['dash_id'])) {
$rows_deleted = dbDelete('dash_widgets', '`dash_id` = ?', [$vars['dash_id']]);
$rows_deleted += dbDelete('dashboards', '`dash_id` = ?', [$vars['dash_id']]);
} else {
print_json_status('failed', 'Invalid Dashboard ID.');
}
if (is_numeric($vars['dash_id'])) {
$rows_updated = dbUpdate(array('dash_name' => $vars['dash_name']), 'dashboards', '`dash_id` = ?', array($vars['dash_id']));
} else {
print_json_status('failed', 'Invalid Dashboard ID.');
}
if ($rows_deleted) {
print_json_status('ok', 'Dashboard Deleted.', ['id' => $vars['dash_id']]);
} else {
print_json_status('failed', 'Deletion Failed.');
}
if ($rows_updated) {
print_json_status('ok', 'Dashboard Name Updated.', [ 'id' => $vars['dash_id'] ]);
} else {
print_json_status('failed', 'Update Failed.');
}
break;
break;
case "update_widget_config":
case "dash_delete":
//print_r($vars);
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
if (is_numeric($vars['dash_id'])) {
$rows_deleted = dbDelete('dash_widgets', '`dash_id` = ?', array($vars['dash_id']));
$rows_deleted += dbDelete('dashboards', '`dash_id` = ?', array($vars['dash_id']));
} else {
print_json_status('failed', 'Invalid Dashboard ID.');
}
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE `widget_id` = ?", [$vars['widget_id']]);
$widget['widget_config'] = safe_json_decode($widget['widget_config']);
if ($rows_deleted) {
print_json_status('ok', 'Dashboard Deleted.', [ 'id' => $vars['dash_id'] ]);
} else {
print_json_status('failed', 'Deletion Failed.');
}
// Verify config value applies to this widget here
break;
$default_on = ['legend'];
case "update_widget_config":
if (isset($vars['config_field']) && isset($vars['config_value'])) {
if (empty($vars['config_value']) ||
(in_array($vars['config_field'], $default_on) && get_var_true($vars['config_value'])) ||
(!in_array($vars['config_field'], $default_on) && get_var_false($vars['config_value']))) {
// Just unset the value if it's empty or it's a default value.
unset($widget['widget_config'][$vars['config_field']]);
} else {
$widget['widget_config'][$vars['config_field']] = $vars['config_value'];
}
//print_r($vars);
dbUpdate(['widget_config' => json_encode($widget['widget_config'])], 'dash_widgets',
'`widget_id` = ?', [$widget['widget_id']]
);
// Currently edit allowed only for Admins
if ($readonly) {
print_json_status('failed', 'Action not allowed.');
exit();
}
//echo dbError();
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE `widget_id` = ?", array($vars['widget_id']));
$widget['widget_config'] = safe_json_decode($widget['widget_config']);
print_json_status('ok', 'Widget Updated.', ['id' => $widget['widget_id']]);
} else {
print_json_status('failed', 'Update Failed.');
}
// Verify config value applies to this widget here
break;
$default_on = [ 'legend' ];
default:
if (isset($vars['config_field']) && isset($vars['config_value'])) {
if ( empty($vars['config_value']) ||
(in_array($vars['config_field'], $default_on) && get_var_true($vars['config_value'])) ||
(!in_array($vars['config_field'], $default_on) && get_var_false($vars['config_value'])) ) {
// Just unset the value if it's empty or it's a default value.
unset($widget['widget_config'][$vars['config_field']]);
} else {
$widget['widget_config'][$vars['config_field']] = $vars['config_value'];
}
// Validate CSRF Token
//r($vars);
$json = '';
if (!str_contains_array($vars['action'], ['widget', 'dash', 'settings_user']) && // widget & dashboard currently not send request token
!request_token_valid($vars, $json)) {
$json = safe_json_decode($json);
$json['reload'] = TRUE;
print_json_status('failed', 'CSRF Token missing. Reload page.', $json);
exit();
}
unset($json);
dbUpdate(array('widget_config' => json_encode($widget['widget_config'])), 'dash_widgets',
'`widget_id` = ?', array($widget['widget_id'])
);
//echo dbError();
print_json_status('ok', 'Widget Updated.', [ 'id' => $widget['widget_id'] ]);
} else {
print_json_status('failed', 'Update Failed.');
}
break;
default:
// Validate CSRF Token
//r($vars);
$json = '';
if (!str_contains_array($vars['action'], [ 'widget', 'dash', 'settings_user' ]) && // widget & dashboard currently not send request token
!request_token_valid($vars, $json)) {
$json = safe_json_decode($json);
$json['reload'] = TRUE;
print_json_status('failed', 'CSRF Token missing. Reload page.', $json);
exit();
}
unset($json);
$action_path = __DIR__ . '/actions/'. $vars['action'] . '.inc.php';
if (is_alpha($vars['action']) && is_file($action_path))
{
include $action_path;
} else {
print_json_status('failed', 'Unknown action requested.');
}
$action_path = __DIR__ . '/actions/' . $vars['action'] . '.inc.php';
if (is_alpha($vars['action']) && is_file($action_path)) {
include $action_path;
} else {
print_json_status('failed', 'Unknown action requested.');
}
}
// EOF

View File

@ -0,0 +1,38 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
// Currently edit allowed only for Admins
if (!$limitwrite) {
print_json_status('failed', 'Action not allowed.');
exit();
}
if ($alert_test = dbFetchRow("SELECT * FROM `alert_tests` WHERE `alert_test_id` = ?", [ $vars['alert_test_id'] ])) {
if ($alert_test['alert_assoc'] !== $vars['alert_assoc']) {
if (dbUpdate([ 'alert_assoc' => $vars['alert_assoc'] ], 'alert_tests', '`alert_test_id` = ?', [ $vars['alert_test_id'] ])) {
update_alert_table($vars['alert_test_id']);
print_json_status('ok', 'Associations updated.',
[ 'id' => $vars['alert_test_id'],
'redirect' => generate_url([ 'page' => 'alert_check', 'alert_test_id' => $vars['alert_test_id'] ]) ]);
} else {
print_json_status('failed', 'Database was not updated.');
}
} else {
print_json_status('warning', 'Associations not changed.');
}
} else {
print_json_status('failed', 'Alert Checker does not exist: [' . $vars['alert_test_id'] . ']');
}
// EOF

View File

@ -6,63 +6,63 @@
*
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
// Currently allowed only for Admins
if (!$readwrite) {
print_json_status('failed', 'Action not allowed.');
return;
// Currently allowed only for Admins and Limit Write
if (!$limitwrite) {
print_json_status('failed', 'Action not allowed.');
return;
}
$ok = TRUE;
foreach (array('entity_type', 'alert_name', 'alert_severity', 'alert_conditions') as $var) {
if (!isset($vars[$var]) || strlen($vars[$var]) == '0') {
$ok = FALSE;
$failed[] = $var;
}
foreach (['entity_type', 'alert_name', 'alert_severity', 'alert_conditions'] as $var) {
if (!isset($vars[$var]) || strlen($vars[$var]) == '0') {
$ok = FALSE;
$failed[] = $var;
}
}
if ($ok) {
if (dbExist('alert_tests', '`entity_type` = ? AND `alert_name` = ?', [ $vars['entity_type'], $vars['alert_name'] ])) {
print_json_status('failed', "Alert Checker '{$vars['alert_name']}' already exist.");
return;
}
if (dbExist('alert_tests', '`entity_type` = ? AND `alert_name` = ?', [$vars['entity_type'], $vars['alert_name']])) {
print_json_status('failed', "Alert Checker '{$vars['alert_name']}' already exist.");
return;
}
$check_array = array();
$check_array = [];
$conditions = array();
foreach (explode("\n", trim($vars['alert_conditions'])) as $cond) {
$condition = array();
list($condition['metric'], $condition['condition'], $condition['value']) = explode(" ", trim($cond), 3);
$conditions[] = $condition;
}
$check_array['conditions'] = safe_json_encode($conditions);
$check_array['alert_assoc'] = $vars['alert_assoc'];
$check_array['entity_type'] = $vars['entity_type'];
$check_array['alert_name'] = $vars['alert_name'];
$check_array['alert_message'] = $vars['alert_message'];
$check_array['severity'] = $vars['alert_severity'];
$check_array['suppress_recovery'] = get_var_true($vars['alert_send_recovery']) ? 0 : 1;
$check_array['alerter'] = NULL;
$check_array['and'] = $vars['alert_and'];
$check_array['delay'] = $vars['alert_delay'];
$check_array['enable'] = '1';
$conditions = [];
foreach (explode("\n", trim($vars['alert_conditions'])) as $cond) {
$condition = [];
[$condition['metric'], $condition['condition'], $condition['value']] = explode(" ", trim($cond), 3);
$conditions[] = $condition;
}
$check_array['conditions'] = safe_json_encode($conditions);
$check_array['alert_assoc'] = $vars['alert_assoc'];
$check_array['entity_type'] = $vars['entity_type'];
$check_array['alert_name'] = $vars['alert_name'];
$check_array['alert_message'] = $vars['alert_message'];
$check_array['severity'] = $vars['alert_severity'];
$check_array['suppress_recovery'] = get_var_true($vars['alert_send_recovery']) ? 0 : 1;
$check_array['alerter'] = NULL;
$check_array['and'] = $vars['alert_and'];
$check_array['delay'] = $vars['alert_delay'];
$check_array['enable'] = '1';
$check_id = dbInsert('alert_tests', $check_array);
$check_id = dbInsert('alert_tests', $check_array);
if (is_numeric($check_id)) {
update_alert_table($check_id);
if (is_numeric($check_id)) {
update_alert_table($check_id);
print_json_status('ok', '', [ 'id' => $check_id, 'redirect' => generate_url([ 'page' => 'alert_check', 'alert_test_id' => $check_id ]) ]);
} else {
print_json_status('ok', '', ['id' => $check_id, 'redirect' => generate_url(['page' => 'alert_check', 'alert_test_id' => $check_id])]);
} else {
print_json_status('failed', 'Alert creation failed. Please note that the alert name <b>must</b> be unique.');
}
print_json_status('failed', 'Alert creation failed. Please note that the alert name <b>must</b> be unique.');
}
} else {
print_json_status('failed', 'Missing required data. (' . implode(", ", $failed) . ')');
print_json_status('failed', 'Missing required data. (' . implode(", ", $failed) . ')');
}
// EOF

View File

@ -6,21 +6,23 @@
*
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
if ($readonly) { return; } // Currently edit allowed only for 7+
if ($readonly) {
return;
} // Currently edit allowed only for 7+
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE `widget_id` = ?", [ $vars['widget_id'] ]);
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE `widget_id` = ?", [$vars['widget_id']]);
$widget['widget_config'] = safe_json_decode($widget['widget_config']);
switch ($widget['widget_type']) {
case "graph":
case "graph":
if (safe_count($widget['widget_config'])) {
if (safe_count($widget['widget_config'])) {
// echo '
// <form onsubmit="return false">
@ -28,121 +30,120 @@ switch ($widget['widget_type']) {
// </form>
// ';
//r($widget['widget_config']);
//r($widget['widget_config']);
//r(isset($widget['widget_config']['legend']) && $widget['widget_config']['legend'] === 'no');
//r(isset($widget['widget_config']['legend']) && $widget['widget_config']['legend'] === 'no');
$modal_args = [
'id' => 'modal-edit_widget_' . $widget['widget_id'],
'title' => 'Configure Widget',
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
//'class' => 'modal-md',
];
$modal_args = [
'id' => 'modal-edit_widget_' . $widget['widget_id'],
'title' => 'Configure Widget',
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
//'class' => 'modal-md',
];
$form = [
'form_only' => TRUE, // Do not add modal open/close divs (it's generated outside)
'type' => 'horizontal',
'id' => 'edit_widget_' . $widget['widget_id'],
'userlevel' => 7, // Minimum user level for display form
'modal_args' => $modal_args, // !!! This generate modal specific form
//'help' => 'This will completely delete the rule and all associations and history.',
'class' => '', // Clean default box class!
//'url' => generate_url([ 'page' => 'syslog_rules' ]),
'onsubmit' => "return false",
];
$form['fieldset']['body'] = [ 'class' => 'modal-body' ]; // Required this class for modal body!
$form['fieldset']['footer'] = [ 'class' => 'modal-footer' ]; // Required this class for modal footer!
$form = [
'form_only' => TRUE, // Do not add modal open/close divs (it's generated outside)
'type' => 'horizontal',
'id' => 'edit_widget_' . $widget['widget_id'],
'userlevel' => 7, // Minimum user level for display form
'modal_args' => $modal_args, // !!! This generate modal specific form
//'help' => 'This will completely delete the rule and all associations and history.',
'class' => '', // Clean default box class!
//'url' => generate_url([ 'page' => 'syslog_rules' ]),
'onsubmit' => "return false",
];
$form['fieldset']['body'] = ['class' => 'modal-body']; // Required this class for modal body!
$form['fieldset']['footer'] = ['class' => 'modal-footer']; // Required this class for modal footer!
$form['row'][1]['widget-config-title'] = [
'type' => 'text',
'fieldset' => 'body',
'name' => 'Title',
'placeholder' => 'Graph Title',
'class' => 'input-xlarge',
'attribs' => [
'data-id' => $widget['widget_id'],
'data-field' => 'title',
'data-type' => 'text'
],
'value' => $widget['widget_config']['title']
];
$form['row'][2]['widget-config-legend'] = [
'type' => 'checkbox',
'fieldset' => 'body',
'name' => 'Show Legend',
//'placeholder' => 'Yes, please delete this rule.',
//'onchange' => "javascript: toggleAttrib('disabled', 'delete_button_".$la['la_id']."'); showDiv(!this.checked, 'warning_".$la['la_id']."_div');",
'attribs' => [
'data-id' => $widget['widget_id'],
'data-field' => 'legend',
'data-type' => 'checkbox'
],
'value' => safe_empty($widget['widget_config']['legend']) ? 'yes' : $widget['widget_config']['legend'] //'legend'
];
$form['row'][1]['widget-config-title'] = [
'type' => 'text',
'fieldset' => 'body',
'name' => 'Title',
'placeholder' => 'Graph Title',
'class' => 'input-xlarge',
'attribs' => [
'data-id' => $widget['widget_id'],
'data-field' => 'title',
'data-type' => 'text'
],
'value' => $widget['widget_config']['title']
];
$form['row'][2]['widget-config-legend'] = [
'type' => 'checkbox',
'fieldset' => 'body',
'name' => 'Show Legend',
//'placeholder' => 'Yes, please delete this rule.',
//'onchange' => "javascript: toggleAttrib('disabled', 'delete_button_".$la['la_id']."'); showDiv(!this.checked, 'warning_".$la['la_id']."_div');",
'attribs' => [
'data-id' => $widget['widget_id'],
'data-field' => 'legend',
'data-type' => 'checkbox'
],
'value' => safe_empty($widget['widget_config']['legend']) ? 'yes' : $widget['widget_config']['legend'] //'legend'
];
$form['row'][8]['close'] = [
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => [
'data-dismiss' => 'modal',
'aria-hidden' => 'true'
]
];
$form['row'][8]['close'] = [
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => [
'data-dismiss' => 'modal',
'aria-hidden' => 'true'
]
];
echo generate_form_modal($form);
unset($form);
echo generate_form_modal($form);
unset($form);
/*
echo '
<form onsubmit="return false" class="form form-horizontal" style="margin-bottom: 0px;">
<fieldset>
<div id="purpose_div" class="control-group" style="margin-bottom: 10px;"> <!-- START row-1 -->
<label class="control-label" for="purpose">Title</label>
<div id="purpose_div" class="controls">
<input type="text" placeholder="Graph Title" name="widget-config-title" class="input" data-field="title" style="width: 100%;" value="'.$widget['widget_config']['title'].'" data-id="'.$widget['widget_id'].'">
</div>
</div>
/*
echo '
<form onsubmit="return false" class="form form-horizontal" style="margin-bottom: 0px;">
<fieldset>
<div id="purpose_div" class="control-group" style="margin-bottom: 10px;"> <!-- START row-1 -->
<label class="control-label" for="purpose">Title</label>
<div id="purpose_div" class="controls">
<input type="text" placeholder="Graph Title" name="widget-config-title" class="input" data-field="title" style="width: 100%;" value="'.$widget['widget_config']['title'].'" data-id="'.$widget['widget_id'].'">
</div>
</div>
<div id="ignore_div" class="control-group" style="margin-bottom: 10px;"> <!-- START row-6 -->
<label class="control-label" for="ignore">Show Legend</label>
<div id="ignore_div" class="controls">
<input type="checkbox" name="widget-config-legend" data-field="legend" data-type="checkbox" value="legend" '.(isset($widget['widget_config']['legend']) && $widget['widget_config']['legend'] === 'no' ? '' : 'checked').' data-id="'.$widget['widget_id'].'">
</div>
</div>
</fieldset> <!-- END fieldset-body -->
<div id="ignore_div" class="control-group" style="margin-bottom: 10px;"> <!-- START row-6 -->
<label class="control-label" for="ignore">Show Legend</label>
<div id="ignore_div" class="controls">
<input type="checkbox" name="widget-config-legend" data-field="legend" data-type="checkbox" value="legend" '.(isset($widget['widget_config']['legend']) && $widget['widget_config']['legend'] === 'no' ? '' : 'checked').' data-id="'.$widget['widget_id'].'">
</div>
</div>
</fieldset> <!-- END fieldset-body -->
<div class="modal-footer">
<fieldset>
<button id="close" name="close" type="submit" class="btn btn-default text-nowrap" value="" data-dismiss="modal" aria-hidden="true">Close</button>
<!-- <button id="action" name="action" type="submit" class="btn btn-primary text-nowrap" value="add_contact"><i style="margin-right: 0px;" class="icon-ok icon-white"></i>&nbsp;&nbsp;Add Contact</button> -->
</fieldset>
</div>
<div class="modal-footer">
<fieldset>
<button id="close" name="close" type="submit" class="btn btn-default text-nowrap" value="" data-dismiss="modal" aria-hidden="true">Close</button>
<!-- <button id="action" name="action" type="submit" class="btn btn-primary text-nowrap" value="add_contact"><i style="margin-right: 0px;" class="icon-ok icon-white"></i>&nbsp;&nbsp;Add Contact</button> -->
</fieldset>
</div>
</form>';
*/
</form>';
*/
} else {
} else {
print_message('To add a graph to this widget, navigate to the required graph and use the "Add To Dashboard" function on the graph page.');
print_message('To add a graph to this widget, navigate to the required graph and use the "Add To Dashboard" function on the graph page.');
echo '<h3>Step 1. Locate Graph and click for Graph Browser.</h3>';
echo '<img class="img img-thumbnail" src="images/doc/add_graph_1">';
echo '<h3>Step 1. Locate Graph and click for Graph Browser.</h3>';
echo '<img class="img img-thumbnail" src="images/doc/add_graph_1">';
echo '<h3>Step 2. Select Add to Dashboard in Graph Browser.</h3>';
echo '<img class="img" src="images/doc/add_graph_2">';
}
break;
default:
print_vars($widget);
echo '<h3>Step 2. Select Add to Dashboard in Graph Browser.</h3>';
echo '<img class="img" src="images/doc/add_graph_2">';
}
break;
default:
r($widget['widget_config']);
}
// EOF

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
@ -15,15 +15,14 @@ $update_ports = [];
//r($vars);
//$ports_attribs = get_device_entities_attribs($device_id, 'port'); // Get all attribs
foreach($vars['port'] as $port_id => $port_data)
{
foreach ($vars['port'] as $port_id => $port_data) {
if (is_entity_write_permitted('port', $port_id)) {
$port = get_port_by_id_cache($port_id);
$port = get_port_by_id_cache($port_id);
$device = device_by_id_cache($port['device_id']);
$updated = FALSE;
$update_array = array();
$updated = FALSE;
$update_array = [];
$port_attribs = get_entity_attribs('port', $port['port_id']);
@ -32,7 +31,7 @@ foreach($vars['port'] as $port_id => $port_data)
}
// Check ignored and disabled port
foreach (array('ignore', 'disabled') as $param) {
foreach (['ignore', 'disabled'] as $param) {
$old_param = $port[$param] ? 1 : 0;
$new_param = (isset($port_data[$param]) && $port_data[$param]) ? 1 : 0;
if ($old_param != $new_param) {
@ -41,7 +40,7 @@ foreach($vars['port'] as $port_id => $port_data)
}
if (count($update_array)) {
dbUpdate($update_array, 'ports', '`port_id` = ?', array($port_id));
dbUpdate($update_array, 'ports', '`port_id` = ?', [$port_id]);
$updated = TRUE;
}
@ -50,7 +49,7 @@ foreach($vars['port'] as $port_id => $port_data)
$old_ifSpeed_bool = isset($port['ifSpeed_custom']);
$new_ifSpeed_bool = isset($port_data['ifSpeed_custom_bool']) && $port_data['ifSpeed_custom_bool'];
if ($new_ifSpeed_bool) {
$port_data['ifSpeed_custom'] = (int) unit_string_to_numeric($port_data['ifSpeed_custom'], 1000);
$port_data['ifSpeed_custom'] = (int)unit_string_to_numeric($port_data['ifSpeed_custom'], 1000);
if ($port_data['ifSpeed_custom'] <= 0) {
// Wrong ifSpeed, skip
//print_warning("Passed incorrect value for port speed: ".unit_string_to_numeric($port_data['ifSpeed_custom'], 1000));
@ -65,7 +64,7 @@ foreach($vars['port'] as $port_id => $port_data)
//r($vars['ifSpeed_custom_' . $port_id]); r($port['ifSpeed_custom']);
set_entity_attrib('port', $port_id, 'ifSpeed_custom', $port_data['ifSpeed_custom'], $device['device_id']);
$update_array['ifSpeed_custom'] = $port_data['ifSpeed_custom'];
$updated = TRUE;
$updated = TRUE;
}
} elseif ($old_ifSpeed_bool !== $new_ifSpeed_bool) {
// Added or removed
@ -88,9 +87,9 @@ foreach($vars['port'] as $port_id => $port_data)
}
// Query updated sensors array
if ($rows_updated) {
print_json_status('ok', $rows_updated.' port(s) updated.', [ 'update_array' => $update_ports ]);
print_json_status('ok', $rows_updated . ' port(s) updated.', ['update_array' => $update_ports]);
} else {
print_json_status('failed', 'No update performed.');
print_json_status('failed', 'No update performed.');
}
unset($ports_attribs);

View File

@ -0,0 +1,35 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
// Currently, allowed only for Admins
if (!$readwrite) {
print_json_status('failed', 'Insufficient permissions to delete role.');
return;
}
$role_id = (int)$vars['role_id'];
if ($role_id > 0) {
$rows_deleted = dbDelete('roles', '`role_id` = ?', [$role_id]);
//$rows_deleted = 0;
if ($rows_deleted > 0) {
dbDelete('roles_entity_permissions', '`role_id` = ?', [$role_id]);
dbDelete('roles_permissions', '`role_id` = ?', [$role_id]);
dbDelete('roles_users', '`role_id` = ?', [$role_id]);
print_json_status('ok', 'Role deleted successfully.', ['reload' => TRUE]);
} else {
print_json_status('failed', 'Failed to delete role.');
}
} else {
print_json_status('failed', 'Invalid role ID.');
}
// EOF

View File

@ -4,96 +4,96 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
$rows_updated = 0;
$rows_updated = 0;
$update_entities = [];
//r($vars);
foreach ($vars['sensors'] as $sensor_id => $sensor_update) {
$update_array = [];
if (is_entity_write_permitted('sensor', $sensor_id)) {
$update_array = [];
if (is_entity_write_permitted('sensor', $sensor_id)) {
$sensor = get_sensor_by_id($sensor_id);
$sensor = get_sensor_by_id($sensor_id);
$device_id = $sensor['device_id'];
$device_id = $sensor['device_id'];
if (!$sensor['sensor_state']) {
// Normal sensors
$fields_switch = [ 'sensor_ignore', 'sensor_custom_limit' ];
$fields_limit = [ 'sensor_limit', 'sensor_limit_warn', 'sensor_limit_low_warn', 'sensor_limit_low' ];
if (!$sensor['sensor_state']) {
// Normal sensors
$fields_switch = ['sensor_ignore', 'sensor_custom_limit'];
$fields_limit = ['sensor_limit', 'sensor_limit_warn', 'sensor_limit_low_warn', 'sensor_limit_low'];
} else {
// State sensors not allow edit limits
$fields_switch = array('sensor_ignore');
$fields_limit = array();
}
// Switch selectors
foreach ($fields_switch as $field) {
$sensor_update[$field] = get_var_true($sensor_update[$field]) ? '1' : '0';
if ($sensor_update[$field] != $sensor[$field]) {
$update_array[$field] = $sensor_update[$field];
}
}
// Limits
if ($sensor_update['sensor_reset_limit']) {
// Reset limits
if ($sensor['sensor_custom_limit']) {
$update_array['sensor_custom_limit'] = '0';
}
$update_array['sensor_limit_low'] = [ 'NULL' ];
$update_array['sensor_limit_low_warn'] = [ 'NULL' ];
$update_array['sensor_limit_warn'] = [ 'NULL' ];
$update_array['sensor_limit'] = [ 'NULL' ];
} elseif ($sensor_update['sensor_custom_limit']) {
foreach ($fields_limit as $field) {
$sensor_update[$field] = !is_numeric($sensor_update[$field]) ? [ 'NULL' ] : (float)$sensor_update[$field];
$sensor[$field] = !is_numeric($sensor[$field]) ? [ 'NULL' ] : (float)$sensor[$field];
if ($sensor_update[$field] !== $sensor[$field]) {
$update_array[$field] = $sensor_update[$field];
} else {
// State sensors not allow edit limits
$fields_switch = ['sensor_ignore'];
$fields_limit = [];
}
}
}
if (count($update_array)) {
dbUpdate($update_array, 'sensors', '`sensor_id` = ?', array($sensor['sensor_id']));
$msg = 'Sensor updated (custom): ' . $sensor['sensor_class'] . ' ' . $sensor['sensor_type'] . ' ' . $sensor['sensor_id'] . ' ' . escape_html($sensor['sensor_descr']) . ' ';
if ($update_array['sensor_limit_low']) {
$msg .= '[L: ' . $update_array['sensor_limit_low'] . ']';
}
if ($update_array['sensor_limit_low_warn']) {
$msg .= '[Lw: ' . $update_array['sensor_limit_low_warn'] . ']';
}
if ($update_array['sensor_limit_warn']) {
$msg .= '[Hw: ' . $update_array['sensor_limit_warn'] . ']';
}
if ($update_array['sensor_limit']) {
$msg .= '[H: ' . $update_array['sensor_limit'] . ']';
}
log_event($msg, $device_id, 'sensor', $sensor['sensor_id']);
$rows_updated++;
// Switch selectors
foreach ($fields_switch as $field) {
$sensor_update[$field] = get_var_true($sensor_update[$field]) ? '1' : '0';
if ($sensor_update[$field] != $sensor[$field]) {
$update_array[$field] = $sensor_update[$field];
}
}
$update_entities[$sensor_id] = $update_array;
}
// Limits
if ($sensor_update['sensor_reset_limit']) {
// Reset limits
if ($sensor['sensor_custom_limit']) {
$update_array['sensor_custom_limit'] = '0';
}
$update_array['sensor_limit_low'] = ['NULL'];
$update_array['sensor_limit_low_warn'] = ['NULL'];
$update_array['sensor_limit_warn'] = ['NULL'];
$update_array['sensor_limit'] = ['NULL'];
} elseif ($sensor_update['sensor_custom_limit']) {
foreach ($fields_limit as $field) {
$sensor_update[$field] = !is_numeric($sensor_update[$field]) ? ['NULL'] : (float)$sensor_update[$field];
$sensor[$field] = !is_numeric($sensor[$field]) ? ['NULL'] : (float)$sensor[$field];
if ($sensor_update[$field] !== $sensor[$field]) {
$update_array[$field] = $sensor_update[$field];
}
}
}
unset($update_array);
if (count($update_array)) {
dbUpdate($update_array, 'sensors', '`sensor_id` = ?', [$sensor['sensor_id']]);
$msg = 'Sensor updated (custom): ' . $sensor['sensor_class'] . ' ' . $sensor['sensor_type'] . ' ' . $sensor['sensor_id'] . ' ' . escape_html($sensor['sensor_descr']) . ' ';
if ($update_array['sensor_limit_low']) {
$msg .= '[L: ' . $update_array['sensor_limit_low'] . ']';
}
if ($update_array['sensor_limit_low_warn']) {
$msg .= '[Lw: ' . $update_array['sensor_limit_low_warn'] . ']';
}
if ($update_array['sensor_limit_warn']) {
$msg .= '[Hw: ' . $update_array['sensor_limit_warn'] . ']';
}
if ($update_array['sensor_limit']) {
$msg .= '[H: ' . $update_array['sensor_limit'] . ']';
}
log_event($msg, $device_id, 'sensor', $sensor['sensor_id']);
$rows_updated++;
} // End write permission check
$update_entities[$sensor_id] = $update_array;
}
unset($update_array);
} // End write permission check
} // end sensors loop
// Query updated sensors array
if ($rows_updated) {
print_json_status('ok', $rows_updated.' sensor(s) updated.', [ 'update_array' => $update_entities ]);
print_json_status('ok', $rows_updated . ' sensor(s) updated.', ['update_array' => $update_entities]);
} else {
print_json_status('failed', 'No update performed.');
print_json_status('failed', 'No update performed.');
}
// EOF

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
@ -14,46 +14,46 @@
// Allowed only for authenticated
if (!$_SESSION['authenticated'] || $_SESSION['user_id'] != $vars['user_id']) {
print_json_status('failed', "Unauthenticated");
//print_json_status('failed', var_export($vars, TRUE));
return;
print_json_status('failed', "Unauthenticated");
//print_json_status('failed', var_export($vars, TRUE));
return;
}
$user_id = $_SESSION['user_id'];
foreach (process_sql_vars($vars) as $param => $entry) {
// This sets:
// $deletes = array();
// $sets = array();
// $errors = array();
// $set_attribs = array(); // set obs_attribs
$$param = $entry;
// This sets:
// $deletes = array();
// $sets = array();
// $errors = array();
// $set_attribs = array(); // set obs_attribs
$$param = $entry;
}
$updates = 0;
// Set fields that were submitted with custom value
if (safe_count($sets)) {
$query = 'SELECT * FROM `users_prefs` WHERE `user_id` = ?' . generate_query_values_and(array_keys($sets), 'pref');
// Fetch current rows in config file so we know which one to UPDATE and which one to INSERT
$in_db = [];
foreach (dbFetchRows($query, [ $user_id ]) as $row) {
$in_db[$row['pref']] = $row['value'];
}
foreach ($sets as $key => $value) {
$serialize = serialize($value);
if (!isset($in_db[$key]) || $serialize !== $in_db[$key]) {
set_user_pref($user_id, $key, $serialize);
$updates++;
$query = 'SELECT * FROM `users_prefs` WHERE `user_id` = ?' . generate_query_values_and(array_keys($sets), 'pref');
// Fetch current rows in config file so we know which one to UPDATE and which one to INSERT
$in_db = [];
foreach (dbFetchRows($query, [$user_id]) as $row) {
$in_db[$row['pref']] = $row['value'];
}
foreach ($sets as $key => $value) {
$serialize = serialize($value);
if (!isset($in_db[$key]) || $serialize !== $in_db[$key]) {
set_user_pref($user_id, $key, $serialize);
$updates++;
}
}
}
}
// Delete fields that were reset to default
if (safe_count($deletes)) {
dbDelete('users_prefs', '`user_id` = ? ' . generate_query_values_and($deletes, 'pref'), [ $user_id ]);
$updates++;
dbDelete('users_prefs', '`user_id` = ? ' . generate_query_values_and($deletes, 'pref'), [$user_id]);
$updates++;
}
/*
@ -64,19 +64,19 @@ foreach ($set_attribs as $attrib => $value) {
}
*/
if ($updates) {
$status = 'ok';
$message = "Settings updated. Please note Web UI setting takes effect only after reload the page.";
$status = 'ok';
$message = "Settings updated. Please note Web UI setting takes effect only after reload the page.";
if (safe_count($errors)) {
$status = 'warning';
$message .= ' Errors: ' . implode('; ', $errors) . '.';
}
print_json_status($status, $message, [ 'reload' => TRUE ]);
if (safe_count($errors)) {
$status = 'warning';
$message .= ' Errors: ' . implode('; ', $errors) . '.';
}
print_json_status($status, $message, ['reload' => TRUE]);
} elseif (safe_count($errors)) {
$status = 'failed';
$message = 'Errors: ' . implode('; ', $errors) . '.';
print_json_status($status, $message);
$status = 'failed';
$message = 'Errors: ' . implode('; ', $errors) . '.';
print_json_status($status, $message);
}
//process_sql_vars($vars);

View File

@ -4,63 +4,63 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
switch (str_replace('->', '|', $vars['setting'])) {
case "theme":
case "web_theme_default":
$pref = 'web_theme_default';
if ($vars['value'] === 'reset') {
session_unset_var("theme");
if ($config['web_theme_default'] === 'system') {
// Override default
session_unset_var("theme_default");
}
case "theme":
case "web_theme_default":
$pref = 'web_theme_default';
if ($vars['value'] === 'reset') {
session_unset_var("theme");
if ($config['web_theme_default'] === 'system') {
// Override default
session_unset_var("theme_default");
}
if (del_user_pref($_SESSION['user_id'], $pref)) {
print_json_status('ok', 'Theme reset.');
}
} elseif (isset($config['themes'][$vars['value']]) || $vars['value'] === 'system') {
if (set_user_pref($_SESSION['user_id'], $pref, serialize($vars['value']))) {
print_json_status('ok', 'Theme set.');
}
} else {
print_json_status('failed', 'Invalid theme.');
}
break;
if (del_user_pref($_SESSION['user_id'], $pref)) {
print_json_status('ok', 'Theme reset.');
}
} elseif (isset($config['themes'][$vars['value']]) || $vars['value'] === 'system') {
if (set_user_pref($_SESSION['user_id'], $pref, serialize($vars['value']))) {
print_json_status('ok', 'Theme set.');
}
} else {
print_json_status('failed', 'Invalid theme.');
}
break;
case "big_graphs":
$pref = 'graphs|size';
if (set_user_pref($_SESSION['user_id'], $pref, serialize('big'))) {
print_json_status('ok', 'Big graphs set.');
session_unset_var("big_graphs"); // clear old
}
//session_set_var("big_graphs", TRUE);
//print_json_status('ok', 'Big graphs set.');
break;
case "big_graphs":
$pref = 'graphs|size';
if (set_user_pref($_SESSION['user_id'], $pref, serialize('big'))) {
print_json_status('ok', 'Big graphs set.');
session_unset_var("big_graphs"); // clear old
}
//session_set_var("big_graphs", TRUE);
//print_json_status('ok', 'Big graphs set.');
break;
case "normal_graphs":
$pref = 'graphs|size';
if (set_user_pref($_SESSION['user_id'], $pref, serialize('normal'))) {
print_json_status('ok', 'Normal graphs set.');
session_unset_var("big_graphs"); // clear old
}
//session_unset_var("big_graphs");
//print_json_status('ok', 'Small graphs set.');
break;
case "normal_graphs":
$pref = 'graphs|size';
if (set_user_pref($_SESSION['user_id'], $pref, serialize('normal'))) {
print_json_status('ok', 'Normal graphs set.');
session_unset_var("big_graphs"); // clear old
}
//session_unset_var("big_graphs");
//print_json_status('ok', 'Small graphs set.');
break;
case "sensors|web_measured_compact":
// BOOL values
$pref = $vars['setting'];
if (set_user_pref($_SESSION['user_id'], $pref, serialize(get_var_true($vars['value'])))) {
print_json_status('ok', 'Setting was set.', [ 'reload' => TRUE ]);
}
break;
case "sensors|web_measured_compact":
// BOOL values
$pref = $vars['setting'];
if (set_user_pref($_SESSION['user_id'], $pref, serialize(get_var_true($vars['value'])))) {
print_json_status('ok', 'Setting was set.', ['reload' => TRUE]);
}
break;
}
// EOF

View File

@ -4,55 +4,55 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
$rows_updated = 0;
$rows_updated = 0;
$update_entities = [];
//r($vars);
foreach ($vars['status'] as $status_id => $status_update) {
$update_array = [];
if(is_entity_write_permitted('status', $status_id)) {
$status = get_status_by_id($status_id);
$update_array = [];
if (is_entity_write_permitted('status', $status_id)) {
$status = get_status_by_id($status_id);
$device_id = $status['device_id'];
$device_id = $status['device_id'];
$fields_switch = array('status_ignore');
$fields_limit = array();
$fields_switch = ['status_ignore'];
$fields_limit = [];
// Switch selectors
foreach ($fields_switch as $field) {
$status_update[$field] = get_var_true($status_update[$field]) ? '1' : '0';
if ($status_update[$field] != $status[$field]) {
$update_array[$field] = $status_update[$field];
}
}
// Switch selectors
foreach ($fields_switch as $field) {
$status_update[$field] = get_var_true($status_update[$field]) ? '1' : '0';
if ($status_update[$field] != $status[$field]) {
$update_array[$field] = $status_update[$field];
}
}
if (count($update_array)) {
dbUpdate($update_array, 'status', '`status_id` = ?', array($status['status_id']));
$msg = 'Status updated (custom): ' . $status['status_type'] . ' ' . $status['status_id'] . ' ' . escape_html($status['status_descr']) . ' ';
log_event($msg, $device_id, 'status', $status['status_id']);
$rows_updated++;
if (count($update_array)) {
dbUpdate($update_array, 'status', '`status_id` = ?', [$status['status_id']]);
$msg = 'Status updated (custom): ' . $status['status_type'] . ' ' . $status['status_id'] . ' ' . escape_html($status['status_descr']) . ' ';
log_event($msg, $device_id, 'status', $status['status_id']);
$rows_updated++;
$update_entities[$status_id] = $update_array;
}
$update_entities[$status_id] = $update_array;
}
unset($update_array);
unset($update_array);
} // End write permission check
} // End write permission check
} // end entity loop
// Query updated array
if ($rows_updated) {
print_json_status('ok', $rows_updated.' status(es) updated.', [ 'update_array' => $update_entities ]);
print_json_status('ok', $rows_updated . ' status(es) updated.', ['update_array' => $update_entities]);
} else {
print_json_status('failed', 'No update performed.');
print_json_status('failed', 'No update performed.');
}
// EOF

View File

@ -5,56 +5,50 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage ajax
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage ajax
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
$config['install_dir'] = "../..";
include_once("../../includes/observium.inc.php");
include_once("../../includes/sql-config.inc.php");
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
if (!$_SESSION['authenticated']) {
echo("unauthenticated");
exit;
}
if ($_SESSION['userlevel'] >= '5')
{
if ($_SESSION['userlevel'] >= '5') {
switch ($_GET['entity_type'])
{
switch ($_GET['entity_type']) {
case "sensor":
foreach (dbFetch("SELECT * FROM `sensors` WHERE device_id = ?", array($_GET['device_id'])) as $sensor)
{
if(is_entity_permitted($sensor, 'sensor'))
{
$string = addslashes($sensor['sensor_descr']);
echo("obj.options[obj.options.length] = new Option('".$string."','".$sensor['sensor_id']."');\n");
}
}
break;
case "sensor":
foreach (dbFetch("SELECT * FROM `sensors` WHERE device_id = ?", [$_GET['device_id']]) as $sensor) {
if (is_entity_permitted($sensor, 'sensor')) {
$string = addslashes($sensor['sensor_descr']);
echo("obj.options[obj.options.length] = new Option('" . $string . "','" . $sensor['sensor_id'] . "');\n");
}
}
break;
case "netscalervsvr":
foreach (dbFetch("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ?", array($_GET['device_id'])) as $entity)
{
$string = addslashes($entity['vsvr_label']);
echo("obj.options[obj.options.length] = new Option('".$string."','".$entity['vsvr_id']."');\n");
}
break;
case "netscalervsvr":
foreach (dbFetch("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ?", [$_GET['device_id']]) as $entity) {
$string = addslashes($entity['vsvr_label']);
echo("obj.options[obj.options.length] = new Option('" . $string . "','" . $entity['vsvr_id'] . "');\n");
}
break;
case "port":
foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0'", array($_GET['device_id'])) as $port)
{
$string = addslashes($port['port_label_short']." - ".$port['ifAlias']);
echo("obj.options[obj.options.length] = new Option('".$string."','".$port['port_id']."');\n");
}
break;
}
case "port":
foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0'", [$_GET['device_id']]) as $port) {
$string = addslashes($port['port_label_short'] . " - " . $port['ifAlias']);
echo("obj.options[obj.options.length] = new Option('" . $string . "','" . $port['port_id'] . "');\n");
}
break;
}
}

View File

@ -5,42 +5,38 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage ajax
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage ajax
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
$config['install_dir'] = "../..";
include_once("../../includes/observium.inc.php");
include_once("../../includes/sql-config.inc.php");
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
if (!$_SESSION['authenticated']) {
echo("unauthenticated");
exit;
}
if (is_numeric($_GET['device_id']) && device_permitted($_GET['device_id']))
{
foreach (dbFetchRows("SELECT `port_id`,`port_label_short`,`ifAlias`,`ifDescr`,`ifName` FROM `ports` WHERE `device_id` = ? AND deleted = 0 ORDER BY ifIndex", array($_GET['device_id'])) as $interface)
{
$descr = array();
if (empty($interface['port_label_short']))
{
$device = device_by_id_cache($interface['port_id']);
process_port_label($interface, $device);
}
$descr[] = $interface['port_label_short'];
if (is_numeric($_GET['device_id']) && device_permitted($_GET['device_id'])) {
foreach (dbFetchRows("SELECT `port_id`,`port_label_short`,`ifAlias`,`ifDescr`,`ifName` FROM `ports` WHERE `device_id` = ? AND deleted = 0 ORDER BY ifIndex", [$_GET['device_id']]) as $interface) {
$descr = [];
if (empty($interface['port_label_short'])) {
$device = device_by_id_cache($interface['port_id']);
process_port_label($interface, $device);
}
$descr[] = $interface['port_label_short'];
if ($interface['ifAlias'])
{
// second part
$descr[] = $interface['ifAlias'];
if ($interface['ifAlias']) {
// second part
$descr[] = $interface['ifAlias'];
}
$string = addslashes(implode(" - ", $descr));
echo("obj.options[obj.options.length] = new Option('" . $string . "','" . $interface['port_id'] . "');\n");
}
$string = addslashes(implode(" - ", $descr));
echo("obj.options[obj.options.length] = new Option('".$string."','".$interface['port_id']."');\n");
}
}
// EOF

View File

@ -5,55 +5,53 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage ajax
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage ajax
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
$config['install_dir'] = "../..";
include_once("../../includes/observium.inc.php");
include_once("../../includes/sql-config.inc.php");
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
if (!$_SESSION['authenticated']) {
echo("unauthenticated");
exit;
}
$result = array();
$result = [];
if ($_SESSION['userlevel'] >= '5')
{
if ($_SESSION['userlevel'] >= '5') {
switch ($_GET['entity_type'])
{
switch ($_GET['entity_type']) {
case "port":
case "port":
$where_array = build_ports_where_array($GLOBALS['vars']);
$where_array = build_ports_where_array($GLOBALS['vars']);
$where = ' WHERE 1 ';
$where .= implode('', $where_array);
$where = ' WHERE 1 ';
$where .= implode('', $where_array);
$query = 'SELECT *, `ports`.`port_id` AS `port_id` FROM `ports`';
//$query .= ' LEFT JOIN `ports-state` AS S ON `ports`.`port_id` = S.`port_id`';
$query .= $where;
$query = 'SELECT *, `ports`.`port_id` AS `port_id` FROM `ports`';
//$query .= ' LEFT JOIN `ports-state` AS S ON `ports`.`port_id` = S.`port_id`';
$query .= $where;
$ports_db = dbFetchRows($query, $param);
port_permitted_array($ports_db);
$ports_db = dbFetchRows($query, $param);
port_permitted_array($ports_db);
foreach ($ports_db as $port) {
humanize_port($port);
$device = device_by_id_cache($port['device_id']);
array_push($result, [ intval($port['port_id']), $device['hostname'], $port['port_label'], $port['ifAlias'], $port['ifOperStatus'] == 'up' ? 'up' : 'down' ]);
}
break;
foreach ($ports_db as $port) {
humanize_port($port);
$device = device_by_id_cache($port['device_id']);
array_push($result, [intval($port['port_id']), $device['hostname'], $port['port_label'], $port['ifAlias'], $port['ifOperStatus'] == 'up' ? 'up' : 'down']);
}
break;
}
}
header('Content-Type: application/json');
print json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
header('Content-Type: application/json');
print json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
}

View File

@ -6,18 +6,18 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
$config['install_dir'] = "../..";
require_once("../../includes/observium.inc.php");
require_once($config['install_dir']."/includes/sql-config.inc.php");
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
if (!$_SESSION['authenticated']) { print_error('Session expired, please log in again!'); exit; }
if (!$_SESSION['authenticated']) {
print_error('Session expired, please log in again!');
exit;
}
ob_start();
@ -25,288 +25,353 @@ $vars = get_vars([ 'JSON', 'POST', 'GET' ]);
$vars['page'] = "popup";
if(isset($vars['debug'])) { r($vars); }
if (isset($vars['debug'])) {
r($vars);
}
switch ($vars['entity_type']) {
case "port":
if (is_numeric($vars['entity_id']) && (port_permitted($vars['entity_id']))) {
$port = get_port_by_id($vars['entity_id']);
echo generate_port_popup($port);
} else {
print_warning("You are not permitted to view this port.");
}
break;
case "port":
if (is_numeric($vars['entity_id']) && (port_permitted($vars['entity_id']))) {
$port = get_port_by_id($vars['entity_id']);
echo generate_port_popup($port);
} else {
print_warning("You are not permitted to view this port.");
}
break;
case "link":
if (is_numeric($vars['entity_id_a']) && (port_permitted($vars['entity_id_a']))) {
$port = get_port_by_id($vars['entity_id_a']);
echo generate_port_popup($port);
} else {
print_warning("You are not permitted to view this port.");
}
if (is_numeric($vars['entity_id_b']) && (port_permitted($vars['entity_id_b']))) {
$port = get_port_by_id($vars['entity_id_b']);
echo generate_port_popup($port, '','none'); // suppress graph for b side of link
} else {
print_warning("You are not permitted to view this port.");
}
break;
case "device":
if (is_numeric($vars['entity_id']) && device_permitted($vars['entity_id'])) {
$device = device_by_id_cache($vars['entity_id']);
echo generate_device_popup($device, $vars);
} else {
print_warning("You are not permitted to view this device.");
}
break;
case "group":
if (is_numeric($vars['entity_id']) && $_SESSION['userlevel'] >= 5) {
$group = get_group_by_id($vars['entity_id']);
echo generate_group_popup_header($group, array());
} else {
print_warning("You are not permitted to view this group.");
}
break;
case "mac":
if (preg_match('/^' . OBS_PATTERN_MAC . '$/i', $vars['entity_id'])) {
$mac = format_mac($vars['entity_id']);
// Other way by using Pear::Net_MAC, see here: http://pear.php.net/manual/en/package.networking.net-mac.importvendors.php
$url = 'https://api.macvendors.com/' . urlencode($mac);
$response = get_http_request($url);
if ($response) {
echo 'MAC vendor: ' . $response;
} else {
echo 'Not Found';
}
} else {
echo 'Not correct MAC address';
}
break;
case "ip":
list($ip) = explode('/', $vars['entity_id']);
if ($ip_version = get_ip_version($ip)) {
$cache_key = 'response_' . $vars['entity_type'] . '_' . $ip;
$cache_entry = get_cache_session($cache_key);
//r($cache_entry);
if (ishit_cache_session()) {
//echo '<h2>CACHED!</h2>';
echo $cache_entry;
exit;
}
$response = '';
$reverse_dns = gethostbyaddr6($ip);
if ($reverse_dns) {
$response .= '<h4>' . $reverse_dns . '</h4><hr />' . PHP_EOL;
}
// WHOIS
if (!isset($config['http_proxy']) && is_executable($config['whois'])) {
// Use direct whois cmd query (preferred)
// NOTE, for now not tested and not supported for KRNIC, ie: 202.30.50.0, 2001:02B8:00A2::
$cmd = $config['whois'] . ' ' . $ip;
$whois = external_exec($cmd);
$multi_whois = explode('# start', $whois); // Some time whois return multiple (ie: whois 8.8.8.8), than use last
if (safe_count($multi_whois) > 1) {
$whois = array_pop($multi_whois);
case "link":
if (is_numeric($vars['entity_id_a']) && (port_permitted($vars['entity_id_a']))) {
$port = get_port_by_id($vars['entity_id_a']);
echo generate_port_popup($port);
} else {
print_warning("You are not permitted to view this port.");
}
$org = 0;
foreach (explode("\n", $whois) as $line) {
if (preg_match('/^(\w[\w\s\-\/]+):.*$/', $line, $matches)) {
if (in_array($matches[1], [ 'Ref', 'source', 'nic-hdl-br' ])) {
if ($org === 1) {
$response .= PHP_EOL;
$org++;
continue;
}
break;
}
if (in_array($matches[1], array('Organization', 'org', 'mnt-irt'))) {
$org++; // has org info
} elseif ($matches[1] === 'Comment') {
continue; // skip comments
}
$response .= $line . PHP_EOL;
}
if (is_numeric($vars['entity_id_b']) && (port_permitted($vars['entity_id_b']))) {
$port = get_port_by_id($vars['entity_id_b']);
echo generate_port_popup($port, '', 'none'); // suppress graph for b side of link
} else {
print_warning("You are not permitted to view this port.");
}
} else {
// Use RIPE whois API query
$whois_url = 'https://stat.ripe.net/data/whois/data.json?';
$whois_url .= 'sourceapp=' . urlencode(OBSERVIUM_PRODUCT . '-' . get_unique_id());
$whois_url .= '&resource=' . urlencode($ip);
break;
if ($request = get_http_request($whois_url)) {
$request = safe_json_decode($request); // Convert to array
if ($request['status'] === 'ok' && safe_count($request['data']['records'])) {
$whois_parts = array();
foreach ($request['data']['records'] as $i => $parts) {
$key = $parts[0]['key'];
if (in_array($key, [ 'NetRange', 'inetnum', 'inet6num' ])) {
case "device":
if (is_numeric($vars['entity_id']) && device_permitted($vars['entity_id'])) {
$device = device_by_id_cache($vars['entity_id']);
echo generate_device_popup($device, $vars);
} else {
print_warning("You are not permitted to view this device.");
}
break;
case "group":
if (is_numeric($vars['entity_id']) && $_SESSION['userlevel'] >= 5) {
$group = get_group_by_id($vars['entity_id']);
echo generate_group_popup_header($group);
} else {
print_warning("You are not permitted to view this group.");
}
break;
case "mac":
if (preg_match('/^' . OBS_PATTERN_MAC . '$/i', $vars['entity_id'])) {
$mac = format_mac($vars['entity_id']);
// Other way by using Pear::Net_MAC, see here: http://pear.php.net/manual/en/package.networking.net-mac.importvendors.php
$url = 'https://api.macvendors.com/' . urlencode($mac);
$response = get_http_request($url);
if ($response) {
echo 'MAC vendor: ' . escape_html($response);
} else {
echo 'Not Found';
}
} else {
echo 'Not correct MAC address';
}
break;
case "ip":
$ip = explode('/', $vars['entity_id'])[0];
if ($ip_version = get_ip_version($ip)) {
$cache_key = 'response_' . $vars['entity_type'] . '_' . $ip;
$cache_entry = get_cache_session($cache_key);
//r($cache_entry);
if (ishit_cache_session()) {
//echo '<h2>CACHED!</h2>';
echo $cache_entry;
exit;
}
$response = '';
$reverse_dns = gethostbyaddr6($ip);
if ($reverse_dns) {
$response .= '<h4>' . $reverse_dns . '</h4><hr />' . PHP_EOL;
}
// WHOIS
if (!isset($config['http_proxy']) && is_executable($config['whois'])) {
// Use direct whois cmd query (preferred)
// NOTE, for now not tested and not supported for KRNIC, ie: 202.30.50.0, 2001:02B8:00A2::
$cmd = $config['whois'] . ' ' . $ip;
$whois = external_exec($cmd);
$multi_whois = explode('# start', $whois); // Some time whois return multiple (ie: whois 8.8.8.8), than use last
if (safe_count($multi_whois) > 1) {
$whois = array_pop($multi_whois);
}
$org = 0;
$whois_parts[0] = '';
foreach ($parts as $part) {
if (in_array($part['key'], [ 'Ref', 'source', 'nic-hdl-br' ])) {
break;
}
if (in_array($part['key'], [ 'Organization', 'org', 'mnt-irt' ])) {
$org = 1; // has org info
$org_name = $part['value'];
} elseif ($part['key'] === 'Comment') {
continue; // skip comments
}
$whois_parts[0] .= sprintf('%-16s %s' . PHP_EOL, $part['key'] . ':', $part['value']);
foreach (explode("\n", $whois) as $line) {
if (preg_match('/^(\w[\w\s\-\/]+):.*$/', $line, $matches)) {
if (in_array($matches[1], ['Ref', 'source', 'nic-hdl-br'])) {
if ($org === 1) {
$response .= PHP_EOL;
$org++;
continue;
}
break;
}
if (in_array($matches[1], ['Organization', 'org', 'mnt-irt'])) {
$org++; // has org info
} elseif ($matches[1] === 'Comment') {
continue; // skip comments
}
$response .= $line . PHP_EOL;
}
}
} else {
// Use RIPE whois API query
$whois_url = 'https://stat.ripe.net/data/whois/data.json?';
$whois_url .= 'sourceapp=' . urlencode(OBSERVIUM_PRODUCT . '-' . get_unique_id());
$whois_url .= '&resource=' . urlencode($ip);
} elseif ($org === 1 && $key === 'OrgName' && strpos($org_name, $parts[0]['value']) === 0) {
if ($request = get_http_request($whois_url)) {
$request = safe_json_decode($request); // Convert to array
if ($request['status'] === 'ok' && safe_count($request['data']['records'])) {
$whois_parts = [];
foreach ($request['data']['records'] as $i => $parts) {
$key = $parts[0]['key'];
$whois_parts[1] = '';
foreach ($parts as $part) {
if (in_array($part['key'], [ 'Ref', 'source', 'nic-hdl-br' ])) {
break;
}
if ($part['key'] === 'Comment') {
continue; // skip comments
}
$whois_parts[1] .= sprintf('%-16s %s' . PHP_EOL, $part['key'] . ':', $part['value']);
if (in_array($key, ['NetRange', 'inetnum', 'inet6num'])) {
$org = 0;
$whois_parts[0] = '';
foreach ($parts as $part) {
if (in_array($part['key'], ['Ref', 'source', 'nic-hdl-br'])) {
break;
}
if (in_array($part['key'], ['Organization', 'org', 'mnt-irt'])) {
$org = 1; // has org info
$org_name = $part['value'];
} elseif ($part['key'] === 'Comment') {
continue; // skip comments
}
$whois_parts[0] .= sprintf('%-16s %s' . PHP_EOL, $part['key'] . ':', $part['value']);
}
} elseif ($org === 1 && $key === 'OrgName' && strpos($org_name, $parts[0]['value']) === 0) {
$whois_parts[1] = '';
foreach ($parts as $part) {
if (in_array($part['key'], ['Ref', 'source', 'nic-hdl-br'])) {
break;
}
if ($part['key'] === 'Comment') {
continue; // skip comments
}
$whois_parts[1] .= sprintf('%-16s %s' . PHP_EOL, $part['key'] . ':', $part['value']);
}
break;
}
}
$response .= implode(PHP_EOL, $whois_parts);
//print_vars($request['data']['records']);
}
}
break;
}
}
$response .= implode(PHP_EOL, $whois_parts);
//print_vars($request['data']['records']);
}
if ($response) {
$cache_entry = '<pre class="small">' . escape_html($response) . '</pre>';
// @session_start();
// $_SESSION['cache']['response_' . $vars['entity_type'] . '_' . $ip] = '<pre class="small">' . $response . '</pre>';
// session_commit();
} else {
$cache_entry = 'Not Found';
//echo 'Not Found';
}
set_cache_session($cache_key, $cache_entry);
echo $cache_entry;
} else {
echo 'Not correct IP address';
}
}
break;
if ($response) {
$cache_entry = '<pre class="small">' . $response . '</pre>';
// @session_start();
// $_SESSION['cache']['response_' . $vars['entity_type'] . '_' . $ip] = '<pre class="small">' . $response . '</pre>';
// session_commit();
} else {
$cache_entry = 'Not Found';
//echo 'Not Found';
}
set_cache_session($cache_key, $cache_entry);
echo $cache_entry;
} else {
echo 'Not correct IP address';
}
break;
case 'autodiscovery':
// if (isset($vars['autodiscovery_id']))
// {
// $vars['entity_id'] = $vars['autodiscovery_id'];
// }
//r($vars);
if (is_numeric($vars['entity_id']) &&
$_SESSION['userlevel'] > 7) {
case 'autodiscovery':
// if (isset($vars['autodiscovery_id']))
// {
// $vars['entity_id'] = $vars['autodiscovery_id'];
// }
//r($vars);
if (is_numeric($vars['entity_id']) &&
$_SESSION['userlevel'] > 7) {
$cache_key = 'response_' . $vars['entity_type'] . '_' . $vars['entity_id'];
$cache_entry = get_cache_session($cache_key);
//r($cache_entry);
if (ishit_cache_session()) {
//echo '<h2>CACHED!</h2>';
echo $cache_entry;
exit;
}
$cache_key = 'response_' . $vars['entity_type'] . '_' . $vars['entity_id'];
$cache_entry = get_cache_session($cache_key);
//r($cache_entry);
if (ishit_cache_session()) {
//echo '<h2>CACHED!</h2>';
echo $cache_entry;
exit;
}
$entry = dbFetchRow('SELECT `remote_hostname`, `remote_ip`, `last_reason`, UNIX_TIMESTAMP(`last_checked`) AS `last_checked_unixtime` FROM `autodiscovery` WHERE `autodiscovery_id` = ?', [$vars['entity_id']]);
$hostname = $entry['remote_hostname'];
$ip = $entry['remote_ip'];
$entry = dbFetchRow('SELECT `remote_hostname`, `remote_ip`, `last_reason`, UNIX_TIMESTAMP(`last_checked`) AS `last_checked_unixtime` FROM `autodiscovery` WHERE `autodiscovery_id` = ?', [ $vars['entity_id'] ]);
$hostname = $entry['remote_hostname'];
$ip = $entry['remote_ip'];
//r($entry);
// 'ok','no_xdp','no_fqdn','no_dns','no_ip_permit','no_ping','no_snmp','no_db','duplicated','unknown'
switch ($entry['last_reason']) {
case 'ok':
$last_reason = "Remote host $hostname ($ip) successfully added to db.";
break;
//r($entry);
// 'ok','no_xdp','no_fqdn','no_dns','no_ip_permit','no_ping','no_snmp','no_db','duplicated','unknown'
switch ($entry['last_reason']) {
case 'ok':
$last_reason = "Remote host $hostname ($ip) successfully added to db.";
break;
case 'no_xdp':
$last_reason = 'Remote platform ignored by XDP autodiscovery configuration.';
break;
case 'no_xdp':
$last_reason = 'Remote platform ignored by XDP autodiscovery configuration.';
break;
case 'no_fqdn':
$last_reason = "Remote IP $ip does not seem to have FQDN.";
break;
case 'no_fqdn':
$last_reason = "Remote IP $ip does not seem to have FQDN.";
break;
case 'no_dns':
$last_reason = "Remote host $hostname not resolved.";
break;
case 'no_dns':
$last_reason = "Remote host $hostname not resolved.";
break;
case 'no_ip_permit':
$last_reason = "Remote IP $ip not permitted in autodiscovery configuration or invalid.";
break;
case 'no_ip_permit':
$last_reason = "Remote IP $ip not permitted in autodiscovery configuration or invalid.";
break;
case 'no_ping':
$last_reason = "Remote host $hostname not pingable.";
break;
case 'no_ping':
$last_reason = "Remote host $hostname not pingable.";
break;
case 'no_snmp':
$last_reason = "Remote host $hostname not SNMPable by configured auth parameters.";
break;
case 'no_snmp':
$last_reason = "Remote host $hostname not SNMPable by configured auth parameters.";
break;
case 'duplicated':
$last_reason = "Remote host $hostname ($ip) already found in db.";
break;
case 'duplicated':
$last_reason = "Remote host $hostname ($ip) already found in db.";
break;
case 'no_db':
$last_reason = "Remote host $hostname ($ip) success, but not added by an DB error.";
break;
case 'no_db':
$last_reason = "Remote host $hostname ($ip) success, but not added by an DB error.";
break;
default:
$last_reason = "Remote host $hostname ($ip) not added by unknown reason.";
break;
}
$cache_entry = '<div style="width: 280px;">';
$cache_entry .= "<h4>$last_reason</h4><hr />";
$cache_entry .= '<strong style="margin-left: 10px;">Autodiscovery checked:</strong> '. format_uptime(time() - $entry['last_checked_unixtime'], 'shorter') . ' ago</span>';
$cache_entry .= '</div>';
//$cache_entry .= build_table_row($entry);
set_cache_session($cache_key, $cache_entry);
echo $cache_entry;
} else {
print_warning("You are not permitted to view this entry.");
}
break;
default:
if (isset($config['entities'][$vars['entity_type']])) {
$entity_ids = array();
foreach (explode(',', $vars['entity_id']) as $id) {
// Filter permitted IDs
if (is_numeric($id) && (is_entity_permitted($id, $vars['entity_type']))) {
$entity_ids[] = $id;
default:
$last_reason = "Remote host $hostname ($ip) not added by unknown reason.";
break;
}
$cache_entry = '<div style="width: 280px;">';
$cache_entry .= "<h4>" . escape_html($last_reason) . "</h4><hr />";
$cache_entry .= '<strong style="margin-left: 10px;">Autodiscovery checked:</strong> ' .
format_uptime(get_time() - $entry['last_checked_unixtime'], 'shorter') . ' ago</span>';
$cache_entry .= '</div>';
//$cache_entry .= build_table_row($entry);
set_cache_session($cache_key, $cache_entry);
echo $cache_entry;
} else {
print_warning("You are not permitted to view this entry.");
}
}
if (count($entity_ids)) {
echo generate_entity_popup_multi($entity_ids, $vars);
//}
//elseif (is_numeric($vars['entity_id']) && (is_entity_permitted($vars['entity_id'], $vars['entity_type'])))
//{
// $entity = get_entity_by_id_cache($vars['entity_type'], $vars['entity_id']);
// echo generate_entity_popup($entity, $vars);
} else {
print_warning("You are not permitted to view this entity.");
}
} else {
print_error("Unknown entity type.");
}
break;
break;
case 'latlon':
// Check if latitude and longitude are set
if (!isset($vars['lat'], $vars['lon'])) {
echo "ERROR: Latitude and Longitude required";
break;
}
$location = [];
// Fetch devices and their locations
$devices = dbFetchRows("SELECT * FROM `devices` LEFT JOIN `devices_locations` USING (`device_id`) " .
generate_where_clause(generate_query_permitted_ng(['devices']),
"location_lat = ? AND location_lon = ?"),
[$vars['lat'], $vars['lon']]);
foreach ($devices as $device) {
if (!$config['web_show_disabled'] && $device["disabled"]) {
continue;
}
if ($device['location'] != '') {
$location['location_name'] = $device['location'];
}
// Categorize devices as up or down
if ($device["status"] == "0" && $device["ignore"] == "0") {
$location["down_hosts"][] = $device;
} else {
$location["up_hosts"][] = $device;
}
}
// Display location information
if (!isset($location['location_name'])) {
echo "Unknown Location";
} else {
$num_up = safe_count($location["up_hosts"]);
$num_down = safe_count($location["down_hosts"]);
$total_hosts = $num_up + $num_down;
$state = 'unknown';
if ($num_down > 0) {
$state = 'down';
} elseif ($num_up > 0) {
$state = 'up';
}
// Generate tooltip content
$tooltip = "<h3>" . escape_html($location['location_name']) . "</h3><hr />";
$tooltip .= '<p><span class="label label-success">Up ' . $num_up . '</span>
<span class="label label-error">Down ' . $num_down . '</span></p>';
if($num_up < 50) {
foreach ($location["up_hosts"] as $host) {
$tooltip .= '<span class="label label-success">' . escape_html($host['hostname']) . '</span> ';
}
}
foreach ($location["down_hosts"] as $host) {
$tooltip .= '<span class="label label-error">' . escape_html($host['hostname']) . '</span> ';
}
//$tooltip .= "<p><small>Coordinates: ".$vars['lat'].",".$vars['lon']."</small></p>";
echo $tooltip;
}
break;
default:
if (isset($config['entities'][$vars['entity_type']])) {
$entity_ids = [];
foreach (explode(',', $vars['entity_id']) as $id) {
// Filter permitted IDs
if (is_numeric($id) && (is_entity_permitted($id, $vars['entity_type']))) {
$entity_ids[] = $id;
}
}
if (count($entity_ids)) {
echo generate_entity_popup_multi($entity_ids, $vars);
} else {
print_warning("You are not permitted to view this entity.");
}
} else {
print_error("Unknown entity type.");
}
break;
}
exit;

95
html/ajax/geojson.php Normal file
View File

@ -0,0 +1,95 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
ini_set('allow_url_fopen', 0); // Why here?
include_once("../../includes/observium.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
include($config['html_dir'] . "/includes/cache-data.inc.php");
if (!$_SESSION['authenticated']) {
echo("unauthenticated");
exit;
}
$vars = get_vars('GET');
$geo = [];
foreach (dbFetchRows("SELECT * FROM `devices` LEFT JOIN `devices_locations` USING (`device_id`) " . generate_where_clause(generate_query_permitted_ng(['devices']))) as $device) {
if (!$config['web_show_disabled'] && $device["disabled"]) {
continue;
}
$lat = (is_numeric($device['location_lat']) ? $device['location_lat'] : $config['geocoding']['default']['lat']);
$lon = (is_numeric($device['location_lon']) ? $device['location_lon'] : $config['geocoding']['default']['lon']);
if ($device["status"] == "0") {
if ($device["ignore"] == "0") {
$locations[$lat][$lon]["down_hosts"][] = $device;
}
} else {
$locations[$lat][$lon]["up_hosts"][] = $device;
}
}
foreach ($locations as $la => $lat) {
foreach ($lat as $lo => $lon) {
$tooltip = "";
$num_up = safe_count($lon["up_hosts"]);
$num_down = safe_count($lon["down_hosts"]);
$total_hosts = $num_up + $num_down;
$tooltip = '<p><span class="label label-success">Up ' . $num_up . '</span> <span class="label label-error">Down ' . $num_down . '</span></p>';
$state = 'unknown';
$location_name = "";
if ($num_down > 0) {
$state = 'down';
$location_name = ($lon['down_hosts'][0]['location'] === '' ? OBS_VAR_UNSET : $lon['down_hosts'][0]['location']);
$location_url = generate_location_url($lon['down_hosts'][0]['location']);
} elseif ($num_up > 0) {
$state = 'up';
$location_name = ($lon['up_hosts'][0]['location'] === '' ? OBS_VAR_UNSET : $lon['up_hosts'][0]['location']);
$location_url = generate_location_url($lon['up_hosts'][0]['location']);
}
$tooltip = "<h3>" . $location_name . "</h3><hr />" . $tooltip;
foreach ($lon["down_hosts"] as $down_host) {
$tooltip .= '<span class="label label-error">' . escape_html($down_host['hostname']) . '</span> ';
}
$feature = ['geometry' => ['type' => 'Point',
'coordinates' => [(float)$lo, (float)$la]],
'type' => 'Feature',
'properties' => ['name' => $location_name,
'state' => $state,
'id' => safename($location_name),
//'popupContent' => $tooltip,
'url' => $location_url]];
$features[] = $feature;
//echo "[$la, $lo, $num_up, $num_down, \"$tooltip\", '$location_name', '$location_url'],\n ";
}
}
$geo = ['type' => 'FeatureCollection', 'features' => $features];
header('Content-type: application/javascript');
//echo 'var geojson = ' . json_encode($geo) . ';';
//print_r($features);
echo safe_json_encode($geo);
//r($geo);
// EOF

View File

@ -4,150 +4,150 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
// FIXME, create api-internal for such
$config['install_dir'] = "../..";
include_once("../../includes/observium.inc.php");
include_once("../../includes/sql-config.inc.php");
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
if (!$_SESSION['authenticated']) { echo('<li class="nav-header">Session expired, please log in again!</li>'); exit; }
if (!$_SESSION['authenticated']) {
echo('<li class="nav-header">Session expired, please log in again!</li>');
exit;
}
$vars = get_vars('GET');
$array_filter = in_array($vars['field'], [ 'syslog_program' ], TRUE); // modules with cached field
$vars = get_vars('GET');
$array_filter = in_array($vars['field'], ['syslog_program'], TRUE); // modules with cached field
if (!safe_empty($vars['field']) && $vars['cache'] !== 'no' && ($array_filter || safe_empty($vars['query']))) {
$cache_key = 'options_' . $vars['field'];
foreach ($vars as $param => $value) {
if (in_array($param, [ 'field', 'query', 'cache' ], TRUE)) { continue; }
$cache_key .= "_$param=$value";
}
$cache_key = 'options_' . $vars['field'];
foreach ($vars as $param => $value) {
if (in_array($param, ['field', 'query', 'cache'], TRUE)) {
continue;
}
$cache_key .= "_$param=$value";
}
} else {
$cache_key = '';
$cache_key = '';
}
$query = '';
if ($cache_key && $options = get_cache_session($cache_key)) {
// Return cached data (if not set in vars cache = 'no')
//header("Content-type: application/json; charset=utf-8");
//echo safe_json_encode(array('options' => $_SESSION['cache'][$cache_key]));
//$options = $_SESSION['cache'][$cache_key];
// Return cached data (if not set in vars cache = 'no')
//header("Content-type: application/json; charset=utf-8");
//echo safe_json_encode(array('options' => $_SESSION['cache'][$cache_key]));
//$options = $_SESSION['cache'][$cache_key];
} else {
$params = array();
//print_vars($vars);
switch ($vars['field']) {
case 'ipv4_network':
case 'ipv6_network':
list($ip_version) = explode('_', $vars['field']);
$query_permitted = generate_query_permitted('ports');
$network_permitted = dbFetchColumn('SELECT DISTINCT(`' . $ip_version . '_network_id`) FROM `' . $ip_version . '_addresses` WHERE 1' . $query_permitted);
$query = 'SELECT `' . $ip_version . '_network` FROM `' . $ip_version . '_networks` WHERE 1 ' . generate_query_values_and($network_permitted, $ip_version . '_network_id');
if (!safe_empty($vars['query'])) {
//$query .= ' AND `' . $ip_version . '_network` LIKE ?';
//$params[] = '%' . $vars['query'] . '%';
$query .= generate_query_values_and($vars['query'], $vars['field'], '%LIKE%');
}
$query .= ' ORDER BY `' . $ip_version . '_network`;';
//print_vars($query);
break;
$params = [];
//print_vars($vars);
switch ($vars['field']) {
case 'ipv4_network':
case 'ipv6_network':
[$ip_version] = explode('_', $vars['field']);
$query_permitted = generate_query_permitted('ports');
$network_permitted = dbFetchColumn('SELECT DISTINCT(`' . $ip_version . '_network_id`) FROM `' . $ip_version . '_addresses` WHERE 1' . $query_permitted);
$query = 'SELECT `' . $ip_version . '_network` FROM `' . $ip_version . '_networks` WHERE 1 ' . generate_query_values_and($network_permitted, $ip_version . '_network_id');
if (!safe_empty($vars['query'])) {
//$query .= ' AND `' . $ip_version . '_network` LIKE ?';
//$params[] = '%' . $vars['query'] . '%';
$query .= generate_query_values_and($vars['query'], $vars['field'], '%LIKE%');
}
$query .= ' ORDER BY `' . $ip_version . '_network`;';
//print_vars($query);
break;
case 'ifspeed':
$query_permitted = generate_query_permitted('ports');
$query = 'SELECT `ifSpeed`, COUNT(`ifSpeed`) as `count` FROM `ports` WHERE `ifSpeed` > 0 '. $query_permitted .' GROUP BY ifSpeed ORDER BY `count` DESC';
$call_function = 'formatRates';
$call_params = array(4, 4);
break;
case 'ifspeed':
$query_permitted = generate_query_permitted('ports');
$query = 'SELECT `ifSpeed`, COUNT(`ifSpeed`) as `count` FROM `ports` WHERE `ifSpeed` > 0 ' . $query_permitted . ' GROUP BY ifSpeed ORDER BY `count` DESC';
$call_function = 'formatRates';
$call_params = [4, 4];
break;
case 'syslog_program':
//$query_permitted = generate_query_permitted();
$query = 'SELECT DISTINCT `program` FROM `syslog`';
if (is_intnum($vars['device_id'])) {
$query .= ' WHERE ' . generate_query_values_ng($vars['device_id'], 'device_id');
}
$array_filter = TRUE; // Search query string in array instead sql query (when this faster)
break;
case 'syslog_program':
//$query_permitted = generate_query_permitted();
$query = 'SELECT DISTINCT `program` FROM `syslog`';
if (is_intnum($vars['device_id'])) {
$query .= ' WHERE ' . generate_query_values_ng($vars['device_id'], 'device_id');
}
$array_filter = TRUE; // Search query string in array instead sql query (when this faster)
break;
case 'bgp_peer_as':
$column = 'bgpPeerRemoteAs';
$query_permitted = generate_query_permitted('devices');
// Combine AS number and AS text into string: ASXXXX: My AS text
$query = 'SELECT DISTINCT CONCAT(?, CONCAT_WS(?, `'.$column.'`, `astext`)) AS `'.$vars['field'].'` FROM `bgpPeers` WHERE 1 ' . $query_permitted;
$params[] = 'AS';
$params[] = ': ';
//$query = 'SELECT DISTINCT `' . $column . '`, `astext` FROM `bgpPeers` WHERE 1 ' . $cache['where']['devices_permitted'] . ' ORDER BY `' . $column . '`';
if (!safe_empty($vars['query'])) {
$query .= ' AND (`' . $column . '` LIKE ? OR `astext` LIKE ?)';
$params[] = '%' . $vars['query'] . '%';
$params[] = '%' . $vars['query'] . '%';
//$query .= generate_query_values_and($vars['query'], $vars['field'], '%LIKE%');
}
break;
case 'bgp_peer_as':
$column = 'bgpPeerRemoteAs';
$query_permitted = generate_query_permitted('devices');
// Combine AS number and AS text into string: ASXXXX: My AS text
$query = 'SELECT DISTINCT CONCAT(?, CONCAT_WS(?, `' . $column . '`, `astext`)) AS `' . $vars['field'] . '` FROM `bgpPeers` WHERE 1 ' . $query_permitted;
$params[] = 'AS';
$params[] = ': ';
if (!safe_empty($vars['query'])) {
$query .= ' AND (`' . $column . '` LIKE ? OR `astext` LIKE ?)';
$params[] = '%' . $vars['query'] . '%';
$params[] = '%' . $vars['query'] . '%';
//$query .= generate_query_values_and($vars['query'], $vars['field'], '%LIKE%');
}
break;
case 'bgp_local_ip':
case 'bgp_peer_ip':
$columns = array('local_ip' => 'bgpPeerLocalAddr',
'peer_ip' => 'bgpPeerRemoteAddr',
);
$param = str_replace('bgp_', '', $vars['field']);
$column = $columns[$param];
$query_permitted = generate_query_permitted('devices');
$query = 'SELECT DISTINCT `' . $column . '` FROM `bgpPeers` WHERE 1 ' . $query_permitted;
if (!safe_empty($vars['query'])) {
$query .= generate_query_values_and($vars['query'], $column, '%LIKE%');
}
break;
case 'bgp_local_ip':
case 'bgp_peer_ip':
$columns = ['local_ip' => 'bgpPeerLocalAddr',
'peer_ip' => 'bgpPeerRemoteAddr'];
$param = str_replace('bgp_', '', $vars['field']);
$column = $columns[$param];
$query_permitted = generate_query_permitted('devices');
$query = 'SELECT DISTINCT `' . $column . '` FROM `bgpPeers` WHERE 1 ' . $query_permitted;
if (!safe_empty($vars['query'])) {
$query .= generate_query_values_and($vars['query'], $column, '%LIKE%');
}
break;
default:
json_output('error', 'Search type unknown');
}
if (strlen($query)) {
$options = dbFetchColumn($query, $params);
if (safe_count($options)) {
if (isset($call_function)) {
$call_options = array();
foreach ($options as $option) {
$call_options[] = call_user_func_array($call_function, array_merge(array($option), $call_params));
}
$options = $call_options;
}
// Cache request in session var (need convert to common caching lib)
if ($cache_key) {
set_cache_session($cache_key, $options);
//@session_start();
//$_SESSION['cache'][$cache_key] = $options; // Cache query data in session for speedup
//session_write_close();
}
} else {
json_output('error', 'Data fields are empty');
default:
json_output('error', 'Search type unknown');
}
if (strlen($query)) {
$options = dbFetchColumn($query, $params);
if (safe_count($options)) {
if (isset($call_function)) {
$call_options = [];
foreach ($options as $option) {
$call_options[] = call_user_func_array($call_function, array_merge([$option], $call_params));
}
$options = $call_options;
}
// Cache request in session var (need convert to common caching lib)
if ($cache_key) {
set_cache_session($cache_key, $options);
//@session_start();
//$_SESSION['cache'][$cache_key] = $options; // Cache query data in session for speedup
//session_write_close();
}
} else {
json_output('error', 'Data fields are empty');
}
}
}
}
if (safe_count($options)) {
// Filter/search query string in array, instead sql query, when this is faster (ie syslog program)
if ($array_filter) {
$new_options = [];
foreach ($options as $option) {
if (stripos($option, $vars['query']) !== FALSE) {
$new_options[] = $option;
}
// Filter/search query string in array, instead sql query, when this is faster (ie syslog program)
if ($array_filter) {
$new_options = [];
foreach ($options as $option) {
if (str_contains_array($option, $vars['query'])) {
$new_options[] = $option;
}
}
$options = $new_options;
}
$options = $new_options;
}
header("Content-type: application/json; charset=utf-8");
echo safe_json_encode(array( 'options' => $options ));
header("Content-type: application/json; charset=utf-8");
echo safe_json_encode(['options' => $options]);
} else {
json_output('error', 'Data fields are empty');
json_output('error', 'Data fields are empty');
}
// EOF

View File

@ -4,101 +4,90 @@
*
* 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-2023 Observium Limited
*
*/
$config['install_dir'] = "../..";
include_once("../../includes/observium.inc.php");
include_once("../../includes/sql-config.inc.php");
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
if (!$_SESSION['authenticated']) { echo('<li class="nav-header">Session expired, please log in again!</li>'); exit; }
if (!$_SESSION['authenticated']) {
echo('<li class="nav-header">Session expired, please log in again!</li>');
exit;
}
include($config['html_dir'] . "/includes/cache-data.inc.php");
$query_limit = 8; // Limit per query
$vars = get_vars([ 'POST', 'GET' ]);
$vars = get_vars(['POST', 'GET']);
// Is there a POST/GET query string?
if (isset($vars['queryString'])) {
$queryString = trim($vars['queryString']);
$queryString = trim($vars['queryString']);
// Is the string length greater than 0?
if (strlen($queryString) > 0)
{
$query_param = "%$queryString%";
// Is the string length greater than 0?
if (strlen($queryString) > 0) {
$query_param = "%$queryString%";
// Start out with a clean slate
$search_results = array();
// Start out with a clean slate
$search_results = [];
// Increase query_limit by one, so we can show "+" on result display if there are more than $query_limit entries
$query_limit++;
// Increase query_limit by one, so we can show "+" on result display if there are more than $query_limit entries
$query_limit++;
// Prepare user permission SQL query for use in search module queries
$query_permitted_device = $cache['where']['devices_permitted'];
$query_permitted_port = $cache['where']['ports_permitted'];
// Run search modules
foreach ($config['wui']['search_modules'] as $module)
{
if (is_file($config['html_dir'] . "/includes/search/$module.inc.php"))
{
include($config['html_dir'] . "/includes/search/$module.inc.php");
}
}
// Reset query_limit
$query_limit--;
foreach ($search_results as $results)
{
$display_count = safe_count($results['results']);
// If there are more results than query_limit (can happen, as we ++'d above), cut array to desired size and add + to counter
if ($display_count > $query_limit)
{
$results['results'] = array_slice($results['results'], 0, $query_limit);
$display_count .= '+';
}
echo('<li class="nav-header">' . $results['descr'] . ': '. $display_count . '</li>' . PHP_EOL);
foreach ($results['results'] as $result)
{
$data = [];
foreach ($result['data'] as $str) {
$str = str_replace('| |', '|', $str);
$data[] = rtrim($str, ' |');
// Run search modules
foreach ($config['wui']['search_modules'] as $module) {
if (is_file($config['html_dir'] . "/includes/search/$module.inc.php")) {
include($config['html_dir'] . "/includes/search/$module.inc.php");
}
}
echo('<li class="divider" style="margin: 0px;"></li>' . PHP_EOL);
echo('<li style="margin: 0px;">' . PHP_EOL . ' <a href="'.$result['url'].'">' . PHP_EOL);
echo(' <dl style="border-left: 10px solid '.$result['colour'].'; " class="dl-horizontal dl-search">' . PHP_EOL);
echo(' <dt style="width: 64px; text-align: center; line-height: 41.5px;">' . get_icon($result['icon']) . '</dt>' . PHP_EOL);
echo(' <dd>' . PHP_EOL);
echo(' <strong>'.html_highlight(escape_html($result['name']), $queryString) . PHP_EOL);
echo(' <small>'. implode('<br />', $data) . '</small>' . PHP_EOL);
echo(' </strong>' . PHP_EOL);
echo(' </dd>' . PHP_EOL);
echo('</dl>' . PHP_EOL);
echo(' </a>' . PHP_EOL);
echo('</li>' . PHP_EOL);
}
}
if (!safe_count($search_results))
{
echo('<li class="nav-header">No search results.</li>');
// Reset query_limit
$query_limit--;
foreach ($search_results as $results) {
$display_count = safe_count($results['results']);
// If there are more results than query_limit (can happen, as we ++'d above), cut array to desired size and add + to counter
if ($display_count > $query_limit) {
$results['results'] = array_slice($results['results'], 0, $query_limit);
$display_count .= '+';
}
echo('<li class="nav-header">' . $results['descr'] . ': ' . $display_count . '</li>' . PHP_EOL);
foreach ($results['results'] as $result) {
$data = [];
foreach ($result['data'] as $str) {
$str = str_replace('| |', '|', $str);
$data[] = rtrim($str, ' |');
}
echo('<li class="divider" style="margin: 0px;"></li>' . PHP_EOL);
echo('<li style="margin: 0px;">' . PHP_EOL . ' <a href="' . $result['url'] . '">' . PHP_EOL);
echo(' <dl style="border-left: 10px solid ' . $result['colour'] . '; " class="dl-horizontal dl-search">' . PHP_EOL);
echo(' <dt style="width: 64px; text-align: center; line-height: 41.5px;">' . get_icon($result['icon']) . '</dt>' . PHP_EOL);
echo(' <dd>' . PHP_EOL);
echo(' <strong>' . html_highlight(escape_html($result['name']), $queryString) . PHP_EOL);
echo(' <small>' . implode('<br />', $data) . '</small>' . PHP_EOL);
echo(' </strong>' . PHP_EOL);
echo(' </dd>' . PHP_EOL);
echo('</dl>' . PHP_EOL);
echo(' </a>' . PHP_EOL);
echo('</li>' . PHP_EOL);
}
}
if (!safe_count($search_results)) {
echo('<li class="nav-header">No search results.</li>');
}
}
}
} else {
// There is no queryString, we shouldn't get here.
echo('<li class="nav-header">There should be no direct access to this script! Please reload the page.</li>');
// There is no queryString, we shouldn't get here.
echo('<li class="nav-header">There should be no direct access to this script! Please reload the page.</li>');
}
// EOF

View File

@ -6,444 +6,283 @@
*
* @package observium
* @subpackage ajax
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
$config['install_dir'] = "../..";
include_once("../../includes/observium.inc.php");
include_once("../../includes/sql-config.inc.php");
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
if (!$_SESSION['authenticated'])
{
echo("unauthenticated");
exit;
if (!$_SESSION['authenticated']) {
echo("unauthenticated");
exit;
}
include_dir($config['html_dir'] . "/includes/widgets/");
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE widget_id = ?", array($_POST['id']));
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE widget_id = ?", [$_POST['id']]);
$widget['height'] = (is_numeric($_POST['height']) ? $_POST['height'] : '3');
$widget['width'] = (is_numeric($_POST['width']) ? $_POST['width'] : '4');
print_dash_mod($widget);
function print_dash_mod ($mod)
function print_dash_mod($mod)
{
global $config;
global $cache;
global $config;
global $cache;
$mod['vars'] = json_decode($mod['widget_config'], TRUE);
$mod['vars'] = json_decode($mod['widget_config'], TRUE);
$width = (is_numeric($mod['width']) ? $mod['width'] : 1240);
$height = (is_numeric($mod['height']) ? $mod['height'] : 80);
$width = (is_numeric($mod['width']) ? $mod['width'] : 1240);
$height = (is_numeric($mod['height']) ? $mod['height'] : 80);
switch ($mod['widget_type'])
{
switch ($mod['widget_type']) {
case "welcome":
echo '<div class="box box-solid do-not-update" style="padding:10px; padding-left: 375px; background-image: url(images/login-hamster-large.png); background-position: left 10px top -100px; background-repeat: no-repeat;">';
echo '<h3>Welcome to your new Observium dashboard!</h3>';
if(isset($mod['vars']['converted']))
{
echo 'This was autogenerated based on your previous front page. It can be modified to suit your requirements.<br />';
} else {
echo 'This is an autogenerated default dashboard. It can be modified to suit your requirements.<br />';
}
echo 'Please see the <strong><a href="'.OBSERVIUM_DOCS_URL.'/dashboard/" target="_blank">documentation</a></strong> for information about how to configure this dashboard. Including how to delete this widget!';
echo '</div>';
break;
case "welcome":
echo '<div class="box box-solid do-not-update" style="padding:10px; padding-left: 375px; background-image: url(images/hamster-login.png); background-position: left 10px top -100px; background-repeat: no-repeat;">';
echo '<h3>Welcome to your new Observium dashboard!</h3>';
if (isset($mod['vars']['converted'])) {
echo 'This was autogenerated based on your previous front page. It can be modified to suit your requirements.<br />';
} else {
echo 'This is an autogenerated default dashboard. It can be modified to suit your requirements.<br />';
}
echo 'Please see the <strong><a href="' . OBSERVIUM_DOCS_URL . '/dashboard/" target="_blank">documentation</a></strong> for information about how to configure this dashboard. Including how to delete this widget!';
echo '</div>';
break;
case "weathermap":
case "weathermap":
echo '<div class="box box-solid do-not-update">';
echo '<div class="box box-solid do-not-update">';
$wmap = dbFetchRow("SELECT * FROM `weathermaps` WHERE `wmap_name` = ?", array($mod['vars']['mapname']));
$wmap = dbFetchRow("SELECT * FROM `weathermaps` WHERE `wmap_name` = ?", [$mod['vars']['mapname']]);
echo ' <div class="hover-hide widget-title" style="z-index: 900; position: absolute; overflow: hidden;" class="widget-title"><h4 style="wwriting-mode: vertical-lr; ttext-orientation: mixed;" class="box-title">' .
'' . htmlentities($wmap['wmap_name']) . '</h4>' .
'</div>' . PHP_EOL;
echo ' <div class="hover-hide widget-title" style="z-index: 900; position: absolute; overflow: hidden;" class="widget-title"><h4 style="wwriting-mode: vertical-lr; ttext-orientation: mixed;" class="box-title">' .
'' . htmlentities($wmap['wmap_name']) . '</h4>' .
'</div>' . PHP_EOL;
echo ' <div class="box-content" style="overflow: hidden">';
echo '<div style="height:100%; overflow:hidden; width: 110%;">';
echo '<a href="'.generate_url(['page' => 'wmap', 'mapname' => $wmap['map_name']]).'">';
echo '<img src="/weathermap.php?mapname=' . htmlentities($wmap['wmap_name']) . '&action=draw&unique=' . time() . '&width='.$width.'&height='.$height.'">';
echo '</a>';
echo ' <div class="box-content" style="overflow: hidden">';
echo '<div style="height:100%; overflow:hidden; width: 110%;">';
echo '<a href="' . generate_url(['page' => 'wmap', 'mapname' => $wmap['map_name']]) . '">';
echo '<img src="/weathermap.php?mapname=' . htmlentities($wmap['wmap_name']) . '&action=draw&unique=' . time() . '&width=' . $width . '&height=' . $height . '">';
echo '</a>';
echo '</div>';
echo ' </div>';
echo '</div>';
echo ' </div>';
echo '</div>';
break;
echo '</div>';
break;
case "map":
echo '<div class="box box-solid do-not-update">';
print_dash_map($mod, $width, $height);
echo '</div>';
break;
case "map":
echo '<div class="box box-solid do-not-update">';
print_dash_map($mod, $width, $height);
echo '</div>';
break;
case "graph":
echo '<div class="box box-solid do-not-update">';
print_dash_graph($mod, $width, $height);
echo '</div>';
break;
case "port_percent":
if ($_SESSION['userlevel'] < 5) {
echo '<div class="box box-solid" style="width: 100%; height: 100%; float:none; display: block; padding: 10px;">';
echo '<div class="alert statusbox alert-warning" style="border-left: 1px; width: 100%; height: 100%; margin-right: 10px; float:none; display: block;">';
echo '<div style="margin: auto; line-height: 75px; text-align: center;">You have insufficient permissions to view this widget.</div>';
echo '</div>';
echo '</div>';
} elseif ($height < 190) {
echo '<div class="box box-solid alert alert-warning" style="width: 100%; height: 100%; float:none; display: block; padding: 10px;">';
echo '<b>WARNING</b> This widget is not tall enough to display the requested content. Module <b>Port Percent</b> requires 190px or taller.';
echo '</div>';
} else {
include($config['html_dir'] . "/includes/status-portpercent.inc.php");
}
break;
case "port_percent":
if($_SESSION['userlevel'] < 5)
{
echo '<div class="box box-solid" style="width: 100%; height: 100%; float:none; display: block; padding: 10px;">';
echo '<div class="alert statusbox alert-warning" style="border-left: 1px; width: 100%; height: 100%; margin-right: 10px; float:none; display: block;">';
echo '<div style="margin: auto; line-height: 75px; text-align: center;">You have insufficient permissions to view this widget.</div>';
echo '</div>';
echo '</div>';
} elseif ($height < 190) {
echo '<div class="box box-solid alert alert-warning" style="width: 100%; height: 100%; float:none; display: block; padding: 10px;">';
echo '<b>WARNING</b> This widget is not tall enough to display the requested content. Module <b>Port Percent</b> requires 190px or taller.';
echo '</div>';
} else {
include($config['html_dir'] . "/includes/status-portpercent.inc.php");
}
break;
case "alert_table":
echo '<div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title">Alert Status</h3></div>';
echo ' <div class="box-content" style="height: ' . ($height - 40) . 'px; overflow: auto;">';
//echo ' <div class="box-content" style="overflow: scroll; overflow-x:scroll;">';
//echo ' <div class="box-content" style="overflow:auto;">';
print_alert_table(['status' => 'failed',
'pagination' => FALSE,
'short' => TRUE]
);
echo ' </div>';
echo ' </div>';
echo '</div>';
break;
case "alert_table":
echo '<div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title">Alert Status</h3></div>';
echo ' <div class="box-content" style="overflow:auto;">';
print_alert_table(array('status' => 'failed',
'pagination' => FALSE,
'short' => TRUE)
);
echo ' </div>';
echo ' </div>';
echo '</div>';
break;
case "status_summary":
echo '<div class="row">';
if ($width > 1000) {
$div_class = "col-md-6";
} else {
$div_class = "col-md-12";
}
case "status_summary":
echo '<div class="row">';
if($width > 1000) { $div_class = "col-md-6"; } else { $div_class = "col-md-12"; }
if ($height < 210) {
$hide_group_bar = 1;
}
if($height < 210) { $hide_group_bar = 1; }
include($config['html_dir'] . '/includes/cache-data.inc.php');
include($config['html_dir'] . "/includes/status-summary.inc.php");
echo '</div>';
break;
include($config['html_dir'] . '/includes/cache-data.inc.php');
include($config['html_dir'] . "/includes/status-summary.inc.php");
echo '</div>';
break;
case "alert_boxes":
case "old_status_boxes":
//r($height);
include($config['html_dir'] . '/includes/cache-data.inc.php');
//$count = round(($width) / 165) * round(($height+10) / 90); // 1.5 wide
$count = floor(($width + 10) / 198) * floor(($height + 10) / 96); // 1.5 wide
echo '<div style="width: auto; height: 100%; overflow-x: visible; overflow-y: visible; margin-right: -25px;">';
if ($mod['widget_type'] == 'alert_boxes') {
print_status_boxes($mod, $count);
} else {
print_status_boxes($config['frontpage']['device_status'], $count);
}
echo '</div>';
break;
case "alert_boxes":
case "old_status_boxes":
//r($height);
include($config['html_dir'] . '/includes/cache-data.inc.php');
//$count = round(($width) / 165) * round(($height+10) / 90); // 1.5 wide
$count = floor(($width+10) / 198) * floor(($height+10) / 96); // 1.5 wide
echo '<div style="width: auto; height: 100%; overflow-x: visible; overflow-y: visible; margin-right: -25px;">';
if($mod['widget_type'] == 'alert_boxes')
{
print_status_boxes($mod, $count);
} else {
print_status_boxes($config['frontpage']['device_status'], $count);
}
echo '</div>';
break;
case "old_status_table":
echo '<div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title">Status Warnings and Notifications</h3></div>';
echo ' <div class="box-content" style="height: ' . ($height - 40) . 'px; overflow: auto;">';
case "old_status_table":
echo '<div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title">Status Warnings and Notifications</h3></div>';
echo ' <div class="box-content" style="height: ' . ($height - 40) .'px; overflow: auto;">';
include($config['html_dir'] . '/includes/cache-data.inc.php');
echo generate_status_table($config['frontpage']['device_status']);
echo generate_box_close();
include($config['html_dir'] . '/includes/cache-data.inc.php');
echo generate_status_table($config['frontpage']['device_status']);
echo generate_box_close();
break;
break;
case "status_donuts":
include($config['html_dir'] . "/includes/status-donuts.inc.php");
break;
case "status_donuts":
include($config['html_dir'] . "/includes/status-donuts.inc.php");
break;
case "syslog":
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/syslog/">Syslog</a></h3></div>';
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
case "syslog":
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/syslog/">Syslog</a></h3></div>';
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
$syslog_vars = array_merge($mod['vars'], ['short' => TRUE, 'pagesize' => ($height - 36) / 26,
'priority' => $config['frontpage']['syslog']['priority']]);
$syslog_vars = $mod['vars'];
print_syslogs($syslog_vars);
$syslog_vars = array_merge($syslog_vars, ['short' => TRUE, 'pagesize' => ($height - 36) / 26,
'priority' => $config['frontpage']['syslog']['priority']]);
echo ' </div>';
echo '</div>';
break;
print_syslogs($syslog_vars);
case "syslog_alerts":
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/syslog_alerts/">Syslog Alerts</a></h3></div>';
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
echo ' </div>';
echo '</div>';
break;
$alertlog_vars = array_merge($mod['vars'], ['short' => TRUE, 'pagesize' => ($height - 36) / 26]);
case "syslog_alerts":
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/syslog_alerts/">Syslog Alerts</a></h3></div>';
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
print_logalert_log(array('short' => TRUE, 'pagesize' => ($height - 36) / 26) );
echo ' </div>';
echo '</div>';
break;
print_logalert_log($alertlog_vars);
case "alertlog":
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/alert_log/">Alert Log</a></h3></div>';
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
print_alert_log_short(array('short' => TRUE, 'pagesize' => ($height - 36) / 26));
echo ' </div>';
echo '</div>';
break;
echo ' </div>';
echo '</div>';
break;
case "eventlog":
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/eventlog/">Eventlog</a></h3></div>';
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
case "alertlog":
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/alert_log/">Alert Log</a></h3></div>';
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
$pagesize = floor(($height - 36) / 26);
//if($width > 1000) { $pagesize -= 3; $short = FALSE; } else { $short = TRUE; }
$alertlog_vars = array_merge($mod['vars'], ['short' => TRUE, 'pagesize' => ($height - 36) / 26]);
print_alert_log($alertlog_vars);
print_events(array('short' => TRUE, 'pagesize' => $pagesize, 'pageno' => 1,
'severity' => $config['frontpage']['eventlog']['severity']));
echo ' </div>';
echo '</div>';
break;
echo ' </div>';
echo '</div>';
break;
case "eventlog":
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/eventlog/">Eventlog</a></h3></div>';
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
$pagesize = floor(($height - 36) / 26);
//if($width > 1000) { $pagesize -= 3; $short = FALSE; } else { $short = TRUE; }
case "realtime":
echo ' <div class="box box-solid do-not-update" style="overflow: hidden;">';
$realtime_link = 'graph-realtime.php?type=bits&amp;id=430082&amp;interval=10';
$eventlog_vars = array_merge($mod['vars'], ['short' => TRUE, 'pagesize' => $pagesize, 'pageno' => 1,
'severity' => $config['frontpage']['eventlog']['severity']]);
?>
<object data="<?php echo($realtime_link); ?>" type="image/svg+xml" width="<?php echo $width; ?>"
height="<?php echo $height; ?>">
<param name="src"
value="graph.php?type=bits&amp;id=<?php echo($port['port_id'] . "&amp;interval=" . $vars['interval']); ?>"/>
Your browser does not support SVG! You need to either use Firefox or Chrome, or download the Adobe SVG
plugin.
</object>
<?php
echo '</div>';
break;
print_events($eventlog_vars);
default:
echo '<div class="grid-stack-item-content box box-solid" style="overflow: hidden; justify-content: center; align-items: center;">';
echo ' <div class="box-content" style="overflow: hidden;">';
echo ' <h3 class="box-title">Unconfigured Module</h3>';
echo ' </div>';
echo '</div>';
break;
}
echo ' </div>';
echo '</div>';
break;
//echo '</div>';
case "realtime":
echo ' <div class="box box-solid do-not-update" style="overflow: hidden;">';
$realtime_link = 'graph-realtime.php?type=bits&amp;id=430082&amp;interval=10';
?>
<object data="<?php echo($realtime_link); ?>" type="image/svg+xml" width="<?php echo $width; ?>"
height="<?php echo $height; ?>">
<param name="src"
value="graph.php?type=bits&amp;id=<?php echo($port['port_id'] . "&amp;interval=" . $vars['interval']); ?>"/>
Your browser does not support SVG! You need to either use Firefox or Chrome, or download the Adobe SVG
plugin.
</object>
<?php
echo '</div>';
break;
default:
$widget_path = $config['html_dir'] . '/includes/widgets/' . $mod['widget_type'] . '.inc.php';
if (is_file($widget_path)) {
include($widget_path);
} else {
echo '<div class="grid-stack-item-content box box-solid" style="overflow: hidden; justify-content: center; align-items: center;">';
echo ' <div class="box-content" style="overflow: hidden;">';
echo ' <h3 class="box-title">Unconfigured Module</h3>';
echo ' </div>';
echo '</div>';
break;
}
}
//echo '</div>';
}
function print_dash_map ($vars, $width, $height)
function print_dash_map($mod, $width, $height)
{
global $config;
global $config;
?>
?>
<style type="text/css">
#map<?php echo $vars['widget_id']; ?> label {
#map<?php echo $mod['widget_id']; ?> label {
width: auto;
display: inline;
}
#map<?php echo $vars['widget_id']; ?> img {
#map<?php echo $mod['widget_id']; ?> img {
max-width: none;
}
#map<?php echo $vars['widget_id']; ?> {
#map<?php echo $mod['widget_id']; ?> {
height: 100%;
width: 100%;
}
</style>
<?php
<?php
echo '<div id="map'.$vars['widget_id'].'"></div>';
echo '<div id="map' . $mod['widget_id'] . '"></div>';
include($config['html_dir']. '/includes/map/leaflet.inc.php');
$vars = $mod['vars']; // set the $vars array to be used mostly by geojson
include($config['html_dir'] . '/includes/map/leaflet.inc.php');
} // End show_map
function print_dash_graph($mod, $width, $height) {
global $config;
$vars = $mod['vars'];
if (!isset($vars['type']))
{
echo '<div style="position: relative; top: 50%; transform: perspective(1px) translateY(-50%); width: 100%; text-align: center;">
<btn class="btn btn-primary" onclick="configWidget(' . $mod['widget_id'] . ')"><i class="icon-signal"/> &nbsp; Select Graph</btn>
</div>';
exit();
}
if (isset($vars['timestamp_from']) && preg_match(OBS_PATTERN_TIMESTAMP, $vars['timestamp_from'])) {
$vars['from'] = strtotime($vars['timestamp_from']);
unset($vars['timestamp_from']);
}
if (isset($vars['timestamp_to']) && preg_match(OBS_PATTERN_TIMESTAMP, $vars['timestamp_to'])) {
$vars['to'] = strtotime($vars['timestamp_to']);
unset($vars['timestamp_to']);
}
// Period alone is sufficient
/*
if (isset($vars['period']))
{
$vars['to'] = "now";
$vars['from'] = "-".$vars['period'];
}
if (!isset($vars['from']))
{
$vars['from'] = $config['time']['day'];
}
if (!isset($vars['to']))
{
$vars['to'] = $config['time']['now'];
}
*/
preg_match('/^(?P<type>[a-z0-9A-Z-]+)_(?P<subtype>.+)/', $vars['type'], $graphtype);
if (OBS_DEBUG) {
print_vars($graphtype);
}
$type = $graphtype['type'];
$subtype = $graphtype['subtype'];
if (is_numeric($vars['device'])) {
$device = device_by_id_cache($vars['device']);
} elseif (!empty($vars['device'])) {
$device = device_by_name($vars['device']);
} elseif ($type === "device" && is_numeric($vars['id'])) {
$device = device_by_id_cache($vars['id']);
}
$preserve_id = $vars['id'];
if (is_file($config['html_dir'] . "/includes/graphs/" . $type . "/auth.inc.php"))
{
include($config['html_dir'] . "/includes/graphs/" . $type . "/auth.inc.php");
}
$vars['id'] = $preserve_id;
if (!$auth) {
print_error_permission();
return;
}
if (isset($config['entities'][$type])) {
$entity = get_entity_by_id_cache($type, $vars['id']);
entity_rewrite($type, $entity);
}
if ($type === 'bgp') {
$entity = get_entity_by_id_cache('bgp_peer', $vars['id']);
entity_rewrite('bgp_peer', $entity);
}
//$device = device_by_id_cache($entity['device_id']);
//$graph_array['type'] = $vars['entity_type'] . '_' . $vars['graph_type'];
//$graph_array['id'] = $vars['entity_id'];
// Generate navbar with subtypes
$graph_array = $vars;
//$graph_array['from'] = '-1day';
//$graph_array['to'] = 'now';
$graph_array['width'] = $width - 76 + 14; // RRD graphs are 75px wider than request value
$graph_array['height'] = $height - 34; //68; // RRD graphs are taller than request value
if ($graph_array['width'] > 350)
{
$graph_array['width'] -= 6;
} // RRD graphs > 350px are 6 px wider because of larger legend font
if ($graph_array['width'] > 350)
{
$graph_array['height'] -= 6;
} // RRD graphs > 350px are 6 px taller because of larger legend font
$title_div = 'top:0px; left: 0px; padding: 4px; border-top-left-radius: 4px; border: 1px solid #e5e5e5; border-left: none; border-top: none; background-color: rgba(255, 255,255, 0.75); ';
$title_div = 'widget-title';
if ($height < 100)
{
$graph_array['height'] = $height;
$graph_array['width'] = $width;
$graph_array['graph_only'] = 'yes';
$title_div = 'top:5px; left: 5px; padding: none; border-radius: 2px; border: 1px solid #e5e5e5; background: rgba(255, 255, 255, 0.7);';
$title_div = 'widget-title-small';
} else {
$graph_array['draw_all'] = 'yes';
}
$t_len = $vars['width'] / 10;
$subtype_text = (isset($config['graph_types'][$type][$subtype]) ? $config['graph_types'][$type][$subtype]['descr'] : nicecase($subtype));
if (!isset($graph_array['title'])) {
if ($type === 'global')
{
$title = "Global :: " . $subtype_text;
} elseif (str_contains($type, "multi")) {
$count = safe_count($graph_array['id']);
$title = $count . ' ' . nicecase(str_replace("multi-", '', $type)) . ' :: ' . $subtype_text;
} else {
$title = device_name($device, $t_len / 2 - 2) . ($type === "device" ? ' :: ' : ' :: ' . truncate($entity['entity_shortname'], 32) . ' :: ' ) . $subtype_text;
}
} else {
$title = $graph_array['title'];
unset($graph_array['title']);
}
//$graph_array['format'] = 'png';
//$graph_array['img_id'] = generate_random_string(5);
//$graph_array['legend'] = 'no';
$graph_array['rigid_height'] = 'yes'; // Force height of graph to be same as height of graph_type.
$graph_array['class'] = 'image-refresh';
$graph = generate_graph_tag($graph_array, TRUE);
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['graph_only']);
unset($link_array['rigid_height']);
unset($link_array['height'], $link_array['width']);
$link = generate_url($link_array);
//echo ' <div class="box-header with-border">' . $device['hostname'] . '<span class="pull-right">' . truncate($entity['entity_name'], 32) . '</span></div>';
echo ' <div class="hover-hide ' . $title_div . '" style="z-index: 900; position: absolute; overflow: hidden;" class="widget-title"><h4 style="wwriting-mode: vertical-lr; ttext-orientation: mixed;" class="box-title">' .
'' . escape_html($title) . '</h4>' .
'</div>' . PHP_EOL;
echo ' <div class="box-content" style="overflow: hidden">';
echo '<div style="height:100%; overflow:hidden; width: 110%;">';
echo '<a href="'.$link.'">'.$graph['img_tag'].'</a>';
echo '</div>';
echo ' </div>';
}
// EOF

View File

@ -3,6 +3,7 @@
Options FollowSymlinks Multiviews
ErrorDocument 404 /error.php?404
RedirectMatch 404 /\.
RewriteEngine on

View File

@ -1,25 +1,33 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webinterface
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webinterface
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
ini_set('allow_url_fopen', 0);
include_once("../includes/sql-config.inc.php");
include_once("../includes/observium.inc.php");
if (!$config['web_iframe'] && is_iframe()) {
print_error_permission("Not allowed to run in a iframe!");
die();
}
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) { if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; } }
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
if (!$_SESSION['authenticated']) {
// not authenticated
die("Unauthenticated");
}
}
require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph.php");
require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph_line.php");
require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph_bar.php");
@ -28,234 +36,219 @@ require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph_date.php");
$vars = get_vars('GET');
if (is_numeric($vars['bill_id']))
{
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'])
{
if (bill_permitted($vars['bill_id']))
{
$bill_id = $vars['bill_id'];
if (is_numeric($vars['bill_id'])) {
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
if (bill_permitted($vars['bill_id'])) {
$bill_id = $vars['bill_id'];
} else {
echo("Unauthorised Access Prohibited.");
exit;
}
} else {
echo("Unauthorised Access Prohibited.");
exit;
$bill_id = $vars['bill_id'];
}
} else {
$bill_id = $vars['bill_id'];
}
} else {
echo("Unauthorised Access Prohibited.");
exit;
echo("Unauthorised Access Prohibited.");
exit;
}
// Workaround for JPGraph 3.5 on Ubuntu per 0015246
if( !function_exists('imageantialias') ) {
function imageantialias( $image, $enabled ) {
return false;
if (!function_exists('imageantialias')) {
function imageantialias($image, $enabled)
{
return FALSE;
}
}
$start = $vars['from'];
$end = $vars['to'];
$xsize = (is_numeric($vars['x']) ? $vars['x'] : "800" );
$ysize = (is_numeric($vars['y']) ? $vars['y'] : "250" );
$start = $vars['from'];
$end = $vars['to'];
$xsize = (is_numeric($vars['x']) ? $vars['x'] : "800");
$ysize = (is_numeric($vars['y']) ? $vars['y'] : "250");
//$count = (is_numeric($_GET['count']) ? $_GET['count'] : "0" );
//$type = (isset($_GET['type']) ? $_GET['type'] : "date" );
//$dur = $end - $start;
//$datefrom = date('Ymthis', $start);
//$dateto = date('Ymthis', $end);
$imgtype = (isset($vars['type']) ? $vars['type'] : "historical" );
$imgbill = (isset($vars['imgbill']) ? $vars['imgbill'] : false);
$yaxistitle = "Bytes";
$imgtype = (isset($vars['type']) ? $vars['type'] : "historical");
$imgbill = (isset($vars['imgbill']) ? $vars['imgbill'] : FALSE);
$yaxistitle = "Bytes";
$in_data = array();
$out_data = array();
$tot_data = array();
$allow_data = array();
$ave_data = array();
$overuse_data = array();
$ticklabels = array();
$in_data = [];
$out_data = [];
$tot_data = [];
$allow_data = [];
$ave_data = [];
$overuse_data = [];
$ticklabels = [];
if ($imgtype == "historical")
{
$i = "0";
if ($imgtype == "historical") {
$i = "0";
foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 12", array($bill_id)) as $data)
{
$datefrom = strftime("%e %b %Y", strtotime($data['bill_datefrom']));
$dateto = strftime("%e %b %Y", strtotime($data['bill_dateto']));
$datelabel = $datefrom."\n".$dateto;
$traf['in'] = $data['traf_in'];
$traf['out'] = $data['traf_out'];
$traf['total'] = $data['traf_total'];
foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 12", [$bill_id]) as $data) {
$datefrom = strftime("%e %b %Y", strtotime($data['bill_datefrom']));
$dateto = strftime("%e %b %Y", strtotime($data['bill_dateto']));
$datelabel = $datefrom . "\n" . $dateto;
$traf['in'] = $data['traf_in'];
$traf['out'] = $data['traf_out'];
$traf['total'] = $data['traf_total'];
if ($data['bill_type'] == "Quota")
{
$traf['allowed'] = $data['bill_allowed'];
$traf['overuse'] = $data['bill_overuse'];
} else {
$traf['allowed'] = "0";
$traf['overuse'] = "0";
if ($data['bill_type'] == "Quota") {
$traf['allowed'] = $data['bill_allowed'];
$traf['overuse'] = $data['bill_overuse'];
} else {
$traf['allowed'] = "0";
$traf['overuse'] = "0";
}
array_push($ticklabels, $datelabel);
array_push($in_data, $traf['in']);
array_push($out_data, $traf['out']);
array_push($tot_data, $traf['total']);
array_push($allow_data, $traf['allowed']);
array_push($overuse_data, $traf['overuse']);
$i++;
//print_vars($data);
}
array_push($ticklabels, $datelabel);
array_push($in_data, $traf['in']);
array_push($out_data, $traf['out']);
array_push($tot_data, $traf['total']);
array_push($allow_data, $traf['allowed']);
array_push($overuse_data, $traf['overuse']);
$i++;
//print_vars($data);
}
if ($i < 12)
{
$y = 12 - $i;
for ($x=0;$x<$y;$x++)
{
$allowed = (($x == "0") ? $traf['allowed'] : "0" );
array_push($in_data, "0");
array_push($out_data, "0");
array_push($tot_data, "0");
array_push($allow_data, $allowed);
array_push($overuse_data, "0");
array_push($ticklabels, "");
}
}
$yaxistitle = "Gigabytes";
$graph_name = "Historical bandwidth over the last 12 billing periods";
if ($i < 12) {
$y = 12 - $i;
for ($x = 0; $x < $y; $x++) {
$allowed = (($x == "0") ? $traf['allowed'] : "0");
array_push($in_data, "0");
array_push($out_data, "0");
array_push($tot_data, "0");
array_push($allow_data, $allowed);
array_push($overuse_data, "0");
array_push($ticklabels, "");
}
}
$yaxistitle = "Gigabytes";
$graph_name = "Historical bandwidth over the last 12 billing periods";
} else {
$data = array();
$average = 0;
if ($imgtype == "day")
{
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data)
{
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
$datelabel = strftime("%e\n%b", $data['timestamp']);
array_push($ticklabels, $datelabel);
array_push($in_data, $traf['in']);
array_push($out_data, $traf['out']);
array_push($tot_data, $traf['total']);
$average += $data['traf_total'];
$data = [];
$average = 0;
if ($imgtype == "day") {
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", [$bill_id, $start, $end]) as $data) {
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
$datelabel = strftime("%e\n%b", $data['timestamp']);
array_push($ticklabels, $datelabel);
array_push($in_data, $traf['in']);
array_push($out_data, $traf['out']);
array_push($tot_data, $traf['total']);
$average += $data['traf_total'];
}
$ave_count = count($tot_data);
if ($imgbill != FALSE) {
$days = strftime("%e", date($end - $start)) - $ave_count - 1;
for ($x = 0; $x < $days; $x++) {
array_push($ticklabels, "");
array_push($in_data, 0);
array_push($out_data, 0);
array_push($tot_data, 0);
}
}
} elseif ($imgtype == "hour") {
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY HOUR(timestamp) ORDER BY timestamp ASC", [$bill_id, $start, $end]) as $data) {
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
$datelabel = strftime("%H:%M", $data['timestamp']);
array_push($ticklabels, $datelabel);
array_push($in_data, $traf['in']);
array_push($out_data, $traf['out']);
array_push($tot_data, $traf['total']);
$average += $data['traf_total'];
}
$ave_count = count($tot_data);
}
$ave_count = count($tot_data);
if ($imgbill != false)
{
$days = strftime("%e", date($end - $start)) - $ave_count - 1;
for ($x=0;$x<$days;$x++)
{
array_push($ticklabels, "");
array_push($in_data, 0);
array_push($out_data, 0);
array_push($tot_data, 0);
}
}
} elseif ($imgtype == "hour")
{
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY HOUR(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data)
{
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
$datelabel = strftime("%H:%M", $data['timestamp']);
array_push($ticklabels, $datelabel);
array_push($in_data, $traf['in']);
array_push($out_data, $traf['out']);
array_push($tot_data, $traf['total']);
$average += $data['traf_total'];
}
$ave_count = count($tot_data);
}
$decimal = 0;
$average = $average / $ave_count;
for ($x = 0; $x <= count($tot_data); $x++)
{
array_push($ave_data, $average);
}
$graph_name = date('M j g:ia', $start)." - ".date('M j g:ia', $end);
$decimal = 0;
$average = $average / $ave_count;
for ($x = 0; $x <= count($tot_data); $x++) {
array_push($ave_data, $average);
}
$graph_name = date('M j g:ia', $start) . " - " . date('M j g:ia', $end);
}
// Create the graph. These two calls are always required
$graph = new Graph($xsize, $ysize, $graph_name);
$graph->img->SetImgFormat("png");
$graph -> img -> SetImgFormat("png");
#$graph->SetScale("textlin",0,0,$start,$end);
$graph->SetScale("textlin");
$graph -> SetScale("textlin");
#$graph->title->Set("$graph_name");
$graph->title->SetFont(FF_FONT2, FS_BOLD, 10);
$graph->SetMarginColor("white");
$graph->SetFrame(false);
$graph->SetMargin("75", "30", "30", "65");
$graph->legend->SetFont(FF_FONT1, FS_NORMAL);
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos("0.52", "0.91", "center");
$graph -> title -> SetFont(FF_FONT2, FS_BOLD, 10);
$graph -> SetMarginColor("white");
$graph -> SetFrame(FALSE);
$graph -> SetMargin("75", "30", "30", "65");
$graph -> legend -> SetFont(FF_FONT1, FS_NORMAL);
$graph -> legend -> SetLayout(LEGEND_HOR);
$graph -> legend -> Pos("0.52", "0.91", "center");
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetPos('min');
$graph->xaxis->SetTitleMargin(30);
$graph->xaxis->SetTickLabels($ticklabels);
$graph->xgrid->Show(true,true);
$graph->xgrid->SetColor('#e0e0e0','#efefef');
$graph -> xaxis -> SetFont(FF_FONT1, FS_BOLD);
$graph -> xaxis -> SetPos('min');
$graph -> xaxis -> SetTitleMargin(30);
$graph -> xaxis -> SetTickLabels($ticklabels);
$graph -> xgrid -> Show(TRUE, TRUE);
$graph -> xgrid -> SetColor('#e0e0e0', '#efefef');
$graph->yaxis->SetFont(FF_FONT1);
$graph->yaxis->SetTitleMargin(50);
$graph->yaxis->title->SetFont(FF_FONT1, FS_NORMAL, 10);
$graph->yaxis->title->Set("Bytes Transferred");
$graph->yaxis->SetLabelFormatCallback('format_bytes_billing');
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#FFFFFF@0.5');
$graph -> yaxis -> SetFont(FF_FONT1);
$graph -> yaxis -> SetTitleMargin(50);
$graph -> yaxis -> title -> SetFont(FF_FONT1, FS_NORMAL, 10);
$graph -> yaxis -> title -> Set("Bytes Transferred");
$graph -> yaxis -> SetLabelFormatCallback('format_bytes_billing');
$graph -> ygrid -> SetFill(TRUE, '#EFEFEF@0.5', '#FFFFFF@0.5');
// Create the bar plots
$barplot_tot = new BarPlot($tot_data);
$barplot_tot->SetLegend("Traffic total");
$barplot_tot->SetColor('darkgray');
$barplot_tot->SetFillColor('lightgray@0.4');
$barplot_tot->value->Show();
$barplot_tot->value->SetFormatCallback('format_bytes_billing_short');
$barplot_tot -> SetLegend("Traffic total");
$barplot_tot -> SetColor('darkgray');
$barplot_tot -> SetFillColor('lightgray@0.4');
$barplot_tot -> value -> Show();
$barplot_tot -> value -> SetFormatCallback('format_bytes_billing_short');
$barplot_in = new BarPlot($in_data);
$barplot_in->SetLegend("Traffic In");
$barplot_in->SetColor('#'.$config['graph_colours']['greens'][1]);
$barplot_in->SetFillColor('#'.$config['graph_colours']['greens'][0]);
$barplot_in->SetWeight(1);
$barplot_in -> SetLegend("Traffic In");
$barplot_in -> SetColor('#' . $config['graph_colours']['greens'][1]);
$barplot_in -> SetFillColor('#' . $config['graph_colours']['greens'][0]);
$barplot_in -> SetWeight(1);
$barplot_out = new BarPlot($out_data);
$barplot_out->SetLegend("Traffic Out");
$barplot_out->SetColor('#'.$config['graph_colours']['blues'][0]);
$barplot_out->SetFillColor('#'.$config['graph_colours']['blues'][1]);
$barplot_out->SetWeight(1);
$barplot_out -> SetLegend("Traffic Out");
$barplot_out -> SetColor('#' . $config['graph_colours']['blues'][0]);
$barplot_out -> SetFillColor('#' . $config['graph_colours']['blues'][1]);
$barplot_out -> SetWeight(1);
if ($imgtype == "historical")
{
$barplot_over = new BarPlot($overuse_data);
$barplot_over->SetLegend("Traffic Overusage");
$barplot_over->SetColor('darkred');
$barplot_over->SetFillColor('lightred@0.4');
$barplot_over->SetWeight(1);
if ($imgtype == "historical") {
$barplot_over = new BarPlot($overuse_data);
$barplot_over -> SetLegend("Traffic Overusage");
$barplot_over -> SetColor('darkred');
$barplot_over -> SetFillColor('lightred@0.4');
$barplot_over -> SetWeight(1);
$lineplot_allow = new LinePlot($allow_data);
$lineplot_allow->SetLegend("Traffic Allowed");
$lineplot_allow->SetColor('black');
$lineplot_allow->SetWeight(1);
$lineplot_allow = new LinePlot($allow_data);
$lineplot_allow -> SetLegend("Traffic Allowed");
$lineplot_allow -> SetColor('black');
$lineplot_allow -> SetWeight(1);
$gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out, $barplot_over));
$gbplot = new GroupBarPlot([$barplot_in, $barplot_tot, $barplot_out, $barplot_over]);
} else {
$lineplot_allow = new LinePlot($ave_data);
//$lineplot_allow->SetLegend("Average per ".$imgtype);
$lineplot_allow->SetLegend("Average");
$lineplot_allow->SetColor('black');
$lineplot_allow->SetWeight(1);
$lineplot_allow = new LinePlot($ave_data);
//$lineplot_allow->SetLegend("Average per ".$imgtype);
$lineplot_allow -> SetLegend("Average");
$lineplot_allow -> SetColor('black');
$lineplot_allow -> SetWeight(1);
$gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out));
$gbplot = new GroupBarPlot([$barplot_in, $barplot_tot, $barplot_out]);
}
$graph->Add($gbplot);
$graph->Add($lineplot_allow);
$graph -> Add($gbplot);
$graph -> Add($lineplot_allow);
// Display the graph
$graph->Stroke();
$graph -> Stroke();
// EOF

View File

@ -1,5 +1,5 @@
/**
* easymde v2.17.0
* easymde v2.18.0
* Copyright Jeroen Akkerman
* @link https://github.com/ionaru/easy-markdown-editor
* @license MIT

View File

@ -6025,6 +6025,8 @@ a .icon-flip-vertical:before {
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
/*scrollbar-width: thin;
scrollbar-color: rgba(128, 128, 128, 0.2) @brand-border;*/
}
.dropdown-menu.pull-right {
right: 0;
@ -6045,16 +6047,22 @@ a .icon-flip-vertical:before {
color: #333333;
white-space: nowrap;
}
.dropdown-menu ::-webkit-scrollbar {
.dropdown-menu::-webkit-scrollbar-track {
background-color: #f9f9f9;
}
.dropdown-menu::-webkit-scrollbar-corner {
background-color: #f9f9f9;
}
.dropdown-menu::-webkit-scrollbar {
width: 10px;
height: 10px;
/* background-color: @box-header-bg; */
}
.dropdown-menu ::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 65px rgba(0, 0, 0, 0.3);
.dropdown-menu::-webkit-scrollbar-thumb {
border-radius: 2px;
}
.dropdown-menu ::-webkit-scrollbar-thumb {
border-radius: 2px;
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.6);
background-color: #dddddd;
border: 2px solid #f9f9f9;
/*border: 2px solid @box-header-bg;*/
}
/*
.navbar-narrow .dropdown-menu {
@ -6831,10 +6839,7 @@ i.menu-icon,
box-shadow: none;
}
.box-body {
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
border-radius: 0 0 3px 3px;
padding: 10px;
}
.no-header .box-body {
@ -6858,22 +6863,13 @@ i.menu-icon,
margin: -9px;
}
.box-body .box-pane {
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 3px;
border-radius: 0 0 0 3px;
}
.box-body .box-pane-right {
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 0;
border-radius: 0 0 3px 0;
}
.box-footer {
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
border-radius: 0 0 3px 3px;
border-top: 1px solid #f4f4f4;
border-top: none;
padding: 10px;
@ -6902,6 +6898,27 @@ i.menu-icon,
background-repeat: no-repeat;
}
}
.box-content {
/*scrollbar-width: thin;
scrollbar-color: rgba(128, 128, 128, 0.2) @brand-border;*/
}
.box-content::-webkit-scrollbar-track {
background-color: #f9f9f9;
}
.box-content::-webkit-scrollbar-corner {
background-color: #f9f9f9;
}
.box-content::-webkit-scrollbar {
width: 10px;
height: 10px;
/* background-color: @box-header-bg; */
}
.box-content::-webkit-scrollbar-thumb {
border-radius: 2px;
background-color: #dddddd;
border: 2px solid #f9f9f9;
/*border: 2px solid @box-header-bg;*/
}
.fade {
opacity: 0;
-moz-transition: opacity 0.15s linear;
@ -10635,20 +10652,6 @@ x:-o-prefocus,
.grid-stack > .grid-stack-item > .grid-stack-item-content {
z-index: unset!important;
}
.box-content::-webkit-scrollbar-track {
background-color: #dddddd;
}
.box-content::-webkit-scrollbar {
width: 10px;
height: 10px;
background-color: #fafafa;
}
.box-content::-webkit-scrollbar-thumb {
border-radius: 10px;
background-color: #333333;
background-color: rgba(128, 128, 128, 0.2);
border: 2px solid #fafafa;
}
.widget-title {
top: 3px;
left: 4px;

View File

@ -6,32 +6,35 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
include_once("../includes/observium.inc.php");
include_once("../includes/sql-config.inc.php");
if (!$config['web_iframe'] && is_iframe()) {
print_error_permission("Not allowed to run in a iframe!");
die();
}
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id']))) {
$port = get_port_by_id($_GET['id']);
$device = device_by_id_cache($port['device_id']);
//$title = generate_device_link($device);
//$title .= " :: Port ".generate_port_link($port);
$auth = TRUE;
$port = get_port_by_id($_GET['id']);
$device = device_by_id_cache($port['device_id']);
//$title = generate_device_link($device);
//$title .= " :: Port ".generate_port_link($port);
$auth = TRUE;
$time = time();
$HC = ($port['port_64bit'] ? 'HC' : '');
$HC = $port['port_64bit'] ? 'HC' : '';
$data = snmp_get_multi_oid($device, "if{$HC}InOctets.".$port['ifIndex']." if{$HC}OutOctets.".$port['ifIndex'], [], "IF-MIB");
$data = snmp_get_multi_oid($device, "if{$HC}InOctets." . $port['ifIndex'] . " if{$HC}OutOctets." . $port['ifIndex'], [], "IF-MIB");
printf("%lf|%s|%s\n", $time, $data[$port['ifIndex']]["if{$HC}InOctets"], $data[$port['ifIndex']]["if{$HC}OutOctets"]);
printf("%lf|%s|%s\n", $time, $data[$port['ifIndex']]["if{$HC}InOctets"], $data[$port['ifIndex']]["if{$HC}OutOctets"]);
} else {
echo("unauthenticated");
exit;
// not authenticated
die("Unauthenticated");
}
// EOF

18
html/error.php Normal file
View File

@ -0,0 +1,18 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
include_once("../includes/observium.inc.php");
//r(array_key_first($_GET));
display_error_http(array_key_first($_GET));
// EOF

View File

@ -6,24 +6,16 @@
*
* @package observium
* @subpackage feed
* @author Mike Stupalov <mike@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
/*
if (isset($_GET['debug']) && $_GET['debug'])
{
ini_set('display_errors', 1);
ini_set('display_startup_errors', 0);
ini_set('log_errors', 0);
ini_set('allow_url_fopen', 0);
ini_set('error_reporting', E_ALL);
}
*/
include_once("../includes/sql-config.inc.php");
include_once("../includes/observium.inc.php");
if (is_iframe()) {
display_error_http(403, 'Not allowed to run in a iframe');
}
include($config['html_dir'] . "/includes/functions.inc.php");
//include($config['html_dir'] . "/includes/authenticate.inc.php"); // not for RSS!
$auth = FALSE;
@ -31,167 +23,141 @@ $vars = get_vars('GET');
// Auth
if (isset($vars['hash']) && strlen($vars['hash']) >= 16 &&
is_numeric($vars['id']) && $vars['id'] > 0)
{
$key = get_user_pref($vars['id'], 'atom_key');
if ($key)
{
// Check hash auth
if ($data = decrypt($vars['hash'], $key))
{
//var_dump($data);
$data = explode('|', $data); // user_id|user_level|auth_mechanism
is_numeric($vars['id']) && $vars['id'] > 0) {
$key = get_user_pref($vars['id'], 'atom_key');
if ($key) {
// Check hash auth
if ($data = decrypt($vars['hash'], $key)) {
//var_dump($data);
$data = explode('|', $data); // user_id|user_level|auth_mechanism
$data_c = count($data);
if ($data_c == 3)
{
$user_id = $data[0];
$user_level = $data[1]; // FIXME, need new way for check userlevel, because it can be changed
$check_auth_mechanism = $config['auth_mechanism'] == $data[2];
$data_c = count($data);
if ($data_c == 3) {
$user_id = $data[0];
$user_level = $data[1]; // FIXME, need new way for check userlevel, because it can be changed
$check_auth_mechanism = $config['auth_mechanism'] == $data[2];
// Now set auth
$auth = $check_auth_mechanism && $user_level > 0 && $user_id == $vars['id'];
}
//else if ($data_c == 2)
//{
// // Force delete old keys without auth_mechanism
//}
// Now set auth
$auth = $check_auth_mechanism && $user_level > 0 && $user_id == $vars['id'];
}
//else if ($data_c == 2)
//{
// // Force delete old keys without auth_mechanism
//}
}
}
}
}
//var_dump($auth);
if (!$auth)
{
//header("HTTP/1.1 401 Unauthorized"); // This force basic auth form (login/password), which unsupported here
header("HTTP/1.1 403 Forbidden");
if ($vars)
{
?>
<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Update feed url</H2>
</BODY>
</HTML>
<?php
}
exit;
if (!$auth) {
display_error_http(401, 'Update feed url');
}
// End auth
session_start();
$_SESSION['user_id'] = $user_id;
$_SESSION['userlevel'] = $user_level;
session_start();
$_SESSION['user_id'] = $user_id;
$_SESSION['userlevel'] = $user_level;
$permissions = permissions_cache($_SESSION['user_id']);
session_commit();
$permissions = permissions_cache($_SESSION['user_id']);
session_write_close();
include($config['html_dir'] . "/includes/cache-data.inc.php"); // Need for check permissions
include($config['html_dir'] . "/includes/cache-data.inc.php"); // Need for check permissions
$use_rss = ($vars['v'] == 'rss' ? TRUE : FALSE); // In most cases used ATOM feed
$param = array('short' => TRUE, 'pagesize' => 25);
if (is_numeric($vars['size']))
{
$param['pagesize'] = $vars['size'];
}
$use_rss = $vars['v'] === 'rss'; // In most cases used ATOM feed
$param = ['short' => TRUE, 'pagesize' => 25];
if (is_numeric($vars['size'])) {
$param['pagesize'] = $vars['size'];
}
// base feed info
$base_url = rtrim($GLOBALS['config']['base_url'], '/');
$feed_generator = OBSERVIUM_PRODUCT.' '.OBSERVIUM_VERSION;
$feed_title = 'Observium ['.$_SERVER["SERVER_NAME"].'] :: Eventlog Feed';
$feed_description = "Latest eventlogs from observium on $base_url";
$feed_link = $base_url.'/eventlog/';
// base feed info
$base_url = rtrim($GLOBALS['config']['base_url'], '/');
$feed_generator = OBSERVIUM_PRODUCT . ' ' . OBSERVIUM_VERSION;
$feed_title = 'Observium [' . $_SERVER["SERVER_NAME"] . '] :: Eventlog Feed';
$feed_description = "Latest eventlogs from observium on $base_url";
$feed_link = $base_url . '/eventlog/';
$events = get_events_array($param);
if ($use_rss)
{
// create rss
// See format options here: http://validator.w3.org/feed/docs/rss2.html
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"></rss>');
$xml->addChild('channel');
$xml->channel->addChild('title', $feed_title);
$xml->channel->addChild('description', $feed_description);
$xml->channel->addChild('link', $feed_link);
$xml->channel->addChild('language', 'en-us');
$xml->channel->addChild('generator', $feed_generator);
$xml->channel->addChild('pubDate', date(DATE_RSS, strtotime($events['updated'])));
$xml->channel->addChild('ttl', '5'); // a number of minutes that indicates how long a channel can be cached before refreshing
} else {
// create atom
// See format options here: http://validator.w3.org/feed/docs/atom.html
$atom_ns = 'http://www.w3.org/2005/Atom';
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><feed xml:lang="en-US" xmlns="'.$atom_ns.'"></feed>');
$xml->addChild('title', $feed_title);
$xml->addChild('subtitle', $feed_description);
$xml->addChild('id', $feed_link);
$xml->addChild('icon', $base_url.'/'.$GLOBALS['config']['favicon']);
$xml->addChild('link');
$xml->link->addAttribute('href', $feed_link);
$self_link = $xml->addChild('link', '', $atom_ns);
$self_link->addAttribute('href', $base_url.$_SERVER['REQUEST_URI']);
$self_link->addAttribute('rel', 'self');
$self_link->addAttribute('type', 'application/atom+xml');
$xml->addChild('generator', $feed_generator);
$xml->addChild('updated', date(DATE_ATOM, strtotime($events['updated'])));
}
$events = get_events_array($param);
if ($use_rss) {
// create rss
// See format options here: http://validator.w3.org/feed/docs/rss2.html
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"></rss>');
$xml -> addChild('channel');
$xml -> channel -> addChild('title', $feed_title);
$xml -> channel -> addChild('description', $feed_description);
$xml -> channel -> addChild('link', $feed_link);
$xml -> channel -> addChild('language', 'en-us');
$xml -> channel -> addChild('generator', $feed_generator);
$xml -> channel -> addChild('pubDate', date(DATE_RSS, strtotime($events['updated'])));
$xml -> channel -> addChild('ttl', '5'); // a number of minutes that indicates how long a channel can be cached before refreshing
} else {
// create atom
// See format options here: http://validator.w3.org/feed/docs/atom.html
$atom_ns = 'http://www.w3.org/2005/Atom';
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><feed xml:lang="en-US" xmlns="' . $atom_ns . '"></feed>');
$xml -> addChild('title', $feed_title);
$xml -> addChild('subtitle', $feed_description);
$xml -> addChild('id', $feed_link);
$xml -> addChild('icon', $base_url . '/' . $GLOBALS['config']['favicon']);
$xml -> addChild('link');
$xml -> link -> addAttribute('href', $feed_link);
$self_link = $xml -> addChild('link', '', $atom_ns);
$self_link -> addAttribute('href', $base_url . $_SERVER['REQUEST_URI']);
$self_link -> addAttribute('rel', 'self');
$self_link -> addAttribute('type', 'application/atom+xml');
$xml -> addChild('generator', $feed_generator);
$xml -> addChild('updated', date(DATE_ATOM, strtotime($events['updated'])));
}
foreach ($events['entries'] as $entry)
{
$entry_device = device_by_id_cache($entry['device_id']);
$entry_vars = array('page' => 'device',
'device' => $entry['device_id'],
'tab' => 'logs',
'section' => 'eventlog',
'type' => $entry['type'],
'timestamp_from' => $entry['timestamp'],
'timestamp_to' => $entry['timestamp']);
$entry_title = escape_html('['.$entry_device['hostname'].'] '.$entry['message']);
$entry_description = escape_html('['.$entry_device['hostname']."]\n".strtoupper($entry['type']).': '.$entry['message']);
$entry_link = $base_url.'/'.generate_device_url($entry_device, $entry_vars);
$entry_id = $entry_link.'guid='.md5($entry['event_id']);
foreach ($events['entries'] as $entry) {
$entry_device = device_by_id_cache($entry['device_id']);
$entry_vars = ['page' => 'device',
'device' => $entry['device_id'],
'tab' => 'logs',
'section' => 'eventlog',
'type' => $entry['type'],
'timestamp_from' => $entry['timestamp'],
'timestamp_to' => $entry['timestamp']];
$entry_title = escape_html('[' . $entry_device['hostname'] . '] ' . $entry['message']);
$entry_description = escape_html('[' . $entry_device['hostname'] . "]\n" . strtoupper($entry['type']) . ': ' . $entry['message']);
$entry_link = $base_url . '/' . generate_device_url($entry_device, $entry_vars);
$entry_id = $entry_link . 'guid=' . md5($entry['event_id']);
if ($use_rss)
{
if ($use_rss) {
// add item element for each article
$item = $xml->channel->addChild('item');
$item->addChild('title', $entry_title);
$item->addChild('description', $entry_description);
$item->addChild('guid', $entry_id);
$item->addChild('link', $entry_link);
$item->addChild('h:dc:creator', $entry['type']);
$item->addChild('pubDate', date(DATE_RSS, strtotime($entry['timestamp'])));
} else {
$item = $xml -> channel -> addChild('item');
$item -> addChild('title', $entry_title);
$item -> addChild('description', $entry_description);
$item -> addChild('guid', $entry_id);
$item -> addChild('link', $entry_link);
$item -> addChild('h:dc:creator', $entry['type']);
$item -> addChild('pubDate', date(DATE_RSS, strtotime($entry['timestamp'])));
} else {
// add entry element for each article
$item = $xml->addChild('entry');
$item->addChild('title', $entry_title);
$item->addChild('summary', $entry_description);
$item->addChild('id', $entry_id);
$item->addChild('link');
$item->link->addAttribute('href', $entry_link);
$item->addChild('author');
$item->author->addChild('name', $entry['type']);
$item->addChild('updated', date(DATE_ATOM, strtotime($entry['timestamp'])));
}
$item = $xml -> addChild('entry');
$item -> addChild('title', $entry_title);
$item -> addChild('summary', $entry_description);
$item -> addChild('id', $entry_id);
$item -> addChild('link');
$item -> link -> addAttribute('href', $entry_link);
$item -> addChild('author');
$item -> author -> addChild('name', $entry['type']);
$item -> addChild('updated', date(DATE_ATOM, strtotime($entry['timestamp'])));
}
}
// Unset & destroy session
session_unset();
session_destroy();
// Unset & destroy session
session_unset();
session_destroy();
// Print feed
header('Content-Type: text/xml; charset=utf-8');
echo $xml->asXML();
// Print feed
header('Content-Type: text/xml; charset=utf-8');
echo $xml -> asXML();
// DOCME needs phpdoc block
function content_cdata($content)
{
return '<![CDATA['.$content.']]>';
return '<![CDATA[' . $content . ']]>';
}
// EOF

View File

@ -1,100 +0,0 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
ini_set('allow_url_fopen', 0);
include_once("../includes/sql-config.inc.php");
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
include($config['html_dir'] . "/includes/cache-data.inc.php");
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
}
$vars = get_vars('GET');
$geo = array();
foreach ($GLOBALS['cache']['devices']['id'] as $device)
{
if (!$config['web_show_disabled'] && $device["disabled"]) { continue; }
$lat = (is_numeric($device['location_lat']) ? $device['location_lat'] : $config['geocoding']['default']['lat']);
$lon = (is_numeric($device['location_lon']) ? $device['location_lon'] : $config['geocoding']['default']['lon']);
if ($device["status"] == "0")
{
if ($device["ignore"] == "0")
{
$locations[$lat][$lon]["down_hosts"][] = $device;
}
} else {
$locations[$lat][$lon]["up_hosts"][] = $device;
}
}
foreach ($locations as $la => $lat)
{
foreach ($lat as $lo => $lon)
{
$tooltip = "";
$num_up = safe_count($lon["up_hosts"]);
$num_down = safe_count($lon["down_hosts"]);
$total_hosts = $num_up + $num_down;
$tooltip = '<p><span class="label label-success">Up '.$num_up.'</span> <span class="label label-error">Down '.$num_down.'</span></p>';
$state = 'unknown';
$location_name = "";
if ($num_down > 0)
{
$state = 'down';
$location_name = ($lon['down_hosts'][0]['location'] === '' ? OBS_VAR_UNSET : $lon['down_hosts'][0]['location']);
$location_url = generate_location_url($lon['down_hosts'][0]['location']);
}
elseif ($num_up > 0)
{
$state = 'up';
$location_name = ($lon['up_hosts'][0]['location'] === '' ? OBS_VAR_UNSET : $lon['up_hosts'][0]['location']);
$location_url = generate_location_url($lon['up_hosts'][0]['location']);
}
$tooltip = "<h3>".$location_name."</h3><hr />".$tooltip;
foreach ($lon["down_hosts"] as $down_host) {
$tooltip .= '<span class="label label-error">' . escape_html($down_host['hostname']) .'</span> ';
}
$feature = array('geometry' => array('type' => 'Point',
'coordinates' => array((float)$lo, (float)$la)),
'type' => 'Feature',
'properties' => array('name' => $location_name,
'state' => $state,
'id' => safename($location_name),
'popupContent' => $tooltip,
'url' => $location_url));
$features[] = $feature;
//echo "[$la, $lo, $num_up, $num_down, \"$tooltip\", '$location_name', '$location_url'],\n ";
}
}
$geo = array('type' => 'FeatureCollection', 'features' => $features);
header('Content-type: application/javascript');
//echo 'var geojson = ' . json_encode($geo) . ';';
//print_r($features);
echo safe_json_encode($geo);
//r($geo);
// EOF

View File

@ -12,9 +12,16 @@
*
*/
include_once("../includes/sql-config.inc.php");
include_once("../includes/observium.inc.php");
if (!$config['web_iframe'] && is_iframe() &&
!http_match_referer('!/device/device=\d+/tab=port/.*?/view=realtime/!')) {
//bdump($_SERVER['HTTP_SEC_FETCH_DEST']);
//bdump($_SERVER['HTTP_REFERER']); //'HTTP_SEC_FETCH_SITE' => 'same-origin'
print_error_permission("Not allowed to run in a iframe!");
die();
}
include($config['html_dir'] . "/includes/functions.inc.php");
include($config['html_dir'] . "/includes/authenticate.inc.php");
// Push $_GET into $vars to be compatible with web interface naming
@ -22,66 +29,59 @@ $vars = get_vars('GET');
if (is_numeric($vars['id']) && ($config['allow_unauth_graphs'] || port_permitted($vars['id'])))
{
$port = get_port_by_id($vars['id']);
$device = device_by_id_cache($port['device_id']);
$title = generate_device_link($device);
$title .= " :: Port ".generate_port_link($port);
$auth = TRUE;
$port = get_port_by_id_cache($vars['id']);
$device = device_by_id_cache($port['device_id']);
$title = generate_device_link($device);
$title .= " :: Port " . generate_port_link($port);
$auth = TRUE;
} else {
echo("Unauthenticated");
die;
// not authenticated
die("Unauthenticated");
}
header("Content-type: image/svg+xml");
/********** HTTP GET Based Conf ***********/
$ifnum = $port['ifIndex']; // BSD / SNMP interface name / number
$ifname = escape_html($port['port_label']); //Interface name that will be showed on top right of graph
$ifnum = $port['ifIndex']; // BSD / SNMP interface name / number
$ifname = escape_html($port['port_label']); //Interface name that will be showed on top right of graph
//$hostname = short_hostname($device['hostname']);
$hostname = escape_html(device_name($device, TRUE));
if($vars['title']) { $ifname = escape_html($vars['title']); }
if ($vars['title']) { $ifname = escape_html($vars['title']); }
/********* Other conf *******/
$scale_type="follow"; //Autoscale default setup : "up" = only increase scale; "follow" = increase and decrease scale according to current graphed datas
$nb_plot=240; //NB plot in graph
$scale_type = "follow"; // Autoscale default setup : "up" = only increase scale; "follow" = increase and decrease scale according to current graphed datas
$nb_plot = 240; // NB plot in graph
if (is_numeric($vars['interval']))
{
$time_interval = $vars['interval'];
} else {
$time_interval = 1; // Refresh time Interval
// Refresh time Interval
$time_interval = is_numeric($vars['interval']) ? $vars['interval'] : 1;
$fetch_link = "data.php?id=" . $vars['id'];
if (OBS_DEBUG) {
$fetch_link .= '&amp;debug=yes';
}
$fetch_link = "data.php?id=".$vars['id'];
if (OBS_DEBUG)
{
$fetch_link .= '&amp;debug=yes';
}
//SVG attributes
$attribs['axis']='fill="black" stroke="black"';
$attribs['in']='fill="green" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
$attribs['out']='fill="blue" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
$attribs['graph_in']='fill="none" stroke="green" stroke-opacity="0.8"';
$attribs['graph_out']='fill="none" stroke="blue" stroke-opacity="0.8"';
$attribs['legend']='fill="black" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4"';
$attribs['graphname']='fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="9"';
$attribs['hostname']='fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="6"';
$attribs['grid_txt']='fill="gray" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="6"';
$attribs['grid']='stroke="gray" stroke-opacity="0.5"';
$attribs['switch_unit']='fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4" text-decoration="underline"';
$attribs['switch_scale']='fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4" text-decoration="underline"';
$attribs['error']='fill="blue" font-family="Arial" font-size="4"';
$attribs['collect_initial']='fill="gray" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4"';
// SVG attributes
$attribs['axis'] = 'fill="black" stroke="black"';
$attribs['in'] = 'fill="green" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
$attribs['out'] = 'fill="blue" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
$attribs['graph_in'] = 'fill="none" stroke="green" stroke-opacity="0.8"';
$attribs['graph_out'] = 'fill="none" stroke="blue" stroke-opacity="0.8"';
$attribs['legend'] = 'fill="black" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4"';
$attribs['graphname'] = 'fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="9"';
$attribs['hostname'] = 'fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="6"';
$attribs['grid_txt'] = 'fill="gray" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="6"';
$attribs['grid'] = 'stroke="gray" stroke-opacity="0.5"';
$attribs['switch_unit'] = 'fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4" text-decoration="underline"';
$attribs['switch_scale'] = 'fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4" text-decoration="underline"';
$attribs['error'] = 'fill="blue" font-family="Arial" font-size="4"';
$attribs['collect_initial'] = 'fill="gray" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4"';
//Error text if we cannot fetch data : depends on which method is used
$error_text = "Can't get data about port $ifnum";
$height=125; //SVG internal height : do not modify
$width=300; //SVG internal width : do not modify
$height = 125; // SVG internal height : do not modify
$width = 300; // SVG internal width : do not modify
/********* Graph DATA **************/
print('<?xml version="1.0" encoding="iso-8859-1"?>' . PHP_EOL);
@ -94,23 +94,23 @@ print('<?xml version="1.0" encoding="iso-8859-1"?>' . PHP_EOL);
<line id="axis_y" x1="0" y1="100%" x2="100%" y2="100%" <?php echo($attribs['axis']) ?>/>
<path id="graph_out" d="M0 <?php echo($height) ?> L 0 <?php echo($height); ?>" <?php echo($attribs['graph_out']) ?>/>
<path id="graph_in" d="M0 <?php echo($height) ?> L 0 <?php echo($height); ?>" <?php echo($attribs['graph_in']) ?>/>
<path id="grid" d="M0 <?php echo($height/4*1) ?> L <?php echo($width) ?> <?php echo($height/4*1) ?> M0 <?php echo($height/4*2) ?> L <?php echo($width) ?> <?php echo($height/4*2) ?> M0 <?php echo ($height/4*3) ?> L <?php echo($width . ' ' . ($height/4*3)) ?>" <?php echo($attribs['grid'])?>/>
<text id="grid_txt1" x="<?php echo($width) ?>" y="<?php echo($height/4*1) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
<text id="grid_txt2" x="<?php echo($width) ?>" y="<?php echo($height/4*2) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
<text id="grid_txt3" x="<?php echo($width) ?>" y="<?php echo($height/4*3) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
<path id="grid" d="M0 <?php echo($height / 4) ?> L <?php echo($width) ?> <?php echo($height / 4) ?> M0 <?php echo($height / 4 * 2) ?> L <?php echo($width) ?> <?php echo($height / 4 * 2) ?> M0 <?php echo ($height / 4 * 3) ?> L <?php echo($width . ' ' . ($height / 4 * 3)) ?>" <?php echo($attribs['grid'])?>/>
<text id="grid_txt1" x="<?php echo($width) ?>" y="<?php echo($height / 4) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
<text id="grid_txt2" x="<?php echo($width) ?>" y="<?php echo($height / 4 * 2) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
<text id="grid_txt3" x="<?php echo($width) ?>" y="<?php echo($height / 4 * 3) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
<text id="graph_in_lbl" x="5" y="8" <?php echo($attribs['in']) ?>>In</text>
<text id="graph_out_lbl" x="5" y="16" <?php echo($attribs['out']) ?>>Out</text>
<text id="graph_in_txt" x="20" y="8" <?php echo($attribs['in']) ?>> </text>
<text id="graph_out_txt" x="20" y="16" <?php echo($attribs['out']) ?>> </text>
<text id="ifname" x="<?php echo($width-2) ?>" y="8" <?php echo($attribs['graphname']) ?> text-anchor="end"><?php echo($ifname) ?></text>
<text id="hostname" x="<?php echo($width-2) ?>" y="14" <?php echo($attribs['hostname']) ?> text-anchor="end"><?php echo($hostname) ?></text>
<text id="switch_unit" x="<?php echo($width*0.55) ?>" y="5" <?php echo($attribs['switch_unit']) ?>>Switch to bytes/s</text>
<text id="switch_scale" x="<?php echo($width*0.55) ?>" y="11" <?php echo($attribs['switch_scale']) ?>>AutoScale (<?php echo($scale_type) ?>)</text>
<text id="datetime" x="<?php echo($width*0.33) ?>" y="5" <?php echo($attribs['legend']) ?>> </text>
<text id="graphlast" x="<?php echo($width*0.55) ?>" y="17" <?php echo($attribs['legend']) ?>>Graph shows last <?php echo($time_interval*$nb_plot) ?> seconds</text>
<polygon id="axis_arrow_x" <?php echo($attribs['axis']) ?> points="<?php echo($width . "," . $height) ?> <?php echo(($width-2) . "," . ($height-2)) ?> <?php echo(($width-2) . "," . $height) ?>"/>
<text id="error" x="<?php echo($width*0.5) ?>" y="<?php echo($height*0.5) ?>" visibility="hidden" <?php echo($attribs['error']) ?> text-anchor="middle"><?php echo($error_text) ?></text>
<text id="collect_initial" x="<?php echo($width*0.5) ?>" y="<?php echo($height*0.5) ?>" visibility="hidden" <?php echo($attribs['collect_initial']) ?> text-anchor="middle">Collecting initial data, please wait...</text>
<text id="ifname" x="<?php echo($width - 2) ?>" y="8" <?php echo($attribs['graphname']) ?> text-anchor="end"><?php echo($ifname) ?></text>
<text id="hostname" x="<?php echo($width - 2) ?>" y="14" <?php echo($attribs['hostname']) ?> text-anchor="end"><?php echo($hostname) ?></text>
<text id="switch_unit" x="<?php echo($width * 0.55) ?>" y="5" <?php echo($attribs['switch_unit']) ?>>Switch to bytes/s</text>
<text id="switch_scale" x="<?php echo($width * 0.55) ?>" y="11" <?php echo($attribs['switch_scale']) ?>>AutoScale (<?php echo($scale_type) ?>)</text>
<text id="datetime" x="<?php echo($width * 0.33) ?>" y="5" <?php echo($attribs['legend']) ?>> </text>
<text id="graphlast" x="<?php echo($width * 0.55) ?>" y="17" <?php echo($attribs['legend']) ?>>Graph shows last <?php echo($time_interval * $nb_plot) ?> seconds</text>
<polygon id="axis_arrow_x" <?php echo($attribs['axis']) ?> points="<?php echo($width . "," . $height) ?> <?php echo(($width - 2) . "," . ($height - 2)) ?> <?php echo(($width - 2) . "," . $height) ?>"/>
<text id="error" x="<?php echo($width * 0.5) ?>" y="<?php echo($height * 0.5) ?>" visibility="hidden" <?php echo($attribs['error']) ?> text-anchor="middle"><?php echo($error_text) ?></text>
<text id="collect_initial" x="<?php echo($width * 0.5) ?>" y="<?php echo($height * 0.5) ?>" visibility="hidden" <?php echo($attribs['collect_initial']) ?> text-anchor="middle">Collecting initial data, please wait...</text>
</g>
<script type="text/ecmascript">
<![CDATA[
@ -120,43 +120,45 @@ print('<?xml version="1.0" encoding="iso-8859-1"?>' . PHP_EOL);
* popular. If getURL is undefined we spin our own by wrapping XMLHttpRequest.
*/
if (typeof getURL == 'undefined') {
getURL = function(url, callback) {
if (!url)
throw 'No URL for getURL';
getURL = function(url, callback) {
if (!url)
throw 'No URL for getURL';
try {
if (typeof callback.operationComplete == 'function')
callback = callback.operationComplete;
} catch (e) {}
if (typeof callback != 'function')
throw 'No callback function for getURL';
var http_request = null;
if (typeof XMLHttpRequest != 'undefined') {
http_request = new XMLHttpRequest();
}
else if (typeof ActiveXObject != 'undefined'){
try {
http_request = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
http_request = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {}
}
}
if (!http_request)
throw 'Both getURL and XMLHttpRequest are undefined';
if (typeof callback.operationComplete == 'function')
callback = callback.operationComplete;
} catch (e) {
}
if (typeof callback != 'function')
throw 'No callback function for getURL';
http_request.onreadystatechange = function() {
if (http_request.readyState == 4) {
callback( { success : true,
content : http_request.responseText,
contentType : http_request.getResponseHeader("Content-Type") } );
}
var http_request = null;
if (typeof XMLHttpRequest != 'undefined') {
http_request = new XMLHttpRequest();
} else if (typeof ActiveXObject != 'undefined') {
try {
http_request = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
http_request = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {
}
}
}
if (!http_request)
throw 'Both getURL and XMLHttpRequest are undefined';
http_request.onreadystatechange = function() {
if (http_request.readyState === 4) {
callback({ success: true,
content: http_request.responseText,
contentType: http_request.getResponseHeader("Content-Type")
});
}
}
http_request.open('GET', url, true);
http_request.send(null);
}
http_request.open('GET', url, true);
http_request.send(null);
}
}
var SVGDoc = null;
@ -173,216 +175,216 @@ var unit = 'bits';
var scale_type = '<?php echo($scale_type) ?>';
function init(evt) {
SVGDoc = evt.target.ownerDocument;
SVGDoc.getElementById("switch_unit").addEventListener("mousedown", switch_unit, false);
SVGDoc.getElementById("switch_scale").addEventListener("mousedown", switch_scale, false);
SVGDoc = evt.target.ownerDocument;
SVGDoc.getElementById("switch_unit").addEventListener("mousedown", switch_unit, false);
SVGDoc.getElementById("switch_scale").addEventListener("mousedown", switch_scale, false);
fetch_data();
fetch_data();
}
function switch_unit(event)
{
SVGDoc.getElementById('switch_unit').firstChild.data = 'Switch to ' + unit + '/s';
unit = (unit == 'bits') ? 'bytes' : 'bits';
function switch_unit(event) {
SVGDoc.getElementById('switch_unit').firstChild.data = 'Switch to ' + unit + '/s';
unit = (unit === 'bits') ? 'bytes' : 'bits';
}
function switch_scale(event)
{
scale_type = (scale_type == 'up') ? 'follow' : 'up';
SVGDoc.getElementById('switch_scale').firstChild.data = 'AutoScale (' + scale_type + ')';
function switch_scale(event) {
scale_type = (scale_type === 'up') ? 'follow' : 'up';
SVGDoc.getElementById('switch_scale').firstChild.data = 'AutoScale (' + scale_type + ')';
}
function fetch_data() {
getURL('<?php echo($fetch_link) ?>', plot_data);
getURL('<?php echo($fetch_link) ?>', plot_data);
}
function plot_data(obj) {
// Show datetimelegend
var now = new Date();
//var datetime = (now.getMonth()+1) + "/" + now.getDate() + "/" + now.getFullYear() + ' ' +
// LZ(now.getHours()) + ":" + LZ(now.getMinutes()) + ":" + LZ(now.getSeconds());
// Show datetimelegend
var now = new Date();
//var datetime = (now.getMonth()+1) + "/" + now.getDate() + "/" + now.getFullYear() + ' ' +
// LZ(now.getHours()) + ":" + LZ(now.getMinutes()) + ":" + LZ(now.getSeconds());
datetime = now.toLocaleString();
//datetime = now.toISOString();
datetime = now.toLocaleString();
//datetime = now.toISOString();
SVGDoc.getElementById('datetime').firstChild.data = datetime;
SVGDoc.getElementById('datetime').firstChild.data = datetime;
if (!obj.success)
return handle_error(); // getURL failed to get data
if (!obj.success)
return handle_error(); // getURL failed to get data
var t = obj.content.split("|");
var ugmt = parseFloat(t[0]); // ugmt is an unixtimestamp style
var ifin = parseInt(t[1]); // number of bytes received by the interface
var ifout = parseInt(t[2]); // number of bytes sent by the interface
var scale;
var t = obj.content.split("|");
var ugmt = parseFloat(t[0]); // ugmt is an unixtimestamp style
var ifin = parseInt(t[1]); // number of bytes received by the interface
var ifout = parseInt(t[2]); // number of bytes sent by the interface
var scale;
if (!isNumber(ifin) || !isNumber(ifout))
return handle_error();
if (!isNumber(ifin) || !isNumber(ifout))
return handle_error();
var diff_ugmt = ugmt - last_ugmt;
var diff_ifin;
if (ifin >= last_ifin) {
diff_ifin = ifin - last_ifin;
} else {
var max = (last_ifin > Math.pow(2,32)) ? Math.pow(2,64) : Math.pow(2,32);
diff_ifin = max - last_ifin + ifin;
}
var diff_ifout;
if (ifout >= last_ifout) {
diff_ifout = ifout - last_ifout;
} else {
var max = (last_ifout > Math.pow(2,32)) ? Math.pow(2,64) : Math.pow(2,32);
diff_ifout = max - last_ifout + ifout;
}
if (diff_ugmt == 0)
diff_ugmt = 1; /* avoid division by zero */
last_ugmt = ugmt;
last_ifin = ifin;
last_ifout = ifout;
switch (plot_in.length) {
case 0:
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'visible');
plot_in[0] = diff_ifin / diff_ugmt;
plot_out[0] = diff_ifout / diff_ugmt;
setTimeout('fetch_data()',<?php echo(1000*$time_interval) ?>);
return;
case 1:
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'hidden');
break;
case max_num_points:
// shift plot to left if the maximum number of plot points has been reached
var i = 0;
while (i < max_num_points) {
plot_in[i] = plot_in[i+1];
plot_out[i] = plot_out[++i];
}
plot_in.length--;
plot_out.length--;
}
plot_in[plot_in.length] = diff_ifin / diff_ugmt;
plot_out[plot_out.length]= diff_ifout / diff_ugmt;
var index_plot = plot_in.length - 1;
SVGDoc.getElementById('graph_in_txt').firstChild.data = formatSpeed(plot_in[index_plot], unit);
SVGDoc.getElementById('graph_out_txt').firstChild.data = formatSpeed(plot_out[index_plot], unit);
/* determine peak for sensible scaling */
if (scale_type == 'up') {
if (plot_in[index_plot] > max)
max = plot_in[index_plot];
if (plot_out[index_plot] > max)
max = plot_out[index_plot];
}
else if (scale_type == 'follow') {
i = 0;
max = 0;
while (i < plot_in.length) {
if (plot_in[i] > max)
max = plot_in[i];
if (plot_out[i] > max)
max = plot_out[i];
i++;
var diff_ugmt = ugmt - last_ugmt;
var diff_ifin;
if (ifin >= last_ifin) {
diff_ifin = ifin - last_ifin;
} else {
var max = (last_ifin > Math.pow(2, 32)) ? Math.pow(2, 64) : Math.pow(2, 32);
diff_ifin = max - last_ifin + ifin;
}
}
var rmax; // max, rounded up
if (unit == 'bits') {
/* round up max, such that
100 kbps -> 200 kbps -> 400 kbps -> 800 kbps -> 1 Mbps -> 2 Mbps -> ... */
rmax = 12500;
i = 0;
while (max > rmax) {
i++;
if (i && (i % 4 == 0))
rmax *= 1.25;
else
rmax *= 2;
var diff_ifout;
if (ifout >= last_ifout) {
diff_ifout = ifout - last_ifout;
} else {
var max = (last_ifout > Math.pow(2, 32)) ? Math.pow(2, 64) : Math.pow(2, 32);
diff_ifout = max - last_ifout + ifout;
}
} else {
/* round up max, such that
10 KB/s -> 20 KB/s -> 40 KB/s -> 80 KB/s -> 100 KB/s -> 200 KB/s -> 400 KB/s -> 800 KB/s -> 1 MB/s ... */
rmax = 10240;
i = 0;
while (max > rmax) {
i++;
if (i && (i % 4 == 0))
rmax *= 1.25;
else
rmax *= 2;
if (i == 8)
rmax *= 1.024;
if (diff_ugmt === 0)
diff_ugmt = 1; /* avoid division by zero */
last_ugmt = ugmt;
last_ifin = ifin;
last_ifout = ifout;
switch (plot_in.length) {
case 0:
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'visible');
plot_in[0] = diff_ifin / diff_ugmt;
plot_out[0] = diff_ifout / diff_ugmt;
setTimeout('fetch_data()',<?php echo(1000 * $time_interval) ?>);
return;
case 1:
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'hidden');
break;
case max_num_points:
// shift plot to left if the maximum number of plot points has been reached
var i = 0;
while (i < max_num_points) {
plot_in[i] = plot_in[i + 1];
plot_out[i] = plot_out[++i];
}
plot_in.length--;
plot_out.length--;
}
}
scale = <?php echo($height) ?> / rmax;
plot_in[plot_in.length] = diff_ifin / diff_ugmt;
plot_out[plot_out.length]= diff_ifout / diff_ugmt;
var index_plot = plot_in.length - 1;
/* change labels accordingly */
SVGDoc.getElementById('grid_txt1').firstChild.data = formatSpeed(3*rmax/4,unit);
SVGDoc.getElementById('grid_txt2').firstChild.data = formatSpeed(2*rmax/4,unit);
SVGDoc.getElementById('grid_txt3').firstChild.data = formatSpeed(rmax/4,unit);
SVGDoc.getElementById('graph_in_txt').firstChild.data = formatSpeed(plot_in[index_plot], unit);
SVGDoc.getElementById('graph_out_txt').firstChild.data = formatSpeed(plot_out[index_plot], unit);
var path_in = "M 0 " + (<?php echo($height) ?> - (plot_in[0] * scale));
var path_out = "M 0 " + (<?php echo($height) ?> - (plot_out[0] * scale));
for (i = 1; i < plot_in.length; i++)
{
var x = step * i;
var y_in = <?php echo($height) ?> - (plot_in[i] * scale);
var y_out = <?php echo($height) ?> - (plot_out[i] * scale);
path_in += " L" + x + " " + y_in;
path_out += " L" + x + " " + y_out;
}
/* determine peak for sensible scaling */
if (scale_type === 'up') {
if (plot_in[index_plot] > max)
max = plot_in[index_plot];
if (plot_out[index_plot] > max)
max = plot_out[index_plot];
} else if (scale_type === 'follow') {
i = 0;
max = 0;
while (i < plot_in.length) {
if (plot_in[i] > max)
max = plot_in[i];
if (plot_out[i] > max)
max = plot_out[i];
i++;
}
}
SVGDoc.getElementById('error').setAttributeNS(null, 'visibility', 'hidden');
SVGDoc.getElementById('graph_in').setAttributeNS(null, 'd', path_in);
SVGDoc.getElementById('graph_out').setAttributeNS(null, 'd', path_out);
var rmax; // max, rounded up
setTimeout('fetch_data()',<?php echo(1000*$time_interval) ?>);
if (unit === 'bits') {
/* round up max, such that
100 kbps -> 200 kbps -> 400 kbps -> 800 kbps -> 1 Mbps -> 2 Mbps -> ... */
rmax = 12500;
i = 0;
while (max > rmax) {
i++;
if (i && (i % 4 === 0))
rmax *= 1.25;
else
rmax *= 2;
}
} else {
/* round up max, such that
10 KB/s -> 20 KB/s -> 40 KB/s -> 80 KB/s -> 100 KB/s -> 200 KB/s -> 400 KB/s -> 800 KB/s -> 1 MB/s ... */
rmax = 10240;
i = 0;
while (max > rmax) {
i++;
if (i && (i % 4 === 0))
rmax *= 1.25;
else
rmax *= 2;
if (i === 8)
rmax *= 1.024;
}
}
scale = <?php echo($height) ?> / rmax;
/* change labels accordingly */
SVGDoc.getElementById('grid_txt1').firstChild.data = formatSpeed(3 * rmax / 4, unit);
SVGDoc.getElementById('grid_txt2').firstChild.data = formatSpeed(2 * rmax / 4, unit);
SVGDoc.getElementById('grid_txt3').firstChild.data = formatSpeed(rmax / 4, unit);
var path_in = "M 0 " + (<?php echo($height) ?> - (plot_in[0] * scale));
var path_out = "M 0 " + (<?php echo($height) ?> - (plot_out[0] * scale));
for (i = 1; i < plot_in.length; i++) {
var x = step * i;
var y_in = <?php echo($height) ?> - (plot_in[i] * scale);
var y_out = <?php echo($height) ?> - (plot_out[i] * scale);
path_in += " L" + x + " " + y_in;
path_out += " L" + x + " " + y_out;
}
SVGDoc.getElementById('error').setAttributeNS(null, 'visibility', 'hidden');
SVGDoc.getElementById('graph_in').setAttributeNS(null, 'd', path_in);
SVGDoc.getElementById('graph_out').setAttributeNS(null, 'd', path_out);
setTimeout('fetch_data()', <?php echo(1000 * $time_interval) ?>);
}
function handle_error() {
SVGDoc.getElementById("error").setAttributeNS(null, 'visibility', 'visible');
setTimeout('fetch_data()',<?php echo(1000*$time_interval) ?>);
SVGDoc.getElementById("error").setAttributeNS(null, 'visibility', 'visible');
setTimeout('fetch_data()', <?php echo(1000 * $time_interval) ?>);
}
function isNumber(a) {
return typeof a == 'number' && isFinite(a);
return typeof a == 'number' && isFinite(a);
}
function formatSpeed(speed, unit) {
if (unit == 'bits')
return formatSpeedBits(speed);
if (unit == 'bytes')
return formatSpeedBytes(speed);
if (unit === 'bits')
return formatSpeedBits(speed);
if (unit === 'bytes')
return formatSpeedBytes(speed);
}
function formatSpeedBits(speed) {
// format speed in bits/sec, input: bytes/sec
if (speed < 125000)
return Math.round(speed / 125) + " Kbps";
if (speed < 125000000)
return Math.round(speed / 1250)/100 + " Mbps";
// else
return Math.round(speed / 1250000)/100 + " Gbps"; /* wow! */
// format speed in bits/sec, input: bytes/sec
if (speed < 125000)
return Math.round(speed / 125) + " Kbps";
if (speed < 125000000)
return Math.round(speed / 1250)/100 + " Mbps";
if (speed < 125000000000)
return Math.round(speed / 1250000)/100 + " Gbps";
// else
return Math.round(speed / 125000000000)/100 + " Tbps"; /* wow! */
}
function formatSpeedBytes(speed) {
// format speed in bytes/sec, input: bytes/sec
if (speed < 1048576)
return Math.round(speed / 10.24)/100 + " KB/s";
if (speed < 1073741824)
return Math.round(speed / 10485.76)/100 + " MB/s";
// else
return Math.round(speed / 10737418.24)/100 + " GB/s"; /* wow! */
// format speed in bytes/sec, input: bytes/sec
if (speed < 1048576)
return Math.round(speed / 10.24)/100 + " KB/s";
if (speed < 1073741824)
return Math.round(speed / 10485.76)/100 + " MB/s";
if (speed < 1099511627776)
return Math.round(speed / 10737418.24)/100 + " GB/s";
// else
return Math.round(speed / 10995116277.76)/100 + " TB/s"; /* wow! */
}
function LZ(x) {
return (x < 0 || x > 9 ? "" : "0") + x;
return (x < 0 || x > 9 ? "" : "0") + x;
}
]]>

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage graphs
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage graphs
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
@ -17,25 +17,25 @@ define('OBS_GRAPH', TRUE);
$start = microtime(TRUE); // Needs common.php
include_once("../includes/sql-config.inc.php");
include($config['html_dir'] . "/includes/functions.inc.php");
include_once("../includes/observium.inc.php");
if (isset($config['allow_unauth_graphs']) && $config['allow_unauth_graphs']) {
$auth = TRUE; // hardcode auth for all with config function
print_debug('Authentication bypassed by $config[\'allow_unauth_graphs\'].');
$auth = TRUE; // hardcode auth for all with config function
print_debug('Authentication bypassed by $config[\'allow_unauth_graphs\'].');
} elseif (isset($config['allow_unauth_graphs_cidr']) && count($config['allow_unauth_graphs_cidr'])) {
//if (match_network($_SERVER['REMOTE_ADDR'], $config['allow_unauth_graphs_cidr']))
if (match_network(get_remote_addr($config['web_session_ip_by_header']), $config['allow_unauth_graphs_cidr'])) {
$auth = TRUE; // hardcode authenticated for matched subnet
print_debug("Authentication by matched CIDR.");
}
//if (match_network($_SERVER['REMOTE_ADDR'], $config['allow_unauth_graphs_cidr']))
if (match_network(get_remote_addr($config['web_session_ip_by_header']), $config['allow_unauth_graphs_cidr'])) {
$auth = TRUE; // hardcode authenticated for matched subnet
print_debug("Authentication by matched CIDR.");
}
}
if (!isset($auth) || !$auth) {
// Normal auth
include($config['html_dir'] . "/includes/authenticate.inc.php");
$auth = $_SESSION['authenticated'];
// Normal auth
include($config['html_dir'] . "/includes/authenticate.inc.php");
$auth = $_SESSION['authenticated'];
} elseif (!isset($_SESSION['userlevel']) && $auth) {
$_SESSION['userlevel'] = 7; // Set global read for session when $auth hardcoded
}
// Push $_GET into $vars to be compatible with web interface naming
@ -46,6 +46,6 @@ include($config['html_dir'] . "/includes/graphs/graph.inc.php");
$runtime = microtime(TRUE) - $start;
print_debug("Runtime ".$runtime." secs");
print_debug("Runtime " . $runtime . " secs");
// EOF

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 781 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 547 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 555 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 B

Some files were not shown because too many files have changed in this diff Show More