New upstream version 3.5.0

This commit is contained in:
geos_one
2025-08-08 11:12:01 +02:00
parent 8948a800bb
commit 8e3d35fd6e
153 changed files with 33544 additions and 22227 deletions

View File

@@ -1,47 +1,49 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Administration overview
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2022 by Martin Willisegger
Project : NagiosQL
Component : Administration overview
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var string $setFileVersion from prepend_adm.php -> Application version string
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 7;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 7;
$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
require $preBasePath. 'functions/prepend_adm.php';
//
// Include content
// ===============
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Administration'));
$conttp->parse('header');
$conttp->show('header');
$conttp->setVariable('DESC', translate('Functions to administrate NagiosQL V3'));
$conttp->parse('main');
$conttp->show('main');
//
// Include Footer
// ==============
/*
Include Footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,92 +1,101 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Alarming overview
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Alarming overview
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var int $chkDomainId from prepend_adm.php
* @var string $setFileVersion from prepend_adm.php
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 3;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 3;
$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
//
// Include content
// ===============
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Alarming'));
$conttp->setVariable('DESC', translate('To define contact data, contact templates and contact groups and time '
. 'periods.'));
. 'periods.'));
$conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable('INACTIVE', translate('Inactive'));
//
// Include statistical data
// ========================
// Get read access groups
$strAccess = $myVisClass->getAccessGroups('read');
/*
Include statistical data
*/
/* Get read access groups */
$strAccess = $myVisClass->getAccessGroups('read');
$intGroupId14 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=14');
$intGroupId15 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=15');
$intGroupId16 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=16');
$intGroupId17 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=17');
if ($myVisClass->checkAccountGroup($intGroupId14, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intGroupId14, 'read') === 0) {
$conttp->setVariable('NAME', translate('Contact data'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contact` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contact` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intGroupId15, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intGroupId15, 'read') === 0) {
$conttp->setVariable('NAME', translate('Contact groups'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contactgroup` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contactgroup` '
. "WHERE active='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE active='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intGroupId16, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intGroupId16, 'read') === 0) {
$conttp->setVariable('NAME', translate('Time periods'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_timeperiod` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_timeperiod` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intGroupId17, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intGroupId17, 'read') === 0) {
$conttp->setVariable('NAME', translate('Contact templates'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contacttemplate` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contacttemplate` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
$conttp->parse('statistics');
$conttp->parse('main');
$conttp->show('main');
//
// Include Footer
// ==============
/*
Include Footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,117 +1,136 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : File editor cgi.cfg
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Cgi configuration file editor
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\NagConfigClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $prePageKey from prepend_adm.php -> Menu group id
* @var string $chkTaFileText from prepend_content.php -> Text area
* @var array $arrDescription from fieldvars.php -> Translated common strings
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 29;
$preContent = 'admin/nagioscfg.htm.tpl';
$preAccess = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 29;
$preContent = 'admin/nagioscfg.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$intRemoveTmp = 0;
$strConfig = '';
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Get configuration set ID
// ========================
$intMethod = 0;
$strConfig = '';
$strErrorMessage = '';
$strInfoMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Get configuration set ID
*/
$intMethod = 0;
$strMethod = '';
$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$intConfigId = (int)$arrConfigSet[0];
if ($myConfigClass->getConfigValues($intConfigId, 'method', $strMethod) === 0) {
$intMethod = (int)$strMethod;
}
$myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strBaseDir);
$strConfigfile = str_replace('//', '/', $strBaseDir. '/cgi.cfg');
$strLocalBackup = str_replace('//', '/', $strBaseDir. '/cgi.cfg_old_').date('YmdHis');
//
// Convert Windows to UNIX
// =======================
$strConfigfile = str_replace('//', '/', $strBaseDir . '/cgi.cfg');
$strLocalBackup = str_replace('//', '/', $strBaseDir . '/cgi.cfg_old_') . date('YmdHis');
/*
Convert Windows LF to UNIX LF
*/
$chkTaFileText = str_replace("\r\n", "\n", $chkTaFileText);
//
// Process data
// ============
if (($chkTaFileText != '') && ($arrConfigSet[0] != 0)) {
if ($intMethod == 1) {
/*
Process data
*/
if (($chkTaFileText !== '') && ($arrConfigSet[0] !== 0)) {
if ($intMethod === 1) {
if (file_exists($strBaseDir) && (is_writable($strBaseDir) && is_writable($strConfigfile))) {
// Backup config file
/* Backup config file */
$intReturn = $myConfigClass->moveFile('nagiosbasic', 'cgi.cfg', $intConfigId);
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
// Write configuration
/* Write configuration */
$resFile = fopen($strConfigfile, 'wb');
fwrite($resFile, $chkTaFileText);
fclose($resFile);
$myVisClass->processMessage('<span style="color:green">' .translate('Configuration file successfully '
. 'written!'). '</span>', $strInfoMessage);
$myDataClass->writeLog(translate('Configuration successfully written:'). ' ' .$strConfigfile);
$myVisClass->processMessage('<span style="color:green">' . translate('Configuration file successfully '
. 'written!') . '</span>', $strInfoMessage);
$myDataClass->writeLog(translate('Configuration successfully written:') . ' ' . $strConfigfile);
} else {
$myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the '
. 'permissions)!'), $strErrorMessage);
$myDataClass->writeLog(translate('Configuration write failed:'). ' ' .$strConfigfile);
. 'permissions)!'), $strErrorMessage);
$myDataClass->writeLog(translate('Configuration write failed:') . ' ' . $strConfigfile);
}
} elseif (($intMethod == 2) || ($intMethod == 3)) {
// Backup config file
} elseif (($intMethod === 2) || ($intMethod === 3)) {
/* Backup config file */
$intReturn1 = $myConfigClass->moveFile('nagiosbasic', 'cgi.cfg', $intConfigId);
if ($intReturn1 == 1) {
if ($intReturn1 === 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
// Write file to temporary
/* Write file to temporary */
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_cgi');
$resFile = fopen($strFileName, 'wb');
fwrite($resFile, $chkTaFileText);
fclose($resFile);
// Copy configuration to remoty system
/* Copy configuration to remoty system */
$intReturn2 = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName, 1);
if ($intReturn2 == 0) {
$myVisClass->processMessage('<span style="color:green">' .translate('Configuration file successfully '
. 'written!'). '</span>', $strInfoMessage);
$myDataClass->writeLog(translate('Configuration successfully written:'). ' ' .$strConfigfile);
unlink($strFileName);
if ($intReturn2 === 0) {
$myVisClass->processMessage('<span style="color:green">' . translate('Configuration file successfully '
. 'written!') . '</span>', $strInfoMessage);
$myDataClass->writeLog(translate('Configuration successfully written:') . ' ' . $strConfigfile);
} else {
$myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the permissions '
. 'on remote system)!'), $strErrorMessage);
$myDataClass->writeLog(translate('Configuration write failed (remote):'). ' ' .$strConfigfile);
unlink($strFileName);
. 'on remote system)!'), $strErrorMessage);
$myDataClass->writeLog(translate('Configuration write failed (remote):') . ' ' . $strConfigfile);
}
unlink($strFileName);
}
} elseif ($arrConfigSet[0] == 0) {
$myVisClass->processMessage(translate('There are no nagios configuration files in common domain, please select a '.
} elseif ($arrConfigSet[0] === 0) {
$myVisClass->processMessage(translate('There are no nagios configuration files in common domain, please select a ' .
'valid domain to edit this files!'), $strErrorMessage);
}
//
// Include content
// ===============
/*
Include content
*/
$conttp->setVariable('TITLE', translate('CGI configuration file'));
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url']. 'admin.php');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF'));
$conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url'] . 'admin.php');
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
}
//
// Open configuration
// ==================
if ($intMethod == 1) {
/*
Open configuration
*/
if ($intMethod === 1) {
if (file_exists($strConfigfile) && is_readable($strConfigfile)) {
$resFile = fopen($strConfigfile, 'rb');
if ($resFile) {
@@ -122,13 +141,13 @@ if ($intMethod == 1) {
} else {
$myVisClass->processMessage(translate('Cannot open the data file (check the permissions)!'), $strErrorMessage);
}
} elseif (($intMethod == 2) || ($intMethod == 3)) {
// Write file to temporary
} elseif (($intMethod === 2) || ($intMethod === 3)) {
/* Write file to temporary */
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_cgi');
// Copy configuration from remoty system
/* Copy configuration from remoty system */
$myConfigClass->strErrorMessage = '';
$intReturn = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName, 0);
if ($intReturn == 0) {
$intReturn = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName);
if ($intReturn === 0) {
$resFile = fopen($strFileName, 'rb');
if (is_resource($resFile)) {
while (!feof($resFile)) {
@@ -140,27 +159,27 @@ if ($intMethod == 1) {
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
$myDataClass->writeLog(translate('Configuration read failed (remote):'). ' ' .$strErrorMessage);
$myDataClass->writeLog(translate('Configuration read failed (remote):') . ' ' . $strErrorMessage);
if (file_exists($strFileName)) {
unlink($strFileName);
}
}
}
$conttp->setVariable('DAT_NAGIOS_CONFIG', $strConfig);
if ($strErrorMessage != '') {
if ($strErrorMessage !== '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('naginsert');
$conttp->show('naginsert');
//
// Process footer
// ==============
/*
Process footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,68 +1,115 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Command definitions
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Check command definitions
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkTfValue1 from prepend_content.php -> Command name
* @var string $chkTfSpValue1 from prepend_content.php -> Command definition
* @var int $chkSelValue1 from prepend_content.php -> Command type
* @var string $chkTaArg1Info from prepend_content.php -> Command argument 1 information
* @var string $chkTaArg2Info from prepend_content.php -> Command argument 2 information
* @var string $chkTaArg3Info from prepend_content.php -> Command argument 3 information
* @var string $chkTaArg4Info from prepend_content.php -> Command argument 4 information
* @var string $chkTaArg5Info from prepend_content.php -> Command argument 5 information
* @var string $chkTaArg6Info from prepend_content.php -> Command argument 6 information
* @var string $chkTaArg7Info from prepend_content.php -> Command argument 7 information
* @var string $chkTaArg8Info from prepend_content.php -> Command argument 8 information
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 18;
$preContent = 'admin/checkcommands.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 18;
$preContent = 'admin/checkcommands.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'checkcommand';
$preTableName = 'tbl_command';
$preKeyField = 'command_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `command_line`='$chkTfValue2', "
. "`command_type`=$chkSelValue1, $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
$preTableName = 'tbl_command';
$preKeyField = 'command_name';
$preAccess = 1;
$preFieldvars = 1;
$intDataWarning = 0;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `command_line`='$chkTfSpValue1', "
. "`command_type`=$chkSelValue1, $preSQLCommon1, `arg1_info`='$chkTaArg1Info', "
. "`arg2_info`='$chkTaArg2Info', `arg3_info`='$chkTaArg3Info', `arg4_info`='$chkTaArg4Info', "
. "`arg5_info`='$chkTaArg5Info', `arg6_info`='$chkTaArg6Info', `arg7_info`='$chkTaArg7Info', "
. "`arg8_info`='$chkTaArg8Info'";
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
if ($intWriteAccessId === 0) {
if (($chkTfValue1 !== '') && ($chkTfSpValue1 !== '')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New command inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New command inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Command modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Command modified:') . ' ' . $chkTfValue1);
}
}
} else {
@@ -76,36 +123,33 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
// Do not show modified time list
/*
Singe data form
*/
$intNoTime = 0;
if ($chkModus === 'add') {
/* Do not show modified time list */
$intNoTime = 1;
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
@@ -114,52 +158,56 @@ if ($chkModus == 'add') {
$conttp->setVariable('NO_TYPE', translate('unclassified'));
$conttp->setVariable('CHECK_TYPE', translate('check command'));
$conttp->setVariable('MISC_TYPE', translate('misc command'));
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
// Insert command type
if ($arrModifyData['command_type'] == 1) {
/* Insert command type */
if ((int)$arrModifyData['command_type'] === 1) {
$conttp->setVariable('CHECK_TYPE_SELECTED', 'selected');
}
if ($arrModifyData['command_type'] == 2) {
if ((int)$arrModifyData['command_type'] === 2) {
$conttp->setVariable('MISC_TYPE_SELECTED', 'selected');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Command definitions'));
$mastertp->setVariable('FIELD_1', translate('Command name'));
$mastertp->setVariable('FIELD_2', translate('Command line'));
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' "
. "OR `command_line` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process search string */
$strSearchWhere = '';
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%' "
. "OR `command_line` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `command_line` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -168,19 +216,19 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `id`, `$preKeyField`, `command_line`, `register`, `active`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
. "AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL = "SELECT `id`, `$preKeyField`, `command_line`, `register`, `active`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
. "AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'command_line', 40);
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -190,7 +238,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,59 +1,62 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Command line visualization
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Command line visualization
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
/**
* Class and variable includes
* @var MysqliDbClass $myDBClass
* /
* /*
* 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));
//
// Define common variables
// =======================
$preNoMain = 1;
//
// Include preprocessing file
// ==========================
require $preBasePath. 'functions/prepend_adm.php';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$preNoMain = 1;
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
$strCommandLine = '&nbsp;';
$intCount = 0;
//
// Get database values
// ===================
if (isset($_GET['cname']) && ($_GET['cname'] != '')) {
$strResult = $myDBClass->getFieldData("SELECT command_line FROM tbl_command WHERE id='".
filter_var($_GET['cname'], FILTER_SANITIZE_NUMBER_INT)."'");
if (($strResult != false) && ($strResult != '')) {
$intCount = 0;
/*
Get database values
*/
if (isset($_GET['cname']) && ($_GET['cname'] !== '')) {
$strResult = $myDBClass->getFieldData("SELECT command_line FROM tbl_command WHERE id='" .
filter_var($_GET['cname'], FILTER_SANITIZE_NUMBER_INT) . "'");
if ($strResult !== '') {
$strCommandLine = $strResult;
$intCount = substr_count($strCommandLine, 'ARG');
if (substr_count($strCommandLine, 'ARG8') != 0) {
if (substr_count($strCommandLine, 'ARG8') !== 0) {
$intCount = 8;
} elseif (substr_count($strCommandLine, 'ARG7') != 0) {
} elseif (substr_count($strCommandLine, 'ARG7') !== 0) {
$intCount = 7;
} elseif (substr_count($strCommandLine, 'ARG6') != 0) {
} elseif (substr_count($strCommandLine, 'ARG6') !== 0) {
$intCount = 6;
} elseif (substr_count($strCommandLine, 'ARG5') != 0) {
} elseif (substr_count($strCommandLine, 'ARG5') !== 0) {
$intCount = 5;
} elseif (substr_count($strCommandLine, 'ARG4') != 0) {
} elseif (substr_count($strCommandLine, 'ARG4') !== 0) {
$intCount = 4;
} elseif (substr_count($strCommandLine, 'ARG3') != 0) {
} elseif (substr_count($strCommandLine, 'ARG3') !== 0) {
$intCount = 3;
} elseif (substr_count($strCommandLine, 'ARG2') != 0) {
} elseif (substr_count($strCommandLine, 'ARG2') !== 0) {
$intCount = 2;
} elseif (substr_count($strCommandLine, 'ARG1') != 0) {
} elseif (substr_count($strCommandLine, 'ARG1') !== 0) {
$intCount = 1;
} else {
$intCount = 0;
@@ -61,30 +64,31 @@ if (isset($_GET['cname']) && ($_GET['cname'] != '')) {
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Commandline</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
background-color: #EDF5FF;
margin: 3px;
border: none;
}
-->
</style>
</head>
<body>
<?php echo $strCommandLine; ?>
<script type="text/javascript" language="javascript">
<!--
parent.argcount = <?php echo $intCount; ?>;
//-->
</script>
</body>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Commandline</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
background-color: #EDF5FF;
margin: 3px;
border: none;
}
-->
</style>
</head>
<body>
<?php echo $strCommandLine; ?>
<script type="text/javascript" language="javascript">
<!--
parent.argcount = <?php echo $intCount; ?>;
//-->
</script>
</body>
</html>

View File

@@ -1,65 +1,74 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Commands overview
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Commands overview
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var int $chkDomainId from prepend_adm.php
* @var string $setFileVersion from prepend_adm.php
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 4;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 4;
$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
//
// Include content
// ===============
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Check commands'));
$conttp->setVariable('DESC', translate('To define check and misc commands, notification commands and special '
. 'commands.'));
. 'commands.'));
$conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable('INACTIVE', translate('Inactive'));
//
// Include statistical data
// ========================
// Get read access groups
$strAccess = $myVisClass->getAccessGroups('read');
/*
Include statistical data
*/
/* Get read access groups */
$strAccess = $myVisClass->getAccessGroups('read');
$intGroupId = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=18');
if ($myVisClass->checkAccountGroup($intGroupId, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intGroupId, 'read') === 0) {
$conttp->setVariable('NAME', translate('Check commands'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_command` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_command` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
$conttp->parse('statistics');
$conttp->parse('main');
$conttp->show('main');
//
// Include Footer
// ==============
/*
Include Footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,47 +1,101 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin configuration target administration
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Admin configuration target administration
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var int $chkActive from prepend_adm.php -> Active checkbox
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $chkTfValue1 from prepend_content.php -> Configuration target name
* @var string $chkTfValue2 from prepend_content.php -> Configuration target description
* @var string $chkTfValue4 from prepend_content.php -> Server name
* @var string $chkTfValue5 from prepend_content.php -> User name
* @var string $chkTfValue6 from prepend_content.php -> Password
* @var string $chkTfValue7 from prepend_content.php -> ssh key file path
* @var string $chkTfValue8 from prepend_content.php -> Base directory
* @var string $chkTfValue9 from prepend_content.php -> Host configuration directory
* @var string $chkTfValue10 from prepend_content.php -> Service configuration directory
* @var string $chkTfValue11 from prepend_content.php -> Backup directory
* @var string $chkTfValue12 from prepend_content.php -> Host backup directory
* @var string $chkTfValue13 from prepend_content.php -> Service backup directory
* @var string $chkTfValue14 from prepend_content.php -> Nagios base directory
* @var string $chkTfValue15 from prepend_content.php -> Import directory
* @var string $chkTfValue16 from prepend_content.php -> Picture directory
* @var string $chkTfValue17 from prepend_content.php -> Command file
* @var string $chkTfValue18 from prepend_content.php -> Binary file
* @var string $chkTfValue19 from prepend_content.php -> Nagios PID file
* @var string $chkTfValue20 from prepend_content.php -> Nagios configuration file
* @var string $chkTfValue21 from prepend_content.php -> CGI configuration file
* @var string $chkTfValue22 from prepend_content.php -> Ressource file
* @var string $chkTfValue23 from prepend_content.php -> ssh port
* @var int $chkSelValue1 from prepend_content.php -> Configuration access method (file based, ssh, ftp)
* @var int $chkSelValue2 from prepend_content.php -> Nagios version
* @var int $chkChbValue1 from prepend_content.php -> Use secure ftp
* @var int $chkSelAccGr from prepend_content.php -> Access group selector
*/
$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));
//
// Define common variables
// =======================
$prePageId = 36;
$preContent = 'admin/configtargets.htm.tpl';
$preListTpl = 'admin/datalist_common.htm.tpl';
$preTableName = 'tbl_configtarget';
$preKeyField = 'target';
$preAccess = 1;
$preFieldvars = 1;
$intIsError = 0;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 36;
$preContent = 'admin/configtargets.htm.tpl';
$preListTpl = 'admin/datalist_common.htm.tpl';
$preTableName = 'tbl_configtarget';
$preKeyField = 'target';
$preAccess = 1;
$preFieldvars = 1;
$intIsError = 0;
$strPathMessage = '';
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Process path values (add slashes)
// =================================
$chkTfValue8 = $myVisClass->addSlash($chkTfValue8);
$chkTfValue9 = $myVisClass->addSlash($chkTfValue9);
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Process path values (add slashes)
*/
$chkTfValue8 = $myVisClass->addSlash($chkTfValue8);
$chkTfValue9 = $myVisClass->addSlash($chkTfValue9);
$chkTfValue10 = $myVisClass->addSlash($chkTfValue10);
$chkTfValue11 = $myVisClass->addSlash($chkTfValue11);
$chkTfValue12 = $myVisClass->addSlash($chkTfValue12);
@@ -49,22 +103,28 @@ $chkTfValue13 = $myVisClass->addSlash($chkTfValue13);
$chkTfValue14 = $myVisClass->addSlash($chkTfValue14);
$chkTfValue15 = $myVisClass->addSlash($chkTfValue15);
$chkTfValue16 = $myVisClass->addSlash($chkTfValue16);
//
// Check if the permissions and other parameters
// =============================================
if (($chkModus == 'modify' || $chkModus == 'insert') && $chkDataId != 0) {
if ($chkSelValue1 == 1) {
$arrPaths = array($chkTfValue8,$chkTfValue9,$chkTfValue10,$chkTfValue11,$chkTfValue12,$chkTfValue13);
/*
Check Port Value
*/
if ((int)$chkTfValue23 === 0) {
$chkTfValue23 = 22;
}
/*
Check the permissions and other parameters
*/
if (($chkModus === 'modify' || $chkModus === 'insert') && $chkDataId !== 0) {
if ($chkSelValue1 === 1) {
$arrPaths = array($chkTfValue8, $chkTfValue9, $chkTfValue10, $chkTfValue11, $chkTfValue12, $chkTfValue13);
foreach ($arrPaths as $elem) {
if ($myConfigClass->isDirWriteable($elem) == 1) {
$myVisClass->processMessage($elem. ' ' .translate('is not writeable'), $strPathMessage);
if ($myConfigClass->isDirWriteable($elem) === 1) {
$myVisClass->processMessage($elem . ' ' . translate('is not writeable'), $strPathMessage);
$intIsError = 1;
}
}
// Nagios base configuration files
/* Nagios base configuration files */
if (!is_writable($chkTfValue20)) {
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios config file'). ' ' .$chkTfValue20
. ' ' .translate('is not writeable')), $strPathMessage);
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios config file') . ' ' . $chkTfValue20
. ' ' . translate('is not writeable')), $strPathMessage);
$intIsError = 1;
} else {
$intCheck = 0;
@@ -72,79 +132,79 @@ if (($chkModus == 'modify' || $chkModus == 'insert') && $chkDataId != 0) {
$resFile = fopen($chkTfValue20, 'rb');
while (!feof($resFile)) {
$strLine = trim(fgets($resFile));
if ((substr_count($strLine, 'cfg_dir') != 0) || (substr_count($strLine, 'cfg_file') != 0)) {
if ((substr_count($strLine, 'cfg_dir') !== 0) || (substr_count($strLine, 'cfg_file') !== 0)) {
$intCheck = 1;
}
}
fclose($resFile);
}
if ($intCheck == 0) {
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios config file'). ' ' .
$chkTfValue20. ' ' .translate('is not a valid configuration file!')), $strPathMessage);
if ($intCheck === 0) {
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios config file') . ' ' .
$chkTfValue20 . ' ' . translate('is not a valid configuration file!')), $strPathMessage);
$intIsError = 1;
}
}
if (!is_writable($chkTfValue14)) {
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios base directory'). ' ' .
$chkTfValue14. ' ' .translate('is not writeable')), $strPathMessage);
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios base directory') . ' ' .
$chkTfValue14 . ' ' . translate('is not writeable')), $strPathMessage);
$intIsError = 1;
}
if (!is_writable($chkTfValue21)) {
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios cgi config file'). ' ' .
$chkTfValue21. ' ' .translate('is not writeable')), $strPathMessage);
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios cgi config file') . ' ' .
$chkTfValue21 . ' ' . translate('is not writeable')), $strPathMessage);
$intIsError = 1;
}
if (!is_readable($chkTfValue22)) {
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios resource config file'). ' ' .
$chkTfValue22. ' ' .translate('is not readable')), $strPathMessage);
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios resource config file') . ' ' .
$chkTfValue22 . ' ' . translate('is not readable')), $strPathMessage);
$intIsError = 1;
}
}
// Check SSH Method
if (($chkSelValue1 == 3) && !function_exists('ssh2_connect')) {
/* Check SSH Method */
if (($chkSelValue1 === 3) && !function_exists('ssh2_connect')) {
$myVisClass->processMessage(translate('SSH module not loaded!'), $strPathMessage);
$intIsError = 1;
}
// Check FTP Method
if (($chkSelValue1 == 2) && !function_exists('ftp_connect')) {
/* Check FTP Method */
if (($chkSelValue1 === 2) && !function_exists('ftp_connect')) {
$myVisClass->processMessage(translate('FTP module not loaded!'), $strPathMessage);
$intIsError = 1;
}
if ($intIsError == 1) {
$chkModus = 'add';
if ($intIsError === 1) {
$chkModus = 'add';
$chkSelModify = 'errormodify';
}
}
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `server`='$chkTfValue4', "
. "`method`='$chkSelValue1', `user`='$chkTfValue5', `password`='$chkTfValue6', "
. "`ssh_key_path`='$chkTfValue7', `ftp_secure`=$chkChbValue1, `basedir`='$chkTfValue8', "
. "`hostconfig`='$chkTfValue9', `serviceconfig`='$chkTfValue10', `backupdir`='$chkTfValue11', "
. "`hostbackup`='$chkTfValue12', `servicebackup`='$chkTfValue13', `nagiosbasedir`='$chkTfValue14', "
. "`importdir`='$chkTfValue15', `picturedir`='$chkTfValue16', `commandfile`='$chkTfValue17', "
. "`binaryfile`='$chkTfValue18', `pidfile`='$chkTfValue19', `conffile`='$chkTfValue20', "
. "`cgifile`='$chkTfValue21', `resourcefile`='$chkTfValue22',`version`=$chkSelValue2, "
. "`access_group`=$chkSelAccGr, `active`='$chkActive',`last_modified`=NOW()";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. "`port`='$chkTfValue23', `method`='$chkSelValue1', `user`='$chkTfValue5', `password`='$chkTfValue6', "
. "`ssh_key_path`='$chkTfValue7', `ftp_secure`=$chkChbValue1, `basedir`='$chkTfValue8', "
. "`hostconfig`='$chkTfValue9', `serviceconfig`='$chkTfValue10', `backupdir`='$chkTfValue11', "
. "`hostbackup`='$chkTfValue12', `servicebackup`='$chkTfValue13', `nagiosbasedir`='$chkTfValue14', "
. "`importdir`='$chkTfValue15', `picturedir`='$chkTfValue16', `commandfile`='$chkTfValue17', "
. "`binaryfile`='$chkTfValue18', `pidfile`='$chkTfValue19', `conffile`='$chkTfValue20', "
. "`cgifile`='$chkTfValue21', `resourcefile`='$chkTfValue22',`version`=$chkSelValue2, "
. "`access_group`=$chkSelAccGr, `active`='$chkActive',`last_modified`=NOW()";
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($chkTfValue4 != '') || ($chkDataId == 0))) {
if ($intWriteAccessId === 0) {
if (($chkTfValue1 !== '') && ($chkTfValue2 !== '') && (($chkTfValue4 !== '') || ($chkDataId === 0))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New Domain inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New Domain inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Domain modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Domain modified:') . ' ' . $chkTfValue1);
}
}
} else {
@@ -158,77 +218,73 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Single view
// ===========
if ($chkModus == 'add') {
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/*
Single view
*/
if ($chkModus === 'add') {
/* Process acces group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
$conttp->setVariable('TITLE', translate('Configuration domain administration'));
if ($intIsError == 1) {
$conttp->setVariable('PATHMESSAGE', '<h2 style="padding-bottom:5px;">' .translate('Warning, at least one ' .
'error occured, please check!'). '</h2>' .$strPathMessage);
if ($intIsError === 1) {
$conttp->setVariable('PATHMESSAGE', '<h2 style="padding-bottom:5px;">' . translate('Warning, at least one ' .
'error occured, please check!') . '</h2>' . $strPathMessage);
}
$conttp->setVariable('CLASS_NAME_1', 'elementHide');
$conttp->setVariable('CLASS_NAME_2', 'elementHide');
$conttp->setVariable('CLASS_NAME_3', 'elementHide');
$conttp->setVariable('FILL_ALLFIELDS', translate('Please fill in all fields marked with an *'));
$conttp->setVariable('FILL_ILLEGALCHARS', translate('The following field contains illegal characters:'));
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Process data
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, 0, '');
// Connection method
if ($arrModifyData['method'] == 1) {
/* Connection method */
if ((int)$arrModifyData['method'] === 1) {
$conttp->setVariable('FILE_SELECTED', 'selected');
}
if ($arrModifyData['method'] == 2) {
if ((int)$arrModifyData['method'] === 2) {
$conttp->setVariable('FTP_SELECTED', 'selected');
$conttp->setVariable('CLASS_NAME_1', 'elementShow');
$conttp->setVariable('CLASS_NAME_2', 'elementHide');
$conttp->setVariable('CLASS_NAME_3', 'elementShow');
}
if ($arrModifyData['method'] == 3) {
if ((int)$arrModifyData['method'] === 3) {
$conttp->setVariable('SFTP_SELECTED', 'selected');
$conttp->setVariable('CLASS_NAME_1', 'elementShow');
$conttp->setVariable('CLASS_NAME_2', 'elementShow');
$conttp->setVariable('CLASS_NAME_3', 'elementHide');
}
if ($arrModifyData['ftp_secure'] == 1) {
if ((int)$arrModifyData['ftp_secure'] === 1) {
$conttp->setVariable('FTPS_CHECKED', 'checked');
}
// Nagios version
$conttp->setVariable('VER_SELECTED_' .$arrModifyData['version'], 'selected');
// Domain localhost cant' be renamed
if ($arrModifyData[$preKeyField] == 'localhost') {
/* Nagios version */
$conttp->setVariable('VER_SELECTED_' . $arrModifyData['version'], 'selected');
/* Domain localhost can't be renamed */
if ($arrModifyData[$preKeyField] === 'localhost') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('LOCKCLASS', 'inputlock');
} elseif ($arrModifyData[$preKeyField] == 'common') {
} elseif ($arrModifyData[$preKeyField] === 'common') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('COMMON_INVISIBLE', 'class="elementHide"');
$conttp->setVariable('LOCKCLASS', 'inputlock');
}
}
if ($chkSelModify == 'errormodify') {
if ($chkSelModify === 'errormodify') {
$conttp->setVariable('DAT_TARGET', $chkTfValue1);
// Domain localhost cant' be renamed
if ($chkTfValue1 == 'localhost') {
/* Domain localhost can't be renamed */
if ($chkTfValue1 === 'localhost') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('LOCKCLASS', 'inputlock');
} elseif ($chkTfValue1 == 'common') {
} elseif ($chkTfValue1 === 'common') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('COMMON_INVISIBLE', 'class="elementHide"');
$conttp->setVariable('LOCKCLASS', 'inputlock');
@@ -237,20 +293,20 @@ if ($chkModus == 'add') {
}
$conttp->setVariable('DAT_ALIAS', $chkTfValue2);
$conttp->setVariable('DAT_SERVER', $chkTfValue4);
// Connection method
if ($chkSelValue1 == 1) {
/* Connection method */
if ($chkSelValue1 === 1) {
$conttp->setVariable('FILE_SELECTED', 'selected');
$conttp->setVariable('CLASS_NAME_1', 'elementHide');
$conttp->setVariable('CLASS_NAME_2', 'elementHide');
$conttp->setVariable('CLASS_NAME_3', 'elementHide');
}
if ($chkSelValue1 == 2) {
if ($chkSelValue1 === 2) {
$conttp->setVariable('FTP_SELECTED', 'selected');
$conttp->setVariable('CLASS_NAME_1', 'elementShow');
$conttp->setVariable('CLASS_NAME_2', 'elementHide');
$conttp->setVariable('CLASS_NAME_3', 'elementShow');
}
if ($chkSelValue1 == 3) {
if ($chkSelValue1 === 3) {
$conttp->setVariable('SFTP_SELECTED', 'selected');
$conttp->setVariable('CLASS_NAME_1', 'elementShow');
$conttp->setVariable('CLASS_NAME_2', 'elementShow');
@@ -258,7 +314,7 @@ if ($chkModus == 'add') {
}
$conttp->setVariable('DAT_USER', $chkTfValue5);
$conttp->setVariable('DAT_SSH_KEY_PATH', $chkTfValue7);
if ($chkChbValue1== 1) {
if ($chkChbValue1 === 1) {
$conttp->setVariable('FTPS_CHECKED', 'checked');
}
$conttp->setVariable('DAT_BASEDIR', $chkTfValue8);
@@ -276,48 +332,50 @@ if ($chkModus == 'add') {
$conttp->setVariable('DAT_CGIFILE', $chkTfValue21);
$conttp->setVariable('DAT_RESOURCEFILE', $chkTfValue22);
$conttp->setVariable('DAT_PICTUREDIR', $chkTfValue16);
// NagiosQL version
if ($chkSelValue2 == 1) {
/* NagiosQL version */
if ($chkSelValue2 === 1) {
$conttp->setVariable('VER_SELECTED_1', 'selected');
}
if ($chkSelValue2 == 2) {
if ($chkSelValue2 === 2) {
$conttp->setVariable('VER_SELECTED_2', 'selected');
}
if ($chkSelValue2 == 3) {
if ($chkSelValue2 === 3) {
$conttp->setVariable('VER_SELECTED_3', 'selected');
}
// Hidden variables
$conttp->setVariable('MODUS', filter_input(INPUT_POST, 'modus', FILTER_SANITIZE_STRING));
/* Hidden variables */
$conttp->setVariable('MODUS', filter_input(INPUT_POST, 'modus'));
$conttp->setVariable('DAT_ID', filter_input(INPUT_POST, 'hidId', FILTER_VALIDATE_INT));
$conttp->setVariable('LIMIT', filter_input(INPUT_POST, 'hidLimit', FILTER_VALIDATE_INT));
// Active
/* Active */
if (filter_input(INPUT_POST, 'chbActive')) {
$conttp->setVariable('ACT_CHECKED', 'checked');
} else {
$conttp->setVariable('ACT_CHECKED', '');
$conttp->setVariable('ACT_CHECKED');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Configuration domain administration'));
$mastertp->setVariable('FIELD_1', translate('Configuration target'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `alias` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)";
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -326,21 +384,21 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `nodelete`, `access_group` "
. "FROM `$preTableName` WHERE `access_group` IN ($strAccess) $strOrderString "
. "LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `nodelete`, `access_group` "
. "FROM `$preTableName` WHERE `access_group` IN ($strAccess) $strOrderString "
. "LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
}
// Show messages
/* Show messages */
$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,95 +1,146 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Contactgroup definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Contactgroup definition
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var int $chkListId from prepend_adm.php -> Actual dataset id (list view)
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkTfValue1 from prepend_content.php -> Contactgroup name
* @var string $chkTfValue2 from prepend_content.php -> Contactgroup description
* @var array $chkMselValue1 from prepend_content.php -> Contact members
* @var array $chkMselValue2 from prepend_content.php -> Contactgroup members
* @var int $intMselValue1 from prepend_content.php -> Contact members multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Contactgroup members multiselect status value
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 15;
$preContent = 'admin/contactgroups.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 15;
$preContent = 'admin/contactgroups.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'contactgroup';
$preTableName = 'tbl_contactgroup';
$preKeyField = 'contactgroup_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$preTableName = 'tbl_contactgroup';
$preKeyField = 'contactgroup_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intRet1 = 0;
$intRet2 = 0;
$intNoTime = 0;
/*
* Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, "
. "`contactgroup_members`=$intMselValue2, $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. "`contactgroup_members`=$intMselValue2, $preSQLCommon1";
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '') && ($intMselValue1 != 0)) {
if ($intWriteAccessId === 0) {
if (($chkTfValue1 !== '') && ($chkTfValue2 !== '') && ($intMselValue1 !== 0)) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New contact group inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New contact group inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Contact group modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Contact group modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkContactgroupToContact',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkContactgroupToContactgroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkContactgroupToContact',
$chkDataId,
@@ -98,10 +149,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkContactgroupToContact', $chkDataId);
}
if ($intRet1 != 0) {
if ($intRet1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkContactgroupToContactgroup',
$chkDataId,
@@ -110,11 +161,11 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkContactgroupToContactgroup', $chkDataId);
}
if ($intRet2 != 0) {
if ($intRet2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2) != 0) {
if (($intRet1 + $intRet2) !== 0) {
$strInfoMessage = '';
}
}
@@ -129,29 +180,26 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
/*
Singe data form
*/
if ($chkModus === 'add') {
$intDataWarning = 0;
$conttp->setVariable('TITLE', translate('Define contact groups (contactgroups.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Process contact member selection fields
if (isset($arrModifyData['members'])) {
$intFieldId = $arrModifyData['members'];
} else {
$intFieldId = 0;
}
/* Process access group selection field */
$intFieldId = $arrModifyData['members'] ?? 0;
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_contact',
'contact_name',
@@ -160,17 +208,13 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Attention, no contacts defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process contactgroup member selection fields
if (isset($arrModifyData['contactgroup_members'])) {
$intFieldId = $arrModifyData['contactgroup_members'];
} else {
$intFieldId = 0;
}
/* Process contactgroup member selection fields */
$intFieldId = $arrModifyData['contactgroup_members'] ?? 0;
$intReturn2 = $myVisClass->parseSelectMulti(
$preTableName,
$preKeyField,
@@ -180,65 +224,65 @@ if ($chkModus == 'add') {
$intFieldId,
$chkListId
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process acces group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
if ($intReturn3 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$strSearchWhere = '';
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define contact groups (contactgroups.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Contact group'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Process filter string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process filter string */
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%' OR `alias` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -247,19 +291,19 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) "
. "$strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) "
. "$strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -269,7 +313,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,127 +1,218 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Contact definitions
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Contact definitions
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $strDomainWhere2 from prepend_adm.php -> Domain selection SQL part without table name
* @var string $chkTfValue1 from prepend_content.php -> Contact name
* @var string $chkTfValue2 from prepend_content.php -> Contact description
* @var string $chkTfValue3 from prepend_content.php -> Email address
* @var string $chkTfValue4 from prepend_content.php -> Pager number
* @var string $chkTfValue5 from prepend_content.php -> Additional address 1
* @var string $chkTfValue6 from prepend_content.php -> Additional address 2
* @var string $chkTfValue7 from prepend_content.php -> Additional address 3
* @var string $chkTfValue8 from prepend_content.php -> Additional address 4
* @var string $chkTfValue9 from prepend_content.php -> Additional address 5
* @var string $chkTfValue10 from prepend_content.php -> Additional address 6
* @var string $chkTfValue11 from prepend_content.php -> Name value if used as contact template
* @var int $chkSelValue1 from prepend_content.php -> Time period hosts
* @var int $chkSelValue2 from prepend_content.php -> Time period services
* @var array $chkMselValue1 from prepend_content.php -> Contact groups
* @var array $chkMselValue2 from prepend_content.php -> Host command
* @var array $chkMselValue3 from prepend_content.php -> Service command
* @var int $intMselValue1 from prepend_content.php -> Contact groups multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Host command multiselect status value
* @var int $intMselValue3 from prepend_content.php -> Service command multiselect status value
* @var string $chkChbGr1a from prepend_content.php -> Host options (d)
* @var string $chkChbGr1b from prepend_content.php -> Host options (u)
* @var string $chkChbGr1c from prepend_content.php -> Host options (r)
* @var string $chkChbGr1d from prepend_content.php -> Host options (f)
* @var string $chkChbGr1e from prepend_content.php -> Host options (s)
* @var string $chkChbGr1f from prepend_content.php -> Host options (n)
* @var string $chkChbGr2a from prepend_content.php -> Service options (w)
* @var string $chkChbGr2b from prepend_content.php -> Service options (u)
* @var string $chkChbGr2c from prepend_content.php -> Service options (c)
* @var string $chkChbGr2d from prepend_content.php -> Service options (r)
* @var string $chkChbGr2e from prepend_content.php -> Service options (f)
* @var string $chkChbGr2f from prepend_content.php -> Service options (s)
* @var string $chkChbGr2g from prepend_content.php -> Service options (n)
* @var int $chkRadValue1 from prepend_content.php -> Contact groups multiselect options
* @var int $chkRadValue2 from prepend_content.php -> Host alarming
* @var int $chkRadValue3 from prepend_content.php -> Service alarming
* @var int $chkRadValue4 from prepend_content.php -> Host command multiselect options
* @var int $chkRadValue5 from prepend_content.php -> Service command multiselect options
* @var int $chkRadValue6 from prepend_content.php -> Retain status information
* @var int $chkRadValue7 from prepend_content.php -> Retain non-status information
* @var int $chkRadValue8 from prepend_content.php -> Can submit command
* @var string $chkTfNullVal1 from prepend_content.php -> Minimum importance
* @var int $intVariables from prepend_content.php -> Form uses variable definitions
* @var int $intTemplates from prepend_content.php -> Form uses template definitions
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 14;
$preContent = 'admin/contacts.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 14;
$preContent = 'admin/contacts.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'contact';
$preTableName = 'tbl_contact';
$preKeyField = 'contact_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Checkbox data processing
// ========================
if (($intVersion == 3) || ($intVersion == 4)) {
$strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f.$chkChbGr2g, 0, -1);
} else {
$strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2g, 0, -1);
$preTableName = 'tbl_contact';
$preKeyField = 'contact_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intRet1 = 0;
$intRet2 = 0;
$intNoTime = 0;
/*
* Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
if (!isset($intMselValue3)) {
$intMselValue3 = 0;
}
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Checkbox data processing
*/
if (($intVersion === 3) || ($intVersion === 4)) {
$strHO = substr($chkChbGr1a . $chkChbGr1b . $chkChbGr1c . $chkChbGr1d . $chkChbGr1e . $chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a . $chkChbGr2b . $chkChbGr2c . $chkChbGr2d . $chkChbGr2e . $chkChbGr2f . $chkChbGr2g, 0, -1);
} else {
$strHO = substr($chkChbGr1a . $chkChbGr1b . $chkChbGr1c . $chkChbGr1d . $chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a . $chkChbGr2b . $chkChbGr2c . $chkChbGr2d . $chkChbGr2e . $chkChbGr2g, 0, -1);
}
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', "
. "`contactgroups`=$intMselValue1, `contactgroups_tploptions`=$chkRadValue1, "
. "`minimum_importance`=$chkTfNullVal1, "
. "`host_notifications_enabled`='$chkRadValue2', `service_notifications_enabled`='$chkRadValue3', "
. "`host_notification_period`='$chkSelValue1', `service_notification_period`='$chkSelValue2', "
. "`host_notification_options`='$strHO', `host_notification_commands_tploptions`=$chkRadValue4, "
. "`service_notification_options`='$strSO', `host_notification_commands`=$intMselValue2, "
. "`service_notification_commands`=$intMselValue3, "
. "`service_notification_commands_tploptions`=$chkRadValue5, `can_submit_commands`='$chkRadValue8', "
. "`retain_status_information`='$chkRadValue6', `retain_nonstatus_information`='$chkRadValue7', "
. "`email`='$chkTfValue3', `pager`='$chkTfValue4', `address1`='$chkTfValue5', `address2`='$chkTfValue6', "
. "`address3`='$chkTfValue7', `address4`='$chkTfValue8', `address5`='$chkTfValue9', "
. "`address6`='$chkTfValue10', `name`='$chkTfValue11', `use_variables`='$intVariables', "
. "`use_template`=$intTemplates, $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. "`contactgroups`=$intMselValue1, `contactgroups_tploptions`=$chkRadValue1, "
. "`minimum_importance`=$chkTfNullVal1, "
. "`host_notifications_enabled`='$chkRadValue2', `service_notifications_enabled`='$chkRadValue3', "
. "`host_notification_period`='$chkSelValue1', `service_notification_period`='$chkSelValue2', "
. "`host_notification_options`='$strHO', `host_notification_commands_tploptions`=$chkRadValue4, "
. "`service_notification_options`='$strSO', `host_notification_commands`=$intMselValue2, "
. "`service_notification_commands`=$intMselValue3, "
. "`service_notification_commands_tploptions`=$chkRadValue5, `can_submit_commands`='$chkRadValue8', "
. "`retain_status_information`='$chkRadValue6', `retain_nonstatus_information`='$chkRadValue7', "
. "`email`='$chkTfValue3', `pager`='$chkTfValue4', `address1`='$chkTfValue5', `address2`='$chkTfValue6', "
. "`address3`='$chkTfValue7', `address4`='$chkTfValue8', `address5`='$chkTfValue9', "
. "`address6`='$chkTfValue10', `name`='$chkTfValue11', `use_variables`='$intVariables', "
. "`use_template`=$intTemplates, $preSQLCommon1";
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if ($chkTfValue1 != '') {
if ($intWriteAccessId === 0) {
if ($chkTfValue1 !== '') {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New contact inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New contact inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Contact modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Contact modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkContactToContactgroup',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkContactToCommandHost',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkContactToCommandService',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
if (isset($intRet3) && ($intRet3 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkContactToContactgroup',
$chkDataId,
@@ -130,10 +221,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkContactToContactgroup', $chkDataId);
}
if ($intRet1 != 0) {
if ($intRet1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkContactToCommandHost',
$chkDataId,
@@ -142,10 +233,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkContactToCommandHost', $chkDataId);
}
if ($intRet2 != 0) {
if ($intRet2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkContactToCommandService',
$chkDataId,
@@ -154,78 +245,74 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkContactToCommandService', $chkDataId);
}
if ($intRet3 != 0) {
if ($intRet3 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
//if (($intRet1 + $intRet2 + $intRet3) != 0) {
//$strInfoMessage = "";
//}
//
// Insert/update templates from session data
// =========================================
if ($chkModus == 'modify') {
$strSQL = "DELETE FROM `tbl_lnkContactToContacttemplate` WHERE `idMaster`=$chkDataId";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
/*
Insert/update templates from session data
*/
if ($chkModus === 'modify') {
$strSQL = "DELETE FROM `tbl_lnkContactToContacttemplate` WHERE `idMaster`=$chkDataId";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(count($_SESSION['templatedefinition']) != 0)) {
(count($_SESSION['templatedefinition']) !== 0)) {
$intSortId = 1;
/** @noinspection ForeachSourceInspection */
foreach ($_SESSION['templatedefinition'] as $elem) {
if ($elem['status'] == 0) {
$strSQL = 'INSERT INTO `tbl_lnkContactToContacttemplate` (`idMaster`,`idSlave`,'
. "`idTable`,`idSort`) VALUES ($chkDataId,".$elem['idSlave']. ', '
. $elem['idTable']. ',' .$intSortId. ')';
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
if ((int)$elem['status'] === 0) {
$strSQL = 'INSERT INTO `tbl_lnkContactToContacttemplate` (`idMaster`,`idSlave`,'
. "`idTable`,`idSort`) VALUES ($chkDataId," . $elem['idSlave'] . ', '
. $elem['idTable'] . ',' . $intSortId . ')';
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
$intSortId++;
}
}
//
// Insert/update variables from session data
// =========================================
if ($chkModus == 'modify') {
$strSQL1 = "SELECT * FROM `tbl_lnkContactToVariabledefinition` WHERE `idMaster`=$chkDataId";
/*
Insert/update variables from session data
*/
if ($chkModus === 'modify') {
$strSQL1 = "SELECT * FROM `tbl_lnkContactToVariabledefinition` WHERE `idMaster`=$chkDataId";
$booReturn = $myDBClass->hasDataArray($strSQL1, $arrData, $intDataCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCount != 0) {
if ($intDataCount !== 0) {
foreach ($arrData as $elem) {
$strSQL = 'DELETE FROM `tbl_variabledefinition` WHERE `id`=' .$elem['idSlave'];
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$strSQL = 'DELETE FROM `tbl_variabledefinition` WHERE `id`=' . $elem['idSlave'];
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
$strSQL = "DELETE FROM `tbl_lnkContactToVariabledefinition` WHERE `idMaster`=$chkDataId";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$strSQL = "DELETE FROM `tbl_lnkContactToVariabledefinition` WHERE `idMaster`=$chkDataId";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
(count($_SESSION['variabledefinition']) != 0)) {
(count($_SESSION['variabledefinition']) !== 0)) {
foreach ($_SESSION['variabledefinition'] as $elem) {
if ($elem['status'] == 0) {
$strSQL = 'INSERT INTO `tbl_variabledefinition` (`name`,`value`,`last_modified`) '
. "VALUES ('".$elem['definition']."','".$elem['range']."',now())";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
if ((int)$elem['status'] === 0) {
$strSQL = 'INSERT INTO `tbl_variabledefinition` (`name`,`value`,`last_modified`) '
. "VALUES ('" . $elem['definition'] . "','" . $elem['range'] . "',now())";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
$strSQL = 'INSERT INTO `tbl_lnkContactToVariabledefinition` (`idMaster`,`idSlave`) '
. "VALUES ($chkDataId,$intInsertId)";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$strSQL = 'INSERT INTO `tbl_lnkContactToVariabledefinition` (`idMaster`,`idSlave`) '
. "VALUES ($chkDataId,$intInsertId)";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
@@ -243,98 +330,92 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
/*
Singe data form
*/
if ($chkModus === 'add') {
$intDataWarning = 0;
$conttp->setVariable('TITLE', translate('Define contacts (contacts.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Process template selection fields (Spezial)
/* Process access group selection field */
$strWhere = '';
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
$strWhere = 'AND `id` <> ' .$arrModifyData['id'];
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
$strWhere = 'AND `id` <> ' . $arrModifyData['id'];
}
$strSQL5 = 'SELECT `id`,`template_name`, `active` '
. "FROM `tbl_contacttemplate` WHERE $strDomainWhere2 ORDER BY `template_name`";
$strSQL5 = 'SELECT `id`,`template_name`, `active`, `config_id` '
. "FROM `tbl_contacttemplate` WHERE $strDomainWhere2 ORDER BY `template_name`";
$booReturn5 = $myDBClass->hasDataArray($strSQL5, $arrDataTpl, $intDataCountTpl);
if ($booReturn5 == false) {
if ($booReturn5 === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCountTpl != 0) {
if ($intDataCountTpl !== 0) {
/** @var array $arrDataTpl */
foreach ($arrDataTpl as $elem) {
if ($elem['active'] == 0) {
if ((int)$elem['active'] === 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$conttp->setVariable('SPECIAL_STYLE', '');
$conttp->setVariable('SPECIAL_STYLE');
}
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['template_name'], ENT_QUOTES, 'UTF-8').
$strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::1');
$conttp->parse('template');
if ((int)$elem['config_id'] === 0) {
$strCommon = ' [common]';
} else {
$strCommon = '';
}
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['template_name'], ENT_QUOTES, 'UTF-8') .
$strActive . $strCommon);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id'] . '::1');
}
$conttp->parse('template');
}
$strSQL6 = 'SELECT `id`, `name`, `active` '
. "FROM `$preTableName` WHERE `name` <> '' $strWhere AND $strDomainWhere ORDER BY `name`";
$strSQL6 = 'SELECT `id`, `name`, `active` '
. "FROM `$preTableName` WHERE `name` <> '' $strWhere AND $strDomainWhere ORDER BY `name`";
$booReturn6 = $myDBClass->hasDataArray($strSQL6, $arrDataHpl, $intDataCount);
if ($booReturn6 == false) {
if ($booReturn6 === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCount != 0) {
if ($intDataCount !== 0) {
/** @var array $arrDataHpl */
foreach ($arrDataHpl as $elem) {
if ($elem['active'] == 0) {
if ((int)$elem['active'] === 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$conttp->setVariable('SPECIAL_STYLE', '');
$conttp->setVariable('SPECIAL_STYLE');
}
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['name'], ENT_QUOTES, 'UTF-8').$strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::2');
$conttp->parse('template');
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['name'], ENT_QUOTES, 'UTF-8') . $strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id'] . '::2');
}
$conttp->parse('template');
}
// Process timeperiod selection fields
if (isset($arrModifyData['host_notification_period'])) {
$intFieldId = $arrModifyData['host_notification_period'];
} else {
$intFieldId = 0;
}
/* Process timeperiod selection fields */
$intFieldId = $arrModifyData['host_notification_period'] ?? 0;
$intReturn1 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'host_time', 1, $intFieldId);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['service_notification_period'])) {
$intFieldId = $arrModifyData['service_notification_period'];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData['service_notification_period'] ?? 0;
$intReturn2 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'service_time', 1, $intFieldId);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Attention, no time periods defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process command selection fields
if (isset($arrModifyData['host_notification_commands'])) {
$intFieldId = $arrModifyData['host_notification_commands'];
} else {
$intFieldId = 0;
}
/* Process command selection fields */
$intFieldId = $arrModifyData['host_notification_commands'] ?? 0;
$intReturn3 = $myVisClass->parseSelectMulti(
'tbl_command',
'command_name',
@@ -343,14 +424,10 @@ if ($chkModus == 'add') {
0,
$intFieldId
);
if ($intReturn3 != 0) {
if ($intReturn3 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['service_notification_commands'])) {
$intFieldId = $arrModifyData['service_notification_commands'];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData['service_notification_commands'] ?? 0;
$intReturn4 = $myVisClass->parseSelectMulti(
'tbl_command',
'command_name',
@@ -359,17 +436,13 @@ if ($chkModus == 'add') {
0,
$intFieldId
);
if ($intReturn4 != 0) {
if ($intReturn4 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Attention, no commands defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process contactgroup selection field
if (isset($arrModifyData['contactgroups'])) {
$intFieldId = $arrModifyData['contactgroups'];
} else {
$intFieldId = 0;
}
/* Process contactgroup selection field */
$intFieldId = $arrModifyData['contactgroups'] ?? 0;
$intReturn5 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
@@ -378,31 +451,27 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn5 != 0) {
if ($intReturn5 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn6 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn6 != 0) {
if ($intReturn6 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$strChbFields = 'HNE,SNE,RSI,CSC,RNS,TPL,SEC,HOC,COG';
$myContentClass->addFormInit($conttp, $strChbFields);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
$conttp->setVariable('DISABLE_SAVE', 'disabled');
}
if ($intVersion == 4) {
if ($intVersion === 4) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1e,chbGr1f');
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2f,chbGr2g');
}
if ($intVersion == 3) {
if ($intVersion === 3) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1e,chbGr1f');
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2f,chbGr2g');
}
@@ -411,69 +480,72 @@ if ($chkModus == 'add') {
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2g');
$conttp->setVariable('VERSION_20_VALUE_MUST', ',tfValue2');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo, $strChbFields);
// Process radio fields
$conttp->setVariable('DAT_HNE' .$arrModifyData['host_notifications_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_SNE' .$arrModifyData['service_notifications_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_RSI' .$arrModifyData['retain_status_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_CSC' .$arrModifyData['can_submit_commands']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_RNS' .$arrModifyData['retain_nonstatus_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_TPL' .$arrModifyData['use_template_tploptions']. '_CHECKED', 'checked');
/* Process radio fields */
$conttp->setVariable('DAT_HNE' . $arrModifyData['host_notifications_enabled'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_SNE' . $arrModifyData['service_notifications_enabled'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_RSI' . $arrModifyData['retain_status_information'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_CSC' . $arrModifyData['can_submit_commands'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_RNS' . $arrModifyData['retain_nonstatus_information'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_TPL' . $arrModifyData['use_template_tploptions'] . '_CHECKED', 'checked');
$conttp->setVariable(
'DAT_SEC' .$arrModifyData['service_notification_commands_tploptions']. '_CHECKED',
'DAT_SEC' . $arrModifyData['service_notification_commands_tploptions'] . '_CHECKED',
'checked'
);
$conttp->setVariable('DAT_HOC' .$arrModifyData['host_notification_commands_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_COG' .$arrModifyData['contactgroups_tploptions']. '_CHECKED', 'checked');
// Process option fields
$conttp->setVariable('DAT_HOC' . $arrModifyData['host_notification_commands_tploptions'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_COG' . $arrModifyData['contactgroups_tploptions'] . '_CHECKED', 'checked');
/* Process option fields */
foreach (explode(',', $arrModifyData['host_notification_options']) as $elem) {
$conttp->setVariable('DAT_HO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_HO' . strtoupper($elem) . '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['service_notification_options']) as $elem) {
$conttp->setVariable('DAT_SO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_SO' . strtoupper($elem) . '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
$strSearchWhere = '';
$intLineCount = 0;
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define contacts (contacts.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Contact name'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' OR "
. "`email` LIKE '%".$strSearchTxt."%' OR `pager` LIKE '%".$strSearchTxt."%' OR "
. "`address1` LIKE '%".$strSearchTxt."%' OR `address2` LIKE '%".$strSearchTxt."%' OR "
. "`address3` LIKE '%".$strSearchTxt."%' OR `address4` LIKE '%".$strSearchTxt."%' OR "
. "`address5` LIKE '%".$strSearchTxt."%' OR `address6` LIKE '%".$strSearchTxt."%' OR "
. "`name` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process search string */
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%' OR `alias` LIKE '%" . $strSearchTxt . "%' OR "
. "`email` LIKE '%" . $strSearchTxt . "%' OR `pager` LIKE '%" . $strSearchTxt . "%' OR "
. "`address1` LIKE '%" . $strSearchTxt . "%' OR `address2` LIKE '%" . $strSearchTxt . "%' OR "
. "`address3` LIKE '%" . $strSearchTxt . "%' OR `address4` LIKE '%" . $strSearchTxt . "%' OR "
. "`address5` LIKE '%" . $strSearchTxt . "%' OR `address6` LIKE '%" . $strSearchTxt . "%' OR "
. "`name` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
}
// Count datasets
$strSQL7 = 'SELECT count(*) AS `number` '
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
/* Count datasets */
$strSQL7 = 'SELECT count(*) AS `number` '
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn7 = $myDBClass->hasSingleDataset($strSQL7, $arrDataLinesCount);
if ($booReturn7 == false) {
if ($booReturn7 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -482,19 +554,19 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL8 = "SELECT `id`, `$preKeyField`, `alias`, `active`, `register`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` "
. "IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL8 = "SELECT `id`, `$preKeyField`, `alias`, `active`, `register`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` "
. "IN ($strAccess) $strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn8 = $myDBClass->hasDataArray($strSQL8, $arrDataLines, $intDataCount);
if ($booReturn8 == false) {
if ($booReturn8 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -504,7 +576,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,127 +1,217 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Contact template definitions
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Contact template definitions
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon2 from prepend_content.php -> Common SQL part 2
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $strDomainWhere2 from prepend_adm.php -> Domain selection SQL part without table name
* @var string $chkTfValue1 from prepend_content.php -> Contact template name
* @var string $chkTfValue2 from prepend_content.php -> Contact template description
* @var string $chkTfValue3 from prepend_content.php -> Email address
* @var string $chkTfValue4 from prepend_content.php -> Pager number
* @var string $chkTfValue5 from prepend_content.php -> Additional address 1
* @var string $chkTfValue6 from prepend_content.php -> Additional address 2
* @var string $chkTfValue7 from prepend_content.php -> Additional address 3
* @var string $chkTfValue8 from prepend_content.php -> Additional address 4
* @var string $chkTfValue9 from prepend_content.php -> Additional address 5
* @var string $chkTfValue10 from prepend_content.php -> Additional address 6
* @var int $chkSelValue1 from prepend_content.php -> Time period hosts
* @var int $chkSelValue2 from prepend_content.php -> Time period services
* @var array $chkMselValue1 from prepend_content.php -> Contact groups
* @var array $chkMselValue2 from prepend_content.php -> Host command
* @var array $chkMselValue3 from prepend_content.php -> Service command
* @var int $intMselValue1 from prepend_content.php -> Contact groups multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Host command multiselect status value
* @var int $intMselValue3 from prepend_content.php -> Service command multiselect status value
* @var string $chkChbGr1a from prepend_content.php -> Host options (d)
* @var string $chkChbGr1b from prepend_content.php -> Host options (u)
* @var string $chkChbGr1c from prepend_content.php -> Host options (r)
* @var string $chkChbGr1d from prepend_content.php -> Host options (f)
* @var string $chkChbGr1e from prepend_content.php -> Host options (s)
* @var string $chkChbGr1f from prepend_content.php -> Host options (n)
* @var string $chkChbGr2a from prepend_content.php -> Service options (w)
* @var string $chkChbGr2b from prepend_content.php -> Service options (u)
* @var string $chkChbGr2c from prepend_content.php -> Service options (c)
* @var string $chkChbGr2d from prepend_content.php -> Service options (r)
* @var string $chkChbGr2e from prepend_content.php -> Service options (f)
* @var string $chkChbGr2f from prepend_content.php -> Service options (s)
* @var string $chkChbGr2g from prepend_content.php -> Service options (n)
* @var int $chkRadValue1 from prepend_content.php -> Contact groups multiselect options
* @var int $chkRadValue2 from prepend_content.php -> Host alarming
* @var int $chkRadValue3 from prepend_content.php -> Service alarming
* @var int $chkRadValue4 from prepend_content.php -> Host command multiselect options
* @var int $chkRadValue5 from prepend_content.php -> Service command multiselect options
* @var int $chkRadValue6 from prepend_content.php -> Retain status information
* @var int $chkRadValue7 from prepend_content.php -> Retain non-status information
* @var int $chkRadValue8 from prepend_content.php -> Can submit command
* @var string $chkTfNullVal1 from prepend_content.php -> Minimum importance
* @var int $intVariables from prepend_content.php -> Form uses variable definitions
* @var int $intTemplates from prepend_content.php -> Form uses template definitions
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 17;
$preContent = 'admin/contacttemplates.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 17;
$preContent = 'admin/contacttemplates.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'contacttemplate';
$preTableName = 'tbl_contacttemplate';
$preKeyField = 'template_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Checkbox data processing
// ========================
if (($intVersion == 3) || ($intVersion == 4)) {
$strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f.$chkChbGr2g, 0, -1);
} else {
$strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2g, 0, -1);
$preTableName = 'tbl_contacttemplate';
$preKeyField = 'template_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intRet1 = 0;
$intRet2 = 0;
$intNoTime = 0;
/*
* Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
if (!isset($intMselValue3)) {
$intMselValue3 = 0;
}
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Checkbox data processing
*/
if (($intVersion === 3) || ($intVersion === 4)) {
$strHO = substr($chkChbGr1a . $chkChbGr1b . $chkChbGr1c . $chkChbGr1d . $chkChbGr1e . $chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a . $chkChbGr2b . $chkChbGr2c . $chkChbGr2d . $chkChbGr2e . $chkChbGr2f . $chkChbGr2g, 0, -1);
} else {
$strHO = substr($chkChbGr1a . $chkChbGr1b . $chkChbGr1c . $chkChbGr1d . $chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a . $chkChbGr2b . $chkChbGr2c . $chkChbGr2d . $chkChbGr2e . $chkChbGr2g, 0, -1);
}
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', "
. "`contactgroups`=$intMselValue1, `contactgroups_tploptions`=$chkRadValue1, "
. "`minimum_importance`=$chkTfNullVal1, "
. "`host_notifications_enabled`='$chkRadValue2', `service_notifications_enabled`='$chkRadValue3', "
. "`host_notification_period`='$chkSelValue1', `service_notification_period`='$chkSelValue2', "
. "`host_notification_options`='$strHO', `host_notification_commands_tploptions`=$chkRadValue4, "
. "`service_notification_options`='$strSO', `host_notification_commands`=$intMselValue2, "
. "`service_notification_commands`=$intMselValue3, "
. "`service_notification_commands_tploptions`=$chkRadValue5, `can_submit_commands`='$chkRadValue8', "
. "`retain_status_information`='$chkRadValue6', `retain_nonstatus_information`='$chkRadValue7', "
. "`email`='$chkTfValue3', `pager`='$chkTfValue4', `address1`='$chkTfValue5', `address2`='$chkTfValue6', "
. "`address3`='$chkTfValue7', `address4`='$chkTfValue8', `address5`='$chkTfValue9', "
. "`address6`='$chkTfValue10', `use_variables`='$intVariables', `use_template`=$intTemplates, "
. $preSQLCommon2;
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. "`contactgroups`=$intMselValue1, `contactgroups_tploptions`=$chkRadValue1, "
. "`minimum_importance`=$chkTfNullVal1, "
. "`host_notifications_enabled`='$chkRadValue2', `service_notifications_enabled`='$chkRadValue3', "
. "`host_notification_period`='$chkSelValue1', `service_notification_period`='$chkSelValue2', "
. "`host_notification_options`='$strHO', `host_notification_commands_tploptions`=$chkRadValue4, "
. "`service_notification_options`='$strSO', `host_notification_commands`=$intMselValue2, "
. "`service_notification_commands`=$intMselValue3, "
. "`service_notification_commands_tploptions`=$chkRadValue5, `can_submit_commands`='$chkRadValue8', "
. "`retain_status_information`='$chkRadValue6', `retain_nonstatus_information`='$chkRadValue7', "
. "`email`='$chkTfValue3', `pager`='$chkTfValue4', `address1`='$chkTfValue5', `address2`='$chkTfValue6', "
. "`address3`='$chkTfValue7', `address4`='$chkTfValue8', `address5`='$chkTfValue9', "
. "`address6`='$chkTfValue10', `use_variables`='$intVariables', `use_template`=$intTemplates, "
. $preSQLCommon2;
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if ($chkTfValue1 != '') {
if ($intWriteAccessId === 0) {
if ($chkTfValue1 !== '') {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New contact template inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New contact template inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Contact template modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Contact template modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkContacttemplateToContactgroup',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkContacttemplateToCommandHost',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkContacttemplateToCommandService',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
if (isset($intRet3) && ($intRet3 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkContacttemplateToContactgroup',
$chkDataId,
@@ -130,10 +220,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkContacttemplateToContactgroup', $chkDataId);
}
if ($intRet1 != 0) {
if ($intRet1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkContacttemplateToCommandHost',
$chkDataId,
@@ -142,10 +232,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkContacttemplateToCommandHost', $chkDataId);
}
if ($intRet2 != 0) {
if ($intRet2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkContacttemplateToCommandService',
$chkDataId,
@@ -157,80 +247,76 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
$chkDataId
);
}
if ($intRet3 != 0) {
if ($intRet3 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
//if (($intRet1 + $intRet2 + $intRet3) != 0) {
//$strInfoMessage = "";
//}
//
// Insert/update templates from session data
// =========================================
if ($chkModus == 'modify') {
$strSQL = 'DELETE FROM `tbl_lnkContacttemplateToContacttemplate` WHERE `idMaster`=' .$chkDataId;
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
/*
Insert/update templates from session data
*/
if ($chkModus === 'modify') {
$strSQL = 'DELETE FROM `tbl_lnkContacttemplateToContacttemplate` WHERE `idMaster`=' . $chkDataId;
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(count($_SESSION['templatedefinition']) != 0)) {
(count($_SESSION['templatedefinition']) !== 0)) {
$intSortId = 1;
/** @noinspection ForeachSourceInspection */
foreach ($_SESSION['templatedefinition'] as $elem) {
if ($elem['status'] == 0) {
$strSQL = 'INSERT INTO `tbl_lnkContacttemplateToContacttemplate` (`idMaster`, '
. "`idSlave`,`idTable`,`idSort`) VALUES ($chkDataId,".$elem['idSlave']. ', '
. $elem['idTable']. ',' .$intSortId. ')';
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
if ((int)$elem['status'] === 0) {
$strSQL = 'INSERT INTO `tbl_lnkContacttemplateToContacttemplate` (`idMaster`, '
. "`idSlave`,`idTable`,`idSort`) VALUES ($chkDataId," . $elem['idSlave'] . ', '
. $elem['idTable'] . ',' . $intSortId . ')';
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
$intSortId++;
}
}
//
// Insert/update variables from session data
// =========================================
if ($chkModus == 'modify') {
$strSQL = 'SELECT * '
. 'FROM `tbl_lnkContacttemplateToVariabledefinition` WHERE `idMaster`=' .$chkDataId;
/*
Insert/update variables from session data
*/
if ($chkModus === 'modify') {
$strSQL = 'SELECT * '
. 'FROM `tbl_lnkContacttemplateToVariabledefinition` WHERE `idMaster`=' . $chkDataId;
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCount != 0) {
if ($intDataCount !== 0) {
foreach ($arrData as $elem) {
$strSQL = 'DELETE FROM `tbl_variabledefinition` WHERE `id`=' .$elem['idSlave'];
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$strSQL = 'DELETE FROM `tbl_variabledefinition` WHERE `id`=' . $elem['idSlave'];
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
$strSQL = 'DELETE FROM `tbl_lnkContacttemplateToVariabledefinition` '
. 'WHERE `idMaster`=' .$chkDataId;
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$strSQL = 'DELETE FROM `tbl_lnkContacttemplateToVariabledefinition` '
. 'WHERE `idMaster`=' . $chkDataId;
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
(count($_SESSION['variabledefinition']) != 0)) {
(count($_SESSION['variabledefinition']) !== 0)) {
foreach ($_SESSION['variabledefinition'] as $elem) {
if ($elem['status'] == 0) {
$strSQL = 'INSERT INTO `tbl_variabledefinition` (`name`,`value`,`last_modified`) '
. "VALUES ('".$elem['definition']."','".$elem['range']."',now())";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
if ((int)$elem['status'] === 0) {
$strSQL = 'INSERT INTO `tbl_variabledefinition` (`name`,`value`,`last_modified`) '
. "VALUES ('" . $elem['definition'] . "','" . $elem['range'] . "',now())";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
$strSQL = 'INSERT INTO `tbl_lnkContacttemplateToVariabledefinition` (`idMaster`, '
. "`idSlave`) VALUES ($chkDataId,$intInsertId)";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$strSQL = 'INSERT INTO `tbl_lnkContacttemplateToVariabledefinition` (`idMaster`, '
. "`idSlave`) VALUES ($chkDataId,$intInsertId)";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
@@ -248,95 +334,85 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
/*
Singe data form
*/
if ($chkModus === 'add') {
$intDataWarning = 0;
$conttp->setVariable('TITLE', translate('Define contact templates (contacttemplates.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Process template selection fields (Spezial)
/* Process template selection fields (Spezial) */
$strWhere = '';
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
$strWhere = 'AND `id` <> ' .$arrModifyData['id'];
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
$strWhere = 'AND `id` <> ' . $arrModifyData['id'];
}
$strSQL1 = "SELECT `id`,`$preKeyField`, `active` FROM `$preTableName` "
. "WHERE $strDomainWhere $strWhere ORDER BY `$preKeyField`";
/** @noinspection SqlResolve */
$strSQL1 = "SELECT `id`,`$preKeyField`, `active` FROM `$preTableName` "
. "WHERE $strDomainWhere $strWhere ORDER BY `$preKeyField`";
$booReturn1 = $myDBClass->hasDataArray($strSQL1, $arrDataTpl, $intDataCountTpl);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCountTpl != 0) {
if ($intDataCountTpl !== 0) {
/** @var array $arrDataTpl */
foreach ($arrDataTpl as $elem) {
if ($elem['active'] == 0) {
if ($elem['active'] === 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$conttp->setVariable('SPECIAL_STYLE', '');
$conttp->setVariable('SPECIAL_STYLE');
}
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem[$preKeyField], ENT_QUOTES, 'UTF-8').$strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::1');
$conttp->parse('template');
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem[$preKeyField], ENT_QUOTES, 'UTF-8') . $strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id'] . '::1');
}
$conttp->parse('template');
}
$strSQL2 = 'SELECT `id`, `name`, `active` FROM `tbl_contact` '
. "WHERE `name` <> '' AND $strDomainWhere2 ORDER BY name";
$strSQL2 = 'SELECT `id`, `name`, `active` FROM `tbl_contact` '
. "WHERE `name` <> '' AND $strDomainWhere2 ORDER BY name";
$booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataHpl, $intDataCountHpl);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCountHpl != 0) {
if ($intDataCountHpl !== 0) {
/** @var array $arrDataHpl */
foreach ($arrDataHpl as $elem) {
if ($elem['active'] == 0) {
if ($elem['active'] === 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$conttp->setVariable('SPECIAL_STYLE', '');
$conttp->setVariable('SPECIAL_STYLE');
}
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['name'], ENT_QUOTES, 'UTF-8').$strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::2');
$conttp->parse('template');
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['name'], ENT_QUOTES, 'UTF-8') . $strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id'] . '::2');
}
$conttp->parse('template');
}
// Process timeperiod selection fields
if (isset($arrModifyData['host_notification_period'])) {
$intFieldId = $arrModifyData['host_notification_period'];
} else {
$intFieldId = 0;
}
/* Process timeperiod selection fields */
$intFieldId = $arrModifyData['host_notification_period'] ?? 0;
$intReturn1 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'host_time', 1, $intFieldId);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['service_notification_period'])) {
$intFieldId = $arrModifyData['service_notification_period'];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData['service_notification_period'] ?? 0;
$intReturn2 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'service_time', 1, $intFieldId);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process command selection fields
if (isset($arrModifyData['host_notification_commands'])) {
$intFieldId = $arrModifyData['host_notification_commands'];
} else {
$intFieldId = 0;
}
/* Process command selection fields */
$intFieldId = $arrModifyData['host_notification_commands'] ?? 0;
$intReturn3 = $myVisClass->parseSelectMulti(
'tbl_command',
'command_name',
@@ -345,14 +421,10 @@ if ($chkModus == 'add') {
0,
$intFieldId
);
if ($intReturn3 != 0) {
if ($intReturn3 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['service_notification_commands'])) {
$intFieldId = $arrModifyData['service_notification_commands'];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData['service_notification_commands'] ?? 0;
$intReturn4 = $myVisClass->parseSelectMulti(
'tbl_command',
'command_name',
@@ -361,15 +433,11 @@ if ($chkModus == 'add') {
0,
$intFieldId
);
if ($intReturn4 != 0) {
if ($intReturn4 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process contactgroup selection field
if (isset($arrModifyData['contactgroups'])) {
$intFieldId = $arrModifyData['contactgroups'];
} else {
$intFieldId = 0;
}
/* Process contactgroup selection field */
$intFieldId = $arrModifyData['contactgroups'] ?? 0;
$intReturn5 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
@@ -378,30 +446,26 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn5 != 0) {
if ($intReturn5 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process acces group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn6 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn6 != 0) {
if ($intReturn6 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$strChbFields = 'HNE,SNE,RSI,CSC,RNS,TPL,SEC,HOC,COG';
$myContentClass->addFormInit($conttp, $strChbFields);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion == 4) {
if ($intVersion === 4) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1e,chbGr1f');
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2f,chbGr2g');
}
if ($intVersion == 3) {
if ($intVersion === 3) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1e,chbGr1f');
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2f,chbGr2g');
}
@@ -410,68 +474,71 @@ if ($chkModus == 'add') {
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2g');
$conttp->setVariable('VERSION_20_VALUE_MUST', ',tfValue2');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo, $strChbFields);
// Process radio fields
$conttp->setVariable('DAT_HNE' .$arrModifyData['host_notifications_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_SNE' .$arrModifyData['service_notifications_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_RSI' .$arrModifyData['retain_status_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_CSC' .$arrModifyData['can_submit_commands']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_RNS' .$arrModifyData['retain_nonstatus_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_TPL' .$arrModifyData['use_template_tploptions']. '_CHECKED', 'checked');
/* Process radio fields */
$conttp->setVariable('DAT_HNE' . $arrModifyData['host_notifications_enabled'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_SNE' . $arrModifyData['service_notifications_enabled'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_RSI' . $arrModifyData['retain_status_information'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_CSC' . $arrModifyData['can_submit_commands'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_RNS' . $arrModifyData['retain_nonstatus_information'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_TPL' . $arrModifyData['use_template_tploptions'] . '_CHECKED', 'checked');
$conttp->setVariable(
'DAT_SEC' .$arrModifyData['service_notification_commands_tploptions']. '_CHECKED',
'DAT_SEC' . $arrModifyData['service_notification_commands_tploptions'] . '_CHECKED',
'checked'
);
$conttp->setVariable('DAT_HOC' .$arrModifyData['host_notification_commands_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_COG' .$arrModifyData['contactgroups_tploptions']. '_CHECKED', 'checked');
// Process option fields
$conttp->setVariable('DAT_HOC' . $arrModifyData['host_notification_commands_tploptions'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_COG' . $arrModifyData['contactgroups_tploptions'] . '_CHECKED', 'checked');
/* Process option fields */
foreach (explode(',', $arrModifyData['host_notification_options']) as $elem) {
$conttp->setVariable('DAT_HO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_HO' . strtoupper($elem) . '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['service_notification_options']) as $elem) {
$conttp->setVariable('DAT_SO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_SO' . strtoupper($elem) . '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
$strSearchWhere = '';
$intLineCount = 0;
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define contact templates (contacttemplates.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Contact name'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Process filter string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' OR "
. "`email` LIKE '%".$strSearchTxt."%' OR `pager` LIKE '%".$strSearchTxt."%' OR "
. "`address1` LIKE '%".$strSearchTxt."%' OR `address2` LIKE '%".$strSearchTxt."%' OR "
. "`address3` LIKE '%".$strSearchTxt."%' OR `address4` LIKE '%".$strSearchTxt."%' OR "
. "`address5` LIKE '%".$strSearchTxt."%' OR `address6` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process filter string */
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%' OR `alias` LIKE '%" . $strSearchTxt . "%' OR "
. "`email` LIKE '%" . $strSearchTxt . "%' OR `pager` LIKE '%" . $strSearchTxt . "%' OR "
. "`address1` LIKE '%" . $strSearchTxt . "%' OR `address2` LIKE '%" . $strSearchTxt . "%' OR "
. "`address3` LIKE '%" . $strSearchTxt . "%' OR `address4` LIKE '%" . $strSearchTxt . "%' OR "
. "`address5` LIKE '%" . $strSearchTxt . "%' OR `address6` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
}
// Count datasets
$strSQL = 'SELECT count(*) AS `number` '
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
/* Count datasets */
$strSQL = 'SELECT count(*) AS `number` '
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -480,19 +547,19 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `register`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) "
. "$strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `register`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) "
. "$strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -502,7 +569,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,70 +1,103 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin domain administration
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Data domain administration
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var int $chkActive from prepend_adm.php -> Active checkbox
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $chkTfValue1 from prepend_content.php -> Domain name
* @var string $chkTfValue2 from prepend_content.php -> Domain description
* @var int $chkSelValue1 from prepend_content.php -> Configuration target domain
* @var string $chkSelValue2 from prepend_content.php -> Nagios version
* @var string $chkSelValue3 from prepend_content.php -> Use common domain selection
* @var string $chkSelAccGr from prepend_content.php -> Access group selector
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 35;
$preContent = 'admin/datadomain.htm.tpl';
$preListTpl = 'admin/datalist_common.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 35;
$preContent = 'admin/datadomain.htm.tpl';
$preListTpl = 'admin/datalist_common.htm.tpl';
$preTableName = 'tbl_datadomain';
$preKeyField = 'domain';
$preAccess = 1;
$preKeyField = 'domain';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
if ($chkTfValue1 == 'common') {
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
if ($chkTfValue1 === 'common') {
$chkSelValue1 = 0;
}
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `targets`=$chkSelValue1, "
. "`version`=$chkSelValue2, `access_group`=$chkSelAccGr, `enable_common`=$chkSelValue3, "
. "`active`='$chkActive', `last_modified`=NOW()";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. "`version`=$chkSelValue2, `access_group`=$chkSelAccGr, `enable_common`=$chkSelValue3, "
. "`active`='$chkActive', `last_modified`=NOW()";
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($chkTfValue1 == 'common') || ($chkSelValue1 != 0))) {
if ($intWriteAccessId === 0) {
if (($chkTfValue1 !== '') && ($chkTfValue2 !== '') && (($chkTfValue1 === 'common') || ($chkSelValue1 !== 0))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New Domain inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New Domain inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Domain modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Domain modified:') . ' ' . $chkTfValue1);
}
}
} else {
@@ -78,59 +111,52 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Single view
// ===========
if ($chkModus == 'add') {
// Process configuration target selection fields
if (isset($arrModifyData['targets'])) {
$intFieldId = $arrModifyData['targets'];
} else {
$intFieldId = 0;
}
/*
Single view
*/
if ($chkModus === 'add') {
$intDataWarning = 0;
$strDBWarning = '';
/* Process configuration target selection fields */
$intFieldId = $arrModifyData['targets'] ?? 0;
$intReturn1 = $myVisClass->parseSelectSimple('tbl_configtarget', 'target', 'target', 0, $intFieldId);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Attention, no configuration targets defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process acces group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn2 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
$conttp->setVariable('TITLE', translate('Data domain administration'));
$conttp->setVariable('FILL_ALLFIELDS', translate('Please fill in all fields marked with an *'));
$conttp->setVariable('FILL_ILLEGALCHARS', translate('The following field contains illegal characters:'));
$conttp->setVariable('ENABLE', translate('Enable'));
$conttp->setVariable('DISABLE', translate('Disable'));
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Process data
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, 0, '');
// Nagios version
$conttp->setVariable('VER_SELECTED_' .$arrModifyData['version'], 'selected');
// Enable common domain
$conttp->setVariable('ENA_COMMON_SELECTED_' .$arrModifyData['enable_common'], 'selected');
// Domain localhost cant' be renamed
if ($arrModifyData['domain'] == 'localhost') {
/* Nagios version */
$conttp->setVariable('VER_SELECTED_' . $arrModifyData['version'], 'selected');
/* Enable common domain */
$conttp->setVariable('ENA_COMMON_SELECTED_' . $arrModifyData['enable_common'], 'selected');
/* Domain localhost cannot be renamed */
if ($arrModifyData['domain'] === 'localhost') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('LOCKCLASS', 'inputlock');
} elseif ($arrModifyData['domain'] == 'common') {
} elseif ($arrModifyData['domain'] === 'common') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('COMMON_INVISIBLE', 'class="elementHide"');
$conttp->setVariable('LOCKCLASS', 'inputlock');
@@ -141,24 +167,26 @@ if ($chkModus == 'add') {
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
$intLineCount = 0;
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Data domain administration'));
$mastertp->setVariable('FIELD_1', translate('Data domain'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `domain` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `alias` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)";
/* Count datasets */
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -167,21 +195,21 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = 'SELECT `id`, `domain`, `alias`, `active`, `nodelete`, `access_group` '
. "FROM `$preTableName` WHERE `access_group` IN ($strAccess) $strOrderString "
. "LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL = 'SELECT `id`, `domain`, `alias`, `active`, `nodelete`, `access_group` '
. "FROM `$preTableName` WHERE `access_group` IN ($strAccess) $strOrderString "
. "LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
}
// Show messages
/* Show messages */
$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,67 +1,87 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin file deletion
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Delete backup files
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\NagConfigClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $prePageKey from prepend_adm.php -> Menu group id
* @var int $chkStatus from prepend_adm.php -> (hidden) Status field
* @var string $chkTfSearch from prepend_content.php -> Text search string
* @var mixed $chkMselValue1 from prepend_content.php -> Backup file list
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 26;
$preContent = 'admin/delbackup.htm.tpl';
$preAccess = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 26;
$preContent = 'admin/delbackup.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Get configuration set ID
// ========================
$strErrorMessage = '';
$strInfoMessage = '';
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Get configuration set ID
*/
$intMethod = 0;
$strMethod = '';
$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$intConfigId = (int)$arrConfigSet[0];
if ($myConfigClass->getConfigValues($intConfigId, 'method', $strMethod) === 0) {
$intMethod = (int)$strMethod;
}
$myConfigClass->getConfigValues($intConfigId, 'backupdir', $strBackupDir);
$myConfigClass->getConfigValues($intConfigId, 'hostbackup', $strHostBackupDir);
$myConfigClass->getConfigValues($intConfigId, 'servicebackup', $strServiceBackupDir);
//
// Process form inputs
// ===================
if (($chkMselValue1[0] != '') && ($chkStatus == 1)) {
/*
Process form inputs
*/
if (isset($chkMselValue1[0]) && ($chkMselValue1[0] !== '') && ($chkStatus === 1)) {
/** @var array $chkMselValue1 */
foreach ($chkMselValue1 as $elem) {
$intCheck = $myConfigClass->removeFile(trim($elem), $intConfigId);
$strFileTmp1 = str_replace($strServiceBackupDir, '', $elem);
$strFileTmp2 = str_replace($strHostBackupDir, '', $strFileTmp1);
$strFile = str_replace($strBackupDir, '', $strFileTmp2);
if ($intCheck == 0) {
$myDataClass->writeLog(translate('File deleted'). ': ' .trim($strFile));
$myVisClass->processMessage($strFile. ' ' .translate('successfully deleted'). '!', $strInfoMessage);
$strFile = str_replace($strBackupDir, '', $strFileTmp2);
if ($intCheck === 0) {
$myDataClass->writeLog(translate('File deleted') . ': ' . trim($strFile));
$myVisClass->processMessage($strFile . ' ' . translate('successfully deleted') . '!', $strInfoMessage);
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
}
}
//
// Include content
// ===============
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Delete backup files'));
$conttp->parse('header');
$conttp->show('header');
@@ -75,42 +95,42 @@ $conttp->setVariable('LANG_REQUIRED', translate('required'));
$conttp->setVariable('MAKE', translate('Delete'));
$conttp->setVariable('ABORT', translate('Abort'));
$conttp->setVariable('CTRL_INFO', translate('Hold CTRL to select<br>more than one entry'));
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
// Build a local file list
if ($intMethod == 1) {
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url'] . 'images/');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF'));
/* Build a local file list */
if ($intMethod === 1) {
$output = array();
$myConfigClass->storeDirToArray($strBackupDir, "\.cfg_old", '', $output, $strErrorMessage);
if (is_array($output) && (count($output) != 0)) {
if (is_array($output) && (count($output) !== 0)) {
foreach ($output as $elem) {
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
if (($chkTfSearch === '') || (substr_count($elem, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_BACKUPFILE', $elem);
$conttp->parse('filelist');
}
}
}
} elseif ($intMethod == 2) {
// Set up basic connection
if ($myConfigClass->getFTPConnection($intConfigId) == '0') {
$arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId, $strBackupDir);
} elseif ($intMethod === 2) {
/* Set up basic connection */
if ($myConfigClass->getFTPConnection($intConfigId) === 0) {
$arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->conFTPConId, $strBackupDir);
if (is_array($arrFiles1)) {
$arrFiles = array_merge($arrFiles, $arrFiles1);
}
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId, $strHostBackupDir);
$arrFiles2 = ftp_nlist($myConfigClass->conFTPConId, $strHostBackupDir);
if (is_array($arrFiles2)) {
$arrFiles = array_merge($arrFiles, $arrFiles2);
}
$arrFiles3 = ftp_nlist($myConfigClass->resConnectId, $strServiceBackupDir);
$arrFiles3 = ftp_nlist($myConfigClass->conFTPConId, $strServiceBackupDir);
if (is_array($arrFiles3)) {
$arrFiles = array_merge($arrFiles, $arrFiles3);
}
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
if (is_array($arrFiles) && (count($arrFiles) !== 0)) {
foreach ($arrFiles as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
if (($chkTfSearch === '') || (substr_count($elem, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_BACKUPFILE', $elem);
$conttp->parse('filelist');
}
@@ -121,32 +141,32 @@ if ($intMethod == 1) {
$strErrorMessage
);
}
ftp_close($myConfigClass->resConnectId);
ftp_close($myConfigClass->conFTPConId);
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
} elseif ($intMethod == 3) {
// Set up basic connection
if ($myConfigClass->getSSHConnection($intConfigId) == '0') {
$arrFiles = array();
$intReturn = $myConfigClass->sendSSHCommand('ls ' .$strBackupDir. '*.cfg_old*', $arrFiles1);
if (($intReturn == 0) && is_array($arrFiles1)) {
} elseif ($intMethod === 3) {
/* Set up basic connection */
if ($myConfigClass->getSSHConnection($intConfigId) === 0) {
$arrFiles = array();
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strBackupDir . '*.cfg_old*', $arrFiles1);
if (($intReturn === 0) && is_array($arrFiles1)) {
$arrFiles = array_merge($arrFiles, $arrFiles1);
}
$intReturn = $myConfigClass->sendSSHCommand('ls ' .$strHostBackupDir. '*.cfg_old*', $arrFiles2);
if (($intReturn == 0) && is_array($arrFiles2)) {
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strHostBackupDir . '*.cfg_old*', $arrFiles2);
if (($intReturn === 0) && is_array($arrFiles2)) {
$arrFiles = array_merge($arrFiles, $arrFiles2);
}
$intReturn = $myConfigClass->sendSSHCommand('ls ' .$strServiceBackupDir. '*.cfg_old*', $arrFiles3);
if (($intReturn == 0) && is_array($arrFiles3)) {
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strServiceBackupDir . '*.cfg_old*', $arrFiles3);
if (($intReturn === 0) && is_array($arrFiles3)) {
$arrFiles = array_merge($arrFiles, $arrFiles3);
}
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
if (is_array($arrFiles) && (count($arrFiles) !== 0)) {
foreach ($arrFiles as $elem) {
if (!substr_count($elem, 'cfg_old')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
if (($chkTfSearch === '') || (substr_count($elem, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $elem));
$conttp->parse('filelist');
}
@@ -161,20 +181,20 @@ if ($intMethod == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
}
if ($strErrorMessage != '') {
if ($strErrorMessage !== '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('main');
$conttp->show('main');
//
// Footer ausgeben
// ===============
/*
Footer ausgeben
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,67 +1,86 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin file deletion
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Delete configuration files
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\NagConfigClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $prePageKey from prepend_adm.php -> Menu group id
* @var int $chkStatus from prepend_adm.php -> (hidden) Status field
* @var string $chkTfSearch from prepend_content.php -> Text search string
* @var mixed $chkMselValue1 from prepend_content.php -> Backup file list
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 27;
$preContent = 'admin/delbackup.htm.tpl';
$preAccess = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 27;
$preContent = 'admin/delbackup.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Get configuration set ID
// ========================
$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$strErrorMessage = '';
$strInfoMessage = '';
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Get configuration set ID
*/
$intMethod = 0;
$strMethod = '';
$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = (int)$arrConfigSet[0];
if ($myConfigClass->getConfigValues($intConfigId, 'method', $strMethod) === 0) {
$intMethod = (int)$strMethod;
}
$myConfigClass->getConfigValues($intConfigId, 'basedir', $strBaseDir);
$myConfigClass->getConfigValues($intConfigId, 'hostconfig', $strHostDir);
$myConfigClass->getConfigValues($intConfigId, 'serviceconfig', $strServiceDir);
//
// Process form inputs
// ===================
/** @var array $chkMselValue1 */
if (($chkMselValue1[0] != '') && ($chkStatus == 1)) {
/*
Process form inputs
*/
if (isset($chkMselValue1[0]) && ($chkMselValue1[0] !== '') && ($chkStatus === 1)) {
foreach ($chkMselValue1 as $elem) {
$intCheck = $myConfigClass->removeFile(trim($elem), $intConfigId);
$strFileTmp1 = str_replace($strServiceDir, '', $elem);
$strFileTmp2 = str_replace($strHostDir, '', $strFileTmp1);
$strFile = str_replace($strBaseDir, '', $strFileTmp2);
if ($intCheck == 0) {
$myDataClass->writeLog(translate('File deleted'). ': ' .trim($strFile));
$myVisClass->processMessage($strFile. ' ' .translate('successfully deleted'). '!', $strInfoMessage);
$strFile = str_replace($strBaseDir, '', $strFileTmp2);
if ($intCheck === 0) {
$myDataClass->writeLog(translate('File deleted') . ': ' . trim($strFile));
$myVisClass->processMessage($strFile . ' ' . translate('successfully deleted') . '!', $strInfoMessage);
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
}
}
//
// Include content
// ===============
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Delete config files'));
$conttp->parse('header');
$conttp->show('header');
@@ -75,95 +94,95 @@ $conttp->setVariable('LANG_REQUIRED', translate('required'));
$conttp->setVariable('MAKE', translate('Delete'));
$conttp->setVariable('ABORT', translate('Abort'));
$conttp->setVariable('CTRL_INFO', translate('Hold CTRL to select<br>more than one entry'));
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
// Build a local file list
if ($intMethod == 1) {
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url'] . 'images/');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF'));
/* Build a local file list */
if ($intMethod === 1) {
$output = array();
$myConfigClass->storeDirToArray($strBaseDir, "\.cfg", '\.cfg_old', $output, $strErrorMessage);
if (is_array($output) && (count($output) != 0)) {
if (is_array($output) && (count($output) !== 0)) {
foreach ($output as $elem2) {
if (($chkTfSearch == '') || (substr_count($elem2, $chkTfSearch) != 0)) {
if (($chkTfSearch === '') || (substr_count($elem2, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_BACKUPFILE', $elem2);
$conttp->parse('filelist');
}
}
}
} elseif ($intMethod == 2) {
// Open ftp connection
if ($myConfigClass->getFTPConnection($intConfigId) == '0') {
$arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId, $strBaseDir);
} elseif ($intMethod === 2) {
/* Open ftp connection */
if ($myConfigClass->getFTPConnection($intConfigId) === 0) {
$arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->conFTPConId, $strBaseDir);
if (is_array($arrFiles1)) {
$arrFiles = array_merge($arrFiles, $arrFiles1);
}
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId, $strHostDir);
$arrFiles2 = ftp_nlist($myConfigClass->conFTPConId, $strHostDir);
if (is_array($arrFiles2)) {
$arrFiles = array_merge($arrFiles, $arrFiles2);
}
$arrFiles3 = ftp_nlist($myConfigClass->resConnectId, $strServiceDir);
$arrFiles3 = ftp_nlist($myConfigClass->conFTPConId, $strServiceDir);
if (is_array($arrFiles3)) {
$arrFiles = array_merge($arrFiles, $arrFiles3);
}
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
if (is_array($arrFiles) && (count($arrFiles) !== 0)) {
foreach ($arrFiles as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
if (($chkTfSearch === '') || (substr_count($elem, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $elem));
$conttp->parse('filelist');
}
}
}
ftp_close($myConfigClass->resConnectId);
ftp_close($myConfigClass->conFTPConId);
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
} elseif ($intMethod == 3) {
// Open ssh connection
if ($myConfigClass->getSSHConnection($intConfigId) == '0') {
$intReturn = $myConfigClass->sendSSHCommand('ls '.$strBaseDir, $arrFiles1);
if (($intReturn == 0) && is_array($arrFiles1) && (count($arrFiles1) != 0)) {
} elseif ($intMethod === 3) {
/* Open ssh connection */
if ($myConfigClass->getSSHConnection($intConfigId) === 0) {
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strBaseDir, $arrFiles1);
if (($intReturn === 0) && is_array($arrFiles1) && (count($arrFiles1) !== 0)) {
foreach ($arrFiles1 as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
}
if (substr_count($elem, 'cgi.cfg') != 0) {
if (substr_count($elem, 'cgi.cfg') !== 0) {
continue;
}
if (substr_count($elem, 'nagios.cfg') != 0) {
if (substr_count($elem, 'nagios.cfg') !== 0) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
$conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $strBaseDir. '/' .$elem));
$conttp->setVariable('DAT_BACKUPFILE_FULL', str_replace('//', '/', $strBaseDir. '/' .$elem));
if (($chkTfSearch === '') || (substr_count($elem, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $strBaseDir . '/' . $elem));
$conttp->setVariable('DAT_BACKUPFILE_FULL', str_replace('//', '/', $strBaseDir . '/' . $elem));
$conttp->parse('filelist');
}
}
}
$intReturn = $myConfigClass->sendSSHCommand('ls '.$strHostDir, $arrFiles2);
if (($intReturn == 0) && is_array($arrFiles2) && (count($arrFiles2) != 0)) {
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strHostDir, $arrFiles2);
if (($intReturn === 0) && is_array($arrFiles2) && (count($arrFiles2) !== 0)) {
foreach ($arrFiles2 as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
$conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $strHostDir. '/' .$elem));
$conttp->setVariable('DAT_BACKUPFILE_FULL', str_replace('//', '/', $strHostDir. '/' .$elem));
if (($chkTfSearch === '') || (substr_count($elem, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $strHostDir . '/' . $elem));
$conttp->setVariable('DAT_BACKUPFILE_FULL', str_replace('//', '/', $strHostDir . '/' . $elem));
$conttp->parse('filelist');
}
}
}
$intReturn = $myConfigClass->sendSSHCommand('ls '.$strServiceDir, $arrFiles3);
if (($intReturn == 0) && is_array($arrFiles3) && (count($arrFiles3) != 0)) {
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strServiceDir, $arrFiles3);
if (($intReturn === 0) && is_array($arrFiles3) && (count($arrFiles3) !== 0)) {
foreach ($arrFiles3 as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
$conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $strServiceDir. '/' .$elem));
$conttp->setVariable('DAT_BACKUPFILE_FULL', str_replace('//', '/', $strServiceDir. '/' .$elem));
if (($chkTfSearch === '') || (substr_count($elem, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $strServiceDir . '/' . $elem));
$conttp->setVariable('DAT_BACKUPFILE_FULL', str_replace('//', '/', $strServiceDir . '/' . $elem));
$conttp->parse('filelist');
}
}
@@ -172,20 +191,20 @@ if ($intMethod == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
}
if ($strErrorMessage != '') {
if ($strErrorMessage !== '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('main');
$conttp->show('main');
//
// Footer ausgeben
// ===============
/*
Footer ausgeben
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,61 +1,66 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Download config file
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Download config file
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\NagConfigClass;
use functions\NagDataClass;
/**
* Class and variable includes
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
*/
/*
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));
//
// Version control
// ===============
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Version control
*/
session_cache_limiter('private_no_expire');
//
// Include preprocessing file
// ==========================
$preNoMain = 1;
$preNoLogin = 1;
require $preBasePath.'functions/prepend_adm.php';
//
// Process post parameters
// =======================
$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)));
//
// Header output
// ===============
/*
Include preprocessing file
*/
$preNoMain = 1;
$preNoLogin = 1;
require $preBasePath . 'functions/prepend_adm.php';
/*
Process post parameters
*/
$chkTable = filter_input(INPUT_GET, 'table');
$chkConfig = filter_input(INPUT_GET, 'config');
$chkLine = filter_input(INPUT_GET, 'line', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
/*
Header output
*/
$arrConfig = $myConfigClass->getConfData();
if (isset($arrConfig[$chkTable])) {
$strFile = $arrConfig[$chkTable]['filename'];
} else {
$strFile = $chkConfig. '.cfg';
$strFile = $chkConfig . '.cfg';
}
if ($strFile == '.cfg') {
if ($strFile === '.cfg') {
exit;
}
header('Content-Disposition: attachment; filename=' .$strFile);
header('Content-Disposition: attachment; filename=' . $strFile);
header('Content-Type: text/plain');
//
// Get data
// ========
if ($chkLine == 0) {
/*
Get data
*/
if ($chkLine === 0) {
$myConfigClass->createConfig($chkTable, 1);
} else {
$myConfigClass->createConfigSingle($chkTable, $chkLine, 1);
}
$myDataClass->writeLog(translate('Download'). ' ' .$strFile);
$myDataClass->writeLog(translate('Download') . ' ' . $strFile);

View File

@@ -1,109 +1,137 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Group administration
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Group administration
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var int $chkActive from prepend_adm.php -> Active checkbox
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var int $chkListId from prepend_adm.php -> Actual dataset id (list view)
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var array $SETS Settings array
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $chkTfValue1 from prepend_content.php -> Group name
* @var string $chkTfValue2 from prepend_content.php -> Group description
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 33;
$preContent = 'admin/group.htm.tpl';
$preListTpl = 'admin/datalist_common.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 33;
$preContent = 'admin/group.htm.tpl';
$preListTpl = 'admin/datalist_common.htm.tpl';
$preSearchSession = 'group';
$preTableName = 'tbl_group';
$preKeyField = 'groupname';
$preAccess = 1;
$preFieldvars = 1;
$preNoAccessGrp = 1;
$arrDataLines = array();
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Add or modify data
// ==================
if (($chkModus == 'insert') || ($chkModus == 'modify')) {
$preTableName = 'tbl_group';
$preKeyField = 'groupname';
$preAccess = 1;
$preFieldvars = 1;
$preNoAccessGrp = 1;
$arrDataLines = array();
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Add or modify data
*/
if (($chkModus === 'insert') || ($chkModus === 'modify')) {
$strSQLx = "`$preTableName` SET `groupname`='$chkTfValue1', `description`='$chkTfValue2', `active`='$chkActive', "
. '`last_modified`=NOW()';
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. '`last_modified`=NOW()';
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
if ($intWriteAccessId === 0) {
if (($chkTfValue1 !== '') && ($chkTfValue2 !== '')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('A new group added:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('A new group added:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('User modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('User modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update user/group data from session data
// ===============================================
if ($chkModus == 'modify') {
$strSQL = "DELETE FROM `tbl_lnkGroupToUser` WHERE `idMaster`=$chkDataId";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn != 0) {
/*
Insert/update user/group data from session data
*/
if ($chkModus === 'modify') {
$strSQL = "DELETE FROM `tbl_lnkGroupToUser` WHERE `idMaster`=$chkDataId";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser']) &&
(count($_SESSION['groupuser']) != 0)) {
(count($_SESSION['groupuser']) !== 0)) {
foreach ($_SESSION['groupuser'] as $elem) {
if ($elem['status'] == 0) {
$intRead = 0;
if ((int)$elem['status'] === 0) {
$intRead = 0;
$intWrite = 0;
$intLink = 0;
if (substr_count($elem['rights'], 'READ') != 0) {
$intRead = 1;
$intLink = 0;
if (substr_count($elem['rights'], 'READ') !== 0) {
$intRead = 1;
}
if (substr_count($elem['rights'], 'WRITE') != 0) {
if (substr_count($elem['rights'], 'WRITE') !== 0) {
$intWrite = 1;
}
if (substr_count($elem['rights'], 'LINK') != 0) {
$intLink = 1;
if (substr_count($elem['rights'], 'LINK') !== 0) {
$intLink = 1;
}
if ($intWrite == 1) {
if ($intWrite === 1) {
$intRead = 1;
$intLink = 1;
}
if ($intRead == 1) {
if ($intRead === 1) {
$intLink = 1;
}
// if ($intLink == 1) $intRead = 1;
$strSQL = 'INSERT INTO `tbl_lnkGroupToUser` (`idMaster`,`idSlave`,`read`,`write`,'
. "`link`) VALUES ($chkDataId,".$elem['user'].",'$intRead','$intWrite',"
. "'$intLink')";
/* if ($intLink === 1) $intRead = 1; */
$strSQL = 'INSERT INTO `tbl_lnkGroupToUser` (`idMaster`,`idSlave`,`read`,`write`,'
. "`link`) VALUES ($chkDataId," . $elem['user'] . ",'$intRead','$intWrite',"
. "'$intLink')";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
@@ -121,25 +149,26 @@ if (($chkModus == 'insert') || ($chkModus == 'modify')) {
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
// Process data fields
$strSQL = 'SELECT * FROM `tbl_user` WHERE `id`<>1 ORDER BY `username`';
/*
Singe data form
*/
if ($chkModus === 'add') {
/* Process data fields */
$strSQL = 'SELECT * FROM `tbl_user` WHERE `id`<>1 ORDER BY `username`';
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
if ($booReturn && ($intDataCount != 0)) {
if ($booReturn && ($intDataCount !== 0)) {
foreach ($arrDataLines as $elem) {
$conttp->setVariable('DAT_USER_ID', $elem['id']);
$conttp->setVariable('DAT_USER', $elem['username']);
/** @noinspection DisconnectedForeachInstructionInspection */
$conttp->parse('users');
}
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
$conttp->setVariable('TITLE', translate('Group administration'));
$conttp->setVariable('LANG_READ', translate('Read'));
@@ -148,32 +177,34 @@ if ($chkModus == 'add') {
$conttp->setVariable('DAT_ID', $chkListId);
$conttp->setVariable('FILL_ALLFIELDS', translate('Please fill in all fields marked with an *'));
$conttp->setVariable('FILL_ILLEGALCHARS', translate('The following field contains illegal characters:'));
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Process data
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, 0, '');
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Group administration'));
$mastertp->setVariable('FIELD_1', translate('Groupname'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `groupname` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `description` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName`";
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName`";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -182,20 +213,20 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = 'SELECT `id`, `groupname`, `description`, `active` '
. "FROM `$preTableName` $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL = 'SELECT `id`, `groupname`, `description`, `active` '
. "FROM `$preTableName` $strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'description');
}
// Show messages
/* Show messages */
$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,112 +1,113 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin time definition list
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Group user administration
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
/**
* Class and variable includes
* @var MysqliDbClass $myDBClass MySQL database class
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
*/
/*
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));
//
// Define common variables
// =======================
$preAccess = 1;
$preNoMain = 1;
require $preBasePath.'functions/prepend_adm.php';
//
// Process get parameters
// ======================
$chkDataId = filter_input(INPUT_GET, 'dataId', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$preAccess = 1;
$preNoMain = 1;
require $preBasePath . 'functions/prepend_adm.php';
/*
Process get parameters
*/
$chkDataId = filter_input(INPUT_GET, 'dataId', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkVersion = filter_input(INPUT_GET, 'version', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkMode = filter_input(INPUT_GET, 'mode', FILTER_SANITIZE_STRING);
$chkUser = filter_input(INPUT_GET, 'user', FILTER_SANITIZE_STRING);
$chkRights = filter_input(INPUT_GET, 'rights', FILTER_SANITIZE_STRING);
$chkId = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_STRING);
$chkLinkTab = filter_input(INPUT_GET, 'linktab', FILTER_SANITIZE_STRING);
$chkMode = (string)filter_input(INPUT_GET, 'mode');
$chkUser = (string)filter_input(INPUT_GET, 'user');
$chkRights = (string)filter_input(INPUT_GET, 'rights');
$chkId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
$chkLinkTab = (string)filter_input(INPUT_GET, 'linktab');
if (substr_count($chkRights, '-')) {
$arrRights = explode('-', $chkRights);
$strRights = '';
if ($arrRights[0] == 1) {
if ((int)$arrRights[0] === 1) {
$strRights .= 'READ,';
}
if ($arrRights[1] == 1) {
if ((int)$arrRights[1] === 1) {
$strRights .= 'WRITE,';
}
if ($arrRights[2] == 1) {
if ((int)$arrRights[2] === 1) {
$strRights .= 'LINK,';
}
if ($strRights != '') {
if ($strRights !== '') {
$strRights = substr($strRights, 0, -1);
}
$chkRights = $strRights;
}
if (get_magic_quotes_gpc() == 0) {
$chkUser = addslashes($chkUser);
$chkRights = addslashes($chkRights);
}
//
// Get datasets
// ============
if ($chkLinkTab != '') {
$strSQL = 'SELECT * FROM `tbl_user` LEFT JOIN `' .$chkLinkTab. '` ON `id`=`idSlave` '
. "WHERE `idMaster`=$chkDataId ORDER BY `username`";
/*
Get datasets
*/
if ($chkLinkTab !== '') {
/** @noinspection SqlResolve */
$strSQL = 'SELECT * FROM `tbl_user` LEFT JOIN `' . $chkLinkTab . '` ON `id`=`idSlave` '
. "WHERE `idMaster`=$chkDataId ORDER BY `username`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
//
// Write data to session
// =====================
if ($chkMode == '') {
/*
Write data to session
*/
if (($chkMode === null) || ($chkMode === '')) {
$_SESSION['groupuser'] = array();
if ($intDataCount != 0) {
if ($intDataCount !== 0) {
foreach ($arrDataLines as $elem) {
$arrTemp['id'] = $elem['id'];
$arrTemp['user'] = $elem['id'];
$arrTemp['id'] = (int)$elem['id'];
$arrTemp['user'] = (int)$elem['id'];
$strRights = '';
if ($elem['read'] == 1) {
if ((int)$elem['read'] === 1) {
$strRights .= 'READ,';
}
if ($elem['write'] == 1) {
if ((int)$elem['write'] === 1) {
$strRights .= 'WRITE,';
}
if ($elem['link'] == 1) {
if ((int)$elem['link'] === 1) {
$strRights .= 'LINK,';
}
if ($strRights != '') {
if ($strRights !== '') {
$strRights = substr($strRights, 0, -1);
}
$arrTemp['rights'] = $strRights;
$arrTemp['status'] = 0;
$_SESSION['groupuser'][] = $arrTemp;
$arrTemp['rights'] = $strRights;
$arrTemp['status'] = 0;
$_SESSION['groupuser'][] = $arrTemp;
}
}
}
}
//
// Add mode
// ========
if ($chkMode == 'add') {
/*
Add mode
*/
if ($chkMode === 'add') {
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser'])) {
$intCheck = 0;
foreach ($_SESSION['groupuser'] as $key => $elem) {
if (($elem['user'] == $chkUser) && ($elem['status'] == 0)) {
if (((int)$elem['user'] === (int)$chkUser) && ((int)$elem['status'] === 0)) {
$_SESSION['groupuser'][$key]['user'] = $chkUser;
$_SESSION['groupuser'][$key]['rights'] = $chkRights;
$intCheck = 1;
}
}
if ($intCheck == 0) {
if ($intCheck === 0) {
$arrTemp['id'] = 0;
$arrTemp['user'] = $chkUser;
$arrTemp['rights'] = $chkRights;
@@ -122,63 +123,68 @@ if ($chkMode == 'add') {
$_SESSION['groupuser'][] = $arrTemp;
}
}
//
// Deletion mode
// =============
if ($chkMode == 'del' && isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser'])) {
/*
Deletion mode
*/
if ($chkMode === 'del' && isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser'])) {
foreach ($_SESSION['groupuser'] as $key => $elem) {
if (($elem['user'] == $chkUser) && ($elem['status'] == 0)) {
if (((int)$elem['user'] === (int)$chkUser) && ((int)$elem['status'] === 0)) {
$_SESSION['groupuser'][$key]['status'] = 1;
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>None</title>
<link href="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="javascript">
<!--
function doDel(key) {
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>None</title>
<link href="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="javascript">
<!--
function doDel(key) {
document.location.href = "<?php
echo $_SESSION['SETS']['path']['base_url']; ?>admin/groupusers.php?dataId=<?php
echo $chkDataId; ?>&mode=del&user="+key;
}
//-->
</script>
</head>
<body style="margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<?php
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser']) && (count($_SESSION['groupuser']) != 0)) {
foreach ($_SESSION['groupuser'] as $elem) {
if ($elem['status'] == 0) {
$strUser = $myDBClass->getFieldData('SELECT `username` FROM `tbl_user` WHERE `id`=' .$elem['user']); ?>
<tr>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php echo $strUser; ?></td>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
echo htmlspecialchars(stripslashes($elem['rights']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="width:50px" align="right"><img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18" alt="<?php
echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>" onClick="doDel('<?php
echo $elem['user']; ?>')" style="cursor:pointer"></td>
</tr>
<?php
echo $chkDataId; ?>&mode=del&user=" + key;
}
//-->
</script>
</head>
<body style="margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<?php
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser']) && (count($_SESSION['groupuser']) !== 0)) {
foreach ($_SESSION['groupuser'] as $elem) {
if ((int)$elem['status'] === 0) {
$strUser = $myDBClass->getFieldData('SELECT `username` FROM `tbl_user` WHERE `id`=' . $elem['user']); ?>
<tr>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php echo $strUser; ?></td>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
echo htmlspecialchars(stripslashes($elem['rights']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="width:50px" align="right"><img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18"
alt="<?php
echo translate('Delete'); ?>"
title="<?php echo translate('Delete'); ?>"
onClick="doDel('<?php
echo $elem['user']; ?>')"
style="cursor:pointer"></td>
</tr>
<?php
}
}
} else {
?>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
<td class="tablerow">&nbsp;</td>
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
} else {
?>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
<td class="tablerow">&nbsp;</td>
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
?>
</table>
</body>
?>
</table>
</body>
</html>

View File

@@ -1,88 +1,99 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Help text editor
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Help text editor
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $prePageKey from prepend_adm.php -> Menu group id
* @var array $SETS Settings array
* @var string $chkTfValue1 from prepend_content.php -> (hidden) Stored key value 1
* @var string $chkTfValue2 from prepend_content.php -> (hidden) Stored key value 2
* @var string $chkTfValue3 from prepend_content.php -> (hidden) Stored Nagios version
* @var int $chkChbValue1 from prepend_content.php -> Load standard text
* @var string $chkTaFileTextRaw from prepend_content.php -> Help text area
* @var array $arrDescription from fieldvars.php -> Translated common strings
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 39;
$preContent = 'admin/helpedit.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 39;
$preContent = 'admin/helpedit.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$setSaveLangId = 'private';
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Process post parameters
// =======================
$strErrorMessage = '';
$strInfoMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Process post parameters
*/
$chkHidVersion = filter_input(INPUT_POST, 'hidVersion', 513, array('options' => array('default' => 'all')));
$chkKey1 = filter_input(INPUT_POST, 'selInfoKey1', FILTER_SANITIZE_STRING);
$chkKey2 = filter_input(INPUT_POST, 'selInfoKey2', FILTER_SANITIZE_STRING);
$chkVersion = filter_input(INPUT_POST, 'selInfoVersion', FILTER_SANITIZE_STRING);
//
// Quote special characters
// ==========================
if (get_magic_quotes_gpc() == 0) {
$chkHidVersion = addslashes($chkHidVersion);
$chkKey1 = addslashes($chkKey1);
$chkKey2 = addslashes($chkKey2);
$chkVersion = addslashes($chkVersion);
}
//
// Security function for text fields
// =================================
$chkKey1 = filter_input(INPUT_POST, 'selInfoKey1', FILTER_DEFAULT, array('options' => array('default' => '')));
$chkKey2 = filter_input(INPUT_POST, 'selInfoKey2', FILTER_DEFAULT, array('options' => array('default' => '')));
$chkVersion = filter_input(INPUT_POST, 'selInfoVersion', FILTER_DEFAULT, array('options' => array('default' => '')));
/*
Security function for text fields
*/
$chkHidVersion = $myVisClass->tfSecure($chkHidVersion);
$chkKey1 = $myVisClass->tfSecure($chkKey1);
$chkKey2 = $myVisClass->tfSecure($chkKey2);
$chkVersion = $myVisClass->tfSecure($chkVersion);
//
// Add or modify data
// ==================
if (($chkTaFileTextRaw != '') && ($chkTfValue3 == '1')) {
$strSQL = "SELECT `infotext` FROM `tbl_info` WHERE `key1`='$chkTfValue1' AND `key2`='$chkTfValue2' "
. "AND `version`='$chkHidVersion' AND `language`='$setSaveLangId'";
$chkKey1 = $myVisClass->tfSecure($chkKey1);
$chkKey2 = $myVisClass->tfSecure($chkKey2);
$chkVersion = $myVisClass->tfSecure($chkVersion);
/*
Add or modify data
*/
if (($chkTaFileTextRaw !== '') && ($chkTfValue3 === '1')) {
$strSQL = "SELECT `infotext` FROM `tbl_info` WHERE `key1`='$chkTfValue1' AND `key2`='$chkTfValue2' "
. "AND `version`='$chkHidVersion' AND `language`='$setSaveLangId'";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($intDataCount == 0) {
if ($intDataCount === 0) {
$strSQL = 'INSERT INTO `tbl_info` (`key1`,`key2`,`version`,`language`,`infotext`) '
. "VALUES ('$chkTfValue1','$chkTfValue2','$chkHidVersion','$setSaveLangId','$chkTaFileTextRaw')";
. "VALUES ('$chkTfValue1','$chkTfValue2','$chkHidVersion','$setSaveLangId','$chkTaFileTextRaw')";
} else {
$strSQL = "UPDATE `tbl_info` SET `infotext` = '$chkTaFileTextRaw' WHERE `key1` = '$chkTfValue1' "
. "AND `key2` = '$chkTfValue2' AND `version` = '$chkHidVersion' AND `language` = '$setSaveLangId'";
. "AND `key2` = '$chkTfValue2' AND `version` = '$chkHidVersion' AND `language` = '$setSaveLangId'";
}
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
}
}
//
// Singe data form
// ===============
/*
Singe data form
*/
$conttp->setVariable('TITLE', translate('Help text editor'));
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url']. 'admin.php');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF'));
$conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url'] . 'admin.php');
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
}
@@ -91,88 +102,91 @@ $conttp->setVariable('INFOKEY_2', translate('Sub key'));
$conttp->setVariable('INFO_LANG', translate('Language'));
$conttp->setVariable('INFO_VERSION', translate('Nagios version'));
$conttp->setVariable('LOAD_DEFAULT', translate('Load default text'));
if ($chkChbValue1 == '1') {
if ($chkChbValue1 === 1) {
$conttp->setVariable('DEFAULT_CHECKED', 'checked');
}
//
// Get Key
// =======
$arrData = array();
$strSQL = 'SELECT DISTINCT `key1` FROM `tbl_info` ORDER BY `key1`';
/*
Get Key
*/
$arrData = array();
$strSQL = 'SELECT DISTINCT `key1` FROM `tbl_info` ORDER BY `key1`';
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($intDataCount != 0) {
if ($intDataCount !== 0) {
foreach ($arrData as $elem) {
$conttp->setVariable('INFOKEY_1_VAL', $elem['key1']);
if ($chkKey1 == $elem['key1']) {
if ($chkKey1 === $elem['key1']) {
$conttp->setVariable('INFOKEY_1_SEL', 'selected');
$conttp->setVariable('INFOKEY_1_SEL_VAL', $elem['key1']);
}
/** @noinspection DisconnectedForeachInstructionInspection */
$conttp->parse('infokey1');
}
}
if ($chkKey1 != '') {
$strSQL = "SELECT DISTINCT `key2` FROM `tbl_info` WHERE `key1` = '$chkKey1' ORDER BY `key1`";
if ($chkKey1 !== '') {
$strSQL = "SELECT DISTINCT `key2` FROM `tbl_info` WHERE `key1` = '$chkKey1' ORDER BY `key1`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($intDataCount != 0) {
if ($intDataCount !== 0) {
foreach ($arrData as $elem) {
$conttp->setVariable('INFOKEY_2_VAL', $elem['key2']);
if ($chkKey2 == $elem['key2']) {
if ($chkKey2 === $elem['key2']) {
$conttp->setVariable('INFOKEY_2_SEL', 'selected');
$conttp->setVariable('INFOKEY_2_SEL_VAL', $elem['key2']);
}
/** @noinspection DisconnectedForeachInstructionInspection */
$conttp->parse('infokey2');
}
}
}
if (($chkKey1 != '') && ($chkKey2 != '')) {
$strSQL = 'SELECT DISTINCT `version` FROM `tbl_info` '
. "WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' ORDER BY `version`";
if (($chkKey1 !== '') && ($chkKey2 !== '')) {
$strSQL = 'SELECT DISTINCT `version` FROM `tbl_info` '
. "WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' ORDER BY `version`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($intDataCount != 0) {
if (($intDataCount == 1) && ($chkVersion == '')) {
if ($intDataCount !== 0) {
if (($intDataCount === 1) && ($chkVersion === '')) {
$chkVersion = $arrData[0]['version'];
}
foreach ($arrData as $elem) {
$conttp->setVariable('INFOVERSION_2_VAL', $elem['version']);
if ($chkVersion == $elem['version']) {
if ($chkVersion === $elem['version']) {
$conttp->setVariable('INFOVERSION_2_SEL', 'selected');
$conttp->setVariable('INFOVERSION_2_SEL_VAL', $elem['version']);
}
/** @noinspection DisconnectedForeachInstructionInspection */
$conttp->parse('infoversion');
}
}
}
//
// Insert content
// ==============
if (($chkKey1 != '') && ($chkKey2 != '') && ($chkVersion != '')) {
$strSQL = "SELECT `infotext` FROM `tbl_info` WHERE `key1`='$chkKey1' AND `key2`='$chkKey2' "
. "AND `version`='$chkVersion' AND `language`='$setSaveLangId'";
/*
Insert content
*/
if (($chkKey1 !== '') && ($chkKey2 !== '') && ($chkVersion !== '')) {
$strSQL = "SELECT `infotext` FROM `tbl_info` WHERE `key1`='$chkKey1' AND `key2`='$chkKey2' "
. "AND `version`='$chkVersion' AND `language`='$setSaveLangId'";
$strContentDB = $myDBClass->getFieldData($strSQL);
if (($chkChbValue1 == 1) || ($strContentDB == '')) {
$strSQL = "SELECT `infotext` FROM `tbl_info` WHERE `key1`='$chkKey1' AND `key2`='$chkKey2' "
. "AND `version`='$chkVersion' AND `language`='default'";
if (($chkChbValue1 === 1) || ($strContentDB === '')) {
$strSQL = "SELECT `infotext` FROM `tbl_info` WHERE `key1`='$chkKey1' AND `key2`='$chkKey2' "
. "AND `version`='$chkVersion' AND `language`='default'";
$strContentDB = $myDBClass->getFieldData($strSQL);
}
$conttp->setVariable('DAT_HELPTEXT', $strContentDB);
}
// Messages
if ($strErrorMessage != '') {
/* Messages */
if ($strErrorMessage !== '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
if ($strInfoMessage != '') {
if ($strInfoMessage !== '') {
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
}
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('helpedit');
$conttp->show('helpedit');
//
// Process footer
// ==============
/*
Process footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,123 +1,197 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Host dependencies definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Host dependencies definition
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strSearchWhere from prepend_content.php -> SQL WHERE addon for data search
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkTfValue1 from prepend_content.php -> Configuration name
* @var int $chkSelValue1 from prepend_content.php -> Dependency period
* @var array $chkMselValue1 from prepend_content.php -> Dependent hosts
* @var array $chkMselValue2 from prepend_content.php -> Hosts
* @var array $chkMselValue3 from prepend_content.php -> Dependent hostgroups
* @var array $chkMselValue4 from prepend_content.php -> Hostgroups
* @var int $intMselValue1 from prepend_content.php -> Dependent hosts multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Hosts multiselect status value
* @var int $intMselValue3 from prepend_content.php -> Dependent hostgroups multiselect status value
* @var int $intMselValue4 from prepend_content.php -> Hostgroups multiselect status value
* @var string $chkChbGr1a from prepend_content.php -> Execution failure criteria (o)
* @var string $chkChbGr1b from prepend_content.php -> Execution failure criteria (d)
* @var string $chkChbGr1c from prepend_content.php -> Execution failure criteria (u)
* @var string $chkChbGr1d from prepend_content.php -> Execution failure criteria (p)
* @var string $chkChbGr1e from prepend_content.php -> Execution failure criteria (n)
* @var string $chkChbGr2a from prepend_content.php -> Notification failure criteria (o)
* @var string $chkChbGr2b from prepend_content.php -> Notification failure criteria (d)
* @var string $chkChbGr2c from prepend_content.php -> Notification failure criteria (u)
* @var string $chkChbGr2d from prepend_content.php -> Notification failure criteria (p)
* @var string $chkChbGr2e from prepend_content.php -> Notification failure criteria (n)
* @var int $chkChbValue1 from prepend_content.php -> Inherit parents
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 19;
$preContent = 'admin/hostdependencies.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 19;
$preContent = 'admin/hostdependencies.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'hostdependencies';
$preTableName = 'tbl_hostdependency';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e, 0, -1);
$strNO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e, 0, -1);
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$preTableName = 'tbl_hostdependency';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intDataWarning = 0;
$intRet1 = 0;
$intRet2 = 0;
$intRet3 = 0;
$intRet4 = 0;
$intNoTime = 0;
/*
Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
if (!isset($intMselValue3)) {
$intMselValue3 = 0;
}
if (!isset($intMselValue4)) {
$intMselValue4 = 0;
}
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Data processing
*/
$strEO = substr($chkChbGr1a . $chkChbGr1b . $chkChbGr1c . $chkChbGr1d . $chkChbGr1e, 0, -1);
$strNO = substr($chkChbGr2a . $chkChbGr2b . $chkChbGr2c . $chkChbGr2d . $chkChbGr2e, 0, -1);
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `dependent_host_name`=$intMselValue1, "
. "`host_name`=$intMselValue2, `dependent_hostgroup_name`=$intMselValue3, `hostgroup_name`=$intMselValue4, "
. "`inherits_parent`='$chkChbValue1', `execution_failure_criteria`='$strEO', "
. "`notification_failure_criteria`='$strNO', `dependency_period`=$chkSelValue1, $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if ((($intMselValue1 != 0) && ($intMselValue2 != 0)) || (($intMselValue3 != 0) && ($intMselValue4 != 0)) ||
(($intMselValue1 != 0) && ($intMselValue4 != 0)) || (($intMselValue3 != 0) && ($intMselValue2 != 0))) {
if ($intWriteAccessId === 0) {
if ((($intMselValue1 !== 0) && ($intMselValue2 !== 0)) || (($intMselValue3 !== 0) && ($intMselValue4 !== 0)) ||
(($intMselValue1 !== 0) && ($intMselValue4 !== 0)) || (($intMselValue3 !== 0) && ($intMselValue2 !== 0))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New host dependency inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New host dependency inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Host dependency modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Host dependency modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkHostdependencyToHost_DH',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkHostdependencyToHost_H',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkHostdependencyToHostgroup_DH',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
if (isset($intRet3) && ($intRet3 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
if ($intMselValue4 !== 0) {
$intRet4 = $myDataClass->dataInsertRelation(
'tbl_lnkHostdependencyToHostgroup_H',
$chkDataId,
$chkMselValue4
);
}
if (isset($intRet4) && ($intRet4 != 0)) {
if (isset($intRet4) && ($intRet4 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostdependencyToHost_DH',
$chkDataId,
@@ -126,10 +200,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkHostdependencyToHost_DH', $chkDataId);
}
if ($intRet1 != 0) {
if ($intRet1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostdependencyToHost_H',
$chkDataId,
@@ -138,10 +212,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkHostdependencyToHost_H', $chkDataId);
}
if ($intRet2 != 0) {
if ($intRet2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostdependencyToHostgroup_DH',
$chkDataId,
@@ -150,10 +224,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkHostdependencyToHostgroup_DH', $chkDataId);
}
if ($intRet3 != 0) {
if ($intRet3 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
if ($intMselValue4 !== 0) {
$intRet4 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostdependencyToHostgroup_H',
$chkDataId,
@@ -162,18 +236,18 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkHostdependencyToHostgroup_H', $chkDataId);
}
if ($intRet4 != 0) {
if ($intRet4 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) {
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) !== 0) {
$strInfoMessage = '';
}
//
// Update Import HASH
// ==================
/*
Update Import HASH
*/
$booReturn = $myDataClass->updateHash($preTableName, $chkDataId);
if ($booReturn != 0) {
if ($booReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
@@ -188,29 +262,25 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
/*
Singe data form
*/
if ($chkModus === 'add') {
$conttp->setVariable('TITLE', translate('Define host dependencies (hostdependencies.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Process host selection field
if (isset($arrModifyData['dependent_host_name'])) {
$intFieldId = $arrModifyData['dependent_host_name'];
} else {
$intFieldId = 0;
}
/* Process host selection field */
$intFieldId = $arrModifyData['dependent_host_name'] ?? 0;
$intReturn = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
@@ -219,14 +289,10 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['host_name'])) {
$intFieldId = $arrModifyData['host_name'];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData['host_name'] ?? 0;
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
@@ -235,25 +301,17 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process time period selection field
if (isset($arrModifyData['dependency_period'])) {
$intFieldId = $arrModifyData['dependency_period'];
} else {
$intFieldId = 0;
}
/* Process time period selection field */
$intFieldId = $arrModifyData['dependency_period'] ?? 0;
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'timeperiod', 1, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process host group selection field
if (isset($arrModifyData['dependent_hostgroup_name'])) {
$intFieldId = $arrModifyData['dependent_hostgroup_name'];
} else {
$intFieldId = 0;
}
/* Process host group selection field */
$intFieldId = $arrModifyData['dependent_hostgroup_name'] ?? 0;
$intReturn = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
@@ -262,14 +320,10 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['hostgroup_name'])) {
$intFieldId = $arrModifyData['hostgroup_name'];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData['hostgroup_name'] ?? 0;
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
@@ -278,77 +332,76 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intReturn2 != 0)) {
if (($intReturn1 !== 0) && ($intReturn2 !== 0)) {
$myVisClass->processMessage(translate('Attention, no hosts and hostgroups defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
if ($arrModifyData['inherits_parent'] == 1) {
if ((int)$arrModifyData['inherits_parent'] === 1) {
$conttp->setVariable('ACT_INHERIT', 'checked');
}
foreach (explode(',', $arrModifyData['execution_failure_criteria']) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_EO' . strtoupper($elem) . '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['notification_failure_criteria']) as $elem) {
$conttp->setVariable('DAT_NO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_NO' . strtoupper($elem) . '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define host dependencies (hostdependencies.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Config name'));
$mastertp->setVariable('FIELD_2', translate('Dependent hosts'). ' / ' .translate('Dependent hostgroups'));
$mastertp->setVariable('FIELD_2', translate('Dependent hosts') . ' / ' . translate('Dependent hostgroups'));
$mastertp->setVariable('DISABLE_SORT_2', 'disable');
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process search string */
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
}
$mastertp->setVariable('DISABLE_SORT_2', 'disable');
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -357,16 +410,16 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `id`, `$preKeyField`, `dependent_host_name`, `dependent_hostgroup_name`, `register`, "
/* Get datasets */
$strSQL = "SELECT `id`, `$preKeyField`, `dependent_host_name`, `dependent_hostgroup_name`, `register`, "
. "`active`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND "
. "`access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
. "`access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData(
$mastertp,
$arrDataLines,
@@ -377,7 +430,7 @@ if ($chkModus == 'display') {
40
);
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -387,7 +440,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,123 +1,192 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Host escalation definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Host escalation definition
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strSearchWhere from prepend_content.php -> SQL WHERE addon for data search
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkTfValue1 from prepend_content.php -> Configuration name
* @var int $chkSelValue1 from prepend_content.php -> Escalation period
* @var array $chkMselValue1 from prepend_content.php -> Contacts
* @var array $chkMselValue2 from prepend_content.php -> Contact groups
* @var array $chkMselValue3 from prepend_content.php -> Hosts
* @var array $chkMselValue4 from prepend_content.php -> Hostgroups
* @var int $intMselValue1 from prepend_content.php -> Contacts multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Contact groups multiselect status value
* @var int $intMselValue3 from prepend_content.php -> Hosts multiselect status value
* @var int $intMselValue4 from prepend_content.php -> Hostgroups multiselect status value
* @var string $chkChbGr1a from prepend_content.php -> Escalation options (d)
* @var string $chkChbGr1b from prepend_content.php -> Escalation options (u)
* @var string $chkChbGr1c from prepend_content.php -> Escalation options (r)
* @var string $chkTfNullVal1 from prepend_content.php -> First notification
* @var string $chkTfNullVal2 from prepend_content.php -> Last notification
* @var string $chkTfNullVal3 from prepend_content.php -> Notification interval
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 20;
$preContent = 'admin/hostescalations.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 20;
$preContent = 'admin/hostescalations.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'hostescalation';
$preTableName = 'tbl_hostescalation';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c, 0, -1);
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$preTableName = 'tbl_hostescalation';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intDataWarning = 0;
$intRet1 = 0;
$intRet2 = 0;
$intRet3 = 0;
$intRet4 = 0;
$intNoTime = 0;
/*
Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
if (!isset($intMselValue3)) {
$intMselValue3 = 0;
}
if (!isset($intMselValue4)) {
$intMselValue4 = 0;
}
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Data processing
*/
$strEO = substr($chkChbGr1a . $chkChbGr1b . $chkChbGr1c, 0, -1);
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `host_name`=$intMselValue3, "
. "`hostgroup_name`=$intMselValue4, `contacts`=$intMselValue1, `contact_groups`=$intMselValue2, "
. "`first_notification`=$chkTfNullVal1, `last_notification`=$chkTfNullVal2, "
. "`notification_interval`=$chkTfNullVal3, `escalation_period`='$chkSelValue1', "
. "`escalation_options`='$strEO', $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if ((($intMselValue3 != 0) || ($chkMselValue4 != 0)) && (($intMselValue1 != 0) || ($intMselValue2 != 0)) &&
($chkTfNullVal1 != 'NULL') && ($chkTfNullVal2 != 'NULL') && ($chkTfNullVal3 != 'NULL')) {
if ($intWriteAccessId === 0) {
if ((($intMselValue3 !== 0) || ($chkMselValue4 !== 0)) && (($intMselValue1 !== 0) || ($intMselValue2 !== 0)) &&
($chkTfNullVal1 !== 'NULL') && ($chkTfNullVal2 !== 'NULL') && ($chkTfNullVal3 !== 'NULL')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New host escalation inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New host escalation inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Host escalation modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Host escalation modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkHostescalationToContact',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkHostescalationToContactgroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkHostescalationToHost',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
if (isset($intRet3) && ($intRet3 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
if ($intMselValue4 !== 0) {
$intRet4 = $myDataClass->dataInsertRelation(
'tbl_lnkHostescalationToHostgroup',
$chkDataId,
$chkMselValue4
);
}
if (isset($intRet4) && ($intRet4 != 0)) {
if (isset($intRet4) && ($intRet4 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostescalationToContact',
$chkDataId,
@@ -126,10 +195,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkHostescalationToContact', $chkDataId);
}
if ($intRet1 != 0) {
if ($intRet1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostescalationToContactgroup',
$chkDataId,
@@ -138,10 +207,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkHostescalationToContactgroup', $chkDataId);
}
if ($intRet2 != 0) {
if ($intRet2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostescalationToHost',
$chkDataId,
@@ -150,10 +219,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkHostescalationToHost', $chkDataId);
}
if ($intRet3 != 0) {
if ($intRet3 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
if ($intMselValue4 !== 0) {
$intRet4 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostescalationToHostgroup',
$chkDataId,
@@ -162,18 +231,18 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkHostescalationToHostgroup', $chkDataId);
}
if ($intRet4 != 0) {
if ($intRet4 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) {
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) !== 0) {
$strInfoMessage = '';
}
//
// Update Import HASH
// ==================
/*
Update Import HASH
*/
$booReturn = $myDataClass->updateHash($preTableName, $chkDataId);
if ($booReturn != 0) {
if ($booReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
@@ -188,29 +257,25 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
/*
Singe data form
*/
if ($chkModus === 'add') {
$conttp->setVariable('TITLE', translate('Define host escalation (hostescalations.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Process host and host group selection field
if (isset($arrModifyData['host_name'])) {
$intFieldId = $arrModifyData['host_name'];
} else {
$intFieldId = 0;
}
/* Process host and host group selection field */
$intFieldId = $arrModifyData['host_name'] ?? 0;
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
@@ -219,14 +284,10 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['hostgroup_name'])) {
$intFieldId = $arrModifyData['hostgroup_name'];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData['hostgroup_name'] ?? 0;
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
@@ -235,29 +296,21 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intReturn2 != 0)) {
if (($intReturn1 !== 0) && ($intReturn2 !== 0)) {
$myVisClass->processMessage(translate('Attention, no hosts and hostgroups defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process timeperiod selection field
if (isset($arrModifyData['escalation_period'])) {
$intFieldId = $arrModifyData['escalation_period'];
} else {
$intFieldId = 0;
}
/* Process timeperiod selection field */
$intFieldId = $arrModifyData['escalation_period'] ?? 0;
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'escperiod', 1, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process contact and contact group selection field
if (isset($arrModifyData['contacts'])) {
$intFieldId = $arrModifyData['contacts'];
} else {
$intFieldId = 0;
}
/* Process contact and contact group selection field */
$intFieldId = $arrModifyData['contacts'] ?? 0;
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_contact',
'contact_name',
@@ -266,14 +319,10 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['contact_groups'])) {
$intFieldId = $arrModifyData['contact_groups'];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData['contact_groups'] ?? 0;
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
@@ -282,70 +331,69 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intReturn2 != 0)) {
if (($intReturn1 !== 0) && ($intReturn2 !== 0)) {
$myVisClass->processMessage(translate('Attention, no contacts and contactgroups defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
// Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
// Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
foreach (explode(',', $arrModifyData['escalation_options']) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_EO' . strtoupper($elem) . '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define host escalation (hostescalations.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Config name'));
$mastertp->setVariable('FIELD_2', translate('Hosts'). ' / ' .translate('Host groups'));
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FIELD_2', translate('Hosts') . ' / ' . translate('Host groups'));
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process search string */
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
}
$mastertp->setVariable('DISABLE_SORT_2', 'disable');
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -354,16 +402,16 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `id`, `$preKeyField`, `host_name`, `hostgroup_name`, `register`, `active`, `config_id`, "
/* Get datasets */
$strSQL = "SELECT `id`, `$preKeyField`, `host_name`, `hostgroup_name`, `register`, `active`, `config_id`, "
. "`access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` "
. "IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
. "IN ($strAccess) $strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData(
$mastertp,
$arrDataLines,
@@ -374,7 +422,7 @@ if ($chkModus == 'display') {
40
);
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -384,7 +432,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,70 +1,115 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Host extended information definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Host extended information definition
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strSearchWhere from prepend_content.php -> SQL WHERE addon for data search
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkTfValue1 from prepend_content.php -> Notes
* @var string $chkTfValue2 from prepend_content.php -> Notes URL
* @var string $chkTfValue3 from prepend_content.php -> Action URL
* @var string $chkTfValue4 from prepend_content.php -> Icon image
* @var string $chkTfValue5 from prepend_content.php -> Icon image alt text
* @var string $chkTfValue6 from prepend_content.php -> VRML image
* @var string $chkTfValue7 from prepend_content.php -> Status image
* @var string $chkTfValue8 from prepend_content.php -> 2D coords
* @var string $chkTfValue9 from prepend_content.php -> 3D coords
* @var int $chkSelValue1 from prepend_content.php -> Host
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 21;
$preContent = 'admin/hostextinfo.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 21;
$preContent = 'admin/hostextinfo.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'hostextinfo';
$preTableName = 'tbl_hostextinfo';
$preKeyField = 'host_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$preTableName = 'tbl_hostextinfo';
$preKeyField = 'host_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intDataWarning = 0;
$intNoTime = 0;
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`=$chkSelValue1, `notes`='$chkTfValue1', `notes_url`='$chkTfValue2', "
. "`action_url`='$chkTfValue3', `icon_image`='$chkTfValue4', `icon_image_alt`='$chkTfValue5', "
. "`vrml_image`='$chkTfValue6', `statusmap_image`='$chkTfValue7', `2d_coords`='$chkTfValue8', "
. "`3d_coords`='$chkTfValue9', $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if ($chkSelValue1 != 0) {
if ($intWriteAccessId === 0) {
if ($chkSelValue1 !== 0) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New host extended information inserted:'). ' ' .$chkSelValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New host extended information inserted:') . ' ' . $chkSelValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Host extended information modified:'). ' ' .$chkSelValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Host extended information modified:') . ' ' . $chkSelValue1);
}
}
} else {
@@ -78,92 +123,87 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
/*
Singe data form
*/
if ($chkModus === 'add') {
$conttp->setVariable('TITLE', translate('Define host extended information (hostextinfo.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
if (isset($arrModifyData[$preKeyField])) {
$intFieldId = $arrModifyData[$preKeyField];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData[$preKeyField] ?? 0;
$intReturn1 = $myVisClass->parseSelectSimple('tbl_host', $preKeyField, 'host', 0, $intFieldId);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Attention, no hosts defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define host extended information (hostextinfo.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Host name'));
$mastertp->setVariable('FIELD_2', translate('Notes'));
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`tbl_host`.`$preKeyField` LIKE '%".$strSearchTxt."%' OR `$preTableName`.`notes` "
. "LIKE '%".$strSearchTxt."%' OR `$preTableName`.`notes_url` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process search string */
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`tbl_host`.`$preKeyField` LIKE '%" . $strSearchTxt . "%' OR `$preTableName`.`notes` "
. "LIKE '%" . $strSearchTxt . "%' OR `$preTableName`.`notes_url` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `$preTableName`.`config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `$preTableName`.`config_id`, `notes` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
. "LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField`=`tbl_host`.`id` "
. "WHERE $strDomainWhere $strSearchWhere AND `$preTableName`.`access_group` IN ($strAccess)";
$booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -172,21 +212,21 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `$preTableName`.`id`, `tbl_host`.`$preKeyField`, `$preTableName`.`notes`, "
/* Get datasets */
$strSQL = "SELECT `$preTableName`.`id`, `tbl_host`.`$preKeyField`, `$preTableName`.`notes`, "
. "`$preTableName`.`register`, `$preTableName`.`active`, `$preTableName`.`config_id`, "
. "`$preTableName`.`access_group` FROM `$preTableName` "
. "LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField` = `tbl_host`.`id` "
. "WHERE $strDomainWhere $strSearchWhere AND `$preTableName`.`access_group` IN ($strAccess) $strOrderString "
. "LIMIT $chkLimit,".$SETS['common']['pagelines'];
. "LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'notes');
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -196,7 +236,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,96 +1,151 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Hostgroup definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Hostgroup definition
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var int $chkListId from prepend_adm.php -> Actual dataset id (list view)
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkTfValue1 from prepend_content.php -> Hostgroup name
* @var string $chkTfValue2 from prepend_content.php -> Hostgroup description
* @var string $chkTfValue3 from prepend_content.php -> Notes
* @var string $chkTfValue4 from prepend_content.php -> Notes URL
* @var string $chkTfValue5 from prepend_content.php -> Action URL
* @var array $chkMselValue1 from prepend_content.php -> Members
* @var array $chkMselValue2 from prepend_content.php -> Hostgroup members
* @var int $intMselValue1 from prepend_content.php -> Members multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Hostgroup members multiselect status value
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 10;
$preContent = 'admin/hostgroups.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 10;
$preContent = 'admin/hostgroups.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'hostgroup';
$preTableName = 'tbl_hostgroup';
$preKeyField = 'hostgroup_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$preTableName = 'tbl_hostgroup';
$preKeyField = 'hostgroup_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intDataWarning = 0;
$intRet1 = 0;
$intRet2 = 0;
$intNoTime = 0;
/*
Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, "
. "`hostgroup_members`=$intMselValue2, `notes`='$chkTfValue3', `notes_url`='$chkTfValue4', "
. "`action_url`='$chkTfValue5', $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. "`hostgroup_members`=$intMselValue2, `notes`='$chkTfValue3', `notes_url`='$chkTfValue4', "
. "`action_url`='$chkTfValue5', $preSQLCommon1";
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($intMselValue1 != 0) || ($intVersion >= 3))) {
if ($intWriteAccessId === 0) {
if (($chkTfValue1 !== '') && ($chkTfValue2 !== '') && (($intMselValue1 !== 0) || ($intVersion >= 3))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New host group inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New host group inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Host group modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Host group modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkHostgroupToHost',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkHostgroupToHostgroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostgroupToHost',
$chkDataId,
@@ -99,10 +154,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkHostgroupToHost', $chkDataId);
}
if ($intRet1 != 0) {
if ($intRet1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostgroupToHostgroup',
$chkDataId,
@@ -111,11 +166,11 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkHostgroupToHostgroup', $chkDataId);
}
if ($intRet2 != 0) {
if ($intRet2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2) != 0) {
if (($intRet1 + $intRet2) !== 0) {
$strInfoMessage = '';
}
}
@@ -130,29 +185,25 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
/*
Singe data form
*/
if ($chkModus === 'add') {
$conttp->setVariable('TITLE', translate('Define host groups (hostgroups.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Process host selection field
if (isset($arrModifyData['members'])) {
$intFieldId = $arrModifyData['members'];
} else {
$intFieldId = 0;
}
/* Process host selection field */
$intFieldId = $arrModifyData['members'] ?? 0;
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
@@ -161,19 +212,15 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intVersion < 3)) {
if (($intReturn1 !== 0) && ($intVersion < 3)) {
$myVisClass->processMessage(translate('Attention, no hosts defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process host group selection field
if (isset($arrModifyData['hostgroup_members'])) {
$intFieldId = $arrModifyData['hostgroup_members'];
} else {
$intFieldId = 0;
}
/* Process host group selection field */
$intFieldId = $arrModifyData['hostgroup_members'] ?? 0;
$intReturn2 = $myVisClass->parseSelectMulti(
$preTableName,
$preKeyField,
@@ -183,66 +230,85 @@ if ($chkModus == 'add') {
$intFieldId,
$chkListId
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
if ($intReturn3 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define host groups (hostgroups.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Host group'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' "
. "OR `notes` LIKE '%".$strSearchTxt."%')";
/* Process search string and filter */
$strSearchWhere = '';
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere .= "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%' OR `alias` LIKE '%" . $strSearchTxt . "%' "
. "OR `notes` LIKE '%" . $strSearchTxt . "%') ";
}
// Row sorting
if ($_SESSION['filter'][$preSearchSession]['registered'] !== '') {
$intRegistered = (int)$_SESSION['filter'][$preSearchSession]['registered'];
if ($intRegistered === 1) {
$strSearchWhere .= "AND `register` = '1' ";
}
if ($intRegistered === 2) {
$strSearchWhere .= "AND `register` = '0' ";
}
$mastertp->setVariable('SEL_REGFILTER_' . $intRegistered . '_SELECTED', 'selected');
}
if ($_SESSION['filter'][$preSearchSession]['active'] !== '') {
$intActivated = (int)$_SESSION['filter'][$preSearchSession]['active'];
if ($intActivated === 1) {
$strSearchWhere .= "AND `active` = '1' ";
}
if ($intActivated === 2) {
$strSearchWhere .= "AND `active` = '0' ";
}
$mastertp->setVariable('SEL_ACTIVEFILTER_' . $intActivated . '_SELECTED', 'selected');
}
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
}
// Count datasets
$strSQL1 = "SELECT count(*) AS `number` FROM `$preTableName` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL1 = "SELECT count(*) AS `number` FROM `$preTableName` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL1, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -251,19 +317,19 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL2 = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` "
. "IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL2 = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` "
. "IN ($strAccess) $strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -273,7 +339,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

File diff suppressed because it is too large Load Diff

View File

@@ -1,149 +1,265 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Hosttemplate definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Host template definition
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $chkDomainId from prepend_adm.php -> Configuration domain id
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon2 from prepend_content.php -> Common SQL part 2
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkTfValue1 from prepend_content.php -> Host template name
* @var string $chkTfValue2 from prepend_content.php -> Host template description
* @var string $chkTfValue3 from prepend_content.php -> Notes
* @var string $chkTfValue4 from prepend_content.php -> VRML image
* @var string $chkTfValue5 from prepend_content.php -> Notes URL
* @var string $chkTfValue6 from prepend_content.php -> Status image
* @var string $chkTfValue7 from prepend_content.php -> Action URL
* @var string $chkTfValue8 from prepend_content.php -> Icon image
* @var string $chkTfValue9 from prepend_content.php -> 2D coords
* @var string $chkTfValue10 from prepend_content.php -> Icon image alt text
* @var string $chkTfValue11 from prepend_content.php -> 3D coords
* @var int $chkSelValue1 from prepend_content.php -> Check command
* @var int $chkSelValue2 from prepend_content.php -> Check period
* @var int $chkSelValue3 from prepend_content.php -> Event handler
* @var int $chkSelValue4 from prepend_content.php -> Notification period
* @var array $chkMselValue1 from prepend_content.php -> Parents
* @var array $chkMselValue2 from prepend_content.php -> Host groups
* @var array $chkMselValue3 from prepend_content.php -> Contacts
* @var array $chkMselValue4 from prepend_content.php -> Contact groups
* @var int $intMselValue1 from prepend_content.php -> Parents multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Host groups multiselect status value
* @var int $intMselValue3 from prepend_content.php -> Contacts multiselect status value
* @var int $intMselValue4 from prepend_content.php -> Contact groups multiselect status value
* @var string $chkChbGr1a from prepend_content.php -> Notification options (d)
* @var string $chkChbGr1b from prepend_content.php -> Notification options (u)
* @var string $chkChbGr1c from prepend_content.php -> Notification options (r)
* @var string $chkChbGr1d from prepend_content.php -> Notification options (f)
* @var string $chkChbGr1e from prepend_content.php -> Notification options (w)
* @var string $chkChbGr2a from prepend_content.php -> Initial state (o)
* @var string $chkChbGr2b from prepend_content.php -> Initial state (d)
* @var string $chkChbGr2c from prepend_content.php -> Initial state (u)
* @var string $chkChbGr3a from prepend_content.php -> Flap detection options (o)
* @var string $chkChbGr3b from prepend_content.php -> Flap detection options (d)
* @var string $chkChbGr3c from prepend_content.php -> Flap detection options (u)
* @var string $chkChbGr4a from prepend_content.php -> Stalking options (o)
* @var string $chkChbGr4b from prepend_content.php -> Stalking options (d)
* @var string $chkChbGr4c from prepend_content.php -> Stalking options (u)
* @var int $chkRadValue1 from prepend_content.php -> Parents multiselect options
* @var int $chkRadValue2 from prepend_content.php -> Hosts groups multiselect options
* @var int $chkRadValue3 from prepend_content.php -> Contacts multiselect options
* @var int $chkRadValue4 from prepend_content.php -> Contact groups multiselect options
* @var int $chkRadValue5 from prepend_content.php -> Active checks
* @var int $chkRadValue6 from prepend_content.php -> Passive checks
* @var int $chkRadValue7 from prepend_content.php -> Freshness checks
* @var int $chkRadValue8 from prepend_content.php -> Obsess over service
* @var int $chkRadValue9 from prepend_content.php -> Event handler
* @var int $chkRadValue10 from prepend_content.php -> Flap detection
* @var int $chkRadValue11 from prepend_content.php -> Retain status information
* @var int $chkRadValue12 from prepend_content.php -> Retain non-status information
* @var int $chkRadValue13 from prepend_content.php -> Process performance data
* @var int $chkRadValue14 from prepend_content.php -> Notification
* @var string $chkTfNullVal1 from prepend_content.php -> Retry interval
* @var string $chkTfNullVal2 from prepend_content.php -> Max check attempts
* @var string $chkTfNullVal3 from prepend_content.php -> Check interval
* @var string $chkTfNullVal4 from prepend_content.php -> Freshness threshold
* @var string $chkTfNullVal5 from prepend_content.php -> Low flap threshold
* @var string $chkTfNullVal6 from prepend_content.php -> High flap threshold
* @var string $chkTfNullVal7 from prepend_content.php -> Notification interval
* @var string $chkTfNullVal8 from prepend_content.php -> First notification delay
* @var string $chkTfNullVal9 from prepend_content.php -> Importance
* @var int $intVariables from prepend_content.php -> Form uses variable definitions
* @var int $intTemplates from prepend_content.php -> Form uses template definitions
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 12;
$preContent = 'admin/hosttemplates.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 12;
$preContent = 'admin/hosttemplates.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'hosttemplate';
$preTableName = 'tbl_hosttemplate';
$preKeyField = 'template_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
$strNO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e, 0, -1);
$strIS = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c, 0, -1);
$strFL = substr($chkChbGr3a.$chkChbGr3b.$chkChbGr3c, 0, -1);
$strST = substr($chkChbGr4a.$chkChbGr4b.$chkChbGr4c, 0, -1);
if ($chkSelValue1 != '') {
$preTableName = 'tbl_hosttemplate';
$preKeyField = 'template_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intDataWarning = 0;
$intRet1 = 0;
$intRet2 = 0;
$intRet3 = 0;
$intRet4 = 0;
$intNoTime = 0;
/*
Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
if (!isset($intMselValue3)) {
$intMselValue3 = 0;
}
if (!isset($intMselValue4)) {
$intMselValue4 = 0;
}
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Data processing
*/
$strNO = substr($chkChbGr1a . $chkChbGr1b . $chkChbGr1c . $chkChbGr1d . $chkChbGr1e, 0, -1);
$strIS = substr($chkChbGr2a . $chkChbGr2b . $chkChbGr2c, 0, -1);
$strFL = substr($chkChbGr3a . $chkChbGr3b . $chkChbGr3c, 0, -1);
$strST = substr($chkChbGr4a . $chkChbGr4b . $chkChbGr4c, 0, -1);
if ($chkSelValue1 !== 0) {
for ($i = 1; $i <= 8; $i++) {
$tmpVar = 'chkTfArg'.$i;
$tmpVar = 'chkTfArg' . $i;
$$tmpVar = str_replace('!', '::bang::', $$tmpVar);
if ($$tmpVar != '') {
$chkSelValue1 .= '!' .$$tmpVar;
if ($$tmpVar !== '') {
$chkSelValue1 .= '!' . $$tmpVar;
}
}
}
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `parents`=$intMselValue1, "
. "`parents_tploptions`=$chkRadValue1, `importance`=$chkTfNullVal9, `hostgroups`=$intMselValue2, "
. "`hostgroups_tploptions`=$chkRadValue2, `check_command`='$chkSelValue1', `use_template`=$intTemplates, "
. "`initial_state`='$strIS', `max_check_attempts`=$chkTfNullVal2, `check_interval`=$chkTfNullVal3, "
. "`retry_interval`=$chkTfNullVal1, `active_checks_enabled`=$chkRadValue5, "
. "`passive_checks_enabled`=$chkRadValue6, `check_period`=$chkSelValue2, "
. "`obsess_over_host`=$chkRadValue8, `check_freshness`=$chkRadValue7, "
. "`freshness_threshold`=$chkTfNullVal4, `event_handler`=$chkSelValue3, "
. "`event_handler_enabled`=$chkRadValue9, `low_flap_threshold`=$chkTfNullVal5, "
. "`high_flap_threshold`=$chkTfNullVal6, `flap_detection_enabled`=$chkRadValue10, "
. "`flap_detection_options`='$strFL', `process_perf_data`=$chkRadValue13, "
. "`retain_status_information`=$chkRadValue11, `retain_nonstatus_information`=$chkRadValue12, "
. "`contacts`=$intMselValue3, `contacts_tploptions`=$chkRadValue3, `contact_groups`=$intMselValue4, "
. "`contact_groups_tploptions`=$chkRadValue4, `notification_interval`=$chkTfNullVal7, "
. "`notification_period`=$chkSelValue4, `first_notification_delay`=$chkTfNullVal8, "
. "`notification_options`='$strNO', `notifications_enabled`=$chkRadValue14, `stalking_options`='$strST', "
. "`notes`='$chkTfValue3', `notes_url`='$chkTfValue5', `action_url`='$chkTfValue7', "
. "`icon_image`='$chkTfValue8', `icon_image_alt`='$chkTfValue10', `vrml_image`='$chkTfValue4', "
. "`statusmap_image`='$chkTfValue6', `2d_coords`='$chkTfValue9', `3d_coords`='$chkTfValue11', "
. "`use_variables`=$intVariables, $preSQLCommon2";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. "`parents_tploptions`=$chkRadValue1, `importance`=$chkTfNullVal9, `hostgroups`=$intMselValue2, "
. "`hostgroups_tploptions`=$chkRadValue2, `check_command`='$chkSelValue1', `use_template`=$intTemplates, "
. "`initial_state`='$strIS', `max_check_attempts`=$chkTfNullVal2, `check_interval`=$chkTfNullVal3, "
. "`retry_interval`=$chkTfNullVal1, `active_checks_enabled`=$chkRadValue5, "
. "`passive_checks_enabled`=$chkRadValue6, `check_period`=$chkSelValue2, "
. "`obsess_over_host`=$chkRadValue8, `check_freshness`=$chkRadValue7, "
. "`freshness_threshold`=$chkTfNullVal4, `event_handler`=$chkSelValue3, "
. "`event_handler_enabled`=$chkRadValue9, `low_flap_threshold`=$chkTfNullVal5, "
. "`high_flap_threshold`=$chkTfNullVal6, `flap_detection_enabled`=$chkRadValue10, "
. "`flap_detection_options`='$strFL', `process_perf_data`=$chkRadValue13, "
. "`retain_status_information`=$chkRadValue11, `retain_nonstatus_information`=$chkRadValue12, "
. "`contacts`=$intMselValue3, `contacts_tploptions`=$chkRadValue3, `contact_groups`=$intMselValue4, "
. "`contact_groups_tploptions`=$chkRadValue4, `notification_interval`=$chkTfNullVal7, "
. "`notification_period`=$chkSelValue4, `first_notification_delay`=$chkTfNullVal8, "
. "`notification_options`='$strNO', `notifications_enabled`=$chkRadValue14, `stalking_options`='$strST', "
. "`notes`='$chkTfValue3', `notes_url`='$chkTfValue5', `action_url`='$chkTfValue7', "
. "`icon_image`='$chkTfValue8', `icon_image_alt`='$chkTfValue10', `vrml_image`='$chkTfValue4', "
. "`statusmap_image`='$chkTfValue6', `2d_coords`='$chkTfValue9', `3d_coords`='$chkTfValue11', "
. "`use_variables`=$intVariables, $preSQLCommon2";
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if ($chkTfValue1 != '') {
if ($intWriteAccessId === 0) {
if ($chkTfValue1 !== '') {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New host template inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New host template inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Host template modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Host template modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkHosttemplateToHost',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkHosttemplateToHostgroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkHosttemplateToContact',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
if (isset($intRet3) && ($intRet3 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
if ($intMselValue4 !== 0) {
$intRet4 = $myDataClass->dataInsertRelation(
'tbl_lnkHosttemplateToContactgroup',
$chkDataId,
$chkMselValue4
);
}
if (isset($intRet4) && ($intRet4 != 0)) {
if (isset($intRet4) && ($intRet4 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkHosttemplateToHost',
$chkDataId,
@@ -152,10 +268,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToHost', $chkDataId);
}
if ($intRet1 != 0) {
if ($intRet1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkHosttemplateToHostgroup',
$chkDataId,
@@ -164,10 +280,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToHostgroup', $chkDataId);
}
if ($intRet2 != 0) {
if ($intRet2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkHosttemplateToContact',
$chkDataId,
@@ -176,10 +292,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToContact', $chkDataId);
}
if ($intRet3 != 0) {
if ($intRet3 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
if ($intMselValue4 !== 0) {
$intRet4 = $myDataClass->dataUpdateRelation(
'tbl_lnkHosttemplateToContactgroup',
$chkDataId,
@@ -188,79 +304,78 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToContactgroup', $chkDataId);
}
if ($intRet4 != 0) {
if ($intRet4 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) {
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) !== 0) {
$strInfoMessage = '';
}
//
// Insert/update session data for templates
// ========================================
if ($chkModus == 'modify') {
$strSQL = 'DELETE FROM `tbl_lnkHosttemplateToHosttemplate` WHERE `idMaster`=' .$chkDataId;
/*
Insert/update session data for templates
*/
if ($chkModus === 'modify') {
$strSQL = 'DELETE FROM `tbl_lnkHosttemplateToHosttemplate` WHERE `idMaster`=' . $chkDataId;
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(count($_SESSION['templatedefinition']) != 0)) {
(count($_SESSION['templatedefinition']) !== 0)) {
$intSortId = 1;
/** @noinspection ForeachSourceInspection */
foreach ($_SESSION['templatedefinition'] as $elem) {
if ($elem['status'] == 0) {
$strSQL = 'INSERT INTO `tbl_lnkHosttemplateToHosttemplate` (`idMaster`,`idSlave`, '
. "`idTable`,`idSort`) VALUES ($chkDataId,".$elem['idSlave']. ', '
. $elem['idTable']. ',' .$intSortId. ')';
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn != 0) {
if ((int)$elem['status'] === 0) {
$strSQL = 'INSERT INTO `tbl_lnkHosttemplateToHosttemplate` (`idMaster`,`idSlave`, '
. "`idTable`,`idSort`) VALUES ($chkDataId," . $elem['idSlave'] . ', '
. $elem['idTable'] . ',' . $intSortId . ')';
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
$intSortId++;
}
}
//
// Insert/update session data for free variables
// =============================================
if ($chkModus == 'modify') {
$strSQL = 'SELECT * FROM `tbl_lnkHosttemplateToVariabledefinition` WHERE `idMaster`='
. $chkDataId;
/*
Insert/update session data for free variables
*/
if ($chkModus === 'modify') {
$strSQL = 'SELECT * FROM `tbl_lnkHosttemplateToVariabledefinition` WHERE `idMaster`='
. $chkDataId;
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCount != 0) {
if ($intDataCount !== 0) {
foreach ($arrData as $elem) {
$strSQL = 'DELETE FROM `tbl_variabledefinition` WHERE `id`=' .$elem['idSlave'];
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn != 0) {
$strSQL = 'DELETE FROM `tbl_variabledefinition` WHERE `id`=' . $elem['idSlave'];
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
$strSQL = 'DELETE FROM `tbl_lnkHosttemplateToVariabledefinition` WHERE `idMaster`=' .$chkDataId;
$strSQL = 'DELETE FROM `tbl_lnkHosttemplateToVariabledefinition` WHERE `idMaster`=' . $chkDataId;
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
(count($_SESSION['variabledefinition']) != 0)) {
(count($_SESSION['variabledefinition']) !== 0)) {
foreach ($_SESSION['variabledefinition'] as $elem) {
if ($elem['status'] == 0) {
$strSQL = 'INSERT INTO `tbl_variabledefinition` (`name`,`value`,`last_modified`) '
. "VALUES ('".$elem['definition']."','".$elem['range']."',now())";
if ((int)$elem['status'] === 0) {
$strSQL = 'INSERT INTO `tbl_variabledefinition` (`name`,`value`,`last_modified`) '
. "VALUES ('" . $elem['definition'] . "','" . $elem['range'] . "',now())";
$intReturn1 = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
$strSQL = 'INSERT INTO `tbl_lnkHosttemplateToVariabledefinition` (`idMaster`, '
. "`idSlave`) VALUES ($chkDataId,$intInsertId)";
$strSQL = 'INSERT INTO `tbl_lnkHosttemplateToVariabledefinition` (`idMaster`, '
. "`idSlave`) VALUES ($chkDataId,$intInsertId)";
$intReturn2 = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
@@ -278,76 +393,75 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
/*
Singe data form
*/
if ($chkModus === 'add') {
$conttp->setVariable('TITLE', translate('Host template definition (hosttemplates.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Process template fields
/* Process template fields */
$strWhere = '';
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
$strWhere = 'AND `id` <> ' .$arrModifyData['id'];
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
$strWhere = 'AND `id` <> ' . $arrModifyData['id'];
}
$strSQL1 = "SELECT `id`,`$preKeyField`, `active` FROM `$preTableName` "
. "WHERE `config_id` = $chkDomainId $strWhere ORDER BY `$preKeyField`";
/** @noinspection SqlResolve */
$strSQL1 = "SELECT `id`,`$preKeyField`, `active` FROM `$preTableName` "
. "WHERE `config_id` = $chkDomainId $strWhere ORDER BY `$preKeyField`";
$booReturn1 = $myDBClass->hasDataArray($strSQL1, $arrDataTpl, $intDataCountTpl);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCountTpl != 0) {
if ($intDataCountTpl !== 0) {
/** @var array $arrDataTpl */
foreach ($arrDataTpl as $elem) {
if ($elem['active'] == 0) {
if ($elem['active'] === 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$conttp->setVariable('SPECIAL_STYLE', '');
$conttp->setVariable('SPECIAL_STYLE');
}
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem[$preKeyField], ENT_QUOTES, 'UTF-8').$strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::1');
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem[$preKeyField], ENT_QUOTES, 'UTF-8') . $strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id'] . '::1');
/** @noinspection DisconnectedForeachInstructionInspection */
$conttp->parse('template');
}
}
$strSQL2 = 'SELECT `id`, `name`, `active` FROM `tbl_host` '
. "WHERE `name` <> '' AND `config_id` = $chkDomainId ORDER BY `name`";
$strSQL2 = 'SELECT `id`, `name`, `active` FROM `tbl_host` '
. "WHERE `name` <> '' AND `config_id` = $chkDomainId ORDER BY `name`";
$booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataHpl, $intDataCountHpl);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCountHpl != 0) {
if ($intDataCountHpl !== 0) {
/** @var array $arrDataHpl */
foreach ($arrDataHpl as $elem) {
if ($elem['active'] == 0) {
if ($elem['active'] === 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$conttp->setVariable('SPECIAL_STYLE', '');
$conttp->setVariable('SPECIAL_STYLE');
}
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['name'], ENT_QUOTES, 'UTF-8').$strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::2');
$conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['name'], ENT_QUOTES, 'UTF-8') . $strActive);
$conttp->setVariable('DAT_TEMPLATE_ID', $elem['id'] . '::2');
/** @noinspection DisconnectedForeachInstructionInspection */
$conttp->parse('template');
}
}
// Process host selection field
if (isset($arrModifyData['parents'])) {
$intFieldId = $arrModifyData['parents'];
} else {
$intFieldId = 0;
}
/* Process host selection field */
$intFieldId = $arrModifyData['parents'] ?? 0;
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
@@ -356,15 +470,11 @@ if ($chkModus == 'add') {
0,
$intFieldId
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process hostgroup selection field
if (isset($arrModifyData['hostgroups'])) {
$intFieldId = $arrModifyData['hostgroups'];
} else {
$intFieldId = 0;
}
/* Process hostgroup selection field */
$intFieldId = $arrModifyData['hostgroups'] ?? 0;
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
@@ -373,55 +483,39 @@ if ($chkModus == 'add') {
0,
$intFieldId
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process check command selection field
if (isset($arrModifyData['check_command']) && ($arrModifyData['check_command'] != '')) {
/* Process check command selection field */
if (isset($arrModifyData['check_command']) && ($arrModifyData['check_command'] !== '')) {
$arrCommand = explode('!', $arrModifyData['check_command']);
$intFieldId = $arrCommand[0];
} else {
$intFieldId = 0;
}
$intReturn3 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'hostcommand', 1, $intFieldId);
if ($intReturn3 != 0) {
if ($intReturn3 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process check period selection field
if (isset($arrModifyData['check_period'])) {
$intFieldId = $arrModifyData['check_period'];
} else {
$intFieldId = 0;
}
/* Process check period selection field */
$intFieldId = $arrModifyData['check_period'] ?? 0;
$intReturn4 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'checkperiod', 1, $intFieldId);
if ($intReturn4 != 0) {
if ($intReturn4 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['notification_period'])) {
$intFieldId = $arrModifyData['notification_period'];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData['notification_period'] ?? 0;
$intReturn5 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'notifyperiod', 1, $intFieldId);
if ($intReturn5 != 0) {
if ($intReturn5 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process event handler selection field
if (isset($arrModifyData['event_handler'])) {
$intFieldId = $arrModifyData['event_handler'];
} else {
$intFieldId = 0;
}
/* Process event handler selection field */
$intFieldId = $arrModifyData['event_handler'] ?? 0;
$intReturn6 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'eventhandler', 1, $intFieldId);
if ($intReturn6 != 0) {
if ($intReturn6 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process contact and contact group selection field
if (isset($arrModifyData['contacts'])) {
$intFieldId = $arrModifyData['contacts'];
} else {
$intFieldId = 0;
}
/* Process contact and contact group selection field */
$intFieldId = $arrModifyData['contacts'] ?? 0;
$intReturn7 = $myVisClass->parseSelectMulti(
'tbl_contact',
'contact_name',
@@ -430,14 +524,10 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn7 != 0) {
if ($intReturn7 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['contact_groups'])) {
$intFieldId = $arrModifyData['contact_groups'];
} else {
$intFieldId = 0;
}
$intFieldId = $arrModifyData['contact_groups'] ?? 0;
$intReturn8 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
@@ -446,115 +536,125 @@ if ($chkModus == 'add') {
2,
$intFieldId
);
if ($intReturn8 != 0) {
if ($intReturn8 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn9 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn9 != 0) {
if ($intReturn9 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$strChbFields = 'ACE,PCE,FRE,OBS,EVH,FLE,STI,NSI,PED,NOE,PAR,HOG,COT,COG,TPL';
$myContentClass->addFormInit($conttp, $strChbFields);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo, $strChbFields);
$conttp->setVariable('DAT_ACE' .$arrModifyData['active_checks_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_PCE' .$arrModifyData['passive_checks_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_FRE' .$arrModifyData['check_freshness']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_OBS' .$arrModifyData['obsess_over_host']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_EVH' .$arrModifyData['event_handler_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_FLE' .$arrModifyData['flap_detection_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_STI' .$arrModifyData['retain_status_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_NSI' .$arrModifyData['retain_nonstatus_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_PED' .$arrModifyData['process_perf_data']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_NOE' .$arrModifyData['notifications_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_PAR' .$arrModifyData['parents_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_HOG' .$arrModifyData['hostgroups_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_COT' .$arrModifyData['contacts_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_COG' .$arrModifyData['contact_groups_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_TPL' .$arrModifyData['use_template_tploptions']. '_CHECKED', 'checked');
// Special processing for -1 values - write 'null' to integer fields
$strIntegerfelder = 'max_check_attempts,check_interval,retry_interval,freshness_threshold,low_flap_threshold,';
$conttp->setVariable('DAT_ACE' . $arrModifyData['active_checks_enabled'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_PCE' . $arrModifyData['passive_checks_enabled'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_FRE' . $arrModifyData['check_freshness'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_OBS' . $arrModifyData['obsess_over_host'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_EVH' . $arrModifyData['event_handler_enabled'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_FLE' . $arrModifyData['flap_detection_enabled'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_STI' . $arrModifyData['retain_status_information'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_NSI' . $arrModifyData['retain_nonstatus_information'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_PED' . $arrModifyData['process_perf_data'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_NOE' . $arrModifyData['notifications_enabled'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_PAR' . $arrModifyData['parents_tploptions'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_HOG' . $arrModifyData['hostgroups_tploptions'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_COT' . $arrModifyData['contacts_tploptions'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_COG' . $arrModifyData['contact_groups_tploptions'] . '_CHECKED', 'checked');
$conttp->setVariable('DAT_TPL' . $arrModifyData['use_template_tploptions'] . '_CHECKED', 'checked');
/* Special processing for -1 values - write 'null' to integer fields */
$strIntegerfelder = 'max_check_attempts,check_interval,retry_interval,freshness_threshold,low_flap_threshold,';
$strIntegerfelder .= 'high_flap_threshold,notification_interval,first_notification_delay';
foreach (explode(',', $strIntegerfelder) as $elem) {
if ($arrModifyData[$elem] == -1) {
$conttp->setVariable('DAT_' .strtoupper($elem), 'null');
if ($arrModifyData[$elem] === -1) {
$conttp->setVariable('DAT_' . strtoupper($elem), 'null');
}
}
if ($arrModifyData['check_command'] != '') {
if ($arrModifyData['check_command'] !== '') {
$arrArgument = explode('!', $arrModifyData['check_command']);
foreach ($arrArgument as $key => $value) {
if ($key == 0) {
$conttp->setVariable('IFRAME_SRC', $_SESSION['SETS']['path']['base_url'].
'admin/commandline.php?cname=' .$value);
if ($key === 0) {
$conttp->setVariable('IFRAME_SRC', $_SESSION['SETS']['path']['base_url'] .
'admin/commandline.php?cname=' . $value);
} else {
$value1 = str_replace('::bang::', '!', $value);
$value2 = str_replace('::back::', "\\", $value1);
$conttp->setVariable('DAT_ARG' .$key, htmlentities($value, ENT_QUOTES, 'UTF-8'));
$conttp->setVariable('DAT_ARG' . $key, htmlentities($value, ENT_QUOTES, 'UTF-8'));
}
}
}
// Process option fields
/* Process option fields */
foreach (explode(',', $arrModifyData['initial_state']) as $elem) {
$conttp->setVariable('DAT_IS' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_IS' . strtoupper($elem) . '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['flap_detection_options']) as $elem) {
$conttp->setVariable('DAT_FL' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_FL' . strtoupper($elem) . '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['notification_options']) as $elem) {
$conttp->setVariable('DAT_NO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_NO' . strtoupper($elem) . '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['stalking_options']) as $elem) {
$conttp->setVariable('DAT_ST' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_ST' . strtoupper($elem) . '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Host template definition (hosttemplates.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Host template name'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_REG_VISIBLE', 'visibility: hidden');
/* Process search string and filter */
$strSearchWhere = '';
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%' OR `alias` LIKE '%" . $strSearchTxt . "%') ";
}
// Row sorting
if ($_SESSION['filter'][$preSearchSession]['active'] !== '') {
$intActivated = (int)$_SESSION['filter'][$preSearchSession]['active'];
if ($intActivated === 1) {
$strSearchWhere .= "AND `active` = '1' ";
}
if ($intActivated === 2) {
$strSearchWhere .= "AND `active` = '0' ";
}
$mastertp->setVariable('SEL_ACTIVEFILTER_' . $intActivated . '_SELECTED', 'selected');
}
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
}
// Count datasets
$strSQL1 = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
. "AND `access_group` IN ($strAccess)";
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL1 = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
. "AND `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL1, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -563,22 +663,22 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL2 = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `last_modified`, `config_id`, "
. "`access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` "
. "IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL2 = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `last_modified`, `config_id`, "
. "`access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` "
. "IN ($strAccess) $strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($myContentClass->strErrorMessage != '') {
if ($myContentClass->strErrorMessage !== '') {
$myVisClass->processMessage($myContentClass->strErrorMessage, $strErrorMessage);
}
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -588,7 +688,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,93 +1,109 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin configuration verification
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Data import
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $prePageKey from prepend_adm.php -> Menu group id
* @var int $chkStatus from prepend_adm.php -> (hidden) Status field
* @var string $chkTfSearch from prepend_content.php -> Text search string
* @var mixed $chkMselValue1 from prepend_content.php -> Import file list
* @var int $chkChbValue1 from prepend_content.php -> Overwrite checkbox
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 25;
$preContent = 'admin/import.htm.tpl';
$preAccess = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 25;
$preContent = 'admin/import.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$intModus = 0;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Initialize import class
// =======================
$intModus = 0;
$strErrorMessage = '';
$strInfoMessage = '';
/*
Define common variables
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Initialize import class
*/
$myImportClass = new functions\NagImportClass($_SESSION);
$myImportClass->myDBClass =& $myDBClass;
$myImportClass->myDataClass =& $myDataClass;
$myImportClass->myDBClass =& $myDBClass;
$myImportClass->myDataClass =& $myDataClass;
$myImportClass->myConfigClass =& $myConfigClass;
//
// Get configuration set ID
// ========================
/*
Get configuration set ID
*/
$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
//
// Process form variables
// ======================
if (isset($_FILES['datValue1']) && ($_FILES['datValue1']['name'] != '') && ($chkStatus == 1)) {
// Upload Error
$intConfigId = $arrConfigSet[0];
/*
Process form variables
*/
if (isset($_FILES['datValue1']) && ($_FILES['datValue1']['name'] !== '') && ($chkStatus === 1)) {
/* Upload Error */
if ($_FILES['datValue1']['error'] !== UPLOAD_ERR_OK) {
$myVisClass->processMessage(
translate('File upload error:'). ' ' .$_FILES['filMedia']['error'],
translate('File upload error:') . ' ' . $_FILES['filMedia']['error'],
$strErrorMessage
);
} else {
$intModus = 1;
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_local_imp');
move_uploaded_file($_FILES['datValue1']['tmp_name'], $strFileName);
$intReturn = $myImportClass->fileImport($strFileName, $intConfigId, $chkChbValue1);
if ($intReturn != 0) {
$intReturn = $myImportClass->fileImport($strFileName, $intConfigId, $chkChbValue1);
if ($intReturn !== 0) {
$myVisClass->processMessage($myImportClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myImportClass->strInfoMessage, $strInfoMessage);
$myDataClass->writeLog(translate('File imported - File [overwrite flag]:'). ' ' .
$_FILES['datValue1']['name']. ' [' .$chkChbValue1. ']');
$myDataClass->writeLog(translate('File imported - File [overwrite flag]:') . ' ' .
$_FILES['datValue1']['name'] . ' [' . $chkChbValue1 . ']');
}
}
}
if (($chkMselValue1[0] != '') && ($chkStatus == 1)) {
/** @var array $chkMselValue1 */
if (isset($chkMselValue1[0]) && ($chkMselValue1[0] !== '') && ($chkStatus === 1)) {
foreach ($chkMselValue1 as $elem) {
$intModus = 1;
$intModus = 1;
$myImportClass->strErrorMessage = '';
$myImportClass->strInfoMessage = '';
$intReturn = $myImportClass->fileImport($elem, $intConfigId, $chkChbValue1);
if ($intReturn != 0) {
$myImportClass->strInfoMessage = '';
$intReturn = $myImportClass->fileImport($elem, $intConfigId, $chkChbValue1);
if ($intReturn !== 0) {
$myVisClass->processMessage($myImportClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myImportClass->strInfoMessage, $strInfoMessage);
$myDataClass->writeLog(translate('File imported - File [overwrite flag]:'). ' ' .$elem. ' ['
.$chkChbValue1. ']');
$myDataClass->writeLog(translate('File imported - File [overwrite flag]:') . ' ' . $elem . ' ['
. $chkChbValue1 . ']');
}
}
}
//
// Start content
// =============
/*
Start content
*/
$conttp->setVariable('TITLE', translate('Configuration import'));
$conttp->parse('header');
$conttp->show('header');
@@ -103,19 +119,23 @@ $conttp->setVariable('OVERWRITE', translate('Overwrite database'));
$conttp->setVariable('MAKE', translate('Import'));
$conttp->setVariable('ABORT', translate('Abort'));
$conttp->setVariable('CTRL_INFO', translate('Hold CTRL to select<br>more than one'));
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable('DAT_IMPORTFILE_1', '');
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url'] . 'images/');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF'));
$conttp->setVariable('DAT_IMPORTFILE_1');
$conttp->setVariable('IMPORT_INFO_1', translate('To prevent errors or misconfigurations, you should import your '
. 'configurations in an useful order. We recommend to do it like this:<br><br><b><i>commands -> '
. 'timeperiods -> contacttemplates -> contacts -> contactgroups -> hosttemplates -> hosts -> '
. 'hostgroups -> servicetemplates -> services -> servicegroups</i></b><br><br>'));
$conttp->setVariable('IMPORT_INFO_2', '<span style="color:#FF0000">' .translate('<b>Check your configuration after '
. 'configurations in a useful order. We recommend to do it like this:<br><br><b><i>commands -> '
. 'timeperiods -> contacttemplates -> contacts -> contactgroups -> hosttemplates -> hosts -> '
. 'hostgroups -> servicetemplates -> services -> servicegroups</i></b><br><br>'));
$conttp->setVariable('IMPORT_INFO_2', '<span style="color:#FF0000">' . translate('<b>Check your configuration after '
. 'import!</b><br>In cause of an error or an uncomplete configuration, re-importing the wrong configuration '
. 'can solve the problem.'). '</span>');
. 'can solve the problem.') . '</span>');
$conttp->parse('filelist1');
// Get settings
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
/* Get settings */
$intMethod = 0;
$strMethod = '';
if ($myConfigClass->getConfigValues($intConfigId, 'method', $strMethod) === 0) {
$intMethod = (int)$strMethod;
}
$myConfigClass->getConfigValues($intConfigId, 'basedir', $strBaseDir);
$myConfigClass->getConfigValues($intConfigId, 'hostconfig', $strHostDir);
$myConfigClass->getConfigValues($intConfigId, 'serviceconfig', $strServiceDir);
@@ -124,17 +144,19 @@ $myConfigClass->getConfigValues($intConfigId, 'hostbackup', $strHostBackupDir);
$myConfigClass->getConfigValues($intConfigId, 'servicebackup', $strServiceBackupDir);
$myConfigClass->getConfigValues($intConfigId, 'importdir', $strImportDir);
$myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strNagiosBaseDir);
if ($intMethod == 1) {
// Building local file list
if ($intMethod === 1) {
/* Building local file list */
$arrOutput1 = array();
$myConfigClass->storeDirToArray(
$strBaseDir,
"\.cfg",
'cgi.cfg|nagios.cfg|nrpe.cfg|nsca.cfg',
$arrOutput1,
$strErrorMessage
);
if ($strNagiosBaseDir != $strBaseDir) {
if (file_exists($strBaseDir)) {
$myConfigClass->storeDirToArray(
$strBaseDir,
"\.cfg",
'cgi.cfg|nagios.cfg|nrpe.cfg|nsca.cfg',
$arrOutput1,
$strErrorMessage
);
}
if (file_exists($strNagiosBaseDir) && $strNagiosBaseDir !== $strBaseDir) {
$myConfigClass->storeDirToArray(
$strNagiosBaseDir,
"\.cfg",
@@ -143,53 +165,61 @@ if ($intMethod == 1) {
$strErrorMessage
);
}
$myConfigClass->storeDirToArray($strHostDir, "\.cfg", '', $arrOutput1, $strErrorMessage);
$myConfigClass->storeDirToArray($strServiceDir, "\.cfg", '', $arrOutput1, $strErrorMessage);
$myConfigClass->storeDirToArray($strHostBackupDir, "\.cfg_", '', $arrOutput1, $strErrorMessage);
$myConfigClass->storeDirToArray($strServiceBackupDir, "\.cfg_", '', $arrOutput1, $strErrorMessage);
if (($strImportDir != '') && ($strImportDir != $strBaseDir) && ($strImportDir != $strNagiosBaseDir)) {
if (file_exists($strHostDir)) {
$myConfigClass->storeDirToArray($strHostDir, "\.cfg", '', $arrOutput1, $strErrorMessage);
}
if (file_exists($strServiceDir)) {
$myConfigClass->storeDirToArray($strServiceDir, "\.cfg", '', $arrOutput1, $strErrorMessage);
}
if (file_exists($strHostBackupDir)) {
$myConfigClass->storeDirToArray($strHostBackupDir, "\.cfg_", '', $arrOutput1, $strErrorMessage);
}
if (file_exists($strServiceBackupDir)) {
$myConfigClass->storeDirToArray($strServiceBackupDir, "\.cfg_", '', $arrOutput1, $strErrorMessage);
}
if (($strImportDir !== '') && ($strImportDir !== $strBaseDir) && ($strImportDir !== $strNagiosBaseDir) && file_exists($strImportDir)) {
$myConfigClass->storeDirToArray($strImportDir, "\.cfg", '', $arrOutput1, $strErrorMessage);
}
$arrOutput2=array_unique($arrOutput1);
if (is_array($arrOutput2) && (count($arrOutput2) != 0)) {
$arrOutput2 = array_unique($arrOutput1);
if (is_array($arrOutput2) && (count($arrOutput2) !== 0)) {
foreach ($arrOutput2 as $elem) {
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
if (($chkTfSearch === '') || (substr_count($elem, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_IMPORTFILE_2', $elem);
$conttp->parse('filelist2');
}
}
}
} elseif ($intMethod == 2) {
// Set up basic connection
if ($myConfigClass->getFTPConnection($intConfigId) == '0') {
$arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId, $strBaseDir);
} elseif ($intMethod === 2) {
/* Set up basic connection */
if ($myConfigClass->getFTPConnection($intConfigId) === 0) {
$arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->conFTPConId, $strBaseDir);
if (is_array($arrFiles1)) {
$arrFiles = array_merge($arrFiles, $arrFiles1);
}
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId, $strHostDir);
$arrFiles2 = ftp_nlist($myConfigClass->conFTPConId, $strHostDir);
if (is_array($arrFiles2)) {
$arrFiles = array_merge($arrFiles, $arrFiles2);
}
$arrFiles3 = ftp_nlist($myConfigClass->resConnectId, $strServiceDir);
$arrFiles3 = ftp_nlist($myConfigClass->conFTPConId, $strServiceDir);
if (is_array($arrFiles3)) {
$arrFiles = array_merge($arrFiles, $arrFiles3);
}
$arrFiles4 = ftp_nlist($myConfigClass->resConnectId, $strHostBackupDir);
$arrFiles4 = ftp_nlist($myConfigClass->conFTPConId, $strHostBackupDir);
if (is_array($arrFiles4)) {
$arrFiles = array_merge($arrFiles, $arrFiles4);
}
$arrFiles5 = ftp_nlist($myConfigClass->resConnectId, $strServiceBackupDir);
$arrFiles5 = ftp_nlist($myConfigClass->conFTPConId, $strServiceBackupDir);
if (is_array($arrFiles5)) {
$arrFiles = array_merge($arrFiles, $arrFiles5);
}
if ($strImportDir != '') {
$arrFiles6 = ftp_nlist($myConfigClass->resConnectId, $strImportDir);
if ($strImportDir !== '') {
$arrFiles6 = ftp_nlist($myConfigClass->conFTPConId, $strImportDir);
if (is_array($arrFiles6)) {
$arrFiles = array_merge($arrFiles, $arrFiles6);
}
}
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
if (is_array($arrFiles) && (count($arrFiles) !== 0)) {
foreach ($arrFiles as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
@@ -209,47 +239,47 @@ if ($intMethod == 1) {
if (substr_count($elem, 'nsca.cfg')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
if (($chkTfSearch === '') || (substr_count($elem, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_IMPORTFILE_2', str_replace('//', '/', $elem));
$conttp->parse('filelist2');
}
}
}
ftp_close($myConfigClass->resConnectId);
ftp_close($myConfigClass->conFTPConId);
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
} elseif ($intMethod == 3) {
// Set up basic connection
if ($myConfigClass->getSSHConnection($intConfigId) == '0') {
$arrFiles = array();
$intReturn = $myConfigClass->sendSSHCommand('ls ' .$strBaseDir. '*.cfg', $arrFiles1);
if (($intReturn == 0) && is_array($arrFiles1)) {
} elseif ($intMethod === 3) {
/* Set up basic connection */
if ($myConfigClass->getSSHConnection($intConfigId) === 0) {
$arrFiles = array();
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strBaseDir . '*.cfg', $arrFiles1);
if (($intReturn === 0) && is_array($arrFiles1)) {
$arrFiles = array_merge($arrFiles, $arrFiles1);
}
$intReturn = $myConfigClass->sendSSHCommand('ls ' .$strHostDir. '*.cfg', $arrFiles2);
if (($intReturn == 0) && is_array($arrFiles2)) {
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strHostDir . '*.cfg', $arrFiles2);
if (($intReturn === 0) && is_array($arrFiles2)) {
$arrFiles = array_merge($arrFiles, $arrFiles2);
}
$intReturn = $myConfigClass->sendSSHCommand('ls ' .$strServiceDir. '*.cfg', $arrFiles3);
if (($intReturn == 0) && is_array($arrFiles3)) {
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strServiceDir . '*.cfg', $arrFiles3);
if (($intReturn === 0) && is_array($arrFiles3)) {
$arrFiles = array_merge($arrFiles, $arrFiles3);
}
$intReturn = $myConfigClass->sendSSHCommand('ls ' .$strHostBackupDir. '*.cfg*', $arrFiles4);
if (($intReturn == 0) && is_array($arrFiles4)) {
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strHostBackupDir . '*.cfg*', $arrFiles4);
if (($intReturn === 0) && is_array($arrFiles4)) {
$arrFiles = array_merge($arrFiles, $arrFiles4);
}
$intReturn = $myConfigClass->sendSSHCommand('ls ' .$strServiceBackupDir. '*.cfg*', $arrFiles5);
if (($intReturn == 0) && is_array($arrFiles5)) {
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strServiceBackupDir . '*.cfg*', $arrFiles5);
if (($intReturn === 0) && is_array($arrFiles5)) {
$arrFiles = array_merge($arrFiles, $arrFiles5);
}
if ($strImportDir != '') {
$intReturn = $myConfigClass->sendSSHCommand('ls ' .$strImportDir. '*.cfg', $arrFiles6);
if (($intReturn == 0) && is_array($arrFiles6)) {
if ($strImportDir !== '') {
$intReturn = $myConfigClass->sendSSHCommand('ls ' . $strImportDir . '*.cfg', $arrFiles6);
if (($intReturn === 0) && is_array($arrFiles6)) {
$arrFiles = array_merge($arrFiles, $arrFiles6);
}
}
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
if (is_array($arrFiles) && (count($arrFiles) !== 0)) {
foreach ($arrFiles as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
@@ -269,7 +299,7 @@ if ($intMethod == 1) {
if (substr_count($elem, 'nsca.cfg')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
if (($chkTfSearch === '') || (substr_count($elem, $chkTfSearch) !== 0)) {
$conttp->setVariable('DAT_IMPORTFILE_2', str_replace('//', '/', $elem));
$conttp->parse('filelist2');
}
@@ -279,20 +309,20 @@ if ($intMethod == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
}
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
if ($strErrorMessage != '') {
if ($strErrorMessage !== '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
$conttp->parse('main');
$conttp->show('main');
//
// Process footer
// ==============
/*
Process footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<html lang="en">
<head>
<title>NagiosQL</title>
</head>

View File

@@ -1,44 +1,47 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin information dialog
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Admin information dialog
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
/**
* Class and variable includes
* @var MysqliDbClass $myDBClass MySQL database class
*/
/*
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));
//
// Include preprocessing file
// ==========================
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Include preprocessing file
*/
$preNoMain = 1;
require $preBasePath.'functions/prepend_adm.php';
//
// Process get parameters
// ======================
$chkKey1 = filter_input(INPUT_GET, 'key1', FILTER_SANITIZE_STRING);
$chkKey2 = filter_input(INPUT_GET, 'key2', FILTER_SANITIZE_STRING);
$chkVersion = filter_input(INPUT_GET, 'version', FILTER_SANITIZE_STRING);
//
// Get information data
// ===================================================
if ($chkKey1 == 'admin' and isset($_SESSION['updInfo'])) {
// Exception for version check at admin.php
require $preBasePath . 'functions/prepend_adm.php';
/*
Process get parameters
*/
$chkKey1 = filter_input(INPUT_GET, 'key1');
$chkKey2 = filter_input(INPUT_GET, 'key2');
$chkVersion = filter_input(INPUT_GET, 'version');
/*
Get information data
*/
if ($chkKey1 === 'admin' and isset($_SESSION['updInfo'])) {
/* Exception for version check at admin.php */
$strContentDB = $_SESSION['updInfo'];
} elseif ($chkKey1 == 'settings') {
// Exception for settings page to have gettext translated text
} elseif ($chkKey1 === 'settings') {
/* Exception for settings page to have gettext translated text */
$arrTrans = array(
'txtRootPath' => translate('This is relative path of your NagiosQL Installation'),
'txtBasePath' => translate('This is the absolut path to your NagiosQL Installation'),
@@ -68,42 +71,47 @@ if ($chkKey1 == 'admin' and isset($_SESSION['updInfo'])) {
'txtProxyServer' => translate('Address of your Proxyserver e.g. proxy.yourdomain.com:3128'),
'txtProxyUser' => translate('Username to connect through your proxy (optional)'),
'txtProxyPasswd' => translate('Password to connect through your proxy (optional)'),
'show_parents' => translate('In environments with a high number of host and service objects, the display of the parent objects can be disabled to improve performance. Existing assignments are preserved during modification.')
);
$strContentDB = $arrTrans[$chkKey2];
} elseif ($chkKey1 === 'cmd_arguments') {
/* Get information from tbl_command */
$strSQL = 'SELECT `arg' . $chkVersion . '_info` FROM `tbl_command` WHERE `id`=' . $chkKey2;
$strContentDB = nl2br($myDBClass->getFieldData($strSQL));
} else {
// Get information from tbl_info
$strSQL = 'SELECT `infotext` FROM `tbl_info` ' .
"WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' AND `version` = '$chkVersion' ".
"AND `language` = 'private'";
/* Get information from tbl_info */
$strSQL = 'SELECT `infotext` FROM `tbl_info` ' .
"WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' AND `version` = '$chkVersion' " .
"AND `language` = 'private'";
$strContentDB = $myDBClass->getFieldData($strSQL);
if ($strContentDB == '') {
$strSQL = 'SELECT `infotext` FROM `tbl_info` ' .
"WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' AND `version` = '$chkVersion' ".
"AND `language` = 'default'";
if ($strContentDB === '') {
$strSQL = 'SELECT `infotext` FROM `tbl_info` ' .
"WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' AND `version` = '$chkVersion' " .
"AND `language` = 'default'";
$strContentDB = $myDBClass->getFieldData($strSQL);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo translate('Information PopUp');?></title>
<style type="text/css">
.infobody {
font-family:"Courier New", Courier, monospace;
font-size:12px;
}
</style>
</head>
<body class="infobody">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><?php echo translate('Information PopUp'); ?></title>
<style type="text/css">
.infobody {
font-family: "Courier New", Courier, monospace;
font-size: 12px;
}
</style>
</head>
<body class="infobody">
<?php
if ($strContentDB != '') {
if (trim($strContentDB) !== '') {
echo $strContentDB;
} else {
echo translate('No information available');
}
?>
</body>
</body>
</html>

View File

@@ -1,85 +1,104 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin logbook
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Logbook administration
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main templat
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $prePageKey from prepend_adm.php -> Menu group id
* @var array $SETS Settings array
* @var string $chkTfValue1 from prepend_content.php -> User name
* @var string $chkTfValue2 from prepend_content.php -> User description
* @var string $chkTfSearch from prepend_content.php -> Text search string
* @var int $chkFromLine from prepend_content.php -> Line number
* @var array $arrDescription from fieldvars.php -> Translated common strings
*
*
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 37;
$preContent = 'admin/logbook.htm.tpl';
$preAccess = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 37;
$preContent = 'admin/logbook.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Delete log entries
// ==================
$strErrorMessage = '';
$strInfoMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Delete log entries
*/
$strWhere = '';
if ($chkTfValue1 != '') {
if ($chkTfValue1 !== '') {
$strWhere .= "AND `time` > '$chkTfValue1 00:00:00'";
}
if ($chkTfValue2 != '') {
if ($chkTfValue2 !== '') {
$strWhere .= "AND `time` < '$chkTfValue2 23:59:59'";
}
if ($strWhere != '') {
$strSQL = 'DELETE FROM `tbl_logbook` WHERE 1=1 ';
$strSQL .= $strWhere;
if ($strWhere !== '') {
$strSQL = 'DELETE FROM `tbl_logbook` WHERE `id`<>0 ';
$strSQL .= $strWhere;
$booReturn = $myDBClass->insertData($strSQL);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage(translate('Dataset successfully deleted. Affected rows:'). ' ' .
$myDBClass->intAffectedRows, $strInfoMessage);
$myVisClass->processMessage(translate('Dataset successfully deleted. Affected rows:') . ' ' .
$myDBClass->intAffectedRows, $strInfoMessage);
}
}
//
// Search data
// ===========
if ($chkTfSearch != '') {
/*
Search data
*/
if ($chkTfSearch !== '') {
$strWhere = "WHERE `user` LIKE '%$chkTfSearch%' OR `ipadress` LIKE '%$chkTfSearch%' "
. "OR `domain` LIKE '%$chkTfSearch%' OR `entry` LIKE '%$chkTfSearch%'";
. "OR `domain` LIKE '%$chkTfSearch%' OR `entry` LIKE '%$chkTfSearch%'";
} else {
$strWhere = '';
}
//
// Get data
// ========
/*
Get data
*/
$intNumRows = $myDBClass->getFieldData("SELECT count(*) FROM `tbl_logbook` $strWhere");
if ($intNumRows <= $chkFromLine) {
$chkFromLine = 0;
}
$strSQL = "SELECT DATE_FORMAT(time,'%Y-%m-%d %H:%i:%s') AS `time`, `user`, `ipadress`, `domain`, `entry` "
. "FROM `tbl_logbook` $strWhere ORDER BY `time` DESC LIMIT $chkFromLine,".$SETS['common']['pagelines'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
$strSQL = "SELECT DATE_FORMAT(time,'%Y-%m-%d %H:%i:%s') AS `time`, `user`, `ipadress`, `domain`, `entry` "
. "FROM `tbl_logbook` $strWhere ORDER BY `time` DESC LIMIT $chkFromLine," . $SETS['common']['pagelines'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
//
// Start content
// =============
/*
Start content
*/
$conttp->setVariable('TITLE', translate('View logbook'));
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
@@ -88,33 +107,33 @@ $conttp->setVariable('LANG_ENTRIES_BEFORE', translate('Delete logentries between
$conttp->setVariable('LOCALE', $SETS['data']['locale']);
$conttp->setVariable('LANG_SELECT_DATE', translate('Please supply a start or a stop time at least'));
$conttp->setVariable('LANG_DELETELOG', translate('Do you really want to delete all log entries between the '
. 'selected dates?'));
. 'selected dates?'));
$conttp->setVariable('DAT_SEARCH', $chkTfSearch);
// Legende einblenden
if ($chkFromLine > 1) {
$intPrevNumber = $chkFromLine - 20;
$conttp->setVariable('LANG_PREVIOUS', '<a href="' .filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING).
'?from_line=' .$intPrevNumber. '"><< ' .translate('previous 20 entries'). '</a>');
$conttp->setVariable('LANG_PREVIOUS', '<a href="' . filter_input(INPUT_SERVER, 'PHP_SELF') .
'?from_line=' . $intPrevNumber . '"><< ' . translate('previous 20 entries') . '</a>');
} else {
$conttp->setVariable('LANG_PREVIOUS', '');
$conttp->setVariable('LANG_PREVIOUS');
}
if ($chkFromLine < $intNumRows-20) {
if ($chkFromLine < $intNumRows - 20) {
$intNextNumber = $chkFromLine + 20;
$conttp->setVariable('LANG_NEXT', '<a href="' .filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING).
'?from_line=' .$intNextNumber. '">' .translate('next 20 entries'). ' >></a>');
$conttp->setVariable('LANG_NEXT', '<a href="' . filter_input(INPUT_SERVER, 'PHP_SELF') .
'?from_line=' . $intNextNumber . '">' . translate('next 20 entries') . ' >></a>');
} else {
$conttp->setVariable('LANG_NEXT', '');
$conttp->setVariable('LANG_NEXT');
}
//
// Output log data
// ===============
if ($intDataCount != 0) {
/*
Output log data
*/
if ($intDataCount !== 0) {
for ($i = 0; $i < $intDataCount; $i++) {
// Set default values
if ($arrDataLines[$i]['ipadress'] == '') {
/* Set default values */
if ($arrDataLines[$i]['ipadress'] === '') {
$arrDataLines[$i]['ipadress'] = '&nbsp;';
}
// Insert data values
/* Insert data values */
$conttp->setVariable('DAT_TIME', $arrDataLines[$i]['time']);
$conttp->setVariable('DAT_ACCOUNT', $arrDataLines[$i]['user']);
$conttp->setVariable('DAT_ACTION', $arrDataLines[$i]['entry']);
@@ -123,18 +142,18 @@ if ($intDataCount != 0) {
$conttp->parse('logdatacell');
}
}
$conttp->setVariable('ERRORMESSAGE', '<br>' .$strErrorMessage);
$conttp->setVariable('INFOMESSAGE', '<br>' .$strInfoMessage);
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->setVariable('ERRORMESSAGE', '<br>' . $strErrorMessage);
$conttp->setVariable('INFOMESSAGE', '<br>' . $strInfoMessage);
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('logbooksite');
$conttp->show('logbooksite');
//
// Process footer
// ==============
/*
Process footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,71 +1,88 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Menu access administration
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Menu access administration
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var array $arrDescription from fieldvars.php -> Translated common strings
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var int $chkSelValue1 from prepend_content.php -> Language selector
* @var int $chkSelValue2 from prepend_content.php -> Standard domain selector
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 34;
$preContent = 'admin/menuaccess.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 34;
$preContent = 'admin/menuaccess.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$preNoAccessGrp = 1;
$intFieldId = 0;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Process data
// ============
if (filter_input(INPUT_POST, 'subSave') && ($chkSelValue1 != 0)) {
$intFieldId = 0;
$strErrorMessage = '';
$strInfoMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Process data
*/
if (filter_input(INPUT_POST, 'subSave') && ($chkSelValue1 !== 0)) {
$strSQL = "UPDATE `tbl_menu` SET `mnuGrpId`='$chkSelValue2' WHERE `mnuId`=$chkSelValue1";
$booReturn = $myDBClass->insertData($strSQL);
if ($booReturn == false) {
$booReturn = $myDBClass->insertData($strSQL);
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while inserting the data into the database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage(translate('Data were successfully inserted to the data base!'), $strInfoMessage);
$myDataClass->writeLog(translate('Access group set for menu item:'). ' ' .
$myDBClass->getFieldData("SELECT `mnuName` FROM `tbl_menu` WHERE `mnuId`=$chkSelValue1"));
$myDataClass->writeLog(translate('Access group set for menu item:') . ' ' .
$myDBClass->getFieldData("SELECT `mnuName` FROM `tbl_menu` WHERE `mnuId`=$chkSelValue1"));
}
}
//
// Include content
// ===============
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Define Menu Access Rights'));
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
}
$conttp->setVariable('LANG_ACCESSDESCRIPTION', translate('In order for a user to get access, he needs to be member '
. 'of the group selected here.'));
//
// Auswahlfeld einlesen
// ====================
$strSQL = 'SELECT A.`mnuId` , B.`mnuName` AS `mainitem`, A.`mnuName` AS `subitem`, A.`mnuGrpId` '
. 'FROM `tbl_menu` AS A LEFT JOIN `tbl_menu` AS B ON A.`mnuTopId` = B.`mnuId` '
. 'ORDER BY A.`mnuTopId`, A.`mnuOrderId`';
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
. 'of the group selected here.'));
/*
Read menu item
*/
$strSQL = 'SELECT A.`mnuId` , B.`mnuName` AS `mainitem`, A.`mnuName` AS `subitem`, A.`mnuGrpId` '
. 'FROM `tbl_menu` AS A LEFT JOIN `tbl_menu` AS B ON A.`mnuTopId` = B.`mnuId` '
. 'ORDER BY A.`mnuTopId`, A.`mnuOrderId`';
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -74,35 +91,35 @@ if ($booReturn == false) {
$conttp->parse('submenu');
foreach ($arrDataLines as $elem) {
$conttp->setVariable('SUBMENU_VALUE', $elem['mnuId']);
if ($elem['mainitem'] != '') {
$conttp->setVariable('SUBMENU_NAME', translate($elem['mainitem']). ' - ' .translate($elem['subitem']));
if (($elem['mainitem'] !== null) && ($elem['mainitem'] !== '')) {
$conttp->setVariable('SUBMENU_NAME', translate($elem['mainitem']) . ' - ' . translate($elem['subitem']));
} else {
$conttp->setVariable('SUBMENU_NAME', translate($elem['subitem']));
}
if ($chkSelValue1 == $elem['mnuId']) {
if ($chkSelValue1 === (int)$elem['mnuId']) {
$conttp->setVariable('SUBMENU_SELECTED', 'selected');
$intFieldId = $elem['mnuGrpId'];
}
// Bypass main site
if ($elem['mnuId'] != 1) {
/* Bypass main site */
if ((int)$elem['mnuId'] !== 1) {
$conttp->parse('submenu');
}
}
// Process access group selection field
/* Process access group selection field */
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
}
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// Check access rights for adding new objects
if ($intGlobalWriteAccess == 1) {
/* Check access rights for adding new objects */
if ($intGlobalWriteAccess === 1) {
$conttp->setVariable('DISABLE_SAVE', 'disabled="disabled"');
}
$conttp->parse('menuaccesssite');
$conttp->show('menuaccesssite');
//
// Process footer
// ==============
/*
Process footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,38 +1,47 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin specials overview
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2022 by Martin Willisegger
Project : NagiosQL
Component : Admin specials overview
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var int $chkDomainId from prepend_adm.php
* @var string $setFileVersion from prepend_adm.php
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 2;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 2;
$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Include content
// ===============
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Monitoring'));
$conttp->parse('header');
$conttp->show('header');
@@ -41,72 +50,72 @@ $conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable('INACTIVE', translate('Inactive'));
//
// Include statistical data
// ========================
// Get read access groups
$strAccess = $myVisClass->getAccessGroups('read');
$intAccessGrp8 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=8');
$intAccessGrp9 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=9');
/*
Include statistical data
*/
/* Get read access groups */
$strAccess = $myVisClass->getAccessGroups('read');
$intAccessGrp8 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=8');
$intAccessGrp9 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=9');
$intAccessGrp10 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=10');
$intAccessGrp11 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=11');
$intAccessGrp12 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=12');
$intAccessGrp13 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=13');
if ($myVisClass->checkAccountGroup($intAccessGrp8, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp8, 'read') === 0) {
$conttp->setVariable('NAME', translate('Hosts'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_host` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_host` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intAccessGrp9, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp9, 'read') === 0) {
$conttp->setVariable('NAME', translate('Services'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_service` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_service` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intAccessGrp10, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp10, 'read') === 0) {
$conttp->setVariable('NAME', translate('Host groups'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostgroup` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostgroup` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intAccessGrp11, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp11, 'read') === 0) {
$conttp->setVariable('NAME', translate('Service groups'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicegroup` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicegroup` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intAccessGrp12, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp12, 'read') === 0) {
$conttp->setVariable('NAME', translate('Host templates'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hosttemplate` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hosttemplate` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intAccessGrp13, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp13, 'read') === 0) {
$conttp->setVariable('NAME', translate('Service templates'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicetemplate` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicetemplate` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
$conttp->parse('statistics');
$conttp->parse('main');
$conttp->show('main');
//
// Include Footer
// ==============
/*
Include Footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,64 +1,65 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin timeperiod definitions
// Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2018-04-10 10:48:30 +0200 (Tue, 10 Apr 2018) $
// Author : $LastChangedBy: martin $
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Mutation dialog
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var array $arrDescription from fieldvars.php -> Translated common strings
* @var int $intVersion from prepend_adm.php -> Nagios version
*/
/*
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));
//
// Define common variables
// =======================
$preContent = 'admin/mutdialog.htm.tpl';
//
// Process post parameters
// =======================
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$preContent = 'admin/mutdialog.htm.tpl';
/*
Process post parameters
*/
$intExclude = filter_input(INPUT_GET, 'exclude', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkObject = filter_input(INPUT_GET, 'object', FILTER_SANITIZE_STRING);
//
// Include preprocessing file
// ==========================
$preAccess = 1;
$chkObject = filter_input(INPUT_GET, 'object');
/*
Include preprocessing file
*/
$preAccess = 1;
$preFieldvars = 1;
$preNoMain = 1;
require $preBasePath.'functions/prepend_adm.php';
//
// Include content
// ===============
$preNoMain = 1;
require $preBasePath . 'functions/prepend_adm.php';
/*
Include content
*/
$conttp->setVariable('BASE_PATH', $_SESSION['SETS']['path']['base_url']);
$conttp->setVariable('OPENER_FIELD', $chkObject);
$conttp->parse('header');
$conttp->show('header');
//
// Form
// ====
/*
Form
*/
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
}
$conttp->setVariable('OPENER_FIELD', $chkObject);
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF'));
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url'] . 'images/');
$conttp->setVariable('AVAILABLE', translate('Available'));
$conttp->setVariable('SELECTED', translate('Selected'));
if (($intExclude == 1) || ($intVersion < 3)) {
if (($intExclude === 1) || ($intVersion < 3)) {
$conttp->setVariable('DISABLE_HTML_BEGIN', '<!--');
$conttp->setVariable('DISABLE_HTML_END', '-->');
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
$conttp->show('datainsert');

View File

@@ -1,119 +1,135 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin timeperiod definitions
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Nagios configuration file editor
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\NagConfigClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $prePageKey from prepend_adm.php -> Menu group id
* @var string $chkTaFileText from prepend_content.php -> Text area
* @var array $arrDescription from fieldvars.php -> Translated common strings
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 28;
$preContent = 'admin/nagioscfg.htm.tpl';
$preAccess = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 28;
$preContent = 'admin/nagioscfg.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$intRemoveTmp = 0;
$strConfig = '';
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Get configuration set ID
// ========================
$strConfig = '';
$strErrorMessage = '';
$strInfoMessage = '';
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Get configuration set ID
*/
$intMethod = 0;
$strMethod = '';
$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$intConfigId = (int)$arrConfigSet[0];
if ($myConfigClass->getConfigValues($intConfigId, 'method', $strMethod) === 0) {
$intMethod = (int)$strMethod;
}
$myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strBaseDir);
$myConfigClass->getConfigValues($intConfigId, 'conffile', $strConfigfile);
$strLocalBackup = $strConfigfile. '_old_' .date('YmdHis');
//
// Convert Windows to UNIX
// =======================
$strLocalBackup = $strConfigfile . '_old_' . date('YmdHis');
/* Convert Windows to UNIX */
$chkTaFileText = str_replace("\r\n", "\n", $chkTaFileText);
//
// Process data
// ============
if (($chkTaFileText != '') && ($arrConfigSet[0] != 0)) {
if ($intMethod == 1) {
/*
Process data
*/
if (($chkTaFileText !== '') && ($arrConfigSet[0] !== 0)) {
if ($intMethod === 1) {
if (file_exists($strBaseDir) && (is_writable($strBaseDir) && is_writable($strConfigfile))) {
// Backup config file
/* Backup config file */
$intReturn = $myConfigClass->moveFile('nagiosbasic', basename($strConfigfile), $intConfigId);
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
// Write configuration
/* Write configuration */
$resFile = fopen($strConfigfile, 'wb');
fwrite($resFile, $chkTaFileText);
fclose($resFile);
$myVisClass->processMessage('<span style="color:green">' .translate('Configuration file successfully '
. 'written!'). '</span>', $strInfoMessage);
$myDataClass->writeLog(translate('Configuration successfully written:'). ' ' .$strConfigfile);
$myVisClass->processMessage('<span style="color:green">' . translate('Configuration file successfully '
. 'written!') . '</span>', $strInfoMessage);
$myDataClass->writeLog(translate('Configuration successfully written:') . ' ' . $strConfigfile);
} else {
$myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the '
. 'permissions)!'), $strErrorMessage);
$myDataClass->writeLog(translate('Configuration write failed:'). ' ' .$strConfigfile);
. 'permissions)!'), $strErrorMessage);
$myDataClass->writeLog(translate('Configuration write failed:') . ' ' . $strConfigfile);
}
} elseif (($intMethod == 2) || ($intMethod == 3)) {
// Backup config file
} elseif (($intMethod === 2) || ($intMethod === 3)) {
/* Backup config file */
$intReturn1 = $myConfigClass->moveFile('nagiosbasic', basename($strConfigfile), $intConfigId);
if ($intReturn1 == 1) {
if ($intReturn1 === 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
// Write file to temporary
/* Write file to temporary */
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_conf');
$resFile = fopen($strFileName, 'wb');
fwrite($resFile, $chkTaFileText);
fclose($resFile);
// Copy configuration to remoty system
/* Copy configuration to remoty system */
$intReturn2 = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName, 1);
if ($intReturn2 == 0) {
$myVisClass->processMessage('<span style="color:green">' .translate('Configuration file successfully '
. 'written!'). '</span>', $strInfoMessage);
$myDataClass->writeLog(translate('Configuration successfully written:'). ' ' .$strConfigfile);
unlink($strFileName);
if ($intReturn2 === 0) {
$myVisClass->processMessage('<span style="color:green">' . translate('Configuration file successfully '
. 'written!') . '</span>', $strInfoMessage);
$myDataClass->writeLog(translate('Configuration successfully written:') . ' ' . $strConfigfile);
} else {
$myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the permissions '
. 'on remote system)!'), $strErrorMessage);
$myDataClass->writeLog(translate('Configuration write failed (remote):'). ' ' .$strConfigfile);
unlink($strFileName);
. 'on remote system)!'), $strErrorMessage);
$myDataClass->writeLog(translate('Configuration write failed (remote):') . ' ' . $strConfigfile);
}
unlink($strFileName);
}
} elseif ($arrConfigSet[0] == 0) {
$myVisClass->processMessage(translate('There are no nagios configuration files in common domain, please select a '.
} elseif ($arrConfigSet[0] === 0) {
$myVisClass->processMessage(translate('There are no nagios configuration files in common domain, please select a ' .
'valid domain to edit this files!'), $strErrorMessage);
}
//
// Include content
// ===============
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Nagios main configuration file'));
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url']. 'admin.php');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF'));
$conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url'] . 'admin.php');
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
}
//
// Open configuration
// ==================
if ($intMethod == 1) {
/*
Open configuration
*/
if ($intMethod === 1) {
if (file_exists($strConfigfile) && is_readable($strConfigfile)) {
$resFile = fopen($strConfigfile, 'rb');
$resFile = fopen($strConfigfile, 'rb');
if ($resFile) {
while (!feof($resFile)) {
$strConfig .= fgets($resFile, 1024);
@@ -122,12 +138,12 @@ if ($intMethod == 1) {
} else {
$myVisClass->processMessage(translate('Cannot open the data file (check the permissions)!'), $strErrorMessage);
}
} elseif (($intMethod == 2) || ($intMethod == 3)) {
// Write file to temporary
} elseif (($intMethod === 2) || ($intMethod === 3)) {
/* Write file to temporary */
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_conf');
// Copy configuration from remoty system
$intReturn = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName, 0);
if ($intReturn == 0) {
/* Copy configuration from remoty system */
$intReturn = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName);
if ($intReturn === 0) {
$resFile = fopen($strFileName, 'rb');
if (is_resource($resFile)) {
while (!feof($resFile)) {
@@ -139,27 +155,27 @@ if ($intMethod == 1) {
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
$myDataClass->writeLog(translate('Configuration read failed (remote):'). ' ' .$strErrorMessage);
$myDataClass->writeLog(translate('Configuration read failed (remote):') . ' ' . $strErrorMessage);
if (file_exists($strFileName)) {
unlink($strFileName);
}
}
}
$conttp->setVariable('DAT_NAGIOS_CONFIG', $strConfig);
if ($strErrorMessage != '') {
if ($strErrorMessage !== '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('naginsert');
$conttp->show('naginsert');
//
// Process footer
// ==============
/*
Process footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,96 +1,114 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Password administration
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Password administration
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main Template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $tplHeaderVar from prepend_adm.php -> Header content
* @var int $prePageKey from prepend_adm.php -> Admin access key
* @var array $arrDescription from fieldvars.php -> Translated common strings
* @var array $SETS Settings array
* @var string $chkTfValue1 from prepend_content.php -> Old Password
* @var string $chkTfValue2 from prepend_content.php -> New Password 1
* @var string $chkTfValue3 from prepend_content.php -> New Password 2
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 31;
$preContent = 'admin/password.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 31;
$preContent = 'admin/password.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$preShowHeader = 0;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Change password
// =======================
if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
// Check old password
$strSQL = 'SELECT * FROM `tbl_user` '
. "WHERE `username`='".$_SESSION['username']."' AND `password`=MD5('$chkTfValue1')";
$strErrorMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Change password
*/
if (($chkTfValue1 !== '') && ($chkTfValue2 !== '')) {
/* Check old password */
$strSQL = 'SELECT * FROM `tbl_user` '
. "WHERE `username`='" . $_SESSION['username'] . "' AND `password`=MD5('$chkTfValue1')";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} elseif ($intDataCount == 1) {
// Check equality and password length
if (($chkTfValue2 === $chkTfValue3) && (strlen($chkTfValue2) >=5)) {
// Update database
} elseif ($intDataCount === 1) {
/* Check equality and password length */
if (($chkTfValue2 === $chkTfValue3) && (strlen($chkTfValue2) >= 5)) {
/* Update database */
$strSQLUpdate = "UPDATE `tbl_user` SET `password`=MD5('$chkTfValue2'), `last_login`=NOW() "
. "WHERE `username`='".$_SESSION['username']."'";
. "WHERE `username`='" . $_SESSION['username'] . "'";
$booReturn = $myDBClass->insertData($strSQLUpdate);
if ($booReturn == true) {
if ($booReturn === true) {
$myDataClass->writeLog(translate('Password successfully modified'));
// Force new login
/* Force new login */
$_SESSION['logged_in'] = 0;
$_SESSION['username'] = '';
$_SESSION['userid'] = 0;
$_SESSION['groupadm'] = 0;
$_SESSION['domain'] = 0;
header('Location: ' .$SETS['path']['protocol']. '://' .
filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING).
$_SESSION['SETS']['path']['base_url']. 'index.php');
$_SESSION['username'] = '';
$_SESSION['userid'] = 0;
$_SESSION['groupadm'] = 0;
$_SESSION['domain'] = 0;
header('Location: ' . $SETS['path']['protocol'] . '://' .
filter_input(INPUT_SERVER, 'HTTP_HOST') .
$_SESSION['SETS']['path']['base_url'] . 'index.php');
} else {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
} else {
// New password wrong
/* New password wrong */
$myVisClass->processMessage(
translate('Password too short or password fields do not match!'),
$strErrorMessage
);
}
} else {
// Old password wrong
/* Old password wrong */
$myVisClass->processMessage(translate('The old password is invalid'), $strErrorMessage);
}
} elseif (filter_input(INPUT_POST, 'submit')) {
// Wrong data
/* Wrong data */
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
//
// Output header variable
// ======================
/*
Output header variable
*/
echo $tplHeaderVar;
//
// Include content
// ===============
/*
Include content
*/
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
}
@@ -99,21 +117,21 @@ $conttp->setVariable('LANG_ABORT', translate('Abort'));
$conttp->setVariable('FILL_ALLFIELDS', translate('Please fill in all fields marked with an *'));
$conttp->setVariable('FILL_NEW_PASSWD_NOT_EQUAL', translate('The new passwords don not match!'));
$conttp->setVariable('FILL_NEW_PWDSHORT', translate('The new password is too short - use at least 6 characters!'));
if ($strErrorMessage != '') {
if ($strErrorMessage !== '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF'));
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url'] . 'images/');
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('passwordsite');
$conttp->show('passwordsite');
//
// Include footer
// ==============
/*
Include footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,165 +1,269 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Service dependencies definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Service dependencies definition
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var int $chkActive from prepend_adm.php -> Active checkbox
* @var int $chkRegister from prepend_adm.php -> Register checkbox
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strSearchWhere from prepend_content.php -> SQL WHERE addon for data search
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkSelAccGr from prepend_content.php -> Access group selector
* @var string $chkTfValue1 from prepend_content.php -> Configuration name
* @var int $chkSelValue1 from prepend_content.php -> Dependency period
* @var array $chkMselValue1 from prepend_content.php -> Hosts
* @var array $chkMselValue2 from prepend_content.php -> Dependent hosts
* @var array $chkMselValue3 from prepend_content.php -> Hostgroups
* @var array $chkMselValue4 from prepend_content.php -> Dependent hostgroups
* @var array $chkMselValue5 from prepend_content.php -> Services
* @var array $chkMselValue6 from prepend_content.php -> Dependent services
* @var array $chkMselValue7 from prepend_content.php -> Servicegroups
* @var array $chkMselValue8 from prepend_content.php -> Dependent servicegroups
* @var int $intMselValue1 from prepend_content.php -> Hosts multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Dependent hosts multiselect status value
* @var int $intMselValue3 from prepend_content.php -> Hostgroups multiselect status value
* @var int $intMselValue4 from prepend_content.php -> Dependent hostgroups multiselect status value
* @var int $intMselValue5 from prepend_content.php -> Services multiselect status value
* @var int $intMselValue6 from prepend_content.php -> Dependent services multiselect status value
* @var int $intMselValue7 from prepend_content.php -> Dependent servicegroups multiselect status value
* @var int $intMselValue8 from prepend_content.php -> Hostgroups multiselect status value
* @var string $chkChbGr1a from prepend_content.php -> Execution failure criteria (o)
* @var string $chkChbGr1b from prepend_content.php -> Execution failure criteria (w)
* @var string $chkChbGr1c from prepend_content.php -> Execution failure criteria (u)
* @var string $chkChbGr1d from prepend_content.php -> Execution failure criteria (c)
* @var string $chkChbGr1e from prepend_content.php -> Execution failure criteria (p)
* @var string $chkChbGr1f from prepend_content.php -> Execution failure criteria (n)
* @var string $chkChbGr2a from prepend_content.php -> Notification failure criteria (o)
* @var string $chkChbGr2b from prepend_content.php -> Notification failure criteria (w)
* @var string $chkChbGr2c from prepend_content.php -> Notification failure criteria (u)
* @var string $chkChbGr2d from prepend_content.php -> Notification failure criteria (c)
* @var string $chkChbGr2e from prepend_content.php -> Notification failure criteria (p)
* @var string $chkChbGr2f from prepend_content.php -> Notification failure criteria (n)
* @var int $chkChbValue1 from prepend_content.php -> Inherit parents
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 22;
$preContent = 'admin/servicedependencies.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 22;
$preContent = 'admin/servicedependencies.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'servicedependencies';
$preTableName = 'tbl_servicedependency';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f, 0, -1);
$strNO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f, 0, -1);
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$preTableName = 'tbl_servicedependency';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intDataWarning = 0;
$intRet1 = 0;
$intRet2 = 0;
$intRet3 = 0;
$intRet4 = 0;
$intRet5 = 0;
$intRet6 = 0;
$intRet7 = 0;
$intRet8 = 0;
$intNoTime = 0;
/*
Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
if (!isset($intMselValue3)) {
$intMselValue3 = 0;
}
if (!isset($intMselValue4)) {
$intMselValue4 = 0;
}
if (!isset($intMselValue5)) {
$intMselValue5 = 0;
}
if (!isset($intMselValue6)) {
$intMselValue6 = 0;
}
if (!isset($intMselValue7)) {
$intMselValue7 = 0;
}
if (!isset($intMselValue8)) {
$intMselValue8 = 0;
}
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Data processing
*/
$strEO = substr($chkChbGr1a . $chkChbGr1b . $chkChbGr1c . $chkChbGr1d . $chkChbGr1e . $chkChbGr1f, 0, -1);
$strNO = substr($chkChbGr2a . $chkChbGr2b . $chkChbGr2c . $chkChbGr2d . $chkChbGr2e . $chkChbGr2f, 0, -1);
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `dependent_host_name`=$intMselValue2, `dependent_hostgroup_name`=$intMselValue4, "
. "`dependent_service_description`=$intMselValue6, `dependent_servicegroup_name`=$intMselValue8, "
. "`host_name`=$intMselValue1, `hostgroup_name`=$intMselValue3, `service_description`=$intMselValue5, "
. "`servicegroup_name`=$intMselValue7, `$preKeyField`='$chkTfValue1', `inherits_parent`='$chkChbValue1', "
. "`execution_failure_criteria`='$strEO', `notification_failure_criteria`='$strNO', "
. "`dependency_period`=$chkSelValue1, $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && (($intMselValue5 != 0) || ($intMselValue7 != 0)) &&
(($intMselValue6 != 0) || ($intMselValue8 != 0))) {
if ($intWriteAccessId === 0) {
if (($chkTfValue1 !== '') && (($intMselValue5 !== 0) || ($intMselValue7 !== 0)) &&
(($intMselValue6 !== 0) || ($intMselValue8 !== 0))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New service dependency inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New service dependency inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Service dependency modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Service dependency modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkServicedependencyToHost_H',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkServicedependencyToHost_DH',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkServicedependencyToHostgroup_H',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
if (isset($intRet3) && ($intRet3 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
if ($intMselValue4 !== 0) {
$intRet4 = $myDataClass->dataInsertRelation(
'tbl_lnkServicedependencyToHostgroup_DH',
$chkDataId,
$chkMselValue4
);
}
if (isset($intRet4) && ($intRet4 != 0)) {
if (isset($intRet4) && ($intRet4 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue5 != 0) {
if ($intMselValue5 !== 0) {
$intRet5 = $myDataClass->dataInsertRelation(
'tbl_lnkServicedependencyToService_S',
$chkDataId,
$chkMselValue5
);
}
if (isset($intRet5) && ($intRet5 != 0)) {
if (isset($intRet5) && ($intRet5 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue6 != 0) {
if ($intMselValue6 !== 0) {
$intRet6 = $myDataClass->dataInsertRelation(
'tbl_lnkServicedependencyToService_DS',
$chkDataId,
$chkMselValue6
);
}
if (isset($intRet6) && ($intRet6 != 0)) {
if (isset($intRet6) && ($intRet6 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue7 != 0) {
if ($intMselValue7 !== 0) {
$intRet7 = $myDataClass->dataInsertRelation(
'tbl_lnkServicedependencyToServicegroup_S',
$chkDataId,
$chkMselValue7
);
}
if (isset($intRet7) && ($intRet7 != 0)) {
if (isset($intRet7) && ($intRet7 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue8 != 0) {
if ($intMselValue8 !== 0) {
$intRet8 = $myDataClass->dataInsertRelation(
'tbl_lnkServicedependencyToServicegroup_DS',
$chkDataId,
$chkMselValue8
);
}
if (isset($intRet8) && ($intRet8 != 0)) {
if (isset($intRet8) && ($intRet8 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicedependencyToHost_H',
$chkDataId,
@@ -168,10 +272,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkServicedependencyToHost_H', $chkDataId);
}
if ($intRet1 != 0) {
if ($intRet1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicedependencyToHost_DH',
$chkDataId,
@@ -180,10 +284,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkServicedependencyToHost_DH', $chkDataId);
}
if ($intRet2 != 0) {
if ($intRet2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicedependencyToHostgroup_H',
$chkDataId,
@@ -195,10 +299,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
$chkDataId
);
}
if ($intRet3 != 0) {
if ($intRet3 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
if ($intMselValue4 !== 0) {
$intRet4 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicedependencyToHostgroup_DH',
$chkDataId,
@@ -210,10 +314,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
$chkDataId
);
}
if ($intRet4 != 0) {
if ($intRet4 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue5 != 0) {
if ($intMselValue5 !== 0) {
$intRet5 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicedependencyToService_S',
$chkDataId,
@@ -225,10 +329,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
$chkDataId
);
}
if ($intRet5 != 0) {
if ($intRet5 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue6 != 0) {
if ($intMselValue6 !== 0) {
$intRet6 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicedependencyToService_DS',
$chkDataId,
@@ -240,10 +344,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
$chkDataId
);
}
if ($intRet6 != 0) {
if ($intRet6 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue7 != 0) {
if ($intMselValue7 !== 0) {
$intRet7 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicedependencyToServicegroup_S',
$chkDataId,
@@ -255,10 +359,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
$chkDataId
);
}
if ($intRet7 != 0) {
if ($intRet7 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue8 != 0) {
if ($intMselValue8 !== 0) {
$intRet8 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicedependencyToServicegroup_DS',
$chkDataId,
@@ -270,18 +374,18 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
$chkDataId
);
}
if ($intRet8 != 0) {
if ($intRet8 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6 + $intRet7 + $intRet8) != 0) {
if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6 + $intRet7 + $intRet8) !== 0) {
$strInfoMessage = '';
}
//
// Update Import HASH
// ==================
/*
Update Import HASH
*/
$booReturn = $myDataClass->updateHash($preTableName, $chkDataId);
if ($booReturn != 0) {
if ($booReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
@@ -296,139 +400,125 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if (($chkModus != 'add') && ($chkModus != 'refresh')) {
$chkModus = 'display';
if (($chkModus !== 'add') && ($chkModus !== 'refresh')) {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if (($chkModus == 'add') || ($chkModus == 'refresh')) {
/*
Singe data form
*/
if (($chkModus === 'add') || ($chkModus === 'refresh')) {
$conttp->setVariable('TITLE', translate('Define service dependencies (servicedependencies.cfg)'));
if ($chkModus == 'refresh') {
$_SESSION['refresh']['sd_host'] = $chkMselValue1;
$_SESSION['refresh']['sd_dependent_host'] = $chkMselValue2;
$_SESSION['refresh']['sd_hostgroup'] = $chkMselValue3;
$_SESSION['refresh']['sd_dependent_hostgroup'] = $chkMselValue4;
$_SESSION['refresh']['sd_service'] = $chkMselValue5;
$_SESSION['refresh']['sd_dependent_service'] = $chkMselValue6;
$_SESSION['refresh']['sd_servicegroup'] = $chkMselValue7;
$_SESSION['refresh']['sd_dependent_servicegroup'] = $chkMselValue8;
$myVisClass->arrSession = $_SESSION;
} else {
$_SESSION['refresh']['sd_host'] = $chkMselValue1;
$_SESSION['refresh']['sd_dependent_host'] = $chkMselValue2;
$_SESSION['refresh']['sd_hostgroup'] = $chkMselValue3;
$_SESSION['refresh']['sd_dependent_hostgroup'] = $chkMselValue4;
$_SESSION['refresh']['sd_service'] = $chkMselValue5;
$_SESSION['refresh']['sd_dependent_service'] = $chkMselValue6;
$_SESSION['refresh']['sd_servicegroup'] = $chkMselValue7;
$_SESSION['refresh']['sd_dependent_servicegroup'] = $chkMselValue8;
$_SESSION['refresh']['sd_host'] = $chkMselValue1;
$_SESSION['refresh']['sd_dependent_host'] = $chkMselValue2;
$_SESSION['refresh']['sd_hostgroup'] = $chkMselValue3;
$_SESSION['refresh']['sd_dependent_hostgroup'] = $chkMselValue4;
$_SESSION['refresh']['sd_service'] = $chkMselValue5;
$_SESSION['refresh']['sd_dependent_service'] = $chkMselValue6;
$_SESSION['refresh']['sd_servicegroup'] = $chkMselValue7;
$_SESSION['refresh']['sd_dependent_servicegroup'] = $chkMselValue8;
if ($chkModus !== 'refresh') {
if (isset($arrModifyData['dependent_host_name']) && ($arrModifyData['dependent_host_name'] > 0)) {
$arrTemp = array();
$strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHost_DH` '
. 'WHERE `idMaster` = ' .$arrModifyData['id'];
$strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHost_DH` '
. 'WHERE `idMaster` = ' . $arrModifyData['id'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($booReturn && ($intDC != 0)) {
if ($booReturn && ($intDC !== 0)) {
foreach ($arrData as $elem) {
if ($elem['exclude'] == 1) {
$arrTemp[] = 'e' .$elem['idSlave'];
if ($elem['exclude'] === 1) {
$arrTemp[] = 'e' . $elem['idSlave'];
} else {
$arrTemp[] = $elem['idSlave'];
}
}
}
if ($arrModifyData['dependent_host_name'] == 2) {
if ($arrModifyData['dependent_host_name'] === 2) {
$arrTemp[] = '*';
}
$_SESSION['refresh']['sd_dependent_host'] = $arrTemp;
}
if (isset($arrModifyData['host_name']) && ($arrModifyData['host_name'] > 0)) {
$arrTemp = array();
$strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHost_H` '
. 'WHERE `idMaster` = ' .$arrModifyData['id'];
$strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHost_H` '
. 'WHERE `idMaster` = ' . $arrModifyData['id'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDC != 0) {
if ($intDC !== 0) {
foreach ($arrData as $elem) {
if ($elem['exclude'] == 1) {
$arrTemp[] = 'e' .$elem['idSlave'];
if ($elem['exclude'] === 1) {
$arrTemp[] = 'e' . $elem['idSlave'];
} else {
$arrTemp[] = $elem['idSlave'];
}
}
}
if ($arrModifyData['host_name'] == 2) {
if ($arrModifyData['host_name'] === 2) {
$arrTemp[] = '*';
}
$_SESSION['refresh']['sd_host'] = $arrTemp;
}
if (isset($arrModifyData['dependent_hostgroup_name']) && ($arrModifyData['dependent_hostgroup_name'] > 0)) {
$arrTemp = array();
$strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHostgroup_DH` '
. 'WHERE `idMaster` = ' .$arrModifyData['id'];
$strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHostgroup_DH` '
. 'WHERE `idMaster` = ' . $arrModifyData['id'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDC != 0) {
if ($intDC !== 0) {
foreach ($arrData as $elem) {
if ($elem['exclude'] == 1) {
$arrTemp[] = 'e' .$elem['idSlave'];
if ($elem['exclude'] === 1) {
$arrTemp[] = 'e' . $elem['idSlave'];
} else {
$arrTemp[] = $elem['idSlave'];
}
}
}
if ($arrModifyData['dependent_hostgroup_name'] == 2) {
if ($arrModifyData['dependent_hostgroup_name'] === 2) {
$arrTemp[] = '*';
}
$_SESSION['refresh']['sd_dependent_hostgroup'] = $arrTemp;
$_SESSION['refresh']['sd_dependent_hostgroup'] = $arrTemp;
}
if (isset($arrModifyData['hostgroup_name']) && ($arrModifyData['hostgroup_name'] > 0)) {
$arrTemp = array();
$strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHostgroup_H` '
. 'WHERE `idMaster` = ' .$arrModifyData['id'];
$arrTemp = array();
$strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHostgroup_H` '
. 'WHERE `idMaster` = ' . $arrModifyData['id'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDC != 0) {
if ($intDC !== 0) {
foreach ($arrData as $elem) {
if ($elem['exclude'] == 1) {
$arrTemp[] = 'e' .$elem['idSlave'];
if ($elem['exclude'] === 1) {
$arrTemp[] = 'e' . $elem['idSlave'];
} else {
$arrTemp[] = $elem['idSlave'];
}
}
}
if ($arrModifyData['hostgroup_name'] == 2) {
if ($arrModifyData['hostgroup_name'] === 2) {
$arrTemp[] = '*';
}
$_SESSION['refresh']['sd_hostgroup'] = $arrTemp;
$_SESSION['refresh']['sd_hostgroup'] = $arrTemp;
}
$myVisClass->arrSession = $_SESSION;
}
// Do not show modified time list
$myVisClass->arrSession = $_SESSION;
/* Do not show modified time list */
$intNoTime = 1;
// Process host selection field
if (isset($arrModifyData['dependent_host_name'])) {
$intFieldId = $arrModifyData['dependent_host_name'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue2) && (count($chkMselValue2) != 0)) {
/* Process host selection field */
$intFieldId = $arrModifyData['dependent_host_name'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue2) && (count($chkMselValue2) !== 0)) {
$strRefresh = 'sd_dependent_host';
} else {
$strRefresh = '';
@@ -443,15 +533,11 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['host_name'])) {
$intFieldId = $arrModifyData['host_name'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue1) && (count($chkMselValue1) != 0)) {
$intFieldId = $arrModifyData['host_name'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue1) && (count($chkMselValue1) !== 0)) {
$strRefresh = 'sd_host';
} else {
$strRefresh = '';
@@ -466,29 +552,21 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process time period selection field
if (isset($arrModifyData['dependency_period'])) {
$intFieldId = $arrModifyData['dependency_period'];
} else {
$intFieldId = 0;
}
if ($chkModus == 'refresh') {
/* Process time period selection field */
$intFieldId = $arrModifyData['dependency_period'] ?? 0;
if ($chkModus === 'refresh') {
$intFieldId = $chkSelValue1;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'timeperiod', 1, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process host group selection field
if (isset($arrModifyData['dependent_hostgroup_name'])) {
$intFieldId = $arrModifyData['dependent_hostgroup_name'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue4) && (count($chkMselValue4) != 0)) {
/* Process host group selection field */
$intFieldId = $arrModifyData['dependent_hostgroup_name'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue4) && (count($chkMselValue4) !== 0)) {
$strRefresh = 'sd_dependent_hostgroup';
} else {
$strRefresh = '';
@@ -503,15 +581,11 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['hostgroup_name'])) {
$intFieldId = $arrModifyData['hostgroup_name'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue3) && (count($chkMselValue3) != 0)) {
$intFieldId = $arrModifyData['hostgroup_name'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue3) && (count($chkMselValue3) !== 0)) {
$strRefresh = 'sd_hostgroup';
} else {
$strRefresh = '';
@@ -526,20 +600,16 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intReturn2 != 0)) {
if (($intReturn1 !== 0) && ($intReturn2 !== 0)) {
$myVisClass->processMessage(translate('Attention, no hosts and hostgroups defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process services selection field
if (isset($arrModifyData['dependent_service_description'])) {
$intFieldId = $arrModifyData['dependent_service_description'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue6) && (count($chkMselValue6) != 0)) {
/* Process services selection field */
$intFieldId = $arrModifyData['dependent_service_description'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue6) && (count($chkMselValue6) !== 0)) {
$strRefresh = 'sd_dependent_service';
} else {
$strRefresh = '';
@@ -554,15 +624,11 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['service_description'])) {
$intFieldId = $arrModifyData['service_description'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue5) && (count($chkMselValue5) != 0)) {
$intFieldId = $arrModifyData['service_description'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue5) && (count($chkMselValue5) !== 0)) {
$strRefresh = 'sd_service';
} else {
$strRefresh = '';
@@ -577,16 +643,12 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process servicegroup selection field
if (isset($arrModifyData['dependent_servicegroup_name'])) {
$intFieldId = $arrModifyData['dependent_servicegroup_name'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue8) && (count($chkMselValue8) != 0)) {
/* Process servicegroup selection field */
$intFieldId = $arrModifyData['dependent_servicegroup_name'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue8) && (count($chkMselValue8) !== 0)) {
$strRefresh = 'sd_dependent_servicegroup';
} else {
$strRefresh = '';
@@ -601,15 +663,11 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['servicegroup_name'])) {
$intFieldId = $arrModifyData['servicegroup_name'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue7) && (count($chkMselValue7) != 0)) {
$intFieldId = $arrModifyData['servicegroup_name'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue7) && (count($chkMselValue7) !== 0)) {
$strRefresh = 'sd_servicegroup';
} else {
$strRefresh = '';
@@ -624,102 +682,101 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
if ($chkModus == 'refresh') {
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
if ($chkModus === 'refresh') {
$intFieldId = $chkSelAccGr;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
if ($chkModus == 'refresh') {
if ($chkTfValue1 != '') {
if ($chkModus === 'refresh') {
if ($chkTfValue1 !== '') {
$conttp->setVariable('DAT_CONFIG_NAME', $chkTfValue1);
}
foreach (explode(',', $strEO) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_EO' . strtoupper($elem) . '_CHECKED', 'checked');
}
foreach (explode(',', $strNO) as $elem) {
$conttp->setVariable('DAT_NO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_NO' . strtoupper($elem) . '_CHECKED', 'checked');
}
if ($chkActive != 1) {
$conttp->setVariable('ACT_CHECKED', '');
if ($chkActive !== 1) {
$conttp->setVariable('ACT_CHECKED');
}
if ($chkRegister != 1) {
$conttp->setVariable('REG_CHECKED', '');
if ($chkRegister !== 1) {
$conttp->setVariable('REG_CHECKED');
}
if ($chkChbValue1 == 1) {
if ($chkChbValue1 === 1) {
$conttp->setVariable('ACT_INHERIT', 'checked');
}
if ($chkDataId != 0) {
if ($chkDataId !== 0) {
$conttp->setVariable('DAT_ID', $chkDataId);
$conttp->setVariable('MODUS', 'modify');
}
// Insert data from database in "modify" mode
} elseif (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
} elseif (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
// Setting special data
if ($arrModifyData['inherits_parent'] == 1) {
/* Setting special data */
if ((int)$arrModifyData['inherits_parent'] === 1) {
$conttp->setVariable('ACT_INHERIT', 'checked');
}
foreach (explode(',', $arrModifyData['execution_failure_criteria']) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_EO' . strtoupper($elem) . '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['notification_failure_criteria']) as $elem) {
$conttp->setVariable('DAT_NO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_NO' . strtoupper($elem) . '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define service dependencies (servicedependencies.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Config name'));
$mastertp->setVariable('FIELD_2', translate('Dependent services'));
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process search string */
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
}
$mastertp->setVariable('DISABLE_SORT_2', 'disable');
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -728,16 +785,16 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasetsk
$strSQL = "SELECT `id`, `$preKeyField`, `dependent_service_description`, `register`, `active`, `config_id`, "
/* Get datasets */
$strSQL = "SELECT `id`, `$preKeyField`, `dependent_service_description`, `register`, `active`, `config_id`, "
. "`access_group` FROM `$preTableName`WHERE $strDomainWhere $strSearchWhere AND `access_group` "
. "IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
. "IN ($strAccess) $strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData(
$mastertp,
$arrDataLines,
@@ -748,7 +805,7 @@ if ($chkModus == 'display') {
40
);
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -758,7 +815,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,144 +1,230 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Service escalation definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Service escalation definition
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strSearchWhere from prepend_content.php -> SQL WHERE addon for data search
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkSelAccGr from prepend_content.php -> Access group selector
* @var string $chkTfValue1 from prepend_content.php -> Configuration name
* @var int $chkSelValue1 from prepend_content.php -> Escalation period
* @var array $chkMselValue1 from prepend_content.php -> Hosts
* @var array $chkMselValue2 from prepend_content.php -> Host groups
* @var array $chkMselValue3 from prepend_content.php -> Services
* @var array $chkMselValue4 from prepend_content.php -> Contacts
* @var array $chkMselValue5 from prepend_content.php -> Contact groups
* @var array $chkMselValue6 from prepend_content.php -> Service groups
* @var int $intMselValue1 from prepend_content.php -> Hosts multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Host groups multiselect status value
* @var int $intMselValue3 from prepend_content.php -> Services multiselect status value
* @var int $intMselValue4 from prepend_content.php -> Contacts multiselect status value
* @var int $intMselValue5 from prepend_content.php -> Contact groups multiselect status value
* @var int $intMselValue6 from prepend_content.php -> Service groups multiselect status value
* @var string $chkChbGr1a from prepend_content.php -> Escalation options (w)
* @var string $chkChbGr1b from prepend_content.php -> Escalation options (u)
* @var string $chkChbGr1c from prepend_content.php -> Escalation options (c)
* @var string $chkChbGr1d from prepend_content.php -> Escalation options (r)
* @var string $chkTfNullVal1 from prepend_content.php -> First notification
* @var string $chkTfNullVal2 from prepend_content.php -> Last notification
* @var string $chkTfNullVal3 from prepend_content.php -> Notification interval
* @var int $chkActive from prepend_adm.php -> Active checkbox
* @var int $chkRegister from prepend_adm.php -> Register checkbox
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 23;
$preContent = 'admin/serviceescalations.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 23;
$preContent = 'admin/serviceescalations.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'serviceescalation';
$preTableName = 'tbl_serviceescalation';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d, 0, -1);
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$preTableName = 'tbl_serviceescalation';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intDataWarning = 0;
$intRet1 = 0;
$intRet2 = 0;
$intRet3 = 0;
$intRet4 = 0;
$intRet5 = 0;
$intRet6 = 0;
$intNoTime = 0;
/*
Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
if (!isset($intMselValue3)) {
$intMselValue3 = 0;
}
if (!isset($intMselValue4)) {
$intMselValue4 = 0;
}
if (!isset($intMselValue5)) {
$intMselValue5 = 0;
}
if (!isset($intMselValue6)) {
$intMselValue6 = 0;
}
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Data processing
*/
$strEO = substr($chkChbGr1a . $chkChbGr1b . $chkChbGr1c . $chkChbGr1d, 0, -1);
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `host_name`=$intMselValue1, "
. "`service_description`=$intMselValue3, `hostgroup_name`=$intMselValue2, `contacts`=$intMselValue4, "
. "`contact_groups`=$intMselValue5, `servicegroup_name`=$intMselValue6, `first_notification`=$chkTfNullVal1, "
. "`last_notification`=$chkTfNullVal2, `notification_interval`=$chkTfNullVal3, "
. "`escalation_period`='$chkSelValue1', `escalation_options`='$strEO', $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if ((($intMselValue1 != 0) || ($intMselValue2 != 0) || ($intMselValue6 != 0)) && (($intMselValue3 != 0) ||
($intMselValue6 != 0)) && (($intMselValue5 != 0) || ($intMselValue4 != 0)) && ($chkTfNullVal1 != 'NULL') &&
($chkTfNullVal2 != 'NULL') && ($chkTfNullVal3 != 'NULL')) {
if ($intWriteAccessId === 0) {
if ((($intMselValue1 !== 0) || ($intMselValue2 !== 0) || ($intMselValue6 !== 0)) && (($intMselValue3 !== 0) ||
($intMselValue6 !== 0)) && (($intMselValue5 !== 0) || ($intMselValue4 !== 0)) && ($chkTfNullVal1 !== 'NULL') &&
($chkTfNullVal2 !== 'NULL') && ($chkTfNullVal3 !== 'NULL')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New service escalation inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New service escalation inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Service escalation modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Service escalation modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToHost',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToHostgroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToService',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
if (isset($intRet3) && ($intRet3 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
if ($intMselValue4 !== 0) {
$intRet4 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToContact',
$chkDataId,
$chkMselValue4
);
}
if (isset($intRet4) && ($intRet4 != 0)) {
if (isset($intRet4) && ($intRet4 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue5 != 0) {
if ($intMselValue5 !== 0) {
$intRet5 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToContactgroup',
$chkDataId,
$chkMselValue5
);
}
if (isset($intRet5) && ($intRet5 != 0)) {
if (isset($intRet5) && ($intRet5 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue6 != 0) {
if ($intMselValue6 !== 0) {
$intRet6 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToServicegroup',
$chkDataId,
$chkMselValue6
);
}
if (isset($intRet6) && ($intRet6 != 0)) {
if (isset($intRet6) && ($intRet6 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToHost',
$chkDataId,
@@ -147,10 +233,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkServiceescalationToHost', $chkDataId);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToHostgroup',
$chkDataId,
@@ -159,10 +245,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkServiceescalationToHostgroup', $chkDataId);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
if ($intMselValue3 !== 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToService',
$chkDataId,
@@ -171,10 +257,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkServiceescalationToService', $chkDataId);
}
if (isset($intRet3) && ($intRet3 != 0)) {
if (isset($intRet3) && ($intRet3 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
if ($intMselValue4 !== 0) {
$intRet4 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToContact',
$chkDataId,
@@ -183,10 +269,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkServiceescalationToContact', $chkDataId);
}
if (isset($intRet4) && ($intRet4 != 0)) {
if (isset($intRet4) && ($intRet4 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue5 != 0) {
if ($intMselValue5 !== 0) {
$intRet5 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToContactgroup',
$chkDataId,
@@ -198,10 +284,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
$chkDataId
);
}
if (isset($intRet5) && ($intRet5 != 0)) {
if (isset($intRet5) && ($intRet5 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue6 != 0) {
if ($intMselValue6 !== 0) {
$intRet6 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToServicegroup',
$chkDataId,
@@ -213,18 +299,18 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
$chkDataId
);
}
if (isset($intRet6) && ($intRet6 != 0)) {
if (isset($intRet6) && ($intRet6 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6) != 0) {
if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6) !== 0) {
$strInfoMessage = '';
}
//
// Update Import HASH
// ==================
/*
Update Import HASH
*/
$booReturn = $myDataClass->updateHash($preTableName, $chkDataId);
if ($booReturn != 0) {
if ($booReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
@@ -239,92 +325,80 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if (($chkModus != 'add') && ($chkModus != 'refresh')) {
$chkModus = 'display';
if (($chkModus !== 'add') && ($chkModus !== 'refresh')) {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if (($chkModus == 'add') || ($chkModus == 'refresh')) {
/*
Singe data form
*/
if (($chkModus === 'add') || ($chkModus === 'refresh')) {
$conttp->setVariable('TITLE', translate('Define service escalation (serviceescalations.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Refresh mode
if ($chkModus == 'refresh') {
$_SESSION['refresh']['se_host'] = $chkMselValue1;
$_SESSION['refresh']['se_hostgroup'] = $chkMselValue2;
$_SESSION['refresh']['se_service'] = $chkMselValue3;
$_SESSION['refresh']['se_contact'] = $chkMselValue4;
$_SESSION['refresh']['se_contactgroup'] = $chkMselValue5;
$_SESSION['refresh']['se_servicegroup'] = $chkMselValue6;
$myVisClass->arrSession = $_SESSION;
} else {
$_SESSION['refresh']['se_host'] = $chkMselValue1;
$_SESSION['refresh']['se_hostgroup'] = $chkMselValue2;
$_SESSION['refresh']['se_service'] = $chkMselValue3;
$_SESSION['refresh']['se_contact'] = $chkMselValue4;
$_SESSION['refresh']['se_contactgroup'] = $chkMselValue5;
$_SESSION['refresh']['se_servicegroup'] = $chkMselValue6;
/* Refresh mode */
$_SESSION['refresh']['se_host'] = $chkMselValue1;
$_SESSION['refresh']['se_hostgroup'] = $chkMselValue2;
$_SESSION['refresh']['se_service'] = $chkMselValue3;
$_SESSION['refresh']['se_contact'] = $chkMselValue4;
$_SESSION['refresh']['se_contactgroup'] = $chkMselValue5;
$_SESSION['refresh']['se_servicegroup'] = $chkMselValue6;
if ($chkModus !== 'refresh') {
if (isset($arrModifyData['host_name']) && ($arrModifyData['host_name'] > 0)) {
$arrTemp = array();
$strSQL = 'SELECT `idSlave`, `exclude` '
. 'FROM `tbl_lnkServiceescalationToHost` WHERE `idMaster` = ' .$arrModifyData['id'];
$arrTemp = array();
$strSQL = 'SELECT `idSlave`, `exclude` '
. 'FROM `tbl_lnkServiceescalationToHost` WHERE `idMaster` = ' . $arrModifyData['id'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDC != 0) {
if ($intDC !== 0) {
foreach ($arrData as $elem) {
if ($elem['exclude'] == 1) {
$arrTemp[] = 'e' .$elem['idSlave'];
if ($elem['exclude'] === 1) {
$arrTemp[] = 'e' . $elem['idSlave'];
} else {
$arrTemp[] = $elem['idSlave'];
}
}
}
if ($arrModifyData['host_name'] == 2) {
if ($arrModifyData['host_name'] === 2) {
$arrTemp[] = '*';
}
$_SESSION['refresh']['se_host'] = $arrTemp;
}
if (isset($arrModifyData['hostgroup_name']) && ($arrModifyData['hostgroup_name'] > 0)) {
$arrTemp = array();
$strSQL = 'SELECT `idSlave`, `exclude` '
. 'FROM `tbl_lnkServiceescalationToHostgroup` WHERE `idMaster` = ' .$arrModifyData['id'];
$arrTemp = array();
$strSQL = 'SELECT `idSlave`, `exclude` '
. 'FROM `tbl_lnkServiceescalationToHostgroup` WHERE `idMaster` = ' . $arrModifyData['id'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDC != 0) {
if ($intDC !== 0) {
foreach ($arrData as $elem) {
if ($elem['exclude'] == 1) {
$arrTemp[] = 'e' .$elem['idSlave'];
if ($elem['exclude'] === 1) {
$arrTemp[] = 'e' . $elem['idSlave'];
} else {
$arrTemp[] = $elem['idSlave'];
}
}
}
if ($arrModifyData['hostgroup_name'] == 2) {
if ($arrModifyData['hostgroup_name'] === 2) {
$arrTemp[] = '*';
}
$_SESSION['refresh']['se_hostgroup'] = $arrTemp;
$_SESSION['refresh']['se_hostgroup'] = $arrTemp;
}
$myVisClass->arrSession = $_SESSION;
}
// Process host selection field
if (isset($arrModifyData['host_name'])) {
$intFieldId = $arrModifyData['host_name'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue1) && (count($chkMselValue1) != 0)) {
$myVisClass->arrSession = $_SESSION;
/* Process host selection field */
$intFieldId = $arrModifyData['host_name'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue1) && (count($chkMselValue1) !== 0)) {
$strRefresh = 'se_host';
} else {
$strRefresh = '';
@@ -339,15 +413,11 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['hostgroup_name'])) {
$intFieldId = $arrModifyData['hostgroup_name'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue2) && (count($chkMselValue2) != 0)) {
$intFieldId = $arrModifyData['hostgroup_name'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue2) && (count($chkMselValue2) !== 0)) {
$strRefresh = 'se_hostgroup';
} else {
$strRefresh = '';
@@ -362,33 +432,25 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intReturn2 != 0)) {
if (($intReturn1 !== 0) && ($intReturn2 !== 0)) {
$myVisClass->processMessage(translate('Attention, no hosts and hostgroups defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process time period selection field
if (isset($arrModifyData['escalation_period'])) {
$intFieldId = $arrModifyData['escalation_period'];
} else {
$intFieldId = 0;
}
if ($chkModus == 'refresh') {
/* Process time period selection field */
$intFieldId = $arrModifyData['escalation_period'] ?? 0;
if ($chkModus === 'refresh') {
$intFieldId = $chkSelValue1;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'timeperiod', 1, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process contact and contact group selection field
if (isset($arrModifyData['contacts'])) {
$intFieldId = $arrModifyData['contacts'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue4) && (count($chkMselValue4) != 0)) {
/* Process contact and contact group selection field */
$intFieldId = $arrModifyData['contacts'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue4) && (count($chkMselValue4) !== 0)) {
$strRefresh = 'se_contact';
} else {
$strRefresh = '';
@@ -403,15 +465,11 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['contact_groups'])) {
$intFieldId = $arrModifyData['contact_groups'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue5) && (count($chkMselValue5) != 0)) {
$intFieldId = $arrModifyData['contact_groups'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue5) && (count($chkMselValue5) !== 0)) {
$strRefresh = 'se_contactgroup';
} else {
$strRefresh = '';
@@ -426,20 +484,16 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intReturn2 != 0)) {
if (($intReturn1 !== 0) && ($intReturn2 !== 0)) {
$myVisClass->processMessage(translate('Attention, no contacts and contactgroups defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process services selection field
if (isset($arrModifyData['service_description'])) {
$intFieldId = $arrModifyData['service_description'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue3) && (count($chkMselValue3) != 0)) {
/* Process services selection field */
$intFieldId = $arrModifyData['service_description'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue3) && (count($chkMselValue3) !== 0)) {
$strRefresh = 'se_service';
} else {
$strRefresh = '';
@@ -454,16 +508,12 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process servicegroup selection field
if (isset($arrModifyData['servicegroup_name'])) {
$intFieldId = $arrModifyData['servicegroup_name'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue6) && (count($chkMselValue6) != 0)) {
/* Process servicegroup selection field */
$intFieldId = $arrModifyData['servicegroup_name'] ?? 0;
if (($chkModus === 'refresh') && is_array($chkMselValue6) && (count($chkMselValue6) !== 0)) {
$strRefresh = 'se_servicegroup';
} else {
$strRefresh = '';
@@ -478,99 +528,98 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
-9,
$strRefresh
);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
if ($chkModus == 'refresh') {
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
if ($chkModus === 'refresh') {
$intFieldId = $chkSelAccGr;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
if ($chkModus == 'refresh') {
if ($chkTfNullVal1 != 'NULL') {
if ($chkModus === 'refresh') {
if ($chkTfNullVal1 !== 'NULL') {
$conttp->setVariable('DAT_FIRST_NOTIFICATION', $chkTfNullVal1);
}
if ($chkTfNullVal2 != 'NULL') {
if ($chkTfNullVal2 !== 'NULL') {
$conttp->setVariable('DAT_LAST_NOTIFICATION', $chkTfNullVal2);
}
if ($chkTfNullVal3 != 'NULL') {
if ($chkTfNullVal3 !== 'NULL') {
$conttp->setVariable('DAT_NOTIFICATION_INTERVAL', $chkTfNullVal3);
}
if ($chkTfValue1 != '') {
if ($chkTfValue1 !== '') {
$conttp->setVariable('DAT_CONFIG_NAME', $chkTfValue1);
}
foreach (explode(',', $strEO) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_EO' . strtoupper($elem) . '_CHECKED', 'checked');
}
if ($chkActive != 1) {
$conttp->setVariable('ACT_CHECKED', '');
if ($chkActive !== 1) {
$conttp->setVariable('ACT_CHECKED');
}
if ($chkRegister != 1) {
$conttp->setVariable('REG_CHECKED', '');
if ($chkRegister !== 1) {
$conttp->setVariable('REG_CHECKED');
}
if ($chkDataId != 0) {
if ($chkDataId !== 0) {
$conttp->setVariable('MODUS', 'modify');
$conttp->setVariable('DAT_ID', $chkDataId);
}
// Insert data from database in "modify" mode
} elseif (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
} elseif (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
.'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
// Process option fields
/* Process option fields */
foreach (explode(',', $arrModifyData['escalation_options']) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
$conttp->setVariable('DAT_EO' . strtoupper($elem) . '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define service escalation (serviceescalations.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Config name'));
$mastertp->setVariable('FIELD_2', translate('Services'));
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process search string */
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
}
$mastertp->setVariable('DISABLE_SORT_2', 'disable');
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -579,16 +628,16 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `id`, `$preKeyField`, `service_description`, `register`, `active`, `config_id`, "
/* Get datasets */
$strSQL = "SELECT `id`, `$preKeyField`, `service_description`, `register`, `active`, `config_id`, "
. "`access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN "
. "($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
. "($strAccess) $strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData(
$mastertp,
$arrDataLines,
@@ -599,7 +648,7 @@ if ($chkModus == 'display') {
40
);
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -609,7 +658,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,78 +1,122 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Service extended information definition
// Component : Service escalation definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Service extended information definition
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $chkDomainId from prepend_adm.php -> Configuration domain id
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strSearchWhere from prepend_content.php -> SQL WHERE addon for data search
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkTfValue1 from prepend_content.php -> Notes
* @var string $chkTfValue2 from prepend_content.php -> Notes URL
* @var string $chkTfValue3 from prepend_content.php -> Action URL
* @var string $chkTfValue4 from prepend_content.php -> Icon image
* @var string $chkTfValue5 from prepend_content.php -> Icon image alt text
* @var int $chkSelValue1 from prepend_content.php -> Host
* @var int $chkSelValue2 from prepend_content.php -> Service description
* @var int $chkActive from prepend_adm.php -> Active checkbox
* @var int $chkRegister from prepend_adm.php -> Register checkbox
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 24;
$preContent = 'admin/serviceextinfo.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 24;
$preContent = 'admin/serviceextinfo.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'serviceextinfo';
$preTableName = 'tbl_serviceextinfo';
$preKeyField = 'host_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$preTableName = 'tbl_serviceextinfo';
$preKeyField = 'host_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intDataWarning = 0;
$intNoTime = 0;
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkSelValue1', `service_description`='$chkSelValue2', "
. "`notes`='$chkTfValue1', `notes_url`='$chkTfValue2', `action_url`='$chkTfValue3', "
. "`icon_image`='$chkTfValue4', `icon_image_alt`='$chkTfValue5', $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkSelValue1 != 0) && ($chkSelValue2 != 0)) {
if ($intWriteAccessId === 0) {
if (($chkSelValue1 !== 0) && ($chkSelValue2 !== 0)) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New service extended information inserted:'). ' ' .$chkSelValue1.
'::' .$chkSelValue2);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New service extended information inserted:') . ' ' . $chkSelValue1 .
'::' . $chkSelValue2);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Service extended information modified:'). ' ' .$chkSelValue1.
'::' .$chkSelValue2);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Service extended information modified:') . ' ' . $chkSelValue1 .
'::' . $chkSelValue2);
}
//
// Update Import HASH
// ==================
/*
Update Import HASH
*/
$booReturn = $myDataClass->updateHash($preTableName, $chkDataId);
if ($booReturn != 0) {
if ($booReturn !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
@@ -87,66 +131,57 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if (($chkModus != 'add') && ($chkModus != 'refresh')) {
$chkModus = 'display';
if (($chkModus !== 'add') && ($chkModus !== 'refresh')) {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if (($chkModus == 'add') || ($chkModus == 'refresh')) {
/*
Singe data form
*/
if (($chkModus === 'add') || ($chkModus === 'refresh')) {
$conttp->setVariable('TITLE', translate('Define service extended information (serviceextinfo.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Refresh mode
if ($chkModus == 'refresh') {
$_SESSION['refresh']['se_host'] = $chkSelValue1;
$myVisClass->arrSession = $_SESSION;
} else {
$_SESSION['refresh']['se_host'] = $chkSelValue1;
if (isset($arrModifyData[$preKeyField]) && ($arrModifyData[$preKeyField] != 0)) {
$strSQL = "SELECT `$preKeyField` FROM `$preTableName` WHERE `id` = ".$arrModifyData['id'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($intDC != 0) {
/* Refresh mode */
$_SESSION['refresh']['se_host'] = $chkSelValue1;
if ($chkModus !== 'refresh') {
if (isset($arrModifyData[$preKeyField]) && ($arrModifyData[$preKeyField] !== 0)) {
/** @noinspection SqlResolve */
$strSQL = "SELECT `$preKeyField` FROM `$preTableName` WHERE `id` = " . $arrModifyData['id'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($intDC !== 0) {
$_SESSION['refresh']['se_host'] = $arrData[0][$preKeyField];
}
} else {
$strSQL = 'SELECT `id` FROM `tbl_host` '
/** @noinspection SqlResolve */
$strSQL = 'SELECT `id` FROM `tbl_host` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId ORDER BY `$preKeyField`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($intDC != 0) {
if ($intDC !== 0) {
$_SESSION['refresh']['se_host'] = $arrData[0]['id'];
}
}
$myVisClass->arrSession = $_SESSION;
}
// Process host selection field
if (isset($arrModifyData[$preKeyField])) {
$intFieldId = $arrModifyData[$preKeyField];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && ($chkSelValue1 != 0)) {
$myVisClass->arrSession = $_SESSION;
/* Process host selection field */
$intFieldId = $arrModifyData[$preKeyField] ?? 0;
if (($chkModus === 'refresh') && ($chkSelValue1 !== 0)) {
$intFieldId = $chkSelValue1;
}
$intReturn1 = $myVisClass->parseSelectSimple('tbl_host', $preKeyField, 'host', 0, $intFieldId);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Attention, no hosts defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process service selection field
if (isset($arrModifyData['service_description'])) {
$intFieldId = $arrModifyData['service_description'];
} else {
$intFieldId = 0;
}
/* Process service selection field */
$intFieldId = $arrModifyData['service_description'] ?? 0;
$intReturn1 = $myVisClass->parseSelectSimple(
'tbl_service',
'service_description',
@@ -154,84 +189,83 @@ if (($chkModus == 'add') || ($chkModus == 'refresh')) {
0,
$intFieldId
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
if ($chkModus == 'refresh') {
if ($chkModus === 'refresh') {
$conttp->setVariable('DAT_NOTES', $chkTfValue1);
$conttp->setVariable('DAT_NOTES_URL', $chkTfValue2);
$conttp->setVariable('DAT_ACTION_URL', $chkTfValue3);
$conttp->setVariable('DAT_ICON_IMAGE', $chkTfValue4);
$conttp->setVariable('DAT_ICON_IMAGE_ALT', $chkTfValue5);
if ($chkActive != 1) {
$conttp->setVariable('ACT_CHECKED', '');
if ($chkActive !== 1) {
$conttp->setVariable('ACT_CHECKED');
}
if ($chkRegister != 1) {
$conttp->setVariable('REG_CHECKED', '');
if ($chkRegister !== 1) {
$conttp->setVariable('REG_CHECKED');
}
if ($chkDataId != 0) {
if ($chkDataId !== 0) {
$conttp->setVariable('MODUS', 'modify');
$conttp->setVariable('DAT_ID', $chkDataId);
}
// Insert data from database in "modify" mode
} elseif (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
} elseif (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
.'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define service extended information (serviceextinfo.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Hostname'));
$mastertp->setVariable('FIELD_2', translate('Service'));
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`tbl_host`.`$preKeyField` LIKE '%".$strSearchTxt."%' OR `$preTableName`.`notes` "
. "LIKE '%".$strSearchTxt."%' OR `$preTableName`.`notes_url` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process search string */
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`tbl_host`.`$preKeyField` LIKE '%" . $strSearchTxt . "%' OR `$preTableName`.`notes` "
. "LIKE '%" . $strSearchTxt . "%' OR `$preTableName`.`notes_url` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `$preTableName`.`config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `$preTableName`.`config_id`, `tbl_service`.`service_description` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
. "LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField` = `tbl_host`.`id` "
. "LEFT JOIN `tbl_service` ON `$preTableName`.`service_description` = `tbl_service`.`id` "
. "WHERE $strDomainWhere $strSearchWhere AND `$preTableName`.`access_group` IN ($strAccess)";
$booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -240,20 +274,20 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `$preTableName`.`id`, `tbl_host`.`$preKeyField`, `tbl_service`.`service_description`, "
/* Get datasets */
$strSQL = "SELECT `$preTableName`.`id`, `tbl_host`.`$preKeyField`, `tbl_service`.`service_description`, "
. "`$preTableName`.`notes`, `$preTableName`.`register`, `$preTableName`.`active`, `$preTableName`.`config_id`, "
. "`$preTableName`.`access_group` FROM `$preTableName` "
. "LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField` = `tbl_host`.`id` "
. "LEFT JOIN `tbl_service` ON `$preTableName`.`service_description` = `tbl_service`.`id` "
. "WHERE $strDomainWhere $strSearchWhere AND `$preTableName`.`access_group` IN ($strAccess) $strOrderString "
. "LIMIT $chkLimit,".$SETS['common']['pagelines'];
. "LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData(
$mastertp,
$arrDataLines,
@@ -263,7 +297,7 @@ if ($chkModus == 'display') {
'service_description'
);
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -273,7 +307,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,75 +1,130 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin servicegroup definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Servicegroup definition
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var int $chkListId from prepend_adm.php -> Actual dataset id (list view)
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkTfValue1 from prepend_content.php -> Servicegroup name
* @var string $chkTfValue2 from prepend_content.php -> Servicegroup description
* @var string $chkTfValue3 from prepend_content.php -> Notes
* @var string $chkTfValue4 from prepend_content.php -> Notes URL
* @var string $chkTfValue5 from prepend_content.php -> Action URL
* @var array $chkMselValue1 from prepend_content.php -> Members
* @var array $chkMselValue2 from prepend_content.php -> Servicegroup members
* @var int $intMselValue1 from prepend_content.php -> Members multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Servicegroup members multiselect status value
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 11;
$preContent = 'admin/servicegroups.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 11;
$preContent = 'admin/servicegroups.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'servicegroup';
$preTableName = 'tbl_servicegroup';
$preKeyField = 'servicegroup_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$preTableName = 'tbl_servicegroup';
$preKeyField = 'servicegroup_name';
$preAccess = 1;
$preFieldvars = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
$strDBWarning = '';
$intDataWarning = 0;
$intRet1 = 0;
$intRet2 = 0;
$intNoTime = 0;
/*
Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, "
. "`servicegroup_members`=$intMselValue2, `notes`='$chkTfValue3', `notes_url`='$chkTfValue4', "
. "`action_url`='$chkTfValue5', $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. "`servicegroup_members`=$intMselValue2, `notes`='$chkTfValue3', `notes_url`='$chkTfValue4', "
. "`action_url`='$chkTfValue5', $preSQLCommon1";
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($intMselValue1 != 0) || ($intVersion >= 3))) {
if ($intWriteAccessId === 0) {
if (($chkTfValue1 !== '') && ($chkTfValue2 !== '') && (($intMselValue1 !== 0) || ($intVersion >= 3))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New service group inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New service group inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Service group modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Service group modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkServicegroupToService',
$chkDataId,
@@ -77,21 +132,21 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkServicegroupToServicegroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicegroupToService',
$chkDataId,
@@ -101,10 +156,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkServicegroupToService', $chkDataId);
}
if ($intRet1 != 0) {
if ($intRet1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicegroupToServicegroup',
$chkDataId,
@@ -113,11 +168,11 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkServicegroupToServicegroup', $chkDataId);
}
if ($intRet2 != 0) {
if ($intRet2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2) != 0) {
if (($intRet1 + $intRet2) !== 0) {
$strInfoMessage = '';
}
}
@@ -132,29 +187,25 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
/*
Singe data form
*/
if ($chkModus === 'add') {
$conttp->setVariable('TITLE', translate('Define service groups (servicegroups.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Process service selection field
if (isset($arrModifyData['members'])) {
$intFieldId = $arrModifyData['members'];
} else {
$intFieldId = 0;
}
/* Process service selection field */
$intFieldId = $arrModifyData['members'] ?? 0;
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_service',
'service_description',
@@ -163,19 +214,15 @@ if ($chkModus == 'add') {
0,
$intFieldId
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intVersion < 3)) {
if (($intReturn1 !== 0) && ($intVersion < 3)) {
$myVisClass->processMessage(translate('Attention, no services defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process service group selection field
if (isset($arrModifyData['servicegroup_members'])) {
$intFieldId = $arrModifyData['servicegroup_members'];
} else {
$intFieldId = 0;
}
/* Process service group selection field */
$intFieldId = $arrModifyData['servicegroup_members'] ?? 0;
$intReturn2 = $myVisClass->parseSelectMulti(
$preTableName,
$preKeyField,
@@ -185,66 +232,85 @@ if ($chkModus == 'add') {
$intFieldId,
$chkListId
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process access group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
if ($intReturn3 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
// Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Define service groups (servicegroups.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Service group'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' "
. "OR `notes` LIKE '%".$strSearchTxt."%')";
/* Process search string and filter */
$strSearchWhere = '';
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere .= "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%' OR `alias` LIKE '%" . $strSearchTxt . "%' "
. "OR `notes` LIKE '%" . $strSearchTxt . "%') ";
}
// Row sorting
if ($_SESSION['filter'][$preSearchSession]['registered'] !== '') {
$intRegistered = (int)$_SESSION['filter'][$preSearchSession]['registered'];
if ($intRegistered === 1) {
$strSearchWhere .= "AND `register` = '1' ";
}
if ($intRegistered === 2) {
$strSearchWhere .= "AND `register` = '0' ";
}
$mastertp->setVariable('SEL_REGFILTER_' . $intRegistered . '_SELECTED', 'selected');
}
if ($_SESSION['filter'][$preSearchSession]['active'] !== '') {
$intActivated = (int)$_SESSION['filter'][$preSearchSession]['active'];
if ($intActivated === 1) {
$strSearchWhere .= "AND `active` = '1' ";
}
if ($intActivated === 2) {
$strSearchWhere .= "AND `active` = '0' ";
}
$mastertp->setVariable('SEL_ACTIVEFILTER_' . $intActivated . '_SELECTED', 'selected');
}
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
}
// Count datasets
$strSQL1 = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
. "AND `access_group` IN ($strAccess)";
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL1 = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
. "AND `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL1, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -253,19 +319,19 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL2 = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) "
. "$strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL2 = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) "
. "$strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -275,7 +341,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,137 +1,173 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Settings configuration
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : NagiosQL settings
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $prePageKey from prepend_adm.php -> Menu group id
* @var array $SETS Settings array
* @var string $chkTfValue1 from prepend_content.php -> Temporary directory
* @var string $chkTfValue2 from prepend_content.php -> Encoding
* @var string $chkTfValue3 from prepend_content.php -> Database server
* @var string $chkTfValue4 from prepend_content.php -> Database server port
* @var string $chkTfValue5 from prepend_content.php -> Database server db name
* @var string $chkTfValue6 from prepend_content.php -> Database server user
* @var string $chkTfValue7 from prepend_content.php -> Database server password
* @var string $chkTfValue8 from prepend_content.php -> Logoff time
* @var string $chkTfValue9 from prepend_content.php -> Data lines per page
* @var string $chkTfValue10 from prepend_content.php -> Proxy server
* @var string $chkTfValue11 from prepend_content.php -> Proxy user
* @var string $chkTfValue12 from prepend_content.php -> Proxy password
* @var int $chkSelValue1 from prepend_content.php -> Server protocol
* @var int $chkSelValue2 from prepend_content.php -> Standard language
* @var int $chkSelValue3 from prepend_content.php -> Webserver authentication
* @var int $chkSelValue4 from prepend_content.php -> Multiselect method
* @var int $chkRadValue1 from prepend_content.php -> Template warnings
* @var int $chkRadValue2 from prepend_content.php -> Update check
* @var int $chkRadValue3 from prepend_content.php -> Enable proxy server
* @var int $chkRadValue4 from prepend_content.php -> Show dependencies
* @var array $arrDescription from fieldvars.php -> Translated common strings
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 38;
$preContent = 'admin/settings.htm.tpl';
$preAccess = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 38;
$preContent = 'admin/settings.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$arrSQL = array();
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Process initial values
// ======================
if (filter_input(INPUT_POST, 'tfValue1') == null) {
$chkTfValue1 = $SETS['path']['tempdir'];
$arrSQL = array();
$strErrorMessage = '';
$strInfoMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Process initial values
*/
if (filter_input(INPUT_POST, 'tfValue1') === null) {
$chkTfValue1 = $SETS['path']['tempdir'];
}
if (filter_input(INPUT_POST, 'tfValue2') == null) {
$chkTfValue2 = $SETS['data']['encoding'];
if (filter_input(INPUT_POST, 'tfValue2') === null) {
$chkTfValue2 = $SETS['data']['encoding'];
}
if (filter_input(INPUT_POST, 'tfValue3') == null) {
$chkTfValue3 = $SETS['db']['server'];
if (filter_input(INPUT_POST, 'tfValue3') === null) {
$chkTfValue3 = $SETS['db']['server'];
}
if (filter_input(INPUT_POST, 'tfValue4') == null) {
$chkTfValue4 = $SETS['db']['port'];
if (filter_input(INPUT_POST, 'tfValue4') === null) {
$chkTfValue4 = $SETS['db']['port'];
}
if (filter_input(INPUT_POST, 'tfValue5') == null) {
$chkTfValue5 = $SETS['db']['database'];
if (filter_input(INPUT_POST, 'tfValue5') === null) {
$chkTfValue5 = $SETS['db']['database'];
}
if (filter_input(INPUT_POST, 'tfValue6') == null) {
$chkTfValue6 = $SETS['db']['username'];
if (filter_input(INPUT_POST, 'tfValue6') === null) {
$chkTfValue6 = $SETS['db']['username'];
}
if (filter_input(INPUT_POST, 'tfValue7') == null) {
$chkTfValue7 = $SETS['db']['password'];
if (filter_input(INPUT_POST, 'tfValue7') === null) {
$chkTfValue7 = $SETS['db']['password'];
}
if (filter_input(INPUT_POST, 'tfValue8') == null) {
$chkTfValue8 = $SETS['security']['logofftime'];
if (filter_input(INPUT_POST, 'tfValue8') === null) {
$chkTfValue8 = $SETS['security']['logofftime'];
}
if (filter_input(INPUT_POST, 'tfValue9') == null) {
$chkTfValue9 = $SETS['common']['pagelines'];
if (filter_input(INPUT_POST, 'tfValue9') === null) {
$chkTfValue9 = $SETS['common']['pagelines'];
}
if (filter_input(INPUT_POST, 'tfValue10') == null) {
if (filter_input(INPUT_POST, 'tfValue10') === null) {
$chkTfValue10 = $SETS['network']['proxyserver'];
}
if (filter_input(INPUT_POST, 'tfValue11') == null) {
if (filter_input(INPUT_POST, 'tfValue11') === null) {
$chkTfValue11 = $SETS['network']['proxyuser'];
}
if (filter_input(INPUT_POST, 'tfValue12') == null) {
if (filter_input(INPUT_POST, 'tfValue12') === null) {
$chkTfValue12 = $SETS['network']['proxypasswd'];
}
if (filter_input(INPUT_POST, 'selValue3') == null) {
$chkSelValue3 = $SETS['security']['wsauth'];
if (filter_input(INPUT_POST, 'selValue3') === null) {
$chkSelValue3 = (int)$SETS['security']['wsauth'];
}
if (filter_input(INPUT_POST, 'selValue4') == null) {
$chkSelValue4 = $SETS['common']['seldisable'];
if (filter_input(INPUT_POST, 'selValue4') === null) {
$chkSelValue4 = (int)$SETS['common']['seldisable'];
}
if (filter_input(INPUT_POST, 'radValue1') == null) {
$chkRadValue1 = $SETS['common']['tplcheck'];
if (filter_input(INPUT_POST, 'radValue1') === null) {
$chkRadValue1 = (int)$SETS['common']['tplcheck'];
}
if (filter_input(INPUT_POST, 'radValue2') == null) {
$chkRadValue2 = $SETS['common']['updcheck'];
if (filter_input(INPUT_POST, 'radValue2') === null) {
$chkRadValue2 = (int)$SETS['common']['updcheck'];
}
if (filter_input(INPUT_POST, 'radValue3') == null) {
$chkRadValue3 = $SETS['network']['proxy'];
if (filter_input(INPUT_POST, 'radValue3') === null) {
$chkRadValue3 = (int)$SETS['network']['proxy'];
}
//
// Save changes
// ============
if (filter_input(INPUT_POST, 'radValue4') === null) {
$chkRadValue4 = (int)$SETS['performance']['parents'];
}
/*
Save changes
*/
if (filter_input(INPUT_POST, 'selValue1')) {
//
// Write settings to database
// ==========================
if ($chkSelValue1 == 2) {
/*
Write settings to database
*/
if ($chkSelValue1 === 2) {
$strProtocol = 'https';
} else {
$strProtocol = 'http';
}
$strLocale = $myDBClass->getFieldData("SELECT `locale` FROM `tbl_language` WHERE `id`='".$chkSelValue2."'");
if ($strLocale == '') {
$strLocale = $myDBClass->getFieldData("SELECT `locale` FROM `tbl_language` WHERE `id`='" . $chkSelValue2 . "'");
if ($strLocale === '') {
$strLocale = 'en_GB';
}
$SETS['path']['protocol'] = $strProtocol;
$SETS['data']['locale'] = $strLocale;
// Check Proxy via curl
$SETS['data']['locale'] = $strLocale;
/* Check Proxy via curl */
if (!function_exists('curl_init')) {
$myVisClass->processMessage(translate('Curl module not loaded, Proxy will be deactivated!'), $strErrorMessage);
$chkRadValue3 = 0;
}
// Check base paths
/* Check base paths */
$strSQLBase = "UPDATE `tbl_settings` SET `value`='%s' WHERE `category`='%s' AND `name`='%s'";
$arrSQL[] = sprintf($strSQLBase, $strProtocol, 'path', 'protocol');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue1, 'path', 'tempdir');
$arrSQL[] = sprintf($strSQLBase, $preRelPath, 'path', 'base_url');
$arrSQL[] = sprintf($strSQLBase, $preBasePath, 'path', 'base_path');
$arrSQL[] = sprintf($strSQLBase, $strLocale, 'data', 'locale');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue2, 'data', 'encoding');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue8, 'security', 'logofftime');
$arrSQL[] = sprintf($strSQLBase, $chkSelValue3, 'security', 'wsauth');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue9, 'common', 'pagelines');
$arrSQL[] = sprintf($strSQLBase, $chkSelValue4, 'common', 'seldisable');
$arrSQL[] = sprintf($strSQLBase, $chkRadValue1, 'common', 'tplcheck');
$arrSQL[] = sprintf($strSQLBase, $chkRadValue2, 'common', 'updcheck');
$arrSQL[] = sprintf($strSQLBase, $chkRadValue3, 'network', 'proxy');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue10, 'network', 'proxyserver');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue11, 'network', 'proxyuser');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue12, 'network', 'proxypasswd');
$arrSQL[] = sprintf($strSQLBase, $strProtocol, 'path', 'protocol');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue1, 'path', 'tempdir');
$arrSQL[] = sprintf($strSQLBase, $preRelPath, 'path', 'base_url');
$arrSQL[] = sprintf($strSQLBase, $preBasePath, 'path', 'base_path');
$arrSQL[] = sprintf($strSQLBase, $strLocale, 'data', 'locale');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue2, 'data', 'encoding');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue8, 'security', 'logofftime');
$arrSQL[] = sprintf($strSQLBase, $chkSelValue3, 'security', 'wsauth');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue9, 'common', 'pagelines');
$arrSQL[] = sprintf($strSQLBase, $chkSelValue4, 'common', 'seldisable');
$arrSQL[] = sprintf($strSQLBase, $chkRadValue1, 'common', 'tplcheck');
$arrSQL[] = sprintf($strSQLBase, $chkRadValue2, 'common', 'updcheck');
$arrSQL[] = sprintf($strSQLBase, $chkRadValue3, 'network', 'proxy');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue10, 'network', 'proxyserver');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue11, 'network', 'proxyuser');
$arrSQL[] = sprintf($strSQLBase, $chkTfValue12, 'network', 'proxypasswd');
$arrSQL[] = sprintf($strSQLBase, $chkRadValue4, 'performance', 'parents');
foreach ($arrSQL as $elem) {
$booReturn = $myDBClass->insertData($elem);
if ($booReturn == false) {
if ($booReturn === false) {
$myVisClass->processMessage(
translate('An error occured while writing settings to database:'),
$strErrorMessage
@@ -139,9 +175,9 @@ if (filter_input(INPUT_POST, 'selValue1')) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
}
// Write db settings to file
if (is_writable($preBasePath. 'config/settings.php')) {
$filSettings = fopen($preBasePath. 'config/settings.php', 'wb');
/* Write db settings to file */
if (is_writable($preBasePath . 'config/settings.php')) {
$filSettings = fopen($preBasePath . 'config/settings.php', 'wb');
if ($filSettings) {
fwrite($filSettings, "<?php\n");
fwrite($filSettings, "exit;\n");
@@ -155,86 +191,83 @@ if (filter_input(INPUT_POST, 'selValue1')) {
fwrite($filSettings, "; Project : NagiosQL\n");
fwrite($filSettings, "; Component: Database Configuration\n");
fwrite($filSettings, "; Website : https://sourceforge.net/projects/nagiosql/\n");
fwrite($filSettings, '; Date : ' .date('F j, Y, g:i a')."\n");
fwrite($filSettings, '; Version : ' .$setFileVersion."\n");
fwrite($filSettings, '; Date : ' . date('F j, Y, g:i a') . "\n");
fwrite($filSettings, '; Version : ' . $setFileVersion . "\n");
fwrite($filSettings, ";\n");
fwrite($filSettings, ";///////////////////////////////////////////////////////////////////////////////\n");
fwrite($filSettings, "[db]\n");
fwrite($filSettings, "type = mysqli\n");
fwrite($filSettings, 'server = ' .$chkTfValue3."\n");
fwrite($filSettings, 'port = ' .$chkTfValue4."\n");
fwrite($filSettings, 'database = ' .$chkTfValue5."\n");
fwrite($filSettings, 'username = ' .$chkTfValue6."\n");
fwrite($filSettings, 'password = ' .$chkTfValue7."\n");
fwrite($filSettings, "type = 'mysqli'\n");
fwrite($filSettings, 'server = \'' . $chkTfValue3 . "'\n");
fwrite($filSettings, 'port = \'' . $chkTfValue4 . "'\n");
fwrite($filSettings, 'database = \'' . $chkTfValue5 . "'\n");
fwrite($filSettings, 'username = \'' . $chkTfValue6 . "'\n");
fwrite($filSettings, 'password = \'' . $chkTfValue7 . "'\n");
fwrite($filSettings, "[path]\n");
fwrite($filSettings, 'base_url = ' .$preRelPath."\n");
fwrite($filSettings, 'base_path = ' .$preBasePath."\n");
fwrite($filSettings, 'base_url = \'' . $preRelPath . "'\n");
fwrite($filSettings, 'base_path = \'' . $preBasePath . "'\n");
fclose($filSettings);
// Activate new language settings
/* Activate new language settings */
$arrLocale = explode('.', $strLocale);
$strDomain = $arrLocale[0];
$loc = setlocale(
LC_ALL,
$strLocale,
$strLocale. '.utf-8',
$strLocale. '.utf-8',
$strLocale. '.utf8',
$strLocale . '.utf-8',
$strLocale . '.utf-8',
$strLocale . '.utf8',
'en_GB',
'en_GB.utf-8',
'en_GB.utf8'
);
if (!isset($loc)) {
$myVisClass->processMessage(translate('Error setting the correct locale. Please report this error '
. "with the associated output of 'locale -a'"), $strErrorMessage);
. "with the associated output of 'locale -a'"), $strErrorMessage);
}
putenv('LC_ALL=' .$strLocale. '.utf-8');
putenv('LANG=' .$strLocale. '.utf-8');
bindtextdomain($strLocale, $preBasePath. 'config/locale');
putenv('LC_ALL=' . $strLocale . '.utf-8');
putenv('LANG=' . $strLocale . '.utf-8');
bindtextdomain($strLocale, $preBasePath . 'config/locale');
bind_textdomain_codeset($strLocale, $chkTfValue2);
textdomain($strLocale);
$myVisClass->processMessage(translate('Settings were changed'), $strInfoMessage);
} else {
$myVisClass->processMessage(translate('An error occured while writing settings.php. Please '
. 'check permissions!'), $strErrorMessage);
. 'check permissions!'), $strErrorMessage);
}
} else {
$myVisClass->processMessage($preBasePath. 'config/settings.php ' .translate('is not writeable, please '
$myVisClass->processMessage($preBasePath . 'config/settings.php ' . translate('is not writeable, please '
. 'check permissions!'), $strErrorMessage);
}
}
//
// Start content
// =============
/*
Start content
*/
$conttp->setVariable('TITLE', translate('Configure Settings'));
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
}
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF'));
$conttp->setVariable('LANG_DESCRIPTION', translate('Change your current NagiosQL settings (e.g. Database user, '
. 'Language).'));
//
// Path settings
// =============
. 'Language).'));
/* Path settings */
$conttp->setVariable('PATH', translate('Path'));
$conttp->setVariable('TEMPDIR_NAME', translate('Temporary Directory'));
$conttp->setVariable('TEMPDIR_VALUE', htmlspecialchars($chkTfValue1, ENT_QUOTES, 'utf-8'));
$conttp->setVariable('PROTOCOL_NAME', translate('Server protocol'));
$conttp->setVariable(strtoupper($SETS['path']['protocol']). '_SELECTED', 'selected');
//
// Data settings
// =============
$conttp->setVariable(strtoupper($SETS['path']['protocol']) . '_SELECTED', 'selected');
/* Data settings */
$conttp->setVariable('DATA', translate('Language'));
$conttp->setVariable('LOCALE', translate('Language'));
// Process language selection field
$strSQL = "SELECT * FROM `tbl_language` WHERE `active`='1' ORDER BY `id`";
/* Process language selection field */
$strSQL = "SELECT * FROM `tbl_language` WHERE `active`='1' ORDER BY `id`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($booReturn && ($intDataCount != 0)) {
if ($booReturn && ($intDataCount !== 0)) {
foreach ($arrData as $elem) {
$conttp->setVariable('LANGUAGE_ID', $elem['id']);
$conttp->setVariable('LANGUAGE_NAME', translate($elem['language']));
if ($elem['locale'] == $SETS['data']['locale']) {
if ($elem['locale'] === $SETS['data']['locale']) {
$conttp->setVariable('LANGUAGE_SELECTED', 'selected');
}
/** @noinspection DisconnectedForeachInstructionInspection */
$conttp->parse('language');
}
} else {
@@ -243,9 +276,7 @@ if ($booReturn && ($intDataCount != 0)) {
}
$conttp->setVariable('ENCODING_NAME', translate('Encoding'));
$conttp->setVariable('ENCODING_VALUE', htmlspecialchars($chkTfValue2, ENT_QUOTES, 'utf-8'));
//
// Database settings
// =================
/* Database settings */
$conttp->setVariable('DB', translate('Database'));
$conttp->setVariable('SERVER_NAME', translate('MySQL Server'));
$conttp->setVariable('SERVER_VALUE', htmlspecialchars($chkTfValue3, ENT_QUOTES, 'utf-8'));
@@ -257,45 +288,36 @@ $conttp->setVariable('USERNAME_NAME', translate('Database user'));
$conttp->setVariable('USERNAME_VALUE', htmlspecialchars($chkTfValue6, ENT_QUOTES, 'utf-8'));
$conttp->setVariable('PASSWORD_NAME', translate('Database password'));
$conttp->setVariable('PASSWORD_VALUE', htmlspecialchars($chkTfValue7, ENT_QUOTES, 'utf-8'));
//
// Security settings
// =================
/* Security settings */
$conttp->setVariable('SECURITY', translate('Security'));
$conttp->setVariable('LOGOFFTIME_NAME', translate('Session auto logoff time'));
$conttp->setVariable('LOGOFFTIME_VALUE', htmlspecialchars($chkTfValue8, ENT_QUOTES, 'utf-8'));
$conttp->setVariable('WSAUTH_NAME', translate('Authentication type'));
$conttp->setVariable('WSAUTH_' .$chkSelValue3. '_SELECTED', 'selected');
//
// Common settings
// ===============
$conttp->setVariable('WSAUTH_' . $chkSelValue3 . '_SELECTED', 'selected');
/* Common settings */
$conttp->setVariable('COMMON', translate('Common'));
$conttp->setVariable('PAGELINES_NAME', translate('Data lines per page'));
$conttp->setVariable('PAGELINES_VALUE', htmlspecialchars($chkTfValue9, ENT_QUOTES, 'utf-8'));
$conttp->setVariable('SELDISABLE_NAME', translate('Selection method'));
$conttp->setVariable('SELDISABLE_' .$chkSelValue4. '_SELECTED', 'selected');
//
// Template Check
// ==============
$conttp->setVariable('SELDISABLE_' . $chkSelValue4 . '_SELECTED', 'selected');
/* Template Check */
$conttp->setVariable('TEMPLATE_CHECK', translate('Template warn message'));
$conttp->setVariable('LANG_ENABLE', translate('Enable'));
$conttp->setVariable('LANG_DISABLE', translate('Disable'));
$conttp->setVariable('TPL_CHECK_' .$chkRadValue1. '_CHECKED', 'checked');
//
// Online version check
// ====================
$conttp->setVariable('TPL_CHECK_' . $chkRadValue1 . '_CHECKED', 'checked');
/* Online version check */
$conttp->setVariable('CLASS_NAME_1', 'elementHide');
$conttp->setVariable('CLASS_NAME_2', 'elementHide');
$conttp->setVariable('UPDATE_CHECK', translate('Online version check'));
$conttp->setVariable('UPD_CHECK_' .$chkRadValue2. '_CHECKED', 'checked');
if ($chkRadValue2 == 1) {
$conttp->setVariable('UPD_CHECK_' . $chkRadValue2 . '_CHECKED', 'checked');
if ($chkRadValue2 === 1) {
$conttp->setVariable('CLASS_NAME_1', 'elementShow');
}
//
// Online update proxy settings
// ============================
/* Online update proxy settings */
$conttp->setVariable('UPD_PROXY_CHECK', translate('Proxyserver'));
$conttp->setVariable('UPD_PROXY_' .$chkRadValue3. '_CHECKED', 'checked');
if (($chkRadValue3 == 1) && ($chkRadValue2 == 1)) {
$conttp->setVariable('UPD_PROXY_' . $chkRadValue3 . '_CHECKED', 'checked');
if (($chkRadValue3 === 1) && ($chkRadValue2 === 1)) {
echo "da";
$conttp->setVariable('CLASS_NAME_2', 'elementShow');
}
$conttp->setVariable('UPD_PROXY_SERVER', translate('Proxy Address'));
@@ -304,26 +326,26 @@ $conttp->setVariable('UPD_PROXY_USERNAME', translate('Proxy Username (optional)'
$conttp->setVariable('UPD_PROXY_USERNAME_VALUE', htmlspecialchars($chkTfValue11, ENT_QUOTES, 'utf-8'));
$conttp->setVariable('UPD_PROXY_PASSWORD', translate('Proxy Password (optional)'));
$conttp->setVariable('UPD_PROXY_PASSWORD_VALUE', htmlspecialchars($chkTfValue12, ENT_QUOTES, 'utf-8'));
//
// Requirements of form
// ====================
/* Performance options */
$conttp->setVariable('PERFORMANCE', translate('Performance options'));
$conttp->setVariable('SHOW_PARENTS', translate('Show object parents'));
$conttp->setVariable('PAR_CHECK_' . $chkRadValue4 . '_CHECKED', 'checked');
/* Requirements of form */
$conttp->setVariable('LANG_SAVE', translate('Save'));
$conttp->setVariable('LANG_ABORT', translate('Abort'));
$conttp->setVariable('LANG_REQUIRED', translate('required'));
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
//
// Check access rights for adding new objects
// ==========================================
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('settingssite');
$conttp->show('settingssite');
//
// Footer ausgeben
// ===============
/*
Footer ausgeben
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,50 +1,59 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Specials overview
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Specials overview
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var int $chkDomainId from prepend_adm.php
* @var string $setFileVersion from prepend_adm.php
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 5;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 5;
$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
//
// Include content
// ===============
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Misc commands'));
$conttp->parse('header');
$conttp->show('header');
$conttp->setVariable('DESC', translate('Define host and service dependencies, host and service escalations as well '.
$conttp->setVariable('DESC', translate('Define host and service dependencies, host and service escalations as well ' .
'as host and service additional data.'));
$conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable('INACTIVE', translate('Inactive'));
//
// Include statistical data
// ========================
// Get read access groups
/*
Include statistical data
*/
/* Get read access groups */
$strAccess = $myVisClass->getAccessGroups('read');
$intAccessGrp19 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=19');
$intAccessGrp20 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=20');
@@ -52,7 +61,7 @@ $intAccessGrp21 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_men
$intAccessGrp22 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=22');
$intAccessGrp23 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=23');
$intAccessGrp24 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=24');
if ($myVisClass->checkAccountGroup($intAccessGrp19, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp19, 'read') === 0) {
$conttp->setVariable('NAME', translate('Host dependencies'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostdependency` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
@@ -60,7 +69,7 @@ if ($myVisClass->checkAccountGroup($intAccessGrp19, 'read') == 0) {
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intAccessGrp20, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp20, 'read') === 0) {
$conttp->setVariable('NAME', translate('Host escalations'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostescalation` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
@@ -68,7 +77,7 @@ if ($myVisClass->checkAccountGroup($intAccessGrp20, 'read') == 0) {
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intAccessGrp21, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp21, 'read') === 0) {
$conttp->setVariable('NAME', translate('Host ext. info'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostextinfo` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
@@ -76,7 +85,7 @@ if ($myVisClass->checkAccountGroup($intAccessGrp21, 'read') == 0) {
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intAccessGrp22, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp22, 'read') === 0) {
$conttp->setVariable('NAME', translate('Service dependencies'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicedependency` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
@@ -84,7 +93,7 @@ if ($myVisClass->checkAccountGroup($intAccessGrp22, 'read') == 0) {
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intAccessGrp23, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp23, 'read') === 0) {
$conttp->setVariable('NAME', translate('Service escalations'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_serviceescalation` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
@@ -92,7 +101,7 @@ if ($myVisClass->checkAccountGroup($intAccessGrp23, 'read') == 0) {
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
}
if ($myVisClass->checkAccountGroup($intAccessGrp24, 'read') == 0) {
if ($myVisClass->checkAccountGroup($intAccessGrp24, 'read') === 0) {
$conttp->setVariable('NAME', translate('Service ext. info'));
$conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_serviceextinfo` '
. "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
@@ -103,10 +112,10 @@ if ($myVisClass->checkAccountGroup($intAccessGrp24, 'read') == 0) {
$conttp->parse('statistics');
$conttp->parse('main');
$conttp->show('main');
//
// Include Footer
// ==============
/*
Include Footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,48 +1,65 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Support page
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Support page
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $setGITVersion from prepend_adm.php -> Application version string - GIT version
* @var int $chkDomainId from prepend_adm.php -> Configuration domain id
* @var int $prePageKey from prepend_adm.php -> Admin access key
* @var array $SETS Settings array
* @var array $arrDescription from fieldvars.php -> Translated common strings
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 40;
$preContent = 'admin/support.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 40;
$preContent = 'admin/support.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$setSaveLangId = 'private';
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Start content
// =============
$strErrorMessage = '';
$strInfoMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Start content
*/
$conttp->setVariable('TITLE', translate('NagiosQL support page'));
$conttp->parse('header');
$conttp->show('header');
//
// Single data form
// ================
$conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url']. 'admin.php');
/*
Single data form
*/
$conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url'] . 'admin.php');
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
}
@@ -50,17 +67,17 @@ $conttp->setVariable('SUBTITLE_1', translate('Support contact information'));
$conttp->setVariable('SUPPORT_TEXT_1', translate('For questions, the online support forum or contact information '
. 'visit our website:'));
$conttp->setVariable('WEBSITE_LINK', translate('NagiosQL on sourceforge'));
//
// Donation
// ========
/*
Donation
*/
$conttp->setVariable('SUBTITLE_2', translate('Donate to support NagiosQL'));
$conttp->setVariable('SUPPORT_TEXT_2', translate('If you like NagiosQL and it simplifies your daily work, then you '
. 'may want to support the project by making a donation. This helps us to keep NagiosQL alive and to cover '
. 'our costs. Thank you for your donation!'));
$conttp->setVariable('DONATE_LINK', translate('Donate for NagiosQL on sourceforge'));
//
// Translations
// ============
/*
Translations
*/
$conttp->setVariable('SUBTITLE_3', translate('Translation services'));
$conttp->setVariable('SUPPORT_TEXT_3', translate('NagiosQL was translated into various languages. Since some '
. 'translators are no longer available in later versions, there may be untranslated words or phrases. If '
@@ -68,51 +85,53 @@ $conttp->setVariable('SUPPORT_TEXT_3', translate('NagiosQL was translated into v
. 'with us now! The translations are simply feasible online - we use an open translation service where '
. 'you can register for free at any time:'));
$conttp->setVariable('TRANSLATION_LINK', translate('Transifex translation service'));
//
// GIT repository
// ==============
/*
GIT repository
*/
$conttp->setVariable('SUBTITLE_8', translate('GIT software repository'));
$conttp->setVariable('SUPPORT_TEXT_5', translate('The NagiosQL sources are available on GitLab. There you will '
.'always find the latest bugfixes and changes as well as older branches.'));
. 'always find the latest bugfixes and changes as well as older branches.'));
$conttp->setVariable('GIT_LINK', translate('GitLab'));
//
// Online version check
// ====================
/*
Online version check
*/
$conttp->setVariable('SUBTITLE_4', translate('Version check'));
if (!isset($SETS['common']['updcheck']) || ($SETS['common']['updcheck'] == '0')) {
if (!isset($SETS['common']['updcheck']) || ($SETS['common']['updcheck'] === '0')) {
$conttp->setVariable('SUPPORT_TEXT_4', translate('The online version check is not enabled. You can enable it '
. 'on the settings page.'));
} elseif (isset($SETS['common']['updcheck']) && ($SETS['common']['updcheck'] == '1')) {
} elseif (isset($SETS['common']['updcheck']) && ($SETS['common']['updcheck'] === '1')) {
$conttp->setVariable('SUPPORT_TEXT_4', translate('The online version check connects the NagiosQL page to find '
. 'out, if your version is still up to date.'));
$conttp->setVariable('LOADER_IMAGE', $_SESSION['SETS']['path']['base_url']. 'images/loader.gif');
$conttp->setVariable('VERSION_IF_SRC', $_SESSION['SETS']['path']['base_url']. 'admin/versioncheck.php?show=0');
$conttp->setVariable('LOADER_IMAGE', $_SESSION['SETS']['path']['base_url'] . 'images/loader.gif');
$conttp->setVariable('VERSION_IF_SRC', $_SESSION['SETS']['path']['base_url'] . 'admin/versioncheck.php?show=0');
$conttp->parse('versioncheck_frame');
$conttp->setVariable('VERSION_IF_SRC_RELOAD', $_SESSION['SETS']['path']['base_url'].
$conttp->setVariable('VERSION_IF_SRC_RELOAD', $_SESSION['SETS']['path']['base_url'] .
'admin/versioncheck.php?show=1');
$conttp->parse('versioncheck_js');
}
//
// Environment check
// =================
$conttp->setVariable('GIT_TITLE', translate('GIT code version'));
$conttp->setVariable('GIT_VERSION', $setFileVersion . '-' . $setGITVersion);
/*
Environment check
*/
$conttp->setVariable('SUBTITLE_5', translate('Environment check'));
// Javascript check
/* Javascript check */
$conttp->setVariable('FAILED', translate('failed'));
$conttp->setVariable('OK', translate('ok'));
// PHP version check
/* PHP version check */
$conttp->setVariable('PHP_VERSION', translate('PHP version'));
if (PHP_VERSION_ID >= 50500) {
$conttp->setVariable('PHP_CLASS', 'checkgreen');
$conttp->setVariable('PHP_RESULT', translate('ok'). ' (' .PHP_VERSION. ')');
$conttp->setVariable('PHP_RESULT', translate('ok') . ' (' . PHP_VERSION . ')');
} else {
$conttp->setVariable('PHP_CLASS', 'checkred');
$conttp->setVariable('PHP_RESULT', translate('failed'). ' (' .PHP_VERSION. ' - '
.translate('Required:'). ' 5.5.0)');
$conttp->setVariable('PHP_RESULT', translate('failed') . ' (' . PHP_VERSION . ' - '
. translate('Required:') . ' 5.5.0)');
}
// PHP modules / extensions
/* PHP modules / extensions */
$strExtPath = ini_get('extension_dir');
$strPrefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
$conttp->setVariable('PHP_SESSION_MODULE', translate('PHP module:'). ' session');
$strPrefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
$conttp->setVariable('PHP_SESSION_MODULE', translate('PHP module:') . ' session');
if (extension_loaded('session')) {
$conttp->setVariable('PHP_SESSION_CLASS', 'checkgreen');
$conttp->setVariable('PHP_SESSION_RESULT', translate('ok'));
@@ -120,7 +139,7 @@ if (extension_loaded('session')) {
$conttp->setVariable('PHP_SESSION_CLASS', 'checkred');
$conttp->setVariable('PHP_SESSION_RESULT', translate('failed'));
}
$conttp->setVariable('PHP_GETTEXT_MODULE', translate('PHP module:'). ' gettext');
$conttp->setVariable('PHP_GETTEXT_MODULE', translate('PHP module:') . ' gettext');
if (extension_loaded('gettext')) {
$conttp->setVariable('PHP_GETTEXT_CLASS', 'checkgreen');
$conttp->setVariable('PHP_GETTEXT_RESULT', translate('ok'));
@@ -128,7 +147,7 @@ if (extension_loaded('gettext')) {
$conttp->setVariable('PHP_GETTEXT_CLASS', 'checkred');
$conttp->setVariable('PHP_GETTEXT_RESULT', translate('failed'));
}
$conttp->setVariable('PHP_FTP_MODULE', translate('PHP module:'). ' ftp');
$conttp->setVariable('PHP_FTP_MODULE', translate('PHP module:') . ' ftp');
if (extension_loaded('ftp')) {
$conttp->setVariable('PHP_FTP_CLASS', 'checkgreen');
$conttp->setVariable('PHP_FTP_RESULT', translate('ok'));
@@ -138,7 +157,7 @@ if (extension_loaded('ftp')) {
$conttp->setVariable('PHP_FTP_RESULT', translate('failed'));
$intFTP_ok = 0;
}
$conttp->setVariable('PHP_SSH2_MODULE', translate('PHP module:'). ' ssh');
$conttp->setVariable('PHP_SSH2_MODULE', translate('PHP module:') . ' ssh');
if (extension_loaded('ssh2')) {
$conttp->setVariable('PHP_SSH2_CLASS', 'checkgreen');
$conttp->setVariable('PHP_SSH2_RESULT', translate('ok'));
@@ -148,62 +167,62 @@ if (extension_loaded('ssh2')) {
$conttp->setVariable('PHP_SSH2_RESULT', translate('failed'));
$intSSH_ok = 0;
}
// Datenbankversion
if ($SETS['db']['type'] == 'mysql') {
/* Datenbankversion */
if ($SETS['db']['type'] === 'mysql') {
$conttp->setVariable('DB_VERSION', translate('MySQL version'));
$strSQL = "SHOW VARIABLES LIKE 'version'";
$strSQL = "SHOW VARIABLES LIKE 'version'";
$booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataset);
if ($booReturn && (count($arrDataset) != 0)) {
if ($booReturn && (count($arrDataset) !== 0)) {
$strDBVersion = $arrDataset['Value'];
if (version_compare($strDBVersion, '5.0.0', '>=')) {
$conttp->setVariable('DB_CLASS', 'checkgreen');
$conttp->setVariable('DB_RESULT', translate('ok'). ' (' .$strDBVersion. ')');
$conttp->setVariable('DB_RESULT', translate('ok') . ' (' . $strDBVersion . ')');
} else {
$conttp->setVariable('DB_CLASS', 'checkorange');
$conttp->setVariable('DB_RESULT', translate('failed'). ' (' .$strDBVersion. ' - ' .translate('Required:').
$conttp->setVariable('DB_RESULT', translate('failed') . ' (' . $strDBVersion . ' - ' . translate('Required:') .
' 5.0.0)');
}
}
}
// INI settings
$conttp->setVariable('INI_FILE_UPLOADS', translate('PHP ini settings:'). ' file_uploads');
/* INI settings */
$conttp->setVariable('INI_FILE_UPLOADS', translate('PHP ini settings:') . ' file_uploads');
$strStatus1 = ini_get('file_uploads');
if (empty($strStatus1) || ($strStatus1 == 1)) {
if (empty($strStatus1) || ($strStatus1 === '1')) {
$conttp->setVariable('INI_FILE_UPLOADS_CLASS', 'checkgreen');
$conttp->setVariable('INI_FILE_UPLOADS_RESULT', translate('ok'));
} else {
$conttp->setVariable('INI_FILE_UPLOADS_CLASS', 'checkred');
$conttp->setVariable('INI_FILE_UPLOADS_RESULT', translate('failed'));
}
$conttp->setVariable('INI_AUTO_START', translate('PHP ini settings:'). ' session.auto_start');
$conttp->setVariable('INI_AUTO_START', translate('PHP ini settings:') . ' session.auto_start');
$strStatus2 = ini_get('session.auto_start');
if (empty($strStatus2) || ($strStatus2 == 0)) {
if (empty($strStatus2) || ($strStatus2 === '0')) {
$conttp->setVariable('INI_AUTO_START_CLASS', 'checkgreen');
$conttp->setVariable('INI_AUTO_START_RESULT', translate('ok'));
} else {
$conttp->setVariable('INI_AUTO_START_CLASS', 'checkred');
$conttp->setVariable('INI_AUTO_START_RESULT', translate('failed'));
}
$conttp->setVariable('INI_SUHO_SESS_ENC', translate('PHP ini settings:'). ' suhosin.session.encrypt');
$conttp->setVariable('INI_SUHO_SESS_ENC', translate('PHP ini settings:') . ' suhosin.session.encrypt');
$strStatus3 = ini_get('suhosin.session.encrypt');
if (empty($strStatus3) || ($strStatus3 == 0)) {
if (empty($strStatus3) || ($strStatus3 === '0')) {
$conttp->setVariable('INI_SUHO_SESS_ENC_CLASS', 'checkgreen');
$conttp->setVariable('INI_SUHO_SESS_ENC_RESULT', translate('ok'));
} else {
$conttp->setVariable('INI_SUHO_SESS_ENC_CLASS', 'checkred');
$conttp->setVariable('INI_SUHO_SESS_ENC_RESULT', translate('failed'));
}
$conttp->setVariable('INI_DATE_TIMEZONE', translate('PHP ini settings:'). ' date.timezone');
$conttp->setVariable('INI_DATE_TIMEZONE', translate('PHP ini settings:') . ' date.timezone');
$strStatus4 = ini_get('date.timezone');
if (!empty($strStatus4)) {
$conttp->setVariable('INI_DATE_TIMEZONE_CLASS', 'checkgreen');
$conttp->setVariable('INI_DATE_TIMEZONE_RESULT', translate('ok'). ' (' .$strStatus4. ')');
$conttp->setVariable('INI_DATE_TIMEZONE_RESULT', translate('ok') . ' (' . $strStatus4 . ')');
} else {
$conttp->setVariable('INI_DATE_TIMEZONE_CLASS', 'checkred');
$conttp->setVariable('INI_DATE_TIMEZONE_RESULT', translate('failed'));
}
// File access checks
$conttp->setVariable('RW_CONFIG', translate('Read/Write access:'). ' settings.php');
/* File access checks */
$conttp->setVariable('RW_CONFIG', translate('Read/Write access:') . ' settings.php');
$strConfigFile = '../config/settings.php';
if (file_exists($strConfigFile) && is_readable($strConfigFile) && is_writable($strConfigFile)) {
$conttp->setVariable('RW_CONFIG_CLASS', 'checkgreen');
@@ -212,13 +231,14 @@ if (file_exists($strConfigFile) && is_readable($strConfigFile) && is_writable($s
$conttp->setVariable('RW_CONFIG_CLASS', 'checkred');
$conttp->setVariable('RW_CONFIG_RESULT', translate('failed'));
}
//
// Domain checks
// =============
/*
Domain checks
*/
$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
if ($intConfigId != 0) {
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $strMethod);
$intMethod = (int)$strMethod;
if ($intConfigId !== 0) {
$conttp->setVariable('SUBTITLE_6', translate('Config domain checks'));
$conttp->setVariable('SUPPORT_TEXT_6', translate('The checks below are based on your data domain and config '
. 'domain settings. To change the data domain, use the pull down menu in the upper right corner. Repeat '
@@ -229,19 +249,19 @@ if ($intConfigId != 0) {
$conttp->setVariable('DOMAIN_NAME', translate('Config domain name'));
$conttp->setVariable('DOMAIN_NAME_VALUE', $strConfName);
$conttp->setVariable('CONNECT_TYPE', translate('Connection type'));
if ($intMethod == 1) {
if ($intMethod === 1) {
$conttp->setVariable('CONNECT_TYPE_CLASS', 'checkgreen');
$conttp->setVariable('CONNECT_TYPE_RESULT', 'Fileaccess');
} elseif ($intMethod == 2) {
if ($intFTP_ok == 1) {
} elseif ($intMethod === 2) {
if ($intFTP_ok === 1) {
$conttp->setVariable('CONNECT_TYPE_CLASS', 'checkgreen');
$conttp->setVariable('CONNECT_TYPE_RESULT', 'FTP');
} else {
$conttp->setVariable('CONNECT_TYPE_CLASS', 'checkred');
$conttp->setVariable('CONNECT_TYPE_RESULT', 'FTP (no FTP module)');
}
} elseif ($intMethod == 3) {
if ($intSSH_ok == 1) {
} elseif ($intMethod === 3) {
if ($intSSH_ok === 1) {
$conttp->setVariable('CONNECT_TYPE_CLASS', 'checkgreen');
$conttp->setVariable('CONNECT_TYPE_RESULT', 'SSH/SFTP');
} else {
@@ -250,15 +270,15 @@ if ($intConfigId != 0) {
}
}
$conttp->setVariable('CONNECT_CHECK', translate('Connection check'));
if ($intMethod == 1) {
if ($intMethod === 1) {
$conttp->setVariable('CONNECT_CHECK_CLASS', 'checkgreen');
$conttp->setVariable('CONNECT_CHECK_RESULT', translate('ok'));
} elseif ($intMethod == 2) {
} elseif ($intMethod === 2) {
$booReturn = 0;
if (empty($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
if (empty($myConfigClass->conFTPConId)) {
$booReturn = $myConfigClass->getFTPConnection($intConfigId);
}
if ($booReturn == 1) {
if ($booReturn === 1) {
$conttp->setVariable('CONNECT_CHECK_CLASS', 'checkred');
$conttp->setVariable('CONNECT_CHECK_RESULT', translate('failed'));
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
@@ -268,12 +288,12 @@ if ($intConfigId != 0) {
$conttp->setVariable('CONNECT_CHECK_RESULT', translate('ok'));
$intConnectCheck = 1;
}
} elseif ($intMethod == 3) {
} elseif ($intMethod === 3) {
$booReturn = 0;
if (empty($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
if (empty($myConfigClass->resSSHConId) || !is_resource($myConfigClass->resSSHConId)) {
$booReturn = $myConfigClass->getSSHConnection($intConfigId);
}
if ($booReturn == 1) {
if ($booReturn === 1) {
$conttp->setVariable('CONNECT_CHECK_CLASS', 'checkred');
$conttp->setVariable('CONNECT_CHECK_RESULT', translate('failed'));
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
@@ -285,25 +305,25 @@ if ($intConfigId != 0) {
}
}
$conttp->setVariable('RW_NAG_CONF', translate('Nagios config file'));
if ($intMethod == 1) {
if ($intMethod === 1) {
if (file_exists($strConffile) && is_readable($strConffile)) {
if (is_writable($strConffile)) {
$conttp->setVariable('RW_NAG_CONF_CLASS', 'checkgreen');
$conttp->setVariable('RW_NAG_CONF_RESULT', translate('ok'));
} else {
$conttp->setVariable('RW_NAG_CONF_CLASS', 'checkorange');
$conttp->setVariable('RW_NAG_CONF_RESULT', translate('ok'). ' (' .translate('readonly'). ')');
$conttp->setVariable('RW_NAG_CONF_RESULT', translate('ok') . ' (' . translate('readonly') . ')');
}
} else {
$conttp->setVariable('RW_NAG_CONF_CLASS', 'checkred');
$conttp->setVariable('RW_NAG_CONF_RESULT', translate('failed'));
}
} elseif (($intMethod == 2) || ($intMethod == 3)) {
// Write file to temporary
} elseif (($intMethod === 2) || ($intMethod === 3)) {
/* Write file to temporary */
$strFileName = tempnam($SETS['path']['tempdir'], 'nagiosql_conf');
// Copy configuration from remote system
$intReturn = $myConfigClass->remoteFileCopy($strConffile, $intConfigId, $strFileName, 0);
if ($intReturn == 0) {
/* Copy configuration from remote system */
$intReturn = $myConfigClass->remoteFileCopy($strConffile, $intConfigId, $strFileName);
if ($intReturn === 0) {
$intCheck = 0;
} else {
$intCheck = 1;
@@ -312,41 +332,40 @@ if ($intConfigId != 0) {
unlink($strFileName);
}
}
// Copy configuration to remote system
if ($intCheck == 0) {
/* Copy configuration to remote system */
if ($intCheck === 0) {
$intReturn = $myConfigClass->remoteFileCopy($strConffile, $intConfigId, $strFileName, 1);
if ($intReturn == 0) {
if ($intReturn === 0) {
$intCheck = 0;
if (file_exists($strFileName)) {
unlink($strFileName);
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
$intCheck = 2;
if (file_exists($strFileName)) {
unlink($strFileName);
}
}
if (file_exists($strFileName)) {
unlink($strFileName);
}
}
// Write Results
if ($intCheck == 0) {
/* Write Results */
if ($intCheck === 0) {
$conttp->setVariable('RW_NAG_CONF_CLASS', 'checkgreen');
$conttp->setVariable('RW_NAG_CONF_RESULT', translate('ok'));
} elseif ($intCheck == 1) {
} elseif ($intCheck === 1) {
$conttp->setVariable('RW_NAG_CONF_CLASS', 'checkred');
$conttp->setVariable('RW_NAG_CONF_RESULT', translate('failed'));
} elseif ($intCheck == 2) {
} elseif ($intCheck === 2) {
$conttp->setVariable('RW_NAG_CONF_CLASS', 'checkorange');
$conttp->setVariable('RW_NAG_CONF_RESULT', translate('ok'). ' (' .translate('readonly'). ')');
$conttp->setVariable('RW_NAG_CONF_RESULT', translate('ok') . ' (' . translate('readonly') . ')');
}
}
$myConfigClass->getConfigValues($intConfigId, 'pidfile', $strPidfile);
$myConfigClass->getConfigValues($intConfigId, 'binaryfile', $strBinary);
$myConfigClass->getConfigValues($intConfigId, 'commandfile', $strCommandfile);
$conttp->setVariable('CHECK_NAG_LOCK', translate('Nagios process file'));
if ($intMethod == 1) {
if (substr_count(PHP_OS, 'Linux') != 0) {
exec('ps -ef | grep '.basename($strBinary).' | grep -v grep', $arrExec);
$intDemonOk = 0;
$intCheck = 0;
if ($intMethod === 1) {
if (substr_count(PHP_OS, 'Linux') !== 0) {
exec('ps -ef | grep ' . basename($strBinary) . ' | grep -v grep', $arrExec);
} else {
$arrExec[0] = 1;
}
@@ -356,9 +375,9 @@ if ($intConfigId != 0) {
$conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('ok'));
$intDemonOk = 0;
} else {
$conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkred');
$conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('failed') . ' ('
. translate('file is missed') . ')');
$conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkorange');
$conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('ok') . ' ('
. translate('file is missed or not used') . ')');
$intDemonOk = 1;
}
} else {
@@ -367,189 +386,186 @@ if ($intConfigId != 0) {
$myVisClass->processMessage(translate('Nagios daemon is not running'), $strErrorMessage);
$intDemonOk = 1;
}
} elseif ($intMethod == 2) {
} elseif ($intMethod === 2) {
$conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkorange');
$conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('ok'). ' (' .translate('not used with FTP'). ')');
$conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('ok') . ' (' . translate('not used with FTP') . ')');
$intDemonOk = 1;
} elseif ($intMethod == 3) {
} elseif ($intMethod === 3) {
$arrResultBinary = array();
$arrResultPid = array();
$intBinary = 1;
$intPid = 1;
if ($strBinary != '') {
$intBinary = $myConfigClass->sendSSHCommand('ps -ef | grep '.basename($strBinary).' | grep '.
basename($strConffile).' | grep -v grep', $arrResultBinary);
$arrResultPid = array();
$intBinary = 1;
$intPid = 1;
if ($strBinary !== '') {
$intBinary = $myConfigClass->sendSSHCommand('ps -ef | grep ' . basename($strBinary) . ' | grep ' .
basename($strConffile) . ' | grep -v grep', $arrResultBinary);
}
if ($strPidfile != '') {
if ($strPidfile !== '') {
$intPid = $myConfigClass->sendSSHCommand('ls ' . $strPidfile, $arrResult2);
}
if (($intBinary == 0) && ($intPid == 0)) {
if (($intBinary === 0) && ($intPid === 0)) {
$conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkgreen');
$conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('ok'));
$intDemonOk = 0;
} elseif (($intBinary == 0) && ($intPid == 1)) {
$conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkred');
$conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('failed'). ' (' .translate('file is missed'). ')');
} elseif (($intBinary === 0) && ($intPid === 1)) {
$conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkorange');
$conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('ok') . ' (' . translate('file is missed or not used') . ')');
$intDemonOk = 1;
} else {
$conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkred');
$conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('failed'). ' (' .translate('demon dead'). ')');
$conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('failed') . ' (' . translate('demon dead') . ')');
$myVisClass->processMessage(translate('Nagios daemon is not running'), $strErrorMessage);
$intDemonOk = 1;
}
}
// Command file
/* Command file */
$conttp->setVariable('RW_NAG_COMMAND', translate('Nagios command file'));
if ($intMethod == 1) {
if ($intMethod === 1) {
if (file_exists($strCommandfile) && is_readable($strCommandfile) && is_writable($strCommandfile)) {
if ($intDemonOk == 0) {
if ($intDemonOk === 0) {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkgreen');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('ok'));
} else {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkorange');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('ok'). ' (' .translate('demon dead'). '?)');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('ok') . ' (' . translate('demon dead') . '?)');
}
}
if (!file_exists($strCommandfile)) {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' (' .translate('file is missed'). ')');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed') . ' (' . translate('file is missed') . ')');
} elseif (!is_writable($strCommandfile)) {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' (' .translate('readonly'). ')');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed') . ' (' . translate('readonly') . ')');
} elseif (!is_readable($strCommandfile)) {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'));
}
} elseif ($intMethod == 2) {
} elseif ($intMethod === 2) {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkorange');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('ok'). ' (' .translate('not used with FTP'). ')');
} elseif ($intMethod == 3) {
if ($strCommandfile != '') {
if ($intDemonOk == 0) {
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('ok') . ' (' . translate('not used with FTP') . ')');
} elseif ($intMethod === 3) {
if ($strCommandfile !== '') {
if ($intDemonOk === 0) {
$myConfigClass->sendSSHCommand('echo "TEST" >>' . $strCommandfile . '; echo $?; echo ""', $arrTemp);
if ($arrTemp[0] == 0) {
if ($arrTemp[0] === 0) {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkgreen');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('ok'));
} else {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' ('
.translate('readonly'). ')');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed') . ' ('
. translate('readonly') . ')');
}
} elseif ($intDemonOk == 1) {
} elseif ($intDemonOk === 1) {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' (' .translate('demon dead'). ')');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed') . ' (' . translate('demon dead') . ')');
} else {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' ('
.translate('file is missed'). ')');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed') . ' ('
. translate('file is missed') . ')');
}
} else {
$conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' (' .translate('file is missed'). ')');
$conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed') . ' (' . translate('file is missed') . ')');
}
}
// Binary file
/* Binary file */
$conttp->setVariable('EXE_NAG_BINARY', translate('Nagios binary file'));
if ($intMethod == 1) {
if ($intMethod === 1) {
if (file_exists($strBinary)) {
if (is_executable($strBinary)) {
$conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkgreen');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('ok'));
} else {
$conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkred');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed'). ' ('
.translate('not executable'). ')');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed') . ' ('
. translate('not executable') . ')');
}
} else {
$conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkred');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed'). ' (' .translate('file is missed'). ')');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed') . ' (' . translate('file is missed') . ')');
}
} elseif ($intMethod == 2) {
} elseif ($intMethod === 2) {
$conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkorange');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('ok'). ' (' .translate('not used with FTP'). ')');
} elseif ($intMethod == 3) {
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('ok') . ' (' . translate('not used with FTP') . ')');
} elseif ($intMethod === 3) {
$booReturn = 0;
/** @noinspection IsEmptyFunctionUsageInspection */
if (empty($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
if (empty($myConfigClass->resSSHConId) || !is_resource($myConfigClass->resSSHConId)) {
$booReturn = $myConfigClass->getSSHConnection($intConfigId);
}
if ($booReturn == 1) {
if ($booReturn === 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} else {
if (($strBinary != '') && ($strConffile != '') &&
($myConfigClass->sendSSHCommand('ls '.$strBinary, $arrTemp) == 0)) {
$myConfigClass->sendSSHCommand($strBinary.' -V', $arrResult);
if (!is_array($arrResult) || ($arrResult == false)) {
$conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkred');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed'). ' (' .
translate('not executable'). ')');
} else {
$conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkgreen');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('ok'));
}
} else {
} else if (($strBinary !== '') && ($strConffile !== '') &&
($myConfigClass->sendSSHCommand('ls ' . $strBinary, $arrTemp) === 0)) {
$myConfigClass->sendSSHCommand($strBinary . ' -V', $arrResult);
if (!is_array($arrResult) || (count($arrResult) === 0)) {
$conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkred');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed'). ' (' .
translate('file is missed'). ')');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed') . ' (' .
translate('not executable') . ')');
} else {
$conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkgreen');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('ok'));
}
} else {
$conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkred');
$conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed') . ' (' .
translate('file is missed') . ')');
}
}
// Check config files
/* Check config files */
$myConfigClass->getConfigValues($intConfigId, 'basedir', $strBasedir);
$myConfigClass->getConfigValues($intConfigId, 'hostconfig', $strHostdir);
$myConfigClass->getConfigValues($intConfigId, 'serviceconfig', $strServicedir);
$conttp->setVariable('SUBTITLE_7', translate('Verify configuration files and demon configuration'));
$conttp->setVariable('CONFIGURATION_NAME', translate('Configuration name'));
$conttp->setVariable('USED', translate('Used in data domain'));
$conttp->setVariable('DEMON_CONFIG', translate('Included in demon configuration'). ' ('
.basename($strConffile). ')');
$arrConfig = array();
$conttp->setVariable('DEMON_CONFIG', translate('Included in demon configuration') . ' ('
. basename($strConffile) . ')');
$arrConfig = array();
$arrConfigFiles = array(
'Hosts' => array( 'table' => 'tbl_host', 'file' => 'directory'),
'Services' => array( 'table' => 'tbl_service', 'file' => 'directory'),
'Hostgroups' => array( 'table' => 'tbl_hostgroup', 'file' => 'hostgroups.cfg'),
'Servicegroups' => array( 'table' => 'tbl_servicegroup', 'file' => 'servicegroups.cfg'),
'Hosttemplates' => array( 'table' => 'tbl_hosttemplate', 'file' => 'hosttemplates.cfg'),
'servicetemplates' => array( 'table' => 'tbl_servicetemplate', 'file' => 'servicetemplates.cfg'),
'Contacts' => array( 'table' => 'tbl_contact', 'file' => 'contacts.cfg'),
'Contactgroups' => array( 'table' => 'tbl_contactgroup', 'file' => 'contactgroups.cfg'),
'Timeperiods' => array( 'table' => 'tbl_timeperiod', 'file' => 'timeperiods.cfg'),
'Contacttemplates' => array( 'table' => 'tbl_contacttemplate', 'file' => 'contacttemplates.cfg'),
'Commands' => array( 'table' => 'tbl_command', 'file' => 'commands.cfg'),
'Hostdependencies' => array( 'table' => 'tbl_hostdependency', 'file' => 'hostdependencies.cfg'),
'Hostescalations' => array( 'table' => 'tbl_hostescalation', 'file' => 'hostescalations.cfg'),
'Hostextinfo' => array( 'table' => 'tbl_hostextinfo', 'file' => 'hostextinfo.cfg'),
'Servicedependencies' => array( 'table' => 'tbl_servicedependency', 'file' => 'servicedependencies.cfg'),
'Serviceescalations' => array( 'table' => 'tbl_serviceescalation', 'file' => 'serviceescalations.cfg'),
'Serviceextinfo' => array( 'table' => 'tbl_serviceextinfo', 'file' => 'serviceextinfo.cfg'));
if ($intMethod == 1) {
'Hosts' => array('table' => 'tbl_host', 'file' => 'directory'),
'Services' => array('table' => 'tbl_service', 'file' => 'directory'),
'Hostgroups' => array('table' => 'tbl_hostgroup', 'file' => 'hostgroups.cfg'),
'Servicegroups' => array('table' => 'tbl_servicegroup', 'file' => 'servicegroups.cfg'),
'Hosttemplates' => array('table' => 'tbl_hosttemplate', 'file' => 'hosttemplates.cfg'),
'servicetemplates' => array('table' => 'tbl_servicetemplate', 'file' => 'servicetemplates.cfg'),
'Contacts' => array('table' => 'tbl_contact', 'file' => 'contacts.cfg'),
'Contactgroups' => array('table' => 'tbl_contactgroup', 'file' => 'contactgroups.cfg'),
'Timeperiods' => array('table' => 'tbl_timeperiod', 'file' => 'timeperiods.cfg'),
'Contacttemplates' => array('table' => 'tbl_contacttemplate', 'file' => 'contacttemplates.cfg'),
'Commands' => array('table' => 'tbl_command', 'file' => 'commands.cfg'),
'Hostdependencies' => array('table' => 'tbl_hostdependency', 'file' => 'hostdependencies.cfg'),
'Hostescalations' => array('table' => 'tbl_hostescalation', 'file' => 'hostescalations.cfg'),
'Hostextinfo' => array('table' => 'tbl_hostextinfo', 'file' => 'hostextinfo.cfg'),
'Servicedependencies' => array('table' => 'tbl_servicedependency', 'file' => 'servicedependencies.cfg'),
'Serviceescalations' => array('table' => 'tbl_serviceescalation', 'file' => 'serviceescalations.cfg'),
'Serviceextinfo' => array('table' => 'tbl_serviceextinfo', 'file' => 'serviceextinfo.cfg'));
if ($intMethod === 1) {
$intCheck = 1;
if (file_exists($strConffile) && is_readable($strConffile)) {
$resFile = fopen($strConffile, 'rb');
while (!feof($resFile)) {
$strLine = trim(fgets($resFile));
if ((0 === strpos($strLine, 'c')) && ((substr_count($strLine, 'cfg_dir') != 0) ||
(substr_count($strLine, 'cfg_file') != 0))) {
if ((0 === strpos($strLine, 'c')) && ((substr_count($strLine, 'cfg_dir') !== 0) ||
(substr_count($strLine, 'cfg_file') !== 0))) {
$arrConfig[] = $strLine;
}
}
$intCheck = 0;
fclose($resFile);
}
} elseif (($intMethod == 2) || ($intMethod == 3)) {
} elseif (($intMethod === 2) || ($intMethod === 3)) {
$intCheck = 1;
// Write file to temporary
/* Write file to temporary */
$strFileName = tempnam($SETS['path']['tempdir'], 'nagiosql_conf');
// Copy configuration from remote system
$intReturn = $myConfigClass->remoteFileCopy($strConffile, $intConfigId, $strFileName, 0);
if ($intReturn == 0) {
/* Copy configuration from remote system */
$intReturn = $myConfigClass->remoteFileCopy($strConffile, $intConfigId, $strFileName);
if ($intReturn === 0) {
$intCheck = 0;
if (file_exists($strFileName) && is_readable($strFileName)) {
$resFile = fopen($strFileName, 'rb');
while (!feof($resFile)) {
$strLine = trim(fgets($resFile));
if ((0 === strpos($strLine, 'c')) && ((substr_count($strLine, 'cfg_dir') != 0) ||
(substr_count($strLine, 'cfg_file') != 0))) {
if ((0 === strpos($strLine, 'c')) && ((substr_count($strLine, 'cfg_dir') !== 0) ||
(substr_count($strLine, 'cfg_file') !== 0))) {
$arrConfig[] = $strLine;
}
}
@@ -566,117 +582,118 @@ if ($intConfigId != 0) {
}
$i = 0;
foreach ($arrConfigFiles as $key => $elem) {
// Line colours
/* Line colours */
$strClassL = 'tdlb';
$strClassM = 'tdmb';
if ($i%2 == 1) {
if ($i % 2 === 1) {
$strClassL = 'tdld';
$strClassM = 'tdmd';
}
$conttp->setVariable('CLASS_L', $strClassL);
$conttp->setVariable('CLASS_M', $strClassM);
// Write configuiration name
/* Write configuiration name */
$conttp->setVariable('CONFIG_NAME', $key);
// Count active datasets
$strSQL = 'SELECT * FROM `' .$elem['table']."` WHERE `active`='1' AND `config_id`=$chkDomainId";
/* Count active datasets */
/** @noinspection SqlResolve */
$strSQL = 'SELECT * FROM `' . $elem['table'] . "` WHERE `active`='1' AND `config_id`=$chkDomainId";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn && ($intDataCount != 0)) {
$conttp->setVariable('ACTIVE_CONFIG_COUNT', '<span class="checkgreen">' .translate('ok'). ' (' .
$intDataCount. ')</span>');
} elseif ($intDataCount == 0) {
$conttp->setVariable('ACTIVE_CONFIG_COUNT', '<span class="checkgreen">' .translate('not used'). '</span>');
if ($booReturn && ($intDataCount !== 0)) {
$conttp->setVariable('ACTIVE_CONFIG_COUNT', '<span class="checkgreen">' . translate('ok') . ' (' .
$intDataCount . ')</span>');
} elseif ($intDataCount === 0) {
$conttp->setVariable('ACTIVE_CONFIG_COUNT', '<span class="checkgreen">' . translate('not used') . '</span>');
} else {
$conttp->setVariable('ACTIVE_CONFIG_COUNT', '<span class="checkred">' .translate('failed'). '</span>');
$conttp->setVariable('ACTIVE_CONFIG_COUNT', '<span class="checkred">' . translate('failed') . '</span>');
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkred">' .translate('failed'). '</span> (' .
translate('cfg definition missed'). ')');
if (($intCheck == 0) && is_array($arrConfig) && (count($arrConfig) != 0)) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkred">' . translate('failed') . '</span> (' .
translate('cfg definition missed') . ')');
if (($intCheck === 0) && is_array($arrConfig) && (count($arrConfig) !== 0)) {
foreach ($arrConfig as $line) {
if ($elem['file'] != 'directory') {
if ((substr_count($line, 'cfg_dir=' .$strBasedir) != 0) && (substr_count($line, 'cfg_dir=' .
substr($strHostdir, 0, -1)) == 0) && (substr_count($line, 'cfg_dir=' .
substr($strServicedir, 0, -1)) == 0)) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkgreen">' .translate('ok').
'</span> (' .$line. ')');
if ($elem['file'] !== 'directory') {
if ((substr_count($line, 'cfg_dir=' . $strBasedir) !== 0) && (substr_count($line, 'cfg_dir=' .
substr($strHostdir, 0, -1)) === 0) && (substr_count($line, 'cfg_dir=' .
substr($strServicedir, 0, -1)) === 0)) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkgreen">' . translate('ok') .
'</span> (' . $line . ')');
break;
}
if (substr_count($line, $strBasedir.$elem['file']) != 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkgreen">' .translate('ok').
'</span> (' .$line. ')');
if (substr_count($line, $strBasedir . $elem['file']) !== 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkgreen">' . translate('ok') .
'</span> (' . $line . ')');
break;
}
if ($intDataCount == 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkorange">' .translate('ok').
'</span> (' .translate('cfg definition missed, but actually not used'). ')');
} elseif (substr_count($line, $elem['file']) != 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkred">' .translate('failed').
'</span> (' .translate('wrong base path:'). ' ' .$line. ')');
if ($intDataCount === 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkorange">' . translate('ok') .
'</span> (' . translate('cfg definition missed, but actually not used') . ')');
} elseif (substr_count($line, $elem['file']) !== 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkred">' . translate('failed') .
'</span> (' . translate('wrong base path:') . ' ' . $line . ')');
break;
}
} elseif ($elem['table'] == 'tbl_host') {
if (substr_count($line, 'cfg_dir=' .substr($strHostdir, 0, -1)) != 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkgreen">' .translate('ok').
'</span> (' .$line. ')');
} elseif ($elem['table'] === 'tbl_host') {
if (substr_count($line, 'cfg_dir=' . substr($strHostdir, 0, -1)) !== 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkgreen">' . translate('ok') .
'</span> (' . $line . ')');
break;
}
if ($intDataCount == 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkorange">' .translate('ok').
'</span> (' .translate('cfg definition missed, but actually not used'). ')');
if ($intDataCount === 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkorange">' . translate('ok') .
'</span> (' . translate('cfg definition missed, but actually not used') . ')');
break;
}
} elseif ($elem['table'] == 'tbl_service') {
if (substr_count($line, 'cfg_dir=' .substr($strServicedir, 0, -1)) != 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkgreen">' .translate('ok').
'</span> (' .$line. ')');
} elseif ($elem['table'] === 'tbl_service') {
if (substr_count($line, 'cfg_dir=' . substr($strServicedir, 0, -1)) !== 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkgreen">' . translate('ok') .
'</span> (' . $line . ')');
break;
}
if ($intDataCount == 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkorange">' .translate('ok').
'</span> (' .translate('cfg definition missed, but actually not used'). ')');
if ($intDataCount === 0) {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkorange">' . translate('ok') .
'</span> (' . translate('cfg definition missed, but actually not used') . ')');
break;
}
}
}
} else {
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkred">' .translate('failed').
'</span> (' .translate('cfg file not readable'). ')');
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkred">' . translate('failed') .
'</span> (' . translate('cfg file not readable') . ')');
}
$conttp->parse('configfileline');
$i++;
}
// Check for unused config
if (($intCheck == 0) && is_array($arrConfig) && (count($arrConfig) != 0)) {
/* Check for unused config */
if (($intCheck === 0) && is_array($arrConfig) && (count($arrConfig) !== 0)) {
foreach ($arrConfig as $line) {
$intTest=0;
$intTest = 0;
foreach ($arrConfigFiles as $elem) {
if (substr_count($line, $elem['file']) != 0) {
if (substr_count($line, $elem['file']) !== 0) {
$intTest = 1;
}
}
if ($intTest == 0) {
if (substr_count($line, substr('cfg_dir=' .$strHostdir, 0, -1)) != 0) {
if ($intTest === 0) {
if (substr_count($line, substr('cfg_dir=' . $strHostdir, 0, -1)) !== 0) {
$intTest = 1;
}
if (substr_count($line, substr('cfg_dir=' .$strServicedir, 0, -1)) != 0) {
if (substr_count($line, substr('cfg_dir=' . $strServicedir, 0, -1)) !== 0) {
$intTest = 1;
}
//if (substr_count($line,substr("cfg_dir=".$strBasedir,0,-1)) != 0) $intTest = 1;
//if (substr_count($line,substr("cfg_dir=".$strBasedir,0,-1)) !== 0) $intTest = 1;
}
if ($intTest == 0) {
// Line colours
if ($intTest === 0) {
/* Line colours */
$strClassL = 'tdlb';
$strClassM = 'tdmb';
if ($i%2 == 1) {
if ($i % 2 === 1) {
$strClassL = 'tdld';
$strClassM = 'tdmd';
}
$conttp->setVariable('CLASS_L', $strClassL);
$conttp->setVariable('CLASS_M', $strClassM);
$conttp->setVariable('CONFIG_NAME', translate('Not used'));
$conttp->setVariable('ACTIVE_CONFIG_COUNT', '<span class="checkred">' .translate('failed'). '</span>');
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkred">' .translate('unused - please delete!').
'</span> (' .$line. ')');
$conttp->setVariable('ACTIVE_CONFIG_COUNT', '<span class="checkred">' . translate('failed') . '</span>');
$conttp->setVariable('DEMON_CFG_OK', '<span class="checkred">' . translate('unused - please delete!') .
'</span> (' . $line . ')');
$conttp->parse('configfileline');
$i++;
}
@@ -685,23 +702,23 @@ if ($intConfigId != 0) {
$conttp->parse('configdomain');
}
// Messages
if ($strErrorMessage != '') {
/* Messages */
if ($strErrorMessage !== '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
if ($strInfoMessage != '') {
if ($strInfoMessage !== '') {
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
}
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('support');
$conttp->show('support');
//
// Process footer
// ==============
/*
Process footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,285 +1,317 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Template definition list
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Template definition list
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
/**
* Class and variable includes
* @var MysqliDbClass $myDBClass MySQL database class
*/
/*
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));
//
// Define common variables
// =======================
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$preAccess = 1;
$preNoMain = 1;
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
//
// Process post parameters
// =======================
$chkLinkTab = '';
$chkPreTab = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
/*
Process post parameters
*/
$chkDataId = filter_input(INPUT_GET, 'dataId', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkMode = filter_input(INPUT_GET, 'mode', FILTER_SANITIZE_STRING);
$chkKey = filter_input(INPUT_GET, 'key', FILTER_SANITIZE_STRING);
$chkDef = filter_input(INPUT_GET, 'def', FILTER_SANITIZE_STRING);
$chkType = filter_input(INPUT_GET, 'type', FILTER_SANITIZE_STRING);
if ($chkDataId == '') {
$chkMode = filter_input(INPUT_GET, 'mode');
$chkKey = filter_input(INPUT_GET, 'key');
$chkDef = filter_input(INPUT_GET, 'def');
$chkType = filter_input(INPUT_GET, 'type');
if ($chkDataId === '') {
$chkDataId = 0;
}
if (get_magic_quotes_gpc() == 0) {
$chkDef = addslashes($chkDef);
}
$arrDefinition = explode('::', $chkDef);
if ($chkType == '') {
if ($chkType === '') {
exit;
}
if ($chkType == 'host') {
if ($chkType === 'host') {
$chkLinkTab = 'tbl_lnkHostToHosttemplate';
$chkPreTab = 'host';
$chkPreTab = 'host';
}
if ($chkType == 'hosttemplate') {
if ($chkType === 'hosttemplate') {
$chkLinkTab = 'tbl_lnkHosttemplateToHosttemplate';
$chkPreTab = 'host';
$chkPreTab = 'host';
}
if ($chkType == 'service') {
if ($chkType === 'service') {
$chkLinkTab = 'tbl_lnkServiceToServicetemplate';
$chkPreTab = 'service';
$chkPreTab = 'service';
}
if ($chkType == 'servicetemplate') {
if ($chkType === 'servicetemplate') {
$chkLinkTab = 'tbl_lnkServicetemplateToServicetemplate';
$chkPreTab = 'service';
$chkPreTab = 'service';
}
if ($chkType == 'contact') {
if ($chkType === 'contact') {
$chkLinkTab = 'tbl_lnkContactToContacttemplate';
$chkPreTab = 'contact';
$chkPreTab = 'contact';
}
if ($chkType == 'contacttemplate') {
if ($chkType === 'contacttemplate') {
$chkLinkTab = 'tbl_lnkContacttemplateToContacttemplate';
$chkPreTab = 'contact';
$chkPreTab = 'contact';
}
//
// Get data
// ========
if ($chkLinkTab != '') {
$strSQL = 'SELECT * FROM `' .$chkLinkTab."` WHERE `idMaster` = $chkDataId ORDER BY `idSort`";
/*
Get data
*/
if ($chkLinkTab !== '') {
/** @noinspection SqlResolve */
$strSQL = 'SELECT * FROM `' . $chkLinkTab . "` WHERE `idMaster` = $chkDataId ORDER BY `idSort`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
//
// Store data to session
// ============================
if ($chkMode == '') {
/* Store data to session */
if ($chkMode === null) {
$_SESSION['templatedefinition'] = array();
$arrTemp = array();
if ($booReturn && ($intDataCount != 0)) {
$arrTemp = array();
if ($booReturn && ($intDataCount !== 0)) {
foreach ($arrDataLines as $elem) {
if ($elem['idTable'] == 1) {
if ((int)$elem['idTable'] === 1) {
$strSQL2 = 'SELECT `template_name` '
. 'FROM `tbl_' .$chkPreTab. 'template` WHERE `id` = ' .$elem['idSlave'];
$strSQL3 = 'SELECT `active` FROM `tbl_' .$chkPreTab. 'template` WHERE `id` = ' .$elem['idSlave'];
. 'FROM `tbl_' . $chkPreTab . 'template` WHERE `id` = ' . $elem['idSlave'];
/** @noinspection SqlResolve */
$strSQL3 = 'SELECT `active` FROM `tbl_' . $chkPreTab . 'template` WHERE `id` = ' . $elem['idSlave'];
/** @noinspection SqlResolve */
$strSQL4 = 'SELECT `config_id` FROM `tbl_' . $chkPreTab . 'template` WHERE `id` = ' . $elem['idSlave'];
} else {
$strSQL2 = 'SELECT `name` FROM `tbl_' .$chkPreTab. '` WHERE `id` = ' .$elem['idSlave'];
$strSQL3 = 'SELECT `active` FROM `tbl_' .$chkPreTab. '` WHERE `id` = ' .$elem['idSlave'];
/** @noinspection SqlResolve */
$strSQL2 = 'SELECT `name` FROM `tbl_' . $chkPreTab . '` WHERE `id` = ' . $elem['idSlave'];
/** @noinspection SqlResolve */
$strSQL3 = 'SELECT `active` FROM `tbl_' . $chkPreTab . '` WHERE `id` = ' . $elem['idSlave'];
/** @noinspection SqlResolve */
$strSQL4 = 'SELECT `config_id` FROM `tbl_' . $chkPreTab . '` WHERE `id` = ' . $elem['idSlave'];
}
$arrTemp['idSlave'] = $elem['idSlave'];
$arrTemp['definition'] = addslashes($myDBClass->getFieldData($strSQL2));
$arrTemp['idTable'] = $elem['idTable'];
$arrTemp['idSort'] = $elem['idSort'];
$arrTemp['active'] = (int)$myDBClass->getFieldData($strSQL3);
$arrTemp['status'] = 0;
$arrTemp['idSlave'] = $elem['idSlave'];
$arrTemp['definition'] = addslashes($myDBClass->getFieldData($strSQL2));
$arrTemp['idTable'] = $elem['idTable'];
$arrTemp['idSort'] = $elem['idSort'];
$arrTemp['active'] = (int)$myDBClass->getFieldData($strSQL3);
$arrTemp['config_id'] = (int)$myDBClass->getFieldData($strSQL4);
$arrTemp['status'] = 0;
$_SESSION['templatedefinition'][] = $arrTemp;
}
}
}
}
//
// Add mode
// ========
if ($chkMode == 'add') {
/*
Add mode
*/
if ($chkMode === 'add') {
$arrTemp = array();
if ($arrDefinition[1] == 1) {
$strSQL2 = 'SELECT `template_name` FROM `tbl_' .$chkPreTab. 'template` WHERE `id` = ' .$arrDefinition[0];
$strSQL3 = 'SELECT `active` FROM `tbl_' .$chkPreTab. 'template` WHERE `id` = ' .$arrDefinition[0];
if ((int)$arrDefinition[1] === 1) {
/** @noinspection SqlResolve */
$strSQL2 = 'SELECT `template_name` FROM `tbl_' . $chkPreTab . 'template` WHERE `id` = ' . $arrDefinition[0];
/** @noinspection SqlResolve */
$strSQL3 = 'SELECT `active` FROM `tbl_' . $chkPreTab . 'template` WHERE `id` = ' . $arrDefinition[0];
/** @noinspection SqlResolve */
$strSQL4 = 'SELECT `config_id` FROM `tbl_' . $chkPreTab . 'template` WHERE `id` = ' . $arrDefinition[0];
} else {
$strSQL2 = 'SELECT `name` FROM `tbl_' .$chkPreTab. '` WHERE `id` = ' .$arrDefinition[0];
$strSQL3 = 'SELECT `active` FROM `tbl_' .$chkPreTab. '` WHERE `id` = ' .$arrDefinition[0];
/** @noinspection SqlResolve */
$strSQL2 = 'SELECT `name` FROM `tbl_' . $chkPreTab . '` WHERE `id` = ' . $arrDefinition[0];
/** @noinspection SqlResolve */
$strSQL3 = 'SELECT `active` FROM `tbl_' . $chkPreTab . '` WHERE `id` = ' . $arrDefinition[0];
/** @noinspection SqlResolve */
$strSQL4 = 'SELECT `config_id` FROM `tbl_' . $chkPreTab . '` WHERE `id` = ' . $arrDefinition[0];
}
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition'])) {
$intCheck = 0;
foreach ($_SESSION['templatedefinition'] as $key => $elem) {
if (($elem['idSlave'] == $arrDefinition[0]) && ($elem['idTable'] == $arrDefinition[1]) &&
($elem['status'] == 0)) {
if ((int)($elem['idSlave'] === $arrDefinition[0]) && ((int)$elem['idTable'] === (int)$arrDefinition[1]) &&
((int)$elem['status'] === 0)) {
$intCheck = 1;
}
}
if ($intCheck == 0) {
$arrTemp['idSlave'] = $arrDefinition[0];
$arrTemp['definition'] = addslashes($myDBClass->getFieldData($strSQL2));
$arrTemp['idTable'] = $arrDefinition[1];
$arrTemp['idSort'] = 0;
$arrTemp['status'] = 0;
$arrTemp['active'] = (int)$myDBClass->getFieldData($strSQL3);
if ($intCheck === 0) {
$arrTemp['idSlave'] = $arrDefinition[0];
$arrTemp['definition'] = addslashes($myDBClass->getFieldData($strSQL2));
$arrTemp['idTable'] = $arrDefinition[1];
$arrTemp['idSort'] = 0;
$arrTemp['status'] = 0;
$arrTemp['active'] = (int)$myDBClass->getFieldData($strSQL3);
$arrTemp['config_id'] = (int)$myDBClass->getFieldData($strSQL4);
$_SESSION['templatedefinition'][] = $arrTemp;
}
} else {
$arrTemp['idSlave'] = $arrDefinition[0];
$arrTemp['definition'] = addslashes($myDBClass->getFieldData($strSQL2));
$arrTemp['idTable'] = $arrDefinition[1];
$arrTemp['idSort'] = 0;
$arrTemp['status'] = 0;
$arrTemp['active'] = (int)$myDBClass->getFieldData($strSQL3);
$arrTemp['idSlave'] = $arrDefinition[0];
$arrTemp['definition'] = addslashes($myDBClass->getFieldData($strSQL2));
$arrTemp['idTable'] = $arrDefinition[1];
$arrTemp['idSort'] = 0;
$arrTemp['status'] = 0;
$arrTemp['active'] = (int)$myDBClass->getFieldData($strSQL3);
$arrTemp['config_id'] = (int)$myDBClass->getFieldData($strSQL4);
$_SESSION['templatedefinition'][] = $arrTemp;
}
}
//
// Deletion mode
// =============
if ($chkMode == 'del' && isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition'])) {
/*
Deletion mode
*/
if ($chkMode === 'del' && isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition'])) {
foreach ($_SESSION['templatedefinition'] as $key => $elem) {
if (($elem['idSlave'] == $arrDefinition[0]) && ($elem['idTable'] == $arrDefinition[1]) &&
($elem['status'] == 0)) {
if (((int)$elem['idSlave'] === (int)$arrDefinition[0]) && ((int)$elem['idTable'] === (int)$arrDefinition[1]) &&
((int)$elem['status'] === 0)) {
$_SESSION['templatedefinition'][$key]['status'] = 1;
}
}
}
//
// Sort mode
// =========
if ($chkMode == 'sortup') {
$chkKey = (int)$chkKey;
/*
Sort mode
*/
if ($chkMode === 'sortup') {
$chkKey = (int)$chkKey;
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(count($_SESSION['templatedefinition']) > 1) && ($chkKey != 0)) {
(count($_SESSION['templatedefinition']) > 1) && ($chkKey !== 0)) {
$arrTemp = array();
$arrWait = array();
$intNow = 0;
$intNow = 0;
foreach ($_SESSION['templatedefinition'] as $key => $elem) {
if ($key != ($chkKey-1)) {
if ($key !== ($chkKey - 1)) {
$arrTemp[] = $elem;
if ($intNow == 1) {
$intNow = 0;
$arrTemp[] = $arrWait;
}
} else {
$arrWait = $elem;
$intNow = 1;
}
}
$_SESSION['templatedefinition'] = $arrTemp;
}
}
if ($chkMode == 'sortdown') {
$chkKey = (int)$chkKey;
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(count($_SESSION['templatedefinition']) > 1) && ($chkKey < (count($_SESSION['templatedefinition'])-1))) {
$arrTemp = array();
$arrWait = array();
$intNow = 0;
foreach ($_SESSION['templatedefinition'] as $key => $elem) {
if ($key != $chkKey) {
$arrTemp[] = $elem;
if ($intNow == 1) {
if ($intNow === 1) {
$intNow = 0;
$arrTemp[] = $arrWait;
}
} else {
$arrWait = $elem;
$intNow = 1;
$intNow = 1;
}
}
$_SESSION['templatedefinition'] = $arrTemp;
}
}
//
// Clean up data structure
// =======================
if ($chkMode === 'sortdown') {
$chkKey = (int)$chkKey;
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(count($_SESSION['templatedefinition']) > 1) && ($chkKey < (count($_SESSION['templatedefinition']) - 1))) {
$arrTemp = array();
$arrWait = array();
$intNow = 0;
foreach ($_SESSION['templatedefinition'] as $key => $elem) {
if ($key !== $chkKey) {
$arrTemp[] = $elem;
if ($intNow === 1) {
$intNow = 0;
$arrTemp[] = $arrWait;
}
} else {
$arrWait = $elem;
$intNow = 1;
}
}
$_SESSION['templatedefinition'] = $arrTemp;
}
}
/*
Clean up data structure
*/
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition'])) {
$arrTemp = array();
foreach ($_SESSION['templatedefinition'] as $key => $elem) {
if ($elem['status'] == 0) {
if ((int)$elem['status'] === 0) {
$arrTemp[] = $elem;
}
}
$_SESSION['templatedefinition'] = $arrTemp;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>None</title>
<link href="<?php echo $_SESSION['SETS']['path']['base_url']?>config/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
<!--
const base = "<?php echo $_SESSION['SETS']['path']['base_url']; ?>admin/templatedefinitions.php?dataId=";
function doDel(key) {
let link;
link = base+"<?php echo $chkDataId; ?>&type=<?php echo $chkType; ?>&mode=del&def="+key;
document.location.href = link;
}
function doUp(key,elem) {
let link;
link = base+"<?php echo $chkDataId; ?>&type=<?php echo $chkType; ?>&mode=sortup&key="+key+"def="+elem;
document.location.href = link;
}
function doDown(key,elem) {
let link;
link = base+"<?php echo $chkDataId; ?>&type=<?php echo $chkType; ?>&mode=sortdown&key="+key+"def="+elem;
document.location.href = link;
}
//-->
</script>
</head>
<body style="margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<?php
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(count($_SESSION['templatedefinition']) != 0)) {
foreach ($_SESSION['templatedefinition'] as $key => $elem) {
if ($elem['status'] == 0) {
?>
<tr>
<td class="tablerow" style="padding-bottom:2px;"><?php
echo htmlspecialchars(stripslashes($elem['definition']), ENT_COMPAT, 'UTF-8');
if ($elem['active'] == 0) {
echo ' [inactive]';
} ?></td>
<td class="tablerow" align="right"><img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/up.gif" width="18" height="18" alt="<?php
echo translate('Up'); ?>" title="<?php echo translate('Up'); ?>" onClick="doUp('<?php
echo $key; ?>','<?php
echo $elem['idSlave']. '::' .$elem['idTable']; ?>')" style="cursor:pointer">&nbsp;<img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/down.gif" width="18" height="18" alt="<?php
echo translate('Down'); ?>" title="<?php echo translate('Down'); ?>" onClick="doDown('<?php
echo $key; ?>','<?php
echo $elem['idSlave']. '::' .$elem['idTable']; ?>')" style="cursor:pointer">&nbsp;<img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18" alt="<?php
echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>" onClick="doDel('<?php
echo $elem['idSlave']. '::' .$elem['idTable']; ?>')" style="cursor:pointer"></td>
</tr>
<?php
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>None</title>
<link href="<?php echo $_SESSION['SETS']['path']['base_url'] ?>config/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
<!--
const base = "<?php echo $_SESSION['SETS']['path']['base_url']; ?>admin/templatedefinitions.php?dataId=";
function doDel(key) {
let link;
link = base + "<?php echo $chkDataId; ?>&type=<?php echo $chkType; ?>&mode=del&def=" + key;
document.location.href = link;
}
function doUp(key, elem) {
let link;
link = base + "<?php echo $chkDataId; ?>&type=<?php echo $chkType; ?>&mode=sortup&key=" + key + "def=" + elem;
document.location.href = link;
}
function doDown(key, elem) {
let link;
link = base + "<?php echo $chkDataId; ?>&type=<?php echo $chkType; ?>&mode=sortdown&key=" + key + "def=" + elem;
document.location.href = link;
}
//-->
</script>
</head>
<body style="margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<?php
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(count($_SESSION['templatedefinition']) !== 0)) {
foreach ($_SESSION['templatedefinition'] as $key => $elem) {
if ((int)$elem['status'] === 0) {
?>
<tr>
<td class="tablerow" style="padding-bottom:2px;"><?php
echo htmlspecialchars(stripslashes($elem['definition']), ENT_COMPAT, 'UTF-8');
if ($elem['active'] === 0) {
echo ' [inactive]';
}
if ($elem['config_id'] === 0) {
echo ' [common]';
}?></td>
<td class="tablerow" align="right"><img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/up.gif" width="18" height="18" alt="<?php
echo translate('Up'); ?>" title="<?php echo translate('Up'); ?>" onClick="doUp('<?php
echo $key; ?>','<?php
echo $elem['idSlave'] . '::' . $elem['idTable']; ?>')" style="cursor:pointer">&nbsp;<img
src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/down.gif" width="18" height="18"
alt="<?php
echo translate('Down'); ?>" title="<?php echo translate('Down'); ?>"
onClick="doDown('<?php
echo $key; ?>','<?php
echo $elem['idSlave'] . '::' . $elem['idTable']; ?>')" style="cursor:pointer">&nbsp;<img
src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18"
alt="<?php
echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>"
onClick="doDel('<?php
echo $elem['idSlave'] . '::' . $elem['idTable']; ?>')" style="cursor:pointer"></td>
</tr>
<?php
}
}
} else {
?>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
} else {
?>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
?>
</table>
</body>
?>
</table>
</body>
</html>

View File

@@ -1,81 +1,80 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin time definition list
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Time definition list
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
/**
* Class and variable includes
* @var MysqliDbClass $myDBClass MySQL database class
*/
/*
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));
//
// Define common variables
// =======================
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$preAccess = 1;
$preNoMain = 1;
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
//
// Process post parameters
// =======================
$chkTipId = filter_input(INPUT_GET, 'tipId', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
/*
Process post parameters
*/
$chkTipId = filter_input(INPUT_GET, 'tipId', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkVersion = filter_input(INPUT_GET, 'version', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkMode = filter_input(INPUT_GET, 'mode', FILTER_SANITIZE_STRING);
$chkDef = filter_input(INPUT_GET, 'def', FILTER_SANITIZE_STRING);
$chkRange = filter_input(INPUT_GET, 'range', FILTER_SANITIZE_STRING);
$chkId = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_STRING);
if (get_magic_quotes_gpc() == 0) {
$chkDef = addslashes($chkDef);
$chkRange = addslashes($chkRange);
}
//
// Get data
// ========
$strSQL = "SELECT * FROM `tbl_timedefinition` WHERE `tipId`=$chkTipId ORDER BY `definition`";
$chkMode = filter_input(INPUT_GET, 'mode');
$chkDef = filter_input(INPUT_GET, 'def');
$chkRange = filter_input(INPUT_GET, 'range');
$chkId = filter_input(INPUT_GET, 'id');
/*
Get data
*/
$strSQL = "SELECT * FROM `tbl_timedefinition` WHERE `tipId`=$chkTipId ORDER BY `definition`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
//
// Store data to session
// ============================
if ($chkMode == '') {
/*
Store data to session
*/
if ($chkMode === null) {
$_SESSION['timedefinition'] = array();
if ($booReturn && ($intDataCount != 0)) {
if ($booReturn && ($intDataCount !== 0)) {
foreach ($arrDataLines as $elem) {
$arrTemp['id'] = $elem['id'];
$arrTemp['definition'] = addslashes($elem['definition']);
$arrTemp['range'] = addslashes($elem['range']);
$arrTemp['status'] = 0;
$_SESSION['timedefinition'][] = $arrTemp;
$arrTemp['id'] = $elem['id'];
$arrTemp['definition'] = addslashes($elem['definition']);
$arrTemp['range'] = addslashes($elem['range']);
$arrTemp['status'] = 0;
$_SESSION['timedefinition'][] = $arrTemp;
}
}
}
//
// Add mode
// =========
if ($chkMode == 'add') {
/*
Add mode
*/
if ($chkMode === 'add') {
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition'])) {
$intCheck = 0;
foreach ($_SESSION['timedefinition'] as $key => $elem) {
if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) {
if (($elem['definition'] === $chkDef) && ((int)$elem['status'] === 0)) {
$_SESSION['timedefinition'][$key]['definition'] = $chkDef;
$_SESSION['timedefinition'][$key]['range'] = $chkRange;
$intCheck = 1;
}
}
if ($intCheck == 0) {
if ($intCheck === 0) {
$arrTemp['id'] = 0;
$arrTemp['definition'] = $chkDef;
$arrTemp['range'] = $chkRange;
@@ -90,109 +89,114 @@ if ($chkMode == 'add') {
$_SESSION['timedefinition'][] = $arrTemp;
}
}
//
// Deletion mode
// =============
if ($chkMode == 'del' && isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition'])) {
/*
Deletion mode
*/
if ($chkMode === 'del' && isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition'])) {
foreach ($_SESSION['timedefinition'] as $key => $elem) {
if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) {
if (($elem['definition'] === $chkDef) && ((int)$elem['status'] === 0)) {
$_SESSION['timedefinition'][$key]['status'] = 1;
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>None</title>
<link href="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
<!--suppress JSUnresolvedVariable -->
<script type="text/javascript">
<!--
function doEdit(key,range) {
<?php
if ($chkVersion == 3) {
?>
parent.document.frmDetail.txtTimedefinition.value = decodeURIComponent(key);
parent.document.frmDetail.txtTimerange2.value = decodeURIComponent(range);
<?php
} else {
?>
if (key === "monday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 0;
} else if (key === "tuesday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 1;
} else if (key === "wednesday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 2;
} else if (key === "thursday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 3;
} else if (key === "friday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 4;
} else if (key === "saturday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 5;
} else if (key === "sunday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 6;
}
parent.document.frmDetail.txtTimerange1.value = range;
<?php
}
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>None</title>
<link href="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
<!--suppress JSUnresolvedVariable -->
<script type="text/javascript">
<!--
function doEdit(key, range) {
<?php
if ($chkVersion >= 3) {
?>
parent.document.frmDetail.txtTimedefinition.value = decodeURIComponent(key);
parent.document.frmDetail.txtTimerange2.value = decodeURIComponent(range);
<?php
} else {
?>
if (key === "monday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 0;
} else if (key === "tuesday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 1;
} else if (key === "wednesday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 2;
} else if (key === "thursday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 3;
} else if (key === "friday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 4;
} else if (key === "saturday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 5;
} else if (key === "sunday") {
parent.document.frmDetail.selTimedefinition.selectedIndex = 6;
}
function doDel(key) {
document.location.href = "<?php
echo $_SESSION['SETS']['path']['base_url']; ?>admin/timedefinitions.php?tipId=<?php
echo $chkTipId; ?>&mode=del&def="+key;
parent.document.frmDetail.txtTimerange1.value = range;
<?php
}
//-->
</script>
<style type="text/css">
.tablerow {
border-bottom:1px solid #009900;
font-size:12px;
height:20px;
padding-top:2px;
padding-left:5px;
padding-right:5px;
}
</style>
</head>
<body style="margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<?php
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition']) &&
(count($_SESSION['timedefinition']) != 0)) {
foreach ($_SESSION['timedefinition'] as $elem) {
if ($elem['status'] == 0) {
?>
<tr>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
echo htmlentities(stripslashes($elem['definition']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
echo htmlentities(stripslashes($elem['range']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="width:50px" align="right"><img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/edit.gif" width="18" height="18" alt="<?php
echo translate('Modify'); ?>" title="<?php echo translate('Modify'); ?>" onClick="doEdit('<?php
echo rawurlencode(stripslashes($elem['definition'])); ?>','<?php
echo rawurlencode(stripslashes($elem['range'])); ?>')" style="cursor:pointer">&nbsp;<img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18" alt="<?php
echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>" onClick="doDel('<?php
echo rawurlencode(stripslashes($elem['definition'])); ?>')" style="cursor:pointer"></td>
</tr>
<?php
?>
}
function doDel(key) {
document.location.href = "<?php
echo $_SESSION['SETS']['path']['base_url']; ?>admin/timedefinitions.php?tipId=<?php
echo $chkTipId; ?>&version=<?php echo $chkVersion; ?>&mode=del&def=" + key;
}
//-->
</script>
<style type="text/css">
.tablerow {
border-bottom: 1px solid #009900;
font-size: 12px;
height: 20px;
padding-top: 2px;
padding-left: 5px;
padding-right: 5px;
}
</style>
</head>
<body style="margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<?php
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition']) &&
(count($_SESSION['timedefinition']) !== 0)) {
foreach ($_SESSION['timedefinition'] as $elem) {
if ((int)$elem['status'] === 0) {
?>
<tr>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
echo htmlentities(stripslashes($elem['definition']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
echo htmlentities(stripslashes($elem['range']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="width:50px" align="right"><img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/edit.gif" width="18" height="18" alt="<?php
echo translate('Modify'); ?>" title="<?php echo translate('Modify'); ?>" onClick="doEdit('<?php
echo rawurlencode(stripslashes($elem['definition'])); ?>','<?php
echo rawurlencode(stripslashes($elem['range'])); ?>')" style="cursor:pointer">&nbsp;<img
src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18"
alt="<?php
echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>"
onClick="doDel('<?php
echo rawurlencode(stripslashes($elem['definition'])); ?>')" style="cursor:pointer"></td>
</tr>
<?php
}
}
} else {
?>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
<td class="tablerow">&nbsp;</td>
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
} else {
?>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
<td class="tablerow">&nbsp;</td>
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
?>
</table>
</body>
?>
</table>
</body>
</html>

View File

@@ -1,95 +1,146 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Timeperiod definitions
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Timeperiod definitions
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var int $intVersion from prepend_adm.php -> Nagios version
* @var int $chkListId from prepend_adm.php -> Actual dataset id (list view)
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $strAccess from prepend_content.php -> List of read access group id's for actual user
* @var string $preSQLCommon1 from prepend_content.php -> Common SQL part 1
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
* @var string $chkTfValue1 from prepend_content.php -> Time period name
* @var string $chkTfValue2 from prepend_content.php -> Time period description
* @var string $chkTfValue3 from prepend_content.php -> Time period template name
* @var array $chkMselValue1 from prepend_content.php -> Excluded time period
* @var array $chkMselValue2 from prepend_content.php -> Included time period
* @var int $intMselValue1 from prepend_content.php -> Excluded time period multiselect status value
* @var int $intMselValue2 from prepend_content.php -> Included time period multiselect status value
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 16;
$preContent = 'admin/timeperiods.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 16;
$preContent = 'admin/timeperiods.htm.tpl';
$preListTpl = 'admin/datalist.htm.tpl';
$preSearchSession = 'timeperiod';
$preTableName = 'tbl_timeperiod';
$preKeyField = 'timeperiod_name';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$preTableName = 'tbl_timeperiod';
$preKeyField = 'timeperiod_name';
$preAccess = 1;
$preFieldvars = 1;
$intNoTime = 0;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
/*
* Default values for form variables
*/
if (!isset($intMselValue1)) {
$intMselValue1 = 0;
}
if (!isset($intMselValue2)) {
$intMselValue2 = 0;
}
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `exclude`=$intMselValue1, "
. "`use_template`=$intMselValue2, `name`='$chkTfValue3', $preSQLCommon1";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. "`use_template`=$intMselValue2, `name`='$chkTfValue3', $preSQLCommon1";
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
if ($intWriteAccessId === 0) {
if (($chkTfValue1 !== '') && ($chkTfValue2 !== '')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
if ($chkModus === 'insert') {
$chkDataId = $intInsertId;
}
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myDataClass->updateStatusTable($preTableName);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New time period inserted:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New time period inserted:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('Time period modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('Time period modified:') . ' ' . $chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
/*
Insert/update relations
*/
$intRet1 = 0;
$intRet2 = 0;
if ($chkModus === 'insert') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkTimeperiodToTimeperiod',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
if (isset($intRet1) && ($intRet1 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkTimeperiodToTimeperiodUse',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
if (isset($intRet2) && ($intRet2 !== 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
} elseif ($chkModus === 'modify') {
if ($intMselValue1 !== 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkTimeperiodToTimeperiod',
$chkDataId,
@@ -98,10 +149,10 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkTimeperiodToTimeperiod', $chkDataId);
}
if ($intRet1 != 0) {
if ($intRet1 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
if ($intMselValue2 !== 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkTimeperiodToTimeperiodUse',
$chkDataId,
@@ -110,35 +161,35 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkTimeperiodToTimeperiodUse', $chkDataId);
}
if ($intRet2 != 0) {
if ($intRet2 !== 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2) != 0) {
if (($intRet1 + $intRet2) !== 0) {
$strInfoMessage = '';
}
//
// Insert/update time defintions
// =============================
if ($chkModus == 'modify') {
$strSQL = "DELETE FROM `tbl_timedefinition` WHERE `tipId`=$chkDataId";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
/*
Insert/update time defintions
*/
if ($chkModus === 'modify') {
$strSQL = "DELETE FROM `tbl_timedefinition` WHERE `tipId`=$chkDataId";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition']) &&
(count($_SESSION['timedefinition']) != 0)) {
(count($_SESSION['timedefinition']) !== 0)) {
foreach ($_SESSION['timedefinition'] as $elem) {
if ($elem['status'] == 0) {
if ($elem['definition'] != 'use') {
if ((int)$elem['status'] === 0) {
if ($elem['definition'] !== 'use') {
$elem['range'] = str_replace(' ', '', $elem['range']);
}
$strSQL = 'INSERT INTO `tbl_timedefinition` (`tipId`,`definition`,`range`, '
. "`last_modified`) VALUES ($chkDataId,'".$elem['definition']."',"
. "'".$elem['range']."',now())";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$strSQL = 'INSERT INTO `tbl_timedefinition` (`tipId`,`definition`,`range`, '
. "`last_modified`) VALUES ($chkDataId,'" . $elem['definition'] . "',"
. "'" . $elem['range'] . "',now())";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
@@ -156,47 +207,41 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Get date/time of last database and config file manipulation
// ===========================================================
/*
Get date/time of last database and config file manipulation
*/
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
if ($intReturn !== 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
/*
Singe data form
*/
if ($chkModus === 'add') {
$intDataWarning = 0;
$strDBWarning = '';
$conttp->setVariable('TITLE', translate('Time period definitions (timeperiods.cfg)'));
// Do not show modified time list
/* Do not show modified time list */
$intNoTime = 1;
// Process exclude selection fields
if (isset($arrModifyData['exclude'])) {
$intFieldId = $arrModifyData['exclude'];
} else {
$intFieldId = 0;
}
/* Process exclude selection fields */
$intFieldId = $arrModifyData['exclude'] ?? 0;
$intReturn1 = $myVisClass->parseSelectMulti(
$preTableName,
'name',
'timeperiod_name',
'excludes',
'tbl_lnkTimeperiodToTimeperiod',
0,
$intFieldId,
$chkListId
);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process include selection fields
if (isset($arrModifyData['use_template'])) {
$intFieldId = $arrModifyData['use_template'];
} else {
$intFieldId = 0;
}
/* Process include selection fields */
$intFieldId = $arrModifyData['use_template'] ?? 0;
$intReturn2 = $myVisClass->parseSelectMulti(
$preTableName,
'name',
@@ -206,68 +251,68 @@ if ($chkModus == 'add') {
$intFieldId,
$chkListId
);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
/* Process acces group selection field */
$intFieldId = $arrModifyData['access_group'] ?? 0;
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
if ($intReturn3 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($intDataWarning === 1) {
$conttp->setVariable('WARNING', $strDBWarning . '<br>' . translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
$conttp->setVariable('LANG_INSERT_ALL_TIMERANGE', translate('Please insert a time definition and a time range'));
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Check relation information to find out locked configuration datasets */
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$strInfo = '<br><span class="redmessage">' . translate('Entry cannot be activated because it is used by '
. 'another configuration') . ':</span>';
$strInfo .= '<br><span class="greenmessage">' . $strRelMessage . '</span>';
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
$conttp->setVariable('TIP_ID', $arrModifyData['id']);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
List view
*/
if ($chkModus === 'display') {
$strSearchWhere = '';
// Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Time period definitions (timeperiods.cfg)'));
$mastertp->setVariable('FIELD_1', translate('Time period'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Process filter string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' "
. "OR `name` LIKE '%".$strSearchTxt."%')";
$mastertp->setVariable('FILTER_VISIBLE', 'visibility: hidden');
/* Process filter string */
if ($_SESSION['search'][$preSearchSession] !== '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%" . $strSearchTxt . "%' OR `alias` LIKE '%" . $strSearchTxt . "%' "
. "OR `name` LIKE '%" . $strSearchTxt . "%')";
}
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
. "AND `access_group` IN ($strAccess)";
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
. "AND `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -276,19 +321,19 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) "
. "$strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
. "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) "
. "$strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
}
// Show messages
/* Show messages */
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
@@ -298,7 +343,7 @@ $myContentClass->showMessages(
$strTimeInfoString,
$intNoTime
);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,45 +1,47 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Tools overview
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2022 by Martin Willisegger
Project : NagiosQL
Component : Tools overview
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var string $setFileVersion from prepend_adm.php -> Application version string
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 6;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 6;
$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
//
// Include content
// ===============
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Different tools'));
$conttp->setVariable('DESC', translate('Useful functions for data import, main configuration, daemon control, etc.'));
$conttp->parse('main');
$conttp->show('main');
//
// Include Footer
// ==============
/*
Include Footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,80 +1,115 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : User administration
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : User administration
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagContentClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var HTML_Template_IT $mastertp Master template (list view)
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagContentClass $myContentClass NagiosQL content class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var int $chkActive from prepend_adm.php -> Active checkbox
* @var string $chkModus from prepend_adm.php -> Form work mode
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
* @var int $hidSortBy from prepend_adm.php -> Sort data by
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
* @var int $chkLimit from prepend_adm.php / settings -> Data set count per page
* @var array $SETS Settings array
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
* @var int $intWriteAccessId from prepend_content.php -> Admin write access to actual dataset id
* @var string $chkTfValue1 from prepend_content.php -> User name
* @var string $chkTfValue2 from prepend_content.php -> User description
* @var string $chkTfValue3 from prepend_content.php -> Password
* @var string $chkTfValue4 from prepend_content.php -> Password confirmation
* @var string $chkTfValue5 from prepend_content.php -> (hidden) old user name
* @var int $chkChbValue1 from prepend_content.php -> Admin rights checkbox
* @var int $chkChbValue2 from prepend_content.php -> Webserver authentification checkbox
* @var int $chkSelValue1 from prepend_content.php -> Language selector
* @var int $chkSelValue2 from prepend_content.php -> Standard domain selector
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 32;
$preContent = 'admin/user.htm.tpl';
$preListTpl = 'admin/datalist_common.htm.tpl';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 32;
$preContent = 'admin/user.htm.tpl';
$preListTpl = 'admin/datalist_common.htm.tpl';
$preSearchSession = 'user';
$preTableName = 'tbl_user';
$preKeyField = 'username';
$preAccess = 1;
$preFieldvars = 1;
$preNoAccessGrp = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Add or modify data
// ==================
if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
// Check password
$preTableName = 'tbl_user';
$preKeyField = 'username';
$preAccess = 1;
$preFieldvars = 1;
$preNoAccessGrp = 1;
$strErrorMessage = '';
$strInfoMessage = '';
$strConsistMessage = '';
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Add or modify data
*/
if ((($chkModus === 'insert') || ($chkModus === 'modify')) && ($intGlobalWriteAccess === 0)) {
/* Check password */
if ((($chkTfValue3 === $chkTfValue4) && (strlen($chkTfValue3) > 5)) ||
(($chkModus == 'modify') && ($chkTfValue3 == ''))) {
if ($chkTfValue3 == '') {
(($chkModus === 'modify') && ($chkTfValue3 === ''))) {
if ($chkTfValue3 === '') {
$strPasswd = '';
} else {
$strPasswd = "`password`=MD5('$chkTfValue3'),";
}
// Grant admin rights
if ($chkTfValue5 == 'Admin') {
$chkTfValue1 = 'Admin';
$chkActive = '1';
/* Admin user cannot be renamed and must be active with full admin rights */
if (strtolower($chkTfValue5) === 'admin') {
$chkTfValue1 = 'admin';
$chkActive = '1';
$chkChbValue1 = '1';
}
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', $strPasswd "
. "`admin_enable`='$chkChbValue1', `wsauth`='$chkChbValue2', `active`='$chkActive', "
. "`language`='$chkSelValue1', `domain`='$chkSelValue2', `last_modified`=NOW()";
if ($chkModus == 'insert') {
$strSQL = 'INSERT INTO ' .$strSQLx;
. "`admin_enable`='$chkChbValue1', `wsauth`='$chkChbValue2', `active`='$chkActive', "
. "`language`='$chkSelValue1', `domain`='$chkSelValue2', `last_modified`=NOW()";
if ($chkModus === 'insert') {
$strSQL = 'INSERT INTO ' . $strSQLx;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$strSQL = 'UPDATE ' . $strSQLx . ' WHERE `id`=' . $chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
if ($intWriteAccessId === 0) {
if (($chkTfValue1 !== '') && ($chkTfValue2 !== '')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn == 1) {
if ($intReturn === 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
if ($chkModus == 'insert') {
$myDataClass->writeLog(translate('New user added:'). ' ' .$chkTfValue1);
if ($chkModus === 'insert') {
$myDataClass->writeLog(translate('New user added:') . ' ' . $chkTfValue1);
}
if ($chkModus == 'modify') {
$myDataClass->writeLog(translate('User modified:'). ' ' .$chkTfValue1);
if ($chkModus === 'modify') {
$myDataClass->writeLog(translate('User modified:') . ' ' . $chkTfValue1);
}
}
} else {
@@ -91,39 +126,31 @@ if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAcce
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
if ($chkModus !== 'add') {
$chkModus = 'display';
}
//
// Singe data form
// ===============
if ($chkModus == 'add') {
// Process domain selection field
if (isset($arrModifyData['domain'])) {
$intFieldId = $arrModifyData['domain'];
} else {
$intFieldId = 1;
}
/*
Singe data form
*/
if ($chkModus === 'add') {
/* Process domain selection field */
$intFieldId = $arrModifyData['domain'] ?? 1;
$intReturn1 = $myVisClass->parseSelectSimple('tbl_datadomain', 'domain', 'std_domain', 0, $intFieldId, 0);
if ($intReturn1 != 0) {
if ($intReturn1 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process language selection field
if (isset($arrModifyData['language'])) {
$intFieldId = $arrModifyData['language'];
} else {
$intFieldId = 0;
}
if ($intFieldId == 0) {
/* Process language selection field */
$intFieldId = $arrModifyData['language'] ?? 0;
if ($intFieldId === 0) {
$intFieldId = $myDBClass->getFieldData('SELECT `id` FROM `tbl_language` '
. "WHERE `locale`='".$_SESSION['SETS']['data']['locale']."'");
. "WHERE `locale`='" . $_SESSION['SETS']['data']['locale'] . "'");
$intFieldId = (int)$intFieldId;
}
$intReturn2 = $myVisClass->parseSelectSimple('tbl_language', 'language', 'language_name', 0, $intFieldId);
if ($intReturn2 != 0) {
if ($intReturn2 !== 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
/* Initial add/modify form definitions */
$myContentClass->addFormInit($conttp);
$conttp->setVariable('TITLE', translate('User administration'));
$conttp->setVariable('WSAUTH_DISABLE', 'disabled');
@@ -135,56 +162,58 @@ if ($chkModus == 'add') {
$conttp->setVariable('LANG_WEBSERVER_AUTH', translate('Webserver authentification'));
$conttp->setVariable('PASSWORD_MUST', 'class="inpmust"');
$conttp->setVariable('PASSWORD_MUST_STAR', '*');
// If webserver authetification is enabled - show option field
if (isset($SETS['security']['wsauth']) && ($SETS['security']['wsauth'] == 1)) {
$conttp->setVariable('WSAUTH_DISABLE', '');
/* If webserver authetification is enabled - show option field */
if (isset($SETS['security']['wsauth']) && ((int)$SETS['security']['wsauth'] === 1)) {
$conttp->setVariable('WSAUTH_DISABLE');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Process data
/* Insert data from database in "modify" mode */
if (isset($arrModifyData) && ($chkSelModify === 'modify')) {
/* Process data */
$myContentClass->addInsertData($conttp, $arrModifyData, 0, '');
// Webserver authentification
$conttp->setVariable('WSAUTH_CHECKED', '');
if ($arrModifyData['wsauth'] == 1) {
/* Webserver authentification */
$conttp->setVariable('WSAUTH_CHECKED');
if ((int)$arrModifyData['wsauth'] === 1) {
$conttp->setVariable('WSAUTH_CHECKED', 'checked');
}
// Object based group administration
$conttp->setVariable('ADMINENABLE_CHECKED', '');
if ($arrModifyData['admin_enable'] == 1) {
/* Object based group administration */
$conttp->setVariable('ADMINENABLE_CHECKED');
if ((int)$arrModifyData['admin_enable'] === 1) {
$conttp->setVariable('ADMINENABLE_CHECKED', 'checked');
}
// Admin rules
if ($arrModifyData[$preKeyField] == 'Admin') {
/* Admin rules */
if ((string)$arrModifyData[$preKeyField] === 'Admin') {
$conttp->setVariable('NAME_DISABLE', 'disabled');
$conttp->setVariable('ACT_DISABLE', 'disabled');
$conttp->setVariable('WSAUTH_DISABLE', 'disabled');
$conttp->setVariable('ADMINENABLE_DISABLE', 'disabled');
$conttp->setVariable('ADMINENABLE_CHECKED', 'checked');
}
$conttp->setVariable('PASSWORD_MUST', '');
$conttp->setVariable('PASSWORD_MUST_STAR', '');
$conttp->setVariable('PASSWORD_MUST');
$conttp->setVariable('PASSWORD_MUST_STAR');
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
}
//
// Data table
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
/*
Data list view
*/
if ($chkModus === 'display') {
/* Initial list view definitions */
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('User administration'));
$mastertp->setVariable('FIELD_1', translate('Username'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Row sorting
/* Row sorting */
$strOrderString = "ORDER BY `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
if ($hidSortBy === 2) {
$strOrderString = "ORDER BY `alias` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName`";
/* Count datasets */
$intLineCount = 0;
/** @noinspection SqlResolve */
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName`";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
if ($booReturn1 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
@@ -193,20 +222,20 @@ if ($chkModus == 'display') {
$chkLimit = 0;
}
}
// Get datasets
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `nodelete` "
. "FROM `$preTableName` $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
/* Get datasets */
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `nodelete` "
. "FROM `$preTableName` $strOrderString LIMIT $chkLimit," . $SETS['common']['pagelines'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
if ($booReturn2 === false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
/* Process data */
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
}
// Show messages
/* Show messages */
$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
/*
Process footer
*/
$myContentClass->showFooter($maintp, $setFileVersion);

View File

@@ -1,165 +1,192 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Variable definition list
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Variable definition list
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
/**
* Class and variable includes
* @var MysqliDbClass $myDBClass MySQL database class
*/
/*
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));
//
// Define common variables
// =======================
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$preAccess = 1;
$preNoMain = 1;
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
//
// Process post parameters
// =======================
$chkDataId = filter_input(INPUT_GET, 'dataId', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkMode = filter_input(INPUT_GET, 'mode', FILTER_SANITIZE_STRING);
$chkDef = filter_input(INPUT_GET, 'def', FILTER_SANITIZE_STRING);
$chkRange = filter_input(INPUT_GET, 'range', FILTER_SANITIZE_STRING);
$chkLinkTab = filter_input(INPUT_GET, 'linktab', FILTER_SANITIZE_STRING);
if (get_magic_quotes_gpc() == 0) {
$chkDef = addslashes($chkDef);
$chkRange = addslashes($chkRange);
}
//
// Get data
// ========
if ($chkLinkTab != '') {
$strSQL = 'SELECT * FROM `tbl_variabledefinition` LEFT JOIN `' .$chkLinkTab. '` ON `id`=`idSlave` ' .
"WHERE `idMaster`=$chkDataId ORDER BY `name`";
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
/*
Process post parameters
*/
$chkDataId = filter_input(INPUT_GET, 'dataId', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkMode = filter_input(INPUT_GET, 'mode');
$chkDef = filter_input(INPUT_GET, 'def');
$chkRange = filter_input(INPUT_GET, 'range');
$chkLinkTab = filter_input(INPUT_GET, 'linktab');
/*
Get data
*/
if ($chkLinkTab !== '') {
/** @noinspection SqlResolve */
$strSQL = 'SELECT * FROM `tbl_variabledefinition` LEFT JOIN `' . $chkLinkTab . '` ON `id`=`idSlave` ' .
"WHERE `idMaster`=$chkDataId ORDER BY `name`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
//
// Store data to session
// ============================
if ($chkMode == '') {
$arrTemp = array();
/* Store data to session */
if ($chkMode === null) {
$arrTemp = array();
$_SESSION['variabledefinition'] = array();
if ($booReturn && ($intDataCount != 0)) {
if ($booReturn && ($intDataCount !== 0)) {
foreach ($arrDataLines as $elem) {
$arrTemp['id'] = $elem['id'];
$arrTemp['definition'] = addslashes($elem['name']);
$arrTemp['range'] = addslashes($elem['value']);
$arrTemp['status'] = 0;
$arrTemp['id'] = $elem['id'];
$arrTemp['definition'] = addslashes($elem['name']);
$arrTemp['range'] = addslashes($elem['value']);
$arrTemp['status'] = 0;
$_SESSION['variabledefinition'][] = $arrTemp;
}
}
}
}
//
// Add mode
// ========
if ($chkMode == 'add') {
/*
Add mode
*/
if ($chkMode === 'add') {
$arrTemp = array();
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition'])) {
$intCheck = 0;
foreach ($_SESSION['variabledefinition'] as $key => $elem) {
if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) {
if (($elem['definition'] === $chkDef) && ((int)$elem['status'] === 0)) {
$_SESSION['variabledefinition'][$key]['definition'] = $chkDef;
$_SESSION['variabledefinition'][$key]['range'] = $chkRange;
$intCheck = 1;
}
}
if ($intCheck == 0) {
$arrTemp['id'] = 0;
$arrTemp['definition'] = $chkDef;
$arrTemp['range'] = $chkRange;
$arrTemp['status'] = 0;
if ($intCheck === 0) {
$arrTemp['id'] = 0;
$arrTemp['definition'] = $chkDef;
$arrTemp['range'] = $chkRange;
$arrTemp['status'] = 0;
$_SESSION['variabledefinition'][] = $arrTemp;
}
} else {
$arrTemp['id'] = 0;
$arrTemp['definition'] = $chkDef;
$arrTemp['range'] = $chkRange;
$arrTemp['status'] = 0;
$arrTemp['id'] = 0;
$arrTemp['definition'] = $chkDef;
$arrTemp['range'] = $chkRange;
$arrTemp['status'] = 0;
$_SESSION['variabledefinition'][] = $arrTemp;
}
}
//
// Deletion mode
// =============
if ($chkMode == 'del' && isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition'])) {
/*
Deletion mode
*/
if ($chkMode === 'del' && isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition'])) {
foreach ($_SESSION['variabledefinition'] as $key => $elem) {
if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) {
if (($elem['definition'] === $chkDef) && ((int)$elem['status'] === 0)) {
$_SESSION['variabledefinition'][$key]['status'] = 1;
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>None</title>
<link href="<?php echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
<!--suppress JSUnresolvedVariable -->
<script type="text/javascript">
function doEdit(key,range) {
parent.document.frmDetail.txtVariablename.value = decodeURIComponent(key);
parent.document.frmDetail.txtVariablevalue.value = decodeURIComponent(range);
}
function doDel(key) {
let link;
link = '<?php echo $_SESSION['SETS']['path']['base_url']; ?>';
link = link+'admin/variabledefinitions.php?dataId=<?php echo $chkDataId; ?>&mode=del&def='+key;
document.location.href = link;
}
function b64DecodeUnicode(str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
function decodeHtml(html) {
let txt = document.createElement("textarea");
txt.innerHTML = html;
return txt.value;
}
function doEdit(key, range) {
parent.document.frmDetail.txtVariablename.value = decodeURIComponent(key);
parent.document.frmDetail.txtVariablevalue.value = decodeHtml(b64DecodeUnicode(range));
}
function doDel(key) {
let link;
link = '<?php echo $_SESSION['SETS']['path']['base_url']; ?>';
link = link + 'admin/variabledefinitions.php?dataId=<?php echo $chkDataId; ?>&mode=del&def=' + key;
document.location.href = link;
}
</script>
</head>
<body style="margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<?php
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
(count($_SESSION['variabledefinition']) != 0)) {
foreach ($_SESSION['variabledefinition'] as $elem) {
if ($elem['status'] == 0) {
?>
<tr>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
echo htmlentities(stripslashes($elem['definition']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
echo htmlentities(stripslashes($elem['range']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="width:50px" align="right"><img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/edit.gif" width="18" height="18" alt="<?php
echo translate('Modify'); ?>" title="<?php echo translate('Modify'); ?>" onClick="doEdit('<?php
echo rawurlencode(stripslashes($elem['definition'])); ?>','<?php
echo rawurlencode(stripslashes($elem['range'])); ?>')" style="cursor:pointer">&nbsp;<img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18" alt="<?php
echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>" onClick="doDel('<?php
echo rawurlencode(stripslashes($elem['definition'])); ?>')" style="cursor:pointer"></td>
</tr>
<?php
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<?php
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
(count($_SESSION['variabledefinition']) !== 0)) {
$intCounter = 0;
foreach ($_SESSION['variabledefinition'] as $elem) {
if ((int)$elem['status'] === 0) {
$intCounter++;
?>
<tr>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
echo htmlentities(stripslashes($elem['definition']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
echo $elem['range']; ?></td>
<td class="tablerow" style="width:50px" align="right"><img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/edit.gif" width="18" height="18" alt="<?php
echo translate('Modify'); ?>" title="<?php echo translate('Modify'); ?>" onClick="doEdit('<?php
echo rawurlencode(stripslashes($elem['definition'])); ?>','<?php
echo base64_encode($elem['range']); ?>')" style="cursor:pointer">&nbsp;<img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18"
alt="<?php
echo translate('Delete'); ?>"
title="<?php echo translate('Delete'); ?>"
onClick="doDel('<?php
echo rawurlencode(stripslashes($elem['definition'])); ?>')"
style="cursor:pointer">
</td>
</tr>
<?php
}
}
}
} else {
?>
if ($intCounter === 0) {
?>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
<td class="tablerow">&nbsp;</td>
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
} else {
?>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
<td class="tablerow">&nbsp;</td>
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</table>
</body>
</html>

View File

@@ -1,575 +1,565 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Configuration verification
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Configuration verification
Website : https:/*sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https:/*gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
use functions\MysqliDbClass;
use functions\NagConfigClass;
use functions\NagDataClass;
use functions\NagVisualClass;
/**
* Class and variable includes
* @var HTML_Template_IT $conttp Content template
* @var HTML_Template_IT $maintp Main template
* @var MysqliDbClass $myDBClass MySQL database class
* @var NagVisualClass $myVisClass Visual content class
* @var NagDataClass $myDataClass NagiosQL data class
* @var NagConfigClass $myConfigClass NagiosQL configuration class
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $prePageKey from prepend_adm.php -> Menu group id
* @var int $chkDomainId from prepend_adm.php -> Configuration domain id
* @var string $chkButValue1 from prepend_content.php -> Write monitoring data button
* @var string $chkButValue2 from prepend_content.php -> Write additional data button
* @var string $chkButValue3 from prepend_content.php -> Check configuration button
* @var string $chkButValue4 from prepend_content.php -> Restart Nagios button
*/
/*
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));
//
// Define common variables
// =======================
$prePageId = 30;
$preContent = 'admin/verify.htm.tpl';
$preAccess = 1;
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$prePageId = 30;
$preContent = 'admin/verify.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$intModus = 0;
$strInfo = '';
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
// Get configuration set ID
// ========================
$intModus = 0;
$strInfo = '';
$strErrorMessage = '';
$strInfoMessage = '';
/*
Include preprocessing files
*/
require $preBasePath . 'functions/prepend_adm.php';
require $preBasePath . 'functions/prepend_content.php';
/*
Get configuration set ID
*/
$intMethod = 0;
$strMethod = '';
$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
//
// Process form variables
// ======================
$intConfigId = (int)$arrConfigSet[0];
if ($myConfigClass->getConfigValues($intConfigId, 'method', $strMethod) === 0) {
$intMethod = (int)$strMethod;
}
/*
Process form variables
*/
$intProcessError = 0;
$intError = 0;
// Write monitoring data
if ($chkButValue1 != '') {
$strNoData = translate('Writing of the configuration failed - no dataset or not activated dataset found'). '::';
// Write host configuration
$strSQL1 = "SELECT `id` FROM `tbl_host` WHERE `config_id` = $chkDomainId AND `active`='1'";
$intError = 0;
/* Write monitoring data */
if (($chkButValue1 !== '') && ($chkButValue1 !== null)) {
$strNoData = translate('Writing of the configuration failed - no dataset or not activated dataset found') . '::';
/* Write host configuration */
$strSQL1 = "SELECT `id` FROM `tbl_host` WHERE `config_id` = $chkDomainId AND `active`='1'";
$myDBClass->hasDataArray($strSQL1, $arrData, $intDataCount);
if ($intDataCount != 0) {
if ($intDataCount !== 0) {
$intError = 0;
foreach ($arrData as $data) {
$intReturn = $myConfigClass->createConfigSingle('tbl_host', $data['id']);
$intError += $intReturn;
}
}
if (($intError == 0) && ($intDataCount != 0)) {
$myVisClass->processMessage(translate('Write host configurations'). ' ...', $strInfo);
$myVisClass->processMessage('Hosts: ' .translate('Configuration file successfully written!'), $strInfo);
} elseif ($intDataCount != 0) {
$myVisClass->processMessage('Hosts: ' .translate('Cannot open/overwrite the configuration file (check the '
if (($intError === 0) && ($intDataCount !== 0)) {
$myVisClass->processMessage(translate('Write host configurations') . ' ...', $strInfo);
$myVisClass->processMessage('Hosts: ' . translate('Configuration file successfully written!'), $strInfo);
} elseif ($intDataCount !== 0) {
$myVisClass->processMessage('Hosts: ' . translate('Cannot open/overwrite the configuration file (check the '
. 'permissions)!'), $strErrorMessage);
$intProcessError = 1;
} else {
$myVisClass->processMessage('Hosts: ' .translate('No configuration items defined!'), $strErrorMessage);
$myVisClass->processMessage('Hosts: ' . translate('No configuration items defined!'), $strErrorMessage);
$intProcessError = 1;
}
// Write service configuration
$strSQL = 'SELECT `id`, `config_name` '
/* Write service configuration */
$strSQL = 'SELECT `id`, `config_name` '
. "FROM `tbl_service` WHERE `config_id` = $chkDomainId AND `active`='1' GROUP BY `config_name`";
$myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($intDataCount != 0) {
if ($intDataCount !== 0) {
$intError = 0;
foreach ($arrData as $data) {
$intReturn = $myConfigClass->createConfigSingle('tbl_service', $data['id']);
$intError += $intReturn;
}
}
if (($intError == 0) && ($intDataCount != 0)) {
$myVisClass->processMessage(translate('Write service configurations'). ' ...', $strInfo);
$myVisClass->processMessage('Services: ' .translate('Configuration file successfully written!'), $strInfo);
} elseif ($intDataCount != 0) {
$myVisClass->processMessage('Services: ' .translate('Cannot open/overwrite the configuration file (check the '
if (($intError === 0) && ($intDataCount !== 0)) {
$myVisClass->processMessage(translate('Write service configurations') . ' ...', $strInfo);
$myVisClass->processMessage('Services: ' . translate('Configuration file successfully written!'), $strInfo);
} elseif ($intDataCount !== 0) {
$myVisClass->processMessage('Services: ' . translate('Cannot open/overwrite the configuration file (check the '
. 'permissions)!'), $strErrorMessage);
$intProcessError = 1;
} else {
$myVisClass->processMessage('Services: ' .translate('No configuration items defined!'), $strErrorMessage);
$myVisClass->processMessage('Services: ' . translate('No configuration items defined!'), $strErrorMessage);
$intProcessError = 1;
}
// Write hostgroup configuration
/* Write hostgroup configuration */
$intReturn1 = $myConfigClass->createConfig('tbl_hostgroup');
if ($intReturn1 == 0) {
$myVisClass->processMessage(translate('Write'). ' hostgroups.cfg ...', $strInfo);
$myVisClass->processMessage('Hostgroups: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn1 === 0) {
$myVisClass->processMessage(translate('Write') . ' hostgroups.cfg ...', $strInfo);
$myVisClass->processMessage('Hostgroups: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' hostgroups.cfg ...', $strInfo);
$myVisClass->processMessage('Hostgroups: ' . translate('No dataset or no activated dataset found - empty '
. 'configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' hostgroups.cfg ...', $strInfo);
$myVisClass->processMessage('Hostgroups: ' .translate('No dataset or no activated dataset found - empty '
. 'configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Hostgroups: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Hostgroups: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write servicegroup configuration
/* Write servicegroup configuration */
$intReturn2 = $myConfigClass->createConfig('tbl_servicegroup');
if ($intReturn2 == 0) {
$myVisClass->processMessage(translate('Write'). ' servicegroups.cfg ...', $strInfo);
$myVisClass->processMessage('Servicegroups: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn2 === 0) {
$myVisClass->processMessage(translate('Write') . ' servicegroups.cfg ...', $strInfo);
$myVisClass->processMessage('Servicegroups: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' servicegroups.cfg ...', $strInfo);
$myVisClass->processMessage('Servicegroups: ' . translate('No dataset or no activated dataset found - empty '
. 'configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' servicegroups.cfg ...', $strInfo);
$myVisClass->processMessage('Servicegroups: ' .translate('No dataset or no activated dataset found - empty '
. 'configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Servicegroups: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Servicegroups: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write hosttemplate configuration
/* Write hosttemplate configuration */
$intReturn3 = $myConfigClass->createConfig('tbl_hosttemplate');
if ($intReturn3 == 0) {
$myVisClass->processMessage(translate('Write'). ' hosttemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Hosttemplates: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn3 === 0) {
$myVisClass->processMessage(translate('Write') . ' hosttemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Hosttemplates: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' hosttemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Hosttemplates: ' . translate('No dataset or no activated dataset found - empty '
. 'configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' hosttemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Hosttemplates: ' .translate('No dataset or no activated dataset found - empty '
. 'configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Hosttemplates: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Hosttemplates: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write servicetemplate configuration
/* Write servicetemplate configuration */
$intReturn4 = $myConfigClass->createConfig('tbl_servicetemplate');
if ($intReturn4 == 0) {
$myVisClass->processMessage(translate('Write'). ' servicetemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Servicetemplates: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn4 === 0) {
$myVisClass->processMessage(translate('Write') . ' servicetemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Servicetemplates: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' servicetemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Servicetemplates: ' . translate('No dataset or no activated dataset found - '
. 'empty configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' servicetemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Servicetemplates: ' .translate('No dataset or no activated dataset found - '
. 'empty configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Servicetemplates: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Servicetemplates: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
}
// Write additional data
if ($chkButValue2 != '') {
$strNoData = translate('Writing of the configuration failed - no dataset or not activated dataset found'). '::';
// Write timeperiod configuration
/* Write additional data */
if (($chkButValue2 !== '') && ($chkButValue2 !== null)) {
$strNoData = translate('Writing of the configuration failed - no dataset or not activated dataset found') . '::';
/* Write timeperiod configuration */
$intReturn5 = $myConfigClass->createConfig('tbl_timeperiod');
if ($intReturn5 == 0) {
$myVisClass->processMessage(translate('Write'). ' timeperiods.cfg ...', $strInfo);
$myVisClass->processMessage('Timeperiods: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn5 === 0) {
$myVisClass->processMessage(translate('Write') . ' timeperiods.cfg ...', $strInfo);
$myVisClass->processMessage('Timeperiods: ' . $myConfigClass->strInfoMessage, $strInfo);
} else {
$myVisClass->processMessage('Timeperiods: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage('Timeperiods: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write command configuration
/* Write command configuration */
$intReturn6 = $myConfigClass->createConfig('tbl_command');
if ($intReturn6 == 0) {
$myVisClass->processMessage(translate('Write'). ' commands.cfg ...', $strInfo);
$myVisClass->processMessage('Commands: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn6 === 0) {
$myVisClass->processMessage(translate('Write') . ' commands.cfg ...', $strInfo);
$myVisClass->processMessage('Commands: ' . $myConfigClass->strInfoMessage, $strInfo);
} else {
$myVisClass->processMessage('Commands: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage('Commands: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write contact configuration
/* Write contact configuration */
$intReturn7 = $myConfigClass->createConfig('tbl_contact');
if ($intReturn7 == 0) {
$myVisClass->processMessage(translate('Write'). ' contacts.cfg ...', $strInfo);
$myVisClass->processMessage('Contacts: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn7 === 0) {
$myVisClass->processMessage(translate('Write') . ' contacts.cfg ...', $strInfo);
$myVisClass->processMessage('Contacts: ' . $myConfigClass->strInfoMessage, $strInfo);
} else {
$myVisClass->processMessage('Contacts: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage('Contacts: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write contactgroup configuration
/* Write contactgroup configuration */
$intReturn8 = $myConfigClass->createConfig('tbl_contactgroup');
if ($intReturn8 == 0) {
$myVisClass->processMessage(translate('Write'). ' contactgroups.cfg ...', $strInfo);
$myVisClass->processMessage('Contactgroups: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn8 === 0) {
$myVisClass->processMessage(translate('Write') . ' contactgroups.cfg ...', $strInfo);
$myVisClass->processMessage('Contactgroups: ' . $myConfigClass->strInfoMessage, $strInfo);
} else {
$myVisClass->processMessage('Contactgroups: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage('Contactgroups: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write contacttemplate configuration
/* Write contacttemplate configuration */
$intReturn9 = $myConfigClass->createConfig('tbl_contacttemplate');
if ($intReturn9 == 0) {
$myVisClass->processMessage(translate('Write'). ' contacttemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Contacttemplates: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn9 === 0) {
$myVisClass->processMessage(translate('Write') . ' contacttemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Contacttemplates: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' contacttemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Contacttemplates: ' . translate('No dataset or no activated dataset found - '
. 'empty configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' contacttemplates.cfg ...', $strInfo);
$myVisClass->processMessage('Contacttemplates: ' .translate('No dataset or no activated dataset found - '
. 'empty configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Contacttemplates: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Contacttemplates: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write servicedependency configuration
/* Write servicedependency configuration */
$intReturn10 = $myConfigClass->createConfig('tbl_servicedependency');
if ($intReturn10 == 0) {
$myVisClass->processMessage(translate('Write'). ' servicedependencies.cfg ...', $strInfo);
$myVisClass->processMessage('Servicedependencies: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn10 === 0) {
$myVisClass->processMessage(translate('Write') . ' servicedependencies.cfg ...', $strInfo);
$myVisClass->processMessage('Servicedependencies: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' servicedependencies.cfg ...', $strInfo);
$myVisClass->processMessage('Servicedependencies: ' . translate('No dataset or no activated dataset found - '
. 'empty configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' servicedependencies.cfg ...', $strInfo);
$myVisClass->processMessage('Servicedependencies: ' .translate('No dataset or no activated dataset found - '
. 'empty configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Servicedependencies: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Servicedependencies: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write hostdependency configuration
/* Write hostdependency configuration */
$intReturn11 = $myConfigClass->createConfig('tbl_hostdependency');
if ($intReturn11 == 0) {
$myVisClass->processMessage(translate('Write'). ' hostdependencies.cfg ...', $strInfo);
$myVisClass->processMessage('Hostdependencies: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn11 === 0) {
$myVisClass->processMessage(translate('Write') . ' hostdependencies.cfg ...', $strInfo);
$myVisClass->processMessage('Hostdependencies: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' hostdependencies.cfg ...', $strInfo);
$myVisClass->processMessage('Hostdependencies: ' . translate('No dataset or no activated dataset found - '
. 'empty configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' hostdependencies.cfg ...', $strInfo);
$myVisClass->processMessage('Hostdependencies: ' .translate('No dataset or no activated dataset found - '
. 'empty configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Hostdependencies: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Hostdependencies: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write serviceescalation configuration
/* Write serviceescalation configuration */
$intReturn12 = $myConfigClass->createConfig('tbl_serviceescalation');
if ($intReturn12 == 0) {
$myVisClass->processMessage(translate('Write'). ' serviceescalations.cfg ...', $strInfo);
$myVisClass->processMessage('Serviceescalations: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn12 === 0) {
$myVisClass->processMessage(translate('Write') . ' serviceescalations.cfg ...', $strInfo);
$myVisClass->processMessage('Serviceescalations: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' serviceescalations.cfg ...', $strInfo);
$myVisClass->processMessage('Serviceescalations: ' . translate('No dataset or no activated dataset found - '
. 'empty configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' serviceescalations.cfg ...', $strInfo);
$myVisClass->processMessage('Serviceescalations: ' .translate('No dataset or no activated dataset found - '
. 'empty configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Serviceescalations: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Serviceescalations: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write hostescalation configuration
/* Write hostescalation configuration */
$intReturn13 = $myConfigClass->createConfig('tbl_hostescalation');
if ($intReturn13 == 0) {
$myVisClass->processMessage(translate('Write'). ' hostescalations.cfg ...', $strInfo);
$myVisClass->processMessage('Hostescalations: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn13 === 0) {
$myVisClass->processMessage(translate('Write') . ' hostescalations.cfg ...', $strInfo);
$myVisClass->processMessage('Hostescalations: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' hostescalations.cfg ...', $strInfo);
$myVisClass->processMessage('Hostescalations: ' . translate('No dataset or no activated dataset found - '
. 'empty configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' hostescalations.cfg ...', $strInfo);
$myVisClass->processMessage('Hostescalations: ' .translate('No dataset or no activated dataset found - '
. 'empty configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Hostescalations: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Hostescalations: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write serviceextinfo configuration
/* Write serviceextinfo configuration */
$intReturn14 = $myConfigClass->createConfig('tbl_serviceextinfo');
if ($intReturn14 == 0) {
$myVisClass->processMessage(translate('Write'). ' serviceextinfo.cfg ...', $strInfo);
$myVisClass->processMessage('Serviceextinfo: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn14 === 0) {
$myVisClass->processMessage(translate('Write') . ' serviceextinfo.cfg ...', $strInfo);
$myVisClass->processMessage('Serviceextinfo: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' serviceextinfo.cfg ...', $strInfo);
$myVisClass->processMessage('Serviceextinfo: ' . translate('No dataset or no activated dataset found - '
. 'empty configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' serviceextinfo.cfg ...', $strInfo);
$myVisClass->processMessage('Serviceextinfo: ' .translate('No dataset or no activated dataset found - '
. 'empty configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Serviceextinfo: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Serviceextinfo: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
// Write hostextinfo configuration
/* Write hostextinfo configuration */
$intReturn15 = $myConfigClass->createConfig('tbl_hostextinfo');
if ($intReturn15 == 0) {
$myVisClass->processMessage(translate('Write'). ' hostextinfo.cfg ...', $strInfo);
$myVisClass->processMessage('Hostextinfo: ' .$myConfigClass->strInfoMessage, $strInfo);
if ($intReturn15 === 0) {
$myVisClass->processMessage(translate('Write') . ' hostextinfo.cfg ...', $strInfo);
$myVisClass->processMessage('Hostextinfo: ' . $myConfigClass->strInfoMessage, $strInfo);
} else if ($myConfigClass->strErrorMessage === $strNoData) {
$myVisClass->processMessage(translate('Write') . ' hostextinfo.cfg ...', $strInfo);
$myVisClass->processMessage('Hostextinfo: ' . translate('No dataset or no activated dataset found - empty '
. 'configuration written') . '::', $strInfo);
} else {
if ($myConfigClass->strErrorMessage == $strNoData) {
$myVisClass->processMessage(translate('Write'). ' hostextinfo.cfg ...', $strInfo);
$myVisClass->processMessage('Hostextinfo: ' .translate('No dataset or no activated dataset found - empty '
. 'configuration written'). '::', $strInfo);
} else {
$myVisClass->processMessage('Hostextinfo: ' .$myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
$myVisClass->processMessage('Hostextinfo: ' . $myConfigClass->strErrorMessage, $strErrorMessage);
$intProcessError = 1;
}
}
// Check configuration
if ($chkButValue3 != '') {
/* Check configuration */
if (($chkButValue3 !== '') && ($chkButValue3 !== null)) {
$myConfigClass->getConfigValues($intConfigId, 'binaryfile', $strBinary);
$myConfigClass->getConfigValues($intConfigId, 'basedir', $strBaseDir);
$myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strNagiosBaseDir);
$myConfigClass->getConfigValues($intConfigId, 'conffile', $strConffile);
if ($intMethod == 1) {
if ($intMethod === 1) {
if (file_exists($strBinary) && is_executable($strBinary)) {
$resFile = popen($strBinary. ' -v ' .$strConffile, 'r');
$resFile = popen($strBinary . ' -v ' . $strConffile, 'r');
} else {
$myVisClass->processMessage(
translate('Cannot find the Nagios binary or no execute permissions!'),
$strErrorMessage
);
}
} elseif ($intMethod == 2) {
} elseif ($intMethod === 2) {
$booReturn = 0;
if (empty($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
if (empty($myConfigClass->conFTPConId)) {
$booReturn = $myConfigClass->getFTPConnection($intConfigId);
}
if ($booReturn == 1) {
if ($booReturn === 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} else {
$intErrorReporting = error_reporting();
error_reporting(0);
if (!($resFile = ftp_exec($myConfigClass->resConnectId, $strBinary.' -v '.$strConffile))) {
if (!($resFile = ftp_exec($myConfigClass->conFTPConId, $strBinary . ' -v ' . $strConffile))) {
$myVisClass->processMessage(translate('Remote execution (FTP SITE EXEC) is not supported on your '
. 'system!'), $strErrorMessage);
}
ftp_close($conn_id);
ftp_close($myConfigClass->conFTPConId);
error_reporting($intErrorReporting);
}
} elseif ($intMethod == 3) {
} elseif ($intMethod === 3) {
$booReturn = 0;
if (empty($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
if (empty($myConfigClass->resSSHConId) || !is_resource($myConfigClass->resSSHConId)) {
$booReturn = $myConfigClass->getSSHConnection($intConfigId);
}
if ($booReturn == 1) {
if ($booReturn === 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} else {
if (($strBinary != '') && ($strConffile != '') &&
$myConfigClass->sendSSHCommand('ls '.$strBinary, $arrTemp) == 0 &&
$myConfigClass->sendSSHCommand('ls '.$strConffile, $arrTemp) == 0) {
$intResult = $myConfigClass->sendSSHCommand($strBinary.' -v '.$strConffile, $arrResult, 15000);
if (!is_array($arrResult) || ($arrResult == false)) {
$myVisClass->processMessage(translate('Remote execution of nagios verify command failed (remote '
. 'SSH)!'), $strErrorMessage);
}
} else {
$myVisClass->processMessage(
translate('Nagios binary or configuration file not found (remote SSH)!'),
$strErrorMessage
);
} else if (($strBinary !== '') && ($strConffile !== '') &&
$myConfigClass->sendSSHCommand('ls ' . $strBinary, $arrTemp) === 0 &&
$myConfigClass->sendSSHCommand('ls ' . $strConffile, $arrTemp) === 0) {
$intResult = $myConfigClass->sendSSHCommand($strBinary . ' -v ' . $strConffile, $arrResult, 15000);
if (!is_array($arrResult)) {
$myVisClass->processMessage(translate('Remote execution of nagios verify command failed (remote '
. 'SSH)!'), $strErrorMessage);
}
} else {
$myVisClass->processMessage(
translate('Nagios binary or configuration file not found (remote SSH)!'),
$strErrorMessage
);
}
}
}
// Restart nagios
if ($chkButValue4 != '') {
// Read config file
/* Restart nagios */
if (($chkButValue4 !== '') && ($chkButValue4 !== null)) {
/* Read config file */
$myConfigClass->getConfigValues($intConfigId, 'commandfile', $strCommandfile);
$myConfigClass->getConfigValues($intConfigId, 'binaryfile', $strBinary);
$myConfigClass->getConfigValues($intConfigId, 'pidfile', $strPidfile);
$myConfigClass->getConfigValues($intConfigId, 'version', $intVersion);
// Check state nagios demon
/* Check state nagios demon */
clearstatcache();
if ($intMethod == 1) {
if (substr_count(PHP_OS, 'Linux') != 0) {
exec('ps -ef | grep '.basename($strBinary).' | grep -v grep', $arrExec);
if ($intMethod === 1) {
if (substr_count(PHP_OS, 'Linux') !== 0) {
exec('ps -ef | grep ' . basename($strBinary) . ' | grep -v grep', $arrExec);
} else {
$arrExec[0] = 1;
}
if (file_exists($strPidfile) && isset($arrExec[0])) {
if (file_exists($strCommandfile) && is_writable($strCommandfile)) {
if ($intVersion == 4) {
$strCommandString = '[' .time(). "] RESTART_PROGRAM\n";
} else {
$strCommandString = '[' .time(). '] RESTART_PROGRAM;' .time()."\n";
}
$timeout = 3;
$old = ini_set('default_socket_timeout', $timeout);
$resCmdFile = fopen($strCommandfile, 'wb');
ini_set('default_socket_timeout', $old);
stream_set_timeout($resCmdFile, $timeout);
stream_set_blocking($resCmdFile, 0);
if ($resCmdFile) {
fwrite($resCmdFile, $strCommandString);
fclose($resCmdFile);
$myDataClass->writeLog(translate('Nagios daemon successfully restarted'));
$myVisClass->processMessage(
translate('Restart command successfully send to Nagios'),
$strInfoMessage
);
} else {
$myDataClass->writeLog(translate('Restart failed - Nagios command file not found or no execute '
. 'permissions'));
$myVisClass->processMessage(
translate('Nagios command file not found or no write permissions!'),
$strErrorMessage
);
}
if (file_exists($strCommandfile) && is_writable($strCommandfile)) {
if ($intVersion === 4) {
$strCommandString = '[' . time() . "] RESTART_PROGRAM\n";
} else {
$strCommandString = '[' . time() . '] RESTART_PROGRAM;' . time() . "\n";
}
$timeout = 3;
$old = ini_set('default_socket_timeout', $timeout);
$resCmdFile = fopen($strCommandfile, 'wb');
ini_set('default_socket_timeout', $old);
stream_set_timeout($resCmdFile, $timeout);
stream_set_blocking($resCmdFile, 0);
if ($resCmdFile) {
fwrite($resCmdFile, $strCommandString);
fclose($resCmdFile);
$myDataClass->writeLog(translate('Nagios daemon successfully restarted'));
$myVisClass->processMessage(
translate('Restart command successfully send to Nagios'),
$strInfoMessage
);
} else {
$myDataClass->writeLog(translate('Restart failed - Nagios command file not found or no execute '
. 'permissions'));
$myVisClass->processMessage(translate('Restart failed - Nagios command file not found or no rights '
. 'to execute'), $strErrorMessage);
$myVisClass->processMessage(
translate('Nagios command file not found or no write permissions!'),
$strErrorMessage
);
}
} else {
$myDataClass->writeLog(translate('Restart failed - Nagios daemon was not running'));
$myVisClass->processMessage(
translate('Nagios daemon is not running, cannot send restart command!'),
$strErrorMessage
);
$myDataClass->writeLog(translate('Restart failed - Nagios command file not found or no execute '
. 'permissions'));
$myVisClass->processMessage(translate('Restart failed - Nagios command file not found or no rights '
. 'to execute'), $strErrorMessage);
}
} elseif ($intMethod == 2) {
} elseif ($intMethod === 2) {
$myDataClass->writeLog(translate('Restart failed - FTP restrictions'));
$myVisClass->processMessage(
translate('Nagios restart is not possible via FTP remote connection!'),
$strErrorMessage
);
} elseif ($intMethod == 3) {
} elseif ($intMethod === 3) {
$booReturn = 0;
if (empty($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
if (empty($myConfigClass->resSSHConId) || !is_resource($myConfigClass->resSSHConId)) {
$booReturn = $myConfigClass->getSSHConnection($intConfigId);
}
if ($booReturn == 1) {
if ($booReturn === 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} else {
if ($myConfigClass->sendSSHCommand('ls '.$strCommandfile, $arrTemp) == 0) {
if ($intVersion == 4) {
$strCommandString = '[' .time(). "] RESTART_PROGRAM\n";
} else {
$strCommandString = '[' .time(). '] RESTART_PROGRAM;' .time()."\n";
}
$arrInfo1 = ssh2_sftp_stat($myConfigClass->resSFTP, $strCommandfile);
$intFileStamp1 = $arrInfo1['mtime'];
$myConfigClass->sendSSHCommand('echo "'.$strCommandString.'" >> '.$strCommandfile, $arrResult);
$arrInfo2 = ssh2_sftp_stat($myConfigClass->resSFTP, $strCommandfile);
$intFileStamp2 = $arrInfo2['mtime'];
if ($intFileStamp2 <= $intFileStamp1) {
$myVisClass->processMessage(translate('Restart failed - Nagios command file not found or no '
. 'rights to execute (remote SSH)!'), $strErrorMessage);
} else {
$myDataClass->writeLog(translate('Nagios daemon successfully restarted (remote SSH)'));
$myVisClass->processMessage(
translate('Restart command successfully send to Nagios (remote SSH)'),
$strInfoMessage
);
}
} else if ($myConfigClass->sendSSHCommand('ls ' . $strCommandfile, $arrTemp) === 0) {
if ($intVersion === 4) {
$strCommandString = '[' . time() . "] RESTART_PROGRAM\n";
} else {
$myVisClass->processMessage(translate('Nagios command file not found (remote SSH)!'), $strErrorMessage);
$strCommandString = '[' . time() . '] RESTART_PROGRAM;' . time() . "\n";
}
$arrInfo1 = ssh2_sftp_stat($myConfigClass->resSFTP, $strCommandfile);
$intFileStamp1 = $arrInfo1['mtime'];
$myConfigClass->sendSSHCommand('echo "' . $strCommandString . '" >> ' . $strCommandfile, $arrResult);
$arrInfo2 = ssh2_sftp_stat($myConfigClass->resSFTP, $strCommandfile);
$intFileStamp2 = $arrInfo2['mtime'];
if ($intFileStamp2 <= $intFileStamp1) {
$myVisClass->processMessage(translate('Restart failed - Nagios command file not found or no '
. 'rights to execute (remote SSH)!'), $strErrorMessage);
} else {
$myDataClass->writeLog(translate('Nagios daemon successfully restarted (remote SSH)'));
$myVisClass->processMessage(
translate('Restart command successfully send to Nagios (remote SSH)'),
$strInfoMessage
);
}
} else {
$myVisClass->processMessage(translate('Nagios command file not found (remote SSH)!'), $strErrorMessage);
}
}
}
//
// include content
// ===============
/*
Include content
*/
$conttp->setVariable('TITLE', translate('Check written configuration files'));
$conttp->setVariable('CHECK_CONFIG', translate('Check configuration files:'));
$conttp->setVariable('RESTART_NAGIOS', translate('Restart Nagios:'));
$conttp->setVariable('WRITE_MONITORING_DATA', translate('Write monitoring data'));
$conttp->setVariable('WRITE_ADDITIONAL_DATA', translate('Write additional data'));
if (($chkButValue3 == '') && ($chkButValue4 == '')) {
if (($chkButValue3 === '') && ($chkButValue4 === '')) {
$conttp->setVariable('WARNING', translate('Warning, always check the configuration files before restarting '
.'Nagios!'));
. 'Nagios!'));
}
$conttp->setVariable('MAKE', translate('Do it'));
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url'] . 'images/');
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF'));
$strOutput = '';
if (isset($resFile) && ($resFile != false)) {
$intError = 0;
if (isset($resFile) && ($resFile !== false)) {
$intError = 0;
$intWarning = 0;
$intLines = 0;
$intLines = 0;
while (!feof($resFile)) {
$strLine = fgets($resFile, 1024);
$intLines++;
if ((substr_count($strLine, 'Error:') != 0) || (substr_count($strLine, 'Total Errors:') != 0)) {
if ((substr_count($strLine, 'Error:') !== 0) || (substr_count($strLine, 'Total Errors:') !== 0)) {
$conttp->setVariable('VERIFY_CLASS', 'errormessage');
$conttp->setVariable('VERIFY_LINE', $strLine);
$conttp->parse('verifyline');
$intError++;
if (substr_count($strLine, 'Total Errors:') != 0) {
if (substr_count($strLine, 'Total Errors:') !== 0) {
$intError--;
}
}
if ((substr_count($strLine, 'Warning:') != 0) || (substr_count($strLine, 'Total Warnings:') != 0)) {
if ((substr_count($strLine, 'Warning:') !== 0) || (substr_count($strLine, 'Total Warnings:') !== 0)) {
$conttp->setVariable('VERIFY_CLASS', 'warnmessage');
$conttp->setVariable('VERIFY_LINE', $strLine);
$conttp->parse('verifyline');
$intWarning++;
if (substr_count($strLine, 'Total Warnings:') != 0) {
if (substr_count($strLine, 'Total Warnings:') !== 0) {
$intWarning--;
}
}
$strOutput .= $strLine. '<br>';
$strOutput .= $strLine . '<br>';
}
$myDataClass->writeLog(translate('Nagios written configuration files checked - Warnings/Errors:'). ' '
.$intWarning. '/' .
$myDataClass->writeLog(translate('Nagios written configuration files checked - Warnings/Errors:') . ' '
. $intWarning . '/' .
$intError);
pclose($resFile);
if (($intError == 0) && ($intWarning == 0) && ($intLines > 5)) {
if (($intError === 0) && ($intWarning === 0) && ($intLines > 5)) {
$conttp->setVariable('VERIFY_CLASS', 'greenmessage');
$conttp->setVariable('VERIFY_LINE', '<b>' .translate('Written configuration files are valid, Nagios can be '
. 'restarted!'). '</b>');
$conttp->setVariable('VERIFY_LINE', '<b>' . translate('Written configuration files are valid, Nagios can be '
. 'restarted!') . '</b>');
$conttp->parse('verifyline');
}
if ($intLines < 5) {
$conttp->setVariable('VERIFY_CLASS', 'redmessage');
$conttp->setVariable('VERIFY_LINE', '<b>' .translate('The configuration could not be tested successfully. '
$conttp->setVariable('VERIFY_LINE', '<b>' . translate('The configuration could not be tested successfully. '
. 'The Nagios binary may have crashed during the test. Please repeat the test or try using the '
. 'commandline to test. A running Nagios service should not be restarted because the configuration may '
. 'be invalid.'). '</b>');
. 'be invalid.') . '</b>');
$conttp->parse('verifyline');
}
$conttp->setVariable('DATA', $strOutput);
$conttp->parse('verifyline');
} elseif (isset($arrResult) && is_array($arrResult)) {
$intError = 0;
$intError = 0;
$intWarning = 0;
foreach ($arrResult as $elem) {
if ((substr_count($elem, 'Error:') != 0) || (substr_count($elem, 'Total Errors:') != 0)) {
if ((substr_count($elem, 'Error:') !== 0) || (substr_count($elem, 'Total Errors:') !== 0)) {
$conttp->setVariable('VERIFY_CLASS', 'errormessage');
$conttp->setVariable('VERIFY_LINE', $elem);
$conttp->parse('verifyline');
$intError++;
if (substr_count($elem, 'Total Errors:') != 0) {
if (substr_count($elem, 'Total Errors:') !== 0) {
$intError--;
}
}
if ((substr_count($elem, 'Warning:') != 0) || (substr_count($elem, 'Total Warnings:') != 0)) {
if ((substr_count($elem, 'Warning:') !== 0) || (substr_count($elem, 'Total Warnings:') !== 0)) {
$conttp->setVariable('VERIFY_CLASS', 'warnmessage');
$conttp->setVariable('VERIFY_LINE', $elem);
$conttp->parse('verifyline');
$intWarning++;
if (substr_count($elem, 'Total Warnings:') != 0) {
if (substr_count($elem, 'Total Warnings:') !== 0) {
$intWarning--;
}
}
$strOutput .= $elem. '<br>';
$strOutput .= $elem . '<br>';
}
$myDataClass->writeLog(translate('Nagios written configuration files checked - Warnings/Errors:'). ' '
.$intWarning. '/' .
$myDataClass->writeLog(translate('Nagios written configuration files checked - Warnings/Errors:') . ' '
. $intWarning . '/' .
$intError);
if (($intError == 0) && ($intWarning == 0)) {
if (($intError === 0) && ($intWarning === 0)) {
$conttp->setVariable('VERIFY_CLASS', 'greenmessage');
$conttp->setVariable('VERIFY_LINE', '<b>' .translate('Written configuration files are valid, Nagios can be '
. 'restarted!'). '</b>');
$conttp->setVariable('VERIFY_LINE', '<b>' . translate('Written configuration files are valid, Nagios can be '
. 'restarted!') . '</b>');
$conttp->parse('verifyline');
}
$conttp->setVariable('DATA', $strOutput);
$conttp->parse('verifyline');
}
if ($strErrorMessage != '') {
if ($strErrorMessage !== '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
if ($strInfo != '') {
if ($strInfo !== '') {
$conttp->setVariable('VERIFY_CLASS', 'greenmessage');
$conttp->setVariable('VERIFY_LINE', '<br>' .$strInfo);
$conttp->setVariable('VERIFY_LINE', '<br>' . $strInfo);
$conttp->parse('verifyline');
}
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
/* Check access rights for adding new objects */
if ($myVisClass->checkAccountGroup($prePageKey, 'write') !== 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('main');
$conttp->show('main');
//
// Insert footer
// =============
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
/*
Insert footer
*/
$maintp->setVariable('VERSION_INFO', "<a href='https:/*sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->show('footer');

View File

@@ -1,124 +1,145 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Online version check
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
/* ----------------------------------------------------------------------------
NagiosQL
-------------------------------------------------------------------------------
(c) 2005-2023 by Martin Willisegger
Project : NagiosQL
Component : Online version check
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.5.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
-----------------------------------------------------------------------------*/
/**
* Class and variable includes
* @var string $setFileVersion from prepend_adm.php -> Application version string
* @var string $setGITVersion from prepend_adm.php -> Application version string - GIT version
* @var array $SETS Settings array
*/
/*
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));
//
// Define common variables
// =======================
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF'));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME'));
/*
Define common variables
*/
$preNoMain = 1;
$chkShow = filter_input(INPUT_GET, 'show', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
$chkShow = filter_input(INPUT_GET, 'show', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
/*
Include preprocessing file
*/
require $preBasePath . 'functions/prepend_adm.php';
$strCommandLine = '&nbsp;';
$intCount = 0;
//
// Get database values
// ===================
if ($chkShow == 1) {
$versionfeed = 'http://api.wizonet.ch/nagiosql/versioncheck.php?myversion=' .urlencode($setFileVersion);
$strError = '';
if ((isset($SETS['network']['proxy']) && ($SETS['network']['proxy'] == '1')) &&
(isset($SETS['network']['proxyserver']) && ($SETS['network']['proxyserver'] != ''))) {
if ((isset($SETS['network']['proxyuser']) && ($SETS['network']['proxyuser'] != '')) &&
(isset($SETS['network']['proxypasswd']) && ($SETS['network']['proxypasswd'] != ''))) {
$strProxyAuth = base64_encode($SETS['network']['proxyuser']. ':' .$SETS['network']['proxypasswd']);
$intCount = 0;
/*
Get database values
*/
if ($chkShow === 1) {
$strInstallHash = $SETS['install']['hash'] ?? 'nohash';
if (isset($setFileVersion) && ($setFileVersion !== '') && ($setFileVersion !== null)) {
$strVersion = $setFileVersion;
} else {
$strVersion = '0.0.0';
}
if (isset($setGITVersion) && ($setGITVersion !== '') && ($setGITVersion !== null)) {
$strGITVersion = $setGITVersion;
} else {
$strGITVersion = '0000-00-00';
}
/** @noinspection HttpUrlsUsage */
$versionfeed = 'http://api.wizonet.ch/nagiosql/versioncheck.php?myversion=' . urlencode($strVersion) . '&mygit='
. urlencode($strGITVersion) . '&myhash=' . urlencode($strInstallHash);
$strError = '';
if (isset($SETS['network']['proxy'], $SETS['network']['proxyserver']) && ($SETS['network']['proxy'] === '1') &&
($SETS['network']['proxyserver'] !== '')) {
if (isset($SETS['network']['proxyuser'], $SETS['network']['proxypasswd']) && ($SETS['network']['proxyuser'] !== '')
&& ($SETS['network']['proxypasswd'] !== '')) {
$strProxyAuth = base64_encode($SETS['network']['proxyuser'] . ':' . $SETS['network']['proxypasswd']);
$aContext = array(
'http' => array(
'proxy' => 'tcp://'.$SETS['network']['proxyserver'],
'request_fulluri' => true,
'header' => "Proxy-Authorization: Basic $strProxyAuth",
'timeout' => 1,
'proxy' => 'tcp://' . $SETS['network']['proxyserver'],
'request_fulluri' => true,
'header' => "Proxy-Authorization: Basic $strProxyAuth",
'timeout' => 1,
),
);
} else {
$aContext = array(
'http' => array(
'proxy' => 'tcp://'.$SETS['network']['proxyserver'],
'request_fulluri' => true,
'timeout' => 1,
'proxy' => 'tcp://' . $SETS['network']['proxyserver'],
'request_fulluri' => true,
'timeout' => 1,
),
);
}
$intErrorReporting = error_reporting();
error_reporting(0);
$cxContext = stream_context_create($aContext);
$arrFile = file($versionfeed, false, $cxContext);
$arrError = error_get_last();
error_reporting($intErrorReporting);
if ($arrError['message'] != '') {
$strError .= utf8_encode($arrError['message']). ' (' .translate('check proxy settings'). ')';
}
} else {
$intErrorReporting = error_reporting();
error_reporting(0);
$cxContext = stream_context_create(array('http' => array('timeout' => 1)));
$arrFile = file($versionfeed, false, $cxContext);
$arrError = error_get_last();
error_reporting($intErrorReporting);
if ($arrError['message'] != '') {
$strError .= utf8_encode($arrError['message']). ' (' .translate('check proxy settings'). ')';
}
}
$strInstalled = translate('Installed');
$strAvailable = translate('Available');
$arrFile = file($versionfeed, false, $cxContext);
$arrError = error_get_last();
error_reporting($intErrorReporting);
if (isset($arrError['message']) && $arrError['message'] !== '') {
$strError .= utf8_encode($arrError['message']) . ' (' . translate('check proxy settings') . ')';
}
$strInstalled = translate('Installed');
$strAvailable = translate('Available');
$strInformation = translate('Information');
$strVersion = '';
$strRelease = '';
$strRelInfo = '';
if (is_array($arrFile) && count($arrFile) != 0) {
$strVersion = '';
$strRelease = '';
$strRelInfo = '';
$strGIT = '';
if (is_array($arrFile) && count($arrFile) !== 0) {
foreach ($arrFile as $elem) {
if (substr_count($elem, 'version') != 0) {
if (substr_count($elem, 'version') !== 0) {
$strVersion = trim(strip_tags($elem));
}
if (substr_count($elem, 'release_date') != 0) {
if (substr_count($elem, 'git') !== 0) {
$strGIT = trim(strip_tags($elem));
}
if (substr_count($elem, 'release_date') !== 0) {
$strRelease = trim(strip_tags($elem));
}
if (substr_count($elem, 'error') != 0) {
$strError = trim(strip_tags($elem));
if (substr_count($elem, 'error') !== 0) {
$strError = trim(strip_tags($elem));
}
if (substr_count($elem, 'information') != 0) {
if (substr_count($elem, 'information') !== 0) {
$strRelInfo = trim(strip_tags($elem));
}
}
}
$setFileAvailable = $strVersion;
$setFileInformation = '';
if (version_compare($strVersion, $setFileVersion, '==')) {
$setFileInformation = "<span class='greenmessage'>".translate('You already have the latest version installed').
'</span>';
if ($strGIT === $setGITVersion) {
$setFileInformation = "<span class='greenmessage'>" . translate('You already have the latest version installed') .
'</span>';
} else {
$setFileInformation = "<span class='greenmessage'>" . translate('You already have the latest version installed') .
' (' . translate('new GIT hotfix version available:') . ' ' . $strVersion . '-' . $strGIT . ')</span>';
}
} elseif (version_compare($strVersion, $setFileVersion, '>=')) {
$setFileInformation = "<span class='redmessage'>".translate('You are using an old NagiosQL version. Please '.
'update to the latest stable version'). '</span>: ';
$setFileInformation .= '<a href="http://sourceforge.net/projects/nagiosql/files/" target="_blank">' .
$setFileInformation = "<span class='redmessage'>" . translate('You are using an old NagiosQL version. Please ' .
'update to the latest stable version') . '</span>: ';
$setFileInformation .= '<a href="https://sourceforge.net/projects/nagiosql/files/" target="_blank">' .
'NagiosQL on Sourceforge</a>';
} elseif (version_compare($strVersion, $setFileVersion, '<=')) {
$setFileInformation = "<span class='redmessage'>".translate('You are using a newer development version '.
'without official support'). '</span>';
$setFileInformation = "<span class='redmessage'>" . translate('You are using a newer development version ' .
'without official support') . '</span>';
}
if (($strError != 'none') && ($strError != '')) {
$setFileInformation = "<span class='redmessage'>".$strError. '</span>';
if (($strError !== 'none') && ($strError !== '')) {
$setFileInformation = "<span class='redmessage'>" . $strError . '</span>';
} ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>Version check</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -129,70 +150,72 @@ if ($chkShow == 1) {
<style type="text/css">
<!--
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
background-color: #FFFFFF;
margin: 0;
border: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
background-color: #FFFFFF;
margin: 0;
border: none;
}
-->
</style>
</head>
<body>
<table width="100%" border="0" class="content_listtable" style="padding:0; margin:0; top:3px;">
<tr>
<th style="text-align: center"><?php echo $strInstalled; ?></th>
<th style="text-align: center"><?php echo $strAvailable; ?></th>
<th style="text-align: left; padding-left: 30px;"><?php echo $strInformation; ?></th>
</tr>
<tr>
<td class="tdmb" style="width:90px;vertical-align:top;padding-top:4px;"><?php
echo $setFileVersion; ?></td>
<td class="tdmb" style="width:90px;vertical-align:top;padding-top:4px;"><?php
echo $setFileAvailable; ?></td>
<td class="tdlb" style="width:470px;vertical-align:top;padding-top:4px;"><?php
echo $setFileInformation; ?></td>
</tr>
</table>
<script type="text/javascript">
<!--
parent.document.getElementById('vcheck').className = 'elementHide';
parent.document.getElementById('versioncheck').className = 'elementShow';
<?php
if (($strError != 'none') && ($strError != '')) {
echo " parent.document.getElementById('versioncheck').height = '65';";
}
?>
//-->
</script>
<table width="100%" border="0" class="content_listtable" style="padding:0; margin:0; top:3px;">
<tr>
<th style="text-align: center"><?php echo $strInstalled; ?></th>
<th style="text-align: center"><?php echo $strAvailable; ?></th>
<th style="text-align: left; padding-left: 30px;"><?php echo $strInformation; ?></th>
</tr>
<tr>
<td class="tdmb" style="width:90px;vertical-align:top;padding-top:4px;"><?php
echo $setFileVersion; ?></td>
<td class="tdmb" style="width:90px;vertical-align:top;padding-top:4px;"><?php
echo $setFileAvailable; ?></td>
<td class="tdlb" style="width:470px;vertical-align:top;padding-top:4px;"><?php
echo $setFileInformation; ?></td>
</tr>
</table>
<script type="text/javascript">
<!--
parent.document.getElementById('vcheck').className = 'elementHide';
parent.document.getElementById('versioncheck').className = 'elementShow';
<?php
if (($strError !== 'none') && ($strError !== '')) {
echo " parent.document.getElementById('versioncheck').height = '65';";
}
?>
//-->
</script>
</body>
</html>
<?php
</html>
<?php
} else {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>Commandline</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
background-color: #FFFFFF;
margin: 0;
border: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
background-color: #FFFFFF;
margin: 0;
border: none;
}
-->
</style>
</head>
<body>
<p><br>Loading...</p>
<p><br>Loading...</p>
</body>
</html>
<?php
</html>
<?php
}
?>