From 3fe5a883e785bab3e30e453bd6495df7dbe03eb8 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 3 Nov 2009 18:01:07 +0000 Subject: [PATCH] 2009-11-03 Miguel de Dios * godmode/alerts/alert_list.php: fix notice alert php describe in the tracker of sourceforge. * godmode/alerts/alert_compounds.php: fix the SQL query bug in PHP when load this page without agent in Pandora. Fixes: 2891215 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2075 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 ++++++ .../godmode/alerts/alert_compounds.php | 25 ++++++++++++------- pandora_console/godmode/alerts/alert_list.php | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1996735ae9..a3436cd337 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2009-11-03 Miguel de Dios + * godmode/alerts/alert_list.php: fix notice alert php describe in the + tracker of sourceforge. + * godmode/alerts/alert_compounds.php: fix the SQL query bug in PHP when + load this page without agent in Pandora. + Fixes: 2891215 + 2009-11-03 Miguel de Dios * godmode/agentes/module_manager_editor_plugin.php: fix the size of field "Plugin parameters". diff --git a/pandora_console/godmode/alerts/alert_compounds.php b/pandora_console/godmode/alerts/alert_compounds.php index 1fedd3e045..62767e1737 100644 --- a/pandora_console/godmode/alerts/alert_compounds.php +++ b/pandora_console/godmode/alerts/alert_compounds.php @@ -121,10 +121,14 @@ if ($search != '') $search, $search); if ($id_agent) $agents = array ($id_agent => $id_agent); -$sql = sprintf ('SELECT COUNT(*) FROM talert_compound - WHERE id_agent in (%s)%s', - implode (',', array_keys ($agents)), $where); -$total = (int) get_db_sql ($sql); + +$total = 0; +if (count($agents) > 0) { + $sql = sprintf ('SELECT COUNT(*) FROM talert_compound + WHERE id_agent in (%s)%s', + implode (',', array_keys ($agents)), $where); + $total = (int) get_db_sql ($sql); +} pagination ($total, $url); $table->id = 'alert_list'; @@ -144,11 +148,14 @@ $table->head[1] = __('Name'); $table->head[2] = __('Agent'); $table->head[3] = __('Delete'); -$sql = sprintf ('SELECT id FROM talert_compound - WHERE id_agent in (%s)%s LIMIT %d OFFSET %d', - implode (',', array_keys ($agents)), $where, - $config['block_size'], get_parameter ('offset')); -$id_alerts = get_db_all_rows_sql ($sql); +$id_alerts = false; +if (count($agents)) { + $sql = sprintf ('SELECT id FROM talert_compound + WHERE id_agent in (%s)%s LIMIT %d OFFSET %d', + implode (',', array_keys ($agents)), $where, + $config['block_size'], get_parameter ('offset')); + $id_alerts = get_db_all_rows_sql ($sql); +} if ($id_alerts === false) $id_alerts = array (); diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 547be4db80..5f3702c199 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -271,13 +271,13 @@ if ($id_agente) { $simple_alerts = get_agent_alerts_simple (array_keys ($agents)); } else { $total = 0; + $where = ''; if (!empty ($agents)) { $sql = sprintf ('SELECT COUNT(*) FROM talert_template_modules WHERE id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN (%s))', implode (',', array_keys ($agents))); - $where = ''; if (get_parameter('search',0)) { if ($priority != -1 ) $where .= " AND priority = " . $priority;