From fb2c412a9ff45826531fbf2db34206e9bfd54693 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 5 Mar 2013 11:00:40 +0000 Subject: [PATCH] 2013-03-05 Miguel de Dios * include/functions_netflow.php, include/functions_graph.php, include/functions_config.php, include/functions_groups.php: improved source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7780 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 + pandora_console/include/functions_config.php | 3 +- pandora_console/include/functions_graph.php | 3 +- pandora_console/include/functions_groups.php | 115 ++++++++++-------- pandora_console/include/functions_netflow.php | 6 +- 5 files changed, 76 insertions(+), 57 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 50de0246f8..f9705a13d5 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2013-03-05 Miguel de Dios + + * include/functions_netflow.php, include/functions_graph.php, + include/functions_config.php, include/functions_groups.php: improved + source code style. + 2013-03-05 Miguel de Dios * godmode/agentes/module_manager_editor.php, diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 35b734f891..5b359f1b1c 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -994,7 +994,8 @@ function config_process_config () { //If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info if (($config["id_user"] == $id || check_acl ($config["id_user"], users_get_groups ($id), "UM")) && $config["user_can_update_info"]) { $view_mode = false; - } else { + } + else { $view_mode = true; } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index b46fafcfcb..05cb38eb59 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1029,7 +1029,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $ $nextData = modules_get_next_data ($agent_module_id, $date); if ($nextData !== false) { array_push ($data, $nextData); - } else if (count ($data) > 0) { + } + else if (count ($data) > 0) { // Propagate the last known data to the end of the interval $nextData = array_pop ($data); array_push ($data, $nextData); diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index a18e6f1b0e..ab836ec7b1 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -841,7 +841,7 @@ function groups_create_group($group_name, $rest_values){ $check = db_get_value('nombre', 'tgrupo', 'nombre', $group_name); - if (!$check){ + if (!$check) { $result = db_process_sql_insert('tgrupo', $values); } else { @@ -860,10 +860,11 @@ function groups_agent_not_init ($group_array) { if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)) { $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; @@ -896,7 +897,7 @@ function groups_agent_ok ($group_array) { return 0; } - else if (!is_array ($group_array)){ + else if (!is_array ($group_array)) { $group_array = array($group_array); } @@ -913,10 +914,11 @@ function groups_agent_critical ($group_array) { if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)) { $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; @@ -928,14 +930,15 @@ function groups_agent_critical ($group_array) { // Get warning agents by using the status code in modules. function groups_agent_warning ($group_array) { - + if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)) { $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; @@ -946,36 +949,38 @@ function groups_agent_warning ($group_array) { // Get monitor NOT INIT, except disabled AND async modules function groups_monitor_not_init ($group_array) { - + // If there are not groups to query, we jump to nextone if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)) { $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - //TODO REVIEW ORACLE AND POSTGRES + //TODO REVIEW ORACLE AND POSTGRES return db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); } // Get monitor OK, except disabled and non-init function groups_monitor_ok ($group_array) { - + // If there are not groups to query, we jump to nextone if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)) { $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; @@ -986,16 +991,17 @@ function groups_monitor_ok ($group_array) { // Get monitor CRITICAL, except disabled and non-init function groups_monitor_critical ($group_array) { - + // If there are not groups to query, we jump to nextone if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)) { $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; @@ -1012,30 +1018,32 @@ function groups_monitor_warning ($group_array) { if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)) { $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - //TODO REVIEW ORACLE AND POSTGRES + //TODO REVIEW ORACLE AND POSTGRES return db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); } // Get monitor UNKNOWN, except disabled and non-init function groups_monitor_unknown ($group_array) { - + // If there are not groups to query, we jump to nextone if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)) { $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; @@ -1046,58 +1054,58 @@ function groups_monitor_unknown ($group_array) { // Get alerts defined for a given group, except disabled function groups_monitor_alerts ($group_array) { - + // If there are not groups to query, we jump to nextone if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)) { $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; //TODO REVIEW ORACLE AND POSTGRES return db_get_sql ("SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 - AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); - + FROM talert_template_modules, tagente_modulo, tagente_estado, tagente + WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 + AND talert_template_modules.disabled = 0 + AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); } // Get alert configured currently FIRED, except disabled function groups_monitor_fired_alerts ($group_array) { - + // If there are not groups to query, we jump to nextone if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)){ $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; //TODO REVIEW ORACLE AND POSTGRES return db_get_sql ("SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 - AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - AND times_fired > 0"); - + FROM talert_template_modules, tagente_modulo, tagente_estado, tagente + WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 + AND talert_template_modules.disabled = 0 + AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo + AND times_fired > 0"); } /** @@ -1114,10 +1122,11 @@ function groups_total_agents ($group_array, $disabled = false) { if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)){ $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; @@ -1125,9 +1134,8 @@ function groups_total_agents ($group_array, $disabled = false) { if (!$disabled) $sql .= " AND disabled = 0"; - + return db_get_sql ($sql); - } /** @@ -1143,16 +1151,17 @@ function groups_agent_disabled ($group_array) { if (empty ($group_array)) { return 0; - } else if (!is_array ($group_array)){ + } + else if (!is_array ($group_array)){ $group_array = array($group_array); } - + $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; $sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause AND disabled = 1"; - return db_get_sql ($sql); + return db_get_sql ($sql); } diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 843c7323ee..00a2bf9ee2 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -597,7 +597,8 @@ function netflow_get_stats ($start_date, $end_date, $filter, $aggregate, $max, $ $values[$i]['datetime'] = $end_date; if ($aggregate == 'proto') { $values[$i]['agg'] = $val[3]; - } else { + } + else { $values[$i]['agg'] = $val[4]; } if (! isset ($val[9])) { @@ -1002,7 +1003,8 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi if ($output == 'HTML' || $output == 'PDF') { $html = netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit); return $html; - } else if ($output == 'XML') { + } + else if ($output == 'XML') { return netflow_stat_xml ($data); } break;