From 9cde128f7c52d45f96c489b5f13181285a0e78a0 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 24 Jul 2012 08:54:40 +0000 Subject: [PATCH] 2012-07-24 Miguel de Dios * godmode/servers/manage_recontask_form.php, godmode/alerts/configure_alert_compound.php, godmode/modules/manage_network_components.php, include/functions_ui.php, include/functions_incidents.php, include/functions_agents.php, include/functions_alerts.php, include/functions_messages.php, include/db/mysql.php, include/functions_reporting.php, include/functions_filemanager.php, include/auth/ldap.php, operation/events/events.php, operation/incidents/incident_detail.php, operation/tree.php, operation/agentes/estado_agente.php, operation/agentes/sla_view.php, operation/users/user_edit.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6798 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 14 ++ .../alerts/configure_alert_compound.php | 13 +- .../modules/manage_network_components.php | 2 +- .../godmode/servers/manage_recontask_form.php | 12 +- pandora_console/include/auth/ldap.php | 125 +++++++++++------- pandora_console/include/db/mysql.php | 11 +- pandora_console/include/functions_agents.php | 43 +++++- pandora_console/include/functions_alerts.php | 3 +- .../include/functions_filemanager.php | 8 +- .../include/functions_incidents.php | 11 +- .../include/functions_messages.php | 5 +- .../include/functions_reporting.php | 35 +++-- pandora_console/include/functions_ui.php | 2 +- .../operation/agentes/estado_agente.php | 46 ++----- .../operation/agentes/sla_view.php | 18 ++- pandora_console/operation/events/events.php | 2 +- .../operation/incidents/incident_detail.php | 3 +- pandora_console/operation/tree.php | 7 +- pandora_console/operation/users/user_edit.php | 3 +- 19 files changed, 218 insertions(+), 145 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 751fb67fa2..62362f97c1 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2012-07-24 Miguel de Dios + + * godmode/servers/manage_recontask_form.php, + godmode/alerts/configure_alert_compound.php, + godmode/modules/manage_network_components.php, + include/functions_ui.php, include/functions_incidents.php, + include/functions_agents.php, include/functions_alerts.php, + include/functions_messages.php, include/db/mysql.php, + include/functions_reporting.php, include/functions_filemanager.php, + include/auth/ldap.php, operation/events/events.php, + operation/incidents/incident_detail.php, operation/tree.php, + operation/agentes/estado_agente.php, operation/agentes/sla_view.php, + operation/users/user_edit.php: cleaned source code style. + 2012-07-23 Miguel de Dios * godmode/agentes/module_manager_editor_prediction.php, diff --git a/pandora_console/godmode/alerts/configure_alert_compound.php b/pandora_console/godmode/alerts/configure_alert_compound.php index 2e3017a8fd..0fa5f0275f 100644 --- a/pandora_console/godmode/alerts/configure_alert_compound.php +++ b/pandora_console/godmode/alerts/configure_alert_compound.php @@ -123,7 +123,8 @@ function update_compound ($step) { } alerts_set_alerts_compound_disable ($id, false); - } elseif ($step == 2) { + } + elseif ($step == 2) { $monday = (bool) get_parameter ('monday'); $tuesday = (bool) get_parameter ('tuesday'); $wednesday = (bool) get_parameter ('wednesday'); @@ -189,21 +190,23 @@ function update_compound ($step) { alerts_delete_alert_compound_action ($key); } } - + foreach ($add_actions as $id_action) { /* TODO: fires_min and fires_max missing */ alerts_add_alert_compound_action ($id, (int) $id_action); } - } elseif ($step == 3) { + } + elseif ($step == 3) { $recovery_notify = (bool) get_parameter ('recovery_notify'); $field2_recovery = (bool) get_parameter ('field2_recovery'); $field3_recovery = (bool) get_parameter ('field3_recovery'); - + $result = alerts_update_alert_compound ($id, array ('recovery_notify' => $recovery_notify, 'field2_recovery' => $field2_recovery, 'field3_recovery' => $field3_recovery)); - } else { + } + else { return false; } diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index eef80103cb..d30aac4507 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -469,4 +469,4 @@ function check_all_checkboxes() { $(".check_delete").attr('checked', false); } } - + \ No newline at end of file diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index 3f2b977692..77d47de968 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -86,16 +86,16 @@ if (isset ($_GET["update"]) or (isset($_GET["crt"]))) { // Edit mode $parent_detection = $row["parent_detection"]; $parent_recursion = $row["parent_recursion"]; } - -} elseif (isset ($_GET["create"]) or isset($_GET["crt"])) { +} +elseif (isset ($_GET["create"]) or isset($_GET["crt"])) { $create_recon = true; - if (isset ($_GET["crt"])){ - if ($_GET["crt"] != "Create"){ + if (isset ($_GET["crt"])) { + if ($_GET["crt"] != "Create") { $create_recon = false; } } - - if ($create_recon){ + + if ($create_recon) { $id_rt = -1; $name = ""; $network = ""; diff --git a/pandora_console/include/auth/ldap.php b/pandora_console/include/auth/ldap.php index bbf263270f..b7ad76905d 100644 --- a/pandora_console/include/auth/ldap.php +++ b/pandora_console/include/auth/ldap.php @@ -22,34 +22,35 @@ if (!isset ($config)) { die (' - -Pandora FMS - The Flexible Monitoring System - Console error - - - - - - - - - - - - -
-
-
-

You cannot access this file

-
- -
-
- ERROR: - You can\'t access this file directly! -
-
-
- + + Pandora FMS - The Flexible Monitoring System - Console error + + + + + + + + + + + + +
+
+
+

You cannot access this file

+
+ +
+
+ ERROR: + You can\'t access this file directly! +
+
+
+
+ '); } @@ -93,7 +94,7 @@ foreach ($opt_keys as $key) { $config["auth"][$key] = 0; continue; case "ldap_admin_dn": - case "ldap_admin_pwd": + case "ldap_admin_pwd": $config["auth"][$key] = ""; continue; default: @@ -127,7 +128,8 @@ function process_user_login ($login, $pass) { if ($profile === false && empty ($config["auth"]["create_user_undefined"])) { $config["auth_error"] = "No profile"; //Error message, don't translate return false; //User doesn't have a profile so doesn't have access - } elseif ($profile === false && !empty ($config["auth"]["create_user_undefined"])) { + } + elseif ($profile === false && !empty ($config["auth"]["create_user_undefined"])) { $ret = profile_create_user_profile ($login); //User doesn't have a profile but we are asked to create one if ($ret === false) { $config["auth_error"] = "Profile creation failed"; //Error message, don't translate @@ -164,8 +166,10 @@ function is_user_admin ($user_id) { */ function is_user ($id_user) { $user = get_user_info ($id_user); + if (empty ($user)) return false; + return true; } @@ -182,6 +186,7 @@ function get_user_fullname ($id_user) { //User doesn't exist return ''; } + return (string) $info["fullname"]; } @@ -194,6 +199,7 @@ function get_user_fullname ($id_user) { */ function get_user_email ($id_user) { $info = get_user_info ($id_user); + return (string) $info["email"]; } @@ -209,6 +215,7 @@ function get_user_id ($user) { if (is_array ($user)) /* FIXME: Is this right? */ return $user['id_user']; + return (int) $user; } @@ -234,7 +241,7 @@ function get_user_info ($id_user) { return $ldap_cache[$id_user]; } - + /** * Get all users that are defined in the admin group in LDAP * @@ -245,7 +252,8 @@ function get_user_admins () { if (! empty ($ldap_cache["cached_admins"])) { return $ldap_cache["cached_admins"]; - } else { + } + else { $ldap_cache["cached_admins"] = array (); } @@ -254,12 +262,14 @@ function get_user_admins () { $sr = ldap_search ( $ldap_cache["ds"], $config["auth"]["ldap_admin_group_name"], $search_filter, array ($config["auth"]["ldap_admin_group_attr"])); if (!$sr) { $ldap_cache["error"] .= 'Error searching LDAP server (get_user_admins): ' . ldap_error ($ldap_cache["ds"]); - } else { + } + else { $admins = ldap_get_entries( $ldap_cache["ds"], $sr); for( $x = 0; $x < $admins[0][$config["auth"]["ldap_admin_group_attr"]]['count']; $x++) { if ($config["auth"]["ldap_admin_group_type"] != 'posixgroup') { $ldap_cache["cached_admins"][] = stripdn ($admins[0][$config["auth"]["ldap_admin_group_attr"]][$x]); - } else { + } + else { $ldap_cache["cached_admins"][] = $admins[0][$config["auth"]["ldap_admin_group_attr"]][$x]; } } @@ -305,17 +315,20 @@ function ldap_search_user ($login) { if (!$sr) { $ldap_cache["error"] .= 'Error searching LDAP server: ' . ldap_error ($ldap_cache["ds"]); - } else { + } + else { $info = @ldap_get_entries ($ldap_cache["ds"], $sr ); if ( $info['count'] != 1 ) { $ldap_cache["error"] .= 'Invalid user'; - } else { + } + else { $nick = $info[0]['dn']; } @ldap_free_result ($sr); } @ldap_close ($ldap_cache["ds"]); } + return $nick; } @@ -329,7 +342,7 @@ function ldap_search_user ($login) { */ function ldap_valid_login ($login, $password) { global $ldap_cache, $config; - + if (! function_exists ("ldap_connect")) { die ("Your installation of PHP does not support LDAP"); } @@ -337,7 +350,8 @@ function ldap_valid_login ($login, $password) { $ret = false; if (!empty ($config["auth"]["ldap_port"])) { $ds = @ldap_connect ($config["auth"]["ldap_server"], $config["auth"]["ldap_port"]); //Since this is a separate bind, we don't store it global - } else { + } + else { $ds = @ldap_connect ($config["auth"]["ldap_server"]); //Since this is a separate bind we don't store it global } if ($ds) { @@ -355,15 +369,18 @@ function ldap_valid_login ($login, $password) { if (!$r) { $ldap_cache["error"] .= 'Invalid login'; //$ldap_cache["error"] .= ': incorrect password'; // uncomment for debugging - } else { + } + else { $ret = true; } - } else { + } + else { $ldap_cache["error"] .= 'Invalid login'; //$ldap_cache["error"] .= ': no such user'; } @ldap_close ($ds); - } else { + } + else { $ldap_cache["error"] .= 'Error connecting to LDAP server'; } return $ret; @@ -387,12 +404,14 @@ function ldap_load_user ($login) { if (!$sr) { $ldap_cache["error"] .= 'Error searching LDAP server (load_user): ' . ldap_error( $ldap_cache["ds"] ); - } else { + } + else { $info = @ldap_get_entries ($ldap_cache["ds"], $sr); if ($info['count'] != 1) { $ldap_cache["error"] .= 'Invalid login'; //$ldap_cache["error"] .= ', could not load user'; //Uncomment for debugging - } else { + } + else { $ret = array (); foreach ($config["auth"]["ldap_user_attr"] as $internal_key => $ldap_key) { $ret["last_connect"] = $time; @@ -408,7 +427,8 @@ function ldap_load_user ($login) { @ldap_free_result ($sr); } @ldap_close ( $ldap_cache["ds"] ); - } else { + } + else { $ldap_cache["error"] .= 'Could not connect to LDAP server'; } @@ -540,9 +560,11 @@ function ldap_connect_bind () { if (!empty ($config["auth"]["ldap_port"]) && !is_resource ($ldap_cache["ds"])) { $ldap_cache["ds"] = @ldap_connect ($config["auth"]["ldap_server"], $config["auth"]["ldap_port"]); - } elseif (!is_resource ($ldap_cache["ds"])) { + } + elseif (!is_resource ($ldap_cache["ds"])) { $ldap_cache["ds"] = @ldap_connect ($config["auth"]["ldap_server"]); - } else { + } + else { return true; } @@ -557,10 +579,11 @@ function ldap_connect_bind () { return $ret; } } - + if (!empty ($config["auth"]["ldap_admin_dn"])) { $r = @ldap_bind ($ldap_cache["ds"], $config["auth"]["ldap_admin_dn"], $config["auth"]["ldap_admin_pwd"]); - } else { + } + else { $r = @ldap_bind ($ldap_cache["ds"]); } @@ -569,10 +592,10 @@ function ldap_connect_bind () { return $ret; } return true; - } else { + } + else { $ldap_cache["error"] .= 'Error connecting to LDAP server'; return $ret; } } - -?> +?> \ No newline at end of file diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 95f2286426..27bbd1b96e 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -367,22 +367,22 @@ function mysql_escape_string_sql($string) { function mysql_db_get_value_filter ($field, $table, $filter, $where_join = 'AND') { if (! is_array ($filter) || empty ($filter)) return false; - + /* Avoid limit and offset if given */ unset ($filter['limit']); unset ($filter['offset']); - + $sql = sprintf ("SELECT %s FROM %s WHERE %s LIMIT 1", $field, $table, db_format_array_where_clause_sql ($filter, $where_join)); $result = db_get_all_rows_sql ($sql); - + if ($result === false) return false; - + $fieldClean = str_replace('`', '', $field); - + return $result[0][$fieldClean]; } @@ -1046,5 +1046,4 @@ function mysql_db_get_table_count($sql, $search_history_db = false) { return $count; } - ?> \ No newline at end of file diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index de38504df5..b9dc6b00a8 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1897,7 +1897,15 @@ function agents_monitor_critical ($id_agent, $filter="") { $filter = " AND ".$filter; } - return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 1 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente = $id_agent".$filter); + return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) + FROM tagente_estado, tagente, tagente_modulo + WHERE tagente.disabled = 0 + AND tagente_estado.utimestamp != 0 + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente_modulo.disabled = 0 + AND estado = 1 + AND tagente_estado.id_agente = tagente.id_agente + AND tagente.id_agente = $id_agent" . $filter); } // Get warning monitors by using the status code in modules. @@ -1908,7 +1916,15 @@ function agents_monitor_warning ($id_agent, $filter="") { $filter = " AND ".$filter; } - return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 2 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente = $id_agent".$filter); + return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) + FROM tagente_estado, tagente, tagente_modulo + WHERE tagente.disabled = 0 + AND tagente_estado.utimestamp != 0 + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente_modulo.disabled = 0 + AND estado = 2 + AND tagente_estado.id_agente = tagente.id_agente + AND tagente.id_agente = $id_agent" . $filter); } // Get unknown monitors by using the status code in modules. @@ -1918,19 +1934,34 @@ function agents_monitor_unknown ($id_agent, $filter="") { if ($filter) { $filter = " AND ".$filter; } - - return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 3 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente = $id_agent".$filter); + + return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) + FROM tagente_estado, tagente, tagente_modulo + WHERE tagente.disabled = 0 + AND tagente_estado.utimestamp != 0 + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente_modulo.disabled = 0 + AND estado = 3 + AND tagente_estado.id_agente = tagente.id_agente + AND tagente.id_agente = $id_agent" . $filter); } // Get ok monitors by using the status code in modules. - function agents_monitor_ok ($id_agent, $filter="") { if ($filter) { $filter = " AND ".$filter; } - return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente = $id_agent".$filter); + return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) + FROM tagente_estado, tagente, tagente_modulo + WHERE tagente.disabled = 0 + AND tagente_estado.utimestamp != 0 + AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente_modulo.disabled = 0 + AND estado = 0 + AND tagente_estado.id_agente = tagente.id_agente + AND tagente.id_agente = $id_agent" . $filter); } /** diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 6ab41272f3..9ffdc9c2f6 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1523,7 +1523,8 @@ function alerts_validate_alert_compound ($id_alert_compound) { $group_id, $agent_id, 1, $config["id_user"], "alert_manual_validation", 1, $alert["id"], $id); - } elseif ($result === false) { + } + elseif ($result === false) { return false; } } diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index e74ac37f2c..b18f388720 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -90,16 +90,18 @@ if (!function_exists ('mime_content_type')) { 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet' ); - + $ext = strtolower (array_pop (explode ('.', $filename))); if (array_key_exists ($ext, $mime_types)) { return $mime_types[$ext]; - } elseif (function_exists ('finfo_open')) { + } + elseif (function_exists ('finfo_open')) { $finfo = finfo_open (FILEINFO_MIME); $mimetype = finfo_file ($finfo, $filename); finfo_close ($finfo); return $mimetype; - } else { + } + else { $temp = exec ("file ".$filename); if (isset($temp) && $temp != '') return $temp; diff --git a/pandora_console/include/functions_incidents.php b/pandora_console/include/functions_incidents.php index 3d41c0ea08..b077d1df13 100644 --- a/pandora_console/include/functions_incidents.php +++ b/pandora_console/include/functions_incidents.php @@ -296,16 +296,19 @@ function incidents_delete_note ($id_note, $transact = true) { $errors++; } } - + if ($transact == true && $errors > 0) { db_process_sql_rollback (); return false; - } elseif ($transact == true) { + } + elseif ($transact == true) { db_process_sql_commit (); return true; - } elseif ($errors > 0) { + } + elseif ($errors > 0) { return false; - } else { + } + else { return true; } } diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 1f3998331d..0b088e5cc7 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -74,7 +74,8 @@ function messages_create_group ($usuario_origen, $dest_group, $subject, $mensaje if (! array_key_exists ($usuario_origen, $users)) { //Users don't exist in the system return false; - } elseif (empty ($group_users)) { + } + elseif (empty ($group_users)) { //There are no users in the group, so it hasn't failed although it hasn't done anything. return true; } @@ -90,7 +91,7 @@ function messages_create_group ($usuario_origen, $dest_group, $subject, $mensaje } } } - + foreach ($group_user as $user) { $return = messages_create_message ($usuario_origen, get_user_id ($user), $subject, $mensaje); if ($return === false) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index fae632ec17..fe6a696468 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1023,7 +1023,8 @@ function reporting_get_group_stats ($id_group = 0) { function reporting_event_reporting ($id_group, $period, $date = 0, $return = false) { if (empty ($date)) { $date = get_system_time (); - } elseif (!is_numeric ($date)) { + } + elseif (!is_numeric ($date)) { $date = strtotime ($date); } @@ -1049,7 +1050,7 @@ function reporting_event_reporting ($id_group, $period, $date = 0, $return = fal $data[3] = $event["timestamp"]; array_push ($table->data, $data); } - + if (empty ($return)) html_print_table ($table); return $table; @@ -1066,7 +1067,7 @@ function reporting_event_reporting ($id_group, $period, $date = 0, $return = fal function reporting_get_fired_alerts_table ($alerts_fired) { $agents = array (); global $config; - + require_once ($config["homedir"].'/include/functions_alerts.php'); foreach (array_keys ($alerts_fired) as $id_alert) { @@ -1238,7 +1239,7 @@ function reporting_alert_reporting_module ($id_agent_module, $period = 0, $date FROM talert_template_modules AS t1 INNER JOIN talert_templates AS t2 ON t1.id_alert_template = t2.id WHERE id_agent_module = ' . $id_agent_module); - + if ($alerts === false) { $alerts = array(); } @@ -1311,7 +1312,7 @@ function reporting_alert_reporting ($id_group, $period = 0, $date = 0, $return = if (sizeof ($alerts) > 0) $fired_percentage = round (sizeof ($alerts_fired) / sizeof ($alerts) * 100, 2); $not_fired_percentage = 100 - $fired_percentage; - + $data = array (); $data[__('Alerts fired')] = $fired_percentage; $data[__('Alerts not fired')] = $not_fired_percentage; @@ -1319,13 +1320,14 @@ function reporting_alert_reporting ($id_group, $period = 0, $date = 0, $return = $output .= pie3d_graph(false, $data, 280, 150, __("other"), "", $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size']); - + $output .= ''.__('Alerts fired').': '.sizeof ($alerts_fired).'
'; $output .= ''.__('Total alerts monitored').': '.sizeof ($alerts).'
'; - + if (! sizeof ($alerts_fired)) { if (!$return) echo $output; + return $output; } $table = reporting_get_fired_alerts_table ($alerts_fired); @@ -1340,6 +1342,7 @@ function reporting_alert_reporting ($id_group, $period = 0, $date = 0, $return = if (!$return) echo $output; + return $output; } @@ -1359,7 +1362,7 @@ function reporting_alert_reporting ($id_group, $period = 0, $date = 0, $return = function reporting_monitor_health ($id_group, $period = 0, $date = 0, $return = false) { if (empty ($date)) //If date is 0, false or empty $date = get_system_time (); - + $datelimit = $date - $period; $output = ''; @@ -1435,13 +1438,15 @@ function reporting_get_monitors_down_table ($monitors_down) { $data[0] = ''; if ($monitor['descripcion'] != '') { $data[1] = $monitor['descripcion']; - } else { + } + else { $data[1] = $monitor['nombre']; } array_push ($table->data, $data); } } } + return $table; } @@ -1457,11 +1462,13 @@ function reporting_get_monitors_down_table ($monitors_down) { */ function reporting_print_group_reporting ($id_group, $return = false) { $agents = agents_get_group_agents ($id_group, false, "none"); - $output = ''.__('Agents in group').': '.count ($agents).'
'; + $output = '' . + sprintf(__('Agents in group: %s'), count($agents)) . + '
'; if ($return === false) echo $output; - + return $output; } @@ -1532,6 +1539,7 @@ function reporting_get_agent_alerts_table ($id_agent, $period = 0, $date = 0) { array_push ($table->data, $data); } + return $table; } @@ -1612,11 +1620,12 @@ function reporting_get_agent_modules_table ($id_agent, $period = 0, $date = 0) { */ function reporting_get_agent_detailed ($id_agent, $period = 0, $date = 0, $return = false) { $output = ''; - $n_a_string = __('N/A').'(*)'; + $n_a_string = __('N/A(*)'); /* Show modules in agent */ $output .= '
'; - $output .= '

'.__('Agent').' - '.agents_get_name ($id_agent).'

'; + $output .= '

' . + __('Agent') . ' - ' . agents_get_name ($id_agent) . '

'; $output .= '

'.__('Modules').'

'; $table_modules = reporting_get_agent_modules_table ($id_agent, $period, $date); $table_modules->width = '99%'; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d697540ec8..5c23105183 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1953,7 +1953,7 @@ function ui_get_full_url ($url = '') { if ( $port != null ) { $fullurl .= ":".$port; } - + if ($url === '') { $url = $_SERVER['REQUEST_URI']; } diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 51be9df620..aeaed33baf 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -455,7 +455,7 @@ foreach ($agents as $agent) { $data = array (); - $data[0] = ''; + $data[0] = ''; $data[0] .= ''; $data[0] .= ui_print_agent_name($agent["id_agente"], true, 60, 'font-size:6.5pt !important;', true); $data[0] .= ''; @@ -469,12 +469,6 @@ foreach ($agents as $agent) { } $data[0] .= '
'; - /*if (check_acl ($config['id_user'], $agent["id_grupo"], "AW")) { - $data[0] .= ''; - $data[0] .= html_print_image ("images/setup.png", true, array ("border" => 0, "width" => 16)); - $data[0] .= ' '; - }*/ - $data[1] = ui_print_truncate_text($agent["description"], 'description', false, true, true, '[…]', 'font-size: 6.5pt'); $data[2] = ui_print_os_icon ($agent["id_os"], false, true); @@ -494,15 +488,15 @@ foreach ($agents as $agent) { $data[5] .= $agent_info["modules"]; if ($agent_info["monitor_alertsfired"] > 0) - $data[5] .= ' : '.$agent_info["monitor_alertsfired"].''; + $data[5] .= ' : ' . $agent_info["monitor_alertsfired"] . ''; if ($agent_info["monitor_critical"] > 0) - $data[5] .= ' : '.$agent_info["monitor_critical"].''; + $data[5] .= ' : ' . $agent_info["monitor_critical"] . ''; if ($agent_info["monitor_warning"] > 0) - $data[5] .= ' : '.$agent_info["monitor_warning"].''; + $data[5] .= ' : ' . $agent_info["monitor_warning"] . ''; if ($agent_info["monitor_unknown"] > 0) - $data[5] .= ' : '.$agent_info["monitor_unknown"].''; + $data[5] .= ' : ' . $agent_info["monitor_unknown"] . ''; if ($agent_info["monitor_normal"] > 0) - $data[5] .= ' : '.$agent_info["monitor_normal"].''; + $data[5] .= ' : ' . $agent_info["monitor_normal"] . ''; $data[5] .= ''; $data[6] = $agent_info["status_img"]; @@ -519,7 +513,7 @@ foreach ($agents as $agent) { $data[8] = ''.$time.''; else $data[8] = $time; - + // This old code was returning "never" on agents without modules, BAD !! // And does not print outdated agents in red. WRONG !!!! // $data[7] = ui_print_timestamp ($agent_info["last_contact"], true); @@ -534,8 +528,8 @@ foreach ($agents as $agent) { $data[9] = "". html_print_image("images/application_edit.png", true, array("align" => 'middle', "title" => __('Edit remote config'))).""; } - - $data[10] = "'.html_print_image('images/cross.png', true, array("border" => '0')) .""; } @@ -550,19 +544,6 @@ if (!empty ($table->data)) { } else { echo '
'.__('There are no defined agents').'
'; } - -/* Godmode controls SHOULD NOT BE HERE - -if (check_acl ($config['id_user'], 0, "LM") || check_acl ($config['id_user'], 0, "AW") - || check_acl ($config['id_user'], 0, "PM") || check_acl ($config['id_user'], 0, "DM") - || check_acl ($config['id_user'], 0, "UM")) { - - echo '
'; - html_print_input_hidden ('new_agent', 1); - html_print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"'); - echo '
'; -} -*/ ?> + \ No newline at end of file diff --git a/pandora_console/operation/agentes/sla_view.php b/pandora_console/operation/agentes/sla_view.php index b5ab128cb8..37e2fa8c81 100644 --- a/pandora_console/operation/agentes/sla_view.php +++ b/pandora_console/operation/agentes/sla_view.php @@ -71,31 +71,35 @@ foreach ($modules as $module_id => $module) { if ($loc < $offset) { $loc++; continue; //Skip offset - } elseif ($loc >= $offset + $config["block_size"]) { + } + elseif ($loc >= $offset + $config["block_size"]) { continue; } $data = array (); $data[0] = ui_print_moduletype_icon ($module["id_tipo_modulo"], true); $data[1] = ui_print_string_substr ($module["nombre"], 25, true); - if ($module["min_critical"] != 0){ + if ($module["min_critical"] != 0) { $sla_min = $module["min_critical"]; $data[2] = format_numeric (reporting_get_agentmodule_sla ($module_id, $config["sla_period"], $sla_min)); $data[2] = 100 - $data[2]. "%"; - } else { + } + else { $data[2] = format_numeric (reporting_get_agentmodule_sla ($module_id, $config["sla_period"], 1)).'%'; } //TODO: Make this work for all new status $status = modules_get_agentmodule_status ($module_id); - if ($status == 1){ + if ($status == 1) { $data[3] = html_print_image ("images/pixel_red.png", true, array ("width" => 40, "height" => 18, "title" => __('Module Down'))); - } else { + } + else { $data[3] = html_print_image ("images/pixel_green.png", true, array ("width" => 40, "height" => 18, "title" => __('Module Up'))); } - + if ($module["module_interval"] > 0) { $data[4] = $module["module_interval"]; - } else { + } + else { $data[4] = $interval; } array_push ($table->data, $data); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index ddaaa2e41c..0270ed68e8 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -439,7 +439,7 @@ $(document).ready( function() { $("input[name=allbox]").change (function() { $("input[name='eventid[]']").attr('checked', $(this).attr('checked')); }); - + $('#select_validate').change (function() { $option = $('#select_validate').val(); diff --git a/pandora_console/operation/incidents/incident_detail.php b/pandora_console/operation/incidents/incident_detail.php index 8e0052fc5a..865247463a 100755 --- a/pandora_console/operation/incidents/incident_detail.php +++ b/pandora_console/operation/incidents/incident_detail.php @@ -226,7 +226,8 @@ if (isset ($id_inc)) { //If $id_inc is set (when $_GET["id"] is set, not $_GET[" ui_print_page_header (__('Incident details'). ' #'.$id_inc, "images/book_edit.png", false, "", false, ""); echo '
'; echo ''; -} else { +} +else { ui_print_page_header (__('Create incident'), "images/book_edit.png", false, "", false, ""); echo ''; } diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index c686172d67..5e19a247f5 100644 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -132,14 +132,15 @@ if (is_ajax ()) ui_print_timestamp ($agent["ultimo_contacto"]); echo " / "; - + if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") { echo __('Never'); - } else { + } + else { echo $agent["ultimo_contacto_remoto"]; } echo ''; - + // Timezone Offset if ($agent['timezone_offset'] != 0) { echo ''.__('Timezone Offset'). ''; diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 2a94c03232..466def9728 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -39,7 +39,8 @@ if ((!check_acl ($config["id_user"], users_get_groups ($id), "UM")) AND ($id != //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; }