diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5516bccf85..af9122faa4 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,15 +1,31 @@ -2012-08-16 Vanessa Gil +2012-08-17 Miguel de Dios + + * include/functions_api.php: fixed the error messages althought you + have event data. - * pandoradb.oracle.sql - pandoradb.postgreSQL.sql - pandoradb.sql - extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql - extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql - extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql: Changed - type 'subnet' and 'field1' to trecon_task table. - - * godmode/servers/manage_recontask_form.php: Added help tip: - several networks to recon task. +2012-08-16 Miguel de Dios + + * extensions/plugin_registration.php, extensions/insert_data.php, + operation/users/user_edit.php, operation/events/events_list.php, + operation/events/events.php, operation/events/export_csv.php, + operation/incidents/incident_detail.php, + operation/visual_console/render_view.php, extras/pandora_diag.php, + mobile/operation/agents/view_agents.php, + godmode/servers/manage_recontask.php, + godmode/reporting/visual_console_builder.wizard.php, + include/functions_api.php: cleaned source code style. + + * godmode/setup/setup_visuals.php, operation/gis_maps/ajax.php, + operation/gis_maps/index.php, operation/gis_maps/render_view.php, + include/functions_config.php, include/functions_gis.php, + include/javascript/openlayers.pandora.js: added the feature to + hidden the names of agents in the map, and when it is set the + default icon in the setup and the agent haven't the icon, then this + is show in the map. Some code from the files "functions_config.php" + and "setup_visuals.php" are modifications of Sancho Lerena from the + branch 4.0. + + MERGED FROM BRANCH PANDORA 4.0 2012-08-16 Sergio Martin diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 3c2d679625..d92fbb3ea1 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -191,7 +191,10 @@ function mainInsertData() { page: "operation/agentes/exportdata", "search_agents_2": 1, "q": term, - id_group: function() { return $("#id_group").val(); }}; + id_group: function() { + return $("#id_group").val(); + } + }; jQuery.ajax ({ data: data_params, diff --git a/pandora_console/extensions/plugin_registration.php b/pandora_console/extensions/plugin_registration.php index 1d39faa409..a48d6ba932 100644 --- a/pandora_console/extensions/plugin_registration.php +++ b/pandora_console/extensions/plugin_registration.php @@ -89,9 +89,9 @@ function pluginreg_extension_main () { unlink ($config["attachment_store"] . "/plugin_definition.ini"); return; } - + // Verify if a plugin with the same name is already registered - + $sql0 = "SELECT COUNT(*) FROM tplugin WHERE name = '" . io_safe_input ($ini_array["plugin_definition"]["name"]) . "'"; $result = db_get_sql ($sql0); @@ -99,9 +99,9 @@ function pluginreg_extension_main () { if ($result> 0) { echo "

".__("Plugin already registered. Aborting!")."

