diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 9a0b872a6e..1244d4286c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.736-190711 +Version: 7.0NG.736-190717 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 4d84020703..d53d0237c5 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.736-190711" +pandora_version="7.0NG.736-190717" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 8a6ac38d5f..0a20d5fcf8 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.736'; -use constant AGENT_BUILD => '190711'; +use constant AGENT_BUILD => '190717'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index c9f7f10dc0..871c852f0b 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.736 -%define release 190711 +%define release 190717 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 8d1ff4fc15..21fbac3598 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.736 -%define release 190711 +%define release 190717 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 52b49cca0c..7adc9eb2da 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.736" -PI_BUILD="190711" +PI_BUILD="190717" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index efa43a74ee..bb2477b149 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190711} +{190717} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 75fb3cbe98..c7983585fc 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.736(Build 190711)") +#define PANDORA_VERSION ("7.0NG.736(Build 190717)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 392c639976..f9415cbc73 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.736(Build 190711))" + VALUE "ProductVersion", "(7.0NG.736(Build 190717))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 32efed3e39..7d9800425b 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.736-190711 +Version: 7.0NG.736-190717 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 68e0aa147f..0e5e800d22 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.736-190711" +pandora_version="7.0NG.736-190717" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt new file mode 100644 index 0000000000..c0d8f0a9db --- /dev/null +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -0,0 +1 @@ +operation/servers/recon_view.php \ No newline at end of file diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql index d3c3b742b2..8c66c7b0a6 100644 --- a/pandora_console/extras/mr/30.sql +++ b/pandora_console/extras/mr/30.sql @@ -10,6 +10,8 @@ ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEF ALTER TABLE `tmodule_relationship` ADD COLUMN `type` ENUM('direct', 'failover') DEFAULT 'direct'; +ALTER TABLE `treport_content` MODIFY COLUMN `name` varchar(300) NULL; + CREATE TABLE `ttask_credentials` ( `id_rt` int(10) unsigned NOT NULL, `identifier` varchar(100) NOT NULL, @@ -39,4 +41,4 @@ CREATE TABLE `tdeployment_hosts` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -COMMIT; \ No newline at end of file +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index bdf79c59c0..3fb25af44f 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -724,7 +724,7 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` ( `type` varchar(30) default 'simple_graph', `period` int(11) NOT NULL default 0, `order` int (11) NOT NULL default 0, - `description` mediumtext, + `description` mediumtext, `text_agent` text, `text` TEXT, `external_source` Text, @@ -1446,6 +1446,7 @@ ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1 ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '0'; ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) DEFAULT '0'; +ALTER table `treport_content` MODIFY COLUMN `name` varchar(300) NULL; -- --------------------------------------------------------------------- -- Table `tmodule_relationship` diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index 4fbdf93140..d8ac4cb91e 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -376,6 +376,9 @@ if (isset($correct_reset_pass_process)) { } if (isset($login_failed)) { + $nick = get_parameter_post('nick'); + $fails = db_get_value('failed_attempt', 'tusuario', 'id_user', $nick); + $attemps = ($config['number_attempts'] - $fails); echo '
'; echo '
'; echo '
'; @@ -386,6 +389,9 @@ if (isset($login_failed)) { echo '

'.__('ERROR').'

'; echo '

'.$config['auth_error'].'

'; echo '
'; + echo '
'; + echo '

Remaining attempts: '.$attemps.'

