From b07a40eade31a63646b91975eadd4fd0d747549b Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 23 Sep 2010 11:52:07 +0000 Subject: [PATCH] 2010-09-23 Miguel de Dios * include/functions_api.php: added function "set_module_data" for to hook call to create module data across web api. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3283 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 ++++ pandora_console/include/functions_api.php | 34 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b88c2f9d3f..a0c78b7190 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2010-09-23 Miguel de Dios + + * include/functions_api.php: added function "set_module_data" for to hook + call to create module data across web api. + 2010-09-23 Miguel de Dios * operation/events/events.php: fixed the re-include two time the file. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 695a826e4a..eadd6b8aac 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -979,13 +979,47 @@ function set_delete_module($id, $id2, $other, $trash1) { } function set_module_data($id, $thrash2, $other, $trash1) { + global $config; + if ($other['type'] == 'array') { $idAgentModule = $id; $data = $other['data'][0]; $time = $other['data'][1]; if ($time == 'now') $time = time(); + $agentModule = get_db_row_filter('tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + if ($agentModule === false) { + returnError('error_parameter', 'Not found module agent.'); + } + else { + $agent = get_db_row_filter('tagente', array('id_agente' => $agentModule['id_agente'])); + + $xmlTemplate = " + + + + + + + + "; + $xml = sprintf($xmlTemplate, safe_output(get_os_name($agent['id_os'])), + safe_output($agent['os_version']), $agent['intervalo'], + safe_output($agent['agent_version']), date('Y/m/d h:i:s', $time), + safe_output($agent['nombre']), $agent['timezone_offset'], + safe_output($agentModule['nombre']), safe_output($agentModule['descripcion']), get_module_type_name($agentModule['id_tipo_modulo']), $data); + + + if (false === @file_put_contents($config['remote_config'] . '/' . safe_output($agent['nombre']) . '.' . $time . '.data', $xml)) { + returnError('error_file', 'Can save agent data xml.'); + } + else { + returnData('string', array('type' => 'string', 'data' => $xml)); + return; + } + } } else { returnError('error_parameter', 'Error in the parameters.');