From eda9361c4f636691e4ed28fdd32ca7886ce39319 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Fri, 11 Oct 2013 11:33:07 +0000 Subject: [PATCH] 2013-10-11 Miguel de Dios * include/functions_agents.php, include/functions_graph.php, include/functions_api.php: fixed a pair of bugs of the api calls. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8892 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 ++++ pandora_console/include/functions_agents.php | 2 +- pandora_console/include/functions_api.php | 30 ++++++++++++++------ pandora_console/include/functions_graph.php | 1 + 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 4d30f7b64e..db48400a3f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2013-10-11 Miguel de Dios + + * include/functions_agents.php, include/functions_graph.php, + include/functions_api.php: fixed a pair of bugs of the api calls. + 2013-10-11 Sergio Martin * include/graphs/flot/pandora.flot.js: Fixed strange diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 8f09f13297..a533c9a429 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1711,7 +1711,7 @@ function agents_delete_agent ($id_agents, $disableACL = false) { db_process_delete_temp ("tagente", "id_agente", $id_agent); db_pandora_audit( "Agent management", - "Deleted agent '$agent_name'"); + "Deleted agent '$agent_name'"); /* Break the loop on error */ diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 8435cc5d2b..0ce8158535 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -223,6 +223,8 @@ function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) { function api_get_agent_module_name_last_value($agentName, $moduleName, $other = ';', $returnType) { + global $config; + $idAgent = agents_get_agent_id($agentName); switch ($config["dbtype"]) { case "mysql": @@ -260,7 +262,7 @@ function api_get_agent_module_name_last_value($agentName, $moduleName, $other = } } else { - get_module_last_value($idModuleAgent, null, $other, $returnType); + api_get_module_last_value($idModuleAgent, null, $other, $returnType); } } @@ -918,7 +920,8 @@ function api_get_custom_field_id($t1, $t2, $other, $returnType) { function api_set_delete_agent($id, $thrash1, $thrast2, $thrash3) { $agentName = $id; $idAgent[0] = agents_get_agent_id($agentName); - if (!agents_delete_agent ($idAgent, true)) + + if (($idAgent[0] === 0) || (!agents_delete_agent ($idAgent, true))) returnError('error_delete', 'Error in delete operation.'); else returnData('string', array('type' => 'string', 'data' => __('Correct Delete'))); @@ -4248,6 +4251,7 @@ function api_get_graph_module_data($id, $thrash1, $other, $thrash2) { $start_date = $other['data'][4]; $date = strtotime($start_date); + $homeurl = '../'; $ttl = 1; @@ -4255,20 +4259,28 @@ function api_get_graph_module_data($id, $thrash1, $other, $thrash2) { $config['flash_charts'] = 0; $image = grafico_modulo_sparse ($id, $period, $draw_events, - $width, $height , '',null, + $width, $height , $label, null, $draw_alerts, $avg_only, false, $date, '', 0, 0,true, false, $homeurl, $ttl); - // Extract url of the image from img tag - preg_match("/src='([^']*)'/i",$image, $match); + preg_match("/
/", + $image, $match); - if (empty($match[1])) { - echo "Error getting graph"; + if (!empty($match[0])) { + echo "Error no data"; } else { - header('Content-type: image/png'); - header('Location: ' . $match[1]); + // Extract url of the image from img tag + preg_match("/src='([^']*)'/i", $image, $match); + + if (empty($match[1])) { + echo "Error getting graph"; + } + else { + header('Content-type: image/png'); + header('Location: ' . $match[1]); + } } } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 195fb7a9b4..e265be9ae7 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -695,6 +695,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, global $config; global $graphic_type; + $flash_chart = $config['flash_charts']; enterprise_include_once("include/functions_reporting.php");