2017-05-22 11:24:21 +02:00
|
|
|
<?php
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// NagiosQL
|
2017-10-20 15:00:08 +02:00
|
|
|
//
|
2017-05-22 11:24:21 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
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 : Preprocessing script for scripting files
|
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
|
|
|
//error_reporting(E_ALL);
|
2017-05-22 11:24:21 +02:00
|
|
|
//error_reporting(E_ERROR);
|
|
|
|
//
|
|
|
|
// Security Protection
|
|
|
|
// ===================
|
|
|
|
if (isset($_GET['SETS']) || isset($_POST['SETS'])) {
|
2019-04-17 11:40:50 +02:00
|
|
|
$SETS = '';
|
2017-05-22 11:24:21 +02:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// Timezone settings (>=PHP5.1)
|
|
|
|
// ============================
|
2019-04-17 11:40:50 +02:00
|
|
|
if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
|
|
|
|
@date_default_timezone_set(@date_default_timezone_get());
|
2017-05-22 11:24:21 +02:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// Define common variables
|
|
|
|
// =======================
|
|
|
|
$chkDomainId = 0;
|
2019-04-17 11:40:50 +02:00
|
|
|
$intError = 0;
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
// Define path constants
|
|
|
|
//
|
2019-04-17 11:40:50 +02:00
|
|
|
//define('BASE_PATH', str_replace("functions", "", dirname(__FILE__)));
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
// Read settings file
|
|
|
|
// ==================
|
2019-04-17 11:40:50 +02:00
|
|
|
$preBasePath = str_replace('functions', '', __DIR__);
|
2017-05-22 11:24:21 +02:00
|
|
|
$preIniFile = $preBasePath.'config/settings.php';
|
|
|
|
//
|
|
|
|
// Read file settings
|
|
|
|
// ==================
|
2019-04-17 11:40:50 +02:00
|
|
|
$SETS = parse_ini_file($preIniFile, true);
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
// Include external function/class files - part 1
|
|
|
|
// ==============================================
|
2019-04-17 11:40:50 +02:00
|
|
|
require $preBasePath.'functions/Autoloader.php';
|
|
|
|
functions\Autoloader::register($preBasePath);
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
// Initialize classes - part 1
|
|
|
|
// ===========================
|
2019-04-17 11:40:50 +02:00
|
|
|
$myDBClass = new functions\MysqliDbClass();
|
2017-10-20 15:00:08 +02:00
|
|
|
$myDBClass->arrParams = $SETS['db'];
|
2019-04-17 11:40:50 +02:00
|
|
|
$myDBClass->hasDBConnection();
|
2017-05-22 11:24:21 +02:00
|
|
|
if ($myDBClass->error == true) {
|
2019-04-17 11:40:50 +02:00
|
|
|
$strDBMessage = $myDBClass->strErrorMessage;
|
|
|
|
$booError = $myDBClass->error;
|
2017-05-22 11:24:21 +02:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// Get additional configuration from the table tbl_settings
|
|
|
|
// ========================================================
|
|
|
|
if ($intError == 0) {
|
2019-04-17 11:40:50 +02:00
|
|
|
$strSQL = 'SELECT `category`,`name`,`value` FROM `tbl_settings`';
|
|
|
|
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
|
|
|
|
if ($booReturn == false) {
|
|
|
|
echo str_replace('::', "\n", 'Error while selecting data from database: ' .$myDBClass->strErrorMessage);
|
|
|
|
$intError = 1;
|
|
|
|
} elseif ($intDataCount != 0) {
|
|
|
|
for ($i=0; $i<$intDataCount; $i++) {
|
|
|
|
$SETS[$arrDataLines[$i]['category']][$arrDataLines[$i]['name']] = $arrDataLines[$i]['value'];
|
|
|
|
}
|
|
|
|
}
|
2017-05-22 11:24:21 +02:00
|
|
|
} else {
|
2019-04-17 11:40:50 +02:00
|
|
|
echo "Could not load configuration settings from database - abort\n";
|
|
|
|
exit;
|
2017-05-22 11:24:21 +02:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// Include external function/class files
|
|
|
|
// =====================================
|
2019-04-17 11:40:50 +02:00
|
|
|
include 'translator.php';
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
// Initialize classes
|
|
|
|
// ==================
|
2019-04-17 11:40:50 +02:00
|
|
|
$arrSession = array();
|
|
|
|
$arrSession['SETS'] = $SETS;
|
|
|
|
$myDataClass = new functions\NagDataClass($arrSession);
|
|
|
|
$myConfigClass = new functions\NagConfigClass($arrSession);
|
|
|
|
$myImportClass = new functions\NagImportClass($arrSession);
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
// Propagating the classes themselves
|
|
|
|
// ==================================
|
2019-04-17 11:40:50 +02:00
|
|
|
$myDataClass->myDBClass =& $myDBClass;
|
|
|
|
$myDataClass->myConfigClass =& $myConfigClass;
|
|
|
|
$myConfigClass->myDBClass =& $myDBClass;
|
|
|
|
$myConfigClass->myDataClass =& $myDataClass;
|
|
|
|
$myImportClass->myDataClass =& $myDataClass;
|
|
|
|
$myImportClass->myDBClass =& $myDBClass;
|
|
|
|
$myImportClass->myConfigClass =& $myConfigClass;
|