"; unlink ($config["attachment_store"] . "/plugin_definition.ini"); - return;; + return; } - + $values = array( 'name' => io_safe_input ($ini_array["plugin_definition"]["name"]), 'description' => io_safe_input ($ini_array["plugin_definition"]["description"]), diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index 569b1ea01b..67316bade0 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -52,7 +52,7 @@ if (!isset($argc)) if ($console_mode == 1) { echo "\nPandora FMS PHP diagnostic tool v3.2 (c) Artica ST 2009-2010 \n"; - + if ($argc == 1 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) { echo "\nThis command line script gives information about Pandora FMS database. This program only can be executed from console, and need a parameter, the @@ -76,9 +76,9 @@ full path to Pandora FMS 'config.php' file. else { if (file_exists("../include/config.php")) include "../include/config.php"; - + global $config; - + // Not from console, this is a web session if ((!isset($config["id_user"])) OR (!check_acl ($config["id_user"], 0, "PM"))) { echo "

You don't have privileges to use diagnostic tool

"; @@ -121,43 +121,90 @@ render_info ("tsesion"); switch ($config["dbtype"]) { case "mysql": - render_info_data ("SELECT `value` FROM tconfig WHERE `token` = 'db_scheme_version'", "DB Schema Version"); - render_info_data ("SELECT `value` FROM tconfig WHERE `token` = 'db_scheme_build'", "DB Schema Build"); - render_info_data ("SELECT `value` FROM tconfig WHERE `token` = 'enterprise_installed'", "Enterprise installed"); - render_row ( date ("Y/m/d H:i:s",db_get_sql ("SELECT `value` FROM tconfig WHERE `token` = 'db_maintance'")), "PandoraDB Last run"); + render_info_data ("SELECT `value` + FROM tconfig + WHERE `token` = 'db_scheme_version'", "DB Schema Version"); + render_info_data ("SELECT `value` + FROM tconfig + WHERE `token` = 'db_scheme_build'", "DB Schema Build"); + render_info_data ("SELECT `value` + FROM tconfig + WHERE `token` = 'enterprise_installed'", "Enterprise installed"); + render_row ( date ("Y/m/d H:i:s", + db_get_sql ("SELECT `value` + FROM tconfig + WHERE `token` = 'db_maintance'")), "PandoraDB Last run"); - render_info_data ("SELECT value FROM tupdate_settings WHERE `key` = 'customer_key';", "Update Key"); - render_info_data ("SELECT value FROM tupdate_settings WHERE `key` = 'updating_code_path'", "Updating code path"); - render_info_data ("SELECT value FROM tupdate_settings WHERE `key` = 'keygen_path'", "Keygen path"); - render_info_data ("SELECT value FROM tupdate_settings WHERE `key` = 'current_update'", "Current Update #"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE `key` = 'customer_key';", "Update Key"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE `key` = 'updating_code_path'", "Updating code path"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE `key` = 'keygen_path'", "Keygen path"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE `key` = 'current_update'", "Current Update #"); break; case "postgresql": - render_info_data ("SELECT \"value\" FROM tconfig WHERE \"token\" = 'db_scheme_version'", "DB Schema Version"); - render_info_data ("SELECT \"value\" FROM tconfig WHERE \"token\" = 'db_scheme_build'", "DB Schema Build"); - render_info_data ("SELECT \"value\" FROM tconfig WHERE \"token\" = 'enterprise_installed'", "Enterprise installed"); - render_row ( date ("Y/m/d H:i:s",db_get_sql ("SELECT \"value\" FROM tconfig WHERE \"token\" = 'db_maintance'")), "PandoraDB Last run"); + render_info_data ("SELECT \"value\" + FROM tconfig + WHERE \"token\" = 'db_scheme_version'", "DB Schema Version"); + render_info_data ("SELECT \"value\" + FROM tconfig + WHERE \"token\" = 'db_scheme_build'", "DB Schema Build"); + render_info_data ("SELECT \"value\" + FROM tconfig + WHERE \"token\" = 'enterprise_installed'", "Enterprise installed"); + render_row ( date ("Y/m/d H:i:s", + db_get_sql ("SELECT \"value\" + FROM tconfig WHERE \"token\" = 'db_maintance'")), "PandoraDB Last run"); - render_info_data ("SELECT value FROM tupdate_settings WHERE \"key\" = 'customer_key';", "Update Key"); - render_info_data ("SELECT value FROM tupdate_settings WHERE \"key\" = 'updating_code_path'", "Updating code path"); - render_info_data ("SELECT value FROM tupdate_settings WHERE \"key\" = 'keygen_path'", "Keygen path"); - render_info_data ("SELECT value FROM tupdate_settings WHERE \"key\" = 'current_update'", "Current Update #"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE \"key\" = 'customer_key';", "Update Key"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE \"key\" = 'updating_code_path'", "Updating code path"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE \"key\" = 'keygen_path'", "Keygen path"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE \"key\" = 'current_update'", "Current Update #"); break; case "oracle": - render_info_data ("SELECT value FROM tconfig WHERE token = 'db_scheme_version'", "DB Schema Version"); - render_info_data ("SELECT value FROM tconfig WHERE token = 'db_scheme_build'", "DB Schema Build"); - render_info_data ("SELECT value FROM tconfig WHERE token = 'enterprise_installed'", "Enterprise installed"); - render_row (db_get_sql ("SELECT value FROM tconfig WHERE token = 'db_maintance'"), "PandoraDB Last run"); + render_info_data ("SELECT value + FROM tconfig + WHERE token = 'db_scheme_version'", "DB Schema Version"); + render_info_data ("SELECT value + FROM tconfig + WHERE token = 'db_scheme_build'", "DB Schema Build"); + render_info_data ("SELECT value + FROM tconfig + WHERE token = 'enterprise_installed'", "Enterprise installed"); + render_row (db_get_sql ("SELECT value + FROM tconfig + WHERE token = 'db_maintance'"), "PandoraDB Last run"); - render_info_data ("SELECT value FROM tupdate_settings WHERE key = 'customer_key'", "Update Key"); - render_info_data ("SELECT value FROM tupdate_settings WHERE key = 'updating_code_path'", "Updating code path"); - render_info_data ("SELECT value FROM tupdate_settings WHERE key = 'keygen_path'", "Keygen path"); - render_info_data ("SELECT value FROM tupdate_settings WHERE key = 'current_update'", "Current Update #"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE key = 'customer_key'", "Update Key"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE key = 'updating_code_path'", "Updating code path"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE key = 'keygen_path'", "Keygen path"); + render_info_data ("SELECT value + FROM tupdate_settings + WHERE key = 'current_update'", "Current Update #"); break; } if ($console_mode == 0) { echo ""; } - - -?> +?> \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_builder.wizard.php b/pandora_console/godmode/reporting/visual_console_builder.wizard.php index cea5ab08a0..9e52848989 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.wizard.php +++ b/pandora_console/godmode/reporting/visual_console_builder.wizard.php @@ -124,7 +124,7 @@ $table->data["all_3"][0] = __('Agents'); $table->data["all_3"][1] = html_print_select (agents_get_group_agents (0, false, "none", false, true), 'id_agents[]', 0, false, '', '', true, true); -$table->data["all_3"][2] = ' ' . __('Modules') . ''; +$table->data["all_3"][2] = ' ' . __('Modules') . ''; $table->data["all_3"][3] = html_print_select (array (), 'module[]', 0, false, __('None'), -1, true, true); diff --git a/pandora_console/godmode/servers/manage_recontask.php b/pandora_console/godmode/servers/manage_recontask.php index 40aaeddbd2..301fa67093 100644 --- a/pandora_console/godmode/servers/manage_recontask.php +++ b/pandora_console/godmode/servers/manage_recontask.php @@ -276,7 +276,7 @@ if ($result !== false) { // PORTS if ($row["id_recon_script"] == 0) { - $data[7] = substr($row["recon_ports"],0,15); + $data[7] = substr($row["recon_ports"],0,15); } else { $data[7] = "-"; diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index f248880153..66805d4604 100644 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -37,6 +37,7 @@ enterprise_include ('godmode/setup/setup_visuals.php'); */ require_once ('include/functions_themes.php'); +require_once ('include/functions_gis.php'); // Header ui_print_page_header (__('Visual configuration'), "", false, "", true); @@ -139,9 +140,47 @@ $table->data[20][0] = __('Item title size text') . ui_print_help_tip(__('When th $table->data[20][1] = html_print_input_text ('item_title_size_text', $config["item_title_size_text"], '', 3, 3, true); +$table->data[21][0] = __('GIS Labels') . ui_print_help_tip(__('This enabling this, you get a label with agent name in GIS maps. If you have lots of agents in the map, will be unreadable. Disabled by default.'), true); +$table->data[21][1] = __('Yes').' '.html_print_radio_button ('gis_label', 1, '', $config["gis_label"], true).'  '; +$table->data[21][1] .= __('No').' '.html_print_radio_button ('gis_label', 0, '', $config["gis_label"], true); + + +$listIcons = gis_get_array_list_icons(); + +$arraySelectIcon = array(); +foreach ($listIcons as $index => $value) $arraySelectIcon[$index] = $index; + +$path = 'images/gis_map/icons/'; //TODO set better method the path + +$table->data[22][0] = __('Default icon in GIS') . ui_print_help_tip(__('Agent icon for GIS Maps. If set to "none", group icon will be used'), true); + +$gis_default_icon = $config["gis_default_icon"]; + +if ($gis_default_icon == '') { + $display_icons = 'none'; + // Hack to show no icon. Use any given image to fix not found image errors + $path_without = "images/spinner.png"; + $path_default = "images/spinner.png"; + $path_ok = "images/spinner.png"; + $path_bad = "images/spinner.png"; + $path_warning = "images/spinner.png"; +} +else { + $display_icons = ''; + $path_without = $path . $gis_default_icon . ".default.png"; + $path_default = $path . $gis_default_icon . ".default.png"; + $path_ok = $path . $gis_default_icon . ".ok.png"; + $path_bad = $path . $gis_default_icon . ".bad.png"; + $path_warning = $path . $gis_default_icon . ".warning.png"; +} + +$table->data[22][1] = html_print_select($arraySelectIcon, "gis_default_icon", $gis_default_icon, "changeIcons();", __('None'), '', true) . ' ' . html_print_image($path_ok, true, array("id" => "icon_ok", "style" => "display:".$display_icons.";")) . ' ' . html_print_image($path_bad, true, array("id" => "icon_bad", "style" => "display:".$display_icons.";")) . ' ' . html_print_image($path_warning, true, array("id" => "icon_warning", "style" => "display:".$display_icons.";")); + + echo '
'; html_print_input_hidden ('update_config', 1); html_print_table ($table); + echo '
'; html_print_submit_button (__('Update'), 'update_button', false, 'class="sub upd"'); echo '
'; diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 8866463004..68f6aaa56e 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -784,7 +784,7 @@ function api_set_delete_agent($id, $thrash1, $thrast2, $thrash3) { * @param $thrash3 Don't use. */ function api_get_all_agents($thrash1, $thrash2, $other, $thrash3) { - + $where = ''; if (isset($other['data'][0])){ @@ -795,22 +795,22 @@ function api_get_all_agents($thrash1, $thrash2, $other, $thrash3) { } if (isset($other['data'][1])){ // Filter by group - if ($other['data'][1] != ""){ + if ($other['data'][1] != "") { $where .= " AND id_grupo = " . $other['data'][1]; } } - if (isset($other['data'][3])){ + if (isset($other['data'][3])) { // Filter by name if ($other['data'][3] != ""){ $where .= " AND nombre LIKE ('%" . $other['data'][3] . "%')"; - } + } } - if (isset($other['data'][4])){ + if (isset($other['data'][4])) { // Filter by policy - if ($other['data'][4] != ""){ + if ($other['data'][4] != "") { $filter_by_policy = enterprise_hook('policies_get_filter_by_agent', array($other['data'][4])); if ($filter_by_policy !== ENTERPRISE_NOT_HOOK){ - $where .= $filter_by_policy; + $where .= $filter_by_policy; } } } @@ -824,9 +824,9 @@ function api_get_all_agents($thrash1, $thrash2, $other, $thrash3) { $result_agents = array(); // Filter by state $sql = "SELECT id_agente, nombre, direccion, comentarios, tconfig_os.name, url_address FROM tagente, tconfig_os WHERE tagente.id_os = tconfig_os.id_os AND disabled = 0 " . $where; - - $all_agents = db_get_all_rows_sql($sql); - + + $all_agents = db_get_all_rows_sql($sql); + // Filter by status: unknown, warning, critical, without modules if (isset($other['data'][2])){ if ($other['data'][2] != "") { @@ -837,12 +837,12 @@ function api_get_all_agents($thrash1, $thrash2, $other, $thrash3) { $modules = db_get_all_rows_filter('tagente_modulo', $filter_modules, 'id_agente_modulo'); $result_modules = array(); // Skip non init modules - foreach ($modules as $module){ + foreach ($modules as $module) { if (modules_get_agentmodule_is_init($module['id_agente_modulo'])){ $result_modules[] = $module; - } + } } - + // Without modules NO_MODULES if ($other['data'][2] == 'no_modules'){ if (empty($result_modules) and $other['data'][2] == 'no_modules'){ @@ -853,27 +853,27 @@ function api_get_all_agents($thrash1, $thrash2, $other, $thrash3) { else { $status = agents_get_status($agent['id_agente'], true); // Filter by status - switch ($other['data'][2]){ + switch ($other['data'][2]) { case 'warning': - if ($status == 2){ + if ($status == 2) { $result_agents[] = $agent; } - break; + break; case 'critical': - if ($status == 1){ + if ($status == 1) { $result_agents[] = $agent; } break; case 'unknown': - if ($status == 3){ - $result_agents[] = $agent; + if ($status == 3) { + $result_agents[] = $agent; } break; case 'normal': - if ($status == 0){ - $result_agents[] = $agent; + if ($status == 0) { + $result_agents[] = $agent; } - break; + break; } } } @@ -886,13 +886,13 @@ function api_get_all_agents($thrash1, $thrash2, $other, $thrash3) { $result_agents = $all_agents; } - if (count($result_agents) > 0 and $result_agents !== false){ + if (count($result_agents) > 0 and $result_agents !== false) { $data = array('type' => 'array', 'data' => $result_agents); - returnData('csv', $data, $separator); + returnData('csv', $data, $separator); } else { - returnError('error_all_agents', 'No agents retrieved.'); + returnError('error_all_agents', 'No agents retrieved.'); } } @@ -910,13 +910,15 @@ function api_get_all_agents($thrash1, $thrash2, $other, $thrash3) { * @param $thrash3 Don't use. */ function api_get_agent_modules($thrash1, $thrash2, $other, $thrash3) { - + $sql = sprintf("SELECT id_agente, id_agente_modulo, nombre - FROM tagente_modulo WHERE id_agente = %d AND disabled = 0 AND delete_pending = 0", $other['data'][0]); - - $all_modules = db_get_all_rows_sql($sql); - - if (count($all_modules) > 0 and $all_modules !== false){ + FROM tagente_modulo + WHERE id_agente = %d AND disabled = 0 + AND delete_pending = 0", $other['data'][0]); + + $all_modules = db_get_all_rows_sql($sql); + + if (count($all_modules) > 0 and $all_modules !== false) { $data = array('type' => 'array', 'data' => $all_modules); returnData('csv', $data, ';'); @@ -940,14 +942,16 @@ function api_get_agent_modules($thrash1, $thrash2, $other, $thrash3) { * @param $thrash3 Don't use. */ function api_get_group_agent($thrash1, $thrash2, $other, $thrash3) { - + $sql = sprintf("SELECT groups.nombre nombre - FROM tagente agents, tgrupo groups WHERE id_agente = %d AND agents.disabled = 0 AND groups.disabled = 0 - AND agents.id_grupo = groups.id_grupo", $other['data'][0]); - - $group_names = db_get_all_rows_sql($sql); - - if (count($group_names) > 0 and $group_names !== false){ + FROM tagente agents, tgrupo groups + WHERE id_agente = %d AND agents.disabled = 0 + AND groups.disabled = 0 + AND agents.id_grupo = groups.id_grupo", $other['data'][0]); + + $group_names = db_get_all_rows_sql($sql); + + if (count($group_names) > 0 and $group_names !== false) { $data = array('type' => 'array', 'data' => $group_names); returnData('csv', $data, ';'); @@ -971,21 +975,23 @@ function api_get_group_agent($thrash1, $thrash2, $other, $thrash3) { * @param $thrash3 Don't use. */ function api_get_policies($thrash1, $thrash2, $other, $thrash3) { - + $where = ''; - - if ($other['data'][0] != ""){ + + if ($other['data'][0] != "") { $where .= ' AND id_agent = ' . $other['data'][0]; - $sql = sprintf("SELECT policy.id, name, id_agent FROM tpolicies policy, tpolicy_agents pol_agents - WHERE policy.id = pol_agents.id %s", $where); - } else { - $sql = "SELECT id, name FROM tpolicies policy"; + $sql = sprintf("SELECT policy.id, name, id_agent + FROM tpolicies policy, tpolicy_agents pol_agents + WHERE policy.id = pol_agents.id %s", $where); + } + else { + $sql = "SELECT id, name FROM tpolicies policy"; } - $policies = db_get_all_rows_sql($sql); - - if (count($policies) > 0 and $policies !== false){ + $policies = db_get_all_rows_sql($sql); + + if (count($policies) > 0 and $policies !== false) { $data = array('type' => 'array', 'data' => $policies); returnData('csv', $data, ';'); @@ -1012,14 +1018,15 @@ function api_get_policy_modules($thrash1, $thrash2, $other, $thrash3) { $where = ''; - if ($other['data'][0] == ""){ + if ($other['data'][0] == "") { returnError('error_policy_modules', 'Error retrieving policy modules. Id_policy cannot be left blank.'); return; } - $policies = enterprise_hook('policies_get_modules_api', array($other['data'][0], $other['data'][1])); + $policies = enterprise_hook('policies_get_modules_api', + array($other['data'][0], $other['data'][1])); - if ($policies === ENTERPRISE_NOT_HOOK){ + if ($policies === ENTERPRISE_NOT_HOOK) { returnError('error_policy_modules', 'Error retrieving policy modules.'); return; } @@ -1291,7 +1298,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3){ } } - $plugin_module_fields = array('id_agente', 'disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', + $plugin_module_fields = array('id_agente', 'disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', 'min_critical', 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'ip_target', 'tcp_port', 'snmp_community', 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'descripcion', 'id_plugin', 'plugin_user', 'plugin_pass', 'plugin_parameter'); @@ -1696,49 +1703,49 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) { */ function api_set_new_network_component($id, $thrash1, $other, $thrash2) { - if ($id == ""){ + if ($id == "") { returnError('error_set_new_network_component', __('Error creating network component. Network component name cannot be left blank.')); - return; + return; } - if ($other['data'][0] < 6 or $other['data'][0] > 18){ + if ($other['data'][0] < 6 or $other['data'][0] > 18) { returnError('error_set_new_network_component', __('Error creating network component. Incorrect value for Network component type field.')); - return; + return; } - if ($other['data'][17] == ""){ + if ($other['data'][17] == "") { returnError('error_set_new_network_component', __('Error creating network component. Network component group cannot be left blank.')); - return; - } + return; + } $values = array ( - 'description' => $other['data'][1], - 'module_interval' => $other['data'][2], - 'max' => $other['data'][3], - 'min' => $other['data'][4], - 'snmp_community' => $other['data'][5], - 'id_module_group' => $other['data'][6], - 'id_modulo' => 2, - 'max_timeout' => $other['data'][7], - 'history_data' => $other['data'][8], - 'min_warning' => $other['data'][9], - 'max_warning' => $other['data'][10], - 'str_warning' => $other['data'][11], - 'min_critical' => $other['data'][12], - 'max_critical' => $other['data'][13], - 'str_critical' => $other['data'][14], - 'min_ff_event' => $other['data'][15], - 'post_process' => $other['data'][16]); + 'description' => $other['data'][1], + 'module_interval' => $other['data'][2], + 'max' => $other['data'][3], + 'min' => $other['data'][4], + 'snmp_community' => $other['data'][5], + 'id_module_group' => $other['data'][6], + 'id_modulo' => 2, + 'max_timeout' => $other['data'][7], + 'history_data' => $other['data'][8], + 'min_warning' => $other['data'][9], + 'max_warning' => $other['data'][10], + 'str_warning' => $other['data'][11], + 'min_critical' => $other['data'][12], + 'max_critical' => $other['data'][13], + 'str_critical' => $other['data'][14], + 'min_ff_event' => $other['data'][15], + 'post_process' => $other['data'][16]); $name_check = db_get_value ('name', 'tnetwork_component', 'name', $id); - if ($name_check !== false){ + if ($name_check !== false) { returnError('error_set_new_network_component', __('Error creating network component. This network component already exists.')); - return; + return; } $id = network_components_create_network_component ($id, $other['data'][0], $other['data'][17], $values); - + if (!$id) returnError('error_set_new_network_component', 'Error creating network component.'); else @@ -1764,54 +1771,54 @@ function api_set_new_network_component($id, $thrash1, $other, $thrash2) { */ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2) { - - if ($id == ""){ + + if ($id == "") { returnError('error_set_new_plugin_component', __('Error creating plugin component. Plugin component name cannot be left blank.')); - return; + return; } - if ($other['data'][7] == ""){ + if ($other['data'][7] == "") { returnError('error_set_new_plugin_component', __('Error creating plugin component. Incorrect value for Id plugin.')); - return; + return; } - - if ($other['data'][21] == ""){ + + if ($other['data'][21] == "") { returnError('error_set_new_plugin_component', __('Error creating plugin component. Plugin component group cannot be left blank.')); - return; - } + return; + } $values = array ( - 'description' => $other['data'][1], - 'module_interval' => $other['data'][2], - 'max' => $other['data'][3], - 'min' => $other['data'][4], - 'tcp_port' => $other['data'][5], - 'id_module_group' => $other['data'][6], - 'id_modulo' => 4, - 'id_plugin' => $other['data'][7], - 'plugin_user' => $other['data'][8], - 'plugin_pass' => $other['data'][9], - 'plugin_parameter' => $other['data'][10], - 'max_timeout' => $other['data'][11], - 'history_data' => $other['data'][12], - 'min_warning' => $other['data'][13], - 'max_warning' => $other['data'][14], - 'str_warning' => $other['data'][15], - 'min_critical' => $other['data'][16], - 'max_critical' => $other['data'][17], - 'str_critical' => $other['data'][18], - 'min_ff_event' => $other['data'][19], - 'post_process' => $other['data'][20]); + 'description' => $other['data'][1], + 'module_interval' => $other['data'][2], + 'max' => $other['data'][3], + 'min' => $other['data'][4], + 'tcp_port' => $other['data'][5], + 'id_module_group' => $other['data'][6], + 'id_modulo' => 4, + 'id_plugin' => $other['data'][7], + 'plugin_user' => $other['data'][8], + 'plugin_pass' => $other['data'][9], + 'plugin_parameter' => $other['data'][10], + 'max_timeout' => $other['data'][11], + 'history_data' => $other['data'][12], + 'min_warning' => $other['data'][13], + 'max_warning' => $other['data'][14], + 'str_warning' => $other['data'][15], + 'min_critical' => $other['data'][16], + 'max_critical' => $other['data'][17], + 'str_critical' => $other['data'][18], + 'min_ff_event' => $other['data'][19], + 'post_process' => $other['data'][20]); $name_check = db_get_value ('name', 'tnetwork_component', 'name', $id); - if ($name_check !== false){ + if ($name_check !== false) { returnError('error_set_new_plugin_component', __('Error creating plugin component. This plugin component already exists.')); - return; + return; } $id = network_components_create_network_component ($id, $other['data'][0], $other['data'][21], $values); - + if (!$id) returnError('error_set_new_plugin_component', 'Error creating plugin component.'); else @@ -1838,40 +1845,40 @@ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2) { */ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) { - - if ($id == ""){ + + if ($id == "") { returnError('error_set_new_snmp_component', __('Error creating SNMP component. SNMP component name cannot be left blank.')); - return; + return; } - if ($other['data'][0] < 15 or $other['data'][0] > 17){ + if ($other['data'][0] < 15 or $other['data'][0] > 17) { returnError('error_set_new_snmp_component', __('Error creating SNMP component. Incorrect value for Snmp component type field.')); - return; + return; } - - if ($other['data'][25] == ""){ + + if ($other['data'][25] == "") { returnError('error_set_new_snmp_component', __('Error creating SNMP component. Snmp component group cannot be left blank.')); - return; - } + return; + } # SNMP version 3 - if ($other['data'][16] == "3"){ + if ($other['data'][16] == "3") { - if ($other['data'][22] != "AES" and $other['data'][22] != "DES"){ + if ($other['data'][22] != "AES" and $other['data'][22] != "DES") { returnError('error_set_new_snmp_component', __('Error creating SNMP component. snmp3_priv_method doesn\'t exists. Set it to \'AES\' or \'DES\'. ')); return; } if ($other['data'][25] != "authNoPriv" and $other['data'][25] != "authPriv" and $other['data'][25] != "noAuthNoPriv"){ returnError('error_set_new_snmp_component', __('Error creating SNMP component. snmp3_sec_level doesn\'t exists. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); - return; - } + return; + } - if ($other['data'][24] != "MD5" and $other['data'][24] != "SHA"){ + if ($other['data'][24] != "MD5" and $other['data'][24] != "SHA") { returnError('error_set_new_snmp_component', __('Error creating SNMP component. snmp3_auth_method doesn\'t exists. Set it to \'MD5\' or \'SHA\'. ')); - return; - } - + return; + } + $values = array ( 'description' => $other['data'][1], 'module_interval' => $other['data'][2], @@ -3792,7 +3799,7 @@ function api_get_graph_module_data($id, $thrash1, $other, $thrash2) { $homeurl = '../'; $ttl = 1; - + global $config; $config['flash_charts'] = 0; @@ -5006,7 +5013,7 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db = nul return; } - + if ($other['type'] == 'string') { if ($other['data'] != '') { returnError('error_parameter', 'Error in the parameters.'); @@ -5018,18 +5025,20 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db = nul } else if ($other['type'] == 'array') { $separator = $other['data'][0]; - + $filterString = otherParameter2Filter($other); } - + $dataRows = db_get_all_rows_filter('tevento', $filterString); $last_error = error_get_last(); - if (!empty($last_error)) { - returnError('ERROR_API_PANDORAFMS', $returnType); - - return; + if (empty($dataRows)) { + if (!empty($last_error)) { + returnError('ERROR_API_PANDORAFMS', $returnType); + + return; + } } - + $data['type'] = 'array'; $data['data'] = $dataRows; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 824c7f384e..1b0e426728 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -232,6 +232,9 @@ function config_update_config () { config_update_value ('module_size_text_medium', get_parameter('module_size_text_medium')); config_update_value ('description_size_text', get_parameter('description_size_text')); config_update_value ('item_title_size_text', get_parameter('item_title_size_text')); + config_update_value ('gis_label', get_parameter ('gis_label')); + config_update_value ('gis_default_icon', get_parameter ('gis_default_icon')); + ///////////// break; case 'enterprise/godmode/setup/setup_history': @@ -271,13 +274,13 @@ function config_process_config () { /* Compatibility fix */ foreach ($configs as $c) { - $config[$c['token']] = $c['value']; + $config[$c['token']] = $c['value']; } if (!isset ($config['language'])) { config_update_value ('language', 'en'); } - + if (isset ($config['homeurl']) && $config['homeurl'][0] != '/') { $config['homeurl'] = '/'.$config['homeurl']; } @@ -703,7 +706,15 @@ function config_process_config () { if (!isset($config['item_title_size_text'])) { config_update_value ('item_title_size_text', 45); } + + if (!isset($config['gis_label'])) { + config_update_value ('gis_label', 0); + } + if (!isset($config['gis_default_icon'])) { + config_update_value ('gis_default_icon', "marker"); + } + /* Finally, check if any value was overwritten in a form */ config_update_config(); } @@ -713,7 +724,7 @@ function config_check () { // At this first version I'm passing errors using session variables, because the error management // is done by an AJAX request. Better solutions could be implemented in the future :-) - + // Check default password for "admin" $is_admin = db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']); if ($is_admin) { diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index 7c3c9557dc..3de865e656 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -36,7 +36,6 @@ function gis_add_parent_lines() { js_refreshParentLines('" . __('Hierarchy of agents') . "'); });"; echo ""; - } /** @@ -358,6 +357,10 @@ function gis_activate_ajax_refresh($layers = null, $lastTimeOfData = null) { function gis_add_agent_point($layerName, $pointName, $lat, $lon, $icon = null, $width = 20, $height = 20, $point_id = '', $status = -1, $type_string = '', $idParent = 0) { + + global $config; + if (!$config['gis_label']) + $pointName = ''; ?> $id)); - + if ($result === false){ echo 'error'; } else { echo 'ok'; - } + } } - if ($get_event_filters){ + if ($get_event_filters) { $event_filter = events_get_event_filter_select(); - echo json_encode($event_filter); + echo json_encode($event_filter); } return; @@ -433,12 +433,14 @@ if ($group_rep == 0) { case "mysql": $sql = "SELECT * FROM tevento - WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination; + WHERE 1=1 ".$sql_post." + ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination; break; case "postgresql": $sql = "SELECT * FROM tevento - WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$pagination." OFFSET ".$offset; + WHERE 1=1 ".$sql_post." + ORDER BY utimestamp DESC LIMIT ".$pagination." OFFSET ".$offset; break; case "oracle": $set = array(); @@ -446,7 +448,8 @@ if ($group_rep == 0) { $set['offset'] = $offset; $sql = "SELECT * FROM tevento - WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC"; + WHERE 1=1 ".$sql_post." + ORDER BY utimestamp DESC"; $sql = oracle_recode_query ($sql, $set); break; } @@ -455,8 +458,11 @@ else { switch ($config["dbtype"]) { case "mysql": db_process_sql ('SET group_concat_max_len = 9999999'); - $sql = "SELECT *, MAX(id_evento) AS id_evento, GROUP_CONCAT(DISTINCT user_comment SEPARATOR '') AS user_comment, - MIN(estado) AS min_estado, MAX(estado) AS max_estado, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep + $sql = "SELECT *, MAX(id_evento) AS id_evento, + GROUP_CONCAT(DISTINCT user_comment SEPARATOR '') AS user_comment, + MIN(estado) AS min_estado, + MAX(estado) AS max_estado, + COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep FROM tevento WHERE 1=1 ".$sql_post." GROUP BY evento, id_agentmodule diff --git a/pandora_console/operation/events/export_csv.php b/pandora_console/operation/events/export_csv.php index 9d216c7d50..919ad0f9fa 100644 --- a/pandora_console/operation/events/export_csv.php +++ b/pandora_console/operation/events/export_csv.php @@ -51,12 +51,9 @@ $tag = get_parameter("tag", ""); $filter = array (); if ($ev_group > 1) $filter['id_grupo'] = $ev_group; -/*if ($status == 1) - $filter['estado'] = 1; -if ($status == 0) - $filter['estado'] = 0; */ + $filter_state = ''; -switch($status) { +switch ($status) { case 0: case 1: case 2: @@ -65,14 +62,14 @@ switch($status) { case 3: $filter_state = " AND (estado = 0 OR estado = 2)"; break; -} +} if ($search != "") $filter[] = 'evento LIKE "%'.io_safe_input($search).'%"'; if (($event_type != "all") OR ($event_type != 0)) $filter['event_type'] = $event_type; if ($severity != -1) $filter[] = 'criticity >= '.$severity; - + if ($id_agent == -2) { $text_agent = (string) get_parameter("text_agent", __("All")); @@ -103,14 +100,14 @@ else { break; } } - - + + if ($id_agent != -1) $filter['id_agente'] = $id_agent; - + if ($id_event != -1) $filter['id_evento'] = $id_event; - + $timestamp_filter = ''; if ($event_view_hr > 0) { $unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds @@ -138,7 +135,7 @@ echo chr (13); $fields = array ('id_grupo', 'id_agente', 'evento', 'estado', 'id_usuario', 'event_type', 'criticity', 'timestamp'); -$sql = db_get_all_rows_filter ('tevento', $filter, $fields, 'AND', true, true); +$sql = db_get_all_rows_filter('tevento', $filter, $fields, 'AND', true, true); // If filter is empty and there are others filters not empty append "WHERE" clause if (empty($filter) and (!empty($filter_state) or !empty($timestamp_filter))) @@ -170,5 +167,4 @@ while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) { echo $event["criticity"]; echo chr (13); } -?> - +?> \ No newline at end of file diff --git a/pandora_console/operation/gis_maps/ajax.php b/pandora_console/operation/gis_maps/ajax.php index aaafe354ef..23c2e31fbc 100644 --- a/pandora_console/operation/gis_maps/ajax.php +++ b/pandora_console/operation/gis_maps/ajax.php @@ -18,6 +18,8 @@ require_once ("include/config.php"); check_login (); +global $config; + require_once ('include/functions_gis.php'); require_once ('include/functions_ui.php'); require_once ('include/functions_agents.php'); @@ -30,7 +32,8 @@ switch ($opt) { $returnJSON['correct'] = 1; $idConection = get_parameter('id_conection'); - $row = db_get_row_filter('tgis_map_connection', array('id_tmap_connection' => $idConection)); + $row = db_get_row_filter('tgis_map_connection', + array('id_tmap_connection' => $idConection)); $returnJSON['content'] = $row; @@ -113,6 +116,9 @@ switch ($opt) { foreach ($agentsGISStatus as $row) { $status = agents_get_status($row['tagente_id_agente']); + if (!$config['gis_label']) + $row['nombre'] = ''; + $agents[$row['tagente_id_agente']] = array( 'icon_path' => gis_get_agent_icon_map($row['tagente_id_agente'], true, $status), 'name' => $row['nombre'], @@ -158,19 +164,19 @@ switch ($opt) { else { $returnJSON['content'] .= __('Position (Long, Lat, Alt)') . ': (' . $agentDataGIS['stored_longitude'] . ', ' . $agentDataGIS['stored_latitude'] . ', ' . $agentDataGIS['stored_altitude'] . ')
'; - } + } $agent_ip_address = agents_get_address ($id_agente); if ($agent_ip_address || $agent_ip_address != '') { $returnJSON['content'] .= __('IP Address').': '.agents_get_address ($id_agente).'
'; } $returnJSON['content'] .= __('OS').': ' . ui_print_os_icon($row['id_os'], true, true); - + $osversion_offset = strlen($row["os_version"]); if ($osversion_offset > 15) { - $osversion_offset = $osversion_offset - 15; + $osversion_offset = $osversion_offset - 15; } else { - $osversion_offset = 0; + $osversion_offset = 0; } $returnJSON['content'] .= ' ( '.substr($row["os_version"],$osversion_offset,15).')
'; $agent_description = $row['comentarios']; @@ -181,7 +187,7 @@ switch ($opt) { $returnJSON['content'] .= __('Agent Version').': '.$row["agent_version"].'
'; $returnJSON['content'] .= __('Last contact') . ": "; if ($row["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") { - $returnJSON['content'] .=__('Never') ."
"; + $returnJSON['content'] .=__('Never') ."
"; } else { $returnJSON['content'] .= $row["ultimo_contacto_remoto"] ."
"; @@ -189,13 +195,12 @@ switch ($opt) { $returnJSON['content'] .= __('Remote').': '. $row["ultimo_contacto"]; echo json_encode($returnJSON); - break; case 'get_map_connection_data': $idConnection = get_parameter('id_connection'); $returnJSON = array(); - + $returnJSON['correct'] = 1; $returnJSON['content'] = db_get_row_sql('SELECT * FROM tgis_map_connection WHERE id_tmap_connection = ' . $idConnection); diff --git a/pandora_console/operation/gis_maps/index.php b/pandora_console/operation/gis_maps/index.php index 1aa7009f95..3554cc7779 100644 --- a/pandora_console/operation/gis_maps/index.php +++ b/pandora_console/operation/gis_maps/index.php @@ -43,7 +43,7 @@ if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) $own_groups = array_keys(users_get_groups($config['id_user'], "IR")); else $own_groups = array_keys(users_get_groups($config['id_user'], "IR", false)); - + if ($maps !== false) { foreach ($maps as $map) { if ($rowPair) diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index ccb94f2c16..aad384a35e 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -98,14 +98,15 @@ else { if (check_acl ($config["id_user"], $map['group_id'], "IW")) $buttons [] = ''.html_print_image ("images/setup.png", true, array ("title" => __('Setup'))).''; -$buttonsString = '' . html_print_image("images/bricks.png", true, array("class" => "top", "border" => '0')) . '  Agent - test_gis1