From 85475bd6cc3ea7c32fbb01287058c4313dfae78e Mon Sep 17 00:00:00 2001 From: Junichi Satoh Date: Thu, 8 Dec 2016 09:35:34 +0900 Subject: [PATCH] Fixed that exported csv file of audit log contains unnecessary data. --- pandora_console/godmode/admin_access_logs.php | 2 +- pandora_console/include/functions.php | 29 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/pandora_console/godmode/admin_access_logs.php b/pandora_console/godmode/admin_access_logs.php index dcbc9b55ee..c3a8c9d0b0 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -299,7 +299,7 @@ html_print_table ($table); echo '
'; echo '' . + '>' . html_print_button (__('Export to CSV '), 'export_csv', false, '', 'class=sub upd', true, false). ''; echo '
'; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 0b0ceb11d7..3f1ebd44f9 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2293,6 +2293,11 @@ function print_audit_csv ($data) { global $config; global $graphic_type; + if (!$data) { + echo __('No data found to export'); + return 0; + } + $config['ignore_callback'] = true; while (@ob_end_clean ()); @@ -2300,20 +2305,20 @@ function print_audit_csv ($data) { header("Content-Disposition: attachment; filename=audit_log".date("Y-m-d_His").".csv"); header("Pragma: no-cache"); header("Expires: 0"); + + // BOM + print pack('C*',0xEF,0xBB,0xBF); - if ($data) { - 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"; - } - } - else { - echo __('No data found to export'); + 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"; } + + exit; } /**