1<?php 2/////////////////////////////////////////////////////////////////////////////// 3// 4// NagiosQL 5// 6/////////////////////////////////////////////////////////////////////////////// 7// 8// (c) 2005-2020 by Martin Willisegger 9// 10// Project : NagiosQL 11// Component : Download config file 12// Website : https://sourceforge.net/projects/nagiosql/ 13// Version : 3.4.1 14// GIT Repo : https://gitlab.com/wizonet/NagiosQL 15// 16/////////////////////////////////////////////////////////////////////////////// 17// 18// Path settings 19// =================== 20$strPattern = '(admin/[^/]*.php)'; 21$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING)); 22$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING)); 23// 24// Version control 25// =============== 26session_cache_limiter('private_no_expire'); 27// 28// Include preprocessing file 29// ========================== 30$preNoMain = 1; 31$preNoLogin = 1; 32require $preBasePath.'functions/prepend_adm.php'; 33// 34// Process post parameters 35// ======================= 36$chkTable = filter_input(INPUT_GET, 'table', FILTER_SANITIZE_STRING); 37$chkConfig = filter_input(INPUT_GET, 'config', FILTER_SANITIZE_STRING); 38$chkLine = filter_input(INPUT_GET, 'line', FILTER_VALIDATE_INT, array('options' => array('default' => 0))); 39// 40// Header output 41// =============== 42$arrConfig = $myConfigClass->getConfData(); 43if (isset($arrConfig[$chkTable])) { 44 $strFile = $arrConfig[$chkTable]['filename']; 45} else { 46 $strFile = $chkConfig. '.cfg'; 47} 48if ($strFile == '.cfg') { 49 exit; 50} 51header('Content-Disposition: attachment; filename=' .$strFile); 52header('Content-Type: text/plain'); 53// 54// Get data 55// ======== 56if ($chkLine == 0) { 57 $myConfigClass->createConfig($chkTable, 1); 58} else { 59 $myConfigClass->createConfigSingle($chkTable, $chkLine, 1); 60} 61$myDataClass->writeLog(translate('Download'). ' ' .$strFile); 62