| 
									
										
										
										
											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; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $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
										 |  |  |     die('Unauthorized'); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 17:08:00 -05:00
										 |  |  | set_debug(strpos($_SERVER['PATH_INFO'], 'debug')); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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")) { | 
					
						
							| 
									
										
										
										
											2015-07-15 22:04:19 +01:00
										 |  |  |     if ($debug === false) { | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |         header('Content-Type: text/csv'); | 
					
						
							|  |  |  |         header('Content-Disposition: attachment; filename="'.$report.'-'.date('Ymd').'.csv"'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-11 23:26:42 -05:00
										 |  |  |     $csv = []; | 
					
						
							|  |  |  |     require Config::get('install_dir') . "/includes/html/reports/$report.csv.inc.php"; | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     foreach ($csv as $line) { | 
					
						
							|  |  |  |         echo implode(',', $line)."\n"; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-08-18 20:28:22 -05:00
										 |  |  | } else { | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     echo "Report not found.\n"; | 
					
						
							| 
									
										
										
										
											2015-04-16 10:08:19 +00:00
										 |  |  | } |