From 027a75a4335248c334d29a30d44c4e4f9394776c Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Fri, 16 Sep 2011 10:22:21 +0000 Subject: [PATCH] 2011-09-16 Juan Manuel Ramon * include/functions_agents.php: Avoid bad syntax sql query in agents_get_modules_data_count() function when an agent doesn't have modules. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4962 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++++++ pandora_console/include/functions_agents.php | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 689afd3a38..c1671a6f98 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2011-09-16 Juan Manuel Ramon + + * include/functions_agents.php: Avoid bad syntax sql query + in agents_get_modules_data_count() function when an agent doesn't + have modules. + 2011-09-16 Juan Manuel Ramon * include/help/en/help_export_server.php diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 8d5eb0a204..68fc86adc6 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1191,14 +1191,16 @@ function agents_get_modules_data_count ($id_agent = 0) { $count["total"] = 0; $query[0] = "SELECT COUNT(*) FROM tagente_datos"; - + foreach ($id_agent as $agent_id) { //Init value $count[$agent_id] = 0; - $modules = array_keys (agents_get_modules ($agent_id)); - foreach ($query as $sql) { + $modules = array_keys (agents_get_modules ($agent_id)); + foreach ($query as $sql) { //Add up each table's data - $count[$agent_id] += (int) db_get_sql ($sql." WHERE id_agente_modulo IN (".implode (",", $modules).")", 0, true); + //Avoid the count over empty array + if (!empty($modules)) + $count[$agent_id] += (int) db_get_sql ($sql." WHERE id_agente_modulo IN (".implode (",", $modules).")", 0, true); } //Add total agent count to total count $count["total"] += $count[$agent_id];