From df50d9f7316125c4e7f33145c4582345b5bd59f2 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Fri, 15 Mar 2013 14:38:48 +0000 Subject: [PATCH] 2013-03-15 Miguel de Dios * include/functions_events.php, include/functions_html.php, include/functions_graph.php, include/functions_reporting.php, operation/events/events_list.php, operation/events/events.php, operation/agentes/group_view.php: improved source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7859 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 ++++++ pandora_console/include/functions_events.php | 24 +++++++++---------- pandora_console/include/functions_graph.php | 18 +++++++------- pandora_console/include/functions_html.php | 2 +- .../include/functions_reporting.php | 17 ++++++------- .../operation/agentes/group_view.php | 13 +++++----- pandora_console/operation/events/events.php | 4 ++-- .../operation/events/events_list.php | 8 +++---- 8 files changed, 51 insertions(+), 42 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b0c20f7761..b4c84703f5 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2013-03-15 Miguel de Dios + + * include/functions_events.php, include/functions_html.php, + include/functions_graph.php, include/functions_reporting.php, + operation/events/events_list.php, operation/events/events.php, + operation/agentes/group_view.php: improved source code style. + 2013-03-15 Miguel de Dios * godmode/massive/massive_copy_modules.php: uploaded lost changes diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f9a2e63ea1..e61e078f4b 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -70,14 +70,14 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met global $config; $table = events_get_events_table($meta, $history); - - if($meta) { + + if ($meta) { $groupby_extra = ', server_id'; } else { $groupby_extra = ''; } - + switch ($config["dbtype"]) { case "mysql": db_process_sql ('SET group_concat_max_len = 9999999'); @@ -89,9 +89,9 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met (SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user, (SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario FROM $table te - WHERE 1=1 ".$sql_post." - GROUP BY estado, evento, id_agentmodule".$groupby_extra." - ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination; + WHERE 1=1 " . $sql_post . " + GROUP BY estado, evento, id_agentmodule" . $groupby_extra . " + ORDER BY timestamp_rep DESC LIMIT " . $offset . "," . $pagination; break; case "postgresql": $sql = "SELECT *, MAX(id_evento) AS id_evento, array_to_string(array_agg(DISTINCT user_comment), '
') AS user_comment, @@ -101,9 +101,9 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met (SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user, (SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario FROM $table te - WHERE 1=1 ".$sql_post." - GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra".$groupby_extra." - ORDER BY timestamp_rep DESC LIMIT ".$pagination." OFFSET ".$offset; + WHERE 1=1 " . $sql_post . " + GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra" . $groupby_extra . " + ORDER BY timestamp_rep DESC LIMIT " . $pagination . " OFFSET " . $offset; break; case "oracle": $set = array(); @@ -111,7 +111,7 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met $set['offset'] = $offset; // TODO: Remove duplicate user comments $sql = "SELECT a.*, b.event_rep, b.timestamp_rep - FROM (SELECT * FROM $table WHERE 1=1 ".$sql_post.") a, + FROM (SELECT * FROM $table WHERE 1=1 " . $sql_post . ") a, (SELECT MAX (id_evento) AS id_evento, to_char(evento) AS evento, id_agentmodule, COUNT(*) AS event_rep, LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep, @@ -120,8 +120,8 @@ function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $met (SELECT owner_user FROM tevento WHERE id_evento = MAX(te.id_evento)) owner_user, (SELECT id_usuario FROM tevento WHERE id_evento = MAX(te.id_evento)) id_usuario FROM $table te - WHERE 1=1 ".$sql_post." - GROUP BY estado, to_char(evento), id_agentmodule".$groupby_extra.") b + WHERE 1=1 " . $sql_post . " + GROUP BY estado, to_char(evento), id_agentmodule" . $groupby_extra . ") b WHERE a.id_evento=b.id_evento AND to_char(a.evento)=to_char(b.evento) AND a.id_agentmodule=b.id_agentmodule"; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index cae6d1ef0a..18a1853ab7 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1383,17 +1383,17 @@ function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $re $filter = array('disabled' => 0, 'id_grupo' => array_keys(users_get_groups(false, 'AR', false))); - - if(!empty($id_agent)) { + + if (!empty($id_agent)) { $filter['id_agente'] = $id_agent; } $fields = array('SUM(critical_count) Critical', - 'SUM(warning_count) Warning', - 'SUM(normal_count) Normal', - 'SUM(unknown_count) Unknown'); + 'SUM(warning_count) Warning', + 'SUM(normal_count) Normal', + 'SUM(unknown_count) Unknown'); - if($show_not_init) { + if ($show_not_init) { $fields[] = 'SUM(notinit_count) "Not init"'; } @@ -1401,18 +1401,18 @@ function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $re // If any value is negative, truncate it to 0 function truncate_negatives(&$element) { - if($element < 0) { + if ($element < 0) { $element = 0; } } array_walk($data, 'truncate_negatives'); - + $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("/images/logo_vertical_water.png")); $colors = array(COL_CRITICAL, COL_WARNING, COL_NORMAL, COL_UNKNOWN); - if($show_not_init) { + if ($show_not_init) { $colors[] = COL_NOTINIT; } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index ae6e1e01d4..127649d81d 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1070,7 +1070,7 @@ function html_print_input_hidden_extended($name, $value, $id, $return = false, $ */ function html_print_submit_button ($label = 'OK', $name = '', $disabled = false, $attributes = '', $return = false) { if (!$name) { - $name="unnamed"; + $name = "unnamed"; } if (is_array ($attributes)) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 78ea5d234e..d98d58e76c 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1004,7 +1004,8 @@ function reporting_get_stats_modules_status($data, $graph_width = 250, $graph_he $tdata = array(); $table_mbs->colspan[count($table_mbs->data)][0] = 4; $table_mbs->cellstyle[count($table_mbs->data)][0] = 'text-align: center;'; - $tdata[0] = '
' . graph_agent_status (false, $graph_width, $graph_height, true, true) . '
'; + $tdata[0] = '
' . + graph_agent_status (false, $graph_width, $graph_height, true, true) . '
'; $table_mbs->rowclass[] = ''; $table_mbs->data[] = $tdata; } @@ -1137,15 +1138,15 @@ function reporting_get_stats_users($data) { else{ $urls['defined_users'] = 'javascript:'; } - + // Users table $table_us = html_get_predefined_table(); - + $tdata = array(); $tdata[0] = html_print_image('images/group.png', true, array('title' => __('Defined users'), 'width' => '20px')); $tdata[1] = count (get_users ()); $tdata[1] = '' . $tdata[1] . ''; - + $tdata[2] = $tdata[3] = ' '; $table_us->rowclass[] = ''; $table_us->data[] = $tdata; @@ -1166,15 +1167,15 @@ function reporting_get_stats_agents_monitors($data) { $urls = array(); $urls['total_agents'] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60"; $urls['monitor_checks'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1"; - + // Agents and modules table $table_am = html_get_predefined_table(); - + $tdata = array(); $tdata[0] = html_print_image('images/bricks.png', true, array('title' => __('Total agents'), 'width' => '20px')); $tdata[1] = $data["total_agents"] <= 0 ? '-' : $data["total_agents"]; $tdata[1] = '' . $tdata[1] . ''; - + $tdata[2] = html_print_image('images/brick.png', true, array('title' => __('Monitor checks'), 'width' => '20px')); $tdata[3] = $data["monitor_checks"] <= 0 ? '-' : $data["monitor_checks"]; $tdata[3] = '' . $tdata[3] . ''; @@ -1189,7 +1190,7 @@ function reporting_get_stats_agents_monitors($data) { return $output; } - + function reporting_get_stats_indicators($data, $width = 280, $height = 20) { $table_ind = html_get_predefined_table(); diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 0a767759f4..4968aca74e 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -50,8 +50,8 @@ $groups_full = users_get_groups ($config['id_user'], "AR", true, true); $groups = array(); foreach($groups_full as $group) { $groups[$group['id_grupo']]['name'] = $group['nombre']; - - if($group['id_grupo'] != 0) { + + if ($group['id_grupo'] != 0) { $groups[$group['parent']]['childs'][] = $group['id_grupo']; $groups[$group['id_grupo']]['prefix'] = $groups[$group['parent']]['prefix'].'   '; } @@ -59,13 +59,14 @@ foreach($groups_full as $group) { $groups[$group['id_grupo']]['prefix'] = ''; } - if(!isset($groups[$group['id_grupo']]['childs'])) { + if (!isset($groups[$group['id_grupo']]['childs'])) { $groups[$group['id_grupo']]['childs'] = array(); } } -if ($config["realtimestats"] == 0){ - $updated_time = __('Last update'). " : ". ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true); +if ($config["realtimestats"] == 0) { + $updated_time = __('Last update') . " : " . + ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true); } else { $updated_time = __("Updated at realtime"); @@ -74,7 +75,7 @@ else { // Header ui_print_page_header (__("Group view"), "images/bricks.png", false, "", false, $updated_time ); -if(tags_has_user_acl_tags()) { +if (tags_has_user_acl_tags()) { ui_print_tags_warning(); } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index bb5e8d2c63..3eee7a0d78 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -41,7 +41,7 @@ if(enterprise_installed() && defined("METACONSOLE")) { // Get the history mode $history = (bool) get_parameter('history', 0); -if(isset($config['event_replication']) && $config['event_replication'] == 1 && !$meta) { +if (isset($config['event_replication']) && $config['event_replication'] == 1 && !$meta) { db_pandora_audit("ACL Violation", "Trying to access event viewer. View disabled due event replication."); ui_print_info_message('Event viewer is disabled due event replication. For more information, please contact with the administrator'); @@ -690,7 +690,7 @@ $(document).ready( function() { id = this.id.split ("-").pop (); $("#delete_cross_"+id).attr ("src", "images/spinner.gif"); - + jQuery.post ("", {"page" : "operation/events/events", "delete_event" : 1, diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index a1cfe33558..1ef51c0f67 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -162,7 +162,7 @@ if ($update_pressed || $open_filter){ if ($open_filter) { echo ''.__('Event control filter').' '.html_print_image ("images/go.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'

'; } -else{ +else { echo ''.__('Event control filter').' '.html_print_image ("images/down.png", true, array ("title" => __('Toggle filter(s)'), "id" => 'toggle_arrow')).'

'; } @@ -291,7 +291,7 @@ $data[0] = html_print_button(__('Add'), 'add_with', $add_with_tag_disabled, $data[0] .= html_print_input_hidden('tag_with', $tag_with_base64, true); $data[0] .= html_print_button(__('Remove'), 'remove_with', $remove_with_tag_disabled, '', 'class="delete sub"', true); - + $data[1] = html_print_button(__('Add'), 'add_without', $add_without_tag_disabled, '', 'class="add sub"', true); $data[1] .= html_print_input_hidden('tag_without', $tag_without_base64, true); @@ -374,7 +374,7 @@ $params['input_name'] = 'text_agent'; $params['value'] = $text_agent; $params['return'] = true; -if($meta) { +if ($meta) { $params['javascript_page'] = 'enterprise/meta/include/ajax/events.ajax'; } else { @@ -415,7 +415,7 @@ $data = array(); $data[0] = '
'; $data[0] .= '' . html_print_image("images/disk.png", true, array("border" => '0', "title" => __('Save filter'), "alt" => __('Save filter'))) . '  '; $data[0] .= '' . html_print_image("images/server_database.png", true, array("border" => '0', "title" => __('Load filter'), "alt" => __('Load filter'))) . ' '; -if(empty($id_name)) { +if (empty($id_name)) { $data[0] .= '[' . __('No filter loaded') . ']'; } else {