0) { $effective_end = $xport_array['meta']['end']; if ($effective_end == $xport_array['meta']['start'] && $xport_array['meta']['rows'] > 0) { $effective_end = $xport_array['meta']['start'] + $xport_array['meta']['step'] * ($xport_array['meta']['rows'] - 1); } $xport_array['meta']['expected_rows'] = (int) floor( ($effective_end - $xport_array['meta']['start']) / $xport_array['meta']['step'] ) + 1; $xport_array['meta']['missing_rows'] = max(0, $xport_array['meta']['expected_rows'] - $xport_array['meta']['rows']); } // Make graph title the suggested file name; strip characters that could break // out of the quoted filename in the Content-Disposition header (CR/LF header // injection, quote escaping). $filename = str_replace(["\r", "\n", '"', '\\'], '', (string) $xport_array['meta']['title_cache']) . '.csv'; header('Content-type: application/vnd.ms-excel; charset=UTF-8'); header('Content-Transfer-Encoding: binary'); if (cacti_is_https()) { header('Pragma: cache'); } header('Cache-Control: max-age=15'); if (!isrv('stdout')) { header('Content-Disposition: attachment; filename="' . $filename . '"'); } if (isrv('format') && gnrv('format') == 'table') { $html = true; } else { $html = false; } if (isset($xport_array['meta']['start'])) { if (!$html) { $output = cacti_csv_cell(__('Title')) . ',' . cacti_csv_cell($xport_array['meta']['title_cache']) . "\n"; $output .= cacti_csv_cell(__('Vertical Label')) . ',' . cacti_csv_cell($xport_array['meta']['vertical_label']) . "\n"; $output .= cacti_csv_cell(__('Start Date')) . ',' . cacti_csv_cell(date('Y-m-d H:i:s', $xport_array['meta']['start'])) . "\n"; $output .= cacti_csv_cell(__('End Date')) . ',' . cacti_csv_cell(date('Y-m-d H:i:s', ($xport_array['meta']['end'] == $xport_array['meta']['start']) ? $xport_array['meta']['start'] + $xport_array['meta']['step'] * ($xport_array['meta']['rows'] - 1) : $xport_array['meta']['end'])) . "\n"; $output .= cacti_csv_cell(__('Step')) . ',' . cacti_csv_cell($xport_array['meta']['step']) . "\n"; $output .= cacti_csv_cell(__('Total Rows')) . ',' . cacti_csv_cell($xport_array['meta']['rows']) . "\n"; $output .= cacti_csv_cell(__('Expected Rows')) . ',' . cacti_csv_cell($xport_array['meta']['expected_rows']) . "\n"; $output .= cacti_csv_cell(__('Missing Rows')) . ',' . cacti_csv_cell($xport_array['meta']['missing_rows']) . "\n"; $output .= cacti_csv_cell(__('Graph ID')) . ',' . cacti_csv_cell($xport_array['meta']['local_graph_id']) . "\n"; $output .= cacti_csv_cell(__('Host ID')) . ',' . cacti_csv_cell($xport_array['meta']['host_id']) . "\n"; if (isset($xport_meta['NthPercentile'])) { foreach ($xport_meta['NthPercentile'] as $item) { $output .= cacti_csv_cell(__('Nth Percentile')) . ',' . cacti_csv_cell($item['value']) . ',' . cacti_csv_cell($item['format']) . "\n"; } } if (isset($xport_meta['Summation'])) { foreach ($xport_meta['Summation'] as $item) { $output .= cacti_csv_cell(__('Summation')) . ',' . cacti_csv_cell($item['value']) . ',' . cacti_csv_cell($item['format']) . "\n"; } } $output .= '""' . "\n"; $header = cacti_csv_cell(__('Date')); for ($i = 1; $i <= $xport_array['meta']['columns']; $i++) { $header .= ',' . cacti_csv_cell($xport_array['meta']['legend']['col' . $i]); } $output .= $header . "\n"; if (isset($xport_array['data']) && is_array($xport_array['data'])) { $j = 0; foreach ($xport_array['data'] as $row) { $data = cacti_csv_cell(date('Y-m-d H:i:s', (isset($row['timestamp']) ? $row['timestamp'] : $xport_array['meta']['start'] + $j * $xport_array['meta']['step']))); for ($i = 1; $i <= $xport_array['meta']['columns']; $i++) { $data .= ',' . cacti_csv_cell($row['col' . $i]); } $output .= $data . "\n"; $j++; } // Full UTF-8 Output print "\xEF\xBB\xBF"; print $output; } } else { print "
"; print "
" . __('Summary Details') . "
'; // print the header information print ""; print ""; print ''; print ''; print ''; print ''; print ''; print ""; print ''; print ''; print ''; print ''; print ''; print ""; print ''; print ''; print ''; print ''; print ''; print ""; print ''; print ''; print ''; print ''; print ''; print ""; print ''; print ''; print ''; print ''; print ''; $class = 'even'; $index = 0; if (isset($xport_meta['NthPercentile'])) { foreach ($xport_meta['NthPercentile'] as $index => $item) { if ($class == 'even') { $class = 'odd'; } else { $class = 'even'; } if ($index % 2 == 0) { if ($index > 0) { print ''; } print ""; } print ''; print ''; } if ($index % 2 != 0) { print ''; } } $index = 0; if (isset($xport_meta['Summation'])) { foreach ($xport_meta['Summation'] as $index => $item) { if ($class == 'even') { $class = 'odd'; } else { $class = 'even'; } if ($index % 2 == 0) { if ($index > 0) { print ''; } print ""; } print ''; print ''; } if ($index % 2 != 0) { print ''; } } print '
' . __('Title') . '' . htmle($xport_array['meta']['title_cache']) . '' . __('Vertical Label') . '' . htmle($xport_array['meta']['vertical_label']) . '
' . __('Start Date') . '' . date('Y-m-d H:i:s', $xport_array['meta']['start']) . '' . __('End Date') . '' . date('Y-m-d H:i:s', ($xport_array['meta']['end'] == $xport_array['meta']['start']) ? $xport_array['meta']['start'] + $xport_array['meta']['step'] * ($xport_array['meta']['rows'] - 1) : $xport_array['meta']['end']) . '
' . __('Step') . '' . $xport_array['meta']['step'] . '' . __('Total Rows') . '' . $xport_array['meta']['rows'] . '
' . __('Expected Rows') . '' . $xport_array['meta']['expected_rows'] . '' . __('Missing Rows') . '' . $xport_array['meta']['missing_rows'] . '
' . __('Graph ID') . '' . $xport_array['meta']['local_graph_id'] . '' . __('Host ID') . '' . $xport_array['meta']['host_id'] . '
' . __('Nth Percentile') . ' [ ' . htmle($item['format']) . ' ]' . htmle($item['value']) . '
' . __('Summation') . ' [ ' . htmle($item['format']) . ' ]' . htmle($item['value']) . '
'; print '

'; // end of CSV header information print "
"; print "'; } } } // log the memory usage cacti_log("The Peak Graph XPORT Memory Usage was '" . memory_get_peak_usage() . "'", false, 'WEBUI', POLLER_VERBOSITY_MEDIUM);