diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ca5acad422..5a86959d6a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2014-07-30 Miguel de Dios + + * godmode/servers/manage_recontask.php, + godmode/servers/manage_recontask_form.php, + include/functions_treeview.php, include/ajax/module.php, + include/functions_reporting.php, include/db/postgresql.php, + include/functions_servers.php, operation/agentes/estado_agente.php, + operation/tree.php: tiny fixes for the improve + the support of postgreSQL databases. + 2014-07-29 Miguel de Dios * include/functions_graph.php, include/functions_reporting.php, diff --git a/pandora_console/godmode/servers/manage_recontask.php b/pandora_console/godmode/servers/manage_recontask.php index 09e2ce0d27..6160426eeb 100644 --- a/pandora_console/godmode/servers/manage_recontask.php +++ b/pandora_console/godmode/servers/manage_recontask.php @@ -204,6 +204,7 @@ if (isset($_GET["create"])) { if (($id_recon_script == 'NULL') && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network)) { $result = db_process_sql_insert('trecon_task', $values); + $reason = __("Network provided is not correct"); } elseif ($id_recon_script != 'NULL') { @@ -215,9 +216,10 @@ if (isset($_GET["create"])) { $result = false; } } - else + else { $result = false; - + } + if ($result !== false) { ui_print_success_message(__('Successfully created recon task')); } diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index 6e1bc7a041..72bf02fb7c 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -54,7 +54,7 @@ if (is_ajax ()) { echo io_json_mb_encode($macros); return; } - + return; } @@ -261,7 +261,7 @@ $table->data[11][1] = html_print_input_text ('snmp_community', $snmp_community, $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script); - + $table->data[12][0] = "" . __('Explanation') . ""; $table->data[12][1] = "" . html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true); diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 7e1b98934a..6e0894d806 100644 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -23,6 +23,14 @@ include_once($config['homedir'] . "/include/functions_ui.php"); enterprise_include_once ('include/functions_metaconsole.php'); $get_plugin_macros = get_parameter('get_plugin_macros'); +$search_modules = get_parameter('search_modules'); +$get_module_detail = get_parameter ('get_module_detail', 0); +$get_module_autocomplete_input = (bool) get_parameter('get_module_autocomplete_input'); +$add_module_relation = (bool) get_parameter('add_module_relation'); +$remove_module_relation = (bool) get_parameter('remove_module_relation'); +$change_module_relation_updates = (bool) get_parameter('change_module_relation_updates'); +$get_id_tag = (bool) get_parameter('get_id_tag', 0); + if ($get_plugin_macros) { $id_plugin = get_parameter('id_plugin', 0); @@ -37,7 +45,7 @@ if ($get_plugin_macros) { return; } -$search_modules = get_parameter('search_modules'); + if ($search_modules) { $id_agents = json_decode(io_safe_output(get_parameter('id_agents'))); $filter = get_parameter('q', '') . '%'; @@ -56,10 +64,9 @@ if ($search_modules) { return; } -$get_module_detail = get_parameter ('get_module_detail', 0); if ($get_module_detail) { - + ui_include_time_picker(); ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/"); @@ -131,15 +138,16 @@ if ($get_module_detail) { html_print_table($formtable); - $moduletype_name = modules_get_moduletype_name (modules_get_agentmodule_type ($module_id)); + $moduletype_name = modules_get_moduletype_name( + modules_get_agentmodule_type($module_id)); $offset = (int) get_parameter("offset"); $block_size = (int) $config["block_size"]; $columns = array (); - $datetime_from = strtotime ($date_from.' '.$time_from); - $datetime_to = strtotime ($date_to.' '.$time_to); + $datetime_from = strtotime ($date_from . ' ' . $time_from); + $datetime_to = strtotime ($date_to . ' ' . $time_to); if ($moduletype_name == "log4x") { $table->width = "100%"; @@ -337,10 +345,10 @@ if ($get_module_detail) { return; } -$get_module_autocomplete_input = (bool) get_parameter('get_module_autocomplete_input'); + if ($get_module_autocomplete_input) { $id_agent = (int) get_parameter("id_agent"); - + ob_clean(); if ($id_agent > 0) { html_print_autocomplete_modules( @@ -350,7 +358,7 @@ if ($get_module_autocomplete_input) { return; } -$add_module_relation = (bool) get_parameter('add_module_relation'); + if ($add_module_relation) { $result = false; $id_module_a = (int) get_parameter("id_module_a"); @@ -384,7 +392,7 @@ if ($add_module_relation) { return; } -$remove_module_relation = (bool) get_parameter('remove_module_relation'); + if ($remove_module_relation) { $id_relation = (int) get_parameter("id_relation"); if ($id_relation > 0) { @@ -395,23 +403,25 @@ if ($remove_module_relation) { return; } -$change_module_relation_updates = (bool) get_parameter('change_module_relation_updates'); + if ($change_module_relation_updates) { $id_relation = (int) get_parameter("id_relation"); if ($id_relation > 0) { $result = (bool) modules_change_relation_lock($id_relation); } + echo json_encode($result); return; } -$get_id_tag = (bool) get_parameter('get_id_tag', 0); + if ($get_id_tag) { $tag_name = get_parameter('tag_name'); - + if ($tag_name) { $tag_id = db_get_value('id_tag', 'ttag', 'name', $tag_name); - } else { + } + else { $tag_id = 0; } diff --git a/pandora_console/include/db/postgresql.php b/pandora_console/include/db/postgresql.php index 2290ec790c..fe1e693bf1 100644 --- a/pandora_console/include/db/postgresql.php +++ b/pandora_console/include/db/postgresql.php @@ -332,6 +332,9 @@ function postgresql_db_process_sql_insert($table, $values) { else if (is_float ($value) || is_double ($value)) { $values_str .= sprintf("%f", $value); } + elseif (is_string($value) && (strtoupper($value) === 'NULL')) { + $values_str .= "NULL"; + } else { $values_str .= sprintf("'%s'", $value); } @@ -346,6 +349,7 @@ function postgresql_db_process_sql_insert($table, $values) { $query .= ' VALUES (' . $values_str . ')'; + return db_process_sql($query, 'insert_id'); } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 3c30fab393..afe2a9676d 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -961,7 +961,9 @@ function reporting_get_stats_servers($tiny = true) { $tdata[0] = html_print_image('images/network.png', true, array('title' => __('Network modules'), 'width' => '25px')); $tdata[1] = '' . format_numeric($server_performance ["total_network_modules"]) . ''; - $tdata[2] = '' . format_numeric($server_performance ["network_modules_rate"], 2) . ''; + $tdata[2] = '' . + format_numeric($server_performance ["network_modules_rate"], 2) . + ''; $tdata[3] = html_print_image('images/module.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '16px')) . '/sec '; $table_srv->rowclass[] = ''; diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 5b7679fca0..77ade97139 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -79,6 +79,8 @@ function servers_get_performance () { $data["avg_interval_remote_modules"] = array(); $data["avg_interval_local_modules"] = 0; $data["local_modules_rate"] = 0; + $data["network_modules_rate"] = 0; + if ($config["realtimestats"] == 1) { $counts = db_get_all_rows_sql ("SELECT tagente_modulo.id_modulo, COUNT(tagente_modulo.id_agente_modulo) modules diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 628253c2c1..d8d377280c 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -468,11 +468,19 @@ function treeview_printTree($type) { echo ''; echo ''; @@ -543,19 +553,25 @@ function treeview_printTree($type) { else { $id = $item['_id_']; } - + echo ""; echo $img . $item['_iconImg_'] ." " . __($item['_name_']) . ' ('; - $counts_info = array('total_count' => $item['_num_ok_'] + $item['_num_critical_'] + $item['_num_warning_'] + $item['_num_unknown_'], - 'normal_count' => $item['_num_ok_'], - 'critical_count' => $item['_num_critical_'], - 'warning_count' => $item['_num_warning_'], - 'unknown_count' => $item['_num_unknown_']); - + $counts_info = array( + 'total_count' => $item['_num_ok_'] + + $item['_num_critical_'] + + $item['_num_warning_'] + + $item['_num_unknown_'], + 'normal_count' => $item['_num_ok_'], + 'critical_count' => $item['_num_critical_'], + 'warning_count' => $item['_num_warning_'], + 'unknown_count' => $item['_num_unknown_']); + + reporting_tiny_stats($counts_info, false, $type); + echo ') '. ""; echo "
"; @@ -581,7 +597,11 @@ function treeview_getData ($type) { $avariableGroups = users_get_groups (); //Get all groups with agents - $full_groups = db_get_all_rows_sql("SELECT DISTINCT id_grupo FROM tagente WHERE total_count > 0"); + $full_groups = db_get_all_rows_sql(" + SELECT DISTINCT id_grupo + FROM tagente + WHERE total_count > 0"); + if ($full_groups === false) { return array (); } @@ -607,9 +627,12 @@ function treeview_getData ($type) { switch ($select_status) { case NORMAL: foreach ($avariableGroups as $group_name) { - $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); + $id_group = db_get_value_sql(' + SELECT id_grupo + FROM tgrupo + WHERE nombre ="' . $group_name . '"'); - $num_ok = groups_agent_ok($id_group); + $num_ok = groups_agent_ok($id_group); if ($num_ok <= 0) unset($avariableGroups[$id_group]); @@ -619,7 +642,10 @@ function treeview_getData ($type) { break; case WARNING: foreach ($avariableGroups as $group_name) { - $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); + $id_group = db_get_value_sql(' + SELECT id_grupo + FROM tgrupo + WHERE nombre ="' . $group_name . '"'); $num_warning = groups_agent_warning($id_group); @@ -629,7 +655,10 @@ function treeview_getData ($type) { break; case CRITICAL: foreach ($avariableGroups as $group_name) { - $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); + $id_group = db_get_value_sql(' + SELECT id_grupo + FROM tgrupo + WHERE nombre ="' . $group_name . '"'); $num_critical = groups_agent_critical($id_group); @@ -639,7 +668,10 @@ function treeview_getData ($type) { break; case UNKNOWN: foreach ($avariableGroups as $group_name) { - $id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"'); + $id_group = db_get_value_sql(' + SELECT id_grupo + FROM tgrupo + WHERE nombre ="' . $group_name . '"'); $num_unknown = groups_agent_unknown($id_group); @@ -656,17 +688,42 @@ function treeview_getData ($type) { } if ($search_free != '') { - $sql_search = " AND id_grupo IN (SELECT id_grupo FROM tagente - WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; + switch ($config['dbtype']) { + case "mysql": + $sql_search = " AND id_grupo IN ( + SELECT id_grupo + FROM tagente + WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; + break; + case "postgresql": + $sql_search = " AND id_grupo IN ( + SELECT id_grupo + FROM tagente + WHERE tagente.nombre LIKE '%$search_free%')"; + break; + case "oracle": + $sql_search = " AND id_grupo IN ( + SELECT id_grupo + FROM tagente + WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; + break; + } } else { $sql_search =''; } + $order_collate = ""; + switch ($config['dbtype']) { + case "mysql": + $order_collate = "COLLATE utf8_general_ci"; + break; + } + switch ($type) { - case 'os': + case 'os': $sql = agents_get_agents(array ( - 'order' => 'nombre COLLATE utf8_general_ci ASC', + 'order' => 'nombre ' . $order_collate . ' ASC', 'disabled' => 0, 'status' => $select_status, 'search' => $sql_search), @@ -676,7 +733,9 @@ function treeview_getData ($type) { false, true); - $sql_os = sprintf("SELECT * FROM tconfig_os WHERE id_os IN (%s)", $sql); + $sql_os = sprintf("SELECT * + FROM tconfig_os + WHERE id_os IN (%s)", $sql); $list = db_get_all_rows_sql($sql_os); @@ -692,17 +751,31 @@ function treeview_getData ($type) { switch ($config["dbtype"]) { case "mysql": + $list = db_get_all_rows_sql(" + SELECT * + FROM tgrupo + WHERE nombre IN (" . $stringAvariableGroups . ") $sql_search + ORDER BY nombre COLLATE utf8_general_ci ASC"); + break; case "postgresql": - $list = db_get_all_rows_sql("SELECT * FROM tgrupo WHERE nombre IN (" . $stringAvariableGroups . ") $sql_search ORDER BY nombre COLLATE utf8_general_ci ASC"); + $list = db_get_all_rows_sql(" + SELECT * + FROM tgrupo + WHERE nombre IN (" . $stringAvariableGroups . ") $sql_search + ORDER BY nombre ASC"); break; case "oracle": - $list = db_get_all_rows_sql("SELECT * FROM tgrupo WHERE dbms_lob.substr(nombre,4000,1) IN (" . $stringAvariableGroups . ") ORDER BY nombre COLLATE utf8_general_ci ASC"); + $list = db_get_all_rows_sql(" + SELECT * + FROM tgrupo + WHERE dbms_lob.substr(nombre,4000,1) IN (" . $stringAvariableGroups . ") + ORDER BY nombre COLLATE utf8_general_ci ASC"); break; } break; case 'module_group': $sql = agents_get_agents(array ( - 'order' => 'nombre COLLATE utf8_general_ci ASC', + 'order' => 'nombre ' . $order_collate . ' ASC', 'disabled' => 0, 'status' => $select_status, 'search' => $sql_search), @@ -714,8 +787,13 @@ function treeview_getData ($type) { // Skip agents without modules $sql .= ' AND tagente.total_count>0'; - $sql_module_groups = sprintf("SELECT * FROM tmodule_group - WHERE id_mg IN (SELECT id_module_group FROM tagente_modulo WHERE id_agente IN (%s))", $sql); + $sql_module_groups = sprintf(" + SELECT * + FROM tmodule_group + WHERE id_mg IN ( + SELECT id_module_group + FROM tagente_modulo + WHERE id_agente IN (%s))", $sql); $list = db_get_all_rows_sql($sql_module_groups); @@ -734,7 +812,8 @@ function treeview_getData ($type) { $groups = implode(',',$groups_id); if ($search_free != '') { - $sql = "SELECT DISTINCT tpolicies.id, tpolicies.name + $sql = " + SELECT DISTINCT tpolicies.id, tpolicies.name FROM tpolicies, tpolicy_modules, tagente_estado, tagente, tagente_modulo WHERE @@ -749,7 +828,7 @@ function treeview_getData ($type) { tagente.nombre LIKE '%$search_free%' AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 - ORDER BY tpolicies.name COLLATE utf8_general_ci ASC"; + ORDER BY tpolicies.name COLLATE utf8_general_ci ASC"; $list = db_get_all_rows_sql($sql); @@ -825,7 +904,7 @@ function treeview_getData ($type) { tagente.id_grupo IN ($groups) AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 - ORDER BY tpolicies.name COLLATE utf8_general_ci ASC"); + ORDER BY tpolicies.name ' . $order_collate . ' ASC"); $element = 0; switch ($select_status) { @@ -889,8 +968,28 @@ function treeview_getData ($type) { } if ($search_free != '') { - $sql_search = " AND t1.id_agente IN (SELECT id_agente FROM tagente - WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; + switch ($config['dbtype']) { + case "mysql": + $sql_search = " AND t1.id_agente IN ( + SELECT id_agente + FROM tagente + WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; + break; + case "postgresql": + $sql_search = " AND t1.id_agente IN ( + SELECT id_agente + FROM tagente + WHERE nombre LIKE '%$search_free%')"; + break; + case "oracle": + $sql_search = " AND t1.id_agente IN ( + SELECT id_agente + FROM tagente + WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; + break; + } + + } else { $sql_search = ''; @@ -899,7 +998,8 @@ function treeview_getData ($type) { if ($select_status != -1) $sql_search .= " AND estado = " . $select_status . " "; - $sql_search .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1'); + $sql_search .= tags_get_acl_tags( + $config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1'); switch ($config["dbtype"]) { case "mysql": @@ -915,7 +1015,7 @@ function treeview_getData ($type) { $sql_search.' GROUP BY t1.nombre ORDER BY t1.nombre'); break; - case "oracle": + case "oracle": $list = db_get_all_rows_sql(' SELECT dbms_lob.substr(t1.nombre,4000,1) as nombre FROM tagente_modulo t1, tagente t2, @@ -950,15 +1050,16 @@ function treeview_getData ($type) { $search_sql = sprintf(" AND tagente.nombre COLLATE utf8_general_ci LIKE '%%%s%%'", $search_free); } - $sql = "SELECT DISTINCT ttag.name - FROM ttag, ttag_module, tagente, tagente_modulo - WHERE ttag.id_tag = ttag_module.id_tag + $sql = " + SELECT DISTINCT ttag.name + FROM ttag, ttag_module, tagente, tagente_modulo + WHERE ttag.id_tag = ttag_module.id_tag AND tagente.id_agente = tagente_modulo.id_agente AND tagente.disabled = 0 AND ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo" . $search_sql . - $user_tags_sql . - " ORDER BY ttag.name COLLATE utf8_general_ci ASC"; + $user_tags_sql . " + ORDER BY ttag.name ' . $order_collate . ' ASC"; $list = db_get_all_rows_sql($sql); break; @@ -1054,6 +1155,13 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel return false; } + $order_collate = ""; + switch ($config['dbtype']) { + case "mysql": + $order_collate = "COLLATE utf8_general_ci"; + break; + } + //TODO CHANGE POLICY ACL FOR TAG ACL $extra_sql = ''; if ($extra_sql != '') { @@ -1062,7 +1170,18 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel $groups_sql = implode(', ', $avariableGroupsIds); if ($search_free != '') { - $search_sql = " AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'"; + switch ($config['dbtype']) { + case "mysql": + $search_sql = " AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'"; + break; + case "postgresql": + $search_sql = " AND tagente.nombre LIKE '%$search_free%'"; + break; + case "oracle": + $search_sql = " AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'"; + break; + } + } else { $search_sql = ''; @@ -1078,14 +1197,14 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel } } - $sql = agents_get_agents(array ( + $sql = agents_get_agents(array ( 'id_grupo' => $id, 'disabled' => 0, 'status' => $statusSel, 'search' => $search_sql), array ('*'), 'AR', - array('field' => 'nombre COLLATE utf8_general_ci', 'order' => ' ASC'), + array('field' => 'nombre ' . $order_collate, 'order' => ' ASC'), true); break; case 'os': @@ -1097,7 +1216,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel 'search' => $search_sql), array ('*'), 'AR', - array('field' => 'nombre COLLATE utf8_general_ci', 'order' => ' ASC'), + array('field' => 'nombre ' . $order_collate, 'order' => ' ASC'), true); break; case 'module_group': @@ -1117,7 +1236,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel FROM tagente_modulo WHERE id_module_group = ' . $id . ')'; - $sql .= 'ORDER BY nombre COLLATE utf8_general_ci ASC'; + $sql .= 'ORDER BY nombre ' . $order_collate . ' ASC'; break; case 'policies': @@ -1144,7 +1263,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_policy_module != 0 AND tpolicy_modules.id_policy = ' . $id . ' - group by tagente.id_agente + GROUP BY tagente.id_agente having COUNT(*) > 0)'; } else if ($statusSel == 0) { @@ -1152,11 +1271,12 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel // If status filter is NORMAL add void agents $sql .= " UNION SELECT * FROM tagente WHERE tagente.disabled = 0 - AND tagente.id_agente NOT IN (SELECT tagente_estado.id_agente + AND tagente.id_agente NOT IN ( + SELECT tagente_estado.id_agente FROM tagente_estado)"; } - $sql .= 'ORDER BY nombre COLLATE utf8_general_ci ASC'; + $sql .= 'ORDER BY nombre ' . $order_collate . ' ASC'; break; case 'module': @@ -1188,7 +1308,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel ) ', $name); - $sql .= 'ORDER BY nombre COLLATE utf8_general_ci ASC'; + $sql .= 'ORDER BY nombre ' . $order_collate . ' ASC'; break; case 'tag': @@ -1219,7 +1339,8 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel $sql .= ' AND tagente.disabled = 0'. $search_sql; - $sql .= ' GROUP BY tagente.id_agente ORDER BY tagente.nombre COLLATE utf8_general_ci ASC'; + $sql .= ' GROUP BY tagente.id_agente + ORDER BY tagente.nombre ' . $order_collate . ' ASC'; break; } @@ -1234,25 +1355,36 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel // Get SQL for the second tree branch function treeview_getSecondBranchSQL ($fatherType, $id, $id_father) { global $config; + + $order_collate = ""; + switch ($config['dbtype']) { + case "mysql": + $order_collate = "COLLATE utf8_general_ci"; + break; + } + switch ($fatherType) { case 'group': $sql = 'SELECT * FROM tagente_modulo AS t1 - INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo + INNER JOIN tagente_estado AS t2 + ON t1.id_agente_modulo = t2.id_agente_modulo WHERE t1.id_agente = ' . $id; $sql .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1'); break; case 'os': $sql = 'SELECT * FROM tagente_modulo AS t1 - INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo + INNER JOIN tagente_estado AS t2 + ON t1.id_agente_modulo = t2.id_agente_modulo WHERE t1.id_agente = ' . $id; $sql .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1'); break; case 'module_group': $sql = 'SELECT * FROM tagente_modulo AS t1 - INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo + INNER JOIN tagente_estado AS t2 + ON t1.id_agente_modulo = t2.id_agente_modulo WHERE t1.id_agente = ' . $id . ' AND id_module_group = ' . $id_father; $sql .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1'); break; @@ -1275,8 +1407,10 @@ function treeview_getSecondBranchSQL ($fatherType, $id, $id_father) { $symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~'; $name = $id_father; for ($i = 0; $i < strlen($symbols); $i++) { - $name = str_replace('_articapandora_'.ord(substr($symbols, $i, 1)).'_pandoraartica_', substr($symbols, $i, 1), $name); - } + $name = str_replace('_articapandora_' . + ord(substr($symbols, $i, 1)) .'_pandoraartica_', + substr($symbols, $i, 1), $name); + } switch ($config["dbtype"]) { case "mysql": $sql = 'SELECT * @@ -1315,8 +1449,9 @@ function treeview_getSecondBranchSQL ($fatherType, $id, $id_father) { break; } - // This line checks for initializated modules or (non-initialized) asyncronous modules - $sql .= ' AND disabled = 0 AND (utimestamp > 0 OR id_tipo_modulo IN (21,22,23)) ORDER BY nombre COLLATE utf8_general_ci ASC'; + // This line checks for initializated modules or (non-initialized) asyncronous modules + $sql .= ' AND disabled = 0 AND (utimestamp > 0 OR id_tipo_modulo IN (21,22,23)) + ORDER BY nombre ' . $order_collate . ' ASC'; return $sql; } ?> diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 8e117c7b6f..9047c87d4b 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -227,7 +227,7 @@ $order = null; $order_collation = ""; switch ($config["dbtype"]) { case "mysql": - $order_collation = " COLLATE utf8_general_ci"; + $order_collation = "COLLATE utf8_general_ci"; break; case "postgresql": case "oracle": diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index 47ad28a0a1..8b06be0357 100644 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -72,7 +72,7 @@ if (is_ajax ()) } if ($printAlertsTable) { $id_module = get_parameter('id_module'); - + if (defined ('METACONSOLE')) { $server = metaconsole_get_connection ($server_name); metaconsole_connect($server); @@ -86,7 +86,7 @@ if (is_ajax ()) } if ($printModuleTable) { $id_module = get_parameter('id_module'); - + if (defined ('METACONSOLE')) { $server = metaconsole_get_connection ($server_name); metaconsole_connect($server); @@ -139,7 +139,8 @@ if (is_ajax ()) } $avariableGroups = users_get_groups(); $avariableGroupsIds = array_keys($avariableGroups); - $sql = treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel, $search_free); + $sql = treeview_getFirstBranchSQL ($type, $id, + $avariableGroupsIds, $statusSel, $search_free); if ($sql === false) { $server_rows = array (); } @@ -437,7 +438,7 @@ if (is_ajax ()) "id=" . $row["id_agente_modulo"]; } echo "". html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . ""; - + echo " "; $nmodule_alerts = db_get_value_sql(sprintf("SELECT count(*) FROM talert_template_modules WHERE id_agent_module = %s", $row["id_agente_modulo"])); @@ -525,35 +526,44 @@ else { } $module_tab = array('text' => "" - . html_print_image ("images/brick.png", true, array ("title" => __('Modules'))) . "", 'active' => $activeTab == "module"); + . html_print_image("images/brick.png", + true, + array("title" => __('Modules'))) . "", + 'active' => $activeTab == "module"); $tags_tab = array('text' => "" - . html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "", 'active' => $activeTab == "tag"); - + . html_print_image("images/tag.png", + true, + array("title" => __('Tags'))) . "", + 'active' => $activeTab == "tag"); + switch ($activeTab) { case 'group': - $order = __('groups'); + $order = __('groups'); break; case 'module_group': - $order = __('module groups'); + $order = __('module groups'); break; case 'policies': - $order = __('policies'); + $order = __('policies'); break; case 'module': - $order = __('modules'); + $order = __('modules'); break; case 'os': - $order = __('OS'); + $order = __('OS'); break; case 'tag': - $order = __('tags'); + $order = __('tags'); break; } if (! defined ('METACONSOLE')) { $onheader = array('tag' => $tags_tab, 'os' => $os_tab, 'group' => $group_tab, 'module_group' => $module_group_tab, 'policies' => $policies_tab, 'module' => $module_tab); - ui_print_page_header (__('Tree view')." - ".__('Sort the agents by ') .$order, "images/extensions.png", false, "", false, $onheader); + ui_print_page_header( + __('Tree view') . " - " . __('Sort the agents by ') . $order, + "images/extensions.png", + false, "", false, $onheader); } else { @@ -569,7 +579,7 @@ else { if ($config['enable_tags_tree']) { $allowed_tabs[] = 'tag'; } - + if (!in_array($activeTab, $allowed_tabs)) { db_pandora_audit("HACK Attempt", "Trying to access to not allowed tab on tree view"); @@ -577,17 +587,19 @@ else { exit; } // End of tab check - + $group_tab = array('text' => "" . html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "", 'active' => $activeTab == "group"); $subsections['group'] = $group_tab; - - if($config['enable_tags_tree']) { - $tags_tab = array('text' => "" - . html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "", 'active' => $activeTab == "tag"); + if ($config['enable_tags_tree']) { + $tags_tab = array( + 'text' => "" . + html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "", + 'active' => $activeTab == "tag"); + $subsections['tag'] = $tags_tab; } @@ -649,6 +661,7 @@ ui_require_javascript_file('pandora_modules'); treeview_printTree($activeTab); + enterprise_hook('close_meta_frame'); ui_include_time_picker(); @@ -672,9 +685,13 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri * id_father int use in js and ajax php, its useful when you have a two subtrees with same agent for diferent each one */ function loadSubTree(type, div_id, less_branchs, id_father, server_name) { - hiddenDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv'); - loadDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv'); - pos = parseInt($('#tree_image'+id_father+'_'+type+'_'+div_id).attr('pos_tree')); + hiddenDiv = $('#tree_div' + id_father + '_' + type + '_' + div_id) + .attr('hiddenDiv'); + loadDiv = $('#tree_div' + id_father + '_' + type + '_' + div_id) + .attr('loadDiv'); + + pos = parseInt($('#tree_image' + id_father + '_' + type + '_' + div_id) + .attr('pos_tree')); //If has yet ajax request running if (loadDiv == 2) @@ -683,8 +700,10 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri if (loadDiv == 0) { //Put an spinner to simulate loading process - $('#tree_div'+id_father+'_'+type+'_'+div_id).html(""); - $('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal'); + $('#tree_div' + id_father + '_' + type + '_' + div_id) + .html(""); + $('#tree_div' + id_father + '_' + type + '_' + div_id) + .show('normal'); $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 2); $.ajax({
'; + + if (! defined ('METACONSOLE')) { + $list = treeview_getData ($type); + } else { - $servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup WHERE disabled = 0"); + $servers = db_get_all_rows_sql (" + SELECT * + FROM tmetaconsole_setup + WHERE disabled = 0"); + if ($servers === false) { $servers = array(); } @@ -502,6 +510,8 @@ function treeview_printTree($type) { metaconsole_restore_db(); } + + if ($list === false) { ui_print_error_message(__('There aren\'t agents in this agrupation')); echo '