From 81df6e92fb1f0433e6f48fee52c87fd936bd79fe Mon Sep 17 00:00:00 2001 From: vgilc Date: Mon, 14 Jul 2014 06:18:11 +0000 Subject: [PATCH] 2014-07-14 Vanessa Gil * godmode/admin_access_log.php include/functions.php: Added export to csv. * godmode/audit_log_csv.php: Added file. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10339 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 + pandora_console/godmode/admin_access_logs.php | 7 + pandora_console/godmode/audit_log_csv.php | 137 ++++++++++++++++++ pandora_console/include/functions.php | 25 ++++ 4 files changed, 176 insertions(+) create mode 100644 pandora_console/godmode/audit_log_csv.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index bcdc47d5d9..e7675aaca9 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2014-07-14 Vanessa Gil + + * godmode/admin_access_log.php + include/functions.php: Added export to csv. + + * godmode/audit_log_csv.php: Added file. + 2014-07-10 Miguel de Dios * include/functions_api.php: fixed the call "set_update_agent" diff --git a/pandora_console/godmode/admin_access_logs.php b/pandora_console/godmode/admin_access_logs.php index 97576a5c36..592cc3ae2d 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -295,6 +295,13 @@ foreach ($result as $row) { html_print_table ($table); +echo ''; + if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { enterprise_hook('enterpriseAuditFooter'); } diff --git a/pandora_console/godmode/audit_log_csv.php b/pandora_console/godmode/audit_log_csv.php new file mode 100644 index 0000000000..a4b1d1e559 --- /dev/null +++ b/pandora_console/godmode/audit_log_csv.php @@ -0,0 +1,137 @@ += DATE_ADD(NOW(), INTERVAL -' . $filter_hours_old . ' HOUR)'; + break; + case "postgresql": + $filter .= ' AND fecha >= NOW() - INTERVAL \'' . $filter_hours_old . ' HOUR \''; + break; + case "oracle": + $filter .= ' AND fecha >= (SYSTIMESTAMP - INTERVAL \'' . $filter_hours_old . '\' HOUR)'; + break; + } +} + +switch ($config["dbtype"]) { + case "mysql": + $sql = sprintf ("SELECT * + FROM tsesion + %s + ORDER BY fecha DESC", $filter); + break; + case "postgresql": + $sql = sprintf ("SELECT * + FROM tsesion + %s + ORDER BY fecha DESC", $filter); + break; + case "oracle": + $sql = sprintf ("SELECT * + FROM tsesion + %s + ORDER BY fecha DESC", $filter); + $result = oracle_recode_query ($sql, $set); + break; +} + +$result = db_get_all_rows_sql ($sql); + +print_audit_csv ($result); + +?> diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 683c90ccb9..d8c1cbae3d 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2134,4 +2134,29 @@ function get_news($arguments) { return $news; } + +/** + * Print audit data in CSV format. + * + * @param array Audit data. + * + */ +function print_audit_csv ($data) { + global $config; + global $graphic_type; + + $config['ignore_callback'] = true; + while (@ob_end_clean ()); + + header("Content-type: application/octet-stream"); + header("Content-Disposition: attachment; filename=audit_log".date("Y-m-d_His").".csv"); + header("Pragma: no-cache"); + header("Expires: 0"); + + echo __('User') . ';' . __('Action') . ';' . __('Date') . ';' . __('Source ID') . ';'. __('Comments') ."\n"; + foreach ($data as $line) { + echo io_safe_output($line['id_usuario']) . ';' . io_safe_output($line['accion']) . ';' . $line['fecha'] . ';' . $line['ip_origen'] . ';'. io_safe_output($line['descripcion']). "\n"; + } +} + ?>