Fixed that exported csv file of audit log contains unnecessary data.

This commit is contained in:
Junichi Satoh 2016-12-08 09:35:34 +09:00
parent 14c5ec6b87
commit 85475bd6cc
2 changed files with 18 additions and 13 deletions

View File

@ -299,7 +299,7 @@ html_print_table ($table);
echo '<div style="width: '.$table->width.'" class="action-buttons">'; echo '<div style="width: '.$table->width.'" class="action-buttons">';
echo '<a href="' . echo '<a href="' .
ui_get_full_url(false, false, false, false) . 'index.php?sec=gextensions&sec2=godmode/audit_log_csv&tipo_log='.$tipo_log.'&user_filter='.$user_filter.'&filter_text='.$filter_text.'&filter_hours_old='.$filter_hours_old.'&filter_ip='.$filter_ip.'"'. ui_get_full_url(false, false, false, false) . 'index.php?sec=gextensions&sec2=godmode/audit_log_csv&tipo_log='.$tipo_log.'&user_filter='.$user_filter.'&filter_text='.$filter_text.'&filter_hours_old='.$filter_hours_old.'&filter_ip='.$filter_ip.'"'.
'target="_new">' . '>' .
html_print_button (__('Export to CSV '), 'export_csv', false, '', 'class=sub upd', true, false). '</a>'; html_print_button (__('Export to CSV '), 'export_csv', false, '', 'class=sub upd', true, false). '</a>';
echo '</div>'; echo '</div>';

View File

@ -2293,6 +2293,11 @@ function print_audit_csv ($data) {
global $config; global $config;
global $graphic_type; global $graphic_type;
if (!$data) {
echo __('No data found to export');
return 0;
}
$config['ignore_callback'] = true; $config['ignore_callback'] = true;
while (@ob_end_clean ()); while (@ob_end_clean ());
@ -2301,19 +2306,19 @@ function print_audit_csv ($data) {
header("Pragma: no-cache"); header("Pragma: no-cache");
header("Expires: 0"); header("Expires: 0");
if ($data) { // BOM
echo __('User') . ';' . print pack('C*',0xEF,0xBB,0xBF);
__('Action') . ';' .
__('Date') . ';' . echo __('User') . ';' .
__('Source ID') . ';' . __('Action') . ';' .
__('Comments') ."\n"; __('Date') . ';' .
foreach ($data as $line) { __('Source ID') . ';' .
echo io_safe_output($line['id_usuario']) . ';' . io_safe_output($line['accion']) . ';' . $line['fecha'] . ';' . $line['ip_origen'] . ';'. io_safe_output($line['descripcion']). "\n"; __('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');
} }
exit;
} }
/** /**