mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
2010-09-23 Miguel de Dios <miguel.dedios@artica.es>
* 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
This commit is contained in:
parent
2ab88e69b5
commit
b07a40eade
@ -1,3 +1,8 @@
|
||||
2010-09-23 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* 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 <miguel.dedios@artica.es>
|
||||
|
||||
* operation/events/events.php: fixed the re-include two time the file.
|
||||
|
@ -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 version='1.0' encoding='ISO-8859-1'?>
|
||||
<agent_data description='' group='' os_name='%s' " .
|
||||
" os_version='%s' interval='%d' version='%s' timestamp='%s' agent_name='%s' timezone_offset='%d'>
|
||||
<module>
|
||||
<name><![CDATA[%s]]></name>
|
||||
<description><![CDATA[%s]]></description>
|
||||
<type><![CDATA[%s]]></type>
|
||||
<data><![CDATA[%s]]></data>
|
||||
</module>
|
||||
</agent_data>";
|
||||
|
||||
$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.');
|
||||
|
Loading…
x
Reference in New Issue
Block a user