'; + echo '
'; echo '
'; html_print_submit_button('Ok', 'hide-login-error', false); echo '
'; @@ -680,5 +686,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' $("#final_process_correct").dialog('close'); }); }); + /* ]]> */ diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index d7c783c5d4..c24478eeb6 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -77,6 +77,7 @@ if (is_ajax()) { } $get_modules_json_for_multiple_snmp = (bool) get_parameter('get_modules_json_for_multiple_snmp', 0); + $get_common_modules = (bool) get_parameter('get_common_modules', 1); if ($get_modules_json_for_multiple_snmp) { include_once 'include/graphs/functions_utils.php'; @@ -100,7 +101,16 @@ if (is_ajax()) { if ($out === false) { $out = $oid_snmp; } else { - $out = array_intersect($out, $oid_snmp); + $commons = array_intersect($out, $oid_snmp); + if ($get_common_modules) { + // Common modules is selected (default) + $out = $commons; + } else { + // All modules is selected + $array1 = array_diff($out, $oid_snmp); + $array2 = array_diff($oid_snmp, $out); + $out = array_merge($commons, $array1, $array2); + } } $oid_snmp = []; @@ -201,7 +211,7 @@ if (!$new_agent && $alias != '') { $table_agent_name .= '
'; if ($id_agente) { - $table_agent_name .= ''; + $table_agent_name .= ''; $table_agent_name .= ''; $table_agent_name .= html_print_image( 'images/zoom.png', @@ -372,13 +382,13 @@ $table_server = '

'.__('Server') $table_server .= '

'; if ($new_agent) { // Set first server by default. - $servers_get_names = servers_get_names(); + $servers_get_names = $servers; $array_keys_servers_get_names = array_keys($servers_get_names); $server_name = reset($array_keys_servers_get_names); } $table_server .= html_print_select( - servers_get_names(), + $servers, 'server_name', $server_name, '', @@ -1164,6 +1174,19 @@ ui_require_jquery_file('bgiframe'); } $(document).ready (function() { + + var previous_primary_group_select; + $("#grupo").on('focus', function () { + previous_primary_group_select = this.value; + }).change(function() { + if ($("#secondary_groups_selected option[value="+$("#grupo").val()+"]").length) { + alert(""); + $("#grupo").val(previous_primary_group_select); + } else { + previous_primary_group_select = this.value; + } + }); + $("select#id_os").pandoraSelectOS (); var checked = $("#checkbox-cascade_protection").is(":checked"); @@ -1212,7 +1235,7 @@ ui_require_jquery_file('bgiframe'); 128, 128 ); - $("#text-agente").prop('disabled', true); + $("#text-agente").prop('readonly', true); }); diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php index 2dca9353ac..3eb404340e 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php @@ -1,16 +1,32 @@ ] => [] array + // Build a [] => [] array. if (!empty($snmp_int_ip)) { foreach ($snmp_int_ip as $key => $value) { - // The key is something like IP-MIB::ipAddressIfIndex.ipv4."" - // or IP-MIB::ipAddressIfIndex.ipv6."" - // The value is something like INTEGER: + // The key is something like IP-MIB::ipAddressIfIndex.ipv4."". + // or IP-MIB::ipAddressIfIndex.ipv6."". + // The value is something like INTEGER: . $data = explode(': ', $value); $interface_id = !empty($data) && isset($data[1]) ? $data[1] : false; @@ -110,7 +126,7 @@ if ($snmpwalk) { $interface_ip = $matches[1]; } - // Get the first ip + // Get the first ip. if ($interface_id !== false && !empty($interface_ip) && !isset($interfaces_ip[$interface_id])) { $interfaces_ip[$interface_id] = $interface_ip; } @@ -119,17 +135,17 @@ if ($snmpwalk) { unset($snmp_int_ip); } - $snmpis = array_merge(($snmpis === false ? [] : $snmpis), ($ifxitems === false ? [] : $ifxitems)); + $snmpis = array_merge((($snmpis === false) ? [] : $snmpis), (($ifxitems === false) ? [] : $ifxitems)); $interfaces = []; - // We get here only the interface part of the MIB, not full mib + // We get here only the interface part of the MIB, not full mib. foreach ($snmpis as $key => $snmp) { $data = explode(': ', $snmp, 2); $keydata = explode('::', $key); $keydata2 = explode('.', $keydata[1]); - // Avoid results without index and interfaces without name + // Avoid results without index and interfaces without name. if (!isset($keydata2[1]) || !isset($data[1])) { continue; } @@ -239,24 +255,22 @@ if ($create_modules) { $oid_array[(count($oid_array) - 1)] = $id; $oid = implode('.', $oid_array); - // Get the name + // Get the name. $name_array = explode('::', $oid_array[0]); $name = $ifname.'_'.$name_array[1]; - // Clean the name + // Clean the name. $name = str_replace('"', '', $name); - // Proc moduletypes + // Proc moduletypes. if (preg_match('/Status/', $name_array[1])) { $module_type = 18; } else if (preg_match('/Present/', $name_array[1])) { $module_type = 18; } else if (preg_match('/PromiscuousMode/', $name_array[1])) { $module_type = 18; - } - - // String moduletypes - else if (preg_match('/Alias/', $name_array[1])) { + } else if (preg_match('/Alias/', $name_array[1])) { + // String moduletypes. $module_type = 17; } else if (preg_match('/Address/', $name_array[1])) { $module_type = 17; @@ -266,15 +280,11 @@ if ($create_modules) { $module_type = 17; } else if (preg_match('/Descr/', $name_array[1])) { $module_type = 17; - } - - // Specific counters (ends in s) - else if (preg_match('/s$/', $name_array[1])) { + } else if (preg_match('/s$/', $name_array[1])) { + // Specific counters (ends in s). $module_type = 16; - } - - // Otherwise, numeric - else { + } else { + // Otherwise, numeric. $module_type = 15; } @@ -330,7 +340,7 @@ if ($create_modules) { $output_oid = ''; - exec('ssh pandora_exec_proxy@'.$row['ip_address'].' snmptranslate -On '.$oid, $output_oid, $rc); + exec('snmptranslate -On '.$oid, $output_oid, $rc); $conf_oid = $output_oid[0]; $oid = $conf_oid; @@ -397,7 +407,9 @@ if ($create_modules) { } if ($done > 0) { - ui_print_success_message(__('Successfully modules created')." ($done)"); + ui_print_success_message( + __('Successfully modules created').' ('.$done.')' + ); } if (!empty($errors)) { @@ -407,17 +419,17 @@ if ($create_modules) { foreach ($errors as $code => $number) { switch ($code) { case ERR_EXIST: - $msg .= '
'.__('Another module already exists with the same name')." ($number)"; + $msg .= '
'.__('Another module already exists with the same name').' ('.$number.')'; break; case ERR_INCOMPLETE: - $msg .= '
'.__('Some required fields are missed').': ('.__('name').') '." ($number)"; + $msg .= '
'.__('Some required fields are missed').': ('.__('name').') ('.$number.')'; break; case ERR_DB: case ERR_GENERIC: default: - $msg .= '
'.__('Processing error')." ($number)"; + $msg .= '
'.__('Processing error').' ('.$number.')'; break; } } @@ -426,10 +438,10 @@ if ($create_modules) { } } -// Create the interface list for the interface +// Create the interface list for the interface. $interfaces_list = []; foreach ($interfaces as $interface) { - // Get the interface name, removing " " characters and avoid "blank" interfaces + // Get the interface name, removing " " characters and avoid "blank" interfaces. if (isset($interface['ifDescr']) && $interface['ifDescr']['value'] != '') { $ifname = $interface['ifDescr']['value']; } else if (isset($interface['ifName']) && $interface['ifName']['value'] != '') { @@ -442,7 +454,7 @@ foreach ($interfaces as $interface) { } echo ''; -echo "
"; +echo ""; $table->width = '100%'; $table->cellpadding = 0; @@ -464,12 +476,14 @@ if (enterprise_installed()) { enterprise_include_once('include/functions_satellite.php'); $rows = get_proxy_servers(); + + // Check if satellite server has remote configuration enabled. + $satellite_remote = config_agents_has_remote_configuration($id_agent); + foreach ($rows as $row) { if ($row['server_type'] != 13) { $s_type = ' (Standard)'; } else { - // Check if satellite server has remote configuration enabled - $satellite_remote = config_agents_has_remote_configuration($id_agent); $id_satellite = $row['id_server']; $s_type = ' (Satellite)'; } @@ -484,8 +498,7 @@ $table->data[1][4] = html_print_select( $servers_to_exec, 'server_to_exec', $server_to_exec, - 'satellite_remote_warn('.$id_satellite.','.$satellite_remote.') -', + 'satellite_remote_warn('.$id_satellite.','.$satellite_remote.')', '', '', true @@ -509,7 +522,7 @@ html_print_table($table); unset($table); -// SNMP3 OPTIONS +// SNMP3 OPTIONS. $table->width = '100%'; $table->data[2][1] = ''.__('Auth user').''; @@ -564,7 +577,7 @@ echo '
'; if (!empty($interfaces_list)) { echo ''; - echo "
"; + echo ""; echo ''; $id_snmp_serialize = serialize_in_temp($interfaces, $config['id_user'].'_snmp'); @@ -589,13 +602,30 @@ if (!empty($interfaces_list)) { $table->width = '100%'; - // Agent selector + // Agent selector. $table->data[0][0] = ''.__('Interfaces').''; $table->data[0][1] = ''; $table->data[0][2] = ''.__('Modules').''; $table->data[1][0] = html_print_select($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:500px; overflow: auto;'); - $table->data[1][1] = html_print_image('images/darrowright.png', true); + + $table->data[1][1] = __('When selecting interfaces'); + $table->data[1][1] .= '
'; + $table->data[1][1] .= html_print_select( + [ + 1 => __('Show common modules'), + 0 => __('Show all modules'), + ], + 'modules_selection_mode', + 1, + false, + '', + '', + true, + false, + false + ); + $table->data[1][2] = html_print_select([], 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:200px;'); $table->data[1][2] .= html_print_input_hidden('agent', $id_agent, true); @@ -619,12 +649,10 @@ ui_require_jquery_file('bgiframe'); /* data[0][3] .= html_print_select_from_sql( $disabledBecauseInPolicy ); +if ((isset($id_agent_module) && $id_agent_module) || $id_policy_module != 0) { + $edit = false; +} else { + $edit = true; +} + $in_policy = strstr($page, 'policy_modules'); if (!$in_policy) { // Cannot select the current module to be itself parent @@ -280,17 +288,6 @@ if (!$in_policy) { $table_simple->data[2][0] = __('Type').' '.ui_print_help_icon($help_type, true, '', 'images/help_green.png', '', 'module_type_help'); $table_simple->data[2][0] .= html_print_input_hidden('id_module_type_hidden', $id_module_type, true); -if (isset($id_agent_module)) { - if ($id_agent_module) { - $edit = false; - } else { - $edit = true; - } -} else { - // Run into a policy - $edit = true; -} - if (!$edit) { $sql = sprintf( 'SELECT id_tipo, nombre diff --git a/pandora_console/godmode/massive/massive_add_profiles.php b/pandora_console/godmode/massive/massive_add_profiles.php index 6000dbe9a6..e337c09f81 100644 --- a/pandora_console/godmode/massive/massive_add_profiles.php +++ b/pandora_console/godmode/massive/massive_add_profiles.php @@ -84,7 +84,9 @@ if ($create_profiles) { ); } -html_print_table($table); +if ($table !== null) { + html_print_table($table); +} unset($table); diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index 5ca25ebc11..36ab0c310c 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -273,6 +273,9 @@ $table->data[1][1] = html_print_select( true ); +$table->data['form_agents_filter'][0] = __('Filter Agents'); +$table->data['form_agents_filter'][1] = html_print_input_text('filter_agents', '', '', 20, 255, true); + $table->data[2][0] = __('Agent'); $table->data[2][0] .= '
'; ?> @@ -865,7 +868,18 @@ $class = 'databox filters'; @@ -923,7 +937,18 @@ $class = 'databox filters'; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 1e552b112a..74adca3139 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -774,14 +774,14 @@ switch ($action) { $table->head[1] = __('Description'); $table->head[2] = __('HTML'); $table->head[3] = __('XML'); - $table->size[0] = '60%'; + $table->size[0] = '50%'; $table->size[1] = '20%'; $table->size[2] = '2%'; - $table->headstyle[2] = 'min-width: 35px;text-align: center;'; + $table->headstyle[2] = 'min-width: 35px;text-align: left;'; $table->size[3] = '2%'; - $table->headstyle[3] = 'min-width: 35px;text-align: center;'; + $table->headstyle[3] = 'min-width: 35px;text-align: left;'; $table->size[4] = '2%'; - $table->headstyle[4] = 'min-width: 35px;text-align: center;'; + $table->headstyle[4] = 'min-width: 35px;text-align: left;'; $next = 4; // Calculate dinamically the number of the column. @@ -790,15 +790,16 @@ switch ($action) { } $table->size[$next] = '2%'; - $table->style[$next] = 'text-align: center;'; + $table->style[$next] = 'text-align: left;'; - $table->headstyle[($next + 2)] = 'min-width: 100px;'; - $table->style[($next + 2)] = 'text-align: center;'; + $table->headstyle[($next + 2)] = 'min-width: 130px; text-align:right;'; + $table->style[($next + 2)] = 'text-align: right;'; // Admin options only for RM flag. if (check_acl($config['id_user'], 0, 'RM')) { $table->head[$next] = __('Private'); + $table->headstyle[$next] = 'min-width: 40px;text-align: left;'; $table->size[$next] = '2%'; if (defined('METACONSOLE')) { $table->align[$next] = ''; @@ -808,7 +809,9 @@ switch ($action) { $next++; $table->head[$next] = __('Group'); - $table->size[$next] = '15%'; + $table->headstyle[$next] = 'min-width: 40px;text-align: left;'; + $table->size[$next] = '2%'; + $table->align[$next] = 'left'; $next++; $op_column = false; @@ -826,7 +829,7 @@ switch ($action) { // $table->size = array (); $table->size[$next] = '10%'; - $table->align[$next] = 'left'; + $table->align[$next] = 'right'; } $columnview = false; @@ -1341,6 +1344,16 @@ switch ($action) { switch ($action) { case 'update': $values = []; + $server_name = get_parameter('server_id'); + if (is_metaconsole() && $server_name != '') { + $id_meta = metaconsole_get_id_server($server_name); + $connection = metaconsole_get_connection_by_id( + $id_meta + ); + metaconsole_connect($connection); + $values['server_name'] = $connection['server_name']; + } + $values['id_report'] = $idReport; $values['description'] = get_parameter('description'); $values['type'] = get_parameter('type', null); @@ -1349,14 +1362,36 @@ switch ($action) { $label = get_parameter('label', ''); + $id_agent = get_parameter('id_agent'); + $id_agent_module = get_parameter('id_agent_module'); + // Add macros name. - $items_label = []; - $items_label['type'] = get_parameter('type'); - $items_label['id_agent'] = get_parameter('id_agent'); - $items_label['id_agent_module'] = get_parameter( - 'id_agent_module' - ); $name_it = (string) get_parameter('name'); + + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_label = [ + 'type' => get_parameter('type'), + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + $values['name'] = reporting_label_macro( $items_label, $name_it @@ -1712,13 +1747,6 @@ switch ($action) { ); $values['id_group'] = get_parameter('combo_group'); $values['server_name'] = get_parameter('server_name'); - $server_id = (int) get_parameter('server_id'); - if ($server_id != 0) { - $connection = metaconsole_get_connection_by_id( - $server_id - ); - $values['server_name'] = $connection['server_name']; - } if ($values['server_name'] == '') { $values['server_name'] = get_parameter( @@ -1975,22 +2003,11 @@ switch ($action) { $values['style'] = io_safe_input(json_encode($style)); + if (is_metaconsole()) { + metaconsole_restore_db(); + } + if ($good_format) { - switch ($config['dbtype']) { - case 'oracle': - if (isset($values['type'])) { - $values[db_escape_key_identifier( - 'type' - )] = $values['type']; - unset($values['type']); - } - break; - - default: - // Default. - break; - } - $resultOperationDB = db_process_sql_update( 'treport_content', $values, @@ -2003,21 +2020,62 @@ switch ($action) { case 'save': $values = []; + + $values['server_name'] = get_parameter('server_name'); + $server_id = (int) get_parameter('server_id'); + if ($server_id != 0) { + $connection = metaconsole_get_connection_by_id( + $server_id + ); + metaconsole_connect($connection); + $values['server_name'] = $connection['server_name']; + } + $values['id_report'] = $idReport; $values['type'] = get_parameter('type', null); $values['description'] = get_parameter('description'); $label = get_parameter('label', ''); - // Add macros name. - $items_label = []; - $items_label['type'] = get_parameter('type'); - $items_label['id_agent'] = get_parameter('id_agent'); - $items_label['id_agent_module'] = get_parameter( - 'id_agent_module' - ); - $name_it = (string) get_parameter('name'); $values['recursion'] = get_parameter('recursion', null); - $values['show_extended_events'] = get_parameter('include_extended_events', null); + $values['show_extended_events'] = get_parameter( + 'include_extended_events', + null + ); + + $id_agent = get_parameter('id_agent'); + $id_agent_module = get_parameter('id_agent_module'); + + // Add macros name. + $name_it = (string) get_parameter('name'); + + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + if (is_metaconsole()) { + metaconsole_restore_db(); + } + + $items_label = [ + 'type' => get_parameter('type'), + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + $values['name'] = reporting_label_macro( $items_label, $name_it @@ -2222,18 +2280,6 @@ switch ($action) { break; } - - - $values['server_name'] = get_parameter('server_name'); - $server_id = (int) get_parameter('server_id'); - if ($server_id != 0) { - $connection = metaconsole_get_connection_by_id( - $server_id - ); - - $values['server_name'] = $connection['server_name']; - } - if ($values['server_name'] == '') { $values['server_name'] = get_parameter( 'combo_server' diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php index d2849ce5e0..720bb57a1c 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.elements.php +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -171,7 +171,7 @@ foreach ($layoutDatas as $layoutData) { $table->data[($i + 1)]['icon'] = html_print_image( 'images/camera.png', true, - ['title' => __('Static Graph')] + ['title' => __('Static Image')] ); break; diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index a7fc94bcca..3eb385332c 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -70,7 +70,7 @@ if (is_ajax()) { $table->head[0] = __('Agent'); $table->head[1] = __('Module'); foreach ($modules as $mod) { - $agent_name = ''.modules_get_agentmodule_agent_name( + $agent_name = ''.modules_get_agentmodule_agent_alias( $mod['id_agente_modulo'] ).''; @@ -1215,4 +1215,3 @@ ui_require_javascript_file('pandora_modules'); - diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index aa2f0a0735..f0e2a4ad08 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -152,12 +152,12 @@ foreach ($servers as $server) { $data[8] = ''; if ($server['type'] == 'recon') { - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/firts_task/icono_grande_reconserver.png', true, [ - 'title' => __('Manage recon tasks'), + 'title' => __('Manage Discovery tasks'), 'style' => 'width:21px;height:21px;', ] ); @@ -165,7 +165,7 @@ foreach ($servers as $server) { } if ($server['type'] == 'data') { - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/target.png', true, @@ -173,7 +173,7 @@ foreach ($servers as $server) { ); $data[8] .= ''; } else if ($server['type'] == 'enterprise snmp') { - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/target.png', true, @@ -182,7 +182,7 @@ foreach ($servers as $server) { $data[8] .= ''; } - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/config.png', true, @@ -191,7 +191,7 @@ foreach ($servers as $server) { $data[8] .= ''; if (($names_servers[$safe_server_name] === true) && ($server['type'] == 'data' || $server['type'] == 'enterprise satellite')) { - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/remote_configuration.png', true, @@ -201,7 +201,7 @@ foreach ($servers as $server) { $names_servers[$safe_server_name] = false; } - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/cross.png', true, diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index f5bfc8c635..c32f128ddd 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -86,7 +86,7 @@ $buttons = []; // Draws header. $buttons['general'] = [ 'active' => false, - 'text' => ''.html_print_image('images/gm_setup.png', true, ['title' => __('General')]).'', + 'text' => ''.html_print_image('images/gm_setup.png', true, ['title' => __('General')]).'', ]; if (enterprise_installed()) { @@ -95,37 +95,37 @@ if (enterprise_installed()) { $buttons['auth'] = [ 'active' => false, - 'text' => ''.html_print_image('images/key.png', true, ['title' => __('Authentication')]).'', + 'text' => ''.html_print_image('images/key.png', true, ['title' => __('Authentication')]).'', ]; $buttons['perf'] = [ 'active' => false, - 'text' => ''.html_print_image('images/performance.png', true, ['title' => __('Performance')]).'', + 'text' => ''.html_print_image('images/performance.png', true, ['title' => __('Performance')]).'', ]; $buttons['vis'] = [ 'active' => false, - 'text' => ''.html_print_image('images/chart.png', true, ['title' => __('Visual styles')]).'', + 'text' => ''.html_print_image('images/chart.png', true, ['title' => __('Visual styles')]).'', ]; if (check_acl($config['id_user'], 0, 'AW')) { if ($config['activate_netflow']) { $buttons['net'] = [ 'active' => false, - 'text' => ''.html_print_image('images/op_netflow.png', true, ['title' => __('Netflow')]).'', + 'text' => ''.html_print_image('images/op_netflow.png', true, ['title' => __('Netflow')]).'', ]; } } $buttons['ehorus'] = [ 'active' => false, - 'text' => ''.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'', + 'text' => ''.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'', ]; // FIXME: Not definitive icon $buttons['notifications'] = [ 'active' => false, - 'text' => ''.html_print_image('images/alerts_template.png', true, ['title' => __('Notifications')]).'', + 'text' => ''.html_print_image('images/alerts_template.png', true, ['title' => __('Notifications')]).'', ]; $help_header = ''; diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 8079aee1e8..ab1d1ef269 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -1,5 +1,13 @@ style[0] = 'font-weight:bold'; $table->size[1] = '70%'; // Current config["language"] could be set by user, not taken from global setup ! -switch ($config['dbtype']) { - case 'mysql': - $current_system_lang = db_get_sql( - 'SELECT `value` - FROM tconfig WHERE `token` = "language"' - ); - break; - - case 'postgresql': - $current_system_lang = db_get_sql( - 'SELECT "value" - FROM tconfig WHERE "token" = \'language\'' - ); - break; - - case 'oracle': - $current_system_lang = db_get_sql( - 'SELECT value - FROM tconfig WHERE token = \'language\'' - ); - break; -} +$current_system_lang = db_get_sql( + 'SELECT `value` FROM tconfig WHERE `token` = "language"' +); if ($current_system_lang == '') { $current_system_lang = 'en'; } -$table->data[0][0] = __('Language code'); -$table->data[0][1] = html_print_select_from_sql( +$i = 0; + +$table->data[$i][0] = __('Language code'); +$table->data[$i++][1] = html_print_select_from_sql( 'SELECT id_language, name FROM tlanguage', 'language', $current_system_lang, @@ -71,68 +90,67 @@ $table->data[0][1] = html_print_select_from_sql( true ); -$table->data[1][0] = __('Remote config directory').ui_print_help_tip(__('Directory where agent remote configuration is stored.'), true); +$table->data[$i][0] = __('Remote config directory').ui_print_help_tip(__('Directory where agent remote configuration is stored.'), true); +$table->data[$i++][1] = html_print_input_text('remote_config', io_safe_output($config['remote_config']), '', 30, 100, true); -$table->data[1][1] = html_print_input_text('remote_config', io_safe_output($config['remote_config']), '', 30, 100, true); +$table->data[$i][0] = __('Phantomjs bin directory').ui_print_help_tip(__('Directory where phantomjs binary file exists and has execution grants.'), true); +$table->data[$i++][1] = html_print_input_text('phantomjs_bin', io_safe_output($config['phantomjs_bin']), '', 30, 100, true); -$table->data[2][0] = __('Phantomjs bin directory').ui_print_help_tip(__('Directory where phantomjs binary file exists and has execution grants.'), true); +$table->data[$i][0] = __('Auto login (hash) password'); +$table->data[$i++][1] = html_print_input_password('loginhash_pwd', io_output_password($config['loginhash_pwd']), '', 15, 15, true); -$table->data[2][1] = html_print_input_text('phantomjs_bin', io_safe_output($config['phantomjs_bin']), '', 30, 100, true); - -$table->data[6][0] = __('Auto login (hash) password'); -$table->data[6][1] = html_print_input_password('loginhash_pwd', io_output_password($config['loginhash_pwd']), '', 15, 15, true); - -$table->data[9][0] = __('Time source'); +$table->data[$i][0] = __('Time source'); $sources['system'] = __('System'); $sources['sql'] = __('Database'); -$table->data[9][1] = html_print_select($sources, 'timesource', $config['timesource'], '', '', '', true); +$table->data[$i++][1] = html_print_select($sources, 'timesource', $config['timesource'], '', '', '', true); -$table->data[10][0] = __('Automatic check for updates'); -$table->data[10][1] = html_print_checkbox_switch('autoupdate', 1, $config['autoupdate'], true); +$table->data[$i][0] = __('Automatic check for updates'); +$table->data[$i++][1] = html_print_checkbox_switch('autoupdate', 1, $config['autoupdate'], true); echo "'; -$table->data[11][0] = __('Enforce https'); -$table->data[11][1] = html_print_checkbox_switch_extended('https', 1, $config['https'], false, '', '', true); +$table->data[$i][0] = __('Enforce https'); +$table->data[$i++][1] = html_print_checkbox_switch_extended('https', 1, $config['https'], false, '', '', true); -$table->data[12][0] = __('Use cert of SSL'); -$table->data[12][1] = html_print_checkbox_switch_extended('use_cert', 1, $config['use_cert'], false, '', '', true); +$table->data[$i][0] = __('Use cert of SSL'); +$table->data[$i++][1] = html_print_checkbox_switch_extended('use_cert', 1, $config['use_cert'], false, '', '', true); -$table->rowstyle[13] = 'display: none;'; -$table->data[13][0] = __('Path of SSL Cert.').ui_print_help_tip(__('Path where you put your cert and name of this cert. Remember your cert only in .pem extension.'), true); -$table->data[13][1] = html_print_input_text('cert_path', io_safe_output($config['cert_path']), '', 50, 255, true); +$table->rowstyle[$i] = 'display: none;'; +$table->rowid[$i] = 'ssl-path-tr'; +$table->data[$i][0] = __('Path of SSL Cert.').ui_print_help_tip(__('Path where you put your cert and name of this cert. Remember your cert only in .pem extension.'), true); +$table->data[$i++][1] = html_print_input_text('cert_path', io_safe_output($config['cert_path']), '', 50, 255, true); -$table->data[14][0] = __('Attachment store').ui_print_help_tip(__('Directory where temporary data is stored.'), true); -$table->data[14][1] = html_print_input_text('attachment_store', io_safe_output($config['attachment_store']), '', 50, 255, true); +$table->data[$i][0] = __('Attachment store').ui_print_help_tip(__('Directory where temporary data is stored.'), true); +$table->data[$i++][1] = html_print_input_text('attachment_store', io_safe_output($config['attachment_store']), '', 50, 255, true); -$table->data[15][0] = __('IP list with API access'); +$table->data[$i][0] = __('IP list with API access'); if (isset($_POST['list_ACL_IPs_for_API'])) { $list_ACL_IPs_for_API = get_parameter_post('list_ACL_IPs_for_API'); } else { $list_ACL_IPs_for_API = get_parameter_get('list_ACL_IPs_for_API', implode("\n", $config['list_ACL_IPs_for_API'])); } -$table->data[15][1] = html_print_textarea('list_ACL_IPs_for_API', 2, 25, $list_ACL_IPs_for_API, 'style="height: 50px; width: 300px"', true); +$table->data[$i++][1] = html_print_textarea('list_ACL_IPs_for_API', 2, 25, $list_ACL_IPs_for_API, 'style="height: 50px; width: 300px"', true); -$table->data[16][0] = __('API password').ui_print_help_tip(__('Please be careful if you put a password put https access.'), true); -$table->data[16][1] = html_print_input_password('api_password', io_output_password($config['api_password']), '', 25, 255, true); +$table->data[$i][0] = __('API password').ui_print_help_tip(__('Please be careful if you put a password put https access.'), true); +$table->data[$i++][1] = html_print_input_password('api_password', io_output_password($config['api_password']), '', 25, 255, true); -$table->data[17][0] = __('Enable GIS features'); -$table->data[17][1] = html_print_checkbox_switch('activate_gis', 1, $config['activate_gis'], true); +$table->data[$i][0] = __('Enable GIS features'); +$table->data[$i++][1] = html_print_checkbox_switch('activate_gis', 1, $config['activate_gis'], true); -$table->data[19][0] = __('Enable Netflow'); +$table->data[$i][0] = __('Enable Netflow'); $rbt_disabled = false; if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $rbt_disabled = true; - $table->data[19][0] .= ui_print_help_tip(__('Not supported in Windows systems'), true); + $table->data[$i][0] .= ui_print_help_tip(__('Not supported in Windows systems'), true); } -$table->data[19][1] = html_print_checkbox_switch_extended('activate_netflow', 1, $config['activate_netflow'], $rbt_disabled, '', '', true); +$table->data[$i++][1] = html_print_checkbox_switch_extended('activate_netflow', 1, $config['activate_netflow'], $rbt_disabled, '', '', true); -$table->data[21][0] = __('Enable Network Traffic Analyzer'); -$table->data[21][1] = html_print_switch( +$table->data[$i][0] = __('Enable Network Traffic Analyzer'); +$table->data[$i++][1] = html_print_switch( [ 'name' => 'activate_nta', 'value' => $config['activate_nta'], @@ -171,11 +189,11 @@ foreach ($timezones as $timezone) { } } -$table->data[23][0] = __('Timezone setup').' '.ui_print_help_tip( +$table->data[$i][0] = __('Timezone setup').' '.ui_print_help_tip( __('Must have the same time zone as the system or database to avoid mismatches of time.'), true ); -$table->data[23][1] = html_print_input_text_extended( +$table->data[$i][1] = html_print_input_text_extended( 'timezone_text', $config['timezone'], 'text-timezone_text', @@ -187,47 +205,63 @@ $table->data[23][1] = html_print_input_text_extended( 'readonly', true ); -$table->data[23][1] .= ''.html_print_image('images/pencil.png', true, ['title' => __('Change timezone')]).''; -$table->data[23][1] .= '  '.html_print_select($zone_name, 'zone', $zone_selected, 'show_timezone();', '', '', true); -$table->data[23][1] .= '  '.html_print_select($timezone_n, 'timezone', $config['timezone'], '', '', '', true); +$table->data[$i][1] .= ''.html_print_image('images/pencil.png', true, ['title' => __('Change timezone')]).''; +$table->data[$i][1] .= '  '.html_print_select($zone_name, 'zone', $zone_selected, 'show_timezone();', '', '', true); +$table->data[$i++][1] .= '  '.html_print_select($timezone_n, 'timezone', $config['timezone'], '', '', '', true); $sounds = get_sounds(); -$table->data[24][0] = __('Sound for Alert fired'); -$table->data[24][1] = html_print_select($sounds, 'sound_alert', $config['sound_alert'], 'replaySound(\'alert\');', '', '', true); -$table->data[24][1] .= ' '.html_print_image('images/control_play_col.png', true, ['id' => 'button_sound_alert', 'style' => 'vertical-align: middle;', 'width' => '16', 'title' => __('Play sound')]).''; -$table->data[24][1] .= '
'; +$table->data[$i][0] = __('Sound for Alert fired'); +$table->data[$i][1] = html_print_select($sounds, 'sound_alert', $config['sound_alert'], 'replaySound(\'alert\');', '', '', true); +$table->data[$i][1] .= ' '.html_print_image('images/control_play_col.png', true, ['id' => 'button_sound_alert', 'style' => 'vertical-align: middle;', 'width' => '16', 'title' => __('Play sound')]).''; +$table->data[$i++][1] .= '
'; -$table->data[25][0] = __('Sound for Monitor critical'); -$table->data[25][1] = html_print_select($sounds, 'sound_critical', $config['sound_critical'], 'replaySound(\'critical\');', '', '', true); -$table->data[25][1] .= ' '.html_print_image('images/control_play_col.png', true, ['id' => 'button_sound_critical', 'style' => 'vertical-align: middle;', 'width' => '16', 'title' => __('Play sound')]).''; -$table->data[25][1] .= '
'; +$table->data[$i][0] = __('Sound for Monitor critical'); +$table->data[$i][1] = html_print_select($sounds, 'sound_critical', $config['sound_critical'], 'replaySound(\'critical\');', '', '', true); +$table->data[$i][1] .= ' '.html_print_image('images/control_play_col.png', true, ['id' => 'button_sound_critical', 'style' => 'vertical-align: middle;', 'width' => '16', 'title' => __('Play sound')]).''; +$table->data[$i++][1] .= '
'; -$table->data[26][0] = __('Sound for Monitor warning'); -$table->data[26][1] = html_print_select($sounds, 'sound_warning', $config['sound_warning'], 'replaySound(\'warning\');', '', '', true); -$table->data[26][1] .= ' '.html_print_image('images/control_play_col.png', true, ['id' => 'button_sound_warning', 'style' => 'vertical-align: middle;', 'width' => '16', 'title' => __('Play sound')]).''; -$table->data[26][1] .= '
'; +$table->data[$i][0] = __('Sound for Monitor warning'); +$table->data[$i][1] = html_print_select($sounds, 'sound_warning', $config['sound_warning'], 'replaySound(\'warning\');', '', '', true); +$table->data[$i][1] .= ' '.html_print_image('images/control_play_col.png', true, ['id' => 'button_sound_warning', 'style' => 'vertical-align: middle;', 'width' => '16', 'title' => __('Play sound')]).''; +$table->data[$i++][1] .= '
'; -$table->data[28][0] = __('Public URL'); -$table->data[28][0] .= ui_print_help_tip( +$table->data[$i][0] = __('Public URL'); +$table->data[$i][0] .= ui_print_help_tip( __('Set this value when your %s across inverse proxy or for example with mod_proxy of Apache.', get_product_name()).' '.__('Without the index.php such as http://domain/console_url/'), true ); -$table->data[28][1] = html_print_input_text('public_url', $config['public_url'], '', 40, 255, true); +$table->data[$i++][1] = html_print_input_text('public_url', $config['public_url'], '', 40, 255, true); -$table->data[29][0] = __('Referer security'); -$table->data[29][0] .= ui_print_help_tip(__("If enabled, actively checks if the user comes from %s's URL", get_product_name()), true); -$table->data[29][1] = html_print_checkbox_switch('referer_security', 1, $config['referer_security'], true); +$table->data[$i][0] = __('Force use Public URL'); +$table->data[$i][0] .= ui_print_help_tip(__('Force using defined public URL).', get_product_name()), true); +$table->data[$i++][1] = html_print_switch( + [ + 'name' => 'force_public_url', + 'value' => $config['force_public_url'], + ] +); -$table->data[30][0] = __('Event storm protection'); -$table->data[30][0] .= ui_print_help_tip(__('If set to yes no events or alerts will be generated, but agents will continue receiving data.'), true); -$table->data[30][1] = html_print_checkbox_switch('event_storm_protection', 1, $config['event_storm_protection'], true); +echo "'; + +$table->data[$i][0] = __('Public URL host exclusions'); +$table->data[$i++][1] = html_print_textarea('public_url_exclusions', 2, 25, $config['public_url_exclusions'], 'style="height: 50px; width: 300px"', true); + +$table->data[$i][0] = __('Referer security'); +$table->data[$i][0] .= ui_print_help_tip(__("If enabled, actively checks if the user comes from %s's URL", get_product_name()), true); +$table->data[$i++][1] = html_print_checkbox_switch('referer_security', 1, $config['referer_security'], true); + +$table->data[$i][0] = __('Event storm protection'); +$table->data[$i][0] .= ui_print_help_tip(__('If set to yes no events or alerts will be generated, but agents will continue receiving data.'), true); +$table->data[$i++][1] = html_print_checkbox_switch('event_storm_protection', 1, $config['event_storm_protection'], true); -$table->data[31][0] = __('Command Snapshot').ui_print_help_tip(__('The string modules with several lines show as command output'), true); -$table->data[31][1] = html_print_checkbox_switch('command_snapshot', 1, $config['command_snapshot'], true); +$table->data[$i][0] = __('Command Snapshot').ui_print_help_tip(__('The string modules with several lines show as command output'), true); +$table->data[$i++][1] = html_print_checkbox_switch('command_snapshot', 1, $config['command_snapshot'], true); -$table->data[32][0] = __('Server logs directory').ui_print_help_tip(__('Directory where the server logs are stored.'), true); -$table->data[32][1] = html_print_input_text( +$table->data[$i][0] = __('Server logs directory').ui_print_help_tip(__('Directory where the server logs are stored.'), true); +$table->data[$i++][1] = html_print_input_text( 'server_log_dir', $config['server_log_dir'], '', @@ -236,8 +270,8 @@ $table->data[32][1] = html_print_input_text( true ); -$table->data[33][0] = __('Log size limit in system logs viewer extension').ui_print_help_tip(__('Max size (in bytes) for the logs to be shown.'), true); -$table->data[33][1] = html_print_input_text( +$table->data[$i][0] = __('Log size limit in system logs viewer extension').ui_print_help_tip(__('Max size (in bytes) for the logs to be shown.'), true); +$table->data[$i++][1] = html_print_input_text( 'max_log_size', $config['max_log_size'], '', @@ -251,8 +285,8 @@ $modes_tutorial = [ 'on_demand' => __('On demand'), 'expert' => __('Expert'), ]; -$table->data['tutorial_mode'][0] = __('Tutorial mode').ui_print_help_tip(__("Configuration of our clippy, 'full mode' show the icon in the header and the contextual helps and it is noise, 'on demand' it is equal to full but it is not noise and 'expert' the icons in the header and the context is not."), true); -$table->data['tutorial_mode'][1] = html_print_select( +$table->data[$i][0] = __('Tutorial mode').ui_print_help_tip(__("Configuration of our clippy, 'full mode' show the icon in the header and the contextual helps and it is noise, 'on demand' it is equal to full but it is not noise and 'expert' the icons in the header and the context is not."), true); +$table->data[$i++][1] = html_print_select( $modes_tutorial, 'tutorial_mode', $config['tutorial_mode'], @@ -263,11 +297,11 @@ $table->data['tutorial_mode'][1] = html_print_select( ); $config['past_planned_downtimes'] = isset($config['past_planned_downtimes']) ? $config['past_planned_downtimes'] : 1; -$table->data[34][0] = __('Allow create planned downtimes in the past').ui_print_help_tip(__('The planned downtimes created in the past will affect the SLA reports'), true); -$table->data[34][1] = html_print_checkbox_switch('past_planned_downtimes', 1, $config['past_planned_downtimes'], true); +$table->data[$i][0] = __('Allow create planned downtimes in the past').ui_print_help_tip(__('The planned downtimes created in the past will affect the SLA reports'), true); +$table->data[$i++][1] = html_print_checkbox_switch('past_planned_downtimes', 1, $config['past_planned_downtimes'], true); -$table->data[35][0] = __('Limit for bulk operations').ui_print_help_tip(__('Your PHP environment is set to 1000 max_input_vars. This parameter should have the same value or lower.', ini_get('max_input_vars')), true); -$table->data[35][1] = html_print_input_text( +$table->data[$i][0] = __('Limit for bulk operations').ui_print_help_tip(__('Your PHP environment is set to 1000 max_input_vars. This parameter should have the same value or lower.', ini_get('max_input_vars')), true); +$table->data[$i++][1] = html_print_input_text( 'limit_parameters_massive', $config['limit_parameters_massive'], '', @@ -276,17 +310,17 @@ $table->data[35][1] = html_print_input_text( true ); -$table->data[36][0] = __('Include agents manually disabled'); -$table->data[36][1] = html_print_checkbox_switch('include_agents', 1, $config['include_agents'], true); +$table->data[$i][0] = __('Include agents manually disabled'); +$table->data[$i++][1] = html_print_checkbox_switch('include_agents', 1, $config['include_agents'], true); -$table->data[37][0] = __('Audit log directory').ui_print_help_tip(__('Directory where audit log is stored.'), true); -$table->data[37][1] = html_print_input_text('auditdir', io_safe_output($config['auditdir']), '', 30, 100, true); +$table->data[$i][0] = __('Audit log directory').ui_print_help_tip(__('Directory where audit log is stored.'), true); +$table->data[$i++][1] = html_print_input_text('auditdir', io_safe_output($config['auditdir']), '', 30, 100, true); -$table->data[38][0] = __('Set alias as name by default in agent creation'); -$table->data[38][1] = html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true); +$table->data[$i][0] = __('Set alias as name by default in agent creation'); +$table->data[$i++][1] = html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true); -$table->data[39][0] = __('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true); -$table->data[39][1] = html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true); +$table->data[$i][0] = __('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true); +$table->data[$i++][1] = html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true); echo ''; @@ -352,44 +386,50 @@ $(document).ready (function () { }); if ($("input[name=use_cert]").is(':checked')) { - $('#setup_general-13').show(); + $('#ssl-path-tr').show(); } $("input[name=use_cert]").change(function () { if( $(this).is(":checked") ) - $('#setup_general-13').show(); + $('#ssl-path-tr').show(); else - $('#setup_general-13').hide(); + $('#ssl-path-tr').hide(); }); $("input[name=https]").change(function (){ if($("input[name=https]").prop('checked')) { - $("#dialog").css({'display': 'inline', 'font-weight': 'bold'}).dialog({ + $("#dialog").dialog({ modal: true, - buttons:{ - "": function(){ - $(this).dialog("close"); + width: 500, + buttons:[ + { + class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-next', + text: "", + click: function(){ + $(this).dialog("close"); + } } - } + ] + }); + } + }) + + $("input[name=force_public_url]").change(function (){ + if($("input[name=force_public_url]").prop('checked')) { + $("#force_public_url_dialog").dialog({ + modal: true, + width: 500, + buttons: [ + { + class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-next', + text: "", + click: function(){ + $(this).dialog("close"); + } + } + ] }); } }) }); - '.$id; + + $type = []; + $alert = get_parameter('alert_fired'); + if ($alert == 'true') { + $resultAlert = alerts_get_event_status_group( + $idGroup, + [ + 'alert_fired', + 'alert_ceased', + ], + $query, + $agents + ); + } + + $critical = get_parameter('critical'); + if ($critical == 'true') { + $resultCritical = alerts_get_event_status_group( + $idGroup, + 'going_up_critical', + $query, + $agents + ); + } + + $warning = get_parameter('warning'); + if ($warning == 'true') { + $resultWarning = alerts_get_event_status_group( + $idGroup, + 'going_up_warning', + $query, + $agents + ); + } + + $unknown = get_parameter('unknown'); + if ($unknown == 'true') { + $resultUnknown = alerts_get_event_status_group( + $idGroup, + 'going_unknown', + $query, + $agents + ); + } + + if ($resultAlert) { + $return = [ + 'fired' => $resultAlert, + 'sound' => $config['sound_alert'], + ]; + $event = events_get_event($resultAlert); + + $module_name = modules_get_agentmodule_name($event['id_agentmodule']); + $agent_name = agents_get_alias($event['id_agente']); + + $return['message'] = io_safe_output($agent_name).' - '; + $return['message'] .= __('Alert fired in module '); + $return['message'] .= io_safe_output($module_name).' - '; + $return['message'] .= $event['timestamp']; + } else if ($resultCritical) { + $return = [ + 'fired' => $resultCritical, + 'sound' => $config['sound_critical'], + ]; + $event = events_get_event($resultCritical); + + $module_name = modules_get_agentmodule_name($event['id_agentmodule']); + $agent_name = agents_get_alias($event['id_agente']); + + $return['message'] = io_safe_output($agent_name).' - '; + $return['message'] .= __('Module ').io_safe_output($module_name); + $return['message'] .= __(' is going to critical').' - '; + $return['message'] .= $event['timestamp']; + } else if ($resultWarning) { + $return = [ + 'fired' => $resultWarning, + 'sound' => $config['sound_warning'], + ]; + $event = events_get_event($resultWarning); + + $module_name = modules_get_agentmodule_name($event['id_agentmodule']); + $agent_name = agents_get_alias($event['id_agente']); + + $return['message'] = io_safe_output($agent_name).' - '; + $return['message'] .= __('Module ').io_safe_output($module_name); + $return['message'] .= __(' is going to warning').' - '; + $return['message'] .= $event['timestamp']; + } else if ($resultUnknown) { + $return = [ + 'fired' => $resultUnknown, + 'sound' => $config['sound_alert'], + ]; + $event = events_get_event($resultUnknown); + + $module_name = modules_get_agentmodule_name($event['id_agentmodule']); + $agent_name = agents_get_alias($event['id_agente']); + + $return['message'] = io_safe_output($agent_name).' - '; + $return['message'] .= __('Module ').io_safe_output($module_name); + $return['message'] .= __(' is going to unknown').' - '; + $return['message'] .= $event['timestamp']; + } else { + $return = ['fired' => 0]; + } + + echo io_json_mb_encode($return); +} + diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index d03b360c16..07cd4f492e 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -1263,6 +1263,7 @@ class ConsoleSupervisor $PHPdisable_functions = ini_get('disable_functions'); $PHPupload_max_filesize_min = config_return_in_bytes('800M'); $PHPmemory_limit_min = config_return_in_bytes('500M'); + $PHPSerialize_precision = ini_get('serialize_precision'); // PhantomJS status. $result_ejecution = exec($config['phantomjs_bin'].'/phantomjs --version'); @@ -1438,6 +1439,30 @@ class ConsoleSupervisor } else { $this->cleanNotifications('NOTIF.PHP.VERSION'); } + + if ($PHPSerialize_precision != -1) { + $url = 'https://www.php.net/manual/en/ini.core.php#ini.serialize-precision'; + if ($config['language'] == 'es') { + $url = 'https://www.php.net/manual/es/ini.core.php#ini.serialize-precision'; + } + + $this->notify( + [ + 'type' => 'NOTIF.PHP.SERIALIZE_PRECISION', + 'title' => sprintf( + __("Not recommended '%s' value in PHP configuration"), + 'serialze_precision' + ), 'message' => sprintf( + __('Recommended value is: %s'), + sprintf('-1') + ).'

'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'), + 'url' => $url, + ] + ); + } else { + $this->cleanNotifications('NOTIF.PHP.SERIALIZE_PRECISION'); + } + } diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index f72acc3ef6..4fbbae4c88 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC190711'; +$build_version = 'PC190717'; $pandora_version = 'v7.0NG.736'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index a07af2ff1e..fdcce4457a 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1513,29 +1513,30 @@ function agents_get_name($id_agent, $case='none') * Get alias of an agent (cached function). * * @param integer $id_agent Agent id. - * @param string $case Case (upper, lower, none) + * @param string $case Case (upper, lower, none). * * @return string Alias of the given agent. */ function agents_get_alias($id_agent, $case='none') { global $config; - // Prepare cache + // Prepare cache. static $cache = []; if (empty($case)) { $case = 'none'; } - // Check cache + // Check cache. if (isset($cache[$case][$id_agent])) { return $cache[$case][$id_agent]; } - if (is_metaconsole()) { - $alias = (string) db_get_value('alias', 'tmetaconsole_agent', 'id_tagente', (int) $id_agent); - } else { - $alias = (string) db_get_value('alias', 'tagente', 'id_agente', (int) $id_agent); - } + $alias = (string) db_get_value( + 'alias', + 'tagente', + 'id_agente', + (int) $id_agent + ); switch ($case) { case 'upper': @@ -1545,6 +1546,10 @@ function agents_get_alias($id_agent, $case='none') case 'lower': $alias = mb_strtolower($alias, 'UTF-8'); break; + + default: + // Not posible. + break; } $cache[$case][$id_agent] = $alias; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 558260f7a8..f59061a03c 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -266,6 +266,14 @@ function config_update_config() $error_update[] = __('Public URL'); } + if (!config_update_value('force_public_url', get_parameter_switch('force_public_url'))) { + $error_update[] = __('Force use Public URL'); + } + + if (!config_update_value('public_url_exclusions', get_parameter('public_url_exclusions'))) { + $error_update[] = __('Public URL host exclusions'); + } + if (!config_update_value('referer_security', get_parameter('referer_security'))) { $error_update[] = __('Referer security'); } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 7a4dc7a11b..c8ad0a5d78 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -25,13 +25,17 @@ * GNU General Public License for more details. * ============================================================================ */ +global $config; require_once $config['homedir'].'/include/functions_ui.php'; require_once $config['homedir'].'/include/functions_tags.php'; require_once $config['homedir'].'/include/functions.php'; +require_once $config['homedir'].'/include/functions_reporting.php'; +enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once('meta/include/functions_events_meta.php'); enterprise_include_once('meta/include/functions_agents_meta.php'); enterprise_include_once('meta/include/functions_modules_meta.php'); +enterprise_include_once('meta/include/functions_events_meta.php'); /** @@ -4852,10 +4856,6 @@ function events_get_count_events_by_agent( $tagente = 'tagente'; $tevento = 'tevento'; - if ($dbmeta) { - $tagente = 'tmetaconsole_agent'; - $tevento = 'tmetaconsole_event'; - } $sql = sprintf( 'SELECT id_agente, @@ -4865,7 +4865,7 @@ function events_get_count_events_by_agent( COUNT(*) AS count FROM %s t3 WHERE utimestamp > %d AND utimestamp <= %d - AND id_grupo IN (%s) %s + AND id_grupo IN (%s) GROUP BY id_agente', $tagente, $tevento, @@ -5032,9 +5032,6 @@ function events_get_count_events_validated_by_user( } $tevento = 'tevento'; - if ($dbmeta) { - $tevento = 'tmetaconsole_event'; - } $sql = sprintf( 'SELECT id_usuario, @@ -5210,9 +5207,6 @@ function events_get_count_events_by_criticity( } $tevento = 'tevento'; - if ($dbmeta) { - $tevento = 'tmetaconsole_event'; - } $sql = sprintf( 'SELECT criticity, @@ -5418,9 +5412,6 @@ function events_get_count_events_validated( } $tevento = 'tevento'; - if ($dbmeta) { - $tevento = 'tmetaconsole_event'; - } $sql = sprintf('SELECT estado, COUNT(*) AS count FROM %s WHERE %s %s GROUP BY estado', $tevento, $sql_filter, $sql_where); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index b1e70b5c1a..d6ce0ba8af 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1277,12 +1277,34 @@ function graphic_combined_module( array_push($modules, $source['id_agent_module']); array_push($weights, $source['weight']); if ($source['label'] != '' || $params_combined['labels']) { - $item['type'] = 'custom_graph'; - $item['id_agent'] = agents_get_module_id( + $id_agent = agents_get_module_id( $source['id_agent_module'] ); - $item['id_agent_module'] = $source['id_agent_module']; - $labels[$source['id_agent_module']] = ($source['label'] != '') ? reporting_label_macro($item, $source['label']) : reporting_label_macro($item, $params_combined['labels']); + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $source['id_agent_module'] + ); + + $module_description = modules_get_agentmodule_descripcion( + $source['id_agent_module'] + ); + + $items_label = [ + 'type' => 'custom_graph', + 'id_agent' => $id_agent, + 'id_agent_module' => $source['id_agent_module'], + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $labels[$source['id_agent_module']] = ($source['label'] != '') ? reporting_label_macro($items_label, $source['label']) : reporting_label_macro($item, $params_combined['labels']); } } } @@ -2161,7 +2183,7 @@ function graphic_combined_module( $graph_values = $temp; if (!$params['vconsole']) { - $width = 1024; + $width = $width; $height = 500; } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 18ee4d3940..fc704e2d46 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -77,8 +77,7 @@ function html_debug_print($var, $file='', $oneline=false) fprintf($f, '%s', $output); fclose($f); } else { - echo '
'.date('Y/m/d H:i:s').' ('.gettype($var).') '.$more_info.'
'; - echo '
';
+        echo '
'.date('Y/m/d H:i:s').' ('.gettype($var).') '.$more_info."\n";
         print_r($var);
         echo '
'; } diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 5d43c8fd19..fbee2a5331 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -566,11 +566,11 @@ function modules_update_agent_module( /** * Creates a module in an agent. * - * @param int Agent id. - * @param int Module name id. - * @param array Extra values for the module. - * @param bool Disable the ACL checking, for default false. - * @param mixed Array with tag's ids or false. + * @param integer $id_agent Agent id. + * @param integer $name Module name id. + * @param array $values Extra values for the module. + * @param boolean $disableACL Disable the ACL checking, for default false. + * @param mixed $tags Array with tag's ids or false. * * @return New module id if the module was created. False if not. */ @@ -584,7 +584,9 @@ function modules_create_agent_module( global $config; if (!$disableACL) { - if (!users_is_admin() && (empty($id_agent) || ! users_access_to_agent($id_agent, 'AW'))) { + if (!users_is_admin() && (empty($id_agent) + || !users_access_to_agent($id_agent, 'AW')) + ) { return false; } } @@ -593,7 +595,7 @@ function modules_create_agent_module( return ERR_INCOMPLETE; } - // Check for non valid characters in module name + // Check for non valid characters in module name. if (mb_ereg_match('[\xc2\xa1\xc2\xbf\xc3\xb7\xc2\xba\xc2\xaa]', io_safe_output($name)) !== false) { return ERR_GENERIC; } @@ -605,23 +607,33 @@ function modules_create_agent_module( $values['nombre'] = $name; $values['id_agente'] = (int) $id_agent; - $exists = (bool) db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['nombre' => $name, 'id_agente' => (int) $id_agent]); + $exists = (bool) db_get_value_filter( + 'id_agente_modulo', + 'tagente_modulo', + [ + 'nombre' => $name, + 'id_agente' => (int) $id_agent, + ] + ); if ($exists) { return ERR_EXIST; } - // Encrypt passwords + // Encrypt passwords. if (isset($values['plugin_pass'])) { $values['plugin_pass'] = io_input_password($values['plugin_pass']); } - // Encrypt SNMPv3 passwords - if (isset($values['id_tipo_modulo']) && ($values['id_tipo_modulo'] >= 15 && $values['id_tipo_modulo'] <= 18) + // Encrypt SNMPv3 passwords. + if (isset($values['id_tipo_modulo']) && ($values['id_tipo_modulo'] >= 15 + && $values['id_tipo_modulo'] <= 18) && isset($values['tcp_send']) && ($values['tcp_send'] == 3) && isset($values['custom_string_2']) ) { - $values['custom_string_2'] = io_input_password($values['custom_string_2']); + $values['custom_string_2'] = io_input_password( + $values['custom_string_2'] + ); } $id_agent_module = db_process_sql_insert('tagente_modulo', $values); @@ -645,25 +657,33 @@ function modules_create_agent_module( } if (isset($values['id_tipo_modulo']) - && ($values['id_tipo_modulo'] == 21 || $values['id_tipo_modulo'] == 22 || $values['id_tipo_modulo'] == 23) + && ($values['id_tipo_modulo'] == 21 + || $values['id_tipo_modulo'] == 22 + || $values['id_tipo_modulo'] == 23) ) { - // Async modules start in normal status + // Async modules start in normal status. $status = AGENT_MODULE_STATUS_NORMAL; } else { - // Sync modules start in unknown status + // Sync modules start in unknown status. $status = AGENT_MODULE_STATUS_NO_DATA; } + // Condition for cron modules. Don't touch. + $time = 0; + if (empty($values['interval']) === false) { + $time = (time() - (int) $values['interval']); + } + $result = db_process_sql_insert( 'tagente_estado', [ 'id_agente_modulo' => $id_agent_module, - 'datos' => 0, + 'datos' => '', 'timestamp' => '01-01-1970 00:00:00', 'estado' => $status, 'known_status' => $status, 'id_agente' => (int) $id_agent, - 'utimestamp' => (time() - (int) $values['interval']), + 'utimestamp' => $time, 'status_changes' => 0, 'last_status' => $status, 'last_known_status' => $status, @@ -680,12 +700,20 @@ function modules_create_agent_module( return ERR_DB; } - // Update module status count if the module is not created disabled + // Update module status count if the module is not created disabled. if (!isset($values['disabled']) || $values['disabled'] == 0) { if ($status == 0) { - db_process_sql('UPDATE tagente SET total_count=total_count+1, normal_count=normal_count+1 WHERE id_agente='.(int) $id_agent); + db_process_sql( + 'UPDATE tagente + SET total_count=total_count+1, normal_count=normal_count+1 + WHERE id_agente='.(int) $id_agent + ); } else { - db_process_sql('UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente='.(int) $id_agent); + db_process_sql( + 'UPDATE tagente + SET total_count=total_count+1, notinit_count=notinit_count+1 + WHERE id_agente='.(int) $id_agent + ); } } diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 69aa0a1608..f1febb5c41 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -35,8 +35,8 @@ define('NETFLOW_RES_LOWD', 6); define('NETFLOW_RES_MEDD', 12); define('NETFLOW_RES_HID', 24); define('NETFLOW_RES_ULTRAD', 30); -define('NETFLOW_RES_HOURLY', 'hourly'); -define('NETFLOW_RES_DAILY', 'daily'); +define('NETFLOW_RES_HOURLY', -1); +define('NETFLOW_RES_DAILY', -2); define('NETFLOW_MAX_DATA_CIRCULAR_MESH', 10000); @@ -473,7 +473,7 @@ function netflow_get_data( // Put all points into an array. $intervals = [($start_date - $multiplier_time)]; - while ((end($intervals) < $end_date) === true) { + while (($next = (end($intervals) + $multiplier_time) < $end_date) === true) { $intervals[] = (end($intervals) + $multiplier_time); } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 97766305a2..083be8b063 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -251,12 +251,16 @@ function reporting_make_reporting_data( if ($metaconsole_on && $server_name != '') { $connection = metaconsole_get_connection($server_name); if (!metaconsole_load_external_db($connection)) { - // ui_print_error_message ("Error connecting to ".$server_name); continue; } } - array_push($agents_to_macro, modules_get_agentmodule_agent($graph_item['id_agent_module'])); + array_push( + $agents_to_macro, + modules_get_agentmodule_agent( + $graph_item['id_agent_module'] + ) + ); if ($metaconsole_on) { // Restore db connection. metaconsole_restore_db(); @@ -296,33 +300,54 @@ function reporting_make_reporting_data( if (!metaconsole_load_external_db($connection)) { continue; } + } - $items_label['agent_description'] = agents_get_description($content['id_agent']); - $items_label['agent_group'] = agents_get_agent_group($content['id_agent']); - $items_label['agent_address'] = agents_get_address($content['id_agent']); + $items_label['agent_description'] = agents_get_description( + $content['id_agent'] + ); + $items_label['agent_group'] = agents_get_agent_group( + $content['id_agent'] + ); + $items_label['agent_address'] = agents_get_address( + $content['id_agent'] + ); + $items_label['agent_alias'] = agents_get_alias( + $content['id_agent'] + ); - $modules = agents_get_modules( - $agent_value, - [ - 'id_agente_modulo', - 'nombre', - 'descripcion', - ], - [ - 'id_agente_modulo' => $content['id_agent_module'], - ] + $modules = agents_get_modules( + $agent_value, + [ + 'id_agente_modulo', + 'nombre', + 'descripcion', + ], + [ + 'id_agente_modulo' => $content['id_agent_module'], + ] + ); + + $items_label['module_name'] = $modules[$content['id_agent_module']]['nombre']; + $items_label['module_description'] = $modules[$content['id_agent_module']]['descripcion']; + + if (is_array($content['id_agent']) + && count($content['id_agent']) != 1 + ) { + $content['style']['name_label'] = str_replace( + '_agent_', + count($content['id_agent']).__(' agents'), + $content['style']['name_label'] ); - - $items_label['module_name'] = $modules[$content['id_agent_module']]['nombre']; - $items_label['module_description'] = $modules[$content['id_agent_module']]['descripcion']; } - if (is_array($content['id_agent']) && count($content['id_agent']) != 1) { - $content['style']['name_label'] = str_replace('_agent_', count($content['id_agent']).__(' agents'), $content['style']['name_label']); - } - - if (is_array($content['id_agent_module']) && count($content['id_agent_module']) != 1) { - $content['style']['name_label'] = str_replace('_module_', count($content['id_agent_module']).__(' modules'), $content['style']['name_label']); + if (is_array($content['id_agent_module']) + && count($content['id_agent_module']) != 1 + ) { + $content['style']['name_label'] = str_replace( + '_module_', + count($content['id_agent_module']).__(' modules'), + $content['style']['name_label'] + ); } if ($metaconsole_on) { @@ -330,7 +355,10 @@ function reporting_make_reporting_data( metaconsole_restore_db(); } - $content['name'] = reporting_label_macro($items_label, $content['style']['name_label']); + $content['name'] = reporting_label_macro( + $items_label, + $content['style']['name_label'] + ); } switch (reporting_get_type($content)) { @@ -1926,6 +1954,18 @@ function reporting_event_report_group( } +/** + * Events for module reports. + * + * @param array $report Report info. + * @param array $content Content info. + * @param string $type Type retun report. + * @param integer $force_width_chart Width chart. + * @param integer $force_height_chart Height chart. + * @param integer $pdf If pdf report. + * + * @return array + */ function reporting_event_report_module( $report, $content, @@ -1954,12 +1994,42 @@ function reporting_event_report_module( metaconsole_connect(null, $id_server); } - $return['title'] = $content['name']; - $return['subtitle'] = agents_get_alias($content['id_agent']).' - '.io_safe_output(modules_get_agentmodule_name($content['id_agent_module'])); + $id_agent = agents_get_module_id( + $content['id_agent_module'] + ); + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + $items_label = [ + 'type' => $content['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $return['title'] = $content['name']; + $return['subtitle'] = $agent_alias.' - '.io_safe_output($module_name); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } if (is_metaconsole()) { @@ -1973,15 +2043,24 @@ function reporting_event_report_module( $event_filter = $content['style']; $return['show_summary_group'] = $event_filter['show_summary_group']; // Filter. - $show_summary_group = $event_filter['show_summary_group']; - $filter_event_severity = json_decode($event_filter['filter_event_severity'], true); - $filter_event_type = json_decode($event_filter['filter_event_type'], true); - $filter_event_status = json_decode($event_filter['filter_event_status'], true); + $show_summary_group = $event_filter['show_summary_group']; + $filter_event_severity = json_decode( + $event_filter['filter_event_severity'], + true + ); + $filter_event_type = json_decode( + $event_filter['filter_event_type'], + true + ); + $filter_event_status = json_decode( + $event_filter['filter_event_status'], + true + ); $filter_event_filter_search = $event_filter['event_filter_search']; // Graphs. - $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; - $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; + $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; + $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated']; $server_name = $content['server_name']; @@ -2819,8 +2898,42 @@ function reporting_event_report_agent( $history = true; } + $id_server = false; + if (is_metaconsole()) { + $id_server = metaconsole_get_id_server($content['server_name']); + metaconsole_connect(null, $id_server); + } + + $id_agent = $content['id_agent']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + ]; + + if ($config['metaconsole']) { + metaconsole_restore_db(); + } + + $label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + if ($label != '') { + $label = reporting_label_macro( + $items_label, + $label + ); + } + + $return['label'] = $label; $return['title'] = $content['name']; - $return['subtitle'] = io_safe_output(agents_get_alias($content['id_agent'])); + $return['subtitle'] = io_safe_output($agent_alias); $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); @@ -2883,13 +2996,6 @@ function reporting_event_report_agent( $metaconsole_dbtable = false; } - $label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; - if ($label != '') { - $label = reporting_label_macro($content, $label); - } - - $return['label'] = $label; - if ($event_graph_by_user_validator) { $data_graph = events_get_count_events_validated_by_user( ['id_agent' => $content['id_agent']], @@ -2969,10 +3075,6 @@ function reporting_event_report_agent( ); } - if ($config['metaconsole']) { - metaconsole_restore_db(); - } - // Total events. if ($return['data'] != '') { $return['total_events'] = count($return['data']); @@ -2984,6 +3086,14 @@ function reporting_event_report_agent( } +/** + * Show historical data. + * + * @param array $report Data report. + * @param array $content Content report. + * + * @return array + */ function reporting_historical_data($report, $content) { global $config; @@ -2995,21 +3105,46 @@ function reporting_historical_data($report, $content) $content['name'] = __('Historical data'); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) + $id_agent = agents_get_module_id( + $content['id_agent_module'] ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias($content['id_agent_module']) + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = io_safe_output(agents_get_alias($id_agent)); + $module_name = io_safe_output( + modules_get_agentmodule_name( + $id_agent_module + ) + ); + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module ); + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + $return['title'] = $content['name']; - $return['subtitle'] = $agent_name.' - '.$module_name; + $return['subtitle'] = $agent_alias.' - '.$module_name; $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } $return['keys'] = [ @@ -3065,6 +3200,14 @@ function reporting_historical_data($report, $content) } +/** + * Show data serialized. + * + * @param array $report Data report. + * @param array $content Content report. + * + * @return array + */ function reporting_database_serialized($report, $content) { global $config; @@ -3075,15 +3218,43 @@ function reporting_database_serialized($report, $content) $content['name'] = __('Database Serialized'); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) - ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias($content['id_agent_module']) + if (is_metaconsole()) { + $id_meta = metaconsole_get_id_server($content['server_name']); + $server = metaconsole_get_connection_by_id($id_meta); + metaconsole_connect($server); + } + + $id_agent = agents_get_module_id( + $content['id_agent_module'] ); + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + $return['title'] = $content['name']; - $return['subtitle'] = $agent_name.' - '.$module_name; + $return['subtitle'] = $agent_alias.' - '.$module_name; $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); @@ -3093,33 +3264,21 @@ function reporting_database_serialized($report, $content) } $return['keys'] = $keys; - - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) - ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_name($content['id_agent_module']) - ); - - $return['agent_name'] = $agent_name; + $return['agent_name'] = $agent_alias; $return['module_name'] = $module_name; - if ($config['metaconsole']) { - $id_meta = metaconsole_get_id_server($content['server_name']); - - $server = metaconsole_get_connection_by_id($id_meta); - metaconsole_connect($server); - } - $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } $datelimit = ($report['datetime'] - $content['period']); $search_in_history_db = db_search_in_history_db($datelimit); - // This query gets information from the default and the historic database + // This query gets information from the default and the historic database. $result = db_get_all_rows_sql( 'SELECT * FROM tagente_datos @@ -3129,9 +3288,9 @@ function reporting_database_serialized($report, $content) $search_in_history_db ); - // Adds string data if there is no numeric data - if ((count($result) < 0) or (!$result)) { - // This query gets information from the default and the historic database + // Adds string data if there is no numeric data. + if ((count($result) < 0) || (!$result)) { + // This query gets information from the default and the historic database. $result = db_get_all_rows_sql( 'SELECT * FROM tagente_datos_string @@ -3151,13 +3310,16 @@ function reporting_database_serialized($report, $content) $date = date($config['date_format'], $row['utimestamp']); $serialized_data = $row['datos']; - // Cut line by line + // Cut line by line. if (empty($content['line_separator']) || empty($serialized_data) ) { $rowsUnserialize = [$row['datos']]; } else { - $rowsUnserialize = explode($content['line_separator'], $serialized_data); + $rowsUnserialize = explode( + $content['line_separator'], + $serialized_data + ); } foreach ($rowsUnserialize as $rowUnser) { @@ -3173,7 +3335,10 @@ function reporting_database_serialized($report, $content) $row['data'][][$keys[0]] = $rowUnser; } } else { - $columnsUnserialize = explode($content['column_separator'], $rowUnser); + $columnsUnserialize = explode( + $content['column_separator'], + $rowUnser + ); $i = 0; $temp_row = []; @@ -3639,6 +3804,14 @@ function reporting_alert_report_group($report, $content) } +/** + * Report alert agent. + * + * @param array $report Info report. + * @param array $content Content report. + * + * @return array + */ function reporting_alert_report_agent($report, $content) { global $config; @@ -3656,16 +3829,33 @@ function reporting_alert_report_agent($report, $content) metaconsole_connect($server); } - $agent_name = agents_get_alias($content['id_agent']); + $id_agent = $content['id_agent']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + ]; $return['title'] = $content['name']; - $return['subtitle'] = $agent_name; + $return['subtitle'] = $agent_alias; $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } $module_list = agents_get_modules($content['id_agent']); @@ -3673,10 +3863,10 @@ function reporting_alert_report_agent($report, $content) $data = []; foreach ($module_list as $id => $module_name) { $data_row = []; - $data_row['agent'] = $agent_name; + $data_row['agent'] = $agent_alias; $data_row['module'] = $module_name; - // Alerts over $id_agent_module + // Alerts over $id_agent_module. $alerts = alerts_get_effective_alert_actions($id); if ($alerts === false) { @@ -3770,6 +3960,14 @@ function reporting_alert_report_agent($report, $content) } +/** + * Alert report module. + * + * @param array $report Info report. + * @param array $content Content report. + * + * @return array + */ function reporting_alert_report_module($report, $content) { global $config; @@ -3787,36 +3985,56 @@ function reporting_alert_report_module($report, $content) metaconsole_connect($server); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) + $id_agent = agents_get_module_id( + $content['id_agent_module'] ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias($content['id_agent_module']) + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module ); + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + $return['title'] = $content['name']; - $return['subtitle'] = $agent_name.' - '.$module_name; + $return['subtitle'] = $agent_alias.' - '.$module_name; $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } $data_row = []; - $data_row['agent'] = io_safe_output( - agents_get_alias( - agents_get_agent_id_by_module_id($content['id_agent_module']) - ) - ); + $data_row['agent'] = io_safe_output($agent_alias); $data_row['module'] = db_get_value_filter( 'nombre', 'tagente_modulo', ['id_agente_modulo' => $content['id_agent_module']] ); - // Alerts over $id_agent_module + // Alerts over $id_agent_module. $alerts = alerts_get_effective_alert_actions($content['id_agent_module']); $ntemplates = 0; @@ -3945,7 +4163,7 @@ function reporting_sql_graph( } } - // Get chart + // Get chart. reporting_set_conf_charts($width, $height, $only_image, $type, $content, $ttl); if (!empty($force_width_chart)) { @@ -3983,6 +4201,14 @@ function reporting_sql_graph( } +/** + * Monitor report module. + * + * @param array $report Info report. + * @param array $content Content report. + * + * @return array + */ function reporting_monitor_report($report, $content) { global $config; @@ -3993,48 +4219,67 @@ function reporting_monitor_report($report, $content) $content['name'] = __('Monitor Report'); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) - ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias($content['id_agent_module']) - ); - - $return['title'] = $content['name']; - $return['subtitle'] = $agent_name.' - '.$module_name; - $return['description'] = $content['description']; - $return['date'] = reporting_get_date_text($report, $content); - - if ($config['metaconsole']) { + if (is_metaconsole()) { $id_meta = metaconsole_get_id_server($content['server_name']); $server = metaconsole_get_connection_by_id($id_meta); metaconsole_connect($server); } + $id_agent = agents_get_module_id( + $content['id_agent_module'] + ); + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $return['title'] = $content['name']; + $return['subtitle'] = $agent_alias.' - '.$module_name; + $return['description'] = $content['description']; + $return['date'] = reporting_get_date_text($report, $content); + $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) - ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_name($content['id_agent_module']) - ); - - $return['agent_name'] = $agent_name; + $return['agent_name'] = $agent_alias; $return['module_name'] = $module_name; - // All values (except id module and report time) by default + // All values (except id module and report time) by default. $report = reporting_advanced_sla( $content['id_agent_module'], ($report['datetime'] - $content['period']), $report['datetime'] ); - if ($report['time_total'] === $report['time_unknown'] || empty($content['id_agent_module'])) { + if ($report['time_total'] === $report['time_unknown'] + || empty($content['id_agent_module']) + ) { $return['data']['unknown'] = 1; } else { $return['data']['ok']['value'] = $report['SLA']; @@ -7572,6 +7817,17 @@ function reporting_custom_graph( } +/** + * Simple graph report. + * + * @param array $report Info report. + * @param array $content Content report. + * @param string $type Type report. + * @param integer $force_width_chart Width chart. + * @param integer $force_height_chart Height chart. + * + * @return array + */ function reporting_simple_graph( $report, $content, @@ -7581,13 +7837,6 @@ function reporting_simple_graph( ) { global $config; - if ($config['metaconsole']) { - $id_meta = metaconsole_get_id_server($content['server_name']); - - $server = metaconsole_get_connection_by_id($id_meta); - metaconsole_connect($server); - } - $return = []; $return['type'] = 'simple_graph'; @@ -7595,16 +7844,52 @@ function reporting_simple_graph( $content['name'] = __('Simple graph'); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) + if ($config['metaconsole']) { + $id_meta = metaconsole_get_id_server($content['server_name']); + + $server = metaconsole_get_connection_by_id($id_meta); + metaconsole_connect($server); + } + + $id_agent = agents_get_module_id( + $content['id_agent_module'] ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias($content['id_agent_module']) + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module ); + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + if ($label != '') { + $label = reporting_label_macro( + $items_label, + $label + ); + } + $return['title'] = $content['name']; - $return['subtitle'] = $agent_name.' - '.$module_name; - $return['agent_name'] = $agent_name; + $return['subtitle'] = $agent_alias.' - '.$module_name; + $return['agent_name'] = $agent_alias; $return['module_name'] = $module_name; $return['description'] = $content['description']; $return['date'] = reporting_get_date_text( @@ -7612,11 +7897,6 @@ function reporting_simple_graph( $content ); - $label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; - if ($label != '') { - $label = reporting_label_macro($content, $label); - } - if (isset($content['style']['fullscale'])) { $fullscale = (bool) $content['style']['fullscale']; } @@ -7624,7 +7904,14 @@ function reporting_simple_graph( $return['chart'] = ''; // Get chart. - reporting_set_conf_charts($width, $height, $only_image, $type, $content, $ttl); + reporting_set_conf_charts( + $width, + $height, + $only_image, + $type, + $content, + $ttl + ); if (!empty($force_width_chart)) { $width = $force_width_chart; @@ -7650,7 +7937,12 @@ function reporting_simple_graph( 'pure' => false, 'date' => $report['datetime'], 'only_image' => $only_image, - 'homeurl' => ui_get_full_url(false, false, false, false), + 'homeurl' => ui_get_full_url( + false, + false, + false, + false + ), 'ttl' => $ttl, 'compare' => $time_compare_overlapped, 'show_unknown' => true, @@ -7661,7 +7953,6 @@ function reporting_simple_graph( ]; $return['chart'] = grafico_modulo_sparse($params); - break; case 'data': @@ -7675,6 +7966,10 @@ function reporting_simple_graph( $return['chart'][$d['utimestamp']] = $d['data']; } break; + + default: + // Not Possible. + break; } if ($config['metaconsole']) { @@ -11713,149 +12008,72 @@ function reporting_get_agentmodule_sla_working_timestamp($period, $date_end, $wt } +/** + * Convert macros for value. + * Item content: + * type + * id_agent + * id_agent_module + * agent_description + * agent_group + * agent_address + * agent_alias + * module_name + * module_description. + * + * @param array $item Data to replace in the macros. + * @param string $label String check macros. + * + * @return string + */ function reporting_label_macro($item, $label) { - switch ($item['type']) { - case 'event_report_agent': - case 'alert_report_agent': - case 'agent_configuration': - case 'event_report_log': - if (preg_match('/_agent_/', $label)) { - $agent_name = agents_get_alias($item['id_agent']); - $label = str_replace('_agent_', $agent_name, $label); - } + if (preg_match('/_agent_/', $label)) { + $label = str_replace( + '_agent_', + $item['agent_alias'], + $label + ); + } - if (preg_match('/_agentdescription_/', $label)) { - if (!is_metaconsole()) { - $agent_name = agents_get_description($item['id_agent']); - } else { - $agent_name = $item['agent_description']; - } + if (preg_match('/_agentdescription_/', $label)) { + $label = str_replace( + '_agentdescription_', + $item['agent_description'], + $label + ); + } - $label = str_replace('_agentdescription_', $agent_name, $label); - } + if (preg_match('/_agentgroup_/', $label)) { + $label = str_replace( + '_agentgroup_', + $item['agent_group'], + $label + ); + } - if (preg_match('/_agentgroup_/', $label)) { - if (!is_metaconsole()) { - $agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true); - } else { - $agent_name = $item['agent_group']; - } + if (preg_match('/_address_/', $label)) { + $label = str_replace( + '_address_', + $item['agent_address'], + $label + ); + } - $label = str_replace('_agentgroup_', $agent_name, $label); - } + if (preg_match('/_module_/', $label)) { + $label = str_replace( + '_module_', + $item['module_name'], + $label + ); + } - if (preg_match('/_address_/', $label)) { - if (!is_metaconsole()) { - $agent_name = agents_get_address($item['id_agent']); - } else { - $agent_name = $item['agent_address']; - } - - $label = str_replace('_address_', $agent_name, $label); - } - break; - - case 'simple_graph': - case 'module_histogram_graph': - case 'custom_graph': - case 'simple_baseline_graph': - case 'event_report_module': - case 'alert_report_module': - case 'historical_data': - case 'sumatory': - case 'database_serialized': - case 'monitor_report': - case 'min_value': - case 'max_value': - case 'avg_value': - case 'projection_graph': - case 'prediction_date': - case 'TTRT': - case 'TTO': - case 'MTBF': - case 'MTTR': - case 'automatic_graph': - if (preg_match('/_agent_/', $label)) { - if (isset($item['agents']) && count($item['agents']) > 1) { - $agent_name = count($item['agents']).__(' agents'); - } else { - $agent_name = agents_get_alias($item['id_agent']); - } - - $label = str_replace('_agent_', $agent_name, $label); - } - - if (preg_match('/_agentdescription_/', $label)) { - if (count($item['agents']) > 1) { - $agent_name = ''; - } else { - if (!is_metaconsole()) { - $agent_name = agents_get_description($item['id_agent']); - } else { - $agent_name = $item['agent_description']; - } - } - - $label = str_replace('_agentdescription_', $agent_name, $label); - } - - if (preg_match('/_agentgroup_/', $label)) { - if (count($item['agents']) > 1) { - $agent_name = ''; - } else { - if (!is_metaconsole()) { - $agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true); - } else { - $agent_name = $item['agent_group']; - } - } - - $label = str_replace('_agentgroup_', $agent_name, $label); - } - - if (preg_match('/_address_/', $label)) { - if (count($item['agents']) > 1) { - $agent_name = ''; - } else { - if (!is_metaconsole()) { - $agent_name = agents_get_address($item['id_agent']); - } else { - $agent_name = $item['agent_address']; - } - } - - $label = str_replace('_address_', $agent_name, $label); - } - - if (preg_match('/_module_/', $label)) { - if ($item['modules'] > 1) { - $module_name = $item['modules'].__(' modules'); - } else { - if (!is_metaconsole()) { - $module_name = modules_get_agentmodule_name($item['id_agent_module']); - } else { - $module_name = $item['module_name']; - } - } - - $label = str_replace('_module_', $module_name, $label); - } - - if (preg_match('/_moduledescription_/', $label)) { - if ($item['modules'] > 1) { - $module_description = ''; - } else { - if (!is_metaconsole()) { - $module_description = modules_get_agentmodule_descripcion($item['id_agent_module']); - } else { - $module_description = $item['module_description']; - } - } - - $label = str_replace('_moduledescription_', $module_description, $label); - } - break; + if (preg_match('/_moduledescription_/', $label)) { + $label = str_replace( + '_moduledescription_', + $item['module_description'], + $label + ); } return $label; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index de32e94312..6a7d60c620 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -141,6 +141,15 @@ function html_do_report_info($report) } +/** + * Print html report. + * + * @param array $report Info. + * @param boolean $mini Type. + * @param integer $report_info Show info. + * + * @return array + */ function reporting_html_print_report($report, $mini=false, $report_info=1) { if ($report_info == 1) { @@ -161,7 +170,38 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) $table->rowstyle = []; if (isset($item['label']) && $item['label'] != '') { - $label = reporting_label_macro($item, $item['label']); + $id_agent = $item['id_agent']; + $id_agent_module = $item['id_agent_module']; + + // Add macros name. + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_label = [ + 'type' => $item['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $label = reporting_label_macro( + $items_label, + $item['label'] + ); } else { $label = ''; } @@ -180,7 +220,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) $table->data['description_row']['description'] = $item['description']; - if ($item['type'] == 'event_report_agent' || $item['type'] == 'event_report_group' || $item['type'] == 'event_report_module') { + if ($item['type'] == 'event_report_agent' + || $item['type'] == 'event_report_group' + || $item['type'] == 'event_report_module' + ) { $table->data['count_row']['count'] = 'Total events: '.$item['total_events']; } @@ -759,7 +802,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) $table1->size[10] = '2%'; $table1->data[0][10] = ''; $table1->size[11] = '15%'; - $table1->data[0][11] = ''.__('Ignore time').''; + $table1->data[0][11] = ''.__('Planned Downtime').''; if ($pdf === 0) { $table->colspan['legend']['cell'] = 2; @@ -3399,7 +3442,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0) $table2->size[10] = '2%'; $table2->data[0][10] = ''; $table2->size[11] = '15%'; - $table2->data[0][11] = ''.__('Ignore time').''; + $table2->data[0][11] = ''.__('Planned Downtime').''; } if ($pdf !== 0) { diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 0850dcbfac..5f82faa91d 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -32,9 +32,9 @@ require_once __DIR__.'/constants.php'; /** * Get a server. * - * @param int Server id to get. - * @param array Extra filter. - * @param array Fields to get. + * @param integer $id_server Server id to get. + * @param array $filter Extra filter. + * @param array $fields Fields to get. * * @return Server with the given id. False if not available. */ @@ -61,7 +61,12 @@ function servers_get_server($id_server, $filter=false, $fields=false) */ function servers_get_names() { - $all_servers = @db_get_all_rows_filter('tserver', false, ['DISTINCT(name) as name']); + $all_servers = db_get_all_rows_sql( + 'SELECT DISTINCT(`name`) as name + FROM tserver + WHERE server_type <> 13' + ); + if ($all_servers === false) { return []; } @@ -76,7 +81,11 @@ function servers_get_names() /** - * This function forces a recon task to be queued by the server asap + * This function forces a recon task to be queued by the server asap. + * + * @param integer $id_recon_task Id. + * + * @return void */ function servers_force_recon_task($id_recon_task) { @@ -141,9 +150,10 @@ function servers_get_total_modules() /** - * This function will get several metrics from the database to get info about server performance + * This function will get several metrics from the database + * to get info about server performance. * - * @return array with several data + * @return array with several data. */ function servers_get_performance() { @@ -161,18 +171,20 @@ function servers_get_performance() if ($config['realtimestats'] == 1) { $counts = db_get_all_rows_sql( - ' - SELECT tagente_modulo.id_modulo, + 'SELECT tagente_modulo.id_modulo, COUNT(tagente_modulo.id_agente_modulo) modules FROM tagente_modulo, tagente_estado, tagente WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente.id_agente = tagente_estado.id_agente - AND tagente_modulo.disabled = 0 AND delete_pending = 0 - AND (utimestamp > 0 OR (id_tipo_modulo = 100 OR (id_tipo_modulo > 21 AND id_tipo_modulo < 23))) + AND (utimestamp > 0 + OR (id_tipo_modulo = 100 + OR (id_tipo_modulo > 21 + AND id_tipo_modulo < 23) + ) + ) AND tagente.disabled = 0 - GROUP BY tagente_modulo.id_modulo' ); @@ -205,6 +217,10 @@ function servers_get_performance() case MODULE_WEB: $data['total_web_modules'] = $c['modules']; break; + + default: + // Not possible. + break; } if ($c['id_modulo'] != MODULE_DATA) { @@ -259,6 +275,8 @@ function servers_get_performance() case SERVER_TYPE_EVENT: case SERVER_TYPE_DISCOVERY: case SERVER_TYPE_SYSLOG: + default: + // Nothing. break; } @@ -272,17 +290,22 @@ function servers_get_performance() $interval_avgs = []; - // Avg of modules interval when modules have module_interval > 0 + // Avg of modules interval when modules have module_interval > 0. $interval_avgs_modules = db_get_all_rows_sql( - ' - SELECT count(tagente_modulo.id_modulo) modules , + 'SELECT count(tagente_modulo.id_modulo) modules , tagente_modulo.id_modulo, AVG(tagente_modulo.module_interval) avg_interval FROM tagente_modulo, tagente_estado, tagente WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND module_interval > 0 - AND (utimestamp > 0 OR (id_tipo_modulo = 100 OR (id_tipo_modulo > 21 AND id_tipo_modulo < 23))) + AND (utimestamp > 0 OR ( + id_tipo_modulo = 100 + OR (id_tipo_modulo > 21 + AND id_tipo_modulo < 23 + ) + ) + ) AND delete_pending = 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente @@ -293,16 +316,15 @@ function servers_get_performance() $interval_avgs_modules = []; } - // Transform into a easily format + // Transform into a easily format. foreach ($interval_avgs_modules as $iamodules) { $interval_avgs[$iamodules['id_modulo']]['avg_interval'] = $iamodules['avg_interval']; $interval_avgs[$iamodules['id_modulo']]['modules'] = $iamodules['modules']; } - // Avg of agents interval when modules have module_interval == 0 + // Avg of agents interval when modules have module_interval == 0. $interval_avgs_agents = db_get_all_rows_sql( - ' - SELECT count(tagente_modulo.id_modulo) modules , + 'SELECT count(tagente_modulo.id_modulo) modules , tagente_modulo.id_modulo, AVG(tagente.intervalo) avg_interval FROM tagente_modulo, tagente_estado, tagente WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo @@ -319,50 +341,89 @@ function servers_get_performance() $interval_avgs_agents = []; } - // Merge with the previous calculated array + // Merge with the previous calculated array. foreach ($interval_avgs_agents as $iaagents) { if (!isset($interval_avgs[$iaagents['id_modulo']]['modules'])) { $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = $iaagents['avg_interval']; $interval_avgs[$iaagents['id_modulo']]['modules'] = $iaagents['modules']; } else { - $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = servers_get_avg_interval($interval_avgs[$iaagents['id_modulo']], $iaagents); + $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = servers_get_avg_interval( + $interval_avgs[$iaagents['id_modulo']], + $iaagents + ); $interval_avgs[$iaagents['id_modulo']]['modules'] += $iaagents['modules']; } } + $info_servers = array_reduce( + servers_get_info(), + function ($carry, $item) { + $carry[$item['server_type']] = $item; + return $carry; + } + ); foreach ($interval_avgs as $id_modulo => $ia) { + $module_lag = 0; switch ($id_modulo) { case MODULE_DATA: + $module_lag = $info_servers[SERVER_TYPE_DATA]['module_lag']; $data['avg_interval_local_modules'] = $ia['avg_interval']; - $data['local_modules_rate'] = servers_get_rate($data['avg_interval_local_modules'], $data['total_local_modules']); + $data['local_modules_rate'] = servers_get_rate( + $data['avg_interval_local_modules'], + ($data['total_local_modules'] - $module_lag) + ); break; case MODULE_NETWORK: + $module_lag = $info_servers[SERVER_TYPE_NETWORK]['module_lag']; + $module_lag += $info_servers[SERVER_TYPE_SNMP]['module_lag']; + $module_lag += $info_servers[SERVER_TYPE_ENTERPRISE_ICMP]['module_lag']; + $module_lag += $info_servers[SERVER_TYPE_ENTERPRISE_SNMP]['module_lag']; $data['avg_interval_network_modules'] = $ia['avg_interval']; $data['network_modules_rate'] = servers_get_rate( $data['avg_interval_network_modules'], - $data['total_network_modules'] + ($data['total_network_modules'] - $module_lag) ); break; case MODULE_PLUGIN: + $module_lag = $info_servers[SERVER_TYPE_PLUGIN]['module_lag']; $data['avg_interval_plugin_modules'] = $ia['avg_interval']; - $data['plugin_modules_rate'] = servers_get_rate($data['avg_interval_plugin_modules'], $data['total_plugin_modules']); + $data['plugin_modules_rate'] = servers_get_rate( + $data['avg_interval_plugin_modules'], + ($data['total_plugin_modules'] - $module_lag) + ); break; case MODULE_PREDICTION: + $module_lag = $info_servers[SERVER_TYPE_PREDICTION]['module_lag']; $data['avg_interval_prediction_modules'] = $ia['avg_interval']; - $data['prediction_modules_rate'] = servers_get_rate($data['avg_interval_prediction_modules'], $data['total_prediction_modules']); + $data['prediction_modules_rate'] = servers_get_rate( + $data['avg_interval_prediction_modules'], + ($data['total_prediction_modules'] - $module_lag) + ); break; case MODULE_WMI: + $module_lag = $info_servers[SERVER_TYPE_WMI]['module_lag']; $data['avg_interval_wmi_modules'] = $ia['avg_interval']; - $data['wmi_modules_rate'] = servers_get_rate($data['avg_interval_wmi_modules'], $data['total_wmi_modules']); + $data['wmi_modules_rate'] = servers_get_rate( + $data['avg_interval_wmi_modules'], + ($data['total_wmi_modules'] - $module_lag) + ); break; case MODULE_WEB: + $module_lag = $info_servers[SERVER_TYPE_WEB]['module_lag']; $data['avg_interval_web_modules'] = $ia['avg_interval']; - $data['web_modules_rate'] = servers_get_rate($data['avg_interval_web_modules'], $data['total_web_modules']); + $data['web_modules_rate'] = servers_get_rate( + $data['avg_interval_web_modules'], + ($data['total_web_modules'] - $module_lag) + ); + break; + + default: + // Not possible. break; } @@ -385,25 +446,55 @@ function servers_get_performance() $data['avg_interval_total_modules'] = (array_sum($data['avg_interval_total_modules']) / count($data['avg_interval_total_modules'])); } - $data['remote_modules_rate'] = servers_get_rate($data['avg_interval_remote_modules'], $data['total_remote_modules']); - $data['total_modules_rate'] = servers_get_rate($data['avg_interval_total_modules'], $data['total_modules']); + $total_modules_lag = 0; + foreach ($info_servers as $key => $value) { + switch ($key) { + case SERVER_TYPE_DATA: + case SERVER_TYPE_NETWORK: + case SERVER_TYPE_SNMP: + case SERVER_TYPE_ENTERPRISE_ICMP: + case SERVER_TYPE_ENTERPRISE_SNMP: + case SERVER_TYPE_PLUGIN: + case SERVER_TYPE_PREDICTION: + case SERVER_TYPE_WMI: + case SERVER_TYPE_WEB: + $total_modules_lag += $value['module_lag']; + break; + + default: + // Not possible. + break; + } + } + + $data['remote_modules_rate'] = servers_get_rate( + $data['avg_interval_remote_modules'], + $data['total_remote_modules'] + ); + + $data['total_modules_rate'] = servers_get_rate( + $data['avg_interval_total_modules'], + ($data['total_modules'] - $total_modules_lag) + ); return ($data); } /** - * Get avg interval + * Get avg interval. * - * @param mixed Array with avg and count data of first part - * @param mixed Array with avg and count data of second part + * @param array $modules_avg_interval1 Array with avg and count + * data of first part. + * @param array $modules_avg_interval2 Array with avg and count + * data of second part. * - * @return float number of avg modules between two parts + * @return float number of avg modules between two parts. */ - - -function servers_get_avg_interval($modules_avg_interval1, $modules_avg_interval2) -{ +function servers_get_avg_interval( + $modules_avg_interval1, + $modules_avg_interval2 +) { $total_modules = ($modules_avg_interval1['modules'] + $modules_avg_interval2['modules']); $parcial1 = ($modules_avg_interval1['avg_interval'] * $modules_avg_interval1['modules']); @@ -416,21 +507,23 @@ function servers_get_avg_interval($modules_avg_interval1, $modules_avg_interval2 /** * Get server rate * - * @param float avg of interval of these modules - * @param int number of modules + * @param float $avg_interval Avg of interval of these modules. + * @param integer $num_modules Number of modules. * * @return float number of modules processed by second */ function servers_get_rate($avg_interval, $num_modules) { - return $avg_interval > 0 ? ($num_modules / $avg_interval) : 0; + return ($avg_interval > 0) ? ($num_modules / $avg_interval) : 0; } /** - * This function will get all the server information in an array or a specific server + * This function will get all the server information in an array + * or a specific server. * - * @param mixed An optional integer or array of integers to select specific servers + * @param integer $id_server An optional integer or array of integers + * to select specific servers. * * @return mixed False in case the server doesn't exist or an array with info. */ @@ -461,127 +554,211 @@ function servers_get_info($id_server=-1) foreach ($result as $server) { switch ($server['server_type']) { case SERVER_TYPE_DATA: - $server['img'] = html_print_image('images/data.png', true, ['title' => __('Data server')]); + $server['img'] = html_print_image( + 'images/data.png', + true, + ['title' => __('Data server')] + ); $server['type'] = 'data'; $id_modulo = 1; break; case SERVER_TYPE_NETWORK: - $server['img'] = html_print_image('images/network.png', true, ['title' => __('Network server')]); + $server['img'] = html_print_image( + 'images/network.png', + true, + ['title' => __('Network server')] + ); $server['type'] = 'network'; $id_modulo = 2; break; case SERVER_TYPE_SNMP: - $server['img'] = html_print_image('images/snmp.png', true, ['title' => __('SNMP Trap server')]); + $server['img'] = html_print_image( + 'images/snmp.png', + true, + ['title' => __('SNMP Trap server')] + ); $server['type'] = 'snmp'; $id_modulo = 0; break; case SERVER_TYPE_DISCOVERY: - $server['img'] = html_print_image('images/recon.png', true, ['title' => __('Discovery server')]); + $server['img'] = html_print_image( + 'images/recon.png', + true, + ['title' => __('Discovery server')] + ); $server['type'] = 'recon'; $id_modulo = 0; break; case SERVER_TYPE_PLUGIN: - $server['img'] = html_print_image('images/plugin.png', true, ['title' => __('Plugin server')]); + $server['img'] = html_print_image( + 'images/plugin.png', + true, + ['title' => __('Plugin server')] + ); $server['type'] = 'plugin'; $id_modulo = 4; break; case SERVER_TYPE_PREDICTION: - $server['img'] = html_print_image('images/chart_bar.png', true, ['title' => __('Prediction server')]); + $server['img'] = html_print_image( + 'images/chart_bar.png', + true, + ['title' => __('Prediction server')] + ); $server['type'] = 'prediction'; $id_modulo = 5; break; case SERVER_TYPE_WMI: - $server['img'] = html_print_image('images/wmi.png', true, ['title' => __('WMI server')]); + $server['img'] = html_print_image( + 'images/wmi.png', + true, + ['title' => __('WMI server')] + ); $server['type'] = 'wmi'; $id_modulo = 6; break; case SERVER_TYPE_EXPORT: - $server['img'] = html_print_image('images/server_export.png', true, ['title' => __('Export server')]); + $server['img'] = html_print_image( + 'images/server_export.png', + true, + ['title' => __('Export server')] + ); $server['type'] = 'export'; $id_modulo = 0; break; case SERVER_TYPE_INVENTORY: - $server['img'] = html_print_image('images/page_white_text.png', true, ['title' => __('Inventory server')]); + $server['img'] = html_print_image( + 'images/page_white_text.png', + true, + ['title' => __('Inventory server')] + ); $server['type'] = 'inventory'; $id_modulo = 0; break; case SERVER_TYPE_WEB: - $server['img'] = html_print_image('images/world.png', true, ['title' => __('Web server')]); + $server['img'] = html_print_image( + 'images/world.png', + true, + ['title' => __('Web server')] + ); $server['type'] = 'web'; $id_modulo = 0; break; case SERVER_TYPE_EVENT: - $server['img'] = html_print_image('images/lightning_go.png', true, ['title' => __('Event server')]); + $server['img'] = html_print_image( + 'images/lightning_go.png', + true, + ['title' => __('Event server')] + ); $server['type'] = 'event'; $id_modulo = 2; break; case SERVER_TYPE_ENTERPRISE_ICMP: - $server['img'] = html_print_image('images/network.png', true, ['title' => __('Enterprise ICMP server')]); + $server['img'] = html_print_image( + 'images/network.png', + true, + ['title' => __('Enterprise ICMP server')] + ); $server['type'] = 'enterprise icmp'; $id_modulo = 2; break; case SERVER_TYPE_ENTERPRISE_SNMP: - $server['img'] = html_print_image('images/network.png', true, ['title' => __('Enterprise SNMP server')]); + $server['img'] = html_print_image( + 'images/network.png', + true, + ['title' => __('Enterprise SNMP server')] + ); $server['type'] = 'enterprise snmp'; $id_modulo = 2; break; case SERVER_TYPE_ENTERPRISE_SATELLITE: - $server['img'] = html_print_image('images/satellite.png', true, ['title' => __('Enterprise Satellite server')]); + $server['img'] = html_print_image( + 'images/satellite.png', + true, + ['title' => __('Enterprise Satellite server')] + ); $server['type'] = 'enterprise satellite'; $id_modulo = 0; break; case SERVER_TYPE_ENTERPRISE_TRANSACTIONAL: - $server['img'] = html_print_image('images/transactional_map.png', true, ['title' => __('Enterprise Transactional server')]); + $server['img'] = html_print_image( + 'images/transactional_map.png', + true, + ['title' => __('Enterprise Transactional server')] + ); $server['type'] = 'enterprise transactional'; $id_modulo = 0; break; case SERVER_TYPE_MAINFRAME: - $server['img'] = html_print_image('images/mainframe.png', true, ['title' => __('Mainframe server')]); + $server['img'] = html_print_image( + 'images/mainframe.png', + true, + ['title' => __('Mainframe server')] + ); $server['type'] = 'mainframe'; $id_modulo = 0; break; case SERVER_TYPE_SYNC: - $server['img'] = html_print_image('images/sync.png', true, ['title' => __('Sync server')]); + $server['img'] = html_print_image( + 'images/sync.png', + true, + ['title' => __('Sync server')] + ); $server['type'] = 'sync'; $id_modulo = 0; break; case SERVER_TYPE_WUX: - $server['img'] = html_print_image('images/icono-wux.png', true, ['title' => __('Wux server')]); + $server['img'] = html_print_image( + 'images/icono-wux.png', + true, + ['title' => __('Wux server')] + ); $server['type'] = 'wux'; $id_modulo = 0; break; case SERVER_TYPE_SYSLOG: - $server['img'] = html_print_image('images/syslog.png', true, ['title' => __('Syslog server')]); + $server['img'] = html_print_image( + 'images/syslog.png', + true, + ['title' => __('Syslog server')] + ); $server['type'] = 'syslog'; $id_modulo = 0; break; case SERVER_TYPE_AUTOPROVISION: - $server['img'] = html_print_image('images/autoprovision.png', true, ['title' => __('Autoprovision server')]); + $server['img'] = html_print_image( + 'images/autoprovision.png', + true, + ['title' => __('Autoprovision server')] + ); $server['type'] = 'autoprovision'; $id_modulo = 0; break; case SERVER_TYPE_MIGRATION: - $server['img'] = html_print_image('images/migration.png', true, ['title' => __('Migration server')]); + $server['img'] = html_print_image( + 'images/migration.png', + true, + ['title' => __('Migration server')] + ); $server['type'] = 'migration'; $id_modulo = 0; break; @@ -594,31 +771,54 @@ function servers_get_info($id_server=-1) } if ($config['realtimestats'] == 0) { - // --------------------------------------------------------------- - // Take data from database if not realtime stats - // --------------------------------------------------------------- - $server['lag'] = db_get_sql('SELECT lag_time FROM tserver WHERE id_server = '.$server['id_server']); - $server['module_lag'] = db_get_sql('SELECT lag_modules FROM tserver WHERE id_server = '.$server['id_server']); - $server['modules'] = db_get_sql('SELECT my_modules FROM tserver WHERE id_server = '.$server['id_server']); - $server['modules_total'] = db_get_sql('SELECT total_modules_running FROM tserver WHERE id_server = '.$server['id_server']); + // Take data from database if not realtime stats. + $server['lag'] = db_get_sql( + 'SELECT lag_time + FROM tserver + WHERE id_server = '.$server['id_server'] + ); + $server['module_lag'] = db_get_sql( + 'SELECT lag_modules + FROM tserver + WHERE id_server = '.$server['id_server'] + ); + $server['modules'] = db_get_sql( + 'SELECT my_modules + FROM tserver + WHERE id_server = '.$server['id_server'] + ); + $server['modules_total'] = db_get_sql( + 'SELECT total_modules_running + FROM tserver + WHERE id_server = '.$server['id_server'] + ); } else { - // --------------------------------------------------------------- - // Take data in realtime - // --------------------------------------------------------------- + // Take data in realtime. $server['module_lag'] = 0; $server['lag'] = 0; - // Inventory server + // Inventory server. if ($server['server_type'] == SERVER_TYPE_INVENTORY) { - // Get modules exported by this server - $server['modules'] = db_get_sql("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente AND tagente.server_name = '".$server['name']."'"); + // Get modules exported by this server. + $server['modules'] = db_get_sql( + "SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) + FROM tagente, tagent_module_inventory + WHERE tagente.disabled=0 + AND tagent_module_inventory.id_agente = tagente.id_agente + AND tagente.server_name = '".$server['name']."'" + ); - // Get total exported modules - $server['modules_total'] = db_get_sql('SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente'); + // Get total exported modules. + $server['modules_total'] = db_get_sql( + 'SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) + FROM tagente, tagent_module_inventory + WHERE tagente.disabled=0 + AND tagent_module_inventory.id_agente = tagente.id_agente' + ); $interval_esc = db_escape_key_identifier('interval'); - // Get the module lag + // Get the module lag. $server['module_lag'] = db_get_sql( 'SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) AS module_lag FROM tagente, tagent_module_inventory @@ -630,7 +830,7 @@ function servers_get_info($id_server=-1) AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.'.$interval_esc ); - // Get the lag + // Get the lag. $server['lag'] = db_get_sql( 'SELECT AVG(UNIX_TIMESTAMP() - utimestamp - tagent_module_inventory.'.$interval_esc.') FROM tagente, tagent_module_inventory @@ -641,162 +841,119 @@ function servers_get_info($id_server=-1) AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory.".$interval_esc.' * 10) AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.'.$interval_esc ); - // Export server + // Export server. } else if ($server['server_type'] == SERVER_TYPE_EXPORT) { - // Get modules exported by this server - $server['modules'] = db_get_sql('SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tserver_export WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export = tserver_export.id AND tserver_export.id_export_server = '.$server['id_server']); + // Get modules exported by this server. + $server['modules'] = db_get_sql( + 'SELECT COUNT(tagente_modulo.id_agente_modulo) + FROM tagente, tagente_modulo, tserver_export + WHERE tagente.disabled=0 + AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_modulo.id_export = tserver_export.id + AND tserver_export.id_export_server = '.$server['id_server'] + ); - // Get total exported modules - $server['modules_total'] = db_get_sql('SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export != 0'); + // Get total exported modules. + $server['modules_total'] = db_get_sql( + 'SELECT COUNT(tagente_modulo.id_agente_modulo) + FROM tagente, tagente_modulo + WHERE tagente.disabled=0 + AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_modulo.id_export != 0' + ); $server['lag'] = 0; $server['module_lag'] = 0; - } - // Discovery server - else if ($server['server_type'] == SERVER_TYPE_DISCOVERY) { + } else if ($server['server_type'] == SERVER_TYPE_DISCOVERY) { + // Discovery server. $server['name'] = ''.$server['name'].''; - // Total jobs running on this Discovery server + // Total jobs running on this Discovery server. $server['modules'] = db_get_sql( 'SELECT COUNT(id_rt) FROM trecon_task WHERE id_recon_server = '.$server['id_server'] ); - // Total recon jobs (all servers) - $server['modules_total'] = db_get_sql('SELECT COUNT(status) FROM trecon_task'); + // Total recon jobs (all servers). + $server['modules_total'] = db_get_sql( + 'SELECT COUNT(status) FROM trecon_task' + ); - // Lag (take average active time of all active tasks) + // Lag (take average active time of all active tasks). $server['module_lag'] = 0; - - switch ($config['dbtype']) { - case 'mysql': - $server['lag'] = db_get_sql('SELECT UNIX_TIMESTAMP() - utimestamp from trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); - - $server['module_lag'] = db_get_sql('SELECT COUNT(id_rt) FROM trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); - break; - - case 'postgresql': - $server['lag'] = db_get_sql("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp from trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server['id_server']); - - $server['module_lag'] = db_get_sql("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server['id_server']); - break; - - case 'oracle': - $server['lag'] = db_get_sql("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.")) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); - - $server['module_lag'] = db_get_sql("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); - break; - } + $server['lag'] = db_get_sql( + 'SELECT UNIX_TIMESTAMP() - utimestamp + FROM trecon_task + WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) + AND id_recon_server = '.$server['id_server'] + ); + $server['module_lag'] = db_get_sql( + 'SELECT COUNT(id_rt) + FROM trecon_task + WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) + AND id_recon_server = '.$server['id_server'] + ); } else { - // --------------------------------------------------------------- - // Data, Plugin, WMI, Network and Others - $server['modules'] = db_get_sql('SELECT count(tagente_estado.id_agente_modulo) FROM tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = '.$server['id_server']); + // Data, Plugin, WMI, Network and Others. + $server['modules'] = db_get_sql( + 'SELECT count(tagente_estado.id_agente_modulo) + FROM tagente_estado, tagente_modulo, tagente + WHERE tagente.disabled=0 + AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_modulo.disabled = 0 + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente_estado.running_by = '.$server['id_server'] + ); - $server['modules_total'] = db_get_sql('SELECT count(tagente_estado.id_agente_modulo) FROM tserver, tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = tserver.id_server AND tserver.server_type = '.$server['server_type']); + $server['modules_total'] = db_get_sql( + 'SELECT count(tagente_estado.id_agente_modulo) + FROM tserver, tagente_estado, tagente_modulo, tagente + WHERE tagente.disabled=0 + AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_modulo.disabled = 0 + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente_estado.running_by = tserver.id_server + AND tserver.server_type = '.$server['server_type'] + ); - // Remote servers LAG Calculation (server_type != 0) + // Remote servers LAG Calculation (server_type != 0). if ($server['server_type'] != 0) { - switch ($config['dbtype']) { - case 'mysql': - $result = db_get_row_sql( - 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente - WHERE utimestamp > 0 - AND tagente.disabled = 0 - AND tagente.id_agente = tagente_estado.id_agente - AND tagente_modulo.disabled = 0 - AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo - AND current_interval > 0 - AND running_by = '.$server['id_server'].' - AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10) - AND (UNIX_TIMESTAMP() - utimestamp) > current_interval' - ); - break; - - case 'postgresql': - $result = db_get_row_sql( - "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente - WHERE utimestamp > 0 - AND tagente.disabled = 0 - AND tagente.id_agente = tagente_estado.id_agente - AND tagente_modulo.disabled = 0 - AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo - AND current_interval > 0 - AND running_by = ".$server['id_server']." - AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) < ( current_interval * 10) - AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > current_interval" - ); - break; - - case 'oracle': - $result = db_get_row_sql( - "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente - WHERE utimestamp > 0 - AND tagente.disabled = 0 - AND tagente.id_agente = tagente_estado.id_agente - AND tagente_modulo.disabled = 0 - AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo - AND current_interval > 0 - AND running_by = '.$server['id_server']." - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.")) - utimestamp) < ( current_interval * 10) - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) - utimestamp) * (".SECONDS_1DAY.')) > current_interval' - ); - break; - } + $result = db_get_row_sql( + 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, + AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag + FROM tagente_estado, tagente_modulo, tagente + WHERE utimestamp > 0 + AND tagente.disabled = 0 + AND tagente.id_agente = tagente_estado.id_agente + AND tagente_modulo.disabled = 0 + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND current_interval > 0 + AND running_by = '.$server['id_server'].' + AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10) + AND (UNIX_TIMESTAMP() - utimestamp) > current_interval' + ); } else { - // Local/Dataserver server LAG calculation: - switch ($config['dbtype']) { - case 'mysql': - $result = db_get_row_sql( - 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente - WHERE utimestamp > 0 - AND tagente.disabled = 0 - AND tagente.id_agente = tagente_estado.id_agente - AND tagente_modulo.disabled = 0 - AND tagente_modulo.id_tipo_modulo < 5 - AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo - AND current_interval > 0 - AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10) - AND running_by = '.$server['id_server'].' - AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)' - ); - break; - - case 'postgresql': - $result = db_get_row_sql( - "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente - WHERE utimestamp > 0 - AND tagente.disabled = 0 - AND tagente.id_agente = tagente_estado.id_agente - AND tagente_modulo.disabled = 0 - AND tagente_modulo.id_tipo_modulo < 5 - AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo - AND current_interval > 0 - AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) < ( current_interval * 10) - AND running_by = ".$server['id_server']." - AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > (current_interval * 1.1)" - ); - break; - - case 'oracle': - $result = db_get_row_sql( - "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.")) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente - WHERE utimestamp > 0 - AND tagente.disabled = 0 - AND tagente.id_agente = tagente_estado.id_agente - AND tagente_modulo.disabled = 0 - AND tagente_modulo.id_tipo_modulo < 5 - AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo - AND current_interval > 0 - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - utimestamp) < ( current_interval * 10) - AND running_by = '.$server['id_server']." - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - utimestamp) > (current_interval * 1.1)' - ); - break; - } + // Local/Dataserver server LAG calculation. + $result = db_get_row_sql( + 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, + AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag + FROM tagente_estado, tagente_modulo, tagente + WHERE utimestamp > 0 + AND tagente.disabled = 0 + AND tagente.id_agente = tagente_estado.id_agente + AND tagente_modulo.disabled = 0 + AND tagente_modulo.id_tipo_modulo < 5 + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND current_interval > 0 + AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10) + AND running_by = '.$server['id_server'].' + AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)' + ); } - // Lag over current_interval * 2 is not lag, it's a timed out module + // Lag over current_interval * 2 is not lag, + // it's a timed out module. if (!empty($result['lag'])) { $server['lag'] = $result['lag']; } @@ -805,28 +962,37 @@ function servers_get_info($id_server=-1) $server['module_lag'] = $result['module_lag']; } } - } //end if + } if (isset($server['module_lag'])) { - $server['lag_txt'] = ($server['lag'] == 0 ? '-' : human_time_description_raw($server['lag'])).' / '.$server['module_lag']; + $server['lag_txt'] = (($server['lag'] == 0) ? '-' : human_time_description_raw($server['lag'])).' / '.$server['module_lag']; } else { $server['lag_txt'] = ''; } if ($server['modules_total'] > 0) { - $server['load'] = round(($server['modules'] / $server['modules_total'] * 100)); + $server['load'] = round( + ($server['modules'] / $server['modules_total'] * 100) + ); } else { $server['load'] = 0; } - // Push the raw data on the return stack + // Push the raw data on the return stack. $return[$server['id_server']] = $server; - } //end foreach + } return $return; } +/** + * Get server type + * + * @param integer $type Type. + * + * @return array Result. + */ function servers_get_servers_type($type) { return db_get_all_rows_filter('tserver', ['server_type' => $type]); @@ -836,25 +1002,28 @@ function servers_get_servers_type($type) /** * Get the server name. * - * @param int Server id. + * @param integer $id_server Server id. * * @return string Name of the given server */ function servers_get_name($id_server) { - return (string) db_get_value('name', 'tserver', 'id_server', (int) $id_server); + return (string) db_get_value( + 'name', + 'tserver', + 'id_server', + (int) $id_server + ); } /** - * Get the presence of .conf and .md5 into remote_config dir + * Get the presence of .conf and .md5 into remote_config dir. * - * @param string Agent name + * @param string $server_name Agent name. * - * @return true if files exist and are writable + * @return true If files exist and are writable. */ - - function servers_check_remote_config($server_name) { global $config; @@ -862,8 +1031,12 @@ function servers_check_remote_config($server_name) $server_md5 = md5($server_name, false); $filenames = []; - $filenames['md5'] = io_safe_output($config['remote_config']).'/md5/'.$server_md5.'.srv.md5'; - $filenames['conf'] = io_safe_output($config['remote_config']).'/conf/'.$server_md5.'.srv.conf'; + $filenames['md5'] = io_safe_output( + $config['remote_config'] + ).'/md5/'.$server_md5.'.srv.md5'; + $filenames['conf'] = io_safe_output( + $config['remote_config'] + ).'/conf/'.$server_md5.'.srv.conf'; if (! isset($filenames['conf'])) { return false; @@ -881,14 +1054,15 @@ function servers_check_remote_config($server_name) /** - * Return a string containing image tag for a given target id (server) - * TODO: Make this print_servertype_icon and move to functions_ui.php. Make XHTML compatible. Make string translatable + * Return a string containing image tag for a given target id (server). + * TODO: Make this print_servertype_icon and move to functions_ui.php. + * Make XHTML compatible. Make string translatable. * - * @deprecated Use print_servertype_icon instead + * @param integer $id Server type id. * - * @param int Server type id + * @deprecated Use print_servertype_icon instead. * - * @return string Fully formatted IMG HTML tag with icon + * @return string Fully formatted IMG HTML tag with icon. */ function servers_show_type($id) { @@ -896,37 +1070,67 @@ function servers_show_type($id) switch ($id) { case 1: - return html_print_image('images/database.png', true, ['title' => get_product_name().' Data server']); + $return = html_print_image( + 'images/database.png', + true, + ['title' => get_product_name().' Data server'] + ); + break; - break; case 2: - return html_print_image('images/network.png', true, ['title' => get_product_name().' Network server']); + $return = html_print_image( + 'images/network.png', + true, + ['title' => get_product_name().' Network server'] + ); + break; - break; case 4: - return html_print_image('images/plugin.png', true, ['title' => get_product_name().' Plugin server']); + $return = html_print_image( + 'images/plugin.png', + true, + ['title' => get_product_name().' Plugin server'] + ); + break; - break; case 5: - return html_print_image('images/chart_bar.png', true, ['title' => get_product_name().' Prediction server']); + $return = html_print_image( + 'images/chart_bar.png', + true, + ['title' => get_product_name().' Prediction server'] + ); + break; - break; case 6: - return html_print_image('images/wmi.png', true, ['title' => get_product_name().' WMI server']); + $return = html_print_image( + 'images/wmi.png', + true, + ['title' => get_product_name().' WMI server'] + ); + break; - break; case 7: - return html_print_image('images/server_web.png', true, ['title' => get_product_name().' WEB server']); + $return = html_print_image( + 'images/server_web.png', + true, + ['title' => get_product_name().' WEB server'] + ); + break; - break; case 8: - return html_print_image('images/module-wux.png', true, ['title' => get_product_name().' WUX server']); + $return = html_print_image( + 'images/module-wux.png', + true, + ['title' => get_product_name().' WUX server'] + ); + break; - break; default: - return '--'; - break; + $return = '--'; + break; } + + return $return; } @@ -941,28 +1145,10 @@ function servers_check_status() { global $config; - switch ($config['dbtype']) { - case 'mysql': - $sql = 'SELECT COUNT(id_server) - FROM tserver - WHERE status = 1 - AND keepalive > NOW() - INTERVAL server_keepalive*2 SECOND'; - break; - - case 'postgresql': - $sql = "SELECT COUNT(id_server) - FROM tserver - WHERE status = 1 - AND keepalive > NOW() - INTERVAL 'server_keepalive*2 SECOND'"; - break; - - case 'oracle': - $sql = "SELECT COUNT(id_server) - FROM tserver - WHERE status = 1 - AND keepalive > systimestamp - INTERVAL 'server_keepalive*2' SECOND"; - break; - } + $sql = 'SELECT COUNT(id_server) + FROM tserver + WHERE status = 1 + AND keepalive > NOW() - INTERVAL server_keepalive*2 SECOND'; $status = (int) db_get_sql($sql); // Cast as int will assure a number value @@ -972,10 +1158,9 @@ function servers_check_status() /** - * @deprecated use servers_get_info instead * Get statistical information for a given server * - * @param int Server id to get status. + * @param integer $id_server Server id to get status. * * @return array Server info array */ diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 6a9620f3e8..9619d88b79 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2055,7 +2055,7 @@ function ui_pagination( $actual_page = floor($offset / $pagination); $ini_page = (floor($actual_page / $block_limit) * $block_limit); $end_page = ($ini_page + $block_limit - 1); - if ($end_page > $number_of_pages) { + if ($end_page >= $number_of_pages) { $end_page = ($number_of_pages - 1); } @@ -3699,6 +3699,24 @@ function ui_get_url_refresh($params=false, $relative=true, $add_post=true) } +/** + * Checks if public_url usage is being forced to target 'visitor'. + * + * @return boolean + */ +function ui_forced_public_url() +{ + global $config; + $exclusions = preg_split("/[\n\s,]+/", io_safe_output($config['public_url_exclusions'])); + + if (in_array($_SERVER['REMOTE_ADDR'], $exclusions)) { + return false; + } + + return (bool) $config['force_public_url']; +} + + /** * Returns a full URL in Pandora. (with the port and https in some systems) * @@ -3745,12 +3763,18 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me } if (!$no_proxy) { - // Check if the PandoraFMS runs across the proxy like as - // mod_proxy of Apache - // and check if public_url is set. - if (!empty($config['public_url']) + // Check proxy. + $proxy = false; + if (ui_forced_public_url()) { + $proxy = true; + $fullurl = $config['public_url']; + if ($url == 'index.php' && is_metaconsole()) { + $fullurl .= '/'.ENTERPRISE_DIR.'/meta'; + } + } else if (!empty($config['public_url']) && (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) ) { + // Forced to use public url when being forwarder by a reverse proxy. $fullurl = $config['public_url']; $proxy = true; } else { @@ -3782,7 +3806,7 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me $url = $config['homeurl_static'].'/'; } - if (defined('METACONSOLE') && $metaconsole_root) { + if (is_metaconsole() && $metaconsole_root) { $url .= 'enterprise/meta/'; } } else if (!strstr($url, '.php')) { @@ -3792,7 +3816,7 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me $fullurl .= $config['homeurl_static'].'/'; } - if (defined('METACONSOLE') && $metaconsole_root) { + if (is_metaconsole() && $metaconsole_root) { $fullurl .= 'enterprise/meta/'; } } else { @@ -3804,7 +3828,7 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me } else { $fullurl .= $config['homeurl_static'].'/'; - if (defined('METACONSOLE') && $metaconsole_root) { + if (is_metaconsole() && $metaconsole_root) { $fullurl .= 'enterprise/meta/'; } } diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index ee97467430..dd4be3c501 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4271,7 +4271,7 @@ function visual_map_create_internal_name_item($label=null, $type, $image, $agent case 'static_graph': case STATIC_GRAPH: - $text = __('Static graph').' - '.$image; + $text = __('Static Image').' - '.$image; break; case 'simple_value': diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 7e7cffeca4..0e678c6111 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -1294,7 +1294,7 @@ function visual_map_editor_print_toolbox() } echo '
'; - visual_map_print_button_editor('static_graph', __('Static Graph'), 'left', false, 'camera_min', true); + visual_map_print_button_editor('static_graph', __('Static Image'), 'left', false, 'camera_min', true); visual_map_print_button_editor('percentile_item', __('Percentile Item'), 'left', false, 'percentile_item_min', true); visual_map_print_button_editor('module_graph', __('Module Graph'), 'left', false, 'graph_min', true); visual_map_print_button_editor('donut_graph', __('Serialized pie graph'), 'left', false, 'donut_graph_min', true); diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index f7af997508..f0976cb98f 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -2791,14 +2791,16 @@ function pandoraFlotArea( if (short_data) { formatted = number_format(v, force_integer, "", short_data); } else { - // It is an integer + // It is an integer. if (v - Math.floor(v) == 0) { formatted = number_format(v, force_integer, "", 2); } } - // Get only two decimals - formatted = round_with_decimals(formatted, 100); + // Get only two decimals. + if (typeof formatted != "string") { + formatted = Math.round(formatted * 100) / 100; + } return formatted; } diff --git a/pandora_console/include/styles/js/cluetip.css b/pandora_console/include/styles/js/cluetip.css index 233dbf3cbb..a1360b0afe 100644 --- a/pandora_console/include/styles/js/cluetip.css +++ b/pandora_console/include/styles/js/cluetip.css @@ -2,19 +2,23 @@ #cluetip-close img { border: 0; } + #cluetip-title { overflow: hidden; } + #cluetip-title #cluetip-close { float: right; position: relative; } + #cluetip-waitimage { width: 43px; height: 11px; position: absolute; background-image: url(../../../images/wait.gif); } + .cluetip-arrows { display: none; position: absolute; @@ -25,9 +29,11 @@ background-repeat: no-repeat; background-position: 0 0; } + #cluetip-extra { display: none; } + /*************************************** =cluetipClass: 'default' -------------------------------------- */ @@ -36,11 +42,13 @@ background-color: #fff; text-align: left; } + .cluetip-default #cluetip-outer { position: relative; margin: 0; background-color: #fff; } + .cluetip-default h3 { margin: 0 0 5px; padding: 8px 10px 4px; @@ -49,6 +57,7 @@ background-color: #b1b1b1; color: #fff; } + .cluetip-default h3#cluetip-title { display: none; height: 0px; @@ -56,41 +65,49 @@ padding: 0; color: #fff; } + .cluetip-default #cluetip-title a { color: #fff; font-size: 0.95em; } + .cluetip-default #cluetip-inner { padding: 10px; } + .cluetip-default div#cluetip-close { text-align: right; margin: 0 5px 5px; color: #900; } + .cluetip-default ul { text-align: left; } + /* default arrows */ .clue-right-default .cluetip-arrows { - background-image: url(../../images/darrowleft.png); + background-image: url(../../../images/darrowleft.png); } + .clue-left-default .cluetip-arrows { - background-image: url(../../images/darrowright.png); + background-image: url(../../../images/darrowright.png); left: 100%; margin-right: -11px; } + .clue-top-default .cluetip-arrows { - background-image: url(../../images/darrowdown.png); + background-image: url(../../../images/darrowdown.png); top: 100%; left: 50%; margin-left: -11px; height: 11px; width: 22px; } + .clue-bottom-default .cluetip-arrows { - background-image: url(../../images/darrowup.png); + background-image: url(../../../images/darrowup.png); top: -11px; left: 50%; margin-left: -11px; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 2bb8997376..94b1a54b15 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -235,11 +235,12 @@ pre { font-family: courier, serif; } fieldset { - background-color: #f9faf9; + background-color: #fff; border: 1px solid #e2e2e2; padding: 0.5em; margin-bottom: 20px; position: relative; + border-radius: 5px; } fieldset legend { font-size: 1.1em; @@ -5328,6 +5329,10 @@ table.info_table.policy_sub_table { margin-bottom: 4px; } +.agent_options input[readonly] { + color: #848484; +} + /* * --------------------------------------------------------------------- * - CLASSES FOR THE NEW TOGGLES - @@ -5866,3 +5871,7 @@ table.table_modal_alternate tr td:first-child { padding-left: 20px; } /* END - Table for show more info in events and config menu in modules graphs */ + +.fullwidth { + width: 100%; +} diff --git a/pandora_console/include/styles/pandora_black.css b/pandora_console/include/styles/pandora_black.css index 030eae88ca..a52c994ed2 100644 --- a/pandora_console/include/styles/pandora_black.css +++ b/pandora_console/include/styles/pandora_black.css @@ -237,19 +237,12 @@ table.table_modal_alternate tr:nth-child(even) td { background-color: #555 !important; } -.info_table .datos3, -.datos3, -.info_table .datos4, -.datos4 { - background-color: #666; - color: #fff; -} - .info_table .datos3, .datos3, .info_table .datos4, .datos4 { background-color: #444; + color: #fff; } .action_buttons a[href] img, @@ -394,3 +387,8 @@ ul.ui-tabs-nav.ui-corner-all.ui-helper-reset.ui-helper-clearfix.ui-widget-header div#box_online * { color: #000; } + +/* discovery.css */ +#text_wizard { + color: #555; +} diff --git a/pandora_console/include/styles/tables.css b/pandora_console/include/styles/tables.css index 7e49d32c83..23f6253421 100644 --- a/pandora_console/include/styles/tables.css +++ b/pandora_console/include/styles/tables.css @@ -262,11 +262,16 @@ a.pandora_pagination { padding: 5px; color: #000; border: 1px solid #cacaca; + border-left: none; min-width: 12px; - margin-right: -1px; text-decoration: none; cursor: pointer; } +.dataTables_paginate > span > span.ellipsis + a.pandora_pagination:last-child, +.dataTables_paginate a.pandora_pagination.previous { + border-left: 1px solid #cacaca; +} + a.pandora_pagination.disabled { color: #cacaca; } diff --git a/pandora_console/index.php b/pandora_console/index.php index 70b078b8bf..21b5e35eb1 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1,17 +1,32 @@ $value) { if ($key == 1) { continue; @@ -162,12 +181,12 @@ if (!empty($config['https']) && empty($_SERVER['HTTPS'])) { $url = ui_get_full_url($query); // Prevent HTTP response splitting attacks - // http://en.wikipedia.org/wiki/HTTP_response_splitting + // http://en.wikipedia.org/wiki/HTTP_response_splitting. $url = str_replace("\n", '', $url); header('Location: '.$url); + // Always exit after sending location headers. exit; - // Always exit after sending location headers } // Pure mode (without menu, header and footer). @@ -188,20 +207,21 @@ echo ''."\n"; echo ''."\n"; -// This starts the page head. In the call back function, things from $page['head'] array will be processed into the head +// This starts the page head. In the callback function, +// $page['head'] array content will be processed into the head. ob_start('ui_process_page_head'); -// Enterprise main +// Enterprise main. enterprise_include('index.php'); echo ''; // This tag is included in the buffer passed to ui_process_page_head so -// technically it can be stripped +// technically it can be stripped. echo ''."\n"; require_once 'include/functions_themes.php'; @@ -212,13 +232,13 @@ $config['remote_addr'] = $_SERVER['REMOTE_ADDR']; $sec2 = get_parameter_get('sec2'); $sec2 = safe_url_extraclean($sec2); $page = $sec2; -// Reference variable for old time sake +// Reference variable for old time sake. $sec = get_parameter_get('sec'); $sec = safe_url_extraclean($sec); $process_login = false; -// Update user password +// Update user password. $change_pass = get_parameter_post('renew_password', 0); if ($change_pass == 1) { @@ -235,14 +255,14 @@ $searchPage = false; $search = get_parameter_get('head_search_keywords'); if (strlen($search) > 0) { $config['search_keywords'] = io_safe_input(trim(io_safe_output(get_parameter('keywords')))); - // If not search category providad, we'll use an agent search + // If not search category providad, we'll use an agent search. $config['search_category'] = get_parameter('search_category', 'all'); if (($config['search_keywords'] != 'Enter keywords to search') && (strlen($config['search_keywords']) > 0)) { $searchPage = true; } } -// Login process +// Login process. if (! isset($config['id_user'])) { // Clear error messages. unset($_COOKIE['errormsg']); @@ -250,50 +270,53 @@ if (! isset($config['id_user'])) { if (isset($_GET['login'])) { include_once 'include/functions_db.php'; - // Include it to use escape_string_sql function + // Include it to use escape_string_sql function. $config['auth_error'] = ''; - // Set this to the error message from the authorization mechanism + // Set this to the error message from the authorization mechanism. $nick = get_parameter_post('nick'); - // This is the variable with the login + // This is the variable with the login. $pass = get_parameter_post('pass'); - // This is the variable with the password + // This is the variable with the password. $nick = db_escape_string_sql($nick); $pass = db_escape_string_sql($pass); - // Since now, only the $pass variable are needed + // Since now, only the $pass variable are needed. unset($_GET['pass'], $_POST['pass'], $_REQUEST['pass']); - // If the auth_code exists, we assume the user has come through the double auth page + // If the auth_code exists, we assume the user has come from + // double authorization page. if (isset($_POST['auth_code'])) { $double_auth_success = false; - // The double authentication is activated and the user has surpassed the first step (the login). + // The double authentication is activated and the user has + // surpassed the first step (the login). // Now the authentication code provided will be checked. if (isset($_SESSION['prepared_login_da'])) { if (isset($_SESSION['prepared_login_da']['id_user']) && isset($_SESSION['prepared_login_da']['timestamp']) ) { - // The user has a maximum of 5 minutes to introduce the double auth code + // The user has a maximum of 5 minutes to introduce + // the double auth code. $dauth_period = SECONDS_2MINUTES; $now = time(); $dauth_time = $_SESSION['prepared_login_da']['timestamp']; if (($now - $dauth_period) < $dauth_time) { - // Nick + // Nick. $nick = $_SESSION['prepared_login_da']['id_user']; - // Code + // Code. $code = (string) get_parameter_post('auth_code'); if (!empty($code)) { $result = validate_double_auth_code($nick, $code); if ($result === true) { - // Double auth success + // Double auth success. $double_auth_success = true; } else { - // Screen + // Screen. $login_screen = 'double_auth'; - // Error message + // Error message. $config['auth_error'] = __('Invalid code'); if (!isset($_SESSION['prepared_login_da']['attempts'])) { @@ -303,9 +326,9 @@ if (! isset($config['id_user'])) { $_SESSION['prepared_login_da']['attempts']++; } } else { - // Screen + // Screen. $login_screen = 'double_auth'; - // Error message + // Error message. $config['auth_error'] = __("The code shouldn't be empty"); if (!isset($_SESSION['prepared_login_da']['attempts'])) { @@ -315,27 +338,27 @@ if (! isset($config['id_user'])) { $_SESSION['prepared_login_da']['attempts']++; } } else { - // Expired login + // Expired login. unset($_SESSION['prepared_login_da']); - // Error message + // Error message. $config['auth_error'] = __('Expired login'); } } else { - // If the code doesn't exist, remove the prepared login + // If the code doesn't exist, remove the prepared login. unset($_SESSION['prepared_login_da']); - // Error message + // Error message. $config['auth_error'] = __('Login error'); } - } - // If $_SESSION['prepared_login_da'] doesn't exist, the user have to do the login again - else { - // Error message + } else { + // If $_SESSION['prepared_login_da'] doesn't exist, the user + // must login again. + // Error message. $config['auth_error'] = __('Login error'); } - // Remove the authenticator code + // Remove the authenticator code. unset($_POST['auth_code'], $code); if (!$double_auth_success) { @@ -347,6 +370,8 @@ if (! isset($config['id_user'])) { $_SERVER['REMOTE_ADDR'] ); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -355,7 +380,8 @@ if (! isset($config['id_user'])) { $login_button_saml = get_parameter('login_button_saml', false); if (isset($double_auth_success) && $double_auth_success) { - // This values are true cause there are checked before complete the 2nd auth step + // This values are true cause there are checked before complete + // the 2nd auth step. $nick_in_db = $_SESSION['prepared_login_da']['id_user']; $expired_pass = false; } else if (($config['auth'] == 'saml') && ($login_button_saml)) { @@ -400,28 +426,34 @@ if (! isset($config['id_user'])) { include_once 'general/login_page.php'; db_pandora_audit('Password expired', 'Password expired: '.$nick, $nick); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); } - // Checks if password has expired + // Checks if password has expired. $check_status = check_pass_status($nick, $pass); switch ($check_status) { case PASSSWORD_POLICIES_FIRST_CHANGE: - // first change + // First change. case PASSSWORD_POLICIES_EXPIRED: - // pass expired + // Pass expired. $expired_pass = true; login_change_password($nick, '', $check_status); break; + + default: + // Ignore. + break; } } } if (($nick_in_db !== false) && $expired_pass) { - // login ok and password has expired + // Login ok and password has expired. include_once 'general/login_page.php'; db_pandora_audit( 'Password expired', @@ -429,30 +461,38 @@ if (! isset($config['id_user'])) { $nick ); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); } else if (($nick_in_db !== false) && (!$expired_pass)) { - // login ok and password has not expired - // Double auth check - if ((!isset($double_auth_success) || !$double_auth_success) && is_double_auth_enabled($nick_in_db)) { - // Store this values in the session to know if the user login was correct + // Login ok and password has not expired. + // Double auth check. + if ((!isset($double_auth_success) + || !$double_auth_success) + && is_double_auth_enabled($nick_in_db) + ) { + // Store this values in the session to know if the user login + // was correct. $_SESSION['prepared_login_da'] = [ 'id_user' => $nick_in_db, 'timestamp' => time(), 'attempts' => 0, ]; - // Load the page to introduce the double auth code + // Load the page to introduce the double auth code. $login_screen = 'double_auth'; include_once 'general/login_page.php'; while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); } - // login ok and password has not expired + // Login ok and password has not expired. $process_login = true; if (is_user_admin($nick)) { @@ -464,7 +504,7 @@ if (! isset($config['id_user'])) { if (!isset($_GET['sec2']) && !isset($_GET['sec'])) { // Avoid the show homepage when the user go to // a specific section of pandora - // for example when timeout the sesion + // for example when timeout the sesion. unset($_GET['sec2']); $_GET['sec'] = 'general/logon_ok'; $home_page = ''; @@ -495,6 +535,7 @@ if (! isset($config['id_user'])) { break; case 'Default': + default: $_GET['sec'] = 'general/logon_ok'; break; @@ -530,11 +571,14 @@ if (! isset($config['id_user'])) { $_SESSION['id_usuario'] = $nick_in_db; $config['id_user'] = $nick_in_db; - // Check if connection goes through F5 balancer. If it does, then don't call config_prepare_session() or user will be back to login all the time + // Check if connection goes through F5 balancer. If it does, then + // don't call config_prepare_session() or user will be back to login + // all the time. $prepare_session = true; foreach ($_COOKIE as $key => $value) { if (preg_match('/BIGipServer*/', $key)) { $prepare_session = false; + break; } } @@ -543,9 +587,13 @@ if (! isset($config['id_user'])) { } if (is_user_admin($config['id_user'])) { - // PHP configuration values - $PHPupload_max_filesize = config_return_in_bytes(ini_get('upload_max_filesize')); - $PHPmemory_limit = config_return_in_bytes(ini_get('memory_limit')); + // PHP configuration values. + $PHPupload_max_filesize = config_return_in_bytes( + ini_get('upload_max_filesize') + ); + $PHPmemory_limit = config_return_in_bytes( + ini_get('memory_limit') + ); $PHPmax_execution_time = ini_get('max_execution_time'); if ($PHPmax_execution_time !== '0') { @@ -580,43 +628,60 @@ if (! isset($config['id_user'])) { $l10n = null; if (file_exists('./include/languages/'.$user_language.'.mo')) { - $l10n = new gettext_reader(new CachedFileReader('./include/languages/'.$user_language.'.mo')); + $cacheFileReader = new CachedFileReader( + './include/languages/'.$user_language.'.mo' + ); + $l10n = new gettext_reader($cacheFileReader); $l10n->load_tables(); } } else { - // login wrong + // Login wrong. $blocked = false; - if ((!is_user_admin($nick) || $config['enable_pass_policy_admin']) && file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { + if ((!is_user_admin($nick) || $config['enable_pass_policy_admin']) + && file_exists(ENTERPRISE_DIR.'/load_enterprise.php') + ) { $blocked = login_check_blocked($nick); } if (!$blocked) { if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { + // Checks failed attempts. login_check_failed($nick); - // Checks failed attempts } $login_failed = true; include_once 'general/login_page.php'; - db_pandora_audit('Logon Failed', 'Invalid login: '.$nick, $nick); + db_pandora_audit( + 'Logon Failed', + 'Invalid login: '.$nick, + $nick + ); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); } else { include_once 'general/login_page.php'; - db_pandora_audit('Logon Failed', 'Invalid login: '.$nick, $nick); + db_pandora_audit( + 'Logon Failed', + 'Invalid login: '.$nick, + $nick + ); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); } } - // Form the url + // Form the url. $query_params_redirect = $_GET; - // Visual console do not want sec2 + // Visual console do not want sec2. if ($home_page == 'Visual console') { unset($query_params_redirect['sec2']); } @@ -630,15 +695,19 @@ if (! isset($config['id_user'])) { $redirect_url .= '&'.safe_url_extraclean($key).'='.safe_url_extraclean($value); } - header('Location: '.$config['homeurl'].'index.php'.$redirect_url); + header('Location: '.ui_get_full_url('index.php'.$redirect_url)); exit; // Always exit after sending location headers. } else if (isset($_GET['loginhash'])) { - // Hash login process + // Hash login process. $loginhash_data = get_parameter('loginhash_data', ''); $loginhash_user = str_rot13(get_parameter('loginhash_user', '')); - if ($config['loginhash_pwd'] != '' && $loginhash_data == md5($loginhash_user.io_output_password($config['loginhash_pwd']))) { + if ($config['loginhash_pwd'] != '' + && $loginhash_data == md5( + $loginhash_user.io_output_password($config['loginhash_pwd']) + ) + ) { db_logon($loginhash_user, $_SERVER['REMOTE_ADDR']); $_SESSION['id_usuario'] = $loginhash_user; $config['id_user'] = $loginhash_user; @@ -646,6 +715,8 @@ if (! isset($config['id_user'])) { include_once 'general/login_page.php'; db_pandora_audit('Logon Failed (loginhash', '', 'system'); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -767,7 +838,7 @@ if (! isset($config['id_user'])) { $body .= '

'; $body .= __('Please click the link below to reset your password'); $body .= '

'; - $body .= ''.__('Reset your password').''; + $body .= ''.__('Reset your password').''; $body .= '

'; $body .= get_product_name(); $body .= '

'; @@ -790,6 +861,8 @@ if (! isset($config['id_user'])) { } while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -799,11 +872,20 @@ if (! isset($config['id_user'])) { $loginhash_data = get_parameter('loginhash_data', ''); $loginhash_user = str_rot13(get_parameter('loginhash_user', '')); $iduser = $_SESSION['id_usuario']; - // logoff_db ($iduser, $_SERVER["REMOTE_ADDR"]); check why is not available + + /* + * Check why is not available. + * logoff_db ($iduser, $_SERVER["REMOTE_ADDR"]); + */ + unset($_SESSION['id_usuario']); unset($iduser); - if ($config['loginhash_pwd'] != '' && $loginhash_data == md5($loginhash_user.io_output_password($config['loginhash_pwd']))) { + if ($config['loginhash_pwd'] != '' + && $loginhash_data == md5( + $loginhash_user.io_output_password($config['loginhash_pwd']) + ) + ) { db_logon($loginhash_user, $_SERVER['REMOTE_ADDR']); $_SESSION['id_usuario'] = $loginhash_user; $config['id_user'] = $loginhash_user; @@ -811,6 +893,8 @@ if (! isset($config['id_user'])) { include_once 'general/login_page.php'; db_pandora_audit('Logon Failed (loginhash', '', 'system'); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -823,7 +907,7 @@ if (! isset($config['id_user'])) { '*' ); if ($user_in_db == false) { - // logout + // Logout. $_REQUEST = []; $_GET = []; $_POST = []; @@ -834,6 +918,8 @@ if (! isset($config['id_user'])) { unset($iduser); include_once 'general/login_page.php'; while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -841,7 +927,7 @@ if (! isset($config['id_user'])) { if (((bool) $user_in_db['is_admin'] === false) && ((bool) $user_in_db['not_login'] === true) ) { - // logout + // Logout. $_REQUEST = []; $_GET = []; $_POST = []; @@ -852,6 +938,8 @@ if (! isset($config['id_user'])) { unset($iduser); include_once 'general/login_page.php'; while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -859,12 +947,12 @@ if (! isset($config['id_user'])) { } } -// Enterprise support +// Enterprise support. if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { include_once ENTERPRISE_DIR.'/load_enterprise.php'; } -// Log off +// Log off. if (isset($_GET['bye'])) { include 'general/logoff.php'; $iduser = $_SESSION['id_usuario']; @@ -877,11 +965,13 @@ if (isset($_GET['bye'])) { if ($config['auth'] == 'saml') { include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php'; - $as = new SimpleSAML_Auth_Simple($config['saml_source']); + $as = new SimpleSAML_Auth_Simple('PandoraFMS'); $as->logout(); } while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -889,10 +979,11 @@ if (isset($_GET['bye'])) { clear_pandora_error_for_header(); -// ---------------------------------------------------------------------- -// EXTENSIONS -// ---------------------------------------------------------------------- /* + * ---------------------------------------------------------------------- + * EXTENSIONS + * ---------------------------------------------------------------------- + * * Load the basic configurations of extension and add extensions into menu. * Load here, because if not, some extensions not load well, I don't why. */ @@ -901,7 +992,7 @@ $config['logged'] = false; extensions_load_extensions($process_login); if ($process_login) { - // Call all extensions login function + // Call all extensions login function. extensions_call_login_function(); unset($_SESSION['new_update']); @@ -992,7 +1083,7 @@ if (get_parameter('login', 0) !== 0) { } } -// Header +// Header. if ($config['pure'] == 0) { echo '

'; - // main_pure + // Main pure. } echo '
'; @@ -1211,31 +1305,31 @@ require_once 'include/functions_clippy.php'; clippy_start($sec2); while (@ob_end_flush()) { - // Dump. + // Dumping... + continue; } db_print_database_debug(); echo ''; $run_time = format_numeric((microtime(true) - $config['start_time']), 3); -echo "\n\n"; +echo "\n\n"; -// Values from PHP to be recovered from JAVASCRIPT +// Values from PHP to be recovered from JAVASCRIPT. require 'include/php_to_js_values.php'; + ?>