From 2574c60623710d8204bc4ee174732ae7baf18999 Mon Sep 17 00:00:00 2001 From: slerena Date: Sun, 24 Aug 2008 23:59:10 +0000 Subject: [PATCH] 2008-08-24 Sancho Lerena * include/functions_db.php: Fixed some warning messages due missing check before several foreachs. * index.php: Disabled development flag to detect config. * operation/agentes/networkmap.php: String too short for names, long IP address was being shortened. * operation/servers/view_server.php, operation/servers/view_server_detail.php godmode/servers/manage_recontask_form.php: Fixed some warnings and added proper message for empty screens. After this commit a beta1 package has been made. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1027 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 17 +++++++++++++++ .../godmode/servers/manage_recontask_form.php | 2 +- pandora_console/include/functions_db.php | 21 ++++++++++++++++++- pandora_console/index.php | 2 +- .../operation/agentes/networkmap.php | 5 +++-- .../operation/servers/view_server.php | 5 +++++ .../operation/servers/view_server_detail.php | 4 +++- 7 files changed, 50 insertions(+), 6 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 18913a9c02..793171c4f4 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,20 @@ +2008-08-24 Sancho Lerena + + * include/functions_db.php: Fixed some warning messages + due missing check before several foreachs. + + * index.php: Disabled development flag to detect config. + + * operation/agentes/networkmap.php: String too short for + names, long IP address was being shortened. + + * operation/servers/view_server.php, + operation/servers/view_server_detail.php + godmode/servers/manage_recontask_form.php: Fixed some warnings + and added proper message for empty screens. + + After this commit a beta1 package has been made. + 2008-08-22 Sancho Lerena * Massive header update. We're now officially on Beta1. diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index 5b7563241e..6bf6c92a4e 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -119,7 +119,7 @@ $table->data[] = array (__('OS'),print_select ($selectbox, "id_os", $id_os,'','' unset ($selectbox); // Group -$sql = "SELECT id_grupo, nombre FROM tgrupo"; +$sql = "SELECT id_grupo, nombre FROM tgrupo WHERE id_grupo > 1"; $result = get_db_all_rows_sql ($sql); foreach ($result as $row) { $selectbox[$row["id_grupo"]] = $row["nombre"]; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index fd7db35d71..cb0555e8c6 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -83,6 +83,10 @@ AND tusuario_perfil.id_usuario = '%s' AND (tusuario_perfil.id_grupo = %d OR tusu $rowdup = get_db_all_rows_sql($query1); $result = 0; + + if (!$rowdup) + return $result; + foreach($rowdup as $row) { // For each profile for this pair of group and user do... switch ($access) { @@ -622,6 +626,8 @@ function get_alert_fires_in_period ($id_agent_module, $period, $date = 0) { function get_alerts_in_group ($id_group) { $alerts = array (); $agents = get_agents_in_group ($id_group); + if (!$agents) + return; foreach ($agents as $agent) { $agent_alerts = get_alerts_in_agent ($agent["id_agente"]); $alerts = array_merge ($alerts, $agent_alerts); @@ -982,6 +988,8 @@ function list_group ($id_user, $show_all = 1){ $mis_grupos = array (); // Define array mis_grupos to put here all groups with Agent Read permission $sql = 'SELECT id_grupo, nombre FROM tgrupo'; $result = get_db_all_rows_sql ($sql); + if (!$result) + return $mis_grupos; foreach ($result as $row) { if (($row["id_grupo"] != 1 || $show_all == 1) && $row["id_grupo"] != 0 && give_acl($id_user,$row["id_grupo"], "AR") == 1) { //Put in an array all the groups the user belongs to @@ -1004,7 +1012,8 @@ function list_group ($id_user, $show_all = 1){ function list_group2 ($id_user) { $mis_grupos = array (); // Define array mis_grupos to put here all groups with Agent Read permission $result = get_db_all_fields_in_table ("tgrupo","id_grupo"); - + if (!$result) + return $mis_grupos; foreach ($result as $row) { if (give_acl ($id_user, $row["id_grupo"], "AR") == 1) { array_push ($mis_grupos, $row["id_grupo"]); //Put in array all the groups the user belongs to @@ -1024,6 +1033,10 @@ function list_group2 ($id_user) { function get_user_groups ($id_user) { $user_groups = array (); $groups = get_db_all_rows_in_table ('tgrupo', 'nombre'); + + if (!$groups) + return $user_groups; + foreach ($groups as $group) { if (! give_acl ($id_user, $group["id_grupo"], "AR")) continue; @@ -1695,6 +1708,7 @@ function get_agent_module_value_sumatory ($id_agent_module, $period, $date = 0) $timestamp_end = 0; $sum = 0; $data_value = 0; + foreach ($datas as $data) { $timestamp_end = $data["utimestamp"]; $elapsed = $timestamp_end - $timestamp_begin; @@ -1782,6 +1796,10 @@ function show_alert_row_mini ($id_combined_alert) { $sql = sprintf("SELECT talerta_agente_modulo.*, tcompound_alert.operation FROM talerta_agente_modulo, tcompound_alert WHERE tcompound_alert.id_aam = talerta_agente_modulo.id_aam AND tcompound_alert.id = %d",$id_combined_alert); $result = get_db_all_rows_sql ($sql); + + if (!$result) + return; + echo ""; echo ""; echo ""; @@ -1793,6 +1811,7 @@ function show_alert_row_mini ($id_combined_alert) { echo ""; echo ""; echo ""; + foreach ($result as $row2) { if ($color == 1) { $tdcolor = "datos"; diff --git a/pandora_console/index.php b/pandora_console/index.php index 8d2bcd7d93..85d2275fcd 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -26,7 +26,7 @@ global $build_version; global $pandora_version; // Set to 1 to do not check for installer or config file (for development!). -$develop_bypass = 1; +$develop_bypass = 0; if ($develop_bypass != 1){ // If no config file, automatically try to install diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index 2a0150a4e9..f030a0f5c8 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -115,8 +115,8 @@ function create_node ($agent, $simple = 0, $font_size = 10) { // Short name $name = strtolower ($agent["nombre"]); - if (strlen ($name) > 12) - $name = substr ($name, 0, 12); + if (strlen ($name) > 16) + $name = substr ($name, 0, 16); if ($simple == 0){ // Set node icon @@ -125,6 +125,7 @@ function create_node ($agent, $simple = 0, $font_size = 10) { } else { $img_node = 'images/networkmap/0.png'; } + $node = $agent['id_agente'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<
".__('Name')."".__('Oper')."".__('MinMax.Al')."".__('Days')."".__('Fired')."
'.$name.'
>, shape="ellipse", URL="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'", diff --git a/pandora_console/operation/servers/view_server.php b/pandora_console/operation/servers/view_server.php index b159b1f307..a895859994 100644 --- a/pandora_console/operation/servers/view_server.php +++ b/pandora_console/operation/servers/view_server.php @@ -60,6 +60,11 @@ $table->head[6] = __('Version'); $table->head[7] = __('Updated at'); $table->data = array (); +if (!$servers){ + echo "
".__('There are no servers configured into the database')."
"; + return; +} + foreach ($servers as $server) { $data = array (); $serverinfo = server_status ($server['id_server']); diff --git a/pandora_console/operation/servers/view_server_detail.php b/pandora_console/operation/servers/view_server_detail.php index cb8e62a971..593c4b3d2f 100644 --- a/pandora_console/operation/servers/view_server_detail.php +++ b/pandora_console/operation/servers/view_server_detail.php @@ -159,7 +159,9 @@ if ($row["recon_server"]) { } echo ""; } else { - echo "This server has no recon tasks assigned"; + echo "
"; + echo __("This server has no recon tasks assigned"); + echo "
"; } }