nagiosql/admin/download.php

62 lines
1.9 KiB
PHP
Raw Permalink Normal View History

2017-05-22 11:24:21 +02:00
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
2019-04-17 11:40:50 +02:00
// (c) 2005-2018 by Martin Willisegger
2017-05-22 11:24:21 +02:00
//
// Project : NagiosQL
// Component : Download config file
2019-04-17 11:40:50 +02:00
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
2017-05-22 11:24:21 +02:00
//
///////////////////////////////////////////////////////////////////////////////
//
2019-04-17 11:40:50 +02:00
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
2017-05-22 11:24:21 +02:00
// Version control
// ===============
session_cache_limiter('private_no_expire');
//
// Include preprocessing file
// ==========================
$preNoMain = 1;
$preNoLogin = 1;
2019-04-17 11:40:50 +02:00
require $preBasePath.'functions/prepend_adm.php';
2017-05-22 11:24:21 +02:00
//
// Process post parameters
// =======================
2019-04-17 11:40:50 +02:00
$chkTable = filter_input(INPUT_GET, 'table', FILTER_SANITIZE_STRING);
$chkConfig = filter_input(INPUT_GET, 'config', FILTER_SANITIZE_STRING);
$chkLine = filter_input(INPUT_GET, 'line', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
2017-05-22 11:24:21 +02:00
//
// Header output
// ===============
2019-04-17 11:40:50 +02:00
$arrConfig = $myConfigClass->getConfData();
if (isset($arrConfig[$chkTable])) {
$strFile = $arrConfig[$chkTable]['filename'];
} else {
$strFile = $chkConfig. '.cfg';
}
if ($strFile == '.cfg') {
exit;
2017-05-22 11:24:21 +02:00
}
2019-04-17 11:40:50 +02:00
header('Content-Disposition: attachment; filename=' .$strFile);
header('Content-Type: text/plain');
2017-05-22 11:24:21 +02:00
//
// Get data
// ========
if ($chkLine == 0) {
2019-04-17 11:40:50 +02:00
$myConfigClass->createConfig($chkTable, 1);
2017-05-22 11:24:21 +02:00
} else {
2019-04-17 11:40:50 +02:00
$myConfigClass->createConfigSingle($chkTable, $chkLine, 1);
2017-05-22 11:24:21 +02:00
}
2019-04-17 11:40:50 +02:00
$myDataClass->writeLog(translate('Download'). ' ' .$strFile);