2015-04-16 10:08:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* LibreNMS
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version. Please see LICENSE.txt at the top level of
|
|
|
|
* the source code distribution for details.
|
|
|
|
*/
|
|
|
|
|
2019-04-11 23:26:42 -05:00
|
|
|
use LibreNMS\Config;
|
2021-04-29 22:42:18 -05:00
|
|
|
use LibreNMS\Util\Debug;
|
2019-04-11 23:26:42 -05:00
|
|
|
|
|
|
|
$init_modules = ['web', 'auth'];
|
2016-11-21 14:12:59 -06:00
|
|
|
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
2015-04-16 10:08:19 +00:00
|
|
|
|
2019-08-05 14:16:05 -05:00
|
|
|
if (! Auth::check()) {
|
2019-04-11 23:26:42 -05:00
|
|
|
exit('Unauthorized');
|
|
|
|
}
|
|
|
|
|
2021-04-29 22:42:18 -05:00
|
|
|
Debug::set(strpos($_SERVER['PATH_INFO'], 'debug'));
|
2018-07-13 17:08:00 -05:00
|
|
|
|
2019-04-11 23:26:42 -05:00
|
|
|
$report = basename($vars['report']);
|
|
|
|
if ($report && file_exists(Config::get('install_dir') . "/includes/html/reports/$report.csv.inc.php")) {
|
2021-04-29 22:42:18 -05:00
|
|
|
if (! Debug::isEnabled()) {
|
2015-04-16 10:08:19 +00:00
|
|
|
header('Content-Type: text/csv');
|
|
|
|
header('Content-Disposition: attachment; filename="' . $report . '-' . date('Ymd') . '.csv"');
|
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2019-04-11 23:26:42 -05:00
|
|
|
$csv = [];
|
|
|
|
require Config::get('install_dir') . "/includes/html/reports/$report.csv.inc.php";
|
2015-04-16 10:08:19 +00:00
|
|
|
foreach ($csv as $line) {
|
|
|
|
echo implode(',', $line) . "\n";
|
|
|
|
}
|
2016-08-18 20:28:22 -05:00
|
|
|
} else {
|
2015-04-16 10:08:19 +00:00
|
|
|
echo "Report not found.\n";
|
|
|
|
}
|