1 Commits

Author SHA1 Message Date
Mario Fetka
b9adf21bc5 intial commit 2017-05-22 11:26:31 +02:00
283 changed files with 42784 additions and 51105 deletions

View File

@@ -5,47 +5,42 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin main site
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-14 13:43:23 +0100 (Wed, 14 Mar 2012) $
// Author : $LastChangedBy: rouven $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1296 $
//
///////////////////////////////////////////////////////////////////////////////
//
// Path settings
// ===================
$preRelPath = strstr(filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING), 'admin.php', true);
$preBasePath = strstr(filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING), 'admin.php', true);
//
// Define common variables
// =======================
$prePageId = 1;
$preContent = 'admin/mainpages.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 1;
$preContent = "admin/mainpages.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("functions/prepend_adm.php");
require("functions/prepend_content.php");
//
// Include Content
// ===============
$conttp->setVariable('TITLE', translate('NagiosQL Administration'));
$conttp->parse('header');
$conttp->show('header');
$conttp->setVariable('DESC', translate('Welcome to NagiosQL, the administration module that can be used to easily '
. 'create, modify and delete configuration files for Nagios. The data is stored in a database '
. 'and can be written directly to the standard files at any time you want.'));
$conttp->parse('main');
$conttp->show('main');
$conttp->setVariable("TITLE",translate('NagiosQL Administration'));
$conttp->parse("header");
$conttp->show("header");
$conttp->setVariable("DESC",translate('Welcome to NagiosQL, the administration module that can be used to easily create, modify and delete configuration files for Nagios. The data is stored in a database and can be written directly to the standard files at any time you want.'));
$conttp->parse("main");
$conttp->show("main");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,43 +5,39 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preContent = 'admin/mainpages.htm.tpl';
$prePageId = 7;
$preContent = "admin/mainpages.tpl.htm";
//
// Include preprocessing file
// ==========================
require $preBasePath. 'functions/prepend_adm.php';
require("../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');
$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
// ==============
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,88 +5,73 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-08 15:13:31 +0100 (Wed, 08 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1189 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preContent = 'admin/mainpages.htm.tpl';
$prePageId = 3;
$preContent = "admin/mainpages.tpl.htm";
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
require("../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.'));
$conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable('INACTIVE', translate('Inactive'));
$conttp->setVariable("TITLE",translate('Alarming'));
$conttp->parse("header");
$conttp->show("header");
$conttp->setVariable("DESC",translate('To define contact data, contact templates and contact groups and time 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');
$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) {
$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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contact` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
$strAccess = $myVisClass->getAccGroups('read');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=14")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_contact WHERE active='0' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contactgroup` '
. "WHERE active='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=15")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_contactgroup WHERE active='0' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_timeperiod` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=16")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_timeperiod WHERE active='0' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contacttemplate` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=17")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_contacttemplate WHERE active='0' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
$conttp->parse('statistics');
$conttp->parse('main');
$conttp->show('main');
$conttp->parse("statistics");
$conttp->parse("main");
$conttp->show("main");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,162 +5,149 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-07 10:38:34 +0100 (Wed, 07 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1275 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preFieldvars = 1;
$intRemoveTmp = 0;
$strConfig = '';
$prePageId = 29;
$preContent = "admin/nagioscfg.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
$intRemoveTmp = 0;
$strConfig = "";
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Get configuration set ID
// ========================
$myConfigClass->getConfigTargets($arrConfigSet);
$arrConfigSet = $myConfigClass->getConfigSets();
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strBaseDir);
$strConfigfile = str_replace('//', '/', $strBaseDir. '/cgi.cfg');
$strLocalBackup = str_replace('//', '/', $strBaseDir. '/cgi.cfg_old_').date('YmdHis');
$myConfigClass->getConfigData($intConfigId,"method",$intMethod);
$myConfigClass->getConfigData($intConfigId,"nagiosbasedir",$strBaseDir);
$strConfigfile = str_replace("//","/",$strBaseDir."/cgi.cfg");
$strLocalBackup = str_replace("//","/",$strBaseDir."/cgi.cfg_old_").date("YmdHis",mktime());
//
// Convert Windows to UNIX
// Convert Windows to UNIX
// =======================
$chkTaFileText = str_replace("\r\n", "\n", $chkTaFileText);
$chkTaFileText = str_replace("\r\n","\n",$chkTaFileText);
//
// Process data
// ============
if (($chkTaFileText != '') && ($arrConfigSet[0] != 0)) {
if ($intMethod == 1) {
if (file_exists($strBaseDir) && (is_writable($strBaseDir) && is_writable($strConfigfile))) {
// Backup config file
$intReturn = $myConfigClass->moveFile('nagiosbasic', 'cgi.cfg', $intConfigId);
if ($intReturn == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
// 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);
} else {
$myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the '
. 'permissions)!'), $strErrorMessage);
$myDataClass->writeLog(translate('Configuration write failed:'). ' ' .$strConfigfile);
}
} elseif (($intMethod == 2) || ($intMethod == 3)) {
// Backup config file
$intReturn1 = $myConfigClass->moveFile('nagiosbasic', 'cgi.cfg', $intConfigId);
if ($intReturn1 == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
// 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
$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);
} 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);
}
}
} 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);
if ($chkTaFileText != "") {
if ($intMethod == 1) {
if (file_exists($strBaseDir) && (is_writable($strBaseDir) && (is_writable($strConfigfile)))) {
// Backup config file
$intReturn = $myConfigClass->moveFile("nagiosbasic","cgi.cfg",$intConfigId);
if ($intReturn == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
}
// Write configuration
$resFile = fopen($strConfigfile,"w");
fputs($resFile,$chkTaFileText);
fclose($resFile);
$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);
}
} else if (($intMethod == 2) || ($intMethod == 3)) {
// Backup config file
$intReturn = $myConfigClass->moveFile("nagiosbasic","cgi.cfg",$intConfigId);
if ($intReturn == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
}
// Write file to temporary
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_cgi');
$resFile = fopen($strFileName,"w");
fputs($resFile,$chkTaFileText);
fclose($resFile);
// Copy configuration to remoty system
$intReturn = $myConfigClass->configCopy($strConfigfile,$intConfigId,$strFileName,1);
if ($intReturn == 0) {
$myVisClass->processMessage("<span style=\"color:green\">".translate('Configuration file successfully written!')."</span>",$strInfoMessage);
$myDataClass->writeLog(translate('Configuration successfully written:')." ".$strConfigfile);
unlink($strFileName);
} 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);
}
}
}
//
// 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');
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
}
$conttp->setVariable("TITLE",translate('CGI configuration file'));
$conttp->parse("header");
$conttp->show("header");
//
// Include input form
// ===================
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
$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) {
if (file_exists($strConfigfile) && is_readable($strConfigfile)) {
$resFile = fopen($strConfigfile, 'rb');
if ($resFile) {
while (!feof($resFile)) {
$strConfig .= fgets($resFile, 1024);
}
}
} else {
$myVisClass->processMessage(translate('Cannot open the data file (check the permissions)!'), $strErrorMessage);
}
} elseif (($intMethod == 2) || ($intMethod == 3)) {
// Write file to temporary
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_cgi');
// Copy configuration from remoty system
$myConfigClass->strErrorMessage = '';
$intReturn = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName, 0);
if ($intReturn == 0) {
$resFile = fopen($strFileName, 'rb');
if (is_resource($resFile)) {
while (!feof($resFile)) {
$strConfig .= fgets($resFile, 1024);
}
unlink($strFileName);
} else {
$myVisClass->processMessage(translate('Cannot open the temporary file'), $strErrorMessage);
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
$myDataClass->writeLog(translate('Configuration read failed (remote):'). ' ' .$strErrorMessage);
if (file_exists($strFileName)) {
unlink($strFileName);
}
}
if (file_exists($strConfigfile) && is_readable($strConfigfile)) {
$resFile = fopen($strConfigfile,"r");
if ($resFile) {
while(!feof($resFile)) {
$strConfig .= fgets($resFile,1024);
}
}
} else {
$myVisClass->processMessage(translate('Cannot open the data file (check the permissions)!'),$strErrorMessage);
}
} else if (($intMethod == 2) || ($intMethod == 3)) {
// Write file to temporary
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_cgi');
// Copy configuration from remoty system
$intReturn = $myConfigClass->configCopy($strConfigfile,$intConfigId,$strFileName,0);
if ($intReturn == 0) {
$resFile = fopen($strFileName,"r");
if (is_resource($resFile)) {
while(!feof($resFile)) {
$strConfig .= fgets($resFile,1024);
}
unlink($strFileName);
} else {
$myVisClass->processMessage(translate('Cannot open the temporary file'),$strErrorMessage);
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
$myDataClass->writeLog(translate('Configuration read failed (remote):')." ".$strErrorMessage);
if (file_exists($strFileName)) unlink($strFileName);
}
}
$conttp->setVariable('DAT_NAGIOS_CONFIG', $strConfig);
if ($strErrorMessage != '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
$conttp->setVariable("DAT_NAGIOS_CONFIG",$strConfig);
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage);
$conttp->setVariable("INFOMESSAGE",$strInfoMessage);
// 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');
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
$conttp->parse("naginsert");
$conttp->show("naginsert");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,192 +5,148 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'checkcommand';
$preTableName = 'tbl_command';
$preKeyField = 'command_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 18;
$preContent = "admin/checkcommands.tpl.htm";
$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';
//
require("../functions/prepend_adm.php");
require("../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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Command modified:'). ' ' .$chkTfValue1);
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
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;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != "") && ($chkTfValue2 != "")) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Command modified:')." ".$chkTfValue1);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Command definitions'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
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;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
$conttp->setVariable('TITLE', translate('Command definitions'));
$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
$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
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
// Insert command type
if ($arrModifyData['command_type'] == 1) {
$conttp->setVariable('CHECK_TYPE_SELECTED', 'selected');
}
if ($arrModifyData['command_type'] == 2) {
$conttp->setVariable('MISC_TYPE_SELECTED', 'selected');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!'));
if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,");
$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
$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
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
// Insert command type
if ($arrModifyData['command_type'] == 1) {$conttp->setVariable("CHECK_TYPE_SELECTED","selected");}
if ($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
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$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'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'command_line', 40);
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'));
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'));
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'command_line',40);
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,86 +5,82 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preNoMain = 1;
//
// Include preprocessing file
// ==========================
require $preBasePath. 'functions/prepend_adm.php';
$strCommandLine = '&nbsp;';
$intCount = 0;
require("../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 != '')) {
$strCommandLine = $strResult;
$intCount = substr_count($strCommandLine, 'ARG');
if (substr_count($strCommandLine, 'ARG8') != 0) {
$intCount = 8;
} elseif (substr_count($strCommandLine, 'ARG7') != 0) {
$intCount = 7;
} elseif (substr_count($strCommandLine, 'ARG6') != 0) {
$intCount = 6;
} elseif (substr_count($strCommandLine, 'ARG5') != 0) {
$intCount = 5;
} elseif (substr_count($strCommandLine, 'ARG4') != 0) {
$intCount = 4;
} elseif (substr_count($strCommandLine, 'ARG3') != 0) {
$intCount = 3;
} elseif (substr_count($strCommandLine, 'ARG2') != 0) {
$intCount = 2;
} elseif (substr_count($strCommandLine, 'ARG1') != 0) {
$intCount = 1;
} else {
$intCount = 0;
}
}
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 != "")) {
$strCommandLine = $strResult;
$intCount = substr_count($strCommandLine,"ARG");
if (substr_count($strCommandLine,"ARG8") != 0) {
$intCount = 8;
} else if (substr_count($strCommandLine,"ARG7") != 0) {
$intCount = 7;
} else if (substr_count($strCommandLine,"ARG6") != 0) {
$intCount = 6;
} else if (substr_count($strCommandLine,"ARG5") != 0) {
$intCount = 5;
} else if (substr_count($strCommandLine,"ARG4") != 0) {
$intCount = 4;
} else if (substr_count($strCommandLine,"ARG3") != 0) {
$intCount = 3;
} else if (substr_count($strCommandLine,"ARG2") != 0) {
$intCount = 2;
} else if (substr_count($strCommandLine,"ARG1") != 0) {
$intCount = 1;
} else {
$intCount = 0;
}
}
}
?>
<!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>
<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

@@ -5,61 +5,55 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-08 15:13:31 +0100 (Wed, 08 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1189 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preContent = 'admin/mainpages.htm.tpl';
$prePageId = 4;
$preContent = "admin/mainpages.tpl.htm";
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
require("../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.'));
$conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable('INACTIVE', translate('Inactive'));
$conttp->setVariable("TITLE",translate('Check commands'));
$conttp->parse("header");
$conttp->show("header");
$conttp->setVariable("DESC",translate('To define check and misc commands, notification commands and special 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');
$intGroupId = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=18');
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_command` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
$strAccess = $myVisClass->getAccGroups('read');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=18")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_command WHERE active='0' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
$conttp->parse('statistics');
$conttp->parse('main');
$conttp->show('main');
$conttp->parse("statistics");
$conttp->parse("main");
$conttp->show("main");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

535
admin/configtargets.php Normal file → Executable file
View File

@@ -5,38 +5,33 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2011-12-01 15:20:17 +0100 (Do, 01. Dez 2011) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1137 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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 = 36;
$preContent = 'admin/configtargets.htm.tpl';
$preListTpl = 'admin/datalist_common.htm.tpl';
$preTableName = 'tbl_configtarget';
$preKeyField = 'target';
$preAccess = 1;
$preFieldvars = 1;
$intIsError = 0;
$strPathMessage = '';
$prePageId = 36;
$preContent = "admin/configtargets.tpl.htm";
$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';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Process path values (add slashes)
// =================================
@@ -52,295 +47,241 @@ $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);
foreach ($arrPaths as $elem) {
if ($myConfigClass->isDirWriteable($elem) == 1) {
$myVisClass->processMessage($elem. ' ' .translate('is not writeable'), $strPathMessage);
$intIsError = 1;
}
}
// Nagios base configuration files
if (!is_writable($chkTfValue20)) {
$myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios config file'). ' ' .$chkTfValue20
. ' ' .translate('is not writeable')), $strPathMessage);
$intIsError = 1;
} else {
$intCheck = 0;
if (file_exists($chkTfValue20) && is_readable($chkTfValue20)) {
$resFile = fopen($chkTfValue20, 'rb');
while (!feof($resFile)) {
$strLine = trim(fgets($resFile));
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);
$intIsError = 1;
}
}
if (!is_writable($chkTfValue14)) {
$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);
$intIsError = 1;
}
if (!is_readable($chkTfValue22)) {
$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')) {
$myVisClass->processMessage(translate('SSH module not loaded!'), $strPathMessage);
$intIsError = 1;
}
// 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';
$chkSelModify = 'errormodify';
}
if (($chkModus == "modify" || $chkModus == "insert")) {
if ($chkDataId != 0) {
if ($chkSelValue1 == 1) {
$arrPaths = array($chkTfValue8,$chkTfValue9,$chkTfValue10,$chkTfValue11,$chkTfValue12,$chkTfValue13);
foreach ($arrPaths AS $elem) {
if (!$myConfigClass->dir_is_writable($elem)) {
$myVisClass->processMessage($elem." ".translate("is not writeable"),$strPathMessage);
$intIsError = 1;
}
}
// Nagios base configuration files
if (!is_writable($chkTfValue20)) {
$myVisClass->processMessage(str_replace(" "," ",translate("Nagios config file")." ".$chkTfValue20." ".translate("is not writeable")),$strPathMessage);
$intIsError = 1;
} else {
$intCheck = 0;
if (file_exists($chkTfValue20) && is_readable($chkTfValue20)) {
$resFile = fopen($chkTfValue20,'r');
while (!feof($resFile)) {
$strLine = trim(fgets($resFile));
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);
$intIsError = 1;
}
}
if (!is_writable($chkTfValue14."cgi.cfg")) {
$myVisClass->processMessage(str_replace(" "," ",translate("Cgi config file")." ".$chkTfValue14."cgi.cfg"." ".translate("is not writeable")),$strPathMessage);
$intIsError = 1;
}
}
// 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')) {
$myVisClass->processMessage(translate('FTP module not loaded!'),$strPathMessage);
$intIsError = 1;
}
if ($intIsError == 1) {
$chkModus = "add";
$chkSelModify = "errormodify";
}
}
}
//
//
// 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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($chkTfValue4 != '') || ($chkDataId == 0))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
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 == 'modify') {
$myDataClass->writeLog(translate('Domain modified:'). ' ' .$chkTfValue1);
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
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', `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', `version`=$chkSelValue2,
`access_group`=$chkSelAccGr, `active`='$chkActive',
`last_modified`=NOW()";
if ($chkModus == "insert") {
$strSQL = "INSERT INTO ".$strSQLx;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != "") && ($chkTfValue2 != "") && (($chkTfValue4 != "") || ($chkDataId == 0))) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
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 == "modify") $myDataClass->writeLog(translate('Domain modified:')." ".$chkTfValue1);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Start content
// =============
$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);
$conttp->parse("header");
$conttp->show("header");
//
// Single view
// ===========
if ($chkModus == 'add') {
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// 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);
}
$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
$myContentClass->addInsertData($conttp, $arrModifyData, 0, '');
// Connection method
if ($arrModifyData['method'] == 1) {
$conttp->setVariable('FILE_SELECTED', 'selected');
}
if ($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) {
$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) {
$conttp->setVariable('FTPS_CHECKED', 'checked');
}
// Nagios version
$conttp->setVariable('VER_SELECTED_' .$arrModifyData['version'], 'selected');
// Domain localhost cant' be renamed
if ($arrModifyData[$preKeyField] == 'localhost') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('LOCKCLASS', 'inputlock');
} elseif ($arrModifyData[$preKeyField] == 'common') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('COMMON_INVISIBLE', 'class="elementHide"');
$conttp->setVariable('LOCKCLASS', 'inputlock');
}
}
if ($chkSelModify == 'errormodify') {
$conttp->setVariable('DAT_TARGET', $chkTfValue1);
// Domain localhost cant' be renamed
if ($chkTfValue1 == 'localhost') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('LOCKCLASS', 'inputlock');
} elseif ($chkTfValue1 == 'common') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('COMMON_INVISIBLE', 'class="elementHide"');
$conttp->setVariable('LOCKCLASS', 'inputlock');
} else {
$conttp->setVariable('LOCKCLASS', 'inpmust');
}
$conttp->setVariable('DAT_ALIAS', $chkTfValue2);
$conttp->setVariable('DAT_SERVER', $chkTfValue4);
// 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) {
$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) {
$conttp->setVariable('SFTP_SELECTED', 'selected');
$conttp->setVariable('CLASS_NAME_1', 'elementShow');
$conttp->setVariable('CLASS_NAME_2', 'elementShow');
$conttp->setVariable('CLASS_NAME_3', 'elementHide');
}
$conttp->setVariable('DAT_USER', $chkTfValue5);
$conttp->setVariable('DAT_SSH_KEY_PATH', $chkTfValue7);
if ($chkChbValue1== 1) {
$conttp->setVariable('FTPS_CHECKED', 'checked');
}
$conttp->setVariable('DAT_BASEDIR', $chkTfValue8);
$conttp->setVariable('DAT_HOSTCONFIG', $chkTfValue9);
$conttp->setVariable('DAT_SERVICECONFIG', $chkTfValue10);
$conttp->setVariable('DAT_BACKUPDIR', $chkTfValue11);
$conttp->setVariable('DAT_HOSTBACKUP', $chkTfValue12);
$conttp->setVariable('DAT_SERVICEBACKUP', $chkTfValue13);
$conttp->setVariable('DAT_NAGIOSBASEDIR', $chkTfValue14);
$conttp->setVariable('DAT_IMPORTDIR', $chkTfValue15);
$conttp->setVariable('DAT_COMMANDFILE', $chkTfValue17);
$conttp->setVariable('DAT_BINARYFILE', $chkTfValue18);
$conttp->setVariable('DAT_PIDFILE', $chkTfValue19);
$conttp->setVariable('DAT_CONFFILE', $chkTfValue20);
$conttp->setVariable('DAT_CGIFILE', $chkTfValue21);
$conttp->setVariable('DAT_RESOURCEFILE', $chkTfValue22);
$conttp->setVariable('DAT_PICTUREDIR', $chkTfValue16);
// NagiosQL version
if ($chkSelValue2 == 1) {
$conttp->setVariable('VER_SELECTED_1', 'selected');
}
if ($chkSelValue2 == 2) {
$conttp->setVariable('VER_SELECTED_2', 'selected');
}
if ($chkSelValue2 == 3) {
$conttp->setVariable('VER_SELECTED_3', 'selected');
}
// Hidden variables
$conttp->setVariable('MODUS', filter_input(INPUT_POST, 'modus', FILTER_SANITIZE_STRING));
$conttp->setVariable('DAT_ID', filter_input(INPUT_POST, 'hidId', FILTER_VALIDATE_INT));
$conttp->setVariable('LIMIT', filter_input(INPUT_POST, 'hidLimit', FILTER_VALIDATE_INT));
// Active
if (filter_input(INPUT_POST, 'chbActive')) {
$conttp->setVariable('ACT_CHECKED', 'checked');
} else {
$conttp->setVariable('ACT_CHECKED', '');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
$conttp->setVariable("CLASS_NAME_1","elementHide");
$conttp->setVariable("CLASS_NAME_2","elementHide");
$conttp->setVariable("FILL_ALLFIELDS",translate('Please fill in all fields marked with an *'));
$conttp->setVariable("FILL_ILLEGALCHARS",translate('The following field contains not permitted characters:'));
// Insert data from database in "modify" mode
// 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) $conttp->setVariable("FILE_SELECTED","selected");
if ($arrModifyData['method'] == 2) {
$conttp->setVariable("FTP_SELECTED","selected");
$conttp->setVariable("CLASS_NAME_1","elementShow");
}
if ($arrModifyData['method'] == 3) {
$conttp->setVariable("SFTP_SELECTED","selected");
$conttp->setVariable("CLASS_NAME_1","elementShow");
$conttp->setVariable("CLASS_NAME_2","elementShow");
}
// Nagios version
if ($arrModifyData['version'] == 1) $conttp->setVariable("VER_SELECTED_1","selected");
if ($arrModifyData['version'] == 2) $conttp->setVariable("VER_SELECTED_2","selected");
if ($arrModifyData['version'] == 3) $conttp->setVariable("VER_SELECTED_3","selected");
// Domain localhost cant' be renamed
if ($arrModifyData[$preKeyField] == "localhost") {
$conttp->setVariable("DOMAIN_DISABLE","readonly");
$conttp->setVariable("LOCKCLASS","inputlock");
} else if ($arrModifyData[$preKeyField] == "common") {
$conttp->setVariable("DOMAIN_DISABLE","readonly");
$conttp->setVariable("COMMON_INVISIBLE","class=\"elementHide\"");
$conttp->setVariable("LOCKCLASS","inputlock");
}
}
if ($chkSelModify == "errormodify") {
$conttp->setVariable("DAT_TARGET",$chkTfValue1);
// Domain localhost cant' be renamed
if ($chkTfValue1 == "localhost") {
$conttp->setVariable("DOMAIN_DISABLE","readonly");
$conttp->setVariable("LOCKCLASS","inputlock");
} else if ($chkTfValue1 == "common") {
$conttp->setVariable("DOMAIN_DISABLE","readonly");
$conttp->setVariable("COMMON_INVISIBLE","class=\"elementHide\"");
$conttp->setVariable("LOCKCLASS","inputlock");
} else {
$conttp->setVariable("LOCKCLASS","inpmust");
}
$conttp->setVariable("DAT_ALIAS",$chkTfValue2);
$conttp->setVariable("DAT_SERVER",$chkTfValue4);
// Connection method
if ($chkSelValue1 == 1) $conttp->setVariable("FILE_SELECTED","selected");
if ($chkSelValue1 == 2) {
$conttp->setVariable("FTP_SELECTED","selected");
$conttp->setVariable("CLASS_NAME_1","elementShow");
}
if ($chkSelValue1 == 3) {
$conttp->setVariable("SFTP_SELECTED","selected");
$conttp->setVariable("CLASS_NAME_1","elementShow");
$conttp->setVariable("CLASS_NAME_2","elementShow");
}
$conttp->setVariable("DAT_USER",$chkTfValue5);
$conttp->setVariable("DAT_SSH_KEY_PATH",$chkTfValue7);
$conttp->setVariable("DAT_BASEDIR",$chkTfValue8);
$conttp->setVariable("DAT_HOSTCONFIG",$chkTfValue9);
$conttp->setVariable("DAT_SERVICECONFIG",$chkTfValue10);
$conttp->setVariable("DAT_BACKUPDIR",$chkTfValue11);
$conttp->setVariable("DAT_HOSTBACKUP",$chkTfValue12);
$conttp->setVariable("DAT_SERVICEBACKUP",$chkTfValue13);
$conttp->setVariable("DAT_NAGIOSBASEDIR",$chkTfValue14);
$conttp->setVariable("DAT_IMPORTDIR",$chkTfValue15);
$conttp->setVariable("DAT_COMMANDFILE",$chkTfValue17);
$conttp->setVariable("DAT_BINARYFILE",$chkTfValue18);
$conttp->setVariable("DAT_PIDFILE",$chkTfValue19);
$conttp->setVariable("DAT_CONFFILE",$chkTfValue20);
$conttp->setVariable("DAT_PICTUREDIR",$chkTfValue16);
// NagiosQL version
if ($chkSelValue2 == 1) $conttp->setVariable("VER_SELECTED_1","selected");
if ($chkSelValue2 == 2) $conttp->setVariable("VER_SELECTED_2","selected");
if ($chkSelValue2 == 3) $conttp->setVariable("VER_SELECTED_3","selected");
// Hidden variables
$conttp->setVariable("MODUS",$_POST['modus']);
$conttp->setVariable("DAT_ID",$_POST['hidId']);
$conttp->setVariable("LIMIT",$_POST['hidLimit']);
// Active
if (isset ($_POST['chbActive'])) {
$conttp->setVariable("ACT_CHECKED","checked");
} else {
$conttp->setVariable("ACT_CHECKED","");
}
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// 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
$strOrderString = "ORDER BY `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
$strOrderString = "ORDER BY `alias` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$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'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Configuration target'));
$mastertp->setVariable("FIELD_2",translate('Description'));
// Row sorting
$strOrderString = "ORDER BY `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) $strOrderString = "ORDER BY `alias` $hidSortDir";
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias');
}
// Show messages
$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,271 +5,178 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'contactgroup';
$preTableName = 'tbl_contactgroup';
$preKeyField = 'contactgroup_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 15;
$preContent = "admin/contactgroups.tpl.htm";
$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';
//
require("../functions/prepend_adm.php");
require("../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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '') && ($intMselValue1 != 0)) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Contact group modified:'). ' ' .$chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkContactgroupToContact',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkContactgroupToContactgroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkContactgroupToContact',
$chkDataId,
$chkMselValue1
);
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkContactgroupToContact', $chkDataId);
}
if ($intRet1 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkContactgroupToContactgroup',
$chkDataId,
$chkMselValue2
);
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkContactgroupToContactgroup', $chkDataId);
}
if ($intRet2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2) != 0) {
$strInfoMessage = '';
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
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;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != "") && ($chkTfValue2 != "") && ($intMselValue1 != 0)) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Contact group modified:')." ".$chkTfValue1);
//
// Insert/update relations
// =======================
if ($chkModus == "insert") {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkContactgroupToContact",$chkDataId,$chkMselValue1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkContactgroupToContactgroup",$chkDataId,$chkMselValue2);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else if ($chkModus == "modify") {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkContactgroupToContact",$chkDataId,$chkMselValue1);
} else {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkContactgroupToContact",$chkDataId);
}
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkContactgroupToContactgroup",$chkDataId,$chkMselValue2);
} else {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkContactgroupToContactgroup",$chkDataId);
}
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (($intRet1 + $intRet2) != 0) $strInfoMessage = "";
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Define contact groups (contactgroups.cfg)'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
$conttp->setVariable('TITLE', translate('Define contact groups (contactgroups.cfg)'));
// Do not show modified time list
$intNoTime = 1;
// Process contact member selection fields
if (isset($arrModifyData['members'])) {
$intFieldId = $arrModifyData['members'];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_contact',
'contact_name',
'contacts',
'tbl_lnkContactgroupToContact',
2,
$intFieldId
);
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;
}
$intReturn2 = $myVisClass->parseSelectMulti(
$preTableName,
$preKeyField,
'contactgroups',
'tbl_lnkContactgroupToContactgroup',
0,
$intFieldId,
$chkListId
);
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;
}
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Do not show modified time list
$intNoTime = 1;
// Process contact member selection fields
$intReturn = 0;
if (isset($arrModifyData['members'])) {$intFieldId = $arrModifyData['members'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti('tbl_contact','contact_name','contacts','tbl_lnkContactgroupToContact',2,$intFieldId);
if ($intReturn != 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;}
$intReturn = $myVisClass->parseSelectMulti($preTableName,$preKeyField,'contactgroups','tbl_lnkContactgroupToContactgroup',0,$intFieldId,$chkListId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// List view
// ==========
if ($chkModus == 'display') {
// Initial list view definitions
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$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'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'));
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'));
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias');
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,506 +5,338 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-04-20 12:39:53 +0200 (Fri, 20 Apr 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1323 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'contact';
$preTableName = 'tbl_contact';
$preKeyField = 'contact_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 14;
$preContent = "admin/contacts.tpl.htm";
$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';
require("../functions/prepend_adm.php");
require("../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);
if ($intVersion == 3) {
$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);
$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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if ($chkTfValue1 != '') {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Contact modified:'). ' ' .$chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkContactToContactgroup',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkContactToCommandHost',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkContactToCommandService',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkContactToContactgroup',
$chkDataId,
$chkMselValue1
);
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkContactToContactgroup', $chkDataId);
}
if ($intRet1 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkContactToCommandHost',
$chkDataId,
$chkMselValue2
);
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkContactToCommandHost', $chkDataId);
}
if ($intRet2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkContactToCommandService',
$chkDataId,
$chkMselValue3
);
} else {
$intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkContactToCommandService', $chkDataId);
}
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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
$intSortId++;
}
}
//
// 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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCount != 0) {
foreach ($arrData as $elem) {
$strSQL = 'DELETE FROM `tbl_variabledefinition` WHERE `id`=' .$elem['idSlave'];
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
$strSQL = "DELETE FROM `tbl_lnkContactToVariabledefinition` WHERE `idMaster`=$chkDataId";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
(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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
$strSQL = 'INSERT INTO `tbl_lnkContactToVariabledefinition` (`idMaster`,`idSlave`) '
. "VALUES ($chkDataId,$intInsertId)";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `contactgroups`=$intMselValue1, `contactgroups_tploptions`=$chkRadValue1,
`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";
}
if ($intWriteAccessId == 0) {
if ($chkTfValue1 != "") {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Contact modified:')." ".$chkTfValue1);
//
// Insert/update relations
// =======================
if ($chkModus == "insert") {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkContactToContactgroup",$chkDataId,$chkMselValue1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkContactToCommandHost",$chkDataId,$chkMselValue2);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkContactToCommandService",$chkDataId,$chkMselValue3);
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else if ($chkModus == "modify") {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkContactToContactgroup",$chkDataId,$chkMselValue1);
} else {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkContactToContactgroup",$chkDataId);
}
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkContactToCommandHost",$chkDataId,$chkMselValue2);
} else {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkContactToCommandHost",$chkDataId);
}
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkContactToCommandService",$chkDataId,$chkMselValue3);
} else {
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkContactToCommandService",$chkDataId);
}
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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) && (count($_SESSION['templatedefinition']) != 0)) {
$intSortId = 1;
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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
$intSortId++;
}
}
//
// Insert/update variables from session data
// =========================================
if ($chkModus == "modify") {
$strSQL = "SELECT * FROM `tbl_lnkContactToVariabledefinition` WHERE `idMaster`=$chkDataId";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intDataCount != 0) {
foreach ($arrData AS $elem) {
$strSQL = "DELETE FROM `tbl_variabledefinition` WHERE `id`=".$elem['idSlave'];
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
}
$strSQL = "DELETE FROM `tbl_lnkContactToVariabledefinition` WHERE `idMaster`=$chkDataId";
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) && (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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
$strSQL = "INSERT INTO `tbl_lnkContactToVariabledefinition` (`idMaster`,`idSlave`)
VALUES ($chkDataId,$intInsertId)";
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
}
}
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate("Define contacts (contacts.cfg)"));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
$conttp->setVariable('TITLE', translate('Define contacts (contacts.cfg)'));
// Do not show modified time list
$intNoTime = 1;
// Process template selection fields (Spezial)
$strWhere = '';
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`";
$booReturn5 = $myDBClass->hasDataArray($strSQL5, $arrDataTpl, $intDataCountTpl);
if ($booReturn5 == false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCountTpl != 0) {
/** @var array $arrDataTpl */
foreach ($arrDataTpl as $elem) {
if ($elem['active'] == 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$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');
}
}
$strSQL6 = 'SELECT `id`, `name`, `active` '
. "FROM `$preTableName` WHERE `name` <> '' $strWhere AND $strDomainWhere ORDER BY `name`";
$booReturn6 = $myDBClass->hasDataArray($strSQL6, $arrDataHpl, $intDataCount);
if ($booReturn6 == false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCount != 0) {
/** @var array $arrDataHpl */
foreach ($arrDataHpl as $elem) {
if ($elem['active'] == 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$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');
}
}
// Process timeperiod selection fields
if (isset($arrModifyData['host_notification_period'])) {
$intFieldId = $arrModifyData['host_notification_period'];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'host_time', 1, $intFieldId);
if ($intReturn1 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['service_notification_period'])) {
$intFieldId = $arrModifyData['service_notification_period'];
} else {
$intFieldId = 0;
}
$intReturn2 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'service_time', 1, $intFieldId);
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;
}
$intReturn3 = $myVisClass->parseSelectMulti(
'tbl_command',
'command_name',
'host_command',
'tbl_lnkContactToCommandHost',
0,
$intFieldId
);
if ($intReturn3 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['service_notification_commands'])) {
$intFieldId = $arrModifyData['service_notification_commands'];
} else {
$intFieldId = 0;
}
$intReturn4 = $myVisClass->parseSelectMulti(
'tbl_command',
'command_name',
'service_command',
'tbl_lnkContactToCommandService',
0,
$intFieldId
);
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;
}
$intReturn5 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
'contactgroup',
'tbl_lnkContactToContactgroup',
2,
$intFieldId
);
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;
}
$intReturn6 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn6 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// 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!'));
$conttp->setVariable('DISABLE_SAVE', 'disabled');
}
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) {
$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) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1f');
$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
$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
$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');
$conttp->setVariable(
'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
foreach (explode(',', $arrModifyData['host_notification_options']) as $elem) {
$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->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Do not show modified time list
$intNoTime = 1;
// Process template selection fields (Spezial)
$strWhere = "";
if (isset($arrModifyData) && ($chkSelModify == "modify")) {
$strWhere = "AND `id` <> ".$arrModifyData['id'];
}
$strSQL = "SELECT `id`,`template_name`, `active` FROM `tbl_contacttemplate` WHERE $strDomainWhere2 ORDER BY `template_name`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataTpl,$intDataCountTpl);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($intDataCountTpl != 0) {
foreach ($arrDataTpl AS $elem) {
if ($elem['active'] == 0) {
$strActive = " [inactive]";
$conttp->setVariable("SPECIAL_STYLE","inactive_option");
} else {
$strActive = "";
$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");
}
}
$strSQL = "SELECT `id`, `name`, `active` FROM `$preTableName` WHERE `name` <> '' $strWhere AND $strDomainWhere ORDER BY `name`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataHpl,$intDataCount);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($arrDataHpl != 0) {
foreach ($arrDataHpl AS $elem) {
if ($elem['active'] == 0) {
$strActive = " [inactive]";
$conttp->setVariable("SPECIAL_STYLE","inactive_option");
} else {
$strActive = "";
$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");
}
}
// Process timeperiod selection fields
$intReturn = 0;
if (isset($arrModifyData['host_notification_period'])) {$intFieldId = $arrModifyData['host_notification_period'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','host_time',1,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['service_notification_period'])) {$intFieldId = $arrModifyData['service_notification_period'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','service_time',1,$intFieldId);
if ($intReturn != 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;}
$intReturn = $myVisClass->parseSelectMulti('tbl_command','command_name','host_command','tbl_lnkContactToCommandHost',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['service_notification_commands'])) {$intFieldId = $arrModifyData['service_notification_commands'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti('tbl_command','command_name','service_command','tbl_lnkContactToCommandService',0,$intFieldId);
if ($intReturn != 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;}
$intReturn = $myVisClass->parseSelectMulti('tbl_contactgroup','contactgroup_name','contactgroup','tbl_lnkContactToContactgroup',2,$intFieldId);
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// 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 ($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");
} else {
$conttp->setVariable("HOST_OPTION_FIELDS","chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1f");
$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
$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
$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");
$conttp->setVariable("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
foreach(explode(",",$arrModifyData['host_notification_options']) AS $elem) {
$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->parse("datainsert");
$conttp->show("datainsert");
}
//
// List view
// ==========
if ($chkModus == 'display') {
// 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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn7 = $myDBClass->hasSingleDataset($strSQL7, $arrDataLinesCount);
if ($booReturn7 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$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'];
$booReturn8 = $myDBClass->hasDataArray($strSQL8, $arrDataLines, $intDataCount);
if ($booReturn8 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias');
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,504 +5,330 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'contacttemplate';
$preTableName = 'tbl_contacttemplate';
$preKeyField = 'template_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 17;
$preContent = "admin/contacttemplates.tpl.htm";
$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';
require("../functions/prepend_adm.php");
require("../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);
if ($intVersion == 3) {
$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);
$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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if ($chkTfValue1 != '') {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Contact template modified:'). ' ' .$chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkContacttemplateToContactgroup',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkContacttemplateToCommandHost',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkContacttemplateToCommandService',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkContacttemplateToContactgroup',
$chkDataId,
$chkMselValue1
);
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkContacttemplateToContactgroup', $chkDataId);
}
if ($intRet1 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkContacttemplateToCommandHost',
$chkDataId,
$chkMselValue2
);
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkContacttemplateToCommandHost', $chkDataId);
}
if ($intRet2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkContacttemplateToCommandService',
$chkDataId,
$chkMselValue3
);
} else {
$intRet3 = $myDataClass->dataDeleteRelation(
'tbl_lnkContacttemplateToCommandService',
$chkDataId
);
}
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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
$intSortId++;
}
}
//
// 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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCount != 0) {
foreach ($arrData as $elem) {
$strSQL = 'DELETE FROM `tbl_variabledefinition` WHERE `id`=' .$elem['idSlave'];
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
$strSQL = 'DELETE FROM `tbl_lnkContacttemplateToVariabledefinition` '
. 'WHERE `idMaster`=' .$chkDataId;
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
(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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
$strSQL = 'INSERT INTO `tbl_lnkContacttemplateToVariabledefinition` (`idMaster`, '
. "`idSlave`) VALUES ($chkDataId,$intInsertId)";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `contactgroups`=$intMselValue1, `contactgroups_tploptions`=$chkRadValue1,
`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";
}
if ($intWriteAccessId == 0) {
if ($chkTfValue1 != "") {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Contact template modified:')." ".$chkTfValue1);
//
// Insert/update relations
// =======================
if ($chkModus == "insert") {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkContacttemplateToContactgroup",$chkDataId,$chkMselValue1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkContacttemplateToCommandHost",$chkDataId,$chkMselValue2);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkContacttemplateToCommandService",$chkDataId,$chkMselValue3);
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else if ($chkModus == "modify") {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkContacttemplateToContactgroup",$chkDataId,$chkMselValue1);
} else {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkContacttemplateToContactgroup",$chkDataId);
}
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkContacttemplateToCommandHost",$chkDataId,$chkMselValue2);
} else {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkContacttemplateToCommandHost",$chkDataId);
}
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkContacttemplateToCommandService",$chkDataId,$chkMselValue3);
} else {
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkContacttemplateToCommandService",$chkDataId);
}
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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) && (count($_SESSION['templatedefinition']) != 0)) {
$intSortId = 1;
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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
$intSortId++;
}
}
//
// Insert/update variables from session data
// =========================================
if ($chkModus == "modify") {
$strSQL = "SELECT * FROM `tbl_lnkContacttemplateToVariabledefinition` WHERE `idMaster`=$chkDataId";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intDataCount != 0) {
foreach ($arrData AS $elem) {
$strSQL = "DELETE FROM `tbl_variabledefinition` WHERE `id`=".$elem['idSlave'];
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
}
$strSQL = "DELETE FROM `tbl_lnkContacttemplateToVariabledefinition` WHERE `idMaster`=$chkDataId";
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) && (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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
$strSQL = "INSERT INTO `tbl_lnkContacttemplateToVariabledefinition` (`idMaster`,`idSlave`)
VALUES ($chkDataId,$intInsertId)";
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
}
}
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate("Define contact templates (contacttemplates.cfg)"));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
$conttp->setVariable('TITLE', translate('Define contact templates (contacttemplates.cfg)'));
// Do not show modified time list
$intNoTime = 1;
// Process template selection fields (Spezial)
$strWhere = '';
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
$strWhere = 'AND `id` <> ' .$arrModifyData['id'];
}
$strSQL1 = "SELECT `id`,`$preKeyField`, `active` FROM `$preTableName` "
. "WHERE $strDomainWhere $strWhere ORDER BY `$preKeyField`";
$booReturn1 = $myDBClass->hasDataArray($strSQL1, $arrDataTpl, $intDataCountTpl);
if ($booReturn1 == false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCountTpl != 0) {
/** @var array $arrDataTpl */
foreach ($arrDataTpl as $elem) {
if ($elem['active'] == 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$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');
}
}
$strSQL2 = 'SELECT `id`, `name`, `active` FROM `tbl_contact` '
. "WHERE `name` <> '' AND $strDomainWhere2 ORDER BY name";
$booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataHpl, $intDataCountHpl);
if ($booReturn2 == false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCountHpl != 0) {
/** @var array $arrDataHpl */
foreach ($arrDataHpl as $elem) {
if ($elem['active'] == 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$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');
}
}
// Process timeperiod selection fields
if (isset($arrModifyData['host_notification_period'])) {
$intFieldId = $arrModifyData['host_notification_period'];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'host_time', 1, $intFieldId);
if ($intReturn1 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['service_notification_period'])) {
$intFieldId = $arrModifyData['service_notification_period'];
} else {
$intFieldId = 0;
}
$intReturn2 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'service_time', 1, $intFieldId);
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;
}
$intReturn3 = $myVisClass->parseSelectMulti(
'tbl_command',
'command_name',
'host_command',
'tbl_lnkContacttemplateToCommandHost',
0,
$intFieldId
);
if ($intReturn3 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['service_notification_commands'])) {
$intFieldId = $arrModifyData['service_notification_commands'];
} else {
$intFieldId = 0;
}
$intReturn4 = $myVisClass->parseSelectMulti(
'tbl_command',
'command_name',
'service_command',
'tbl_lnkContacttemplateToCommandService',
0,
$intFieldId
);
if ($intReturn4 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process contactgroup selection field
if (isset($arrModifyData['contactgroups'])) {
$intFieldId = $arrModifyData['contactgroups'];
} else {
$intFieldId = 0;
}
$intReturn5 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
'contactgroup',
'tbl_lnkContacttemplateToContactgroup',
2,
$intFieldId
);
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;
}
$intReturn6 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn6 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// 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 ($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) {
$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) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1f');
$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
$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
$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');
$conttp->setVariable(
'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
foreach (explode(',', $arrModifyData['host_notification_options']) as $elem) {
$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->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Do not show modified time list
$intNoTime = 1;
// Process template selection fields (Spezial)
$strWhere = "";
if (isset($arrModifyData) && ($chkSelModify == "modify")) {
$strWhere = "AND `id` <> ".$arrModifyData['id'];
}
$strSQL = "SELECT `id`,`$preKeyField`, `active` FROM `$preTableName` WHERE $strDomainWhere $strWhere ORDER BY `$preKeyField`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataTpl,$intDataCountTpl);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($intDataCountTpl != 0) {
foreach ($arrDataTpl AS $elem) {
if ($elem['active'] == 0) {
$strActive = " [inactive]";
$conttp->setVariable("SPECIAL_STYLE","inactive_option");
} else {
$strActive = "";
$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");
}
}
$strSQL = "SELECT `id`, `name`, `active` FROM `tbl_contact` WHERE `name` <> '' AND $strDomainWhere2 ORDER BY name";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataHpl,$intDataCount);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($arrDataHpl != 0) {
foreach ($arrDataHpl AS $elem) {
if ($elem['active'] == 0) {
$strActive = " [inactive]";
$conttp->setVariable("SPECIAL_STYLE","inactive_option");
} else {
$strActive = "";
$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");
}
}
// Process timeperiod selection fields
$intReturn = 0;
if (isset($arrModifyData['host_notification_period'])) {$intFieldId = $arrModifyData['host_notification_period'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','host_time',1,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['service_notification_period'])) {$intFieldId = $arrModifyData['service_notification_period'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','service_time',1,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process command selection fields
if (isset($arrModifyData['host_notification_commands'])) {$intFieldId = $arrModifyData['host_notification_commands'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti('tbl_command','command_name','host_command','tbl_lnkContacttemplateToCommandHost',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['service_notification_commands'])) {$intFieldId = $arrModifyData['service_notification_commands'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti('tbl_command','command_name','service_command','tbl_lnkContacttemplateToCommandService',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process contactgroup selection field
if (isset($arrModifyData['contactgroups'])) {$intFieldId = $arrModifyData['contactgroups'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti('tbl_contactgroup','contactgroup_name','contactgroup','tbl_lnkContacttemplateToContactgroup',2,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// 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 ($intVersion == 3) {
$conttp->setVariable("HOST_OPTION_FIELDS","chbHOd3,chbHOu3,chbHOr3,chbHOf3,chbHOs3,chbHOn3");
$conttp->setVariable("SERVICE_OPTION_FIELDS","chbSOw3,chbSOu3,chbSOc3,chbSOr3,chbSOf3,chbSOs3,chbSOn3");
} else {
$conttp->setVariable("HOST_OPTION_FIELDS","chbHOd2,chbHOu2,chbHOr2,chbHOf2,chbHOn2");
$conttp->setVariable("SERVICE_OPTION_FIELDS","chbSOw2,chbSOu2,chbSOc2,chbSOr2,chbSOf2,chbSOn2");
$conttp->setVariable("VERSION_20_VALUE_MUST",",tfFriendly");
}
// 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
$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");
$conttp->setVariable("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
foreach(explode(",",$arrModifyData['host_notification_options']) AS $elem) {
$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->parse("datainsert");
$conttp->show("datainsert");
}
//
// List view
// ==========
if ($chkModus == 'display') {
// 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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$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'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias');
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

281
admin/datadomain.php Normal file → Executable file
View File

@@ -5,183 +5,156 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2011-12-01 15:20:17 +0100 (Do, 01. Dez 2011) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1137 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preTableName = 'tbl_datadomain';
$preKeyField = 'domain';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 35;
$preContent = "admin/datadomain.tpl.htm";
$preTableName = 'tbl_datadomain';
$preKeyField = 'domain';
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
require("../functions/prepend_adm.php");
require("../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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($chkTfValue1 == 'common') || ($chkSelValue1 != 0))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Domain modified:'). ' ' .$chkTfValue1);
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
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;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != "") && ($chkTfValue2 != "") && (($chkTfValue1 == 'common') || ($chkSelValue1 != 0))) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Domain modified:')." ".$chkTfValue1);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Data domain administration'));
$conttp->parse("header");
$conttp->show("header");
//
// Single view
// ===========
if ($chkModus == 'add') {
// Process configuration target selection fields
if (isset($arrModifyData['targets'])) {
$intFieldId = $arrModifyData['targets'];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectSimple('tbl_configtarget', 'target', 'target', 0, $intFieldId);
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;
}
$intReturn2 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('LOCKCLASS', 'inputlock');
} elseif ($arrModifyData['domain'] == 'common') {
$conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable('COMMON_INVISIBLE', 'class="elementHide"');
$conttp->setVariable('LOCKCLASS', 'inputlock');
} else {
$conttp->setVariable('CHECK_TARGETS', ',selValue1');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Process configuration target selection fields
$intReturn = 0;
if (isset($arrModifyData['targets'])) {$intFieldId = $arrModifyData['targets'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_configtarget','target','target',0,$intFieldId);
if ($intReturn != 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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!'));
$conttp->setVariable("FILL_ALLFIELDS",translate('Please fill in all fields marked with an *'));
$conttp->setVariable("FILL_ILLEGALCHARS",translate('The following field contains not permitted 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
$myContentClass->addInsertData($conttp,$arrModifyData,0,'');
// Nagios version
if ($arrModifyData['version'] == 1) $conttp->setVariable("VER_SELECTED_1","selected");
if ($arrModifyData['version'] == 2) $conttp->setVariable("VER_SELECTED_2","selected");
if ($arrModifyData['version'] == 3) $conttp->setVariable("VER_SELECTED_3","selected");
// Enable common domain
if ($arrModifyData['enable_common'] == 0) $conttp->setVariable("ENA_COMMON_SELECTED_0","selected");
if ($arrModifyData['enable_common'] == 1) $conttp->setVariable("ENA_COMMON_SELECTED_1","selected");
// Domain localhost cant' be renamed
if ($arrModifyData['domain'] == "localhost") {
$conttp->setVariable("DOMAIN_DISABLE","readonly");
$conttp->setVariable("LOCKCLASS","inputlock");
} else if ($arrModifyData['domain'] == "common") {
$conttp->setVariable("DOMAIN_DISABLE","readonly");
$conttp->setVariable("COMMON_INVISIBLE","class=\"elementHide\"");
$conttp->setVariable("LOCKCLASS","inputlock");
} else {
$conttp->setVariable("CHECK_TARGETS",",selValue1");
}
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// List view
// ==========
if ($chkModus == 'display') {
// 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
$strOrderString = "ORDER BY `domain` $hidSortDir";
if ($hidSortBy == 2) {
$strOrderString = "ORDER BY `alias` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$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'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Data domain'));
$mastertp->setVariable("FIELD_2",translate('Description'));
// Row sorting
$strOrderString = "ORDER BY `domain` $hidSortDir";
if ($hidSortBy == 2) $strOrderString = "ORDER BY `alias` $hidSortDir";
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias');
}
// Show messages
$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,176 +5,145 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1257 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preFieldvars = 1;
$prePageId = 26;
$preContent = "admin/delbackup.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Get configuration set ID
// ========================
$myConfigClass->getConfigTargets($arrConfigSet);
$arrConfigSet = $myConfigClass->getConfigSets();
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$myConfigClass->getConfigValues($intConfigId, 'backupdir', $strBackupDir);
$myConfigClass->getConfigValues($intConfigId, 'hostbackup', $strHostBackupDir);
$myConfigClass->getConfigValues($intConfigId, 'servicebackup', $strServiceBackupDir);
$myConfigClass->getConfigData($intConfigId,"method",$intMethod);
$myConfigClass->getConfigData($intConfigId,"backupdir",$strBackupDir);
$myConfigClass->getConfigData($intConfigId,"hostbackup",$strHostBackupDir);
$myConfigClass->getConfigData($intConfigId,"servicebackup",$strServiceBackupDir);
//
// Process form inputs
// ===================
if (($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);
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
}
if (($chkMselValue1[0] != "") && ($chkStatus == 1)) {
foreach($chkMselValue1 AS $elem) {
$intCheck = $myConfigClass->removeFile(trim($elem),$intConfigId);
$strFile = str_replace($strServiceBackupDir,"",$elem);
$strFile = str_replace($strHostBackupDir,"",$strFile);
$strFile = str_replace($strBackupDir,"",$strFile);
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
// ===============
$conttp->setVariable('TITLE', translate('Delete backup files'));
$conttp->parse('header');
$conttp->show('header');
$conttp->setVariable('LANG_SEARCH_STRING', translate('Filter string'));
$conttp->setVariable('LANG_SEARCH', translate('Search'));
$conttp->setVariable('LANG_DELETE', translate('Delete'));
$conttp->setVariable('LANG_DELETE_SEARCH', translate('Reset filter'));
$conttp->setVariable('DAT_SEARCH', $chkTfSearch);
$conttp->setVariable('BACKUPFILE', translate('Backup file'));
$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));
$conttp->setVariable("TITLE",translate("Delete backup files"));
$conttp->parse("header");
$conttp->show("header");
$conttp->setVariable("LANG_SEARCH_STRING",translate('Filter string'));
$conttp->setVariable("LANG_SEARCH",translate('Search'));
$conttp->setVariable("LANG_DELETE",translate('Delete'));
$conttp->setVariable("LANG_DELETE_SEARCH",translate("Reset filter"));
$conttp->setVariable("DAT_SEARCH",$chkTfSearch);
$conttp->setVariable("BACKUPFILE",translate("Backup file"));
$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_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
// Build a local file list
if ($intMethod == 1) {
$output = array();
$myConfigClass->storeDirToArray($strBackupDir, "\.cfg_old", '', $output, $strErrorMessage);
if (is_array($output) && (count($output) != 0)) {
foreach ($output as $elem) {
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);
if (is_array($arrFiles1)) {
$arrFiles = array_merge($arrFiles, $arrFiles1);
}
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId, $strHostBackupDir);
if (is_array($arrFiles2)) {
$arrFiles = array_merge($arrFiles, $arrFiles2);
}
$arrFiles3 = ftp_nlist($myConfigClass->resConnectId, $strServiceBackupDir);
if (is_array($arrFiles3)) {
$arrFiles = array_merge($arrFiles, $arrFiles3);
}
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
foreach ($arrFiles as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
$conttp->setVariable('DAT_BACKUPFILE', $elem);
$conttp->parse('filelist');
}
}
} else {
$myVisClass->processMessage(
translate('No backup files or no permission to read the backup files'),
$strErrorMessage
);
}
ftp_close($myConfigClass->resConnectId);
} 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)) {
$arrFiles = array_merge($arrFiles, $arrFiles1);
}
$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)) {
$arrFiles = array_merge($arrFiles, $arrFiles3);
}
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)) {
$conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $elem));
$conttp->parse('filelist');
}
}
} else {
$myVisClass->processMessage(
translate('No backup files or no permission to read the backup files'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$output = array();
$temp=$myConfigClass->DirToArray($strBackupDir, "\.cfg_", "",$output,$strErrorMessage);
if (is_array($output) && (count($output) != 0)) {
foreach ($output AS $elem) {
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) {
$conttp->setVariable("DAT_BACKUPFILE",$elem);
$conttp->parse("filelist");
}
}
}
} else if ($intMethod == 2) {
// Set up basic connection
if ($myConfigClass->getFTPConnection($intConfigId) == "0") {
$arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId,$strBackupDir);
if (is_array($arrFiles1)) $arrFiles = array_merge($arrFiles,$arrFiles1);
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId,$strHostBackupDir);
if (is_array($arrFiles2)) $arrFiles = array_merge($arrFiles,$arrFiles2);
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId,$strServiceBackupDir);
if (is_array($arrFiles1)) $arrFiles = array_merge($arrFiles,$arrFiles1);
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
foreach ($arrFiles AS $elem) {
if (!substr_count($elem,"cfg")) continue;
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) {
$conttp->setVariable("DAT_BACKUPFILE",$elem);
$conttp->parse("filelist");
}
}
} else {
$myVisClass->processMessage(translate("No backup files or no permission to read the backup files"),$strErrorMessage);
}
ftp_close($myConfigClass->resConnectId);
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
}
} else if ($intMethod == 3) {
// Set up basic connection
if ($myConfigClass->getSSHConnection($intConfigId) == "0") {
$arrFiles = array();
$arrFiles1 = $myConfigClass->sendSSHCommand("ls ".$strBackupDir."*.cfg_old*");
if (is_array($arrFiles1)) $arrFiles = array_merge($arrFiles,$arrFiles1);
$arrFiles2 = $myConfigClass->sendSSHCommand("ls ".$strHostBackupDir."*.cfg_old*");
if (is_array($arrFiles2)) $arrFiles = array_merge($arrFiles,$arrFiles2);
$arrFiles3 = $myConfigClass->sendSSHCommand("ls ".$strServiceBackupDir."*.cfg_old*");
if (is_array($arrFiles3)) $arrFiles = array_merge($arrFiles,$arrFiles3);
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)) {
$conttp->setVariable("DAT_BACKUPFILE",str_replace("//","/",$elem));
$conttp->parse("filelist");
}
}
} else {
$myVisClass->processMessage(translate("No backup files or no permission to read the backup files"),$strErrorMessage);
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
}
}
if ($strErrorMessage != '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage);
$conttp->setVariable("INFOMESSAGE",$strInfoMessage);
// 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');
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
$conttp->parse("main");
$conttp->show("main");
//
// Footer ausgeben
// ===============
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,187 +5,160 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1257 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preFieldvars = 1;
$prePageId = 27;
$preContent = "admin/delbackup.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Get configuration set ID
// ========================
$myConfigClass->getConfigTargets($arrConfigSet);
$arrConfigSet = $myConfigClass->getConfigSets();
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$myConfigClass->getConfigValues($intConfigId, 'basedir', $strBaseDir);
$myConfigClass->getConfigValues($intConfigId, 'hostconfig', $strHostDir);
$myConfigClass->getConfigValues($intConfigId, 'serviceconfig', $strServiceDir);
$myConfigClass->getConfigData($intConfigId,"method",$intMethod);
$myConfigClass->getConfigData($intConfigId,"basedir",$strBaseDir);
$myConfigClass->getConfigData($intConfigId,"hostconfig",$strHostDir);
$myConfigClass->getConfigData($intConfigId,"serviceconfig",$strServiceDir);
//
// Process form inputs
// ===================
/** @var array $chkMselValue1 */
if (($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);
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
}
if (($chkMselValue1[0] != "") && ($chkStatus == 1)) {
foreach($chkMselValue1 AS $elem) {
$intCheck = $myConfigClass->removeFile(trim($elem),$intConfigId);
$strFile = str_replace($strServiceDir,"",$elem);
$strFile = str_replace($strHostDir,"",$strFile);
$strFile = str_replace($strBaseDir,"",$strFile);
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
// ===============
$conttp->setVariable('TITLE', translate('Delete config files'));
$conttp->parse('header');
$conttp->show('header');
$conttp->setVariable('LANG_SEARCH_STRING', translate('Filter string'));
$conttp->setVariable('LANG_SEARCH', translate('Search'));
$conttp->setVariable('LANG_DELETE', translate('Delete'));
$conttp->setVariable('LANG_DELETE_SEARCH', translate('Reset filter'));
$conttp->setVariable('DAT_SEARCH', $chkTfSearch);
$conttp->setVariable('BACKUPFILE', translate('Configuration file'));
$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));
$conttp->setVariable("TITLE",translate("Delete config files"));
$conttp->parse("header");
$conttp->show("header");
$conttp->setVariable("LANG_SEARCH_STRING",translate('Filter string'));
$conttp->setVariable("LANG_SEARCH",translate('Search'));
$conttp->setVariable("LANG_DELETE",translate('Delete'));
$conttp->setVariable("LANG_DELETE_SEARCH",translate("Reset filter"));
$conttp->setVariable("DAT_SEARCH",$chkTfSearch);
$conttp->setVariable("BACKUPFILE",translate("Configuration file"));
$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_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
// 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)) {
foreach ($output as $elem2) {
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);
if (is_array($arrFiles1)) {
$arrFiles = array_merge($arrFiles, $arrFiles1);
}
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId, $strHostDir);
if (is_array($arrFiles2)) {
$arrFiles = array_merge($arrFiles, $arrFiles2);
}
$arrFiles3 = ftp_nlist($myConfigClass->resConnectId, $strServiceDir);
if (is_array($arrFiles3)) {
$arrFiles = array_merge($arrFiles, $arrFiles3);
}
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
foreach ($arrFiles as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
$conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $elem));
$conttp->parse('filelist');
}
}
}
ftp_close($myConfigClass->resConnectId);
} 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)) {
foreach ($arrFiles1 as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
}
if (substr_count($elem, 'cgi.cfg') != 0) {
continue;
}
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));
$conttp->parse('filelist');
}
}
}
$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));
$conttp->parse('filelist');
}
}
}
$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));
$conttp->parse('filelist');
}
}
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$output = array();
$temp=$myConfigClass->DirToArray($strBaseDir, "\.cfg", "",$output,$strErrorMessage);
if (is_array($output) && (count($output) != 0)) {
foreach ($output AS $elem2) {
if (($chkTfSearch == "") || (substr_count($elem2,$chkTfSearch) != 0)) {
$conttp->setVariable("DAT_BACKUPFILE",$elem2);
$conttp->parse("filelist");
}
}
}
} else if ($intMethod == 2) {
// Open ftp connection
if ($myConfigClass->getFTPConnection($intConfigId) == "0") {
$arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId,$strBaseDir);
if (is_array($arrFiles1)) $arrFiles = array_merge($arrFiles,$arrFiles1);
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId,$strHostDir);
if (is_array($arrFiles2)) $arrFiles = array_merge($arrFiles,$arrFiles2);
$arrFiles3 = ftp_nlist($myConfigClass->resConnectId,$strServiceDir);
if (is_array($arrFiles3)) $arrFiles = array_merge($arrFiles,$arrFiles3);
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
foreach ($arrFiles AS $elem) {
if (!substr_count($elem,"cfg")) continue;
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) {
$conttp->setVariable("DAT_BACKUPFILE",str_replace("//","/",$elem));
$conttp->parse("filelist");
}
}
}
ftp_close($myConfigClass->resConnectId);
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
}
} else if ($intMethod == 3) {
// Open ssh connection
if ($myConfigClass->getSSHConnection($intConfigId) == "0") {
$arrFiles1 = $myConfigClass->sendSSHCommand('ls '.$strBaseDir);
if (is_array($arrFiles1) && (count($arrFiles1) != 0)) {
foreach ($arrFiles1 AS $elem) {
if (!substr_count($elem,"cfg")) continue;
if (substr_count($elem,"cgi.cfg") != 0) continue;
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));
$conttp->parse("filelist");
}
}
}
$arrFiles2 = $myConfigClass->sendSSHCommand('ls '.$strHostDir);
if (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));
$conttp->parse("filelist");
}
}
}
$arrFiles3 = $myConfigClass->sendSSHCommand('ls '.$strServiceDir);
if (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));
$conttp->parse("filelist");
}
}
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
}
}
if ($strErrorMessage != '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage);
$conttp->setVariable("INFOMESSAGE",$strInfoMessage);
// 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');
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
$conttp->parse("main");
$conttp->show("main");
//
// Footer ausgeben
// ===============
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,22 +5,18 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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
// ===============
session_cache_limiter('private_no_expire');
@@ -29,33 +25,44 @@ session_cache_limiter('private_no_expire');
// ==========================
$preNoMain = 1;
$preNoLogin = 1;
require $preBasePath.'functions/prepend_adm.php';
require("../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)));
$chkTable = isset($_GET['table']) ? htmlspecialchars($_GET['table'], ENT_QUOTES, 'utf-8') : "";
$chkConfig = isset($_GET['config']) ? htmlspecialchars($_GET['config'], ENT_QUOTES, 'utf-8') : "";
$chkLine = isset($_GET['line']) ? htmlspecialchars($_GET['line'], ENT_QUOTES, 'utf-8') : 0;
//
// Header output
// ===============
$arrConfig = $myConfigClass->getConfData();
if (isset($arrConfig[$chkTable])) {
$strFile = $arrConfig[$chkTable]['filename'];
} else {
$strFile = $chkConfig. '.cfg';
switch($chkTable) {
case "tbl_timeperiod": $strFile = "timeperiods.cfg"; break;
case "tbl_command": $strFile = "commands.cfg"; break;
case "tbl_contact": $strFile = "contacts.cfg"; break;
case "tbl_contacttemplate": $strFile = "contacttemplates.cfg"; break;
case "tbl_contactgroup": $strFile = "contactgroups.cfg"; break;
case "tbl_hosttemplate": $strFile = "hosttemplates.cfg"; break;
case "tbl_servicetemplate": $strFile = "servicetemplates.cfg"; break;
case "tbl_hostgroup": $strFile = "hostgroups.cfg"; break;
case "tbl_servicegroup": $strFile = "servicegroups.cfg"; break;
case "tbl_servicedependency": $strFile = "servicedependencies.cfg"; break;
case "tbl_hostdependency": $strFile = "hostdependencies.cfg"; break;
case "tbl_serviceescalation": $strFile = "serviceescalations.cfg"; break;
case "tbl_hostescalation": $strFile = "hostescalations.cfg"; break;
case "tbl_hostextinfo": $strFile = "hostextinfo.cfg"; break;
case "tbl_serviceextinfo": $strFile = "serviceextinfo.cfg"; break;
default: $strFile = $chkConfig.".cfg";
}
if ($strFile == '.cfg') {
exit;
}
header('Content-Disposition: attachment; filename=' .$strFile);
header('Content-Type: text/plain');
if ($strFile == ".cfg") exit;
header("Content-Disposition: attachment; filename=".$strFile);
header("Content-Type: text/plain");
//
// Get data
// ========
if ($chkLine == 0) {
$myConfigClass->createConfig($chkTable, 1);
$myConfigClass->createConfig($chkTable,1);
} else {
$myConfigClass->createConfigSingle($chkTable, $chkLine, 1);
$myConfigClass->createConfigSingle($chkTable,$chkLine,1);
}
$myDataClass->writeLog(translate('Download'). ' ' .$strFile);
$myDataClass->writeLog(translate('Download')." ".$strFile);
?>

View File

@@ -5,197 +5,161 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'group';
$preTableName = 'tbl_group';
$preKeyField = 'groupname';
$preAccess = 1;
$preFieldvars = 1;
$preNoAccessGrp = 1;
$arrDataLines = array();
$prePageId = 33;
$preContent = "admin/group.tpl.htm";
$preSearchSession = 'group';
$preTableName = 'tbl_group';
$preKeyField = 'groupname';
$preAccess = 1;
$preFieldvars = 1;
$preNoAccessGrp = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
//
require("../functions/prepend_adm.php");
require("../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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == '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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser']) &&
(count($_SESSION['groupuser']) != 0)) {
foreach ($_SESSION['groupuser'] as $elem) {
if ($elem['status'] == 0) {
$intRead = 0;
$intWrite = 0;
$intLink = 0;
if (substr_count($elem['rights'], 'READ') != 0) {
$intRead = 1;
}
if (substr_count($elem['rights'], 'WRITE') != 0) {
$intWrite = 1;
}
if (substr_count($elem['rights'], 'LINK') != 0) {
$intLink = 1;
}
if ($intWrite == 1) {
$intRead = 1;
$intLink = 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')";
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if (($chkModus == "insert") || ($chkModus == "modify")) {
$strSQLx = "`$preTableName` SET `groupname`='$chkTfValue1', `description`='$chkTfValue2', `active`='$chkActive', `last_modified`=NOW()";
if ($chkModus == "insert") {
$strSQL = "INSERT INTO ".$strSQLx;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != "") && ($chkTfValue2 != "")) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser']) && (count($_SESSION['groupuser']) != 0)) {
foreach($_SESSION['groupuser'] AS $elem) {
if ($elem['status'] == 0) {
$intRead = 0; $intWrite = 0; $intLink = 0;
if (substr_count($elem['rights'],"READ") != 0) $intRead = 1;
if (substr_count($elem['rights'],"WRITE") != 0) $intWrite = 1;
if (substr_count($elem['rights'],"LINK") != 0) $intLink = 1;
if ($intWrite == 1) {$intRead = 1;$intLink = 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')";
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
}
}
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Group administration'));
$conttp->parse("header");
$conttp->show("header");
//
// 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)) {
foreach ($arrDataLines as $elem) {
$conttp->setVariable('DAT_USER_ID', $elem['id']);
$conttp->setVariable('DAT_USER', $elem['username']);
$conttp->parse('users');
}
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
$conttp->setVariable('TITLE', translate('Group administration'));
$conttp->setVariable('LANG_READ', translate('Read'));
$conttp->setVariable('LANG_WRITE', translate('Write'));
$conttp->setVariable('LANG_LINK', translate('Link'));
$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
$myContentClass->addInsertData($conttp, $arrModifyData, 0, '');
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Process data fields
$strSQL = "SELECT * FROM tbl_user WHERE id <> 1 ORDER BY username";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($booReturn && ($intDataCount != 0)) {
foreach($arrDataLines AS $elem) {
$conttp->setVariable("DAT_USER_ID",$elem['id']);
$conttp->setVariable("DAT_USER",$elem['username']);
$conttp->parse("users");
}
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
$conttp->setVariable("LANG_READ",translate("Read"));
$conttp->setVariable("LANG_WRITE",translate("Write"));
$conttp->setVariable("LANG_LINK",translate("Link"));
$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 not permitted characters:'));
// 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
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable('TITLE', translate('Group administration'));
$mastertp->setVariable('FIELD_1', translate('Groupname'));
$mastertp->setVariable('FIELD_2', translate('Description'));
// Row sorting
$strOrderString = "ORDER BY `groupname` $hidSortDir";
if ($hidSortBy == 2) {
$strOrderString = "ORDER BY `description` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName`";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$chkLimit = 0;
}
}
// 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) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'description');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Groupname'));
$mastertp->setVariable("FIELD_2",translate('Description'));
// Row sorting
$strOrderString = "ORDER BY `groupname` $hidSortDir";
if ($hidSortBy == 2) $strOrderString = "ORDER BY `description` $hidSortDir";
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName`";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $chkLimit = 0;
}
// Get datasets
$strSQL = "SELECT `id`, `groupname`, `description`, `active` FROM `$preTableName` $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'description');
}
// Show messages
$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,171 +5,146 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1257 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
//$prePageId = 33;
$preNoMain = 1;
require $preBasePath.'functions/prepend_adm.php';
require("../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);
if (substr_count($chkRights, '-')) {
$arrRights = explode('-', $chkRights);
$strRights = '';
if ($arrRights[0] == 1) {
$strRights .= 'READ,';
}
if ($arrRights[1] == 1) {
$strRights .= 'WRITE,';
}
if ($arrRights[2] == 1) {
$strRights .= 'LINK,';
}
if ($strRights != '') {
$strRights = substr($strRights, 0, -1);
}
$chkRights = $strRights;
$chkDataId = isset($_GET['dataId']) ? htmlspecialchars($_GET['dataId'], ENT_QUOTES, 'utf-8') : 0;
$chkMode = isset($_GET['mode']) ? htmlspecialchars($_GET['mode'], ENT_QUOTES, 'utf-8') : "";
$chkUser = isset($_GET['user']) ? htmlspecialchars($_GET['user'], ENT_QUOTES, 'utf-8') : "";
$chkRights = isset($_GET['rights']) ? htmlspecialchars($_GET['rights'], ENT_QUOTES, 'utf-8') : "";
$chkId = isset($_GET['id']) ? htmlspecialchars($_GET['id'], ENT_QUOTES, 'utf-8') : "";
$chkVersion = isset($_GET['version']) ? htmlspecialchars($_GET['version'], ENT_QUOTES, 'utf-8') : 0;
$chkLinkTab = isset($_GET['linktab']) ? htmlspecialchars($_GET['linktab'], ENT_QUOTES, 'utf-8') : "";
if (substr_count($chkRights,"-")) {
$arrRights = explode("-",$chkRights);
$strRights = "";
if ($arrRights[0] == 1) $strRights .= "READ,";
if ($arrRights[1] == 1) $strRights .= "WRITE,";
if ($arrRights[2] == 1) $strRights .= "LINK,";
if ($strRights != "") $strRights = substr($strRights,0,-1);
$chkRights = $strRights;
}
if (get_magic_quotes_gpc() == 0) {
$chkUser = addslashes($chkUser);
$chkRights = addslashes($chkRights);
$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`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
//
// Write data to session
// =====================
if ($chkMode == '') {
$_SESSION['groupuser'] = array();
if ($intDataCount != 0) {
foreach ($arrDataLines as $elem) {
$arrTemp['id'] = $elem['id'];
$arrTemp['user'] = $elem['id'];
$strRights = '';
if ($elem['read'] == 1) {
$strRights .= 'READ,';
}
if ($elem['write'] == 1) {
$strRights .= 'WRITE,';
}
if ($elem['link'] == 1) {
$strRights .= 'LINK,';
}
if ($strRights != '') {
$strRights = substr($strRights, 0, -1);
}
$arrTemp['rights'] = $strRights;
$arrTemp['status'] = 0;
$_SESSION['groupuser'][] = $arrTemp;
}
}
}
if ($chkLinkTab != "") {
$strSQL = "SELECT * FROM `tbl_user` LEFT JOIN `".$chkLinkTab."` ON `id`=`idSlave` WHERE `idMaster`=$chkDataId ORDER BY `username`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
//
// Write data to session
// =====================
if ($chkMode == "") {
$_SESSION['groupuser'] = "";
if ($intDataCount != 0) {
foreach ($arrDataLines AS $elem) {
$arrTemp['id'] = $elem['id'];
$arrTemp['user'] = $elem['id'];
$strRights = "";
if ($elem['read'] == 1) $strRights .= "READ,";
if ($elem['write'] == 1) $strRights .= "WRITE,";
if ($elem['link'] == 1) $strRights .= "LINK,";
if ($strRights != "") $strRights = substr($strRights,0,-1);
$arrTemp['rights'] = $strRights;
$arrTemp['status'] = 0;
$_SESSION['groupuser'][] = $arrTemp;
}
}
}
}
//
// 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)) {
$_SESSION['groupuser'][$key]['user'] = $chkUser;
$_SESSION['groupuser'][$key]['rights'] = $chkRights;
$intCheck = 1;
}
}
if ($intCheck == 0) {
$arrTemp['id'] = 0;
$arrTemp['user'] = $chkUser;
$arrTemp['rights'] = $chkRights;
$arrTemp['status'] = 0;
$_SESSION['groupuser'][] = $arrTemp;
}
} else {
$arrTemp['id'] = 0;
$arrTemp['user'] = $chkUser;
$arrTemp['rights'] = $chkRights;
$arrTemp['status'] = 0;
$_SESSION['groupuser'] = array();
$_SESSION['groupuser'][] = $arrTemp;
}
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)) {
$_SESSION['groupuser'][$key]['user'] = $chkUser;
$_SESSION['groupuser'][$key]['rights'] = $chkRights;
$intCheck = 1;
}
}
if ($intCheck == 0) {
$arrTemp['id'] = 0;
$arrTemp['user'] = $chkUser;
$arrTemp['rights'] = $chkRights;
$arrTemp['status'] = 0;
$_SESSION['groupuser'][] = $arrTemp;
}
} else {
$arrTemp['id'] = 0;
$arrTemp['user'] = $chkUser;
$arrTemp['rights'] = $chkRights;
$arrTemp['status'] = 0;
$_SESSION['groupuser'][] = $arrTemp;
}
}
//
// 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)) {
$_SESSION['groupuser'][$key]['status'] = 1;
}
}
if ($chkMode == "del") {
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser'])) {
foreach ($_SESSION['groupuser'] AS $key => $elem) {
if (($elem['user'] == $chkUser) && ($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">
<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%">
<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']); ?>
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>
<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 {
} else {
?>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
@@ -177,8 +152,8 @@ if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser']) && (count(
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
}
?>
</table>
</body>
</table>
</body>
</html>

View File

@@ -5,174 +5,149 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1257 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$setSaveLangId = 'private';
$prePageId = 39;
$preContent = "admin/helpedit.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
$setSaveLangId = "private";
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../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
// =================================
$chkHidVersion = $myVisClass->tfSecure($chkHidVersion);
$chkKey1 = $myVisClass->tfSecure($chkKey1);
$chkKey2 = $myVisClass->tfSecure($chkKey2);
$chkVersion = $myVisClass->tfSecure($chkVersion);
//
$chkHidVersion = isset($_POST['hidVersion']) ? $_POST['hidVersion'] : "all";
$chkKey1 = isset($_POST['selInfoKey1']) ? $_POST['selInfoKey1'] : "";
$chkKey2 = isset($_POST['selInfoKey2']) ? $_POST['selInfoKey2'] : "";
$chkVersion = isset($_POST['selInfoVersion']) ? $_POST['selInfoVersion'] : "";
//
// 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) {
$strSQL = 'INSERT INTO `tbl_info` (`key1`,`key2`,`version`,`language`,`infotext`) '
. "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'";
}
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
}
if (($chkTaValue1 != "") && ($chkTfValue3 == "1")) {
$strSQL = "SELECT `infotext` FROM `tbl_info`
WHERE `key1` = '$chkTfValue1' AND `key2` = '$chkTfValue2' AND `version` = '$chkHidVersion'
AND `language` = '$setSaveLangId'";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
if ($intDataCount == 0) {
$strSQL = "INSERT INTO `tbl_info` (`key1`,`key2`,`version`,`language`,`infotext`)
VALUES ('$chkTfValue1','$chkTfValue2','$chkHidVersion','$setSaveLangId','$chkTaValue1')";
} else {
$strSQL = "UPDATE `tbl_info` SET `infotext` = '$chkTaValue1'
WHERE `key1` = '$chkTfValue1' AND `key2` = '$chkTfValue2' AND `version` = '$chkHidVersion'
AND `language` = '$setSaveLangId'";
}
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($intReturn != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage);
}
}
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Help text editor'));
$conttp->parse("header");
$conttp->show("header");
//
// 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');
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
}
$conttp->setVariable('INFOKEY_1', translate('Main key'));
$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') {
$conttp->setVariable('DEFAULT_CHECKED', 'checked');
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
$conttp->setVariable("MAINSITE",$_SESSION['SETS']['path']['base_url']."admin.php");
foreach($arrDescription AS $elem) {
$conttp->setVariable($elem['name'],$elem['string']);
}
$conttp->setVariable("INFOKEY_1",translate('Main key'));
$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") $conttp->setVariable("DEFAULT_CHECKED","checked");
//
// Get Key
// =======
$arrData = array();
$strSQL = 'SELECT DISTINCT `key1` FROM `tbl_info` ORDER BY `key1`';
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
$strSQL = "SELECT DISTINCT `key1` FROM `tbl_info` ORDER BY `key1`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
if ($intDataCount != 0) {
foreach ($arrData as $elem) {
$conttp->setVariable('INFOKEY_1_VAL', $elem['key1']);
if ($chkKey1 == $elem['key1']) {
$conttp->setVariable('INFOKEY_1_SEL', 'selected');
$conttp->setVariable('INFOKEY_1_SEL_VAL', $elem['key1']);
}
$conttp->parse('infokey1');
}
foreach ($arrData AS $elem) {
$conttp->setVariable("INFOKEY_1_VAL",$elem['key1']);
if ($chkKey1 == $elem['key1']) {
$conttp->setVariable("INFOKEY_1_SEL","selected");
$conttp->setVariable("INFOKEY_1_SEL_VAL",$elem['key1']);
}
$conttp->parse("infokey1");
}
}
if ($chkKey1 != '') {
$strSQL = "SELECT DISTINCT `key2` FROM `tbl_info` WHERE `key1` = '$chkKey1' ORDER BY `key1`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($intDataCount != 0) {
foreach ($arrData as $elem) {
$conttp->setVariable('INFOKEY_2_VAL', $elem['key2']);
if ($chkKey2 == $elem['key2']) {
$conttp->setVariable('INFOKEY_2_SEL', 'selected');
$conttp->setVariable('INFOKEY_2_SEL_VAL', $elem['key2']);
}
$conttp->parse('infokey2');
}
}
if ($chkKey1 != "") {
$strSQL = "SELECT DISTINCT `key2` FROM `tbl_info` WHERE `key1` = '$chkKey1' ORDER BY `key1`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
if ($intDataCount != 0) {
foreach ($arrData AS $elem) {
$conttp->setVariable("INFOKEY_2_VAL",$elem['key2']);
if ($chkKey2 == $elem['key2']) {
$conttp->setVariable("INFOKEY_2_SEL","selected");
$conttp->setVariable("INFOKEY_2_SEL_VAL",$elem['key2']);
}
$conttp->parse("infokey2");
}
}
}
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 == '')) {
$chkVersion = $arrData[0]['version'];
}
foreach ($arrData as $elem) {
$conttp->setVariable('INFOVERSION_2_VAL', $elem['version']);
if ($chkVersion == $elem['version']) {
$conttp->setVariable('INFOVERSION_2_SEL', 'selected');
$conttp->setVariable('INFOVERSION_2_SEL_VAL', $elem['version']);
}
$conttp->parse('infoversion');
}
}
if (($chkKey1 != "") && ($chkKey2 != "")) {
$strSQL = "SELECT DISTINCT `version` FROM `tbl_info` WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' ORDER BY `version`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
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']) {
$conttp->setVariable("INFOVERSION_2_SEL","selected");
$conttp->setVariable("INFOVERSION_2_SEL_VAL",$elem['version']);
}
$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'";
$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'";
$strContentDB = $myDBClass->getFieldData($strSQL);
}
$conttp->setVariable('DAT_HELPTEXT', $strContentDB);
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'";
$strContentDB = $myDBClass->getFieldData($strSQL);
}
$conttp->setVariable("DAT_HELPTEXT",$strContentDB);
}
// Messages
if ($strErrorMessage != '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
if ($strInfoMessage != '') {
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
}
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage);
if ($strInfoMessage != "") $conttp->setVariable("INFOMESSAGE",$strInfoMessage);
// 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');
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
$conttp->parse("helpedit");
$conttp->show("helpedit");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,389 +5,225 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'hostdependencies';
$preTableName = 'tbl_hostdependency';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 19;
$preContent = "admin/hostdependencies.tpl.htm";
$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';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Data processing
// ===============
$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e, 0, -1);
$strNO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e, 0, -1);
//
$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;
} else {
$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))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Host dependency modified:'). ' ' .$chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkHostdependencyToHost_DH',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkHostdependencyToHost_H',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkHostdependencyToHostgroup_DH',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataInsertRelation(
'tbl_lnkHostdependencyToHostgroup_H',
$chkDataId,
$chkMselValue4
);
}
if (isset($intRet4) && ($intRet4 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostdependencyToHost_DH',
$chkDataId,
$chkMselValue1
);
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkHostdependencyToHost_DH', $chkDataId);
}
if ($intRet1 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostdependencyToHost_H',
$chkDataId,
$chkMselValue2
);
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkHostdependencyToHost_H', $chkDataId);
}
if ($intRet2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostdependencyToHostgroup_DH',
$chkDataId,
$chkMselValue3
);
} else {
$intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkHostdependencyToHostgroup_DH', $chkDataId);
}
if ($intRet3 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostdependencyToHostgroup_H',
$chkDataId,
$chkMselValue4
);
} else {
$intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkHostdependencyToHostgroup_H', $chkDataId);
}
if ($intRet4 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) {
$strInfoMessage = '';
}
//
// Update Import HASH
// ==================
$booReturn = $myDataClass->updateHash($preTableName, $chkDataId);
if ($booReturn != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
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;
} else {
$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))) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Host dependency modified:')." ".$chkTfValue1);
//
// Insert/update relations
// =======================
if ($chkModus == "insert") {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkHostdependencyToHost_DH",$chkDataId,$chkMselValue1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkHostdependencyToHost_H",$chkDataId,$chkMselValue2);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkHostdependencyToHostgroup_DH",$chkDataId,$chkMselValue3);
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkHostdependencyToHostgroup_H",$chkDataId,$chkMselValue4);
if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else if ($chkModus == "modify") {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkHostdependencyToHost_DH",$chkDataId,$chkMselValue1);
} else {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkHostdependencyToHost_DH",$chkDataId);
}
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkHostdependencyToHost_H",$chkDataId,$chkMselValue2);
} else {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkHostdependencyToHost_H",$chkDataId);
}
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkHostdependencyToHostgroup_DH",$chkDataId,$chkMselValue3);
} else {
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkHostdependencyToHostgroup_DH",$chkDataId);
}
if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkHostdependencyToHostgroup_H",$chkDataId,$chkMselValue4);
} else {
$intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkHostdependencyToHostgroup_H",$chkDataId);
}
if ($intRet4 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) $strInfoMessage = "";
//
// Update Import HASH
// ==================
$booReturn = $myDataClass->updateHash($preTableName,$chkDataId);
if ($booReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Define host dependencies (hostdependencies.cfg)'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
$conttp->setVariable('TITLE', translate('Define host dependencies (hostdependencies.cfg)'));
// 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;
}
$intReturn = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
'depend_host',
'tbl_lnkHostdependencyToHost_DH',
2,
$intFieldId
);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['host_name'])) {
$intFieldId = $arrModifyData['host_name'];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
'host',
'tbl_lnkHostdependencyToHost_H',
2,
$intFieldId
);
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;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'timeperiod', 1, $intFieldId);
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;
}
$intReturn = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
'depend_hostgroup',
'tbl_lnkHostdependencyToHostgroup_DH',
2,
$intFieldId
);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['hostgroup_name'])) {
$intFieldId = $arrModifyData['hostgroup_name'];
} else {
$intFieldId = 0;
}
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
'hostgroup',
'tbl_lnkHostdependencyToHostgroup_H',
2,
$intFieldId
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
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;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
if ($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');
}
foreach (explode(',', $arrModifyData['notification_failure_criteria']) as $elem) {
$conttp->setVariable('DAT_NO' .strtoupper($elem). '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// 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;}
$intReturn = $myVisClass->parseSelectMulti('tbl_host','host_name','depend_host','tbl_lnkHostdependencyToHost_DH',2,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['host_name'])) {$intFieldId = $arrModifyData['host_name'];} else {$intFieldId = 0;}
$intReturn1 = $myVisClass->parseSelectMulti('tbl_host','host_name','host','tbl_lnkHostdependencyToHost_H',2,$intFieldId);
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','timeperiod',1,$intFieldId);
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;}
$intReturn = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','depend_hostgroup','tbl_lnkHostdependencyToHostgroup_DH',2,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['hostgroup_name'])) {$intFieldId = $arrModifyData['hostgroup_name'];} else {$intFieldId = 0;}
$intReturn2 = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','hostgroup','tbl_lnkHostdependencyToHostgroup_H',2,$intFieldId);
if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
if ($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");
}
foreach(explode(",",$arrModifyData['notification_failure_criteria']) AS $elem) {
$conttp->setVariable("DAT_NO".strtoupper($elem)."_CHECKED","checked");
}
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// 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('DISABLE_SORT_2', 'disable');
// Process search string
if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchTxt = $_SESSION['search'][$preSearchSession];
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$chkLimit = 0;
}
}
// 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'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData(
$mastertp,
$arrDataLines,
$intDataCount,
$intLineCount,
$preKeyField,
'process_field',
40
);
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Config name'));
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $chkLimit = 0;
}
// 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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'process_field',40);
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,386 +5,222 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'hostescalation';
$preTableName = 'tbl_hostescalation';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 20;
$preContent = "admin/hostescalations.tpl.htm";
$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';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Data processing
// ===============
$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c, 0, -1);
//
$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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
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') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Host escalation modified:'). ' ' .$chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkHostescalationToContact',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkHostescalationToContactgroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkHostescalationToHost',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataInsertRelation(
'tbl_lnkHostescalationToHostgroup',
$chkDataId,
$chkMselValue4
);
}
if (isset($intRet4) && ($intRet4 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostescalationToContact',
$chkDataId,
$chkMselValue1
);
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkHostescalationToContact', $chkDataId);
}
if ($intRet1 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostescalationToContactgroup',
$chkDataId,
$chkMselValue2
);
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkHostescalationToContactgroup', $chkDataId);
}
if ($intRet2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostescalationToHost',
$chkDataId,
$chkMselValue3
);
} else {
$intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkHostescalationToHost', $chkDataId);
}
if ($intRet3 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostescalationToHostgroup',
$chkDataId,
$chkMselValue4
);
} else {
$intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkHostescalationToHostgroup', $chkDataId);
}
if ($intRet4 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) {
$strInfoMessage = '';
}
//
// Update Import HASH
// ==================
$booReturn = $myDataClass->updateHash($preTableName, $chkDataId);
if ($booReturn != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
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;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
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") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Host escalation modified:')." ".$chkTfValue1);
//
// Insert/update relations
// =======================
if ($chkModus == "insert") {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkHostescalationToContact",$chkDataId,$chkMselValue1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkHostescalationToContactgroup",$chkDataId,$chkMselValue2);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkHostescalationToHost",$chkDataId,$chkMselValue3);
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkHostescalationToHostgroup",$chkDataId,$chkMselValue4);
if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else if ($chkModus == "modify") {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkHostescalationToContact",$chkDataId,$chkMselValue1);
} else {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkHostescalationToContact",$chkDataId);
}
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkHostescalationToContactgroup",$chkDataId,$chkMselValue2);
} else {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkHostescalationToContactgroup",$chkDataId);
}
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkHostescalationToHost",$chkDataId,$chkMselValue3);
} else {
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkHostescalationToHost",$chkDataId);
}
if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkHostescalationToHostgroup",$chkDataId,$chkMselValue4);
} else {
$intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkHostescalationToHostgroup",$chkDataId);
}
if ($intRet4 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) $strInfoMessage = "";
//
// Update Import HASH
// ==================
$booReturn = $myDataClass->updateHash($preTableName,$chkDataId);
if ($booReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Define host escalation (hostescalations.cfg)'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
$conttp->setVariable('TITLE', translate('Define host escalation (hostescalations.cfg)'));
// 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;
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
'host',
'tbl_lnkHostescalationToHost',
2,
$intFieldId
);
if ($intReturn1 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['hostgroup_name'])) {
$intFieldId = $arrModifyData['hostgroup_name'];
} else {
$intFieldId = 0;
}
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
'hostgroup',
'tbl_lnkHostescalationToHostgroup',
2,
$intFieldId
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
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;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'escperiod', 1, $intFieldId);
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;
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_contact',
'contact_name',
'contact',
'tbl_lnkHostescalationToContact',
2,
$intFieldId
);
if ($intReturn1 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['contact_groups'])) {
$intFieldId = $arrModifyData['contact_groups'];
} else {
$intFieldId = 0;
}
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
'contactgroup',
'tbl_lnkHostescalationToContactgroup',
2,
$intFieldId
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
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;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
foreach (explode(',', $arrModifyData['escalation_options']) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// 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;}
$intReturn1 = $myVisClass->parseSelectMulti('tbl_host','host_name','host','tbl_lnkHostescalationToHost',2,$intFieldId);
if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['hostgroup_name'])) {$intFieldId = $arrModifyData['hostgroup_name'];} else {$intFieldId = 0;}
$intReturn2 = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','hostgroup','tbl_lnkHostescalationToHostgroup',2,$intFieldId);
if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','escperiod',1,$intFieldId);
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;}
$intReturn1 = $myVisClass->parseSelectMulti('tbl_contact','contact_name','contact','tbl_lnkHostescalationToContact',2,$intFieldId);
if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['contact_groups'])) {$intFieldId = $arrModifyData['contact_groups'];} else {$intFieldId = 0;}
$intReturn2 = $myVisClass->parseSelectMulti('tbl_contactgroup','contactgroup_name','contactgroup','tbl_lnkHostescalationToContactgroup',2,$intFieldId);
if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
foreach(explode(",",$arrModifyData['escalation_options']) AS $elem) {
$conttp->setVariable("DAT_EO".strtoupper($elem)."_CHECKED","checked");
}
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// 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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$chkLimit = 0;
}
}
// 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'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData(
$mastertp,
$arrDataLines,
$intDataCount,
$intLineCount,
$preKeyField,
'process_field',
40
);
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $chkLimit = 0;
}
// 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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'process_field',40);
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,198 +5,155 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'hostextinfo';
$preTableName = 'tbl_hostextinfo';
$preKeyField = 'host_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 21;
$preContent = "admin/hostextinfo.tpl.htm";
$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';
//
require("../functions/prepend_adm.php");
require("../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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if ($chkSelValue1 != 0) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Host extended information modified:'). ' ' .$chkSelValue1);
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
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;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if ($chkSelValue1 != 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Host extended information modified:')." ".$chkSelValue1);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Define host extended information (hostextinfo.cfg)'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
$conttp->setVariable('TITLE', translate('Define host extended information (hostextinfo.cfg)'));
// Do not show modified time list
$intNoTime = 1;
if (isset($arrModifyData[$preKeyField])) {
$intFieldId = $arrModifyData[$preKeyField];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectSimple('tbl_host', $preKeyField, 'host', 0, $intFieldId);
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;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Do not show modified time list
$intNoTime = 1;
if (isset($arrModifyData[$preKeyField])) {$intFieldId = $arrModifyData[$preKeyField];} else {$intFieldId = 0;}
$intReturn1 = $myVisClass->parseSelectSimple('tbl_host',$preKeyField,'host',0,$intFieldId);
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// 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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `$preTableName`.`config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
$strOrderString = "ORDER BY `$preTableName`.`config_id`, `notes` $hidSortDir";
}
// Count datasets
$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) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$chkLimit = 0;
}
}
// 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'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
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');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `$preTableName`.`config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) $strOrderString = "ORDER BY `$preTableName`.`config_id`, `notes` $hidSortDir";
// Count datasets
$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->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $chkLimit = 0;
}
// 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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
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
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,275 +5,178 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'hostgroup';
$preTableName = 'tbl_hostgroup';
$preKeyField = 'hostgroup_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 10;
$preContent = "admin/hostgroups.tpl.htm";
$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';
//
require("../functions/prepend_adm.php");
require("../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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($intMselValue1 != 0) || ($intVersion >= 3))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Host group modified:'). ' ' .$chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkHostgroupToHost',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkHostgroupToHostgroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostgroupToHost',
$chkDataId,
$chkMselValue1
);
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkHostgroupToHost', $chkDataId);
}
if ($intRet1 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkHostgroupToHostgroup',
$chkDataId,
$chkMselValue2
);
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkHostgroupToHostgroup', $chkDataId);
}
if ($intRet2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2) != 0) {
$strInfoMessage = '';
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
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;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != "") && ($chkTfValue2 != "") && (($intMselValue1 != 0) || ($intVersion == 3))) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Host group modified:')." ".$chkTfValue1);
//
// Insert/update relations
// =======================
if ($chkModus == "insert") {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkHostgroupToHost",$chkDataId,$chkMselValue1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkHostgroupToHostgroup",$chkDataId,$chkMselValue2);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else if ($chkModus == "modify") {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkHostgroupToHost",$chkDataId,$chkMselValue1);
} else {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkHostgroupToHost",$chkDataId);
}
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkHostgroupToHostgroup",$chkDataId,$chkMselValue2);
} else {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkHostgroupToHostgroup",$chkDataId);
}
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (($intRet1 + $intRet2) != 0) $strInfoMessage = "";
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Define host groups (hostgroups.cfg)'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
$conttp->setVariable('TITLE', translate('Define host groups (hostgroups.cfg)'));
// Do not show modified time list
$intNoTime = 1;
// Process host selection field
if (isset($arrModifyData['members'])) {
$intFieldId = $arrModifyData['members'];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
'host_members',
'tbl_lnkHostgroupToHost',
2,
$intFieldId
);
if ($intReturn1 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
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;
}
$intReturn2 = $myVisClass->parseSelectMulti(
$preTableName,
$preKeyField,
'hostgroups',
'tbl_lnkHostgroupToHostgroup',
0,
$intFieldId,
$chkListId
);
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;
}
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Do not show modified time list
$intNoTime = 1;
// Process host selection field
if (isset($arrModifyData['members'])) {$intFieldId = $arrModifyData['members'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti('tbl_host','host_name','host_members','tbl_lnkHostgroupToHost',2,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (($intReturn != 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;}
$intReturn = $myVisClass->parseSelectMulti($preTableName,$preKeyField,'hostgroups','tbl_lnkHostgroupToHostgroup',0,$intFieldId,$chkListId);
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// 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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL1, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$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'];
$booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias');
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

File diff suppressed because it is too large Load Diff

View File

@@ -5,590 +5,378 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'hosttemplate';
$preTableName = 'tbl_hosttemplate';
$preKeyField = 'template_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 12;
$preContent = "admin/hosttemplates.tpl.htm";
$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';
require("../functions/prepend_adm.php");
require("../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 != '') {
for ($i = 1; $i <= 8; $i++) {
$tmpVar = 'chkTfArg'.$i;
$$tmpVar = str_replace('!', '::bang::', $$tmpVar);
if ($$tmpVar != '') {
$chkSelValue1 .= '!' .$$tmpVar;
}
}
$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 != "") {
for ($i=1;$i<=8;$i++) {
if (${"chkTfArg$i"} != "") $chkSelValue1 .= "!".${"chkTfArg$i"};
}
}
//
//
// 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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if ($chkTfValue1 != '') {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Host template modified:'). ' ' .$chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkHosttemplateToHost',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkHosttemplateToHostgroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkHosttemplateToContact',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataInsertRelation(
'tbl_lnkHosttemplateToContactgroup',
$chkDataId,
$chkMselValue4
);
}
if (isset($intRet4) && ($intRet4 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkHosttemplateToHost',
$chkDataId,
$chkMselValue1
);
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToHost', $chkDataId);
}
if ($intRet1 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkHosttemplateToHostgroup',
$chkDataId,
$chkMselValue2
);
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToHostgroup', $chkDataId);
}
if ($intRet2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkHosttemplateToContact',
$chkDataId,
$chkMselValue3
);
} else {
$intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToContact', $chkDataId);
}
if ($intRet3 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataUpdateRelation(
'tbl_lnkHosttemplateToContactgroup',
$chkDataId,
$chkMselValue4
);
} else {
$intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToContactgroup', $chkDataId);
}
if ($intRet4 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) {
$strInfoMessage = '';
}
//
// 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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
$intSortId++;
}
}
//
// 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) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCount != 0) {
foreach ($arrData as $elem) {
$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;
$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)) {
foreach ($_SESSION['variabledefinition'] as $elem) {
if ($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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
$strSQL = 'INSERT INTO `tbl_lnkHosttemplateToVariabledefinition` (`idMaster`, '
. "`idSlave`) VALUES ($chkDataId,$intInsertId)";
$intReturn2 = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `parents`=$intMselValue1, `parents_tploptions`=$chkRadValue1,
`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";
}
if ($intWriteAccessId == 0) {
if ($chkTfValue1 != "") {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Host template modified:')." ".$chkTfValue1);
//
// Insert/update relations
// =======================
if ($chkModus == "insert") {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkHosttemplateToHost",$chkDataId,$chkMselValue1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkHosttemplateToHostgroup",$chkDataId,$chkMselValue2);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkHosttemplateToContact",$chkDataId,$chkMselValue3);
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkHosttemplateToContactgroup",$chkDataId,$chkMselValue4);
if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else if ($chkModus == "modify") {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkHosttemplateToHost",$chkDataId,$chkMselValue1);
} else {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkHosttemplateToHost",$chkDataId);
}
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkHosttemplateToHostgroup",$chkDataId,$chkMselValue2);
} else {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkHosttemplateToHostgroup",$chkDataId);
}
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkHosttemplateToContact",$chkDataId,$chkMselValue3);
} else {
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkHosttemplateToContact",$chkDataId);
}
if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkHosttemplateToContactgroup",$chkDataId,$chkMselValue4);
} else {
$intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkHosttemplateToContactgroup",$chkDataId);
}
if ($intRet4 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) $strInfoMessage = "";
//
// 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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) && (count($_SESSION['templatedefinition']) != 0)) {
$intSortId = 1;
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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
$intSortId++;
}
}
//
// Insert/update session data for free variables
// =============================================
if ($chkModus == "modify") {
$strSQL = "SELECT * FROM `tbl_lnkHosttemplateToVariabledefinition` WHERE `idMaster`=$chkDataId";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($intDataCount != 0) {
foreach ($arrData AS $elem) {
$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";
$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)) {
foreach($_SESSION['variabledefinition'] AS $elem) {
if ($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_lnkHosttemplateToVariabledefinition` (`idMaster`,`idSlave`)
VALUES ($chkDataId,$intInsertId)";
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
}
}
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Host template definition (hosttemplates.cfg)'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
$conttp->setVariable('TITLE', translate('Host template definition (hosttemplates.cfg)'));
// Do not show modified time list
$intNoTime = 1;
// Process template fields
$strWhere = '';
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`";
$booReturn1 = $myDBClass->hasDataArray($strSQL1, $arrDataTpl, $intDataCountTpl);
if ($booReturn1 == false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCountTpl != 0) {
/** @var array $arrDataTpl */
foreach ($arrDataTpl as $elem) {
if ($elem['active'] == 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$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');
}
}
$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) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDataCountHpl != 0) {
/** @var array $arrDataHpl */
foreach ($arrDataHpl as $elem) {
if ($elem['active'] == 0) {
$strActive = ' [inactive]';
$conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
} else {
$strActive = '';
$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');
}
}
// Process host selection field
if (isset($arrModifyData['parents'])) {
$intFieldId = $arrModifyData['parents'];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
'host_parents',
'tbl_lnkHosttemplateToHost',
0,
$intFieldId
);
if ($intReturn1 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process hostgroup selection field
if (isset($arrModifyData['hostgroups'])) {
$intFieldId = $arrModifyData['hostgroups'];
} else {
$intFieldId = 0;
}
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
'hostgroup',
'tbl_lnkHosttemplateToHostgroup',
0,
$intFieldId
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// 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) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process check period selection field
if (isset($arrModifyData['check_period'])) {
$intFieldId = $arrModifyData['check_period'];
} else {
$intFieldId = 0;
}
$intReturn4 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'checkperiod', 1, $intFieldId);
if ($intReturn4 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['notification_period'])) {
$intFieldId = $arrModifyData['notification_period'];
} else {
$intFieldId = 0;
}
$intReturn5 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'notifyperiod', 1, $intFieldId);
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;
}
$intReturn6 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'eventhandler', 1, $intFieldId);
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;
}
$intReturn7 = $myVisClass->parseSelectMulti(
'tbl_contact',
'contact_name',
'host_contacts',
'tbl_lnkHosttemplateToContact',
2,
$intFieldId
);
if ($intReturn7 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['contact_groups'])) {
$intFieldId = $arrModifyData['contact_groups'];
} else {
$intFieldId = 0;
}
$intReturn8 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
'host_contactgroups',
'tbl_lnkHosttemplateToContactgroup',
2,
$intFieldId
);
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;
}
$intReturn9 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn9 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// 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 ($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
$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
$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,';
$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['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);
} else {
$value1 = str_replace('::bang::', '!', $value);
$value2 = str_replace('::back::', "\\", $value1);
$conttp->setVariable('DAT_ARG' .$key, htmlentities($value, ENT_QUOTES, 'UTF-8'));
}
}
}
// Process option fields
foreach (explode(',', $arrModifyData['initial_state']) as $elem) {
$conttp->setVariable('DAT_IS' .strtoupper($elem). '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['flap_detection_options']) as $elem) {
$conttp->setVariable('DAT_FL' .strtoupper($elem). '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['notification_options']) as $elem) {
$conttp->setVariable('DAT_NO' .strtoupper($elem). '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['stalking_options']) as $elem) {
$conttp->setVariable('DAT_ST' .strtoupper($elem). '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Do not show modified time list
$intNoTime = 1;
// Process template fields
$strWhere = "";
if (isset($arrModifyData) && ($chkSelModify == "modify")) {
$strWhere = "AND `id` <> ".$arrModifyData['id'];
}
$strSQL = "SELECT `id`,`$preKeyField`, `active` FROM `$preTableName` WHERE `config_id` = $chkDomainId $strWhere ORDER BY `$preKeyField`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataTpl,$intDataCountTpl);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($intDataCountTpl != 0) {
foreach ($arrDataTpl AS $elem) {
if ($elem['active'] == 0) {
$strActive = " [inactive]";
$conttp->setVariable("SPECIAL_STYLE","inactive_option");
} else {
$strActive = "";
$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");
}
}
$strSQL = "SELECT `id`, `name`, `active` FROM `tbl_host` WHERE `name` <> '' AND `config_id` = $chkDomainId ORDER BY `name`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataHpl,$intDataCount);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($arrDataHpl != 0) {
foreach ($arrDataHpl AS $elem) {
if ($elem['active'] == 0) {
$strActive = " [inactive]";
$conttp->setVariable("SPECIAL_STYLE","inactive_option");
} else {
$strActive = "";
$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");
}
}
// Process host selection field
if (isset($arrModifyData['parents'])) {$intFieldId = $arrModifyData['parents'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti('tbl_host','host_name','host_parents','tbl_lnkHosttemplateToHost',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process hostgroup selection field
if (isset($arrModifyData['hostgroups'])) {$intFieldId = $arrModifyData['hostgroups'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','hostgroup','tbl_lnkHosttemplateToHostgroup',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process check command selection field
if (isset($arrModifyData['check_command']) && ($arrModifyData['check_command'] != "")) {
$arrCommand = explode("!",$arrModifyData['check_command']);
$intFieldId = $arrCommand[0];
} else {
$intFieldId = 0;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_command','command_name','hostcommand',1,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process check period selection field
$intReturn = 0;
if (isset($arrModifyData['check_period'])) {$intFieldId = $arrModifyData['check_period'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','checkperiod',1,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['notification_period'])) {$intFieldId = $arrModifyData['notification_period'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','notifyperiod',1,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process event handler selection field
if (isset($arrModifyData['event_handler'])) {$intFieldId = $arrModifyData['event_handler'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_command','command_name','eventhandler',1,$intFieldId);
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;}
$intReturn = $myVisClass->parseSelectMulti('tbl_contact','contact_name','host_contacts','tbl_lnkHosttemplateToContact',2,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['contact_groups'])) {$intFieldId = $arrModifyData['contact_groups'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti('tbl_contactgroup','contactgroup_name','host_contactgroups','tbl_lnkHosttemplateToContactgroup',2,$intFieldId);
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// 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 ($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
$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
$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,high_flap_threshold,";
$strIntegerfelder .= "notification_interval,first_notification_delay";
foreach(explode(",",$strIntegerfelder) AS $elem) {
if ($arrModifyData[$elem] == -1) {
$conttp->setVariable("DAT_".strtoupper($elem),"null");
}
}
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);
} else {
$conttp->setVariable("DAT_ARG".$key,htmlentities($value,ENT_QUOTES,'UTF-8'));
}
}
}
// Process option fields
foreach(explode(",",$arrModifyData['initial_state']) AS $elem) {
$conttp->setVariable("DAT_IS".strtoupper($elem)."_CHECKED","checked");
}
foreach(explode(",",$arrModifyData['flap_detection_options']) AS $elem) {
$conttp->setVariable("DAT_FL".strtoupper($elem)."_CHECKED","checked");
}
foreach(explode(",",$arrModifyData['notification_options']) AS $elem) {
$conttp->setVariable("DAT_NO".strtoupper($elem)."_CHECKED","checked");
}
foreach(explode(",",$arrModifyData['stalking_options']) AS $elem) {
$conttp->setVariable("DAT_ST".strtoupper($elem)."_CHECKED","checked");
}
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// 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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL1, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$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'];
$booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($myContentClass->strErrorMessage != '') {
$myVisClass->processMessage($myContentClass->strErrorMessage, $strErrorMessage);
}
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $chkLimit = 0;
}
// Get datasets
$strSQL = "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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias');
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,294 +5,216 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-07 10:38:34 +0100 (Wed, 07 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1275 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preFieldvars = 1;
$intModus = 0;
$prePageId = 25;
$preContent = "admin/import.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
$intModus = 0;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Initialize import class
// =======================
$myImportClass = new functions\NagImportClass($_SESSION);
$myImportClass->myDBClass =& $myDBClass;
$myImportClass->myDataClass =& $myDataClass;
$myImportClass->myConfigClass =& $myConfigClass;
include("../functions/import_class.php");
$myImportClass = new nagimport;
$myImportClass->myDataClass =& $myDataClass;
$myImportClass->myDBClass =& $myDBClass;
$myImportClass->myConfigClass =& $myConfigClass;
//
// Get configuration set ID
// ========================
$myConfigClass->getConfigTargets($arrConfigSet);
$arrConfigSet = $myConfigClass->getConfigSets();
$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'],
$strErrorMessage
);
} else {
$intModus = 1;
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_local_imp');
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'],$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) {
$myVisClass->processMessage($myImportClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage($myImportClass->strInfoMessage, $strInfoMessage);
$myDataClass->writeLog(translate('File imported - File [overwrite flag]:'). ' ' .
$_FILES['datValue1']['name']. ' [' .$chkChbValue1. ']');
}
}
$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 [overwite flag]:')." ".$_FILES['datValue1']['name']." [".$chkChbValue1."]");
}
}
}
if (($chkMselValue1[0] != '') && ($chkStatus == 1)) {
/** @var array $chkMselValue1 */
foreach ($chkMselValue1 as $elem) {
$intModus = 1;
$myImportClass->strErrorMessage = '';
$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. ']');
}
}
if (($chkMselValue1[0] != "") && ($chkStatus == 1)) {
foreach($chkMselValue1 AS $elem) {
$intModus = 1;
$myImportClass->strErrorMessage = "";
$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 [overwite flag]:')." ".$elem." [".$chkChbValue1."]");
}
}
}
//
// Start content
// =============
$conttp->setVariable('TITLE', translate('Configuration import'));
$conttp->parse('header');
$conttp->show('header');
$conttp->setVariable('LANG_SEARCH_STRING', translate('Filter string'));
$conttp->setVariable('LANG_SEARCH', translate('Search'));
$conttp->setVariable('LANG_DELETE', translate('Delete'));
$conttp->setVariable('LANG_DELETE_SEARCH', translate('Reset filter'));
$conttp->setVariable('DAT_SEARCH', $chkTfSearch);
$conttp->setVariable('TEMPLATE', translate('Template definition'));
$conttp->setVariable('IMPORTFILE', translate('Import file'));
$conttp->setVariable('LOCAL_FILE', translate('Local import file'));
$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('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 '
. 'import!</b><br>In cause of an error or an uncomplete configuration, re-importing the wrong configuration '
. 'can solve the problem.'). '</span>');
$conttp->parse('filelist1');
$conttp->setVariable("TITLE",translate('Configuration import'));
$conttp->parse("header");
$conttp->show("header");
$conttp->setVariable("LANG_SEARCH_STRING",translate('Filter string'));
$conttp->setVariable("LANG_SEARCH",translate('Search'));
$conttp->setVariable("LANG_DELETE",translate('Delete'));
$conttp->setVariable("LANG_DELETE_SEARCH",translate("Reset filter"));
$conttp->setVariable("DAT_SEARCH",$chkTfSearch);
$conttp->setVariable("TEMPLATE",translate('Template definition'));
$conttp->setVariable("IMPORTFILE",translate('Import file'));
$conttp->setVariable("LOCAL_FILE",translate('Local import file'));
$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_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
$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 import!</b><br>In cause of an error or an uncomplete configuration, re-importing the wrong configuration can solve the problem.")."</span>");
$conttp->parse("filelist1");
// Get settings
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$myConfigClass->getConfigValues($intConfigId, 'basedir', $strBaseDir);
$myConfigClass->getConfigValues($intConfigId, 'hostconfig', $strHostDir);
$myConfigClass->getConfigValues($intConfigId, 'serviceconfig', $strServiceDir);
$myConfigClass->getConfigValues($intConfigId, 'backupdir', $strBackupDir);
$myConfigClass->getConfigValues($intConfigId, 'hostbackup', $strHostBackupDir);
$myConfigClass->getConfigValues($intConfigId, 'servicebackup', $strServiceBackupDir);
$myConfigClass->getConfigValues($intConfigId, 'importdir', $strImportDir);
$myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strNagiosBaseDir);
$myConfigClass->getConfigData($intConfigId,"method",$intMethod);
$myConfigClass->getConfigData($intConfigId,"basedir",$strBaseDir);
$myConfigClass->getConfigData($intConfigId,"hostconfig",$strHostDir);
$myConfigClass->getConfigData($intConfigId,"serviceconfig",$strServiceDir);
$myConfigClass->getConfigData($intConfigId,"backupdir",$strBackupDir);
$myConfigClass->getConfigData($intConfigId,"hostbackup",$strHostBackupDir);
$myConfigClass->getConfigData($intConfigId,"servicebackup",$strServiceBackupDir);
$myConfigClass->getConfigData($intConfigId,"importdir",$strImportDir);
$myConfigClass->getConfigData($intConfigId,"nagiosbasedir",$strNagiosBaseDir);
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) {
$myConfigClass->storeDirToArray(
$strNagiosBaseDir,
"\.cfg",
'cgi.cfg|nagios.cfg|nrpe.cfg|nsca.cfg',
$arrOutput1,
$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)) {
$myConfigClass->storeDirToArray($strImportDir, "\.cfg", '', $arrOutput1, $strErrorMessage);
}
$arrOutput2=array_unique($arrOutput1);
if (is_array($arrOutput2) && (count($arrOutput2) != 0)) {
foreach ($arrOutput2 as $elem) {
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);
if (is_array($arrFiles1)) {
$arrFiles = array_merge($arrFiles, $arrFiles1);
}
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId, $strHostDir);
if (is_array($arrFiles2)) {
$arrFiles = array_merge($arrFiles, $arrFiles2);
}
$arrFiles3 = ftp_nlist($myConfigClass->resConnectId, $strServiceDir);
if (is_array($arrFiles3)) {
$arrFiles = array_merge($arrFiles, $arrFiles3);
}
$arrFiles4 = ftp_nlist($myConfigClass->resConnectId, $strHostBackupDir);
if (is_array($arrFiles4)) {
$arrFiles = array_merge($arrFiles, $arrFiles4);
}
$arrFiles5 = ftp_nlist($myConfigClass->resConnectId, $strServiceBackupDir);
if (is_array($arrFiles5)) {
$arrFiles = array_merge($arrFiles, $arrFiles5);
}
if ($strImportDir != '') {
$arrFiles6 = ftp_nlist($myConfigClass->resConnectId, $strImportDir);
if (is_array($arrFiles6)) {
$arrFiles = array_merge($arrFiles, $arrFiles6);
}
}
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
foreach ($arrFiles as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
}
if (substr_count($elem, 'resource.cfg')) {
continue;
}
if (substr_count($elem, 'nagios.cfg')) {
continue;
}
if (substr_count($elem, 'cgi.cfg')) {
continue;
}
if (substr_count($elem, 'nrpe.cfg')) {
continue;
}
if (substr_count($elem, 'nsca.cfg')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
$conttp->setVariable('DAT_IMPORTFILE_2', str_replace('//', '/', $elem));
$conttp->parse('filelist2');
}
}
}
ftp_close($myConfigClass->resConnectId);
} 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)) {
$arrFiles = array_merge($arrFiles, $arrFiles1);
}
$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)) {
$arrFiles = array_merge($arrFiles, $arrFiles3);
}
$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)) {
$arrFiles = array_merge($arrFiles, $arrFiles5);
}
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)) {
foreach ($arrFiles as $elem) {
if (!substr_count($elem, 'cfg')) {
continue;
}
if (substr_count($elem, 'resource.cfg')) {
continue;
}
if (substr_count($elem, 'nagios.cfg')) {
continue;
}
if (substr_count($elem, 'cgi.cfg')) {
continue;
}
if (substr_count($elem, 'nrpe.cfg')) {
continue;
}
if (substr_count($elem, 'nsca.cfg')) {
continue;
}
if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
$conttp->setVariable('DAT_IMPORTFILE_2', str_replace('//', '/', $elem));
$conttp->parse('filelist2');
}
}
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
// Building local file list
$output = array();
$temp=$myConfigClass->DirToArray($strBaseDir, "\.cfg", "cgi.cfg|nagios.cfg|nrpe.cfg|nsca.cfg",$output,$strErrorMessage);
if ($strNagiosBaseDir != $strBaseDir) {
$temp=$myConfigClass->DirToArray($strNagiosBaseDir, "\.cfg", "cgi.cfg|nagios.cfg|nrpe.cfg|nsca.cfg",$output,$strErrorMessage);
}
$temp=$myConfigClass->DirToArray($strHostDir, "\.cfg", "",$output,$strErrorMessage);
$temp=$myConfigClass->DirToArray($strServiceDir, "\.cfg", "",$output,$strErrorMessage);
$temp=$myConfigClass->DirToArray($strHostBackupDir, "\.cfg_", "",$output,$strErrorMessage);
$temp=$myConfigClass->DirToArray($strServiceBackupDir, "\.cfg_", "",$output,$strErrorMessage);
if (($strImportDir != "") && ($strImportDir != $strBaseDir) && ($strImportDir != $strNagiosBaseDir)) {
$temp=$myConfigClass->DirToArray($strImportDir, "\.cfg", "",$output,$strErrorMessage);
}
$output=array_unique($output);
if (is_array($output) && (count($output) != 0)) {
foreach ($output AS $elem) {
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) {
$conttp->setVariable("DAT_IMPORTFILE_2",$elem);
$conttp->parse("filelist2");
}
}
}
} else if ($intMethod == 2) {
// Set up basic connection
if ($myConfigClass->getFTPConnection($intConfigId) == "0") {
$arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId,$strBaseDir);
if (is_array($arrFiles1)) $arrFiles = array_merge($arrFiles,$arrFiles1);
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId,$strHostDir);
if (is_array($arrFiles2)) $arrFiles = array_merge($arrFiles,$arrFiles2);
$arrFiles3 = ftp_nlist($myConfigClass->resConnectId,$strServiceDir);
if (is_array($arrFiles3)) $arrFiles = array_merge($arrFiles,$arrFiles3);
$arrFiles4 = ftp_nlist($myConfigClass->resConnectId,$strHostBackupDir);
if (is_array($arrFiles4)) $arrFiles = array_merge($arrFiles,$arrFiles4);
$arrFiles5 = ftp_nlist($myConfigClass->resConnectId,$strServiceBackupDir);
if (is_array($arrFiles5)) $arrFiles = array_merge($arrFiles,$arrFiles5);
if ($strImportDir != "" ) {
$arrFiles6 = ftp_nlist($myConfigClass->resConnectId,$strImportDir);
if (is_array($arrFiles6)) $arrFiles = array_merge($arrFiles,$arrFiles6);
}
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
foreach ($arrFiles AS $elem) {
if (!substr_count($elem,"cfg")) continue;
if (substr_count($elem,"resource.cfg")) continue;
if (substr_count($elem,"nagios.cfg")) continue;
if (substr_count($elem,"cgi.cfg")) continue;
if (substr_count($elem,"nrpe.cfg")) continue;
if (substr_count($elem,"nsca.cfg")) continue;
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) {
$conttp->setVariable("DAT_IMPORTFILE_2",str_replace("//","/",$elem));
$conttp->parse("filelist2");
}
}
}
ftp_close($myConfigClass->resConnectId);
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
}
} else if ($intMethod == 3) {
// Set up basic connection
if ($myConfigClass->getSSHConnection($intConfigId) == "0") {
$arrFiles = array();
$arrFiles1 = $myConfigClass->sendSSHCommand("ls ".$strBaseDir."*.cfg");
if ($arrFiles1 && is_array($arrFiles1)) $arrFiles = array_merge($arrFiles,$arrFiles1);
$arrFiles2 = $myConfigClass->sendSSHCommand("ls ".$strHostDir."*.cfg");
if (is_array($arrFiles2)) $arrFiles = array_merge($arrFiles,$arrFiles2);
$arrFiles3 = $myConfigClass->sendSSHCommand("ls ".$strServiceDir."*.cfg");
if (is_array($arrFiles3)) $arrFiles = array_merge($arrFiles,$arrFiles3);
$arrFiles4 = $myConfigClass->sendSSHCommand("ls ".$strHostBackupDir."*.cfg*");
if (is_array($arrFiles4)) $arrFiles = array_merge($arrFiles,$arrFiles4);
$arrFiles5 = $myConfigClass->sendSSHCommand("ls ".$strServiceBackupDir."*.cfg*");
if (is_array($arrFiles5)) $arrFiles = array_merge($arrFiles,$arrFiles5);
if ($strImportDir != "" ) {
$arrFiles6 = $myConfigClass->sendSSHCommand("ls ".$strImportDir."*.cfg");
if (is_array($arrFiles6)) $arrFiles = array_merge($arrFiles,$arrFiles6);
}
if (is_array($arrFiles) && (count($arrFiles) != 0)) {
foreach ($arrFiles AS $elem) {
if (!substr_count($elem,"cfg")) continue;
if (substr_count($elem,"resource.cfg")) continue;
if (substr_count($elem,"nagios.cfg")) continue;
if (substr_count($elem,"cgi.cfg")) continue;
if (substr_count($elem,"nrpe.cfg")) continue;
if (substr_count($elem,"nsca.cfg")) continue;
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) {
$conttp->setVariable("DAT_IMPORTFILE_2",str_replace("//","/",$elem));
$conttp->parse("filelist2");
}
}
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
}
}
// Check access rights for adding new objects
if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
if ($strErrorMessage != '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
$conttp->parse('main');
$conttp->show('main');
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage);
$conttp->setVariable("INFOMESSAGE",$strInfoMessage);
$conttp->parse("main");
$conttp->show("main");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

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

View File

@@ -5,105 +5,91 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Component : Admin information dialog
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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
// ==========================
$preNoMain = 1;
require $preBasePath.'functions/prepend_adm.php';
$preNoMain = 1;
require("../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);
$chkKey1 = isset($_GET['key1']) ? htmlspecialchars($_GET['key1'], ENT_QUOTES, 'utf-8') : "";
$chkKey2 = isset($_GET['key2']) ? htmlspecialchars($_GET['key2'], ENT_QUOTES, 'utf-8') : "";
$chkVersion = isset($_GET['version']) ? htmlspecialchars($_GET['version'], ENT_QUOTES, 'utf-8') : "";
//
// 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
$arrTrans = array(
'txtRootPath' => translate('This is relative path of your NagiosQL Installation'),
'txtBasePath' => translate('This is the absolut path to your NagiosQL Installation'),
'selProtocol' => translate('If you need a secure connection, select HTTPS instead of HTTP'),
'txtTempdir' => translate('Please choose a temporary directory with write permissions. The default is the ' .
'temp directory provided by your OS'),
'selLanguage' => translate('Please choose your application language for new users and login portal'),
'txtEncoding' => translate('Encoding should be set to nothing else than utf-8. Any changes at your own risk'),
'txtDBserver' => translate('IP-Address or hostname of the database server<br>e.g. localhost'),
'txtDBport' => translate('MySQL Server Port, default is 3306'),
'txtDBname' => translate('Name of the NagiosQL database<br>e.g. db_nagiosql_v3'),
'txtDBuser' => translate('User with sufficient permission for the NagiosQL database<br>At least this user ' .
'should have SELECT, INSERT, UPDATE, DELETE permissions'),
'txtDBpass' => translate('Password for the above mentioned user'),
'txtLogoff' => translate('After the defined amount of seconds the session will terminate for security ' .
'reasons'),
'selWSAuth' => translate('Decide between authentication based on your Webserver<br>e.g. Apache ' .
'configuration (config file or htaccess) or NagiosQL'),
'txtLines' => translate('Number of entries per side that should be visible (e.g. services or hosts)'),
'selSeldisable' => translate('Method of selection of multiple entries by using the new dialog or by holding ' .
'CTRL + left mouse button, as in NagiosQL 2'),
'templatecheck' => translate('Enable or disable the warning if a required field contains no data in objects ' .
'with templates'),
'updatecheck' => translate('Enable or disable the automatic online version check.'),
'chkUpdProxy' => translate('If you require a Proxyserver to connect to the Internet (Port 80), please ' .
'define one.'),
'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)'),
);
$strContentDB = $arrTrans[$chkKey2];
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
$arrTrans = array (
"txtRootPath" => translate("This is relative path of your NagiosQL Installation"),
"txtBasePath" => translate("This is the absolut path to your NagiosQL Installation"),
"selProtocol" => translate("If you need a secure connection, select HTTPS instead of HTTP"),
"txtTempdir" => translate("Please choose a temporary directory with write permissions. The default is the temp directory provided by your OS"),
"selLanguage" => translate("Please choose your application language"),
"txtEncoding" => translate("Encoding should be set to nothing else than utf-8. Any changes at your own risk"),
"txtDBserver" => translate("IP-Address or hostname of the database server<br>e.g. localhost"),
"txtDBport" => translate("MySQL Server Port, default is 3306"),
"txtDBname" => translate("Name of the NagiosQL database<br>e.g. db_nagiosql_v3"),
"txtDBuser" => translate("User with sufficient permission for the NagiosQL database<br>At least this user should have SELECT, INSERT, UPDATE, DELETE permissions"),
"txtDBpass" => translate("Password for the above mentioned user"),
"txtLogoff" => translate("After the defined amount of seconds the session will terminate for security reasons"),
"selWSAuth" => translate("Decide between authentication based on your Webserver<br>e.g. Apache configuration (config file or htaccess) or NagiosQL"),
"txtLines" => translate("How many entries per side should be visibile (e.g. services or hosts)"),
"selSeldisable" => translate("Selection of multiple entries by using the new dialog or by holding CTRL + left click like in NagiosQL2"),
"templatecheck" => translate("Enable or disable the warning if a required field contains no data in objects with templates"),
"updatecheck" => translate("Enable or disable the automatic online version check."),
"chkUpdProxy" => translate("If you require a Proxyserver to connect to the Internet (Port 80), please define one."),
"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)"),
);
$strContentDB = $arrTrans[$chkKey2];
} else {
// 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'";
$strContentDB = $myDBClass->getFieldData($strSQL);
}
// 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'";
$strContentDB = $myDBClass->getFieldData($strSQL);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo translate("Information PopUp");?></title>
<style>
.infobody {
font-family:"Courier New", Courier, monospace;
font-size:12px;
}
</style>
</head>
<body class="infobody">
<?php
if ($strContentDB != '') {
echo $strContentDB;
if ($strContentDB != "") {
echo $strContentDB;
} else {
echo translate('No information available');
echo translate("No information available");
}
?>
</body>
</body>
</html>

View File

@@ -5,136 +5,120 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-01-13 07:40:23 +0100 (Fri, 13 Jan 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1158 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preFieldvars = 1;
$prePageId = 37;
$preContent = "admin/admin_master.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Delete log entries
// ==================
$strWhere = '';
if ($chkTfValue1 != '') {
$strWhere .= "AND `time` > '$chkTfValue1 00:00:00'";
}
if ($chkTfValue2 != '') {
$strWhere .= "AND `time` < '$chkTfValue2 23:59:59'";
}
if ($strWhere != '') {
$strSQL = 'DELETE FROM `tbl_logbook` WHERE 1=1 ';
$strSQL .= $strWhere;
$booReturn = $myDBClass->insertData($strSQL);
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);
}
if (isset($_POST['tfValue1']) && (($chkTfValue1 != "") || ($chkTfValue2 != ""))) {
$strWhere = "";
if ($chkTfValue1 != "") {
$strWhere .= "AND `time` > '$chkTfValue1 00:00:00'";
}
if ($chkTfValue2 != "") {
$strWhere .= "AND `time` < '$chkTfValue2 23:59:59'";
}
$strSQL = "DELETE FROM `tbl_logbook` WHERE 1=1 $strWhere";
$booReturn = $myDBClass->insertData($strSQL);
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);
}
}
//
// Search data
// ===========
if ($chkTfSearch != '') {
$strWhere = "WHERE `user` LIKE '%$chkTfSearch%' OR `ipadress` LIKE '%$chkTfSearch%' "
. "OR `domain` LIKE '%$chkTfSearch%' OR `entry` LIKE '%$chkTfSearch%'";
if ($chkTfSearch != "") {
$strWhere = "WHERE `user` LIKE '%$chkTfSearch%' OR `ipadress` LIKE '%$chkTfSearch%' OR `domain` LIKE '%$chkTfSearch%' OR `entry` LIKE '%$chkTfSearch%'";
} else {
$strWhere = '';
$strWhere = "";
}
//
// 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 ($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->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
//
// Start content
// =============
$conttp->setVariable('TITLE', translate('View logbook'));
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
$conttp->setVariable("TITLE",translate('View logbook'));
foreach($arrDescription AS $elem) {
$conttp->setVariable($elem['name'],$elem['string']);
}
$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?'));
$conttp->setVariable('DAT_SEARCH', $chkTfSearch);
$conttp->setVariable("LANG_ENTRIES_BEFORE",translate('Delete logentries between:'));
$conttp->setVariable("LOCALE",$SETS['data']['locale']);
$conttp->setVariable("LANG_SELECT_DATE",translate('Please at least fill in a start or a stop time'));
$conttp->setVariable("LANG_DELETELOG",translate('Do you really want to delete all log entries between the 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>');
$intPrevNumber = $chkFromLine - 20;
$conttp->setVariable("LANG_PREVIOUS", "<a href=\"".filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)."?from_line=".$intPrevNumber."\"><< ".translate('previous 20 entries')."</a>");
} else {
$conttp->setVariable('LANG_PREVIOUS', '');
$conttp->setVariable("LANG_PREVIOUS", "");
}
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>');
$intNextNumber = $chkFromLine + 20;
$conttp->setVariable("LANG_NEXT", "<a href=\"".filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)."?from_line=".$intNextNumber."\">".translate('next 20 entries')." >></a>");
} else {
$conttp->setVariable('LANG_NEXT', '');
$conttp->setVariable("LANG_NEXT", "");
}
//
//
// Output log data
// ===============
if ($intDataCount != 0) {
for ($i = 0; $i < $intDataCount; $i++) {
// Set default values
if ($arrDataLines[$i]['ipadress'] == '') {
$arrDataLines[$i]['ipadress'] = '&nbsp;';
}
// Insert data values
$conttp->setVariable('DAT_TIME', $arrDataLines[$i]['time']);
$conttp->setVariable('DAT_ACCOUNT', $arrDataLines[$i]['user']);
$conttp->setVariable('DAT_ACTION', $arrDataLines[$i]['entry']);
$conttp->setVariable('DAT_IPADRESS', $arrDataLines[$i]['ipadress']);
$conttp->setVariable('DAT_DOMAIN', $arrDataLines[$i]['domain']);
$conttp->parse('logdatacell');
}
for ($i=0;$i<$intDataCount;$i++) {
// Set default values
if ($arrDataLines[$i]['ipadress'] == "") $arrDataLines[$i]['ipadress'] = "&nbsp;";
// Insert data values
$conttp->setVariable("DAT_TIME", $arrDataLines[$i]['time']);
$conttp->setVariable("DAT_ACCOUNT", $arrDataLines[$i]['user']);
$conttp->setVariable("DAT_ACTION", $arrDataLines[$i]['entry']);
$conttp->setVariable("DAT_IPADRESS", $arrDataLines[$i]['ipadress']);
$conttp->setVariable("DAT_DOMAIN", $arrDataLines[$i]['domain']);
$conttp->parse("logdatacell");
}
}
$conttp->setVariable('ERRORMESSAGE', '<br>' .$strErrorMessage);
$conttp->setVariable('INFOMESSAGE', '<br>' .$strInfoMessage);
$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');
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
$conttp->parse("logbooksite");
$conttp->show("logbooksite");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,104 +5,95 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preNoAccessGrp = 1;
$intFieldId = 0;
$prePageId = 34;
$preContent = "admin/admin_master.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
$preNoAccessGrp = 1;
$intFieldId = 0;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../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) {
$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"));
}
if (isset($_POST['subSave']) && ($chkSelValue1 != 0)) {
$strSQL = "UPDATE `tbl_menu` SET `mnuGrpId`='$chkSelValue2' WHERE `mnuId`=$chkSelValue1";
$booReturn = $myDBClass->insertData($strSQL);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while inserting the data to the data base:'),$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"));
}
}
//
// Include content
// ===============
$conttp->setVariable('TITLE', translate('Define Menu Access Rights'));
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
$conttp->setVariable("TITLE",translate('Define Menu Accessrights'));
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.'));
$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);
$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->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$conttp->setVariable('SUBMENU_VALUE', '0');
$conttp->setVariable('SUBMENU_NAME', '&nbsp;');
$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']));
} else {
$conttp->setVariable('SUBMENU_NAME', translate($elem['subitem']));
}
if ($chkSelValue1 == $elem['mnuId']) {
$conttp->setVariable('SUBMENU_SELECTED', 'selected');
$intFieldId = $elem['mnuGrpId'];
}
// Bypass main site
if ($elem['mnuId'] != 1) {
$conttp->parse('submenu');
}
}
// Process access group selection field
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
$conttp->setVariable("SUBMENU_VALUE","0");
$conttp->setVariable("SUBMENU_NAME","&nbsp;");
$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']));
} else {
$conttp->setVariable("SUBMENU_NAME",translate($elem['subitem']));
}
if ($chkSelValue1 == $elem['mnuId']) {
$conttp->setVariable("SUBMENU_SELECTED","selected");
$intFieldId = $elem['mnuGrpId'];
}
// Bypass main site
if ($elem['mnuId'] != 1) $conttp->parse("submenu");
}
// Process access group selection field
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
}
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
$conttp->setVariable("ERRORMESSAGE",$strErrorMessage);
$conttp->setVariable("INFOMESSAGE",$strInfoMessage);
// Check access rights for adding new objects
if ($intGlobalWriteAccess == 1) {
$conttp->setVariable('DISABLE_SAVE', 'disabled="disabled"');
}
$conttp->parse('menuaccesssite');
$conttp->show('menuaccesssite');
if ($intGlobalWriteAccess == 1) $conttp->setVariable("DISABLE_SAVE","disabled=\"disabled\"");
$conttp->parse("menuaccesssite");
$conttp->show("menuaccesssite");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,108 +5,86 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-08 15:13:31 +0100 (Wed, 08 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1189 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preContent = 'admin/mainpages.htm.tpl';
$prePageId = 2;
$preContent = "admin/mainpages.tpl.htm";
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Include content
// ===============
$conttp->setVariable('TITLE', translate('Monitoring'));
$conttp->parse('header');
$conttp->show('header');
$conttp->setVariable('DESC', translate('Define host and service supervisions as well as host and service groups.'));
$conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable('INACTIVE', translate('Inactive'));
$conttp->setVariable("TITLE",translate('Monitoring'));
$conttp->parse("header");
$conttp->show("header");
$conttp->setVariable("DESC",translate('To define host and service supervisions as well as host and service groups.'));
$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');
$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) {
$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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_host` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
$strAccess = $myVisClass->getAccGroups('read');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=8")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_host` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_service` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=9")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_service` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostgroup` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=10")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hostgroup` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicegroup` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=11")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_servicegroup` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hosttemplate` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=12")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hosttemplate` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicetemplate` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=13")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_servicetemplate` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
$conttp->parse('statistics');
$conttp->parse('main');
$conttp->show('main');
$conttp->parse("statistics");
$conttp->parse("main");
$conttp->show("main");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,60 +5,55 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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) $
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.2.0
// Revision : $LastChangedRevision: 1257 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preContent = "admin/mutdialog.tpl.htm";
//
// 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);
$chkObject = isset($_GET['object']) ? htmlspecialchars($_GET['object'], ENT_QUOTES, 'utf-8') : "";
$intExclude = isset($_GET['exclude']) ? htmlspecialchars($_GET['exclude'], ENT_QUOTES, 'utf-8') : 0;
//
// Include preprocessing file
// ==========================
$preAccess = 1;
$preFieldvars = 1;
$preNoMain = 1;
require $preBasePath.'functions/prepend_adm.php';
require("../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');
$conttp->setVariable("BASE_PATH",$_SESSION['SETS']['path']['base_url']);
$conttp->setVariable("OPENER_FIELD",$chkObject);
$conttp->parse("header");
$conttp->show("header");
//
// Form
// ====
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
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('AVAILABLE', translate('Available'));
$conttp->setVariable('SELECTED', translate('Selected'));
$conttp->setVariable("OPENER_FIELD",$chkObject);
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
$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)) {
$conttp->setVariable('DISABLE_HTML_BEGIN', '<!--');
$conttp->setVariable('DISABLE_HTML_END', '-->');
$conttp->setVariable("DISABLE_HTML_BEGIN","<!--");
$conttp->setVariable("DISABLE_HTML_END","-->");
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
$conttp->parse("datainsert");
$conttp->show("datainsert");
?>

View File

@@ -5,161 +5,149 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-07 10:38:34 +0100 (Wed, 07 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1275 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preFieldvars = 1;
$intRemoveTmp = 0;
$strConfig = '';
$prePageId = 28;
$preContent = "admin/nagioscfg.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
$intRemoveTmp = 0;
$strConfig = "";
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Get configuration set ID
// ========================
$myConfigClass->getConfigTargets($arrConfigSet);
$arrConfigSet = $myConfigClass->getConfigSets();
$intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strBaseDir);
$myConfigClass->getConfigValues($intConfigId, 'conffile', $strConfigfile);
$strLocalBackup = $strConfigfile. '_old_' .date('YmdHis');
$myConfigClass->getConfigData($intConfigId,"method",$intMethod);
$myConfigClass->getConfigData($intConfigId,"nagiosbasedir",$strBaseDir);
$myConfigClass->getConfigData($intConfigId,"conffile",$strConfigfile);
$strLocalBackup = $strConfigfile."_old_".date("YmdHis",mktime());
//
// Convert Windows to UNIX
// Convert Windows to UNIX
// =======================
$chkTaFileText = str_replace("\r\n", "\n", $chkTaFileText);
$chkTaFileText = str_replace("\r\n","\n",$chkTaFileText);
//
// Process data
// ============
if (($chkTaFileText != '') && ($arrConfigSet[0] != 0)) {
if ($intMethod == 1) {
if (file_exists($strBaseDir) && (is_writable($strBaseDir) && is_writable($strConfigfile))) {
// Backup config file
$intReturn = $myConfigClass->moveFile('nagiosbasic', basename($strConfigfile), $intConfigId);
if ($intReturn == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
// 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);
} else {
$myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the '
. 'permissions)!'), $strErrorMessage);
$myDataClass->writeLog(translate('Configuration write failed:'). ' ' .$strConfigfile);
}
} elseif (($intMethod == 2) || ($intMethod == 3)) {
// Backup config file
$intReturn1 = $myConfigClass->moveFile('nagiosbasic', basename($strConfigfile), $intConfigId);
if ($intReturn1 == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
// 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
$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);
} 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);
}
}
} 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);
if ($chkTaFileText != "") {
if ($intMethod == 1) {
if (file_exists($strBaseDir) && (is_writable($strBaseDir) && (is_writable($strConfigfile)))) {
// Backup config file
$intReturn = $myConfigClass->moveFile("nagiosbasic",basename($strConfigfile),$intConfigId);
if ($intReturn == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
}
// Write configuration
$resFile = fopen($strConfigfile,"w");
fputs($resFile,$chkTaFileText);
fclose($resFile);
$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);
}
} else if (($intMethod == 2) || ($intMethod == 3)) {
// Backup config file
$intReturn = $myConfigClass->moveFile("nagiosbasic",basename($strConfigfile),$intConfigId);
if ($intReturn == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
}
// Write file to temporary
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_conf');
$resFile = fopen($strFileName,"w");
fputs($resFile,$chkTaFileText);
fclose($resFile);
// Copy configuration to remoty system
$intReturn = $myConfigClass->configCopy($strConfigfile,$intConfigId,$strFileName,1);
if ($intReturn == 0) {
$myVisClass->processMessage("<span style=\"color:green\">".translate('Configuration file successfully written!')."</span>",$strInfoMessage);
$myDataClass->writeLog(translate('Configuration successfully written:')." ".$strConfigfile);
unlink($strFileName);
} 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);
}
}
}
//
// 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');
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
$conttp->setVariable("TITLE",translate('Nagios main configuration file'));
$conttp->parse("header");
$conttp->show("header");
//
// Include input form
// ===================
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
$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) {
if (file_exists($strConfigfile) && is_readable($strConfigfile)) {
$resFile = fopen($strConfigfile, 'rb');
if ($resFile) {
while (!feof($resFile)) {
$strConfig .= fgets($resFile, 1024);
}
}
} else {
$myVisClass->processMessage(translate('Cannot open the data file (check the permissions)!'), $strErrorMessage);
}
} 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) {
$resFile = fopen($strFileName, 'rb');
if (is_resource($resFile)) {
while (!feof($resFile)) {
$strConfig .= fgets($resFile, 1024);
}
unlink($strFileName);
} else {
$myVisClass->processMessage(translate('Cannot open the temporary file'), $strErrorMessage);
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
$myDataClass->writeLog(translate('Configuration read failed (remote):'). ' ' .$strErrorMessage);
if (file_exists($strFileName)) {
unlink($strFileName);
}
}
if (file_exists($strConfigfile) && is_readable($strConfigfile)) {
$resFile = fopen($strConfigfile,"r");
if ($resFile) {
while(!feof($resFile)) {
$strConfig .= fgets($resFile,1024);
}
}
} else {
$myVisClass->processMessage(translate('Cannot open the data file (check the permissions)!'),$strErrorMessage);
}
} else if (($intMethod == 2) || ($intMethod == 3)) {
// Write file to temporary
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_conf');
// Copy configuration from remoty system
$intReturn = $myConfigClass->configCopy($strConfigfile,$intConfigId,$strFileName,0);
if ($intReturn == 0) {
$resFile = fopen($strFileName,"r");
if (is_resource($resFile)) {
while(!feof($resFile)) {
$strConfig .= fgets($resFile,1024);
}
unlink($strFileName);
} else {
$myVisClass->processMessage(translate('Cannot open the temporary file'),$strErrorMessage);
}
} else {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
$myDataClass->writeLog(translate('Configuration read failed (remote):')." ".$strErrorMessage);
if (file_exists($strFileName)) unlink($strFileName);
}
}
$conttp->setVariable('DAT_NAGIOS_CONFIG', $strConfig);
if ($strErrorMessage != '') {
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
$conttp->setVariable("DAT_NAGIOS_CONFIG",$strConfig);
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage);
$conttp->setVariable("INFOMESSAGE",$strInfoMessage);
// 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');
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
$conttp->parse("naginsert");
$conttp->show("naginsert");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,84 +5,71 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1257 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preShowHeader = 0;
$prePageId = 31;
$preContent = "admin/admin_master.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
$preShowHeader = 0;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../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) {
$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
$strSQLUpdate = "UPDATE `tbl_user` SET `password`=MD5('$chkTfValue2'), `last_login`=NOW() "
. "WHERE `username`='".$_SESSION['username']."'";
$booReturn = $myDBClass->insertData($strSQLUpdate);
if ($booReturn == true) {
$myDataClass->writeLog(translate('Password successfully modified'));
// 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');
} else {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
} else {
// New password wrong
$myVisClass->processMessage(
translate('Password too short or password fields do not match!'),
$strErrorMessage
);
}
} else {
// Old password wrong
$myVisClass->processMessage(translate('The old password is invalid'), $strErrorMessage);
}
} elseif (filter_input(INPUT_POST, 'submit')) {
// Wrong data
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
if (($chkTfValue1 != "") && ($chkTfValue2 != "")) {
// Check old password
$strSQL = "SELECT * FROM `tbl_user` WHERE `username`='".$_SESSION['username']."' AND `password`=MD5('$chkTfValue1')";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else if ($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']."'";
$booReturn = $myDBClass->insertData($strSQLUpdate);
if ($booReturn == true) {
$myDataClass->writeLog(translate('Password successfully modified'));
// Force new login
$_SESSION['logged_in'] = 0;
$_SESSION['username'] = "";
$_SESSION['userid'] = 0;
$_SESSION['groupadm'] = 0;
$_SESSION['domain'] = 0;
header("Location: ".$SETS['path']['protocol']."://".$_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
$myVisClass->processMessage(translate('Password too short or password fields unequally!'),$strErrorMessage);
}
} else {
// Old password wrong
$myVisClass->processMessage(translate('Old password is wrong'),$strErrorMessage);
}
} else if (isset($_POST['submit'])) {
// Wrong data
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
//
// Output header variable
@@ -91,29 +78,25 @@ echo $tplHeaderVar;
//
// Include content
// ===============
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
foreach($arrDescription AS $elem) {
$conttp->setVariable($elem['name'],$elem['string']);
}
$conttp->setVariable('LANG_SAVE', translate('Save'));
$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 != '') {
$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/');
$conttp->setVariable("LANG_SAVE",translate('Save'));
$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 are not equal!'));
$conttp->setVariable("FILL_NEW_PWDSHORT",translate('The new password is too short - use at least 6 characters!'));
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage);
$conttp->setVariable("ACTION_INSERT",filter_var($_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('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('passwordsite');
$conttp->show('passwordsite');
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
$conttp->parse("passwordsite");
$conttp->show("passwordsite");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

File diff suppressed because it is too large Load Diff

View File

@@ -5,611 +5,322 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'serviceescalation';
$preTableName = 'tbl_serviceescalation';
$preKeyField = 'config_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 23;
$preContent = "admin/serviceescalations.tpl.htm";
$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';
require("../functions/prepend_adm.php");
require("../functions/prepend_content.php");
//
// Data processing
// ===============
$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d, 0, -1);
//
$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;
} else {
$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')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Service escalation modified:'). ' ' .$chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToHost',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToHostgroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToService',
$chkDataId,
$chkMselValue3
);
}
if (isset($intRet3) && ($intRet3 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToContact',
$chkDataId,
$chkMselValue4
);
}
if (isset($intRet4) && ($intRet4 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue5 != 0) {
$intRet5 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToContactgroup',
$chkDataId,
$chkMselValue5
);
}
if (isset($intRet5) && ($intRet5 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue6 != 0) {
$intRet6 = $myDataClass->dataInsertRelation(
'tbl_lnkServiceescalationToServicegroup',
$chkDataId,
$chkMselValue6
);
}
if (isset($intRet6) && ($intRet6 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToHost',
$chkDataId,
$chkMselValue1
);
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkServiceescalationToHost', $chkDataId);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToHostgroup',
$chkDataId,
$chkMselValue2
);
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkServiceescalationToHostgroup', $chkDataId);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToService',
$chkDataId,
$chkMselValue3
);
} else {
$intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkServiceescalationToService', $chkDataId);
}
if (isset($intRet3) && ($intRet3 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToContact',
$chkDataId,
$chkMselValue4
);
} else {
$intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkServiceescalationToContact', $chkDataId);
}
if (isset($intRet4) && ($intRet4 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue5 != 0) {
$intRet5 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToContactgroup',
$chkDataId,
$chkMselValue5
);
} else {
$intRet5 = $myDataClass->dataDeleteRelation(
'tbl_lnkServiceescalationToContactgroup',
$chkDataId
);
}
if (isset($intRet5) && ($intRet5 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue6 != 0) {
$intRet6 = $myDataClass->dataUpdateRelation(
'tbl_lnkServiceescalationToServicegroup',
$chkDataId,
$chkMselValue6
);
} else {
$intRet6 = $myDataClass->dataDeleteRelation(
'tbl_lnkServiceescalationToServicegroup',
$chkDataId
);
}
if (isset($intRet6) && ($intRet6 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6) != 0) {
$strInfoMessage = '';
}
//
// Update Import HASH
// ==================
$booReturn = $myDataClass->updateHash($preTableName, $chkDataId);
if ($booReturn != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if (($chkModus != 'add') && ($chkModus != 'refresh')) {
$chkModus = 'display';
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;
} else {
$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")) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Service escalation modified:')." ".$chkTfValue1);
//
// Insert/update relations
// =======================
if ($chkModus == "insert") {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToHost",$chkDataId,$chkMselValue1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToHostgroup",$chkDataId,$chkMselValue2);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToService",$chkDataId,$chkMselValue3);
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToContact",$chkDataId,$chkMselValue4);
if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue5 != 0) $intRet5 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToContactgroup",$chkDataId,$chkMselValue5);
if (isset($intRet5) && ($intRet5 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue6 != 0) $intRet6 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToServicegroup",$chkDataId,$chkMselValue6);
if (isset($intRet6) && ($intRet6 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else if ($chkModus == "modify") {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToHost",$chkDataId,$chkMselValue1);
} else {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToHost",$chkDataId);
}
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToHostgroup",$chkDataId,$chkMselValue2);
} else {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToHostgroup",$chkDataId);
}
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue3 != 0) {
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToService",$chkDataId,$chkMselValue3);
} else {
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToService",$chkDataId);
}
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue4 != 0) {
$intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToContact",$chkDataId,$chkMselValue4);
} else {
$intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToContact",$chkDataId);
}
if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue5 != 0) {
$intRet5 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToContactgroup",$chkDataId,$chkMselValue5);
} else {
$intRet5 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToContactgroup",$chkDataId);
}
if (isset($intRet5) && ($intRet5 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue6 != 0) {
$intRet6 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToServicegroup",$chkDataId,$chkMselValue6);
} else {
$intRet6 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToServicegroup",$chkDataId);
}
if (isset($intRet6) && ($intRet6 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6) != 0) $strInfoMessage = "";
//
// Update Import HASH
// ==================
$booReturn = $myDataClass->updateHash($preTableName,$chkDataId);
if ($booReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if (($chkModus != "add") && ($chkModus != "refresh")) $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Define service escalation (serviceescalations.cfg)'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if (($chkModus == 'add') || ($chkModus == 'refresh')) {
$conttp->setVariable('TITLE', translate('Define service escalation (serviceescalations.cfg)'));
// 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;
if (isset($arrModifyData['host_name']) && ($arrModifyData['host_name'] > 0)) {
$arrTemp = array();
$strSQL = 'SELECT `idSlave`, `exclude` '
. 'FROM `tbl_lnkServiceescalationToHost` WHERE `idMaster` = ' .$arrModifyData['id'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($booReturn == false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDC != 0) {
foreach ($arrData as $elem) {
if ($elem['exclude'] == 1) {
$arrTemp[] = 'e' .$elem['idSlave'];
} else {
$arrTemp[] = $elem['idSlave'];
}
}
}
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'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($booReturn == false) {
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
if ($intDC != 0) {
foreach ($arrData as $elem) {
if ($elem['exclude'] == 1) {
$arrTemp[] = 'e' .$elem['idSlave'];
} else {
$arrTemp[] = $elem['idSlave'];
}
}
}
if ($arrModifyData['hostgroup_name'] == 2) {
$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)) {
$strRefresh = 'se_host';
} else {
$strRefresh = '';
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_host',
'host_name',
'host',
'tbl_lnkServiceescalationToHost',
2,
$intFieldId,
-9,
$strRefresh
);
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)) {
$strRefresh = 'se_hostgroup';
} else {
$strRefresh = '';
}
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
'hostgroup',
'tbl_lnkServiceescalationToHostgroup',
2,
$intFieldId,
-9,
$strRefresh
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
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') {
$intFieldId = $chkSelValue1;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'timeperiod', 1, $intFieldId);
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)) {
$strRefresh = 'se_contact';
} else {
$strRefresh = '';
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_contact',
'contact_name',
'contact',
'tbl_lnkServiceescalationToContact',
2,
$intFieldId,
-9,
$strRefresh
);
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)) {
$strRefresh = 'se_contactgroup';
} else {
$strRefresh = '';
}
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
'contactgroup',
'tbl_lnkServiceescalationToContactgroup',
2,
$intFieldId,
-9,
$strRefresh
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
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)) {
$strRefresh = 'se_service';
} else {
$strRefresh = '';
}
$intReturn = $myVisClass->parseSelectMulti(
'tbl_service',
'service_description',
'service',
'tbl_lnkServiceescalationToService',
2,
$intFieldId,
-9,
$strRefresh
);
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)) {
$strRefresh = 'se_servicegroup';
} else {
$strRefresh = '';
}
$intReturn = $myVisClass->parseSelectMulti(
'tbl_servicegroup',
'servicegroup_name',
'servicegroup',
'tbl_lnkServiceescalationToServicegroup',
0,
$intFieldId,
-9,
$strRefresh
);
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') {
$intFieldId = $chkSelAccGr;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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') {
$conttp->setVariable('DAT_FIRST_NOTIFICATION', $chkTfNullVal1);
}
if ($chkTfNullVal2 != 'NULL') {
$conttp->setVariable('DAT_LAST_NOTIFICATION', $chkTfNullVal2);
}
if ($chkTfNullVal3 != 'NULL') {
$conttp->setVariable('DAT_NOTIFICATION_INTERVAL', $chkTfNullVal3);
}
if ($chkTfValue1 != '') {
$conttp->setVariable('DAT_CONFIG_NAME', $chkTfValue1);
}
foreach (explode(',', $strEO) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
}
if ($chkActive != 1) {
$conttp->setVariable('ACT_CHECKED', '');
}
if ($chkRegister != 1) {
$conttp->setVariable('REG_CHECKED', '');
}
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
$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
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
// Process option fields
foreach (explode(',', $arrModifyData['escalation_options']) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if (($chkModus == "add") || ($chkModus == "refresh")) {
// 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;
} 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;
if (isset($arrModifyData['host_name']) && ($arrModifyData['host_name'] > 0 )){
$arrTemp = array();
$strSQL = "SELECT `idSlave`, `exclude` FROM `tbl_lnkServiceescalationToHost` WHERE `idMaster` = ".$arrModifyData['id'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDC);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($intDC != 0) {
foreach ($arrData AS $elem) {
if ($elem['exclude'] == 1) {
$arrTemp[] = "e".$elem['idSlave'];
} else {
$arrTemp[] = $elem['idSlave'];
}
}
}
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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDC);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($intDC != 0) {
foreach ($arrData AS $elem) {
if ($elem['exclude'] == 1) {
$arrTemp[] = "e".$elem['idSlave'];
} else {
$arrTemp[] = $elem['idSlave'];
}
}
}
if ($arrModifyData['hostgroup_name'] == 2) $arrTemp[] = '*';
$_SESSION['refresh']['se_hostgroup'] = $arrTemp;
}
}
// Process host selection field
if (isset($arrModifyData['host_name'])) {$intFieldId = $arrModifyData['host_name'];} else {$intFieldId = 0;}
if (($chkModus == "refresh") && (count($chkMselValue1) != 0)) {$strRefresh = 'se_host';} else {$strRefresh = '';}
$intReturn1 = $myVisClass->parseSelectMulti('tbl_host','host_name','host','tbl_lnkServiceescalationToHost',2,$intFieldId,-9,$strRefresh);
if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['hostgroup_name'])) {$intFieldId = $arrModifyData['hostgroup_name'];} else {$intFieldId = 0;}
if (($chkModus == "refresh") && (count($chkMselValue2) != 0)) {$strRefresh = 'se_hostgroup';} else {$strRefresh = '';}
$intReturn2 = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','hostgroup','tbl_lnkServiceescalationToHostgroup',2,$intFieldId,-9,$strRefresh);
if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
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") $intFieldId = $chkSelValue1;
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','timeperiod',1,$intFieldId);
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") && (count($chkMselValue4) != 0)) {$strRefresh = 'se_contact';} else {$strRefresh = '';}
$intReturn1 = $myVisClass->parseSelectMulti('tbl_contact','contact_name','contact','tbl_lnkServiceescalationToContact',2,$intFieldId,-9,$strRefresh);
if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (isset($arrModifyData['contact_groups'])) {$intFieldId = $arrModifyData['contact_groups'];} else {$intFieldId = 0;}
if (($chkModus == "refresh") && (count($chkMselValue5) != 0)) {$strRefresh = 'se_contactgroup';} else {$strRefresh = '';}
$intReturn2 = $myVisClass->parseSelectMulti('tbl_contactgroup','contactgroup_name','contactgroup','tbl_lnkServiceescalationToContactgroup',2,$intFieldId,-9,$strRefresh);
if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
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") && (count($chkMselValue3) != 0)) {$strRefresh = 'se_service';} else {$strRefresh = '';}
$intReturn = $myVisClass->parseSelectMulti('tbl_service','service_description','service','tbl_lnkServiceescalationToService',2,$intFieldId,-9,$strRefresh);
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") && (count($chkMselValue6) != 0)) {$strRefresh = 'se_servicegroup';} else {$strRefresh = '';}
$intReturn = $myVisClass->parseSelectMulti('tbl_servicegroup','servicegroup_name','servicegroup','tbl_lnkServiceescalationToServicegroup',0,$intFieldId,-9,$strRefresh);
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") $intFieldId = $chkSelAccGr;
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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") $conttp->setVariable("DAT_FIRST_NOTIFICATION",$chkTfNullVal1);
if ($chkTfNullVal2 != "NULL") $conttp->setVariable("DAT_LAST_NOTIFICATION",$chkTfNullVal2);
if ($chkTfNullVal3 != "NULL") $conttp->setVariable("DAT_NOTIFICATION_INTERVAL",$chkTfNullVal3);
if ($chkTfValue1 != "") $conttp->setVariable("DAT_CONFIG_NAME",$chkTfValue1);
foreach(explode(",",$strEO) AS $elem) {
$conttp->setVariable("DAT_EO".strtoupper($elem)."_CHECKED","checked");
}
if ($chkActive != 1) $conttp->setVariable("ACT_CHECKED","");
if ($chkRegister != 1) $conttp->setVariable("REG_CHECKED","");
if ($chkDataId != 0) {
$conttp->setVariable("MODUS","modify");
$conttp->setVariable("DAT_ID",$chkDataId);
}
// Insert data from database in "modify" mode
} else 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
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
// Process option fields
foreach(explode(",",$arrModifyData['escalation_options']) AS $elem) {
$conttp->setVariable("DAT_EO".strtoupper($elem)."_CHECKED","checked");
}
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// 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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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` "
. "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$chkLimit = 0;
}
}
// 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'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData(
$mastertp,
$arrDataLines,
$intDataCount,
$intLineCount,
$preKeyField,
'process_field',
40
);
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $chkLimit = 0;
}
// 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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'process_field',40);
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,275 +5,199 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'serviceextinfo';
$preTableName = 'tbl_serviceextinfo';
$preKeyField = 'host_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 24;
$preContent = "admin/serviceextinfo.tpl.htm";
$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';
//
require("../functions/prepend_adm.php");
require("../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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkSelValue1 != 0) && ($chkSelValue2 != 0)) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Service extended information modified:'). ' ' .$chkSelValue1.
'::' .$chkSelValue2);
}
//
// Update Import HASH
// ==================
$booReturn = $myDataClass->updateHash($preTableName, $chkDataId);
if ($booReturn != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if (($chkModus != 'add') && ($chkModus != 'refresh')) {
$chkModus = 'display';
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;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if (($chkSelValue1 != 0) && ($chkSelValue2 != 0)) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Service extended information modified:')." ".$chkSelValue1."::".$chkSelValue2);
//
// Update Import HASH
// ==================
$booReturn = $myDataClass->updateHash($preTableName,$chkDataId);
if ($booReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if (($chkModus != "add") && ($chkModus != "refresh")) $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Define service extended information (serviceextinfo.cfg)'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if (($chkModus == 'add') || ($chkModus == 'refresh')) {
$conttp->setVariable('TITLE', translate('Define service extended information (serviceextinfo.cfg)'));
// 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) {
$_SESSION['refresh']['se_host'] = $arrData[0][$preKeyField];
}
} else {
$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) {
$_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)) {
$intFieldId = $chkSelValue1;
}
$intReturn1 = $myVisClass->parseSelectSimple('tbl_host', $preKeyField, 'host', 0, $intFieldId);
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;
}
$intReturn1 = $myVisClass->parseSelectSimple(
'tbl_service',
'service_description',
'service_extinfo',
0,
$intFieldId
);
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;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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') {
$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 ($chkRegister != 1) {
$conttp->setVariable('REG_CHECKED', '');
}
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
$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
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if (($chkModus == "add") || ($chkModus == "refresh")) {
// Do not show modified time list
$intNoTime = 1;
// Refresh mode
if ($chkModus == "refresh") {
$_SESSION['refresh']['se_host'] = $chkSelValue1;
} else {
$_SESSION['refresh']['se_host'] = $chkSelValue1;
if (isset($arrModifyData[$preKeyField]) && ($arrModifyData[$preKeyField] != 0 )){
$strSQL = "SELECT `$preKeyField` FROM `$preTableName` WHERE `id` = ".$arrModifyData['id'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDC);
if ($intDC != 0) {
$_SESSION['refresh']['se_host'] = $arrData[0][$preKeyField];
}
} else {
$strSQL = "SELECT `id` FROM `tbl_host` WHERE `active`='1' AND `config_id`=$chkDomainId ORDER BY `$preKeyField`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDC);
if ($intDC != 0) {
$_SESSION['refresh']['se_host'] = $arrData[0]['id'];
}
}
}
// Process host selection field
if (isset($arrModifyData[$preKeyField])) {$intFieldId = $arrModifyData[$preKeyField];} else {$intFieldId = 0;}
if (($chkModus == "refresh") && ($chkSelValue1 != 0)) $intFieldId = $chkSelValue1;
$intReturn1 = $myVisClass->parseSelectSimple('tbl_host',$preKeyField,'host',0,$intFieldId);
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;}
$intReturn1 = $myVisClass->parseSelectSimple('tbl_service','service_description','service_extinfo',0,$intFieldId);
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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") {
$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 ($chkRegister != 1) $conttp->setVariable("REG_CHECKED","");
if ($chkDataId != 0) {
$conttp->setVariable("MODUS","modify");
$conttp->setVariable("DAT_ID",$chkDataId);
}
// Insert data from database in "modify" mode
} else 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
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// 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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `$preTableName`.`config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
$strOrderString = "ORDER BY `$preTableName`.`config_id`, `tbl_service`.`service_description` $hidSortDir";
}
// Count datasets
$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) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$chkLimit = 0;
}
}
// 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'];
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData(
$mastertp,
$arrDataLines,
$intDataCount,
$intLineCount,
$preKeyField,
'service_description'
);
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `$preTableName`.`config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) $strOrderString = "ORDER BY `$preTableName`.`config_id`, `tbl_service`.`service_description` $hidSortDir";
// Count datasets
$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->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'));
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intCount = (int)$arrDataLinesCount['number'];
if ($intCount < $chkLimit) $chkLimit = 0;
}
// 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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'));
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'service_description');
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,277 +5,179 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'servicegroup';
$preTableName = 'tbl_servicegroup';
$preKeyField = 'servicegroup_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 11;
$preContent = "admin/servicegroups.tpl.htm";
$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';
//
require("../functions/prepend_adm.php");
require("../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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($intMselValue1 != 0) || ($intVersion >= 3))) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Service group modified:'). ' ' .$chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkServicegroupToService',
$chkDataId,
$chkMselValue1,
1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkServicegroupToServicegroup',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicegroupToService',
$chkDataId,
$chkMselValue1,
1
);
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkServicegroupToService', $chkDataId);
}
if ($intRet1 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkServicegroupToServicegroup',
$chkDataId,
$chkMselValue2
);
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkServicegroupToServicegroup', $chkDataId);
}
if ($intRet2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2) != 0) {
$strInfoMessage = '';
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
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;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != "") && ($chkTfValue2 != "") && (($intMselValue1 != 0) || ($intVersion == 3))) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Service group modified:')." ".$chkTfValue1);
//
// Insert/update relations
// =======================
if ($chkModus == "insert") {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkServicegroupToService",$chkDataId,$chkMselValue1,1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkServicegroupToServicegroup",$chkDataId,$chkMselValue2);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else if ($chkModus == "modify") {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkServicegroupToService",$chkDataId,$chkMselValue1,1);
} else {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkServicegroupToService",$chkDataId);
}
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkServicegroupToServicegroup",$chkDataId,$chkMselValue2);
} else {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkServicegroupToServicegroup",$chkDataId);
}
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (($intRet1 + $intRet2) != 0) $strInfoMessage = "";
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Define service groups (servicegroups.cfg)'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
$conttp->setVariable('TITLE', translate('Define service groups (servicegroups.cfg)'));
// Do not show modified time list
$intNoTime = 1;
// Process service selection field
if (isset($arrModifyData['members'])) {
$intFieldId = $arrModifyData['members'];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_service',
'service_description',
'service_members',
'tbl_lnkServicegroupToService',
0,
$intFieldId
);
if ($intReturn1 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
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;
}
$intReturn2 = $myVisClass->parseSelectMulti(
$preTableName,
$preKeyField,
'servicegroups',
'tbl_lnkServicegroupToServicegroup',
0,
$intFieldId,
$chkListId
);
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;
}
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Do not show modified time list
$intNoTime = 1;
// Process service selection field
$intReturn = 0;
if (isset($arrModifyData['members'])) {$intFieldId = $arrModifyData['members'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti('tbl_service','service_description','service_members','tbl_lnkServicegroupToService',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
if (($intReturn != 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;}
$intReturn = $myVisClass->parseSelectMulti($preTableName,$preKeyField,'servicegroups','tbl_lnkServicegroupToServicegroup',0,$intFieldId,$chkListId);
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;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
}
$conttp->parse("datainsert");
$conttp->show("datainsert");
}
//
// 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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL1, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$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'];
$booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias');
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$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

@@ -5,325 +5,257 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preFieldvars = 1;
$arrSQL = array();
$prePageId = 38;
$preContent = "admin/settings.tpl.htm";
$preAccess = 1;
$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
require("../functions/prepend_adm.php");
require("../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, 'tfValue3') == null) {
$chkTfValue3 = $SETS['db']['server'];
}
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, 'tfValue6') == null) {
$chkTfValue6 = $SETS['db']['username'];
}
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, 'tfValue9') == null) {
$chkTfValue9 = $SETS['common']['pagelines'];
}
if (filter_input(INPUT_POST, 'tfValue10') == null) {
$chkTfValue10 = $SETS['network']['proxyserver'];
}
if (filter_input(INPUT_POST, 'tfValue11') == null) {
$chkTfValue11 = $SETS['network']['proxyuser'];
}
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, 'selValue4') == null) {
$chkSelValue4 = $SETS['common']['seldisable'];
}
if (filter_input(INPUT_POST, 'radValue1') == null) {
$chkRadValue1 = $SETS['common']['tplcheck'];
}
if (filter_input(INPUT_POST, 'radValue2') == null) {
$chkRadValue2 = $SETS['common']['updcheck'];
}
if (filter_input(INPUT_POST, 'radValue3') == null) {
$chkRadValue3 = $SETS['network']['proxy'];
}
if (!isset($_POST['tfValue1'])) $chkTfValue1 = $SETS['path']['tempdir'];
if (!isset($_POST['tfValue2'])) $chkTfValue2 = $SETS['data']['encoding'];
if (!isset($_POST['tfValue3'])) $chkTfValue3 = $SETS['db']['server'];
if (!isset($_POST['tfValue4'])) $chkTfValue4 = $SETS['db']['port'];
if (!isset($_POST['tfValue5'])) $chkTfValue5 = $SETS['db']['database'];
if (!isset($_POST['tfValue6'])) $chkTfValue6 = $SETS['db']['username'];
if (!isset($_POST['tfValue7'])) $chkTfValue7 = $SETS['db']['password'];
if (!isset($_POST['tfValue8'])) $chkTfValue8 = $SETS['security']['logofftime'];
if (!isset($_POST['tfValue9'])) $chkTfValue9 = $SETS['common']['pagelines'];
if (!isset($_POST['tfValue10'])) $chkTfValue10 = $SETS['network']['proxyserver'];
if (!isset($_POST['tfValue11'])) $chkTfValue11 = $SETS['network']['proxyuser'];
if (!isset($_POST['tfValue12'])) $chkTfValue12 = $SETS['network']['proxypasswd'];
if (!isset($_POST['selValue3'])) $chkSelValue3 = $SETS['security']['wsauth'];
if (!isset($_POST['selValue4'])) $chkSelValue4 = $SETS['common']['seldisable'];
if (!isset($_POST['radValue1'])) $chkRadValue1 = $SETS['common']['tplcheck'];
if (!isset($_POST['radValue2'])) $chkRadValue2 = $SETS['common']['updcheck'];
if (!isset($_POST['radValue3'])) $chkRadValue3 = $SETS['network']['proxy'];
//
// Save changes
// ============
if (filter_input(INPUT_POST, 'selValue1')) {
//
// 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 = 'en_GB';
}
$SETS['path']['protocol'] = $strProtocol;
$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
$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');
foreach ($arrSQL as $elem) {
$booReturn = $myDBClass->insertData($elem);
if ($booReturn == false) {
$myVisClass->processMessage(
translate('An error occured while writing settings to database:'),
$strErrorMessage
);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
}
// 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");
fwrite($filSettings, "?>\n");
fwrite($filSettings, ";///////////////////////////////////////////////////////////////////////////////\n");
fwrite($filSettings, ";\n");
fwrite($filSettings, "; NagiosQL\n");
fwrite($filSettings, ";\n");
fwrite($filSettings, ";///////////////////////////////////////////////////////////////////////////////\n");
fwrite($filSettings, ";\n");
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, ";\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, "[path]\n");
fwrite($filSettings, 'base_url = ' .$preRelPath."\n");
fwrite($filSettings, 'base_path = ' .$preBasePath."\n");
fclose($filSettings);
// Activate new language settings
$arrLocale = explode('.', $strLocale);
$strDomain = $arrLocale[0];
$loc = setlocale(
LC_ALL,
$strLocale,
$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);
}
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);
}
} else {
$myVisClass->processMessage($preBasePath. 'config/settings.php ' .translate('is not writeable, please '
. 'check permissions!'), $strErrorMessage);
}
if (isset($_POST) && isset($_POST['selValue1'])) {
//
// 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 = "en_GB";
// 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
$strBaseURL = str_replace("admin/settings.php","",$_SERVER["PHP_SELF"]);
$strBasePath = substr(realpath('.'),0,-5);
$arrSQL = "";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$strProtocol."' WHERE `category` = 'path' AND `name`='protocol'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue1."' WHERE `category` = 'path' AND `name`='tempdir'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$strBaseURL."' WHERE `category` = 'path' AND `name`='base_url'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$strBasePath."' WHERE `category` = 'path' AND `name`='base_path'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$strLocale."' WHERE `category` = 'data' AND `name`='locale'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue2."' WHERE `category` = 'data' AND `name`='encoding'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue8."' WHERE `category` = 'security' AND `name`='logofftime'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkSelValue3."' WHERE `category` = 'security' AND `name`='wsauth'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue9."' WHERE `category` = 'common' AND `name`='pagelines'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkSelValue4."' WHERE `category` = 'common' AND `name`='seldisable'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkRadValue1."' WHERE `category` = 'common' AND `name`='tplcheck'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkRadValue2."' WHERE `category` = 'common' AND `name`='updcheck'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkRadValue3."' WHERE `category` = 'network' AND `name`='proxy'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue10."' WHERE `category` = 'network' AND `name`='proxyserver'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue11."' WHERE `category` = 'network' AND `name`='proxyuser'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue12."' WHERE `category` = 'network' AND `name`='proxypasswd'";
foreach ($arrSQL AS $elem) {
$booReturn = $myDBClass->insertData($elem);
if ($booReturn == false) {
$myVisClass->processMessage(translate('An error occured while writing settings to database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
}
// Write db settings to file
if (is_writable($strBasePath."config/settings.php")) {
$filSettings = fopen($strBasePath."config/settings.php","w");
if ($filSettings) {
fwrite($filSettings,"<?php\n");
fwrite($filSettings,"exit;\n");
fwrite($filSettings,"?>\n");
fwrite($filSettings,";///////////////////////////////////////////////////////////////////////////////\n");
fwrite($filSettings,";\n");
fwrite($filSettings,"; NagiosQL\n");
fwrite($filSettings,";\n");
fwrite($filSettings,";///////////////////////////////////////////////////////////////////////////////\n");
fwrite($filSettings,";\n");
fwrite($filSettings,"; Project : NagiosQL\n");
fwrite($filSettings,"; Component: Database Configuration\n");
fwrite($filSettings,"; Website : http://www.nagiosql.org\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,"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 = ".$strBaseURL."\n");
fwrite($filSettings,"base_path = ".$strBasePath."\n");
fclose($filSettings);
// Activate new language settings
$arrLocale = explode(".",$strLocale);
$strDomain = $arrLocale[0];
$loc = setlocale(LC_ALL, $strLocale, $strLocale.".utf-8", $strLocale.".utf-8", $strLocale.".utf8", "en_GB", "en_GB.utf-8", "en_GB.utf8");
if (!isset($loc)) {
$myVisClass->processMessage(translate("Error in setting the correct locale, please report this error with the associated output of 'locale -a'"),$strErrorMessage);
}
putenv("LC_ALL=".$strLocale.".utf-8");
putenv("LANG=".$strLocale.".utf-8");
bindtextdomain($strLocale, $strBasePath."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);
}
} else {
$myVisClass->processMessage($strBasePath."config/settings.php ".translate("is not writeable, please check permissions!"),$strErrorMessage);
}
}
//
// Start content
// =============
$conttp->setVariable('TITLE', translate('Configure Settings'));
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
$conttp->setVariable("TITLE",translate('Configure Settings'));
$conttp->parse("header");
$conttp->show("header");
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('LANG_DESCRIPTION', translate('Change your current NagiosQL settings (e.g. Database user, '
. 'Language).'));
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
$conttp->setVariable("LANG_DESCRIPTION",translate('Change your current NagiosQL settings (e.g. Database user, 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');
$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('DATA', translate('Language'));
$conttp->setVariable('LOCALE', translate('Language'));
$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`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
$strSQL = "SELECT * FROM `tbl_language` WHERE `active`='1' ORDER BY `id`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
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']) {
$conttp->setVariable('LANGUAGE_SELECTED', 'selected');
}
$conttp->parse('language');
}
foreach($arrData AS $elem) {
$conttp->setVariable("LANGUAGE_ID",$elem['id']);
$conttp->setVariable("LANGUAGE_NAME",translate($elem['language']));
if ($elem['locale'] == $SETS['data']['locale']) $conttp->setVariable("LANGUAGE_SELECTED","selected");
$conttp->parse("language");
}
} else {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
$conttp->setVariable('ENCODING_NAME', translate('Encoding'));
$conttp->setVariable('ENCODING_VALUE', htmlspecialchars($chkTfValue2, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("ENCODING_NAME",translate('Encoding'));
$conttp->setVariable("ENCODING_VALUE",htmlspecialchars($chkTfValue2, ENT_QUOTES, 'utf-8'));
//
// Database settings
// =================
$conttp->setVariable('DB', translate('Database'));
$conttp->setVariable('SERVER_NAME', translate('MySQL Server'));
$conttp->setVariable('SERVER_VALUE', htmlspecialchars($chkTfValue3, ENT_QUOTES, 'utf-8'));
$conttp->setVariable('SERVER_PORT', translate('MySQL Server Port'));
$conttp->setVariable('PORT_VALUE', htmlspecialchars($chkTfValue4, ENT_QUOTES, 'utf-8'));
$conttp->setVariable('DATABASE_NAME', translate('Database name'));
$conttp->setVariable('DATABASE_VALUE', htmlspecialchars($chkTfValue5, ENT_QUOTES, 'utf-8'));
$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'));
$conttp->setVariable("DB",translate('Database'));
$conttp->setVariable("SERVER_NAME",translate('MySQL Server'));
$conttp->setVariable("SERVER_VALUE",htmlspecialchars($chkTfValue3, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("SERVER_PORT",translate('MySQL Server Port'));
$conttp->setVariable("PORT_VALUE",htmlspecialchars($chkTfValue4, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("DATABASE_NAME",translate('Database name'));
$conttp->setVariable("DATABASE_VALUE",htmlspecialchars($chkTfValue5, ENT_QUOTES, 'utf-8'));
$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
// =================
$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');
$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('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');
$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('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');
$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('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('CLASS_NAME_1', 'elementShow');
}
$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("CLASS_NAME_1","elementShow");
//
// 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('CLASS_NAME_2', 'elementShow');
}
$conttp->setVariable('UPD_PROXY_SERVER', translate('Proxy Address'));
$conttp->setVariable('UPD_PROXY_SERVER_VALUE', htmlspecialchars($chkTfValue10, ENT_QUOTES, 'utf-8'));
$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'));
$conttp->setVariable("UPD_PROXY_CHECK", translate('Proxyserver'));
$conttp->setVariable("UPD_PROXY_".$chkRadValue3."_CHECKED","checked");
if (($chkRadValue3 == 1) && ($chkRadValue2 == 1)) $conttp->setVariable("CLASS_NAME_2","elementShow");
$conttp->setVariable("UPD_PROXY_SERVER", translate('Proxy Address'));
$conttp->setVariable("UPD_PROXY_SERVER_VALUE",htmlspecialchars($chkTfValue10, ENT_QUOTES, 'utf-8'));
$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
// ====================
$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);
$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) {
$conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
$conttp->parse('settingssite');
$conttp->show('settingssite');
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
$conttp->parse("settingssite");
$conttp->show("settingssite");
//
// Footer ausgeben
// ===============
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,108 +5,85 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-08 15:13:31 +0100 (Wed, 08 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1189 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preContent = 'admin/mainpages.htm.tpl';
$prePageId = 5;
$preContent = "admin/mainpages.tpl.htm";
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
require("../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 '.
'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'));
$conttp->setVariable("TITLE",translate('Misc commands'));
$conttp->parse("header");
$conttp->show("header");
$conttp->setVariable("DESC",translate('To 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
$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');
$intAccessGrp21 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=21');
$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) {
$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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostdependency` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
$strAccess = $myVisClass->getAccGroups('read');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=19")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hostdependency` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostescalation` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=20")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hostescalation` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostextinfo` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=21")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hostextinfo` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicedependency` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=22")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_servicedependency` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_serviceescalation` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=23")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_serviceescalation` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
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)"));
$conttp->setVariable('INACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_serviceextinfo` '
. "WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse('statisticrow');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=24")+0,'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)"));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_serviceextinfo` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow");
}
$conttp->parse('statistics');
$conttp->parse('main');
$conttp->show('main');
$conttp->parse("statistics");
$conttp->parse("main");
$conttp->show("main");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

File diff suppressed because it is too large Load Diff

View File

@@ -5,281 +5,245 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-04-05 08:11:59 +0200 (Thu, 05 Apr 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1315 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preAccess = 1;
$preNoMain = 1;
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
require("../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 == '') {
$chkDataId = 0;
}
$chkDataId = isset($_GET['dataId']) ? htmlspecialchars($_GET['dataId'], ENT_QUOTES, 'utf-8') : 0;
$chkMode = isset($_GET['mode']) ? htmlspecialchars($_GET['mode'], ENT_QUOTES, 'utf-8') : "";
$chkKey = isset($_GET['key']) ? htmlspecialchars($_GET['key'], ENT_QUOTES, 'utf-8') : "";
$chkDef = isset($_GET['def']) ? htmlspecialchars($_GET['def'], ENT_QUOTES, 'utf-8') : "";
$chkType = isset($_GET['type']) ? htmlspecialchars($_GET['type'], ENT_QUOTES, 'utf-8') : "";
if ($chkDataId == "") $chkDataId = 0;
if (get_magic_quotes_gpc() == 0) {
$chkDef = addslashes($chkDef);
$chkDef = addslashes($chkDef);
}
$arrDefinition = explode('::', $chkDef);
if ($chkType == '') {
exit;
$arrDefinition = explode("::",$chkDef);
if ($chkType == "") {
exit;
}
if ($chkType == 'host') {
$chkLinkTab = 'tbl_lnkHostToHosttemplate';
$chkPreTab = 'host';
if ($chkType == "host") {
$chkLinkTab = "tbl_lnkHostToHosttemplate";
$chkPreTab = "host";
}
if ($chkType == 'hosttemplate') {
$chkLinkTab = 'tbl_lnkHosttemplateToHosttemplate';
$chkPreTab = 'host';
if ($chkType == "hosttemplate") {
$chkLinkTab = "tbl_lnkHosttemplateToHosttemplate";
$chkPreTab = "host";
}
if ($chkType == 'service') {
$chkLinkTab = 'tbl_lnkServiceToServicetemplate';
$chkPreTab = 'service';
if ($chkType == "service") {
$chkLinkTab = "tbl_lnkServiceToServicetemplate";
$chkPreTab = "service";
}
if ($chkType == 'servicetemplate') {
$chkLinkTab = 'tbl_lnkServicetemplateToServicetemplate';
$chkPreTab = 'service';
if ($chkType == "servicetemplate") {
$chkLinkTab = "tbl_lnkServicetemplateToServicetemplate";
$chkPreTab = "service";
}
if ($chkType == 'contact') {
$chkLinkTab = 'tbl_lnkContactToContacttemplate';
$chkPreTab = 'contact';
if ($chkType == "contact") {
$chkLinkTab = "tbl_lnkContactToContacttemplate";
$chkPreTab = "contact";
}
if ($chkType == 'contacttemplate') {
$chkLinkTab = 'tbl_lnkContacttemplateToContacttemplate';
$chkPreTab = 'contact';
if ($chkType == "contacttemplate") {
$chkLinkTab = "tbl_lnkContacttemplateToContacttemplate";
$chkPreTab = "contact";
}
//
// Get data
// ========
if ($chkLinkTab != '') {
$strSQL = 'SELECT * FROM `' .$chkLinkTab."` WHERE `idMaster` = $chkDataId ORDER BY `idSort`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
//
// Store data to session
// ============================
if ($chkMode == '') {
$_SESSION['templatedefinition'] = array();
$arrTemp = array();
if ($booReturn && ($intDataCount != 0)) {
foreach ($arrDataLines as $elem) {
if ($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'];
} else {
$strSQL2 = 'SELECT `name` FROM `tbl_' .$chkPreTab. '` WHERE `id` = ' .$elem['idSlave'];
$strSQL3 = 'SELECT `active` 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;
$_SESSION['templatedefinition'][] = $arrTemp;
}
}
}
if ($chkLinkTab != "") {
$strSQL = "SELECT * FROM `".$chkLinkTab."` WHERE `idMaster` = $chkDataId ORDER BY `idSort`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
//
// Store data to session
// ============================
if ($chkMode == "") {
$_SESSION['templatedefinition'] = "";
if ($booReturn && ($intDataCount != 0)) {
foreach ($arrDataLines AS $elem) {
if ($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'];
} else {
$strSQL2 = "SELECT `name` FROM `tbl_".$chkPreTab."` WHERE `id` = ".$elem['idSlave'];
$strSQL3 = "SELECT `active` 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'] = $myDBClass->getFieldData($strSQL3)+0;
$arrTemp['status'] = 0;
$_SESSION['templatedefinition'][] = $arrTemp;
}
}
}
}
//
// 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];
} else {
$strSQL2 = 'SELECT `name` FROM `tbl_' .$chkPreTab. '` WHERE `id` = ' .$arrDefinition[0];
$strSQL3 = 'SELECT `active` 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)) {
$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);
$_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);
$_SESSION['templatedefinition'][] = $arrTemp;
}
if ($chkMode == "add") {
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];
} else {
$strSQL2 = "SELECT `name` FROM `tbl_".$chkPreTab."` WHERE `id` = ".$arrDefinition[0];
$strSQL3 = "SELECT `active` 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)) {
$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'] = $myDBClass->getFieldData($strSQL3)+0;
$_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'] = $myDBClass->getFieldData($strSQL3)+0;
$_SESSION['templatedefinition'][] = $arrTemp;
}
}
//
// 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)) {
$_SESSION['templatedefinition'][$key]['status'] = 1;
}
}
if ($chkMode == "del") {
if (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)) {
$_SESSION['templatedefinition'][$key]['status'] = 1;
}
}
}
}
//
// Sort mode
// =========
if ($chkMode == 'sortup') {
$chkKey = (int)$chkKey;
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
(count($_SESSION['templatedefinition']) > 1) && ($chkKey != 0)) {
$arrTemp = array();
$arrWait = array();
$intNow = 0;
foreach ($_SESSION['templatedefinition'] as $key => $elem) {
if ($key != ($chkKey-1)) {
$arrTemp[] = $elem;
if ($intNow == 1) {
$intNow = 0;
$arrTemp[] = $arrWait;
}
} else {
$arrWait = $elem;
$intNow = 1;
}
}
$_SESSION['templatedefinition'] = $arrTemp;
}
if ($chkMode == "sortup") {
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition'])) {
$arrTemp = "";
$arrWait = "";
$intNow = 0;
foreach ($_SESSION['templatedefinition'] AS $key => $elem) {
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) {
$intNow = 0;
$arrTemp[] = $arrWait;
}
} else {
$arrWait = $elem;
$intNow = 1;
}
}
$_SESSION['templatedefinition'] = $arrTemp;
}
if ($chkMode == "sortdown") {
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition'])) {
$arrTemp = "";
$arrWait = "";
$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) {
$arrTemp[] = $elem;
}
}
$_SESSION['templatedefinition'] = $arrTemp;
$arrTemp = "";
foreach ($_SESSION['templatedefinition'] AS $key => $elem) {
if ($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%">
<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/templatedefinitions.php?dataId=<?php echo $chkDataId; ?>&type=<?php echo $chkType; ?>&mode=del&def="+key;
}
function doUp(key,elem) {
document.location.href = "<?php echo $_SESSION['SETS']['path']['base_url']; ?>admin/templatedefinitions.php?dataId=<?php echo $chkDataId; ?>&type=<?php echo $chkType; ?>&mode=sortup&key="+key+"def="+elem;
}
function doDown(key,elem) {
document.location.href = "<?php echo $_SESSION['SETS']['path']['base_url']; ?>admin/templatedefinitions.php?dataId=<?php echo $chkDataId; ?>&type=<?php echo $chkType; ?>&mode=sortdown&key="+key+"def="+elem;
}
//-->
</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>
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
}
}
}
} else {
} else {
?>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<tr>
<td class="tablerow"><?php echo translate('No data'); ?></td>
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
}
?>
</table>
</body>
</html>
</table>
</body>
</html>

View File

@@ -5,194 +5,179 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1257 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preAccess = 1;
//$prePageId = 16;
$preNoMain = 1;
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
require("../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);
$chkTipId = (isset($_GET['tipId']) && ($_GET['tipId'] != "")) ? htmlspecialchars($_GET['tipId'], ENT_QUOTES, 'utf-8') : 0;
$chkMode = isset($_GET['mode']) ? htmlspecialchars($_GET['mode'], ENT_QUOTES, 'utf-8') : "";
$chkDef = isset($_GET['def']) ? html_entity_decode($_GET['def']) : "";
$chkRange = isset($_GET['range']) ? html_entity_decode($_GET['range']) : "";
$chkId = isset($_GET['id']) ? htmlspecialchars($_GET['id'], ENT_QUOTES, 'utf-8') : "";
$chkVersion = isset($_GET['version']) ? htmlspecialchars($_GET['version'], ENT_QUOTES, 'utf-8') : 0;
if (get_magic_quotes_gpc() == 0) {
$chkDef = addslashes($chkDef);
$chkRange = addslashes($chkRange);
$chkDef = addslashes($chkDef);
$chkRange = addslashes($chkRange);
}
//
// Get data
// ========
$strSQL = "SELECT * FROM `tbl_timedefinition` WHERE `tipId`=$chkTipId ORDER BY `definition`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
$strSQL = "SELECT * FROM `tbl_timedefinition` WHERE `tipId` = $chkTipId ORDER BY `definition`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
//
// Store data to session
// ============================
if ($chkMode == '') {
$_SESSION['timedefinition'] = array();
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;
}
}
if ($chkMode == "") {
$_SESSION['timedefinition'] = "";
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;
}
}
}
//
// 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)) {
$_SESSION['timedefinition'][$key]['definition'] = $chkDef;
$_SESSION['timedefinition'][$key]['range'] = $chkRange;
$intCheck = 1;
}
}
if ($intCheck == 0) {
$arrTemp['id'] = 0;
$arrTemp['definition'] = $chkDef;
$arrTemp['range'] = $chkRange;
$arrTemp['status'] = 0;
$_SESSION['timedefinition'][] = $arrTemp;
}
} else {
$arrTemp['id'] = 0;
$arrTemp['definition'] = $chkDef;
$arrTemp['range'] = $chkRange;
$arrTemp['status'] = 0;
$_SESSION['timedefinition'][] = $arrTemp;
}
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)) {
$_SESSION['timedefinition'][$key]['definition'] = $chkDef;
$_SESSION['timedefinition'][$key]['range'] = $chkRange;
$intCheck = 1;
}
}
if ($intCheck == 0) {
$arrTemp['id'] = 0;
$arrTemp['definition'] = $chkDef;
$arrTemp['range'] = $chkRange;
$arrTemp['status'] = 0;
$_SESSION['timedefinition'][] = $arrTemp;
}
} else {
$arrTemp['id'] = 0;
$arrTemp['definition'] = $chkDef;
$arrTemp['range'] = $chkRange;
$arrTemp['status'] = 0;
$_SESSION['timedefinition'][] = $arrTemp;
}
}
//
// 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)) {
$_SESSION['timedefinition'][$key]['status'] = 1;
}
}
if ($chkMode == "del") {
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition'])) {
foreach ($_SESSION['timedefinition'] AS $key => $elem) {
if (($elem['definition'] == $chkDef) && ($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) {
<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 doEdit(key,range) {
<?php
if ($chkVersion == 3) {
?>
parent.document.frmDetail.txtTimedefinition.value = decodeURIComponent(key);
parent.document.frmDetail.txtTimerange2.value = decodeURIComponent(range);
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;
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
}
?>
}
function doDel(key) {
document.location.href = "<?php
echo $_SESSION['SETS']['path']['base_url']; ?>admin/timedefinitions.php?tipId=<?php
echo $chkTipId; ?>&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%">
}
function doDel(key) {
document.location.href = "<?php echo $_SESSION['SETS']['path']['base_url']; ?>admin/timedefinitions.php?tipId=<?php echo $chkTipId; ?>&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 ($elem['status'] == 0) {
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>
<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>
<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

@@ -5,300 +5,197 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1282 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'timeperiod';
$preTableName = 'tbl_timeperiod';
$preKeyField = 'timeperiod_name';
$preAccess = 1;
$preFieldvars = 1;
$prePageId = 16;
$preContent = "admin/timeperiods.tpl.htm";
$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';
//
require("../functions/prepend_adm.php");
require("../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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == 'insert') {
$chkDataId = $intInsertId;
}
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 == 'modify') {
$myDataClass->writeLog(translate('Time period modified:'). ' ' .$chkTfValue1);
}
//
// Insert/update relations
// =======================
if ($chkModus == 'insert') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataInsertRelation(
'tbl_lnkTimeperiodToTimeperiod',
$chkDataId,
$chkMselValue1
);
}
if (isset($intRet1) && ($intRet1 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataInsertRelation(
'tbl_lnkTimeperiodToTimeperiodUse',
$chkDataId,
$chkMselValue2
);
}
if (isset($intRet2) && ($intRet2 != 0)) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
} elseif ($chkModus == 'modify') {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation(
'tbl_lnkTimeperiodToTimeperiod',
$chkDataId,
$chkMselValue1
);
} else {
$intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkTimeperiodToTimeperiod', $chkDataId);
}
if ($intRet1 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation(
'tbl_lnkTimeperiodToTimeperiodUse',
$chkDataId,
$chkMselValue2
);
} else {
$intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkTimeperiodToTimeperiodUse', $chkDataId);
}
if ($intRet2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition']) &&
(count($_SESSION['timedefinition']) != 0)) {
foreach ($_SESSION['timedefinition'] as $elem) {
if ($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) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
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;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != "") && ($chkTfValue2 != "")) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId;
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 == "modify") $myDataClass->writeLog(translate('Time period modified:')." ".$chkTfValue1);
//
// Insert/update relations
// =======================
if ($chkModus == "insert") {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkTimeperiodToTimeperiod",$chkDataId,$chkMselValue1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkTimeperiodToTimeperiodUse",$chkDataId,$chkMselValue2);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else if ($chkModus == "modify") {
if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkTimeperiodToTimeperiod",$chkDataId,$chkMselValue1);
} else {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkTimeperiodToTimeperiod",$chkDataId);
}
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkTimeperiodToTimeperiodUse",$chkDataId,$chkMselValue2);
} else {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkTimeperiodToTimeperiodUse",$chkDataId);
}
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition']) && (count($_SESSION['timedefinition']) != 0)) {
foreach($_SESSION['timedefinition'] AS $elem) {
if ($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) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
}
}
}
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Get date/time of last database and config file manipulation
// ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('Timeperiod definitions'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
$conttp->setVariable('TITLE', translate('Time period definitions (timeperiods.cfg)'));
// Do not show modified time list
$intNoTime = 1;
// Process exclude selection fields
if (isset($arrModifyData['exclude'])) {
$intFieldId = $arrModifyData['exclude'];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectMulti(
$preTableName,
'name',
'excludes',
'tbl_lnkTimeperiodToTimeperiod',
0,
$intFieldId,
$chkListId
);
if ($intReturn1 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process include selection fields
if (isset($arrModifyData['use_template'])) {
$intFieldId = $arrModifyData['use_template'];
} else {
$intFieldId = 0;
}
$intReturn2 = $myVisClass->parseSelectMulti(
$preTableName,
'name',
'uses',
'tbl_lnkTimeperiodToTimeperiodUse',
0,
$intFieldId,
$chkListId
);
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;
}
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
$conttp->setVariable('TIP_ID', $arrModifyData['id']);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Do not show modified time list
$intNoTime = 1;
// Process exclude selection fields
if (isset($arrModifyData['exclude'])) {$intFieldId = $arrModifyData['exclude'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti($preTableName,'name','excludes','tbl_lnkTimeperiodToTimeperiod',0,$intFieldId,$chkListId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process include selection fields
if (isset($arrModifyData['use_template'])) {$intFieldId = $arrModifyData['use_template'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectMulti($preTableName,'name','uses','tbl_lnkTimeperiodToTimeperiodUse',0,$intFieldId,$chkListId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;}
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
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
$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
$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
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$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'];
$booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn2 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$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."%')";
}
// Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
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)";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $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'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias');
}
// Show messages
$myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,41 +5,39 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preContent = 'admin/mainpages.htm.tpl';
$prePageId = 6;
$preContent = "admin/mainpages.tpl.htm";
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
require("../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');
$conttp->setVariable("TITLE",translate('Different tools'));
$conttp->parse("header");
$conttp->show("header");
$conttp->setVariable("DESC",translate('Useful functions for data import, main configuration, daemon control and so on.'));
$conttp->parse("main");
$conttp->show("main");
//
// 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->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse("footer");
$maintp->show("footer");
?>

View File

@@ -5,208 +5,171 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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';
$preSearchSession = 'user';
$preTableName = 'tbl_user';
$preKeyField = 'username';
$preAccess = 1;
$preFieldvars = 1;
$preNoAccessGrp = 1;
$prePageId = 32;
$preContent = "admin/user.tpl.htm";
$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';
//
require("../functions/prepend_adm.php");
require("../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 == '') {
$strPasswd = '';
} else {
$strPasswd = "`password`=MD5('$chkTfValue3'),";
}
// Grant admin rights
if ($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;
} else {
$strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
$intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
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 == 'modify') {
$myDataClass->writeLog(translate('User modified:'). ' ' .$chkTfValue1);
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Password too short or password fields do not match!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
// Check password
if ((($chkTfValue3 === $chkTfValue4) && (strlen($chkTfValue3) > 5)) || (($chkModus == "modify") && ($chkTfValue3 == ""))) {
if ($chkTfValue3 == "") {$strPasswd = "";} else {$strPasswd = "`password`=MD5('$chkTfValue3'),";}
// Grant admin rights
if ($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;
} else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
}
if ($intWriteAccessId == 0) {
if (($chkTfValue1 != "") && ($chkTfValue2 != "")) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($intReturn == 1) {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage);
if ($chkModus == "insert") $myDataClass->writeLog(translate('A new user added:')." ".$chkTfValue1);
if ($chkModus == "modify") $myDataClass->writeLog(translate('User modified:')." ".$chkTfValue1);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Password too short or password fields unequally!'),$strErrorMessage);
}
$chkModus = "display";
}
if ($chkModus != "add") $chkModus = "display";
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('User administration'));
$conttp->parse("header");
$conttp->show("header");
//
// Singe data form
// ===============
if ($chkModus == 'add') {
// Process domain selection field
if (isset($arrModifyData['domain'])) {
$intFieldId = $arrModifyData['domain'];
} else {
$intFieldId = 1;
}
$intReturn1 = $myVisClass->parseSelectSimple('tbl_datadomain', 'domain', 'std_domain', 0, $intFieldId, 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) {
$intFieldId = $myDBClass->getFieldData('SELECT `id` FROM `tbl_language` '
. "WHERE `locale`='".$_SESSION['SETS']['data']['locale']."'");
$intFieldId = (int)$intFieldId;
}
$intReturn2 = $myVisClass->parseSelectSimple('tbl_language', 'language', 'language_name', 0, $intFieldId);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
$conttp->setVariable('TITLE', translate('User administration'));
$conttp->setVariable('WSAUTH_DISABLE', 'disabled');
$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('FILL_PASSWD_NOT_EQUAL', translate('The passwords do not match!'));
$conttp->setVariable('FILL_PASSWORD', translate('Please fill in the password'));
$conttp->setVariable('FILL_PWDSHORT', translate('The password is too short - use at least 6 characters!'));
$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', '');
}
// 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) {
$conttp->setVariable('WSAUTH_CHECKED', 'checked');
}
// Object based group administration
$conttp->setVariable('ADMINENABLE_CHECKED', '');
if ($arrModifyData['admin_enable'] == 1) {
$conttp->setVariable('ADMINENABLE_CHECKED', 'checked');
}
// Admin rules
if ($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->parse('datainsert');
$conttp->show('datainsert');
if ($chkModus == "add") {
// Process domain selection field
if (isset($arrModifyData['domain'])) {$intFieldId = $arrModifyData['domain'];} else {$intFieldId = 1;}
$intReturn = $myVisClass->parseSelectSimple('tbl_datadomain','domain','std_domain',0,$intFieldId,0);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Process language selection field
if (isset($arrModifyData['language'])) {$intFieldId = $arrModifyData['language'];} else {$intFieldId = 0;}
if ($intFieldId == 0) {
$intFieldId = $myDBClass->getFieldData("SELECT `id` FROM `tbl_language` WHERE `locale`='".$_SESSION['SETS']['data']['locale']."'")+0;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_language','language','language_name',0,$intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
$conttp->setVariable("WSAUTH_DISABLE","disabled");
$conttp->setVariable("FILL_ALLFIELDS",translate('Please fill in all fields marked with an *'));
$conttp->setVariable("FILL_ILLEGALCHARS",translate('The following field contains not permitted characters:'));
$conttp->setVariable("FILL_PASSWD_NOT_EQUAL",translate('The passwords are not equal!'));
$conttp->setVariable("FILL_PASSWORD",translate('Please fill in the password'));
$conttp->setVariable("FILL_PWDSHORT",translate('The password is too short - use at least 6 characters!'));
$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","");
}
// 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) $conttp->setVariable("WSAUTH_CHECKED","checked");
// Object based group administration
$conttp->setVariable("ADMINENABLE_CHECKED","");
if ($arrModifyData['admin_enable'] == 1) $conttp->setVariable("ADMINENABLE_CHECKED","checked");
// Admin rules
if ($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->parse("datainsert");
$conttp->show("datainsert");
}
//
// Data table
// ==========
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
$strOrderString = "ORDER BY `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) {
$strOrderString = "ORDER BY `alias` $hidSortDir";
}
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName`";
$booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($booReturn1 == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) {
$chkLimit = 0;
}
}
// 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) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp, $arrDataLines, $intDataCount, $intLineCount, $preKeyField, 'alias');
if ($chkModus == "display") {
// Initial list view definitions
$myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Username'));
$mastertp->setVariable("FIELD_2",translate('Description'));
// Row sorting
$strOrderString = "ORDER BY `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) $strOrderString = "ORDER BY `alias` $hidSortDir";
// Count datasets
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName`";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else {
$intLineCount = (int)$arrDataLinesCount['number'];
if ($intLineCount < $chkLimit) $chkLimit = 0;
}
// Get datasets
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `nodelete`
FROM `$preTableName` $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
}
// Process data
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias');
}
// Show messages
$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1);
//
// Process footer
// ==============
$myContentClass->showFooter($maintp, $setFileVersion);
$myContentClass->showFooter($maintp,$setFileVersion);
?>

View File

@@ -5,151 +5,136 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1257 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$preAccess = 1;
$preNoMain = 1;
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
require("../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);
$chkDataId = isset($_GET['dataId']) ? htmlspecialchars($_GET['dataId'], ENT_QUOTES, 'utf-8') : 0;
$chkMode = isset($_GET['mode']) ? htmlspecialchars($_GET['mode'], ENT_QUOTES, 'utf-8') : "";
$chkDef = isset($_GET['def']) ? $_GET['def'] : "";
$chkRange = isset($_GET['range']) ? $_GET['range'] : "";
$chkId = isset($_GET['id']) ? htmlspecialchars($_GET['id'], ENT_QUOTES, 'utf-8') : "";
$chkVersion = isset($_GET['version']) ? htmlspecialchars($_GET['version'], ENT_QUOTES, 'utf-8') : 0;
$chkLinkTab = isset($_GET['linktab']) ? htmlspecialchars($_GET['linktab'], ENT_QUOTES, 'utf-8') : "";
if (get_magic_quotes_gpc() == 0) {
$chkDef = addslashes($chkDef);
$chkRange = addslashes($chkRange);
$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`";
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
//
// Store data to session
// ============================
if ($chkMode == '') {
$arrTemp = array();
$_SESSION['variabledefinition'] = array();
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;
$_SESSION['variabledefinition'][] = $arrTemp;
}
}
}
if ($chkLinkTab != "") {
$strSQL = "SELECT * FROM `tbl_variabledefinition` LEFT JOIN `".$chkLinkTab."` ON `id`=`idSlave` WHERE `idMaster`=$chkDataId ORDER BY `name`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
//
// Store data to session
// ============================
if ($chkMode == "") {
$_SESSION['variabledefinition'] = "";
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;
$_SESSION['variabledefinition'][] = $arrTemp;
}
}
}
}
//
// 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)) {
$_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;
$_SESSION['variabledefinition'][] = $arrTemp;
}
} else {
$arrTemp['id'] = 0;
$arrTemp['definition'] = $chkDef;
$arrTemp['range'] = $chkRange;
$arrTemp['status'] = 0;
$_SESSION['variabledefinition'][] = $arrTemp;
}
if ($chkMode == "add") {
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition'])) {
$intCheck = 0;
foreach ($_SESSION['variabledefinition'] AS $key => $elem) {
if (($elem['definition'] == $chkDef) && ($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;
$_SESSION['variabledefinition'][] = $arrTemp;
}
} else {
$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'])) {
foreach ($_SESSION['variabledefinition'] as $key => $elem) {
if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) {
$_SESSION['variabledefinition'][$key]['status'] = 1;
}
}
if ($chkMode == "del") {
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition'])) {
foreach ($_SESSION['variabledefinition'] AS $key => $elem) {
if (($elem['definition'] == $chkDef) && ($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>
<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;
}
</script>
<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 doEdit(key,range) {
parent.document.frmDetail.txtVariablename.value = decodeURIComponent(key);
parent.document.frmDetail.txtVariablevalue.value = decodeURIComponent(range);
}
function doDel(key) {
document.location.href = "<?php echo $_SESSION['SETS']['path']['base_url']; ?>admin/variabledefinitions.php?dataId=<?php echo $chkDataId; ?>&mode=del&def="+key;
}
//-->
</script>
</head>
<body style="margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<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) {
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>
<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>
@@ -158,8 +143,8 @@ if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefini
<td class="tablerow" align="right">&nbsp;</td>
</tr>
<?php
}
}
?>
</table>
</table>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -5,193 +5,168 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 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
// Component : Command line visualization
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2011-10-31 15:42:09 +0100 (Mo, 31. Okt 2011) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1118 $
//
///////////////////////////////////////////////////////////////////////////////
//
// 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;
$chkShow = filter_input(INPUT_GET, 'show', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$preNoMain = 1;
$chkShow = isset($_GET['show']) ? $_GET['show']+0 : 0;
//
// Include preprocessing file
// ==========================
require $preBasePath.'functions/prepend_adm.php';
$strCommandLine = '&nbsp;';
$intCount = 0;
require("../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']);
$aContext = array(
'http' => array(
'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,
),
);
}
$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');
$strInformation = translate('Information');
$strVersion = '';
$strRelease = '';
$strRelInfo = '';
if (is_array($arrFile) && count($arrFile) != 0) {
foreach ($arrFile as $elem) {
if (substr_count($elem, 'version') != 0) {
$strVersion = 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, 'information') != 0) {
$strRelInfo = trim(strip_tags($elem));
}
}
}
$setFileAvailable = $strVersion;
if (version_compare($strVersion, $setFileVersion, '==')) {
$setFileInformation = "<span class='greenmessage'>".translate('You already have the latest version installed').
'</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">' .
'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>';
}
if (($strError != 'none') && ($strError != '')) {
$setFileInformation = "<span class='redmessage'>".$strError. '</span>';
} ?>
$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']);
$aContext = array(
'http' => array(
'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,
),
);
}
$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');
$strInformation = translate('Information');
$strVersion = "";
$strRelease = "";
$strRelInfo = "";
if (is_array($arrFile) && (count($arrFile)) != 0) {
foreach ($arrFile AS $elem) {
if (substr_count($elem,"version") != 0) $strVersion = 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,"information") != 0) $strRelInfo = trim(strip_tags($elem));
}
}
$setFileAvailable = $strVersion;
if (version_compare($strVersion, $setFileVersion,'==')) {
$setFileInformation = "<span class='greenmessage'>".translate('You already have the latest version installed')."</span>";
} else if (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\">NagiosQL on Sourceforge</a>";
} else if (version_compare($strVersion, $setFileVersion,'<=')) {
$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>";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Version check</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
<link href="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>config/content.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
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';
<head>
<title>Version check</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<?php echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
<link href="<?php echo $_SESSION['SETS']['path']['base_url']; ?>config/content.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
background-color: #FFFFFF;
margin: 0px;
border: none;
}
-->
</style>
</head>
<body>
<table width="100%" border="0" class="content_listtable" style="padding:0px; margin:0px; 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 language="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';";
}
if (($strError != "none") && ($strError != "")) {
echo " parent.document.getElementById('versioncheck').height = '65';";
}
?>
//-->
</script>
</body>
//-->
</script>
</body>
</html>
<?php
} else {
?>
<!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: #FFFFFF;
margin: 0;
border: none;
}
-->
</style>
</head>
<body>
<p><br>Loading...</p>
</body>
<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: 0px;
border: none;
}
-->
</style>
</head>
<body>
<p><br>Loading...</p>
</body>
</html>
<?php
}

View File

@@ -5,33 +5,39 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 by Martin Willisegger
//
// Project : NagiosQL
// Component : CSS content definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2011-10-27 09:50:16 +0200 (Thu, 27 Oct 2011) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1111 $
//
/////////////////////////////////////////////////////////////////////////////*/
/* Content main div */
#content_main {
top:-3px;
left:0;
left:0px;
width:890px;
margin: 0;
padding: 0 0 0 10px;
padding: 0px;
margin: 0px;
padding-left: 10px;
position:relative;
font-size: 12px;
}
/* Content title (list and single view) */
#content_title {
color: #0c4271;
margin: 0 0 0 2px;
margin:0px;
padding:0px;
margin-top:0px;
margin-left:2px;
font-size:20px;
font-weight:bold;
font-family:Arial, Helvetica, sans-serif;
padding: 0 0 5px;
padding-bottom:5px;
}
/* Content special definitions */
.elementHide {
@@ -69,8 +75,6 @@
font-size: 12px;
padding:2px;
}
/*noinspection CssUnusedSymbol*/
#content_main .warnmessage {
font-size: 12px;
color: #FF9900;
@@ -90,7 +94,7 @@
/* Content tags */
#content_main h2 {
font-size: 14px;
margin-bottom:0;
margin-bottom:0px;
}
/* Version string */
.version {
@@ -108,8 +112,8 @@
}
/* Content forms */
#content_main form {
margin:0;
padding:0;
margin:0px;
padding:0px;
}
/* Content form table (single view and top/bottom line of list view) */
.content_formtable {
@@ -119,8 +123,8 @@
font-size:12px;
}
.content_formtable td {
padding:0;
margin:0;
padding:0px;
margin:0px;
height:18px;
text-align:left;
}
@@ -139,8 +143,8 @@
/* Form field definitions */
.content_formtable input[type=text] {
width:200px;
padding:0;
margin:0;
padding:0px;
margin:0px;
border: 1px solid #6CF;
background: #d1e2fd url(../images/input.png);
font-family:Verdana, Helvetica, sans-serif;
@@ -149,8 +153,8 @@
}
.content_formtable input[type=password] {
width:200px;
padding:0;
margin:0;
padding:0px;
margin:0px;
border: 1px solid #6CF;
background: #d1e2fd url(../images/input.png);
font-family:Verdana, Helvetica, sans-serif;
@@ -174,8 +178,6 @@
font-size:12px;
height:18px;
}
/*noinspection CssUnusedSymbol*/
.content_formtable input[type=text].inputlock {
width:200px;
border: 1px solid #053056;
@@ -199,8 +201,8 @@
.content_formtable input[type=text].short {
width:150px;
height:18px;
padding:0;
margin:0;
padding:0px;
margin:0px;
border: 1px solid #6CF;
background: #d1e2fd url(../images/input.png);
font-family:Verdana, Helvetica, sans-serif;
@@ -229,7 +231,7 @@
height:25px;
padding-left:10px;
padding-right:10px;
margin:0;
margin:0px;
padding-bottom:2px;
}
.content_formtable input[type=button][disabled] {
@@ -241,7 +243,7 @@
height:25px;
padding-left:10px;
padding-right:10px;
margin:0;
margin:0px;
padding-bottom:2px;
}
.content_formtable input[type=submit] {
@@ -253,7 +255,7 @@
height:25px;
padding-left:10px;
padding-right:10px;
margin:0;
margin:0px;
padding-bottom:2px;
}
.content_formtable input[type=submit][disabled] {
@@ -265,7 +267,7 @@
height:25px;
padding-left:10px;
padding-right:10px;
margin:0;
margin:0px;
padding-bottom:2px;
}
.content_formtable input[type=reset] {
@@ -277,20 +279,20 @@
height:25px;
padding-left:10px;
padding-right:10px;
margin:0;
margin:0px;
padding-bottom:2px;
}
.content_formtable input[type=checkbox] {
border:none;
margin-left:0;
margin-right:0;
margin-left:0px;
margin-right:0px;
background:none;
float:left;
}
.content_formtable input[type=radio] {
border:none;
margin-left:0;
margin-right:0;
margin-left:0px;
margin-right:0px;
background:none;
float:left;
}
@@ -317,18 +319,12 @@
color: #FFFFFF;
font-weight: bold;
}
/*noinspection CssUnusedSymbol*/
.content_formtable .inactive_option {
background-color:#FF8000;
}
/*noinspection ALL*/
.content_formtable .foreign_option {
background-color:#C90;
}
/*noinspection ALL*/
.content_formtable .ieselected {
background-color:#3399FF;
color:#000000;
@@ -387,14 +383,13 @@
.content_listtable td {
text-align: left;
vertical-align: middle;
padding: 0 0 2px;
padding:0px;
padding-bottom:2px;
height:25px;
}
.content_listtable .tdlb {
padding-left:5px;
}
/*noinspection ALL*/
.content_listtable .tdld {
padding-left:5px;
background-color: #dbe6ff;
@@ -402,8 +397,6 @@
.content_listtable .tdmb {
text-align: center;
}
/*noinspection ALL*/
.content_listtable .tdmd {
text-align: center;
background-color: #dbe6ff;
@@ -429,8 +422,8 @@
text-align:center;
}
.content_logtable .loglegend {
border: 0;
padding: 0;
border: 0px;
padding: 0px;
width:445px;
}
/* Custom */

View File

@@ -5,283 +5,244 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 by Martin Willisegger
//
// Project : NagiosQL
// Component : field language variables (for replace in templates)
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
///////////////////////////////////////////////////////////////////////////////
//
// Feldvariabeln setzen
// ====================
$arrDescription[] = array('name' => 'LANG_DOMAIN', 'string' => translate('Domain'));
$arrDescription[] = array('name' => 'LANG_DESCRIPTION', 'string' => translate('Description'));
$arrDescription[] = array('name' => 'LANG_SERVER_NAMEe', 'string' => translate('Server name'));
$arrDescription[] = array('name' => 'LANG_METHOD', 'string' => translate('Method'));
$arrDescription[] = array('name' => 'LANG_USERNAME', 'string' => translate('Username'));
$arrDescription[] = array('name' => 'LANG_PASSWORD', 'string' => translate('Password'));
$arrDescription[] = array('name' => 'LANG_SSH_KEY',
'string' => translate('Directory with SSH key pair'));
$arrDescription[] = array('name' => 'LANG_FTPS',
'string' => translate('Use encrypted FTP (FTPS)'));
$arrDescription[] = array('name' => 'LANG_SERVER_NAME', 'string' => translate('Server name'));
$arrDescription[] = array('name' => 'LANG_CONFIGURATION_DIRECTORIES',
'string' => translate('Configuration directories'));
$arrDescription[] = array('name' => 'LANG_NAGIOS_DIRECTORIES',
'string' => translate('Nagios configuration files and directories'));
$arrDescription[] = array('name' => 'LANG_BASE_DIRECTORY', 'string' => translate('Base directory'));
$arrDescription[] = array('name' => 'LANG_HOST_DIRECTORY', 'string' => translate('Host directory'));
$arrDescription[] = array('name' => 'LANG_SERVICE_DIRECTORY', 'string' => translate('Service directory'));
$arrDescription[] = array('name' => 'LANG_BACKUP_DIRECTORY', 'string' => translate('Backup directory'));
$arrDescription[] = array('name' => 'LANG_HOST_BACKUP_DIRECTORY', 'string' => translate('Host backup directory'));
$arrDescription[] = array('name' => 'LANG_SERVICE_BACKUP_DIRECTORY',
'string' => translate('Service backup directory'));
$arrDescription[] = array('name' => 'LANG_PICTURE_DIRECTORY', 'string' => translate('Picture base directory'));
$arrDescription[] = array('name' => 'LANG_NAGIOS_COMMAND_FILE', 'string' => translate('Nagios command file'));
$arrDescription[] = array('name' => 'LANG_NAGIOS_BINARY_FILE', 'string' => translate('Nagios binary file'));
$arrDescription[] = array('name' => 'LANG_NAGIOS_PROCESS_FILE', 'string' => translate('Nagios process file'));
$arrDescription[] = array('name' => 'LANG_NAGIOS_CONFIG_FILE', 'string' => translate('Nagios config file'));
$arrDescription[] = array('name' => 'LANG_NAGIOS_CGI_FILE', 'string' => translate('Nagios cgi file'));
$arrDescription[] = array('name' => 'LANG_NAGIOS_RESOURCE_FILE', 'string' => translate('Nagios resource file'));
$arrDescription[] = array('name' => 'LANG_NAGIOS_VERSION', 'string' => translate('Nagios version'));
$arrDescription[] = array('name' => 'LANG_ENABLE_COMMON_DOMAIN', 'string' => translate('Use common domain'));
$arrDescription[] = array('name' => 'LANG_ENABLE_UTF8_DECODE',
'string' => translate('Decode UTF8 data in config files'));
$arrDescription[] = array('name' => 'LANG_ACCESS_KEY_HOLES', 'string' => translate('Access key holes'));
$arrDescription[] = array('name' => 'LANG_ACCESS_KEYS', 'string' => translate('Access keys'));
$arrDescription[] = array('name' => 'LANG_ACTIVE', 'string' => translate('Active'));
$arrDescription[] = array('name' => 'LANG_REGISTERED', 'string' => translate('Registered'));
$arrDescription[] = array('name' => 'LANG_REQUIRED', 'string' => translate('required'));
$arrDescription[] = array('name' => 'LANG_SAVE', 'string' => translate('Save'));
$arrDescription[] = array('name' => 'LANG_ABORT', 'string' => translate('Abort'));
$arrDescription[] = array('name' => 'LANG_FUNCTION', 'string' => translate('Function'));
$arrDescription[] = array('name' => 'LANG_MARKED', 'string' => translate('Marked'));
$arrDescription[] = array('name' => 'LANG_DO_IT', 'string' => translate('Do it'));
$arrDescription[] = array('name' => 'LANG_ADD', 'string' => translate('Add'));
$arrDescription[] = array('name' => 'LANG_FORMCHECK', 'string' => translate('Form check'));
$arrDescription[] = array('name' => 'LANG_SECURE_QUESTION', 'string' => translate('Secure question'));
$arrDescription[] = array('name' => 'LANG_YES', 'string' => translate('Yes'));
$arrDescription[] = array('name' => 'LANG_NO', 'string' => translate('No'));
$arrDescription[] = array('name' => 'LANG_TIME', 'string' => translate('Time'));
$arrDescription[] = array('name' => 'LANG_USER', 'string' => translate('User'));
$arrDescription[] = array('name' => 'LANG_IP', 'string' => translate('IP Address'));
$arrDescription[] = array('name' => 'LANG_ENTRY', 'string' => translate('Entry'));
$arrDescription[] = array('name' => 'LANG_FROM', 'string' => translate('From'));
$arrDescription[] = array('name' => 'LANG_TO', 'string' => translate('To'));
$arrDescription[] = array('name' => 'LANG_DELETE_LOG_ENTRIES', 'string' => translate('Delete log entries'));
$arrDescription[] = array('name' => 'LANG_COPY', 'string' => translate('Copy'));
$arrDescription[] = array('name' => 'LANG_DELETE', 'string' => translate('Delete'));
$arrDescription[] = array('name' => 'LANG_MODIFY', 'string' => translate('Modify'));
$arrDescription[] = array('name' => 'LANG_CONFIRM_PASSWORD', 'string' => translate('Confirm password'));
$arrDescription[] = array('name' => 'LANG_OLD_PASSWORD', 'string' => translate('Old password'));
$arrDescription[] = array('name' => 'LANG_NEW_PASSWORD', 'string' => translate('New password'));
$arrDescription[] = array('name' => 'LANG_CHANGE_PASSWORD', 'string' => translate('Change password'));
$arrDescription[] = array('name' => 'LANG_MENU_PAGE', 'string' => translate('Menu page'));
$arrDescription[] = array('name' => 'LANG_SEARCH_STRING', 'string' => translate('Search string'));
$arrDescription[] = array('name' => 'LANG_SEARCH', 'string' => translate('Search'));
$arrDescription[] = array('name' => 'LANG_DELETE_SEARCH', 'string' => translate('Reset filter'));
$arrDescription[] = array('name' => 'LANG_WRITE_CONFIG_FILE', 'string' => translate('Write config file'));
$arrDescription[] = array('name' => 'LANG_DOWNLOAD', 'string' => translate('Download'));
$arrDescription[] = array('name' => 'LANG_DUPLICATE', 'string' => translate('Copy'));
$arrDescription[] = array('name' => 'LANG_COMMAND', 'string' => translate('Command'));
$arrDescription[] = array('name' => 'LANG_COMMAND_LINE', 'string' => translate('Command line'));
$arrDescription[] = array('name' => 'LANG_COMMAND_TYPE', 'string' => translate('Command type'));
$arrDescription[] = array('name' => 'LANG_TIME_PERIOD', 'string' => translate('Time period'));
$arrDescription[] = array('name' => 'LANG_EXCLUDE', 'string' => translate('Exclude'));
$arrDescription[] = array('name' => 'LANG_INCLUDE', 'string' => translate('Include'));
$arrDescription[] = array('name' => 'LANG_TIME_DEFINITIONS', 'string' => translate('Time definitions'));
$arrDescription[] = array('name' => 'LANG_WEEKDAY', 'string' => translate('Weekday'));
$arrDescription[] = array('name' => 'LANG_TIME_RANGE', 'string' => translate('Time range'));
$arrDescription[] = array('name' => 'LANG_TIME_DEFINITION', 'string' => translate('Time definition'));
$arrDescription[] = array('name' => 'LANG_INSERT', 'string' => translate('Insert'));
$arrDescription[] = array('name' => 'LANG_MODIFY_SELECTION', 'string' => translate('Modify selection'));
$arrDescription[] = array('name' => 'LANG_CONTACT_NAME', 'string' => translate('Contact name'));
$arrDescription[] = array('name' => 'LANG_CONTACT_GROUP', 'string' => translate('Contact group'));
$arrDescription[] = array('name' => 'LANG_MINIMUM_IMPORTANCE', 'string' => translate('Minimum importance'));
$arrDescription[] = array('name' => 'LANG_TIME_PERIOD_HOSTS', 'string' => translate('Time period hosts'));
$arrDescription[] = array('name' => 'LANG_TIME_PERIOD_SERVICES', 'string' => translate('Time period services'));
$arrDescription[] = array('name' => 'LANG_HOST_OPTIONS', 'string' => translate('Host options'));
$arrDescription[] = array('name' => 'LANG_SERVICE_OPTIONS', 'string' => translate('Service options'));
$arrDescription[] = array('name' => 'LANG_HOST_COMMAND', 'string' => translate('Host command'));
$arrDescription[] = array('name' => 'LANG_SERVICE_COMMAND', 'string' => translate('Service command'));
$arrDescription[] = array('name' => 'LANG_EMAIL_ADDRESS', 'string' => translate('EMail address'));
$arrDescription[] = array('name' => 'LANG_PAGER_NUMBER', 'string' => translate('Pager number'));
$arrDescription[] = array('name' => 'LANG_ADDON_ADDRESS', 'string' => translate('Addon address'));
$arrDescription[] = array('name' => 'LANG_HOST_NOTIF_ENABLE', 'string' => translate('Host notif. enable'));
$arrDescription[] = array('name' => 'LANG_SERVICE_NOTIF_ENABLE', 'string' => translate('Service notif. enable'));
$arrDescription[] = array('name' => 'LANG_CAN_SUBMIT_COMMANDS', 'string' => translate('Can submit commands'));
$arrDescription[] = array('name' => 'LANG_RETAIN_STATUS_INFO', 'string' => translate('Retain status info'));
$arrDescription[] = array('name' => 'LANG_RETAIN_NONSTATUS_INFO', 'string' => translate('Retain non-status info'));
$arrDescription[] = array('name' => 'LANG_MEMBERS', 'string' => translate('Members'));
$arrDescription[] = array('name' => 'LANG_GROUP_MEMBERS', 'string' => translate('Group members'));
$arrDescription[] = array('name' => 'LANG_COMMON_SETTINGS', 'string' => translate('Common settings'));
$arrDescription[] = array('name' => 'LANG_SERVICE_SETTINGS', 'string' => translate('Service settings'));
$arrDescription[] = array('name' => 'LANG_SERVICE_SETTINGS_DESC',
'string' => translate('Add this host configuration to existing service definitions'));
$arrDescription[] = array('name' => 'LANG_TEMPLATE_NAME', 'string' => translate('Template name'));
$arrDescription[] = array('name' => 'LANG_PARENTS', 'string' => translate('Parents'));
$arrDescription[] = array('name' => 'LANG_PARENT_SERVICES', 'string' => translate('Parent services'));
$arrDescription[] = array('name' => 'LANG_HOST_GROUPS', 'string' => translate('Host groups'));
$arrDescription[] = array('name' => 'LANG_CHECK_COMMAND', 'string' => translate('Check command'));
$arrDescription[] = array('name' => 'LANG_COMMAND_VIEW', 'string' => translate('Command view'));
$arrDescription[] = array('name' => 'LANG_ADDITIONAL_TEMPLATES', 'string' => translate('Additional templates'));
$arrDescription[] = array('name' => 'LANG_CHECK_SETTINGS', 'string' => translate('Check settings'));
$arrDescription[] = array('name' => 'LANG_INITIAL_STATE', 'string' => translate('Initial state'));
$arrDescription[] = array('name' => 'LANG_RETRY_INTERVAL', 'string' => translate('Retry interval'));
$arrDescription[] = array('name' => 'LANG_MAX_CHECK_ATTEMPTS', 'string' => translate('Max check attempts'));
$arrDescription[] = array('name' => 'LANG_CHECK_INTERVAL', 'string' => translate('Check interval'));
$arrDescription[] = array('name' => 'LANG_ACTIVE_CHECKS_ENABLED', 'string' => translate('Active checks enabled'));
$arrDescription[] = array('name' => 'LANG_PASSIVE_CHECKS_ENABLED', 'string' => translate('Passive checks enabled'));
$arrDescription[] = array('name' => 'LANG_CHECK_PERIOD', 'string' => translate('Check period'));
$arrDescription[] = array('name' => 'LANG_FRESHNESS_TRESHOLD', 'string' => translate('Freshness treshold'));
$arrDescription[] = array('name' => 'LANG_CHECK_FRESHNESS', 'string' => translate('Check freshness'));
$arrDescription[] = array('name' => 'LANG_OBSESS_OVER_HOST', 'string' => translate('Obsess over host'));
$arrDescription[] = array('name' => 'LANG_OBSESS_OVER_SERVICE', 'string' => translate('Obsess over service'));
$arrDescription[] = array('name' => 'LANG_EVENT_HANDLER', 'string' => translate('Event handler'));
$arrDescription[] = array('name' => 'LANG_EVENT_HANDLER_ENABLED', 'string' => translate('Event handler enabled'));
$arrDescription[] = array('name' => 'LANG_LOW_FLAP_THRESHOLD', 'string' => translate('Low flap threshold'));
$arrDescription[] = array('name' => 'LANG_HIGH_FLAP_THRESHOLD', 'string' => translate('High flap threshold'));
$arrDescription[] = array('name' => 'LANG_FLAP_DETECTION_ENABLED', 'string' => translate('Flap detection enabled'));
$arrDescription[] = array('name' => 'LANG_FLAP_DETECTION_OPTIONS', 'string' => translate('Flap detection options'));
$arrDescription[] = array('name' => 'LANG_RETAIN_STATUS_INFORMATION',
'string' => translate('Retain status information'));
$arrDescription[] = array('name' => 'LANG_RETAIN_NOSTATUS_INFORMATION',
'string' => translate('Retain non-status information'));
$arrDescription[] = array('name' => 'LANG_PROCESS_PERF_DATA', 'string' => translate('Process perf data'));
$arrDescription[] = array('name' => 'LANG_ALARM_SETTINGS', 'string' => translate('Alarm settings'));
$arrDescription[] = array('name' => 'LANG_CONTACTS', 'string' => translate('Contacts'));
$arrDescription[] = array('name' => 'LANG_CONTACT_GROUPS', 'string' => translate('Contact groups'));
$arrDescription[] = array('name' => 'LANG_NOTIFICATION_PERIOD', 'string' => translate('Notification period'));
$arrDescription[] = array('name' => 'LANG_NOTIFICATION_OPTIONS', 'string' => translate('Notification options'));
$arrDescription[] = array('name' => 'LANG_NOTIFICATION_INTERVAL', 'string' => translate('Notification interval'));
$arrDescription[] = array('name' => 'LANG_FIRST_NOTIFICATION_DELAY',
'string' => translate('First notification delay'));
$arrDescription[] = array('name' => 'LANG_NOTIFICATION_ENABLED', 'string' => translate('Notification enabled'));
$arrDescription[] = array('name' => 'LANG_IMPORTANCE', 'string' => translate('Importance'));
$arrDescription[] = array('name' => 'LANG_STALKING_OPTIONS', 'string' => translate('Stalking options'));
$arrDescription[] = array('name' => 'LANG_ADDON_SETTINGS', 'string' => translate('Addon settings'));
$arrDescription[] = array('name' => 'LANG_NOTES', 'string' => translate('Notes'));
$arrDescription[] = array('name' => 'LANG_VRML_IMAGE', 'string' => translate('VRML image'));
$arrDescription[] = array('name' => 'LANG_NOTES_URL', 'string' => translate('Notes URL'));
$arrDescription[] = array('name' => 'LANG_STATUS_IMAGE', 'string' => translate('Status image'));
$arrDescription[] = array('name' => 'LANG_ICON_IMAGE', 'string' => translate('Icon image'));
$arrDescription[] = array('name' => 'LANG_ACTION_URL', 'string' => translate('Action URL'));
$arrDescription[] = array('name' => 'LANG_2D_COORDS', 'string' => translate('2D coords'));
$arrDescription[] = array('name' => 'LANG_3D_COORDS', 'string' => translate('3D coords'));
$arrDescription[] = array('name' => 'LANG_ICON_IMAGE_ALT_TEXT', 'string' => translate('Icon image ALT text'));
$arrDescription[] = array('name' => 'LANG_STANDARD', 'string' => translate('standard'));
$arrDescription[] = array('name' => 'LANG_ON', 'string' => translate('on'));
$arrDescription[] = array('name' => 'LANG_OFF', 'string' => translate('off'));
$arrDescription[] = array('name' => 'LANG_SKIP', 'string' => translate('skip'));
$arrDescription[] = array('name' => 'LANG_FREE_VARIABLE_DEFINITIONS',
'string' => translate('Free variable definitions'));
$arrDescription[] = array('name' => 'LANG_VARIABLE_NAME', 'string' => translate('Variable name'));
$arrDescription[] = array('name' => 'LANG_VARIABLE_VALUE', 'string' => translate('Variable value'));
$arrDescription[] = array('name' => 'DELETE', 'string' => translate('Delete'));
$arrDescription[] = array('name' => 'DUPLICATE', 'string' => translate('Copy'));
$arrDescription[] = array('name' => 'ACTIVATE', 'string' => translate('Activate'));
$arrDescription[] = array('name' => 'DEACTIVATE', 'string' => translate('Deactivate'));
$arrDescription[] = array('name' => 'INFO', 'string' => translate('Information'));
$arrDescription[] = array('name' => 'WRITE_CONFIG', 'string' => translate('Write config file'));
$arrDescription[] = array('name' => 'LANG_DELETESINGLE',
'string' => translate('Do you really want to delete this database entry:'));
$arrDescription[] = array('name' => 'LANG_DELETEOK',
'string' => translate('Do you really want to delete all marked entries?'));
$arrDescription[] = array('name' => 'LANG_MARKALL',
'string' => translate('Mark all shown datasets'));
$arrDescription[] = array('name' => 'LANG_FILE', 'string' => translate('File'));
$arrDescription[] = array('name' => 'LANG_WRITE_CONF_ALL', 'string' => translate('Write all config files'));
$arrDescription[] = array('name' => 'LANG_ADDRESS', 'string' => translate('Address'));
$arrDescription[] = array('name' => 'LANG_DISPLAY_NAME', 'string' => translate('Display name'));
$arrDescription[] = array('name' => 'LANG_USE_THIS_AS_TEMPLATE',
'string' => translate('Use this configuration as a template'));
$arrDescription[] = array('name' => 'LANG_GENERIC_NAME', 'string' => translate('Generic name'));
$arrDescription[] = array('name' => 'LANG_HOST_NAME', 'string' => translate('Host name'));
$arrDescription[] = array('name' => 'FILL_ALLFIELDS',
'string' => translate('Please fill in all fields marked with an *'));
$arrDescription[] = array('name' => 'FILL_ILLEGALCHARS',
'string' => translate('The following field contains illegal characters:'));
$arrDescription[] = array('name' => 'FILL_BOXES',
'string' => translate('Please check at least one option from:'));
$arrDescription[] = array('name' => 'LANG_HOSTGROUP_NAME', 'string' => translate('Host group name'));
$arrDescription[] = array('name' => 'LANG_HOSTGROUP_MEMBERS', 'string' => translate('Host group members'));
$arrDescription[] = array('name' => 'LANG_HOSTS', 'string' => translate('Hosts'));
$arrDescription[] = array('name' => 'LANG_SERVICE_DESCRIPTION', 'string' => translate('Service description'));
$arrDescription[] = array('name' => 'LANG_SERVICEGROUPS', 'string' => translate('Service groups'));
$arrDescription[] = array('name' => 'LANG_IS_VOLATILE', 'string' => translate('Is volatile'));
$arrDescription[] = array('name' => 'LANG_PARALLELIZE_CHECK', 'string' => translate('Parallelize checks'));
$arrDescription[] = array('name' => 'LANG_CONFIGFILTER', 'string' => translate('Config name filter'));
$arrDescription[] = array('name' => 'LANG_CONFIG_NAME', 'string' => translate('Config name'));
$arrDescription[] = array('name' => 'LANG_IMPORT_DIRECTORY', 'string' => translate('Import directory'));
$arrDescription[] = array('name' => 'LANG_INSERT_ALL_VARIABLE',
'string' => translate('Please insert a variable name and a variable definition'));
$arrDescription[] = array('name' => 'LANG_MUST_BUT_TEMPLATE',
'string' => '<b>' .translate('Warning:'). '</b> ' .translate('You have not filled in some required fields!<br><br>'
. 'If this values are set by a template, you can save anyway - otherwise you will get an invalid '
. 'configuration!'));
$arrDescription[] = array('name' => 'LANG_TPLNAME', 'string' => translate('Template name'));
$arrDescription[] = array('name' => 'LANG_NAGIOS_BASEDIR', 'string' => translate('Nagios base directory'));
$arrDescription[] = array('name' => 'LANG_WRITE_CONFIG', 'string' => translate('Write config'));
$arrDescription[] = array('name' => 'FILL_ARGUMENTS',
'string' => '<b>' .translate('Warning:'). '</b> ' .translate('You have not filled in all command arguments (ARGx) '
. 'for your selected command!<br><br>If this arguments are optional, you can save anyway - otherwise '
. 'you will get an invalid configuration!'));
$arrDescription[] = array('name' => 'LANG_SERVICEGROUP_MEMBERS', 'string' => translate('Service group members'));
$arrDescription[] = array('name' => 'LANG_SERVICEGROUP_NAME', 'string' => translate('Service group name'));
$arrDescription[] = array('name' => 'LANG_DEPENDHOSTS', 'string' => translate('Dependent hosts'));
$arrDescription[] = array('name' => 'LANG_DEPENDHOSTGRS', 'string' => translate('Dependent hostgroups'));
$arrDescription[] = array('name' => 'LANG_HOSTGROUPS', 'string' => translate('Hostgroups'));
$arrDescription[] = array('name' => 'LANG_INHERIT', 'string' => translate('Inherit parents'));
$arrDescription[] = array('name' => 'LANG_EXECFAILCRIT',
'string' => translate('Execution failure criteria'));
$arrDescription[] = array('name' => 'LANG_NOTIFFAILCRIT',
'string' => translate('Nofification failure criteria'));
$arrDescription[] = array('name' => 'LANG_DEPENDENCY_PERIOD', 'string' => translate('Dependency period'));
$arrDescription[] = array('name' => 'LANG_ESCALATION_PERIOD', 'string' => translate('Escalation period'));
$arrDescription[] = array('name' => 'LANG_ESCALATION_OPTIONS', 'string' => translate('Escalation options'));
$arrDescription[] = array('name' => 'LANG_FIRST_NOTIFICATION', 'string' => translate('First notification'));
$arrDescription[] = array('name' => 'LANG_LAST_NOTIFICATION', 'string' => translate('Last notification'));
$arrDescription[] = array('name' => 'LANG_DEPENDSERVICES', 'string' => translate('Dependent services'));
$arrDescription[] = array('name' => 'LANG_SERVICES', 'string' => translate('Services'));
$arrDescription[] = array('name' => 'LANG_DEPENDSERVICEGROUPS',
'string' => translate('Dependent servicegroups'));
$arrDescription[] = array('name' => 'LANG_HELP', 'string' => translate('Help'));
$arrDescription[] = array('name' => 'LANG_CALENDAR', 'string' => translate('Calendar'));
$arrDescription[] = array('name' => 'LANG_GROUPNAME', 'string' => translate('Group name'));
$arrDescription[] = array('name' => 'LANG_USERS', 'string' => translate('Users'));
$arrDescription[] = array('name' => 'LANG_ACCESS_GROUP', 'string' => translate('Access group'));
$arrDescription[] = array('name' => 'LANG_USER_DEFINITIONS', 'string' => translate('User definitions'));
$arrDescription[] = array('name' => 'LANG_USER_NAME', 'string' => translate('User name'));
$arrDescription[] = array('name' => 'LANG_USER_RIGHTS', 'string' => translate('User rights'));
$arrDescription[] = array('name' => 'LANG_OBJECT_ACCESS_RESTRICTIONS',
'string' => translate('Object access restrictions'));
$arrDescription[] = array('name' => 'LANG_ADMIN_ENABLE',
'string' => translate('Enable group administration'));
$arrDescription[] = array('name' => 'LANG_SHOW_RELATION_DATA', 'string' => translate('Show relation data'));
$arrDescription[] = array('name' => 'LANG_HIDE_RELATION_DATA', 'string' => translate('Hide relation data'));
$arrDescription[] = array('name' => 'LANG_CONFIG_TARGET', 'string' => translate('Configuration target'));
$arrDescription[] = array('name' => 'LANG_LANGUAGE', 'string' => translate('User language'));
$arrDescription[] = array('name' => 'LANG_STANDARD_DOMAIN', 'string' => translate('Standard domain'));
$arrDescription[] = array('name' => 'LANG_SERVICES_WARNING',
'string' => '<b>' .translate('Warning:'). '</b> ' .translate('The associated services must be additionally '.
'written to the files. Only writing the host configuration is not sufficient because the modification is ' .
'stored inside the service files!'));
$arrDescription[] = array ("name" => "LANG_DOMAIN", "string" => translate("Domain"));
$arrDescription[] = array ("name" => "LANG_DESCRIPTION", "string" => translate("Description"));
$arrDescription[] = array ("name" => "LANG_SERVER_NAMEe", "string" => translate("Server name"));
$arrDescription[] = array ("name" => "LANG_METHOD", "string" => translate("Method"));
$arrDescription[] = array ("name" => "LANG_USERNAME", "string" => translate("Username"));
$arrDescription[] = array ("name" => "LANG_PASSWORD", "string" => translate("Password"));
$arrDescription[] = array ("name" => "LANG_SSH_KEY", "string" => translate("Directory with SSH key pair"));
$arrDescription[] = array ("name" => "LANG_SERVER_NAME", "string" => translate("Server name"));
$arrDescription[] = array ("name" => "LANG_CONFIGURATION_DIRECTORIES", "string" => translate("Configuration directories"));
$arrDescription[] = array ("name" => "LANG_BASE_DIRECTORY", "string" => translate("Base directory"));
$arrDescription[] = array ("name" => "LANG_HOST_DIRECTORY", "string" => translate("Host directory"));
$arrDescription[] = array ("name" => "LANG_SERVICE_DIRECTORY", "string" => translate("Service directory"));
$arrDescription[] = array ("name" => "LANG_BACKUP_DIRECTORY", "string" => translate("Backup directory"));
$arrDescription[] = array ("name" => "LANG_HOST_BACKUP_DIRECTORY", "string" => translate("Host backup directory"));
$arrDescription[] = array ("name" => "LANG_SERVICE_BACKUP_DIRECTORY", "string" => translate("Service backup directory"));
$arrDescription[] = array ("name" => "LANG_PICTURE_DIRECTORY", "string" => translate("Picture base directory"));
$arrDescription[] = array ("name" => "LANG_NAGIOS_COMMAND_FILE", "string" => translate("Nagios command file"));
$arrDescription[] = array ("name" => "LANG_NAGIOS_BINARY_FILE", "string" => translate("Nagios binary file"));
$arrDescription[] = array ("name" => "LANG_NAGIOS_PROCESS_FILE", "string" => translate("Nagios process file"));
$arrDescription[] = array ("name" => "LANG_NAGIOS_CONFIG_FILE", "string" => translate("Nagios config file"));
$arrDescription[] = array ("name" => "LANG_NAGIOS_VERSION", "string" => translate("Nagios version"));
$arrDescription[] = array ("name" => "LANG_ENABLE_COMMON_DOMAIN", "string" => translate("Use common domain"));
$arrDescription[] = array ("name" => "LANG_ENABLE_UTF8_DECODE", "string" => translate("Decode UTF8 data in config files"));
$arrDescription[] = array ("name" => "LANG_ACCESS_KEY_HOLES", "string" => translate("Access key holes"));
$arrDescription[] = array ("name" => "LANG_ACCESS_KEYS", "string" => translate("Access keys"));
$arrDescription[] = array ("name" => "LANG_ACTIVE", "string" => translate("Active"));
$arrDescription[] = array ("name" => "LANG_REGISTERED", "string" => translate("Registered"));
$arrDescription[] = array ("name" => "LANG_REQUIRED", "string" => translate("required"));
$arrDescription[] = array ("name" => "LANG_SAVE", "string" => translate("Save"));
$arrDescription[] = array ("name" => "LANG_ABORT", "string" => translate("Abort"));
$arrDescription[] = array ("name" => "LANG_FUNCTION", "string" => translate("Function"));
$arrDescription[] = array ("name" => "LANG_MARKED", "string" => translate("Marked"));
$arrDescription[] = array ("name" => "LANG_DO_IT", "string" => translate("Do it"));
$arrDescription[] = array ("name" => "LANG_ADD", "string" => translate("Add"));
$arrDescription[] = array ("name" => "LANG_FORMCHECK", "string" => translate("Formcheck"));
$arrDescription[] = array ("name" => "LANG_SECURE_QUESTION", "string" => translate("Secure question"));
$arrDescription[] = array ("name" => "LANG_YES", "string" => translate("Yes"));
$arrDescription[] = array ("name" => "LANG_NO", "string" => translate("No"));
$arrDescription[] = array ("name" => "LANG_TIME", "string" => translate("Time"));
$arrDescription[] = array ("name" => "LANG_USER", "string" => translate("User"));
$arrDescription[] = array ("name" => "LANG_IP", "string" => translate("IP"));
$arrDescription[] = array ("name" => "LANG_ENTRY", "string" => translate("Entry"));
$arrDescription[] = array ("name" => "LANG_FROM", "string" => translate("From"));
$arrDescription[] = array ("name" => "LANG_TO", "string" => translate("To"));
$arrDescription[] = array ("name" => "LANG_DELETE_LOG_ENTRIES", "string" => translate("Delete log entries"));
$arrDescription[] = array ("name" => "LANG_COPY", "string" => translate("Copy"));
$arrDescription[] = array ("name" => "LANG_DELETE", "string" => translate("Delete"));
$arrDescription[] = array ("name" => "LANG_MODIFY", "string" => translate("Modify"));
$arrDescription[] = array ("name" => "LANG_CONFIRM_PASSWORD", "string" => translate("Confirm password"));
$arrDescription[] = array ("name" => "LANG_OLD_PASSWORD", "string" => translate("Old password"));
$arrDescription[] = array ("name" => "LANG_NEW_PASSWORD", "string" => translate("New password"));
$arrDescription[] = array ("name" => "LANG_CHANGE_PASSWORD", "string" => translate("Change password"));
$arrDescription[] = array ("name" => "LANG_MENU_PAGE", "string" => translate("Menu page"));
$arrDescription[] = array ("name" => "LANG_SEARCH_STRING", "string" => translate("Search string"));
$arrDescription[] = array ("name" => "LANG_SEARCH", "string" => translate("Search"));
$arrDescription[] = array ("name" => "LANG_DELETE_SEARCH", "string" => translate("Reset filter"));
$arrDescription[] = array ("name" => "LANG_WRITE_CONFIG_FILE", "string" => translate("Write config file"));
$arrDescription[] = array ("name" => "LANG_DOWNLOAD", "string" => translate("Download"));
$arrDescription[] = array ("name" => "LANG_DUPLICATE", "string" => translate("Copy"));
$arrDescription[] = array ("name" => "LANG_COMMAND", "string" => translate("Command"));
$arrDescription[] = array ("name" => "LANG_COMMAND_LINE", "string" => translate("Command line"));
$arrDescription[] = array ("name" => "LANG_COMMAND_TYPE", "string" => translate("Command type"));
$arrDescription[] = array ("name" => "LANG_TIME_PERIOD", "string" => translate("Time period"));
$arrDescription[] = array ("name" => "LANG_EXCLUDE", "string" => translate("Exclude"));
$arrDescription[] = array ("name" => "LANG_INCLUDE", "string" => translate("Include"));
$arrDescription[] = array ("name" => "LANG_TIME_DEFINITIONS", "string" => translate("Time definitions"));
$arrDescription[] = array ("name" => "LANG_WEEKDAY", "string" => translate("Weekday"));
$arrDescription[] = array ("name" => "LANG_TIME_RANGE", "string" => translate("Time range"));
$arrDescription[] = array ("name" => "LANG_TIME_DEFINITION", "string" => translate("Time definition"));
$arrDescription[] = array ("name" => "LANG_INSERT", "string" => translate("Insert"));
$arrDescription[] = array ("name" => "LANG_MODIFY_SELECTION", "string" => translate("Modify selection"));
$arrDescription[] = array ("name" => "LANG_CONTACT_NAME", "string" => translate("Contact name"));
$arrDescription[] = array ("name" => "LANG_CONTACT_GROUP", "string" => translate("Contact group"));
$arrDescription[] = array ("name" => "LANG_TIME_PERIOD_HOSTS", "string" => translate("Time period hosts"));
$arrDescription[] = array ("name" => "LANG_TIME_PERIOD_SERVICES", "string" => translate("Time period services"));
$arrDescription[] = array ("name" => "LANG_HOST_OPTIONS", "string" => translate("Host options"));
$arrDescription[] = array ("name" => "LANG_SERVICE_OPTIONS", "string" => translate("Service options"));
$arrDescription[] = array ("name" => "LANG_HOST_COMMAND", "string" => translate("Host command"));
$arrDescription[] = array ("name" => "LANG_SERVICE_COMMAND", "string" => translate("Service command"));
$arrDescription[] = array ("name" => "LANG_EMAIL_ADDRESS", "string" => translate("EMail address"));
$arrDescription[] = array ("name" => "LANG_PAGER_NUMBER", "string" => translate("Pager number"));
$arrDescription[] = array ("name" => "LANG_ADDON_ADDRESS", "string" => translate("Addon address"));
$arrDescription[] = array ("name" => "LANG_HOST_NOTIF_ENABLE", "string" => translate("Host notif. enable"));
$arrDescription[] = array ("name" => "LANG_SERVICE_NOTIF_ENABLE", "string" => translate("Service notif. enable"));
$arrDescription[] = array ("name" => "LANG_CAN_SUBMIT_COMMANDS", "string" => translate("Can submit commands"));
$arrDescription[] = array ("name" => "LANG_RETAIN_STATUS_INFO", "string" => translate("Retain status info"));
$arrDescription[] = array ("name" => "LANG_RETAIN_NONSTATUS_INFO", "string" => translate("Retain nonstatus info"));
$arrDescription[] = array ("name" => "LANG_MEMBERS", "string" => translate("Members"));
$arrDescription[] = array ("name" => "LANG_GROUP_MEMBERS", "string" => translate("Group members"));
$arrDescription[] = array ("name" => "LANG_COMMON_SETTINGS", "string" => translate("Common settings"));
$arrDescription[] = array ("name" => "LANG_SERVICE_SETTINGS", "string" => translate("Service settings"));
$arrDescription[] = array ("name" => "LANG_SERVICE_SETTINGS_DESC", "string" => translate("Add this host configuration to existing service definitions"));
$arrDescription[] = array ("name" => "LANG_TEMPLATE_NAME", "string" => translate("Template name"));
$arrDescription[] = array ("name" => "LANG_PARENTS", "string" => translate("Parents"));
$arrDescription[] = array ("name" => "LANG_HOST_GROUPS", "string" => translate("Host groups"));
$arrDescription[] = array ("name" => "LANG_CHECK_COMMAND", "string" => translate("Check command"));
$arrDescription[] = array ("name" => "LANG_COMMAND_VIEW", "string" => translate("Command view"));
$arrDescription[] = array ("name" => "LANG_ADDITIONAL_TEMPLATES", "string" => translate("Additional templates"));
$arrDescription[] = array ("name" => "LANG_CHECK_SETTINGS", "string" => translate("Check settings"));
$arrDescription[] = array ("name" => "LANG_INITIAL_STATE", "string" => translate("Initial state"));
$arrDescription[] = array ("name" => "LANG_RETRY_INTERVAL", "string" => translate("Retry interval"));
$arrDescription[] = array ("name" => "LANG_MAX_CHECK_ATTEMPTS", "string" => translate("Max check attempts"));
$arrDescription[] = array ("name" => "LANG_CHECK_INTERVAL", "string" => translate("Check interval"));
$arrDescription[] = array ("name" => "LANG_ACTIVE_CHECKS_ENABLED", "string" => translate("Active checks enabled"));
$arrDescription[] = array ("name" => "LANG_PASSIVE_CHECKS_ENABLED", "string" => translate("Passive checks enabled"));
$arrDescription[] = array ("name" => "LANG_CHECK_PERIOD", "string" => translate("Check period"));
$arrDescription[] = array ("name" => "LANG_FRESHNESS_TRESHOLD", "string" => translate("Freshness treshold"));
$arrDescription[] = array ("name" => "LANG_CHECK_FRESHNESS", "string" => translate("Check freshness"));
$arrDescription[] = array ("name" => "LANG_OBSESS_OVER_HOST", "string" => translate("Obsess over host"));
$arrDescription[] = array ("name" => "LANG_OBSESS_OVER_SERVICE", "string" => translate("Obsess over service"));
$arrDescription[] = array ("name" => "LANG_EVENT_HANDLER", "string" => translate("Event handler"));
$arrDescription[] = array ("name" => "LANG_EVENT_HANDLER_ENABLED", "string" => translate("Event handler enabled"));
$arrDescription[] = array ("name" => "LANG_LOW_FLAP_THRESHOLD", "string" => translate("Low flap threshold"));
$arrDescription[] = array ("name" => "LANG_HIGH_FLAP_THRESHOLD", "string" => translate("High flap threshold"));
$arrDescription[] = array ("name" => "LANG_FLAP_DETECTION_ENABLED", "string" => translate("Flap detection enabled"));
$arrDescription[] = array ("name" => "LANG_FLAP_DETECTION_OPTIONS", "string" => translate("Flap detection options"));
$arrDescription[] = array ("name" => "LANG_RETAIN_STATUS_INFORMATION", "string" => translate("Retain status information"));
$arrDescription[] = array ("name" => "LANG_RETAIN_NOSTATUS_INFORMATION","string" => translate("Retain nostatus information"));
$arrDescription[] = array ("name" => "LANG_PROCESS_PERF_DATA", "string" => translate("Process perf data"));
$arrDescription[] = array ("name" => "LANG_ALARM_SETTINGS", "string" => translate("Alarm settings"));
$arrDescription[] = array ("name" => "LANG_CONTACTS", "string" => translate("Contacts"));
$arrDescription[] = array ("name" => "LANG_CONTACT_GROUPS", "string" => translate("Contact groups"));
$arrDescription[] = array ("name" => "LANG_NOTIFICATION_PERIOD", "string" => translate("Notification period"));
$arrDescription[] = array ("name" => "LANG_NOTIFICATION_OPTIONS", "string" => translate("Notification options"));
$arrDescription[] = array ("name" => "LANG_NOTIFICATION_INTERVAL", "string" => translate("Notification interval"));
$arrDescription[] = array ("name" => "LANG_FIRST_NOTIFICATION_DELAY", "string" => translate("First notification delay"));
$arrDescription[] = array ("name" => "LANG_NOTIFICATION_ENABLED", "string" => translate("Notification enabled"));
$arrDescription[] = array ("name" => "LANG_STALKING_OPTIONS", "string" => translate("Stalking options"));
$arrDescription[] = array ("name" => "LANG_ADDON_SETTINGS", "string" => translate("Addon settings"));
$arrDescription[] = array ("name" => "LANG_NOTES", "string" => translate("Notes"));
$arrDescription[] = array ("name" => "LANG_VRML_IMAGE", "string" => translate("VRML image"));
$arrDescription[] = array ("name" => "LANG_NOTES_URL", "string" => translate("Notes URL"));
$arrDescription[] = array ("name" => "LANG_STATUS_IMAGE", "string" => translate("Status image"));
$arrDescription[] = array ("name" => "LANG_ICON_IMAGE", "string" => translate("Icon image"));
$arrDescription[] = array ("name" => "LANG_ACTION_URL", "string" => translate("Action URL"));
$arrDescription[] = array ("name" => "LANG_2D_COORDS", "string" => translate("2D coords"));
$arrDescription[] = array ("name" => "LANG_3D_COORDS", "string" => translate("3D coords"));
$arrDescription[] = array ("name" => "LANG_ICON_IMAGE_ALT_TEXT", "string" => translate("Icon image ALT text"));
$arrDescription[] = array ("name" => "LANG_STANDARD", "string" => translate("standard"));
$arrDescription[] = array ("name" => "LANG_ON", "string" => translate("on"));
$arrDescription[] = array ("name" => "LANG_OFF", "string" => translate("off"));
$arrDescription[] = array ("name" => "LANG_SKIP", "string" => translate("skip"));
$arrDescription[] = array ("name" => "LANG_FREE_VARIABLE_DEFINITIONS", "string" => translate("Free variable definitions"));
$arrDescription[] = array ("name" => "LANG_VARIABLE_NAME", "string" => translate("Variable name"));
$arrDescription[] = array ("name" => "LANG_VARIABLE_VALUE", "string" => translate("Variable value"));
$arrDescription[] = array ("name" => "DELETE", "string" => translate("Delete"));
$arrDescription[] = array ("name" => "DUPLICATE", "string" => translate("Copy"));
$arrDescription[] = array ("name" => "ACTIVATE", "string" => translate("Activate"));
$arrDescription[] = array ("name" => "DEACTIVATE", "string" => translate("Deactivate"));
$arrDescription[] = array ("name" => "INFO", "string" => translate("Information"));
$arrDescription[] = array ("name" => "WRITE_CONFIG", "string" => translate("Write config file"));
$arrDescription[] = array ("name" => "LANG_DELETESINGLE", "string" => translate("Do you really want to delete this database entry:"));
$arrDescription[] = array ("name" => "LANG_DELETEOK", "string" => translate("Do you really want to delete all marked entries?"));
$arrDescription[] = array ("name" => "LANG_MARKALL", "string" => translate("Mark all shown datasets"));
$arrDescription[] = array ("name" => "LANG_FILE", "string" => translate("File"));
$arrDescription[] = array ("name" => "LANG_WRITE_CONF_ALL", "string" => translate("Write all config files"));
$arrDescription[] = array ("name" => "LANG_ADDRESS", "string" => translate("Address"));
$arrDescription[] = array ("name" => "LANG_DISPLAY_NAME", "string" => translate("Display name"));
$arrDescription[] = array ("name" => "LANG_USE_THIS_AS_TEMPLATE", "string" => translate("Use this configuration as template"));
$arrDescription[] = array ("name" => "LANG_GENERIC_NAME", "string" => translate("Generic name"));
$arrDescription[] = array ("name" => "LANG_HOST_NAME", "string" => translate("Host name"));
$arrDescription[] = array ("name" => "FILL_ALLFIELDS", "string" => translate("Please fill in all fields marked with an *"));
$arrDescription[] = array ("name" => "FILL_ILLEGALCHARS", "string" => translate("The following field contains not permitted characters:"));
$arrDescription[] = array ("name" => "FILL_BOXES", "string" => translate("Please check at least one option from:"));
$arrDescription[] = array ("name" => "LANG_HOSTGROUP_NAME", "string" => translate("Host group name"));
$arrDescription[] = array ("name" => "LANG_HOSTGROUP_MEMBERS", "string" => translate("Host group members"));
$arrDescription[] = array ("name" => "LANG_HOSTS", "string" => translate("Hosts"));
$arrDescription[] = array ("name" => "LANG_SERVICE_DESCRIPTION", "string" => translate("Service description"));
$arrDescription[] = array ("name" => "LANG_SERVICEGROUPS", "string" => translate("Service groups"));
$arrDescription[] = array ("name" => "LANG_IS_VOLATILE", "string" => translate("Is volatile"));
$arrDescription[] = array ("name" => "LANG_PARALLELIZE_CHECK", "string" => translate("Parallelize checks"));
$arrDescription[] = array ("name" => "LANG_CONFIGFILTER", "string" => translate("Config name filter"));
$arrDescription[] = array ("name" => "LANG_CONFIG_NAME", "string" => translate("Config name"));
$arrDescription[] = array ("name" => "LANG_IMPORT_DIRECTORY", "string" => translate("Import directory"));
$arrDescription[] = array ("name" => "LANG_INSERT_ALL_VARIABLE", "string" => translate("Please insert a variable name and a variable definition"));
$arrDescription[] = array ("name" => "LANG_MUST_BUT_TEMPLATE", "string" => "<b>".translate("Warning:")."<\/b> ".translate("You have not filled in some required fields!<br><br>If this values are set by a template, you can save anyway - otherwise you will get an invalid configuration!"));
$arrDescription[] = array ("name" => "LANG_TPLNAME", "string" => translate("Template name"));
$arrDescription[] = array ("name" => "LANG_NAGIOS_BASEDIR", "string" => translate("Nagios base directory"));
$arrDescription[] = array ("name" => "LANG_WRITE_CONFIG", "string" => translate("Write config"));
$arrDescription[] = array ("name" => "FILL_ARGUMENTS", "string" => "<b>".translate("Warning:")."<\/b> ".translate("You have not filled in all command arguments (ARGx) for your selected command!<br><br>If this arguments are optional, you can save anyway - otherwise you will get an invalid configuration!"));
$arrDescription[] = array ("name" => "LANG_SERVICEGROUP_MEMBERS", "string" => translate("Service group members"));
$arrDescription[] = array ("name" => "LANG_SERVICEGROUP_NAME", "string" => translate("Service group name"));
$arrDescription[] = array ("name" => "LANG_DEPENDHOSTS", "string" => translate("Dependent hosts"));
$arrDescription[] = array ("name" => "LANG_DEPENDHOSTGRS", "string" => translate("Dependent hostgroups"));
$arrDescription[] = array ("name" => "LANG_HOSTGROUPS", "string" => translate("Hostgroups"));
$arrDescription[] = array ("name" => "LANG_INHERIT", "string" => translate("Inherit parents"));
$arrDescription[] = array ("name" => "LANG_EXECFAILCRIT", "string" => translate("Execution failure criteria"));
$arrDescription[] = array ("name" => "LANG_NOTIFFAILCRIT", "string" => translate("Nofification failure criteria"));
$arrDescription[] = array ("name" => "LANG_DEPENDENCY_PERIOD", "string" => translate("Dependency period"));
$arrDescription[] = array ("name" => "LANG_ESCALATION_PERIOD", "string" => translate("Escalation period"));
$arrDescription[] = array ("name" => "LANG_ESCALATION_OPTIONS", "string" => translate("Escalation options"));
$arrDescription[] = array ("name" => "LANG_FIRST_NOTIFICATION", "string" => translate("First notification"));
$arrDescription[] = array ("name" => "LANG_LAST_NOTIFICATION", "string" => translate("Last notification"));
$arrDescription[] = array ("name" => "LANG_DEPENDSERVICES", "string" => translate("Dependent services"));
$arrDescription[] = array ("name" => "LANG_SERVICES", "string" => translate("Services"));
$arrDescription[] = array ("name" => "LANG_DEPENDSERVICEGROUPS", "string" => translate("Dependent servicegroups"));
$arrDescription[] = array ("name" => "LANG_HELP", "string" => translate("Help"));
$arrDescription[] = array ("name" => "LANG_CALENDAR", "string" => translate("Calendar"));
$arrDescription[] = array ("name" => "LANG_GROUPNAME", "string" => translate("Group name"));
$arrDescription[] = array ("name" => "LANG_USERS", "string" => translate("Users"));
$arrDescription[] = array ("name" => "LANG_ACCESS_GROUP", "string" => translate("Access group"));
$arrDescription[] = array ("name" => "LANG_USER_DEFINITIONS", "string" => translate("User definitions"));
$arrDescription[] = array ("name" => "LANG_USER_NAME", "string" => translate("User name"));
$arrDescription[] = array ("name" => "LANG_USER_RIGHTS", "string" => translate("User rights"));
$arrDescription[] = array ("name" => "LANG_OBJECT_ACCESS_RESTRICTIONS", "string" => translate("Object access restrictions"));
$arrDescription[] = array ("name" => "LANG_ADMIN_ENABLE", "string" => translate("Enable group administration"));
$arrDescription[] = array ("name" => "LANG_SHOW_RELATION_DATA", "string" => translate("Show relation data"));
$arrDescription[] = array ("name" => "LANG_HIDE_RELATION_DATA", "string" => translate("Hide relation data"));
$arrDescription[] = array ("name" => "LANG_CONFIG_TARGET", "string" => translate("Configuration target"));
$arrDescription[] = array ("name" => "LANG_LANGUAGE", "string" => translate("User language"));
$arrDescription[] = array ("name" => "LANG_STANDARD_DOMAIN", "string" => translate("Standard domain"));
$arrDescription[] = array ("name" => "LANG_SERVICES_WARNING", "string" => "<b>".translate("Warning:")."</b> ".translate("The associated services must be additionally written to the files. Only writing the host configuration is not sufficient because the modification is stored inside the service files!"));
// weekdays
$arrDescription[] = array('name' => 'LANG_MONDAY', 'string' => translate('Monday'));
$arrDescription[] = array('name' => 'LANG_TUESDAY', 'string' => translate('Tuesday'));
$arrDescription[] = array('name' => 'LANG_WEDNESDAY', 'string' => translate('Wednesday'));
$arrDescription[] = array('name' => 'LANG_THURSDAY', 'string' => translate('Thursday'));
$arrDescription[] = array('name' => 'LANG_FRIDAY', 'string' => translate('Friday'));
$arrDescription[] = array('name' => 'LANG_SATURDAY', 'string' => translate('Saturday'));
$arrDescription[] = array('name' => 'LANG_SUNDAY', 'string' => translate('Sunday'));
$arrDescription[] = array ("name" => "LANG_MONDAY", "string" => translate("Monday"));
$arrDescription[] = array ("name" => "LANG_TUESDAY", "string" => translate("Tuesday"));
$arrDescription[] = array ("name" => "LANG_WEDNESDAY", "string" => translate("Wednesday"));
$arrDescription[] = array ("name" => "LANG_THURSDAY", "string" => translate("Thursday"));
$arrDescription[] = array ("name" => "LANG_FRIDAY", "string" => translate("Friday"));
$arrDescription[] = array ("name" => "LANG_SATURDAY", "string" => translate("Saturday"));
$arrDescription[] = array ("name" => "LANG_SUNDAY", "string" => translate("Sunday"));
if ($SETS['common']['seldisable'] == 0) {
$arrDescription[] = array('name' => 'LANG_CTRLINFO',
'string' => translate('Hold CTRL to select<br>more than one entry'));
$arrDescription[] = array ("name" => "LANG_CTRLINFO", "string" => translate("Hold CTRL to select<br>more than one entry"));
} else {
$arrDescription[] = array('name' => 'LANG_CTRLINFO', 'string' => '&nbsp;');
$arrDescription[] = array ("name" => "LANG_CTRLINFO", "string" => "&nbsp;");
}
//
// Quick fix for poEdit for dynamically loaded Parameters
@@ -332,3 +293,4 @@ translate('Help editor');
translate('Data domains');
translate('Config targets');
translate('Support');
?>

View File

@@ -2,9 +2,11 @@
# #
# # Project : NagiosQL
# # Component : Translation File English
# # Website : https://sourceforge.net/projects/nagiosql/
# # Version : 3.4.0
# # GIT Repo : https://gitlab.com/wizonet/NagiosQL
# # Website : http://www.nagiosql.org
# # Date : $LastChangedDate: 2012-03-09 22:55:35 +0100 (Fri, 09 Mar 2012) $
# # Author : $LastChangedBy: martin $
# # Version : 3.1.1
# # Revision : $LastChangedRevision: 1284 $
# #
# #############################################################################
# Translators:
@@ -23,6 +25,7 @@ msgstr ""
"Language: da_DK\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"X-Generator: Pootle 2.1.5\n"
"X-Poedit-Basepath: D:\\$_Daten\\Webentwicklung\\NagiosQL_v3.2_svn\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: .\n"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,9 +2,11 @@
# #
# # Project : NagiosQL
# # Component : Translation File Spanish (Argentina)
# # Website : https://sourceforge.net/projects/nagiosql/
# # Version : 3.4.0
# # GIT Repo : https://gitlab.com/wizonet/NagiosQL
# # Website : http://www.nagiosql.org
# # Date : $LastChangedDate: 2012-03-09 22:55:35 +0100 (Fri, 09 Mar 2012) $
# # Author : $LastChangedBy: martin $
# # Version : 3.1.1
# # Revision : $LastChangedRevision: 1284 $
# #
# #############################################################################
msgid ""
@@ -14,7 +16,7 @@ msgstr ""
"POT-Creation-Date: 2012-03-09 22:51+0100\n"
"PO-Revision-Date: 2012-03-09 22:51+0100\n"
"Last-Translator: \n"
"Language-Team: https://sourceforge.net/projects/nagiosql/ <hnieva@gmail.com>\n"
"Language-Team: www.nagiosql.org <hnieva@gmail.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -22,6 +24,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Pootle 2.1.5\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-Basepath: D:\\$_Daten\\Webentwicklung\\NagiosQL_v3.2_svn\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-SearchPath-0: .\n"

View File

@@ -2,9 +2,11 @@
# #
# # Project : NagiosQL
# # Component : Translation File English
# # Website : https://sourceforge.net/projects/nagiosql/
# # Version : 3.4.0
# # GIT Repo : https://gitlab.com/wizonet/NagiosQL
# # Website : http://www.nagiosql.org
# # Date : $LastChangedDate: 2012-03-09 22:55:35 +0100 (Fri, 09 Mar 2012) $
# # Author : $LastChangedBy: martin $
# # Version : 3.1.1
# # Revision : $LastChangedRevision: 1284 $
# #
# #############################################################################
# Translators:
@@ -23,6 +25,7 @@ msgstr ""
"Language: es_ES\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"X-Generator: Pootle 2.1.5\n"
"X-Poedit-Basepath: D:\\$_Daten\\Webentwicklung\\NagiosQL_v3.2_svn\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: .\n"

View File

@@ -2,9 +2,11 @@
# #
# # Project : NagiosQL
# # Component : Translation File English
# # Website : https://sourceforge.net/projects/nagiosql/
# # Version : 3.4.0
# # GIT Repo : https://gitlab.com/wizonet/NagiosQL
# # Website : http://www.nagiosql.org
# # Date : $LastChangedDate: 2012-03-09 22:55:35 +0100 (Fri, 09 Mar 2012) $
# # Author : $LastChangedBy: martin $
# # Version : 3.1.1
# # Revision : $LastChangedRevision: 1284 $
# #
# #############################################################################
# Translators:
@@ -22,6 +24,7 @@ msgstr ""
"Language: fr_FR\n"
"Plural-Forms: nplurals=2; plural=(n > 1)\n"
"X-Generator: Pootle 2.1.5\n"
"X-Poedit-Basepath: D:\\$_Daten\\Webentwicklung\\NagiosQL_v3.2_svn\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: .\n"

View File

@@ -2,9 +2,11 @@
# #
# # Project : NagiosQL
# # Component : Translation File English
# # Website : https://sourceforge.net/projects/nagiosql/
# # Version : 3.4.0
# # GIT Repo : https://gitlab.com/wizonet/NagiosQL
# # Website : http://www.nagiosql.org
# # Date : $LastChangedDate: 2012-03-09 22:55:35 +0100 (Fri, 09 Mar 2012) $
# # Author : $LastChangedBy: martin $
# # Version : 3.1.1
# # Revision : $LastChangedRevision: 1284 $
# #
# #############################################################################
# Translators:
@@ -22,6 +24,7 @@ msgstr ""
"Language: it_IT\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"X-Generator: Pootle 2.1.5\n"
"X-Poedit-Basepath: D:\\$_Daten\\Webentwicklung\\NagiosQL_v3.2_svn\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: .\n"

View File

@@ -2,9 +2,11 @@
# #
# # Project : NagiosQL
# # Component : Translation File English
# # Website : https://sourceforge.net/projects/nagiosql/
# # Version : 3.4.0
# # GIT Repo : https://gitlab.com/wizonet/NagiosQL
# # Website : http://www.nagiosql.org
# # Date : $LastChangedDate: 2012-03-09 22:55:35 +0100 (Fri, 09 Mar 2012) $
# # Author : $LastChangedBy: martin $
# # Version : 3.1.1
# # Revision : $LastChangedRevision: 1284 $
# #
# #############################################################################
# Translators:
@@ -22,6 +24,7 @@ msgstr ""
"Language: ja_JP\n"
"Plural-Forms: nplurals=1; plural=0\n"
"X-Generator: Pootle 2.1.5\n"
"X-Poedit-Basepath: D:\\$_Daten\\Webentwicklung\\NagiosQL_v3.2_svn\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: .\n"

View File

@@ -2,9 +2,11 @@
# #
# # Project : NagiosQL
# # Component : Translation File English
# # Website : https://sourceforge.net/projects/nagiosql/
# # Version : 3.4.0
# # GIT Repo : https://gitlab.com/wizonet/NagiosQL
# # Website : http://www.nagiosql.org
# # Date : $LastChangedDate: 2012-03-09 22:55:35 +0100 (Fri, 09 Mar 2012) $
# # Author : $LastChangedBy: martin $
# # Version : 3.1.1
# # Revision : $LastChangedRevision: 1284 $
# #
# #############################################################################
# Translators:
@@ -22,6 +24,7 @@ msgstr ""
"Language: nl_NL\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"X-Generator: Pootle 2.1.5\n"
"X-Poedit-Basepath: D:\\$_Daten\\Webentwicklung\\NagiosQL_v3.2_svn\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: .\n"

View File

@@ -2,9 +2,11 @@
# #
# # Project : NagiosQL
# # Component : Translation File English
# # Website : https://sourceforge.net/projects/nagiosql/
# # Version : 3.4.0
# # GIT Repo : https://gitlab.com/wizonet/NagiosQL
# # Website : http://www.nagiosql.org
# # Date : $LastChangedDate: 2012-03-09 22:55:35 +0100 (Fri, 09 Mar 2012) $
# # Author : $LastChangedBy: martin $
# # Version : 3.1.1
# # Revision : $LastChangedRevision: 1284 $
# #
# #############################################################################
# Translators:
@@ -22,6 +24,7 @@ msgstr ""
"Language: pl_PL\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
"X-Generator: Pootle 2.1.5\n"
"X-Poedit-Basepath: D:\\$_Daten\\Webentwicklung\\NagiosQL_v3.2_svn\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: .\n"

File diff suppressed because it is too large Load Diff

View File

@@ -2,9 +2,11 @@
# #
# # Project : NagiosQL
# # Component : Translation File English
# # Website : https://sourceforge.net/projects/nagiosql/
# # Version : 3.4.0
# # GIT Repo : https://gitlab.com/wizonet/NagiosQL
# # Website : http://www.nagiosql.org
# # Date : $LastChangedDate: 2012-03-09 22:55:35 +0100 (Fri, 09 Mar 2012) $
# # Author : $LastChangedBy: martin $
# # Version : 3.1.1
# # Revision : $LastChangedRevision: 1284 $
# #
# #############################################################################
# Translators:
@@ -22,6 +24,7 @@ msgstr ""
"Language: ru_RU\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
"X-Generator: Pootle 2.1.5\n"
"X-Poedit-Basepath: D:\\$_Daten\\Webentwicklung\\NagiosQL_v3.2_svn\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: .\n"

File diff suppressed because it is too large Load Diff

View File

@@ -5,25 +5,27 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2005-2012 by Martin Willisegger
//
// Project : NagiosQL
// Component : CSS Main definition
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1229 $
//
/////////////////////////////////////////////////////////////////////////////*/
body {
font-family: Arial, Helvetica, sans-serif;
background-color: #FFFFFF;
margin: 0;
padding: 0;
margin: 0px;
padding: 0px;
font-size: 12px;
}
#login {
text-align: center;
margin:0 auto;
margin:0pt auto;
max-width:80em;
min-width:740px;
}
@@ -56,7 +58,7 @@ body {
text-decoration: none;
font-weight: bold;
background-color: #FFFFFF;
padding: 2px 3px 0 3px;
padding: 2px 3px 0px 3px;
border-top:1px solid #002C52;
border-left:1px solid #002C52;
border-right:1px solid #002C52;
@@ -94,7 +96,7 @@ body {
/********************/
h1,h2,h3 {
color: #0c4271;
margin-top: 0;
margin-top: 0px;
}
h1 {
text-align: left;
@@ -111,8 +113,8 @@ h3 {
/** Menu **********/
/********************/
.menutable {
margin: 0;
padding: 0;
margin: 0px;
padding: 0px;
border: none;
text-align:left;
}
@@ -123,8 +125,6 @@ h3 {
.menutable a:hover {
color: #FF00FF;
}
/*noinspection ALL*/
.menutable .menu_act {
color: #FF0000;
font-size: 12px;
@@ -155,8 +155,6 @@ h3 {
.menutable .menu a:hover {
color: #FFFFFF;
}
/*noinspection ALL*/
.menutable .menu_sub {
font-size: 11px;
color: #666666;
@@ -172,8 +170,6 @@ h3 {
color: #666666;
text-decoration: underline;
}
/*noinspection ALL*/
.menutable .menu_sub_act {
font-size: 11px;
font-weight: bold;

49
debian/README.Debian vendored Normal file
View File

@@ -0,0 +1,49 @@
NagiosQL for Debian
-------------------
NagiosQL comes with a web based installer. For security reason you have to
enable it manually:
sudo touch /usr/share/nagiosql/htdocs/install/ENABLE_INSTALLER
Start your browser and enter http://<yourhost>/nagiosql.
After installation, you must remove the file ENABLE_INSTALLER, otherwise
you can' start using NagiosQL:
sudo rm /usr/share/nagiosql/htdocs/install/ENABLE_INSTALLER
In the Webfrontend of NagiosQL login in as user Admin and go to
Administration/Domains -> domain 'localhost'. Please check the settings and
change it to your needs.
For security reasons nagios.cfg and cgi.cfg are not writeable to www-data
as NagiosQL request it. You can read the config files through the web
frontend, but not edit. Unfortunately NagiosQL requests a writeable
nagios.cfg for adding domains or changing values of existing domains.
You can perform the following steps to change permissions of nagios.cfg and
cgi.cfg permanently:
dpkg-statoverride --update --add nagios www-data 0664 /etc/nagios4/nagios.cfg
dpkg-statoverride --update --add nagios www-data 0664 /etc/nagios4/cgi.cfg
Additional remarks:
- this package comes with a configured domain 'localhost' and uses the
following pathes:
/etc/nagiosql/domains/localhost = misc nagios objects
/etc/nagiosql/domains/localhost/hosts = host object
/etc/nagiosql/domains/localhost/services = service objects
/etc/nagiosql/domain-backups/localhost
/etc/nagiosql/domain-backups/localhost/hosts
/etc/nagiosql/domain-backups/localhost/services
- add the following line to nagios.cfg:
cfg_dir=/etc/nagiosql/domains/localhost
check the configs via the web interface and reload nagios4:
/etc/init.d/nagios4 reload
-- Wolfgang Barth <wob@swobspace.net> Sat, 13 Jun 2009 12:30:28 +0200

4
debian/README.source vendored Normal file
View File

@@ -0,0 +1,4 @@
This package uses quilt to manage all modifications to the upstream source.
See /usr/share/doc/quilt/README.source for instructions how to generate the
patched source, add a new modification, and remove an existing one.

17
debian/apache.conf vendored Normal file
View File

@@ -0,0 +1,17 @@
Alias /nagiosql "/usr/share/nagiosql/htdocs"
<Directory "/usr/share/nagiosql/htdocs">
Options FollowSymLinks
DirectoryIndex index.php
<IfVersion < 2.3>
Order Allow,Deny
Allow From All
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
</Directory>

26
debian/changelog vendored Normal file
View File

@@ -0,0 +1,26 @@
nagiosql (3.2.0-4) UNRELEASED; urgency=medium
* Bump to 3.2.0 branch with servicepack 3
* drop dpatch and switch to quilt
* switch to nagios4 for default nagios implementation
* many small bugfixes for mysqli
-- Mario Fetka <mario.fetka@gmail.com> Sun, 21 May 2017 19:21:36 +0200
nagiosql (3.0.3-1ubuntu2) lucid; urgency=low
* Add missing dependency - dpatch
-- fenris <fenris@ubuntu.com> Tue, 16 Mar 2010 16:41:12 +0800
nagiosql (3.0.3-1ubuntu1) karmic; urgency=low
* Initial release for Ubuntu
-- fenris <fenris@ubuntu.com> Thu, 04 Feb 2010 20:53:48 +0800
nagiosql (3.0.3-1) unstable; urgency=low
* Initial release (Closes: #0000)
-- Wolfgang Barth <wob@swobspace.net> Sat, 13 Jun 2009 12:30:28 +0200

1
debian/compat vendored Normal file
View File

@@ -0,0 +1 @@
8

32
debian/control vendored Normal file
View File

@@ -0,0 +1,32 @@
Source: nagiosql
Section: net
Priority: optional
Maintainer: fenris@ubuntu.com
XSBC-Original-Maintainer: Wolfgang Barth <wob@swobspace.net>
Build-Depends: debhelper (>= 7), default-mysql-server | mysql-server, php7.0-ldap | php5-ldap , php7.0-mysql | php5-mysql, rsync
Standards-Version: 3.8.0
Homepage: http://www.nagiosql.org
Package: nagiosql
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends}, php-ssh2
Recommends: nagios4
Description: Web based administration tool for Nagios 2 and above
It helps you to easily build a complex configuration with all options,
manage and use them. NagiosQL is based on a webserver with PHP, MySQL and
local file or remote access to the Nagios configuration files.
.
The main features are:
.
* create, delete, modify and copy settings
* create and export configuration files
* create and download configuration files
* easy configuration import
* auto backup configuration files
* consistency checks
* syntax verification
* user management
* instant activation of new configs
* many translations
* easy Installation Wizard
* MySQL database platform

43
debian/copyright vendored Normal file
View File

@@ -0,0 +1,43 @@
This package was debianized by Wolfgang Barth <wob@swobspace.net> on
Sat, 13 Jun 2009 11:16:45 +0200.
It was downloaded from http://www.nagiosql.org
Upstream Authors:
Martin Willisegger
Rouven Homann
Copyright:
Copyright (C) 2008, 2009 by Martin Willisegger
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted under the terms of the BSD License.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
On Debian systems, the complete text of the BSD License can be
found in `/usr/share/common-licenses/BSD'.
NagiosQL comes with tinymce. The license can be found in
usr/share/nagiosql/htdocs/functions/tinyMCE/jscripts/tiny_mce/license.txt.
The Debian packaging is copyright 2009, Wolfgang Barth <wob@swobspace.net> and
is licensed under the GPL version 2, see `/usr/share/common-licenses/GPL-2'.
To build the package, the original tar file nagiosql3xy.tar.gz has to be
repacked. The content of the upstream source is now in the directory
nagiosql-<version>.orig/.

6
debian/dirs vendored Normal file
View File

@@ -0,0 +1,6 @@
usr/share/nagiosql/htdocs
etc/nagiosql
etc/nagiosql/hosts
etc/nagiosql/services
etc/nagiosql/backup/hosts
etc/nagiosql/backup/services

7
debian/docs vendored Normal file
View File

@@ -0,0 +1,7 @@
doc/INSTALLATION_deDE.txt
doc/INSTALLATION_enGB.txt
doc/CHANGELOG
doc/README_SSH_KEY
doc/LICENSE
doc/LIZENZ
README.md

1
debian/links vendored Normal file
View File

@@ -0,0 +1 @@
etc/nagiosql/apache.conf etc/apache2/conf-available/nagiosql.conf

33
debian/nagiosql.1 vendored Normal file
View File

@@ -0,0 +1,33 @@
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH NAGIOSQL SECTION "June 13, 2009"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
nagiosql \- Web based administration tool for Nagios 2 and above
.SH SYNOPSIS
.B http://localhost/nagiosql
.SH DESCRIPTION
nagiosql is web based, so start your browser and enter
http://localhost/nagiosql.
.SH SEE ALSO
.BR /usr/share/doc/nagiosql/*
.br
.BR http://www.nagiosql.org
.SH AUTHOR
nagiosql was written by Martin Willsegger
.PP
This manual page was written by Wolfgang Barth <wob@swobspace.net>,
for the Debian project (and may be used by others).

5
debian/nagiosql.lintian-overrides vendored Normal file
View File

@@ -0,0 +1,5 @@
nagiosql: extra-license-file usr/share/nagiosql/htdocs/functions/tinyMCE/jscripts/tiny_mce/license.txt
nagiosql: embedded-javascript-library usr/share/nagiosql/htdocs/functions/tinyMCE/jscripts/tiny_mce/tiny_mce.js
nagiosql: embedded-javascript-library usr/share/nagiosql/htdocs/functions/tinyMCE/jscripts/tiny_mce/tiny_mce_popup.js
nagiosql: embedded-javascript-library usr/share/nagiosql/htdocs/functions/yui/build/yahoo-dom-event/yahoo-dom-event.js
nagiosql: embedded-javascript-library usr/share/nagiosql/htdocs/install/js/prototype.js

View File

@@ -0,0 +1,280 @@
diff -uNr nagiosql32.orig/admin/contacts.php nagiosql32/admin/contacts.php
--- nagiosql32.orig/admin/contacts.php 2012-04-20 12:39:53.983095000 +0200
+++ nagiosql32/admin/contacts.php 2012-04-20 12:39:56.000000000 +0200
@@ -10,7 +10,7 @@
// Project : NagiosQL
// Component : Contact definitions
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2012-04-20 12:39:53 +0200 (Fri, 20 Apr 2012) $
+// Date : $LastChangedDate: 2012-04-20 12:39:53 +0200 (Fr, 20. Apr 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1323 $
diff -uNr nagiosql32.orig/admin/hosts.php nagiosql32/admin/hosts.php
--- nagiosql32.orig/admin/hosts.php 2012-04-17 12:09:50.082574000 +0200
+++ nagiosql32/admin/hosts.php 2012-04-17 11:54:12.000000000 +0200
@@ -10,10 +10,10 @@
// Project : NagiosQL
// Component : Host definition
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2012-04-17 12:09:50 +0200 (Tue, 17 Apr 2012) $
+// Date : $LastChangedDate: 2012-04-05 08:11:59 +0200 (Do, 05. Apr 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
-// Revision : $LastChangedRevision: 1321 $
+// Revision : $LastChangedRevision: 1315 $
//
///////////////////////////////////////////////////////////////////////////////
//
diff -uNr nagiosql32.orig/admin/services.php nagiosql32/admin/services.php
--- nagiosql32.orig/admin/services.php 2012-04-17 12:09:50.082574000 +0200
+++ nagiosql32/admin/services.php 2012-04-17 11:53:36.000000000 +0200
@@ -10,10 +10,10 @@
// Project : NagiosQL
// Component : Service definition
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2012-04-17 12:09:50 +0200 (Tue, 17 Apr 2012) $
+// Date : $LastChangedDate: 2012-04-05 08:11:59 +0200 (Do, 05. Apr 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
-// Revision : $LastChangedRevision: 1321 $
+// Revision : $LastChangedRevision: 1315 $
//
///////////////////////////////////////////////////////////////////////////////
//
diff -uNr nagiosql32.orig/admin/templatedefinitions.php nagiosql32/admin/templatedefinitions.php
--- nagiosql32.orig/admin/templatedefinitions.php 2012-04-05 08:11:59.091878000 +0200
+++ nagiosql32/admin/templatedefinitions.php 2012-04-05 08:12:08.000000000 +0200
@@ -10,7 +10,7 @@
// Project : NagiosQL
// Component : Template definition list
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2012-04-05 08:11:59 +0200 (Thu, 05 Apr 2012) $
+// Date : $LastChangedDate: 2012-04-05 08:11:59 +0200 (Do, 05. Apr 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1315 $
diff -uNr nagiosql32.orig/functions/config_class.php nagiosql32/functions/config_class.php
--- nagiosql32.orig/functions/config_class.php 2013-01-10 09:46:11.799949000 +0100
+++ nagiosql32/functions/config_class.php 2012-04-17 11:59:16.000000000 +0200
@@ -10,10 +10,10 @@
// Project : NagiosQL
// Component : Configuration Class
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2013-01-10 09:46:11 +0100 (Thu, 10 Jan 2013) $
+// Date : $LastChangedDate: 2012-04-17 11:47:05 +0200 (Di, 17. Apr 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
-// Revision : $LastChangedRevision: 1351 $
+// Revision : $LastChangedRevision: 1319 $
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -710,8 +710,6 @@
} else {
$this->myDataClass->writeLog(translate('Writing of the configuration failed - no dataset or not activated dataset found'));
$this->processClassMessage(translate('Writing of the configuration failed - no dataset or not activated dataset found')."::",$this->strErrorMessage);
- $configtp->parse();
- $booReturn = $this->writeConfigFile($configtp->get(),$strFile,0,$intConfigID,$resConfigFile,$strConfigFile);
return(1);
}
$configtp->parse();
@@ -1254,7 +1252,7 @@
if ($strDataValue == 2) {$strDataValue = "*,";} else {$strDataValue = "";}
foreach ($arrDataRel AS $data) {
if ($data['exclude'] == 0) {
- $strDataValue .= $data['strSlave'].",";
+ $strDataValue .= $data['strSlave'].",";
} else if ($this->intNagVersion >=3) {
$strDataValue .= "!".$data['strSlave'].",";
}
diff -uNr nagiosql32.orig/functions/import_class.php nagiosql32/functions/import_class.php
--- nagiosql32.orig/functions/import_class.php 2012-09-18 10:44:22.198475000 +0200
+++ nagiosql32/functions/import_class.php 2012-04-17 11:47:08.000000000 +0200
@@ -10,10 +10,10 @@
// Project : NagiosQL
// Component : Import Class
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2012-09-18 10:44:22 +0200 (Tue, 18 Sep 2012) $
+// Date : $LastChangedDate: 2012-04-17 11:47:05 +0200 (Di, 17. Apr 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
-// Revision : $LastChangedRevision: 1346 $
+// Revision : $LastChangedRevision: 1319 $
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -899,7 +899,6 @@
$booResult = $this->myDBClass->insertData($strSQL);
if ($booResult == false) $this->strErrorMessage .= $this->myDBClass->strErrorMessage;
$intSlaveId = $this->myDBClass->intLastId;
-
// Special processing for serviceextinfo
if (($strDataTable == "tbl_serviceextinfo") && ($strKey == "service_description")) {
$strSQL = "SELECT `id` FROM `tbl_host` WHERE `host_name`='".$arrImportData['host_name']['value']."'";
@@ -997,7 +996,7 @@
}
// Does the entry already exist?
$strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` $strLink WHERE `".$arrRelData['target1']."` = '".$elem."'
- $strWhere AND `config_id`=".$this->intDomainId;
+ $strWhere AND `active`='1' AND `config_id`=".$this->intDomainId;
$strId = $this->myDBClass->getFieldData($strSQL);
if ($strId != "") {
$intSlaveId = $strId+0;
@@ -1014,7 +1013,7 @@
}
// Insert relations
$strSQL = "INSERT INTO `".$arrRelData['linkTable']."` SET `idMaster` = ".$intDataId.", `idSlave` = ".$intSlaveId.",
- `exclude`=".$intExclude;
+ `exclude`=".$intExclude;
$booResult = $this->myDBClass->insertData($strSQL);
if ($booResult == false) $this->strErrorMessage .= $this->myDBClass->strErrorMessage;
// Keep values
@@ -1105,7 +1104,7 @@
// Process data values
foreach ($arrValues AS $elem) {
// Does the template already exist? (table 1)
- $strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` WHERE `".$arrRelData['target1']."` = '".$elem."'
+ $strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` WHERE `".$arrRelData['target1']."` = '".$elem."' AND `active`='1'
AND `config_id`=".$this->intDomainId;
$strId = $this->myDBClass->getFieldData($strSQL);
if ($strId != "") {
@@ -1114,7 +1113,7 @@
}
if ($intSlaveId == 0) {
// Does the template already exist? (table 2)
- $strSQL = "SELECT `id` FROM `".$arrRelData['tableName2']."` WHERE `".$arrRelData['target2']."` = '".$elem."'
+ $strSQL = "SELECT `id` FROM `".$arrRelData['tableName2']."` WHERE `".$arrRelData['target2']."` = '".$elem."' AND `active`='1'
AND `config_id`=".$this->intDomainId;
$strId = $this->myDBClass->getFieldData($strSQL);
if ($strId != "") {
@@ -1219,8 +1218,7 @@
// Process data values
foreach ($arrValues AS $elem) {
// Does the entry already exist?
- $strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` WHERE `".$arrRelData['target1']."` = '".$elem."'
- AND `config_id`=".$this->intDomainId;
+ $strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` WHERE `".$arrRelData['target1']."` = '".$elem."' AND `active`='1' AND `config_id`=".$this->intDomainId;
$strId = $this->myDBClass->getFieldData($strSQL);
if ($strId != "") {
$intSlaveId = $strId+0;
@@ -1422,7 +1420,7 @@
}
// Does the entry already exist?
$strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` WHERE `".$arrRelData['target1']."` = '".$elem."'
- $strWhere AND `config_id`=".$this->intDomainId;
+ $strWhere AND `active`='1' AND `config_id`=".$this->intDomainId;
$strId = $this->myDBClass->getFieldData($strSQL);
if ($strId != "") {
$intSlaveId = $strId+0;
diff -uNr nagiosql32.orig/functions/prepend_adm.php nagiosql32/functions/prepend_adm.php
--- nagiosql32.orig/functions/prepend_adm.php 2013-01-10 09:46:11.799949000 +0100
+++ nagiosql32/functions/prepend_adm.php 2012-03-27 12:47:58.000000000 +0200
@@ -9,14 +9,14 @@
// Project : NagiosQL
// Component : Preprocessing script
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2013-01-10 09:46:11 +0100 (Thu, 10 Jan 2013) $
+// Date : $LastChangedDate: 2012-03-27 12:47:56 +0200 (Di, 27. Mär 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
-// Revision : $LastChangedRevision: 1351 $
+// Revision : $LastChangedRevision: 1308 $
//
///////////////////////////////////////////////////////////////////////////////
//error_reporting(E_ALL);
-error_reporting(E_ALL & ~E_STRICT);
+error_reporting(E_ALL);
//
// Security Protection
// ===================
@@ -253,7 +253,7 @@
$_SESSION['userid'] = $arrDataUser[0]['id'];
$_SESSION['groupadm'] = $arrDataUser[0]['admin_enable'];
$_SESSION['startsite'] = $_SESSION['SETS']['path']['base_url']."admin.php";
- $_SESSION['timestamp'] = time();
+ $_SESSION['timestamp'] = mktime();
$_SESSION['logged_in'] = 1;
$_SESSION['domain'] = $arrDataUser[0]['domain'];
// Update language settings
@@ -273,10 +273,8 @@
}
}
if (($_SESSION['logged_in'] == 0) && isset($chkInsName) && ($chkInsName != "") && ($intError == 0)) {
- $chkInsName = mysql_real_escape_string($chkInsName);
- $chkInsPasswd = mysql_real_escape_string($chkInsPasswd);
- $strSQL = "SELECT * FROM `tbl_user` WHERE `username`='".$chkInsName."'
- AND `password`=MD5('".$chkInsPasswd."') AND `active`='1'";
+ $strSQL = "SELECT * FROM `tbl_user` WHERE `username`='".mysql_real_escape_string($chkInsName)."'
+ AND `password`=MD5('$chkInsPasswd') AND `active`='1'";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataUser,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
@@ -288,7 +286,7 @@
$_SESSION['userid'] = $arrDataUser[0]['id'];
$_SESSION['groupadm'] = $arrDataUser[0]['admin_enable'];
$_SESSION['startsite'] = $_SESSION['SETS']['path']['base_url'] ."admin.php";
- $_SESSION['timestamp'] = time();
+ $_SESSION['timestamp'] = mktime();
$_SESSION['logged_in'] = 1;
$_SESSION['domain'] = $arrDataUser[0]['domain'];
// Update language settings
@@ -329,9 +327,9 @@
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else if ($intDataCount == 1) {
// Time expired?
- if (time() - $_SESSION['timestamp'] > $_SESSION['SETS']['security']['logofftime']) {
+ if (mktime() - $_SESSION['timestamp'] > $_SESSION['SETS']['security']['logofftime']) {
// Force new login
- $myDataClass->writeLog(translate('Session timeout reached - Seconds:')." ".(time() - $_SESSION['timestamp']." - User: ".$_SESSION['username']));
+ $myDataClass->writeLog(translate('Session timeout reached - Seconds:')." ".(mktime() - $_SESSION['timestamp']." - User: ".$_SESSION['username']));
$_SESSION['logged_in'] = 0;
header("Location: ".$_SESSION['SETS']['path']['protocol']."://".$_SERVER['HTTP_HOST'].$_SESSION['SETS']['path']['base_url']."index.php");
@@ -347,7 +345,7 @@
}
}
// Update login time
- $_SESSION['timestamp'] = time();
+ $_SESSION['timestamp'] = mktime();
if (isset($preContent) && ($preContent == "index.tpl.htm")) {
header("Location: ".$_SESSION['SETS']['path']['protocol']."://".$_SERVER['HTTP_HOST'].$_SESSION['startsite']);
}
diff -uNr nagiosql32.orig/functions/prepend_content.php nagiosql32/functions/prepend_content.php
--- nagiosql32.orig/functions/prepend_content.php 2012-05-03 15:15:32.673020000 +0200
+++ nagiosql32/functions/prepend_content.php 2012-04-04 07:30:16.000000000 +0200
@@ -144,14 +144,14 @@
$chkButValue3 = isset($_POST['butValue3']) ? $_POST['butValue3'] : ""; // Common button value
$chkButValue4 = isset($_POST['butValue4']) ? $_POST['butValue4'] : ""; // Common button value
$chkButValue5 = isset($_POST['butValue5']) ? $_POST['butValue5'] : ""; // Common button value
-$chkTfNullVal1 = (isset($_POST['tfNullVal1']) && ($_POST['tfNullVal1'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal1'])+0 : "NULL"; // Common text NULL field value
-$chkTfNullVal2 = (isset($_POST['tfNullVal2']) && ($_POST['tfNullVal2'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal2'])+0 : "NULL"; // Common text NULL field value
-$chkTfNullVal3 = (isset($_POST['tfNullVal3']) && ($_POST['tfNullVal3'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal3'])+0 : "NULL"; // Common text NULL field value
-$chkTfNullVal4 = (isset($_POST['tfNullVal4']) && ($_POST['tfNullVal4'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal4'])+0 : "NULL"; // Common text NULL field value
-$chkTfNullVal5 = (isset($_POST['tfNullVal5']) && ($_POST['tfNullVal5'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal5'])+0 : "NULL"; // Common text NULL field value
-$chkTfNullVal6 = (isset($_POST['tfNullVal6']) && ($_POST['tfNullVal6'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal6'])+0 : "NULL"; // Common text NULL field value
-$chkTfNullVal7 = (isset($_POST['tfNullVal7']) && ($_POST['tfNullVal7'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal7'])+0 : "NULL"; // Common text NULL field value
-$chkTfNullVal8 = (isset($_POST['tfNullVal8']) && ($_POST['tfNullVal8'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal8'])+0 : "NULL"; // Common text NULL field value
+$chkTfNullVal1 = (isset($_POST['tfNullVal1']) && ($_POST['tfNullVal1'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal1']) : "NULL"; // Common text NULL field value
+$chkTfNullVal2 = (isset($_POST['tfNullVal2']) && ($_POST['tfNullVal2'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal2']) : "NULL"; // Common text NULL field value
+$chkTfNullVal3 = (isset($_POST['tfNullVal3']) && ($_POST['tfNullVal3'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal3']) : "NULL"; // Common text NULL field value
+$chkTfNullVal4 = (isset($_POST['tfNullVal4']) && ($_POST['tfNullVal4'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal4']) : "NULL"; // Common text NULL field value
+$chkTfNullVal5 = (isset($_POST['tfNullVal5']) && ($_POST['tfNullVal5'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal5']) : "NULL"; // Common text NULL field value
+$chkTfNullVal6 = (isset($_POST['tfNullVal6']) && ($_POST['tfNullVal6'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal6']) : "NULL"; // Common text NULL field value
+$chkTfNullVal7 = (isset($_POST['tfNullVal7']) && ($_POST['tfNullVal7'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal7']) : "NULL"; // Common text NULL field value
+$chkTfNullVal8 = (isset($_POST['tfNullVal8']) && ($_POST['tfNullVal8'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal8']) : "NULL"; // Common text NULL field value
//
// Quote special characters
// ==========================
diff -uNr nagiosql32.orig/templates/admin/user.tpl.htm nagiosql32/templates/admin/user.tpl.htm
--- nagiosql32.orig/templates/admin/user.tpl.htm 2012-03-27 12:47:56.208241000 +0200
+++ nagiosql32/templates/admin/user.tpl.htm 2012-03-27 12:47:58.000000000 +0200
@@ -3,7 +3,7 @@
<!-- Project : NagiosQL -->
<!-- Component : User template -->
<!-- Website : http://www.nagiosql.org -->
-<!-- Date : $LastChangedDate: 2012-03-27 12:47:56 +0200 (Tue, 27 Mar 2012) $ -->
+<!-- Date : $LastChangedDate: 2012-03-27 12:47:56 +0200 (Di, 27. Mär 2012) $ -->
<!-- Author : $LastChangedBy: martin $ -->
<!-- Version : 3.2.0 -->
<!-- Revision : $LastChangedRevision: 1308 $ -->

View File

@@ -0,0 +1,248 @@
diff -uNr nagiosql32.orig/admin/verify.php nagiosql32/admin/verify.php
--- nagiosql32.orig/admin/verify.php 2012-09-24 14:42:29.052342000 +0200
+++ nagiosql32/admin/verify.php 2012-09-24 13:42:30.000000000 +0200
@@ -10,7 +10,7 @@
// Project : NagiosQL
// Component : Configuration verification
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2012-09-24 14:42:29 +0200 (Mon, 24 Sep 2012) $
+// Date : $LastChangedDate: 2012-09-24 14:42:29 +0200 (Mo, 24. Sep 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1347 $
diff -uNr nagiosql32.orig/functions/config_class.php nagiosql32/functions/config_class.php
--- nagiosql32.orig/functions/config_class.php 2017-05-20 19:36:57.228000000 +0200
+++ nagiosql32/functions/config_class.php 2013-01-10 09:46:14.000000000 +0100
@@ -10,10 +10,10 @@
// Project : NagiosQL
// Component : Configuration Class
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2012-04-17 11:47:05 +0200 (Di, 17. Apr 2012) $
+// Date : $LastChangedDate: 2013-01-10 09:46:11 +0100 (Do, 10. Jan 2013) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
-// Revision : $LastChangedRevision: 1319 $
+// Revision : $LastChangedRevision: 1351 $
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -710,6 +710,8 @@
} else {
$this->myDataClass->writeLog(translate('Writing of the configuration failed - no dataset or not activated dataset found'));
$this->processClassMessage(translate('Writing of the configuration failed - no dataset or not activated dataset found')."::",$this->strErrorMessage);
+ $configtp->parse();
+ $booReturn = $this->writeConfigFile($configtp->get(),$strFile,0,$intConfigID,$resConfigFile,$strConfigFile);
return(1);
}
$configtp->parse();
@@ -1252,7 +1254,7 @@
if ($strDataValue == 2) {$strDataValue = "*,";} else {$strDataValue = "";}
foreach ($arrDataRel AS $data) {
if ($data['exclude'] == 0) {
- $strDataValue .= $data['strSlave'].",";
+ $strDataValue .= $data['strSlave'].",";
} else if ($this->intNagVersion >=3) {
$strDataValue .= "!".$data['strSlave'].",";
}
diff -uNr nagiosql32.orig/functions/import_class.php nagiosql32/functions/import_class.php
--- nagiosql32.orig/functions/import_class.php 2017-05-20 19:36:57.228000000 +0200
+++ nagiosql32/functions/import_class.php 2012-09-18 09:44:24.000000000 +0200
@@ -10,10 +10,10 @@
// Project : NagiosQL
// Component : Import Class
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2012-04-17 11:47:05 +0200 (Di, 17. Apr 2012) $
+// Date : $LastChangedDate: 2012-09-18 10:44:22 +0200 (Di, 18. Sep 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
-// Revision : $LastChangedRevision: 1319 $
+// Revision : $LastChangedRevision: 1346 $
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -899,6 +899,7 @@
$booResult = $this->myDBClass->insertData($strSQL);
if ($booResult == false) $this->strErrorMessage .= $this->myDBClass->strErrorMessage;
$intSlaveId = $this->myDBClass->intLastId;
+
// Special processing for serviceextinfo
if (($strDataTable == "tbl_serviceextinfo") && ($strKey == "service_description")) {
$strSQL = "SELECT `id` FROM `tbl_host` WHERE `host_name`='".$arrImportData['host_name']['value']."'";
@@ -996,7 +997,7 @@
}
// Does the entry already exist?
$strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` $strLink WHERE `".$arrRelData['target1']."` = '".$elem."'
- $strWhere AND `active`='1' AND `config_id`=".$this->intDomainId;
+ $strWhere AND `config_id`=".$this->intDomainId;
$strId = $this->myDBClass->getFieldData($strSQL);
if ($strId != "") {
$intSlaveId = $strId+0;
@@ -1013,7 +1014,7 @@
}
// Insert relations
$strSQL = "INSERT INTO `".$arrRelData['linkTable']."` SET `idMaster` = ".$intDataId.", `idSlave` = ".$intSlaveId.",
- `exclude`=".$intExclude;
+ `exclude`=".$intExclude;
$booResult = $this->myDBClass->insertData($strSQL);
if ($booResult == false) $this->strErrorMessage .= $this->myDBClass->strErrorMessage;
// Keep values
@@ -1104,7 +1105,7 @@
// Process data values
foreach ($arrValues AS $elem) {
// Does the template already exist? (table 1)
- $strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` WHERE `".$arrRelData['target1']."` = '".$elem."' AND `active`='1'
+ $strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` WHERE `".$arrRelData['target1']."` = '".$elem."'
AND `config_id`=".$this->intDomainId;
$strId = $this->myDBClass->getFieldData($strSQL);
if ($strId != "") {
@@ -1113,7 +1114,7 @@
}
if ($intSlaveId == 0) {
// Does the template already exist? (table 2)
- $strSQL = "SELECT `id` FROM `".$arrRelData['tableName2']."` WHERE `".$arrRelData['target2']."` = '".$elem."' AND `active`='1'
+ $strSQL = "SELECT `id` FROM `".$arrRelData['tableName2']."` WHERE `".$arrRelData['target2']."` = '".$elem."'
AND `config_id`=".$this->intDomainId;
$strId = $this->myDBClass->getFieldData($strSQL);
if ($strId != "") {
@@ -1218,7 +1219,8 @@
// Process data values
foreach ($arrValues AS $elem) {
// Does the entry already exist?
- $strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` WHERE `".$arrRelData['target1']."` = '".$elem."' AND `active`='1' AND `config_id`=".$this->intDomainId;
+ $strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` WHERE `".$arrRelData['target1']."` = '".$elem."'
+ AND `config_id`=".$this->intDomainId;
$strId = $this->myDBClass->getFieldData($strSQL);
if ($strId != "") {
$intSlaveId = $strId+0;
@@ -1420,7 +1422,7 @@
}
// Does the entry already exist?
$strSQL = "SELECT `id` FROM `".$arrRelData['tableName1']."` WHERE `".$arrRelData['target1']."` = '".$elem."'
- $strWhere AND `active`='1' AND `config_id`=".$this->intDomainId;
+ $strWhere AND `config_id`=".$this->intDomainId;
$strId = $this->myDBClass->getFieldData($strSQL);
if ($strId != "") {
$intSlaveId = $strId+0;
diff -uNr nagiosql32.orig/functions/nag_class.php nagiosql32/functions/nag_class.php
--- nagiosql32.orig/functions/nag_class.php 2012-10-03 10:00:02.307645000 +0200
+++ nagiosql32/functions/nag_class.php 2012-10-03 09:00:04.000000000 +0200
@@ -10,7 +10,7 @@
// Project : NagiosQL
// Component : Visualization Class
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2012-10-03 10:00:02 +0200 (Wed, 03 Oct 2012) $
+// Date : $LastChangedDate: 2012-10-03 10:00:02 +0200 (Mi, 03. Okt 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1349 $
diff -uNr nagiosql32.orig/functions/prepend_adm.php nagiosql32/functions/prepend_adm.php
--- nagiosql32.orig/functions/prepend_adm.php 2017-05-20 19:36:57.232000000 +0200
+++ nagiosql32/functions/prepend_adm.php 2013-01-10 09:46:14.000000000 +0100
@@ -9,14 +9,14 @@
// Project : NagiosQL
// Component : Preprocessing script
// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2012-03-27 12:47:56 +0200 (Di, 27. Mär 2012) $
+// Date : $LastChangedDate: 2013-01-10 09:46:11 +0100 (Do, 10. Jan 2013) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
-// Revision : $LastChangedRevision: 1308 $
+// Revision : $LastChangedRevision: 1351 $
//
///////////////////////////////////////////////////////////////////////////////
//error_reporting(E_ALL);
-error_reporting(E_ALL);
+error_reporting(E_ALL & ~E_STRICT);
//
// Security Protection
// ===================
@@ -253,7 +253,7 @@
$_SESSION['userid'] = $arrDataUser[0]['id'];
$_SESSION['groupadm'] = $arrDataUser[0]['admin_enable'];
$_SESSION['startsite'] = $_SESSION['SETS']['path']['base_url']."admin.php";
- $_SESSION['timestamp'] = mktime();
+ $_SESSION['timestamp'] = time();
$_SESSION['logged_in'] = 1;
$_SESSION['domain'] = $arrDataUser[0]['domain'];
// Update language settings
@@ -273,8 +273,10 @@
}
}
if (($_SESSION['logged_in'] == 0) && isset($chkInsName) && ($chkInsName != "") && ($intError == 0)) {
- $strSQL = "SELECT * FROM `tbl_user` WHERE `username`='".mysql_real_escape_string($chkInsName)."'
- AND `password`=MD5('$chkInsPasswd') AND `active`='1'";
+ $chkInsName = mysql_real_escape_string($chkInsName);
+ $chkInsPasswd = mysql_real_escape_string($chkInsPasswd);
+ $strSQL = "SELECT * FROM `tbl_user` WHERE `username`='".$chkInsName."'
+ AND `password`=MD5('".$chkInsPasswd."') AND `active`='1'";
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataUser,$intDataCount);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
@@ -286,7 +288,7 @@
$_SESSION['userid'] = $arrDataUser[0]['id'];
$_SESSION['groupadm'] = $arrDataUser[0]['admin_enable'];
$_SESSION['startsite'] = $_SESSION['SETS']['path']['base_url'] ."admin.php";
- $_SESSION['timestamp'] = mktime();
+ $_SESSION['timestamp'] = time();
$_SESSION['logged_in'] = 1;
$_SESSION['domain'] = $arrDataUser[0]['domain'];
// Update language settings
@@ -327,9 +329,9 @@
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
} else if ($intDataCount == 1) {
// Time expired?
- if (mktime() - $_SESSION['timestamp'] > $_SESSION['SETS']['security']['logofftime']) {
+ if (time() - $_SESSION['timestamp'] > $_SESSION['SETS']['security']['logofftime']) {
// Force new login
- $myDataClass->writeLog(translate('Session timeout reached - Seconds:')." ".(mktime() - $_SESSION['timestamp']." - User: ".$_SESSION['username']));
+ $myDataClass->writeLog(translate('Session timeout reached - Seconds:')." ".(time() - $_SESSION['timestamp']." - User: ".$_SESSION['username']));
$_SESSION['logged_in'] = 0;
header("Location: ".$_SESSION['SETS']['path']['protocol']."://".$_SERVER['HTTP_HOST'].$_SESSION['SETS']['path']['base_url']."index.php");
@@ -345,7 +347,7 @@
}
}
// Update login time
- $_SESSION['timestamp'] = mktime();
+ $_SESSION['timestamp'] = time();
if (isset($preContent) && ($preContent == "index.tpl.htm")) {
header("Location: ".$_SESSION['SETS']['path']['protocol']."://".$_SERVER['HTTP_HOST'].$_SESSION['startsite']);
}
diff -uNr nagiosql32.orig/functions/prepend_content.php nagiosql32/functions/prepend_content.php
--- nagiosql32.orig/functions/prepend_content.php 2017-05-20 19:36:57.232000000 +0200
+++ nagiosql32/functions/prepend_content.php 2012-05-03 08:10:06.000000000 +0200
@@ -144,14 +144,14 @@
$chkButValue3 = isset($_POST['butValue3']) ? $_POST['butValue3'] : ""; // Common button value
$chkButValue4 = isset($_POST['butValue4']) ? $_POST['butValue4'] : ""; // Common button value
$chkButValue5 = isset($_POST['butValue5']) ? $_POST['butValue5'] : ""; // Common button value
-$chkTfNullVal1 = (isset($_POST['tfNullVal1']) && ($_POST['tfNullVal1'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal1']) : "NULL"; // Common text NULL field value
-$chkTfNullVal2 = (isset($_POST['tfNullVal2']) && ($_POST['tfNullVal2'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal2']) : "NULL"; // Common text NULL field value
-$chkTfNullVal3 = (isset($_POST['tfNullVal3']) && ($_POST['tfNullVal3'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal3']) : "NULL"; // Common text NULL field value
-$chkTfNullVal4 = (isset($_POST['tfNullVal4']) && ($_POST['tfNullVal4'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal4']) : "NULL"; // Common text NULL field value
-$chkTfNullVal5 = (isset($_POST['tfNullVal5']) && ($_POST['tfNullVal5'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal5']) : "NULL"; // Common text NULL field value
-$chkTfNullVal6 = (isset($_POST['tfNullVal6']) && ($_POST['tfNullVal6'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal6']) : "NULL"; // Common text NULL field value
-$chkTfNullVal7 = (isset($_POST['tfNullVal7']) && ($_POST['tfNullVal7'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal7']) : "NULL"; // Common text NULL field value
-$chkTfNullVal8 = (isset($_POST['tfNullVal8']) && ($_POST['tfNullVal8'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal8']) : "NULL"; // Common text NULL field value
+$chkTfNullVal1 = (isset($_POST['tfNullVal1']) && ($_POST['tfNullVal1'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal1'])+0 : "NULL"; // Common text NULL field value
+$chkTfNullVal2 = (isset($_POST['tfNullVal2']) && ($_POST['tfNullVal2'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal2'])+0 : "NULL"; // Common text NULL field value
+$chkTfNullVal3 = (isset($_POST['tfNullVal3']) && ($_POST['tfNullVal3'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal3'])+0 : "NULL"; // Common text NULL field value
+$chkTfNullVal4 = (isset($_POST['tfNullVal4']) && ($_POST['tfNullVal4'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal4'])+0 : "NULL"; // Common text NULL field value
+$chkTfNullVal5 = (isset($_POST['tfNullVal5']) && ($_POST['tfNullVal5'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal5'])+0 : "NULL"; // Common text NULL field value
+$chkTfNullVal6 = (isset($_POST['tfNullVal6']) && ($_POST['tfNullVal6'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal6'])+0 : "NULL"; // Common text NULL field value
+$chkTfNullVal7 = (isset($_POST['tfNullVal7']) && ($_POST['tfNullVal7'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal7'])+0 : "NULL"; // Common text NULL field value
+$chkTfNullVal8 = (isset($_POST['tfNullVal8']) && ($_POST['tfNullVal8'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal8'])+0 : "NULL"; // Common text NULL field value
//
// Quote special characters
// ==========================
diff -uNr nagiosql32.orig/templates/admin/servicedependencies.tpl.htm nagiosql32/templates/admin/servicedependencies.tpl.htm
--- nagiosql32.orig/templates/admin/servicedependencies.tpl.htm 2013-01-10 09:46:11.799949000 +0100
+++ nagiosql32/templates/admin/servicedependencies.tpl.htm 2013-01-10 09:46:14.000000000 +0100
@@ -3,7 +3,7 @@
<!-- Project : NagiosQL -->
<!-- Component : servicedependencies template -->
<!-- Website : http://www.nagiosql.org -->
-<!-- Date : $LastChangedDate: 2013-01-10 09:46:11 +0100 (Thu, 10 Jan 2013) $ -->
+<!-- Date : $LastChangedDate: 2013-01-10 09:46:11 +0100 (Do, 10. Jan 2013) $ -->
<!-- Author : $LastChangedBy: martin $ -->
<!-- Version : 3.2.0 -->
<!-- Revision : $LastChangedRevision: 1351 $ -->

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,68 @@
diff -uNr nagiosql32/functions/data_class.php nsql/functions/data_class.php
--- nagiosql32/functions/data_class.php 2017-05-21 04:16:26.144000000 +0200
+++ nsql/functions/data_class.php 2017-01-06 14:55:10.000000000 +0100
@@ -110,7 +110,7 @@
$strSQL = "DELETE FROM `".$strTableName."` WHERE `id` = $intDataId $strNoDelete";
$booReturn = $this->myDBClass->insertData($strSQL);
if ($booReturn == false) {
- $this->processClassMessage(translate('Delete failed because a database error:')."::".mysql_error()."::",$this->strInfoMessage);
+ $this->processClassMessage(translate('Delete failed because a database error:')."::".mysqli_error()."::",$this->strInfoMessage);
return(1);
} else if ($this->myDBClass->intAffectedRows == 0) {
$this->processClassMessage(translate('No data deleted. Probably the dataset does not exist or it is protected from delete.')."::",$this->strErrorMessage);
@@ -134,7 +134,7 @@
$strSQL = "DELETE FROM `".$strTableName."` WHERE `id` = ".$elem['id'];
$booReturn = $this->myDBClass->insertData($strSQL);
if ($booReturn == false) {
- $this->processClassMessage(translate('Delete failed because a database error:')."::".mysql_error()."::",$this->strInfoMessage);
+ $this->processClassMessage(translate('Delete failed because a database error:')."::".mysqli_error()."::",$this->strInfoMessage);
return(1);
} else {
$intDeleteCount = $intDeleteCount + $this->myDBClass->intAffectedRows;
diff -uNr nagiosql32/functions/import_class.php nsql/functions/import_class.php
--- nagiosql32/functions/import_class.php 2017-05-21 04:16:11.976000000 +0200
+++ nsql/functions/import_class.php 2017-01-04 13:11:32.000000000 +0100
@@ -632,8 +632,8 @@
if ($strKeyField == "") {$strKey = $strConfigName;} else {$strKey = $strKeyField;}
if ($booResult != true) {
$this->strErrorMessage .= $this->myDBClass->strErrorMessage;
- if ($strKeyField != "") $this->strErrorMessage .= translate('Entry')." <b class=\"blackmessage\">".$strKey." -> ".$arrImportData[$strKeyField]['value']."</b> ".translate('inside')." <b class=\"blackmessage\">".$strTable."</b> ".translate('could not be inserted:')." ".mysql_error()."::";
- if ($strKeyField == "") $this->strErrorMessage .= translate('Entry')." <b class=\"blackmessage\">".$strTemp1." -> ".$strTemp2.translate('inside')."</b> ".$strTable." <b class=\"blackmessage\">".$strTable."</b> ".translate('could not be inserted:')." ".mysql_error()."::";
+ if ($strKeyField != "") $this->strErrorMessage .= translate('Entry')." <b class=\"blackmessage\">".$strKey." -> ".$arrImportData[$strKeyField]['value']."</b> ".translate('inside')." <b class=\"blackmessage\">".$strTable."</b> ".translate('could not be inserted:')." ".mysqli_error()."::";
+ if ($strKeyField == "") $this->strErrorMessage .= translate('Entry')." <b class=\"blackmessage\">".$strTemp1." -> ".$strTemp2.translate('inside')."</b> ".$strTable." <b class=\"blackmessage\">".$strTable."</b> ".translate('could not be inserted:')." ".mysqli_error()."::";
return(1);
} else {
if ($strKeyField != "") $this->strInfoMessage .= translate('Entry')." <b class=\"blackmessage\">".$strKey." -> ".$arrImportData[$strKeyField]['value']."</b> ".translate('inside')." <b class=\"blackmessage\">".$strTable."</b> ".translate('successfully inserted')."::";
@@ -1236,7 +1236,7 @@
// Update data in master table
$arrCommand[0] = $intSlaveId;
$strValue = implode("!",$arrCommand);
- $strSQL = "UPDATE `".$strDataTable."` SET `".$arrRelData['fieldName']."` = '".mysql_real_escape_string($strValue)."' WHERE `id` = ".$intDataId;
+ $strSQL = "UPDATE `".$strDataTable."` SET `".$arrRelData['fieldName']."` = '".mysqli_real_escape_string($strValue)."' WHERE `id` = ".$intDataId;
$booResult = $this->myDBClass->insertData($strSQL);
if ($booResult == false) $this->strErrorMessage .= $this->myDBClass->strErrorMessage;
}
diff -uNr nagiosql32/functions/mysql_class.php nsql/functions/mysql_class.php
--- nagiosql32/functions/mysql_class.php 2017-05-21 04:16:26.144000000 +0200
+++ nsql/functions/mysql_class.php 2017-01-06 14:55:18.000000000 +0100
@@ -330,7 +330,7 @@
//
///////////////////////////////////////////////////////////////////////////////////////////
function dbdisconnect() {
- @mysql_close($this->strDBId);
+ @mysqli_close($this->strDBId);
return true;
}
diff -uNr nagiosql32/functions/prepend_content.php nsql/functions/prepend_content.php
--- nagiosql32/functions/prepend_content.php 2017-05-21 04:16:11.980000000 +0200
+++ nsql/functions/prepend_content.php 2017-01-06 15:15:59.000000000 +0100
@@ -321,7 +321,7 @@
if ($intSuccess != 0) $myVisClass->processMessage(translate('Configuration files successfully written!'),$strInfoMessage);
if ($intError != 0) $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, not found or you do not have write permission!'),$strErrorMessage);
} else if ($preTableName == 'tbl_service') {
- $strSQL = "SELECT `id`, `$preKeyField` FROM `$preTableName` WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1' GROUP BY `$preKeyField`";
+ $strSQL = "SELECT `id`, `$preKeyField` FROM `$preTableName` WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1' GROUP BY `$preKeyField`, `id`";
$myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
if ($booReturn && ($intDataCount != 0)) {

94
debian/patches/40_settings_php.patch vendored Normal file
View File

@@ -0,0 +1,94 @@
diff -uNr nagiosql32.orig/admin/settings.php nagiosql32/admin/settings.php
--- nagiosql32.orig/admin/settings.php 2012-02-21 14:10:41.579203000 +0100
+++ nagiosql32/admin/settings.php 2017-05-20 20:02:31.568000000 +0200
@@ -92,8 +92,8 @@
}
}
// Write db settings to file
- if (is_writable($strBasePath."config/settings.php")) {
- $filSettings = fopen($strBasePath."config/settings.php","w");
+ if (is_writable("/etc/nagiosql/settings.php")) {
+ $filSettings = fopen("/etc/nagiosql/settings.php","w");
if ($filSettings) {
fwrite($filSettings,"<?php\n");
fwrite($filSettings,"exit;\n");
diff -uNr nagiosql32.orig/admin/support.php nagiosql32/admin/support.php
--- nagiosql32.orig/admin/support.php 2012-03-08 08:40:12.245037000 +0100
+++ nagiosql32/admin/support.php 2017-05-20 20:01:59.792000000 +0200
@@ -211,7 +211,7 @@
}
// File access checks
$conttp->setVariable("RW_CONFIG",translate("Read/Write access:")." settings.php");
-$strConfigFile = "../config/settings.php";
+$strConfigFile = "/etc/nagiosql/settings.php";
if (file_exists($strConfigFile) && is_readable($strConfigFile) && is_writable($strConfigFile)) {
$conttp->setVariable("RW_CONFIG_CLASS","checkgreen");
$conttp->setVariable("RW_CONFIG_RESULT",translate("ok"));
diff -uNr nagiosql32.orig/functions/prepend_adm.php nagiosql32/functions/prepend_adm.php
--- nagiosql32.orig/functions/prepend_adm.php 2017-05-20 20:08:12.900000000 +0200
+++ nagiosql32/functions/prepend_adm.php 2017-05-20 20:04:18.164000000 +0200
@@ -77,14 +77,14 @@
//
// Start installer
// ===============
-$preIniFile = $preBasePath.'config/settings.php';
+$preIniFile = '/etc/nagiosql/settings.php';
if (!file_exists($preIniFile) OR ! is_readable($preIniFile)) {
header("Location: ".$preBaseURL."install/index.php");
}
//
// Read file settings
// ==================
-$SETS = parse_ini_file($preBasePath.'config/settings.php',true);
+$SETS = parse_ini_file('/etc/nagiosql/settings.php',true);
if (!isset($_SESSION['SETS']['db'])) $_SESSION['SETS']['db'] = $SETS['db'];
//
// Include external function/class files - part 1
diff -uNr nagiosql32.orig/functions/prepend_scripting.php nagiosql32/functions/prepend_scripting.php
--- nagiosql32.orig/functions/prepend_scripting.php 2012-02-29 09:54:45.611973000 +0100
+++ nagiosql32/functions/prepend_scripting.php 2017-05-20 20:03:34.636000000 +0200
@@ -42,7 +42,7 @@
// Read settings file
// ==================
$preBasePath = str_replace("scripts","",getcwd());
-$preIniFile = $preBasePath.'config/settings.php';
+$preIniFile = '/etc/nagiosql/settings.php';
//
// Read file settings
// ==================
diff -uNr nagiosql32.orig/install/functions/install_class.php nagiosql32/install/functions/install_class.php
--- nagiosql32.orig/install/functions/install_class.php 2017-05-20 20:08:12.900000000 +0200
+++ nagiosql32/install/functions/install_class.php 2017-05-20 20:05:46.564000000 +0200
@@ -659,7 +659,7 @@
$strBasePath = substr(realpath('.'),0,-7);
$strE_ID = error_reporting();
error_reporting(0);
- $filSettings = fopen($strBasePath."config/settings.php","w");
+ $filSettings = fopen("/etc/nagiosql/settings.php","w");
error_reporting($strE_ID);
if ($filSettings) {
// Write Database Configuration into settings.php
diff -uNr nagiosql32.orig/install/index.php nagiosql32/install/index.php
--- nagiosql32.orig/install/index.php 2017-05-20 20:08:12.904000000 +0200
+++ nagiosql32/install/index.php 2017-05-20 20:04:52.492000000 +0200
@@ -27,7 +27,7 @@
$preContent = "templates/index.tpl.htm";
$preEncode = 'utf-8';
$preLocale = "../config/locale";
-$filConfig = "../config/settings.php";
+$filConfig = "/etc/nagiosql/settings.php";
$preDBType = "mysqli";
$strLangOpt = "";
$intError = 0;
diff -uNr nagiosql32.orig/install/step1.php nagiosql32/install/step1.php
--- nagiosql32.orig/install/step1.php 2017-05-20 20:08:12.904000000 +0200
+++ nagiosql32/install/step1.php 2017-05-20 20:05:19.420000000 +0200
@@ -186,7 +186,7 @@
}
$arrTemplate['CHECK_5_CONTENT_1'] = $strHTML;
// File access checks
-$strConfigFile = "../config/settings.php";
+$strConfigFile = "/etc/nagiosql/settings.php";
if (file_exists($strConfigFile) && is_readable($strConfigFile)) {
$arrTemplate['CHECK_6_CONTENT_1'] = $strHTMLPart1.translate("Read test on settings file (config/settings.php)").$strHTMLPart4.translate("OK")."</span><br>\n";
} else if (file_exists($strConfigFile)&& !is_readable($strConfigFile)) {

View File

@@ -0,0 +1,12 @@
diff -uNr nagiosql32.orig/install/sql/nagiosQL_v32_db_mysql.sql nagiosql32/install/sql/nagiosQL_v32_db_mysql.sql
--- nagiosql32.orig/install/sql/nagiosQL_v32_db_mysql.sql 2012-03-01 12:24:44.682770000 +0100
+++ nagiosql32/install/sql/nagiosQL_v32_db_mysql.sql 2017-05-20 20:31:30.760000000 +0200
@@ -83,7 +83,7 @@
-- Datasets for table `tbl_configtarget`
--
-INSERT INTO `tbl_configtarget` (`id`, `target`, `alias`, `server`, `method`, `user`, `password`, `ssh_key_path`, `basedir`, `hostconfig`, `serviceconfig`, `backupdir`, `hostbackup`, `servicebackup`, `nagiosbasedir`, `importdir`, `picturedir`, `commandfile`, `binaryfile`, `pidfile`, `conffile`, `version`, `access_group`, `active`, `nodelete`, `last_modified`) VALUES(1, 'localhost', 'Local installation', 'localhost', '1', '', '', '', '/etc/nagiosql/', '/etc/nagiosql/hosts/', '/etc/nagiosql/services/', '/etc/nagiosql/backup/', '/etc/nagiosql/backup/hosts/', '/etc/nagiosql/backup/services/', '/etc/nagiosql/', '/opt/nagios/etc/objects/', '', '/var/nagios/rw/nagios.cmd', '/opt/nagios/bin/nagios', '/var/nagios/nagios.lock', '/etc/nagiosql/nagios.cfg', 3, 0, '1', '1', NOW());
+INSERT INTO `tbl_configtarget` (`id`, `target`, `alias`, `server`, `method`, `user`, `password`, `ssh_key_path`, `basedir`, `hostconfig`, `serviceconfig`, `backupdir`, `hostbackup`, `servicebackup`, `nagiosbasedir`, `importdir`, `picturedir`, `commandfile`, `binaryfile`, `pidfile`, `conffile`, `version`, `access_group`, `active`, `nodelete`, `last_modified`) VALUES(1, 'localhost', 'Local installation', 'localhost', '1', '', '', '', '/etc/nagiosql/', '/etc/nagiosql/hosts/', '/etc/nagiosql/services/', '/etc/nagiosql/backup/', '/etc/nagiosql/backup/hosts/', '/etc/nagiosql/backup/services/', '/etc/nagiosql/', '/etc/nagios4/objects/', '', '/var/lib/nagios4/rw/nagios.cmd', '/usr/sbin/nagios4', '/var/run/nagios4/nagios4.pid', '/etc/nagios4/nagios.cfg', 3, 0, '1', '1', NOW());
-- --------------------------------------------------------

View File

@@ -0,0 +1,34 @@
--- nagiosql-3.0.3.orig/debian/patches/30_nagios3_configs_readonly.dpatch
+++ nagiosql-3.0.3/debian/patches/30_nagios3_configs_readonly.dpatch
@@ -0,0 +1,31 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 30_nagios3_configs_readonly.dpatch by <wob@swobspace.eli.st-elisabeth.de>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+@DPATCH@
+diff -urNad nagiosql-3.0.3~/nagiosql3/admin/domain.php nagiosql-3.0.3/nagiosql3/admin/domain.php
+--- nagiosql-3.0.3~/nagiosql3/admin/domain.php 2009-04-28 15:02:27.000000000 +0200
++++ nagiosql-3.0.3/nagiosql3/admin/domain.php 2009-06-14 14:18:09.000000000 +0200
+@@ -154,11 +154,11 @@
+ }
+ // Nagios base configuration files
+ if (isset($chkInsNagiosBaseDir)) {
+- if (! is_writable($chkInsNagiosBaseDir."nagios.cfg")) {
++ if (! is_readable($chkInsNagiosBaseDir."nagios.cfg")) {
+ $permissionerror .= $chkInsNagiosBaseDir."nagios.cfg ".gettext("is not writeable")."<br>";
+ $isanerror=1;
+ }
+- if (! is_writable($chkInsNagiosBaseDir."cgi.cfg")) {
++ if (! is_readable($chkInsNagiosBaseDir."cgi.cfg")) {
+ $permissionerror .= $chkInsNagiosBaseDir."cgi.cfg ".gettext("is not writeable")."<br>";
+ $isanerror=1;
+ }
+@@ -411,4 +411,4 @@
+ $maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> - Version: $setFileVersion");
+ $maintp->parse("footer");
+ $maintp->show("footer");
+-?>
+\ No newline at end of file
++?>

7
debian/patches/series vendored Normal file
View File

@@ -0,0 +1,7 @@
10_service_pack_1_additional_fixes_only.patch
20_service_pack_2_additional_fixes_only.patch
30_service_pack_3_additional_fixes_only.patch
31_service_pack_3_additional_fixes_only_mysqli.patch
40_settings_php.patch
50_nagios4_debian_pathes.patch
60_nagios4_configs_readonly.patch

78
debian/postinst vendored Normal file
View File

@@ -0,0 +1,78 @@
#!/bin/sh
# postinst script for nagiosql
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
setperm() {
user="$1"
group="$2"
mode="$3"
file="$4"
shift 4
# only do something when no setting exists
if ! dpkg-statoverride --list "$file" >/dev/null 2>&1; then
chown "$user":"$group" "$file"
chmod "$mode" "$file"
fi
}
setgrperm() {
group="$1"
mode="$2"
file="$3"
shift 3
# only do something when no setting exists
if ! dpkg-statoverride --list "$file" >/dev/null 2>&1; then
chgrp "$group" "$file"
chmod "$mode" "$file"
fi
}
case "$1" in
configure)
# -- /etc/nagiosql directories
for dir in `find /etc/nagiosql -type d 2> /dev/null`; do
[ -d $dir ] && setperm www-data nagios 6755 $dir
done
# -- /etc/nagiosql files
for file in `find /etc/nagiosql -type f -name \*.cfg 2> /dev/null`; do
[ -f $file ] && setperm www-data nagios 0644 $file
done
# -- /etc/nagios4 config files
for cfg in /etc/nagios4/nagios.cfg /etc/nagios/nagios4/cgi.cfg ; do
[ -e $cfg ] && setgrperm www-data 0644 $cfg
done
# -- at last
nsqlcfg="/etc/nagiosql/settings.php"
[ -e $nsqlcfg ] && setperm www-data www-data 0600 $nsqlcfg
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

40
debian/prerm vendored Normal file
View File

@@ -0,0 +1,40 @@
#!/bin/sh
# prerm script for nagiosql
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <prerm> `remove'
# * <old-prerm> `upgrade' <new-version>
# * <new-prerm> `failed-upgrade' <old-version>
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
# * <deconfigured's-prerm> `deconfigure' `in-favour'
# <package-being-installed> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
remove|upgrade|deconfigure)
ENABLER="/usr/share/nagiosql/htdocs/install/ENABLE_INSTALLER"
[ -e $ENABLER ] && rm -f $ENABLER
;;
failed-upgrade)
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

82
debian/rules vendored Executable file
View File

@@ -0,0 +1,82 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
DESTDIR = debian/nagiosql
configure: configure-stamp
configure-stamp:
dh_testdir
# Add here commands to configure the package.
touch configure-stamp
build: build-stamp
build-stamp: configure-stamp
dh_testdir
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
dh_clean
install: build
dh_testdir
dh_testroot
dh_prep
dh_installdirs
# cp -a nagiosql3/* $(DESTDIR)/usr/share/nagiosql/htdocs/.
mkdir -p $(CURDIR)/$(DESTDIR)/usr/share/nagiosql/htdocs/
rsync -avr --exclude 'debian' --exclude '*-stamp' --exclude '.pc' $(CURDIR)/ $(CURDIR)/$(DESTDIR)/usr/share/nagiosql/htdocs/
rm -rf $(DESTDIR)/usr/share/nagiosql/htdocs/doc
rm -rf $(DESTDIR)/usr/share/nagiosql/htdocs/README.md
install -m 644 debian/apache.conf $(DESTDIR)/etc/nagiosql/
# Build architecture-dependent files here.
binary-arch: install
# Build architecture-independent files here.
binary-indep: install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
dh_lintian
# dh_install
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_python
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
dh_link
# dh_strip
dh_compress
dh_fixperms
# dh_perl
# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

1
debian/source/format vendored Normal file
View File

@@ -0,0 +1 @@
3.0 (quilt)

25
doc/CHANGELOG Normal file → Executable file
View File

@@ -1,21 +1,3 @@
CHANGELOG 3.4.0
---------------
- Support for PHP 7.x (developped and tested with PHP 7.2.4)
- Support for PHP < 5.5 dropped
- Code reworked to follow PSR1/PSR2 standards
- New class autoloader function
- Several minor bugfixes
- Moved sourcecode to GitLab
- FTP now supports encrypted communication (FTPS) - new option in config targets
- Full support for Nagios 4.x added (importance and service parents)
- Nagios cgi.cfg path is now handled by NagiosQL
- Nagios ressource.cfg path is now handled by NagiosQL
CHANGELOG 3.3.0
---------------
- [OK] Support for PHP version 7.0 (not 7.1 or higher)
- [OK] Database interface changed from mysql to mysqli
CHANGELOG 3.2.0
---------------
@@ -32,3 +14,10 @@ CHANGELOG 3.2.0
- [OK] Servicegroup support for servicedependencies and serviceescalations
- [OK][BUG] Reworked service selection in servicedependencies and serviceescalations
- [OK][BUG] Reworked right management (menu access / read rights)
OPEN in 3.2.0
-------------
- YUI3 - YUI3 is still BETA
- Reworking templates for better integration
- Support for different time zones of remote systems (timestamp/file_stamp)
- PosgresQL support (comes with 3.2.x)

View File

@@ -4,13 +4,16 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2008-2012 by Martin Willisegger
//
// Project : NagiosQL
// Component : Installations HowTo
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Project : NagiosQL
// Component: Installations HowTo
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-12 08:30:07 +0100 (Mon, 12 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1288 $
// SVN-ID : $Id: INSTALLATION_deDE.txt 1288 2012-03-12 07:30:07Z martin $
//
///////////////////////////////////////////////////////////////////////////////
@@ -19,11 +22,11 @@
====================
* Webserver z.B. Apache 2.x
* MySQL/MariaDB 5.x oder neuer
* Nagios 2.x/3.x/4.x oder Nagios kompatible Monitoringsoftware
* PHP 5.5.0 oder groesser, inklusive:
* MySQL 5.x oder neuer
* Nagios 2.x/3.x oder Nagios kompatible Monitoringsoftware
* PHP 5.2.0 oder groesser, inklusive:
* PHP Module: Session
* PHP Module: MySQLi
* PHP Module: MySQL
* PHP Module: gettext
* PHP Module: filter
* PHP Module: FTP (optional)
@@ -35,7 +38,7 @@
= Neuinstallation =
===================
1. Download und entpacken von NagiosQL 3.4 in einem Apache zugaenglichen Verzeichnis.
1. Download und entpacken von NagiosQL 3.2 in einem Apache zugaenglichen Verzeichnis.
2. Der Installationsassistent wird automatisch durch Eingabe von install/index.php gestartet.
3. Die gewuenschte Sprache auswaehlen (siehe Appendix 2.)
4. Zum Installieren von NagiosQL den Anweisungen folgen.
@@ -44,14 +47,14 @@
= AKTUALISIERUNG =
==================
1. Aktualisierungen von NagiosQL 1.x und 2.x sind leider nicht moeglich, bitte einfach eine neue Installation starten und
1. Aktualisierungen von NagiosQL 1.x und 2.x sind leider nicht moeglich, bitte einfach eine neue Installation starten und
dann die Nagios Konfiguration durch den Import einbinden.
2. Aktualisierungen von NagiosQL 3.x
a. Download und entpacken von NagiosQL 3.4 in ein NEUES Apache zugaenglichen Verzeichnis (DocumentRoot auf neues Verzeichnis
a. Download und entpacken von NagiosQL 3.2 in ein NEUES Apache zugaenglichen Verzeichnis (DocumentRoot auf neues Verzeichnis
aendern)
b. Wird dieselbe Apachekonfiguration verwendet (altes NagiosQL Verzeichnis wegkopieren, neues NagiosQL Verzeichnis bekommt
b. Wird dieselbe Apachekonfiguration verwendet (altes NagiosQL Verzeichnis wegkopiert, neues NagiosQL Verzeichnis bekommt
denselben Namen), sollte der Apache Demon vor dem Upgrade neu gestartet werden.
c. Verschiebe die alte config/settings.php Datei in das neue NagiosQL 3.4 Verzeichnis config/
c. Verschiebe die alte config/settings.php Datei in das neue NagiosQL 3.2 Verzeichnis config/
d. Die alte Datenbank manuell sichern (z.Bsp. mit mysqldump)
e. Der Installationsassistent wird durch den Aufruf von install/index.php gestartet
f. Die gewuenschte Sprache waehlen (siehe auch Appendix 1.) und den Anweisungen folgen
@@ -98,7 +101,7 @@ Oeffnen Sie nach erfolgter Installation die Support Seite unter Administration u
================
=== Probleme ===
================
Zur Zeit gibt es keine bekannten Probleme. Support erreicht man ueber das Forum (https://sourceforge.net/projects/nagiosql/) oder fuer Programmfehler den Bugtracker (http://dev.nagigosql.org)
Zur Zeit gibt es keine bekannten Probleme. Support erreicht man ueber das Forum (http://www.nagiosql.org/forum.html) oder fuer Programmfehler den Bugtracker (http://dev.nagigosql.org)
================
=== APPENDIX ===

View File

@@ -4,13 +4,16 @@
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
// (c) 2008-2012 by Martin Willisegger
//
// Project : NagiosQL
// Component : Installation HowTo
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Project : NagiosQL
// Component: Installation HowTo
// Website : http://www.nagiosql.org
// Date : $LastChangedDate: 2012-03-12 08:30:07 +0100 (Mon, 12 Mar 2012) $
// Author : $LastChangedBy: martin $
// Version : 3.2.0
// Revision : $LastChangedRevision: 1288 $
// SVN-ID : $Id: INSTALLATION_enGB.txt 1288 2012-03-12 07:30:07Z martin $
//
///////////////////////////////////////////////////////////////////////////////
@@ -19,11 +22,11 @@
================
* Webserver like Apache 2.x
* MySQL/MariaDB 5.x or greater
* Nagios 2.x/3.x/4.x or Nagios compatible monitoring software
* PHP 5.5.0 or greater including:
* MySQL 5.x or greater
* Nagios 2.x/3.x or Nagios compatible monitoring software
* PHP 5.2.0 or greater including:
* PHP Module: Session
* PHP Module: MySQLi
* PHP Module: MySQL
* PHP Module: gettext
* PHP Module: filter
* PHP Module: FTP (optional)
@@ -35,7 +38,7 @@
NEW INSTALLATION
================
1. Download and extract NagiosQL 3.4 to a directory within your Apache Document Root
1. Download and extract NagiosQL 3.2 to a directory within your Apache Document Root
2. Start the Installation Wizard by opening install/index.php
3. Switch to your preferred language (see Appendix 1.)
4. Follow the instructions to install NagiosQL
@@ -44,13 +47,13 @@ NEW INSTALLATION
=== UPGRADES ===
================
1. Upgrade from NagiosQL 1.x and 2.x are not possible, you should better start at "New Installation" and after the installation is done,
1. Upgrade from NagiosQL 1.x and 2.x are not possible, you should better start at "New Installation" and after the installation is done,
import Nagios configuration files with NagiosQL
2. Upgrade from NagiosQL 3.x
a. Download and extract NagiosQL 3.4 to a NEW directory and change your Apache DocumentRoot to the new directory
2. Upgrade from NagiosQL 3.x
a. Download and extract NagiosQL 3.2 to a NEW directory and change your Apache DocumentRoot to the new directory
b. If the same Apache configuration is used (old NagiosQL directory moved away and new NagiosQL directory moved to the old
DocumentRoot), you should restart the apache demon before upgrade
b. Move your old config/settings.php file to the new NagiosQL 3.4 config/ folder
b. Move your old config/settings.php file to the new NagiosQL 3.2 config/ folder
c. Backup your old NagiosQL database (as example with mysqldump)
d. Start the Installation Wizard by opening install/index.php
e. Switch to your preferred language (see Appendix) and follow the instructions
@@ -98,7 +101,7 @@ After installation - go to administration - support and check your installation.
================
=== PROBLEMS ===
================
There are currently no known issues. If you having questions, please visit our forum https://sourceforge.net/projects/nagiosql/. If you probably found a bug, please help us and open a new bug report at http://dev.nagigosql.org
There are currently no known issues. If you having questions, please visit our forum http://www.nagiosql.org/forum.html. If you probably found a bug, please help us and open a new bug report at http://dev.nagigosql.org
================
=== APPENDIX ===

View File

@@ -1,674 +1,36 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
NagiosQL
Copyright (C) 2018 Martin
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
NagiosQL Copyright (C) 2018 Martin Willisegger
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
NagiosQL License - based on BSD License
Copyright (c) 2005-2012, Martin Willisegger
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the NagiosQL team - www.nagiosql.org.
4. Neither the name of the NagiosQL team - www.nagiosql.org nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE NAGIOSQL TEAM AND THE COPYRIGHT HOLDER ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE NAGIOSQL TEAM AND THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Additional conditions for NagiosQL
a) Using NagiosQL bundled with commercial products is only allowed with
explicit approval of the copyright holder.
b) Using the code of NagiosQL to build a "fork" is only allowed with
explicit approval of the copyright holder.

38
doc/LIZENZ Normal file
View File

@@ -0,0 +1,38 @@
Freie Übersetzung der BSD basierenden NagiosQL Lizenz - es gilt die englische Originalversion!
Copyright (c) 2005-2012, Martin Willisegger
Alle Rechte vorbehalten.
Weiterverbreitung und Verwendung in nichtkompilierter oder kompilierter Form, mit oder ohne
Veränderung, sind unter den folgenden Bedingungen zulässig:
1. Weiterverbreitete nichtkompilierte Exemplare müssen das obige Copyright,
diese Liste der Bedingungen und den folgenden Haftungsausschluss im Quelltext enthalten.
2. Weiterverbreitete kompilierte Exemplare müssen das obige Copyright, diese Liste der
Bedingungen und den folgenden Haftungsausschluss in der Dokumentation und/oder anderen
Materialien, die mit dem Exemplar verbreitet werden, enthalten.
3. Alle Werbematerialien, die Eigenschaften oder die Benutzung erwähnen, müssen die folgende
Bemerkung enthalten: „Dieses Produkt enthält Software, die vom NagiosQL Team - www.nagiosql.org
entwickelt wurde.“
4. Weder der Name des vom NagiosQL Team - www.nagiosql.org noch die Namen der Beitragsleistenden
dürfen zum Kennzeichnen oder Bewerben von Produkten, die von dieser Software abgeleitet wurden,
ohne spezielle vorherige schriftliche Genehmigung verwendet werden.
DIESE SOFTWARE WIRD VOM NAGIOSQL TEAM UND DEM RECHTEINHABER SOWIE DEN BEITRAGSLEISTENDEN OHNE
JEGLICHE SPEZIELLE ODER IMPLIZIERTE GARANTIEN ZUR VERFÜGUNG GESTELLT, DIE UNTER ANDEREM EINSCHLIESSEN:
DIE IMPLIZIERTE GARANTIE DER VERWENDBARKEIT DER SOFTWARE FÜR EINEN BESTIMMTEN ZWECK. AUF KEINEN FALL
IST DAS NAGIOSQL TEAM, DER RECHTEINHABER SOWIE DIE BEITRAGSLEISTENDEN FÜR IRGENDWELCHE DIREKTEN,
INDIREKTEN, ZUFÄLLIGEN, SPEZIELLEN, BEISPIELHAFTEN ODER FOLGESCHÄDEN (UNTER ANDEREM VERSCHAFFEN
VON ERSATZGÜTERN ODER -DIENSTLEISTUNGEN; EINSCHRÄNKUNG DER NUTZUNGSFÄHIGKEIT; VERLUST VON NUTZUNGSFÄHIGKEIT;
DATEN; PROFIT ODER GESCHÄFTSUNTERBRECHUNG), WIE AUCH IMMER VERURSACHT UND UNTER WELCHER VERPFLICHTUNG AUCH
IMMER, OB IN VERTRAG, STRIKTER VERPFLICHTUNG ODER UNERLAUBTER HANDLUNG (INKLUSIVE FAHRLÄSSIGKEIT)
VERANTWORTLICH, AUF WELCHEM WEG SIE AUCH IMMER DURCH DIE BENUTZUNG DIESER SOFTWARE ENTSTANDEN SIND,
SOGAR, WENN SIE AUF DIE MÖGLICHKEIT EINES SOLCHEN SCHADENS HINGEWIESEN WORDEN SIND.
Zusätzliche Bedingungen zu NagiosQL
a) Das bündeln von NagiosQL zusammen mit einem kommerziellen Produkt ist nur zulässig
mit ausdrücklicher Genehmigung des Copyright Inhabers.
b) Das Benutzen von Code von NagiosQL mit dem Zweck einen "Fork" zu erstellen ist nur
zulässig mit ausdrücklicher Genehmigung des Copyright Inhabers.

View File

@@ -8,7 +8,7 @@ Local system
2. Create a path for the ssh keys
# mkdir /etc/nagiosql/ssh
2. Create a key pair (only rsa is supported!)
# ssh-keygen -t rsa -b 4096
# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /etc/nagiosql/ssh/id_rsa
-> empty passphrase!

Some files were not shown because too many files have changed in this diff Show More