diff --git a/admin.php b/admin.php
index b605af6..7ff5f2d 100644
--- a/admin.php
+++ b/admin.php
@@ -5,42 +5,47 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin main site
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 1;
+$preContent = 'admin/mainpages.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("functions/prepend_adm.php");
-require("functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'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","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/administration.php b/admin/administration.php
index 30d4fbb..12f35c6 100644
--- a/admin/administration.php
+++ b/admin/administration.php
@@ -5,39 +5,43 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Administration overview
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
+$prePageId = 7;
+$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
-require("../functions/prepend_adm.php");
+require $preBasePath. 'functions/prepend_adm.php';
//
// Include content
// ===============
-$conttp->setVariable("TITLE",translate('Administration'));
-$conttp->parse("header");
-$conttp->show("header");
-$conttp->setVariable("DESC",translate('Functions to administrate NagiosQL V3'));
-$conttp->parse("main");
-$conttp->show("main");
+$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","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/alarming.php b/admin/alarming.php
index 8897e9d..f35dda0 100644
--- a/admin/alarming.php
+++ b/admin/alarming.php
@@ -5,73 +5,88 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Alarming overview
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
+$prePageId = 3;
+$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
-require("../functions/prepend_adm.php");
+require $preBasePath.'functions/prepend_adm.php';
//
// Include content
// ===============
-$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'));
+$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'));
//
// Include statistical data
// ========================
// Get read access groups
-$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");
+$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');
}
-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($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`=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($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`=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");
+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');
}
-$conttp->parse("statistics");
-$conttp->parse("main");
-$conttp->show("main");
+$conttp->parse('statistics');
+$conttp->parse('main');
+$conttp->show('main');
//
// Include Footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/cgicfg.php b/admin/cgicfg.php
index 55abf97..ff6b214 100644
--- a/admin/cgicfg.php
+++ b/admin/cgicfg.php
@@ -5,149 +5,162 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : File editor cgi.cfg
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
-$intRemoveTmp = 0;
-$strConfig = "";
+$prePageId = 29;
+$preContent = 'admin/nagioscfg.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
+$intRemoveTmp = 0;
+$strConfig = '';
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Get configuration set ID
// ========================
-$arrConfigSet = $myConfigClass->getConfigSets();
+$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
-$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",time());
+$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');
//
-// 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 != "") {
- 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("".translate('Configuration file successfully written!')." ",$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("".translate('Configuration file successfully written!')." ",$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);
- }
- }
+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('' .translate('Configuration file successfully '
+ . 'written!'). ' ', $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('' .translate('Configuration file successfully '
+ . 'written!'). ' ', $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);
}
//
// Include content
// ===============
-$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']);
-}
+$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']);
+}
//
// Open configuration
// ==================
if ($intMethod == 1) {
- 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);
- }
+ 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);
+ }
+ }
}
-$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->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
-$conttp->parse("naginsert");
-$conttp->show("naginsert");
+if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
+ $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
+}
+$conttp->parse('naginsert');
+$conttp->show('naginsert');
//
// Process footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/checkcommands.php b/admin/checkcommands.php
index 25a1eef..69ca44a 100644
--- a/admin/checkcommands.php
+++ b/admin/checkcommands.php
@@ -5,148 +5,192 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Command definitions
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'checkcommand';
-$preTableName = 'tbl_command';
-$preKeyField = 'command_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 18;
+$preContent = 'admin/checkcommands.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'checkcommand';
+$preTableName = 'tbl_command';
+$preKeyField = 'command_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
-//
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `command_line`='$chkTfValue2', `command_type`=$chkSelValue1, $preSQLCommon1";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } 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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Command definitions'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// 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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // 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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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);
+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);
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/commandline.php b/admin/commandline.php
index 7bc4995..2ea41f0 100644
--- a/admin/commandline.php
+++ b/admin/commandline.php
@@ -5,82 +5,86 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Command line visualization
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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("../functions/prepend_adm.php");
-$strCommandLine = " ";
-$intCount = 0;
+require $preBasePath. 'functions/prepend_adm.php';
+$strCommandLine = ' ';
+$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;
- } 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;
- }
-
- }
+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;
+ }
+ }
}
?>
-
- Commandline
-
-
-
-
-
-
-
+
+ Commandline
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/commands.php b/admin/commands.php
index 5c90b88..e5a1702 100644
--- a/admin/commands.php
+++ b/admin/commands.php
@@ -5,55 +5,61 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Commands overview
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
+$prePageId = 4;
+$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
-require("../functions/prepend_adm.php");
+require $preBasePath.'functions/prepend_adm.php';
//
// Include content
// ===============
-$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'));
+$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'));
//
// Include statistical data
// ========================
// Get read access groups
-$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");
+$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');
}
-$conttp->parse("statistics");
-$conttp->parse("main");
-$conttp->show("main");
+$conttp->parse('statistics');
+$conttp->parse('main');
+$conttp->show('main');
//
// Include Footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/configtargets.php b/admin/configtargets.php
index 8f29968..409e069 100644
--- a/admin/configtargets.php
+++ b/admin/configtargets.php
@@ -5,33 +5,38 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin configuration target administration
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preTableName = 'tbl_configtarget';
-$preKeyField = 'target';
-$preAccess = 1;
-$preFieldvars = 1;
-$intIsError = 0;
-$strPathMessage = "";
+$prePageId = 36;
+$preContent = 'admin/configtargets.htm.tpl';
+$preListTpl = 'admin/datalist_common.htm.tpl';
+$preTableName = 'tbl_configtarget';
+$preKeyField = 'target';
+$preAccess = 1;
+$preFieldvars = 1;
+$intIsError = 0;
+$strPathMessage = '';
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Process path values (add slashes)
// =================================
@@ -47,241 +52,295 @@ $chkTfValue16 = $myVisClass->addSlash($chkTfValue16);
//
// Check if the permissions and other parameters
// =============================================
-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";
- }
- }
+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';
+ }
}
-//
+//
// 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', `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 == '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 != "add") $chkModus = "display";
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Configuration domain administration'));
-if ($intIsError == 1) $conttp->setVariable("PATHMESSAGE","".translate("Warning, at least one error occured, please check!")." ".$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("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");
+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', '' .translate('Warning, at least one ' .
+ 'error occured, please check!'). ' ' .$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');
}
//
// List view
// ==========
-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');
+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');
}
// Show messages
-$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1);
+$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
//
// Process footer
// ==============
-$myContentClass->showFooter($maintp,$setFileVersion);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/contactgroups.php b/admin/contactgroups.php
index b656e5e..033e7e5 100644
--- a/admin/contactgroups.php
+++ b/admin/contactgroups.php
@@ -5,178 +5,271 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Contactgroup definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'contactgroup';
-$preTableName = 'tbl_contactgroup';
-$preKeyField = 'contactgroup_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 15;
+$preContent = 'admin/contactgroups.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'contactgroup';
+$preTableName = 'tbl_contactgroup';
+$preKeyField = 'contactgroup_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
-//
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, `contactgroup_members`=$intMselValue2, $preSQLCommon1";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } 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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define contact groups (contactgroups.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // Process data
- $myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
- }
- $conttp->parse("datainsert");
- $conttp->show("datainsert");
+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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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');
+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');
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/contacts.php b/admin/contacts.php
index 0dd9819..4244079 100644
--- a/admin/contacts.php
+++ b/admin/contacts.php
@@ -5,338 +5,506 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Contact definitions
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'contact';
-$preTableName = 'tbl_contact';
-$preKeyField = 'contact_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 14;
+$preContent = 'admin/contacts.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'contact';
+$preTableName = 'tbl_contact';
+$preKeyField = 'contact_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Checkbox data processing
// ========================
-if ($intVersion == 3) {
- $strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f,0,-1);
- $strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f.$chkChbGr2g,0,-1);
+if (($intVersion == 3) || ($intVersion == 4)) {
+ $strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f, 0, -1);
+ $strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f.$chkChbGr2g, 0, -1);
} else {
- $strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1f,0,-1);
- $strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2g,0,-1);
+ $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,
- `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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate("Define contacts (contacts.cfg)"));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // 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') {
+ $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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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');
+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');
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/contacttemplates.php b/admin/contacttemplates.php
index a54f100..81b3117 100644
--- a/admin/contacttemplates.php
+++ b/admin/contacttemplates.php
@@ -5,330 +5,504 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Contact template definitions
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'contacttemplate';
-$preTableName = 'tbl_contacttemplate';
-$preKeyField = 'template_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 17;
+$preContent = 'admin/contacttemplates.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'contacttemplate';
+$preTableName = 'tbl_contacttemplate';
+$preKeyField = 'template_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Checkbox data processing
// ========================
-if ($intVersion == 3) {
- $strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f,0,-1);
- $strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f.$chkChbGr2g,0,-1);
+if (($intVersion == 3) || ($intVersion == 4)) {
+ $strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f, 0, -1);
+ $strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f.$chkChbGr2g, 0, -1);
} else {
- $strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1f,0,-1);
- $strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2g,0,-1);
+ $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,
- `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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate("Define contact templates (contacttemplates.cfg)"));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // 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') {
+ $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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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');
+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');
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/datadomain.php b/admin/datadomain.php
index 2e1f62b..da1a485 100644
--- a/admin/datadomain.php
+++ b/admin/datadomain.php
@@ -5,156 +5,183 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin domain administration
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preTableName = 'tbl_datadomain';
-$preKeyField = 'domain';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 35;
+$preContent = 'admin/datadomain.htm.tpl';
+$preListTpl = 'admin/datalist_common.htm.tpl';
+$preTableName = 'tbl_datadomain';
+$preKeyField = 'domain';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
-//
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- if ($chkTfValue1 == 'common') $chkSelValue1 = 0;
- $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `targets`=$chkSelValue1, `version`=$chkSelValue2,
- `access_group`=$chkSelAccGr, `enable_common`=$chkSelValue3, `active`='$chkActive',
- `last_modified`=NOW()";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } 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 == '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 != "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
- $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." ".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");
+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. ' ' .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');
}
//
// List view
// ==========
-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');
+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');
}
// Show messages
-$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1);
+$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
//
// Process footer
// ==============
-$myContentClass->showFooter($maintp,$setFileVersion);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/delbackup.php b/admin/delbackup.php
index c087631..4e6cd26 100644
--- a/admin/delbackup.php
+++ b/admin/delbackup.php
@@ -5,145 +5,176 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin file deletion
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 26;
+$preContent = 'admin/delbackup.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Get configuration set ID
// ========================
-$arrConfigSet = $myConfigClass->getConfigSets();
+$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
-$myConfigClass->getConfigData($intConfigId,"method",$intMethod);
-$myConfigClass->getConfigData($intConfigId,"backupdir",$strBackupDir);
-$myConfigClass->getConfigData($intConfigId,"hostbackup",$strHostBackupDir);
-$myConfigClass->getConfigData($intConfigId,"servicebackup",$strServiceBackupDir);
+$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
+$myConfigClass->getConfigValues($intConfigId, 'backupdir', $strBackupDir);
+$myConfigClass->getConfigValues($intConfigId, 'hostbackup', $strHostBackupDir);
+$myConfigClass->getConfigValues($intConfigId, 'servicebackup', $strServiceBackupDir);
//
// Process form inputs
// ===================
-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);
- }
- }
+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);
+ }
+ }
}
//
// 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 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));
+$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 more than one entry'));
+$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
+$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
// Build a local file list
if ($intMethod == 1) {
- $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);
- }
+ $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);
+ }
}
-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->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
-$conttp->parse("main");
-$conttp->show("main");
+if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
+ $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
+}
+$conttp->parse('main');
+$conttp->show('main');
//
// Footer ausgeben
// ===============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/delconfig.php b/admin/delconfig.php
index 73b6c07..f724bd1 100644
--- a/admin/delconfig.php
+++ b/admin/delconfig.php
@@ -5,160 +5,187 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin file deletion
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 27;
+$preContent = 'admin/delbackup.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Get configuration set ID
// ========================
-$arrConfigSet = $myConfigClass->getConfigSets();
+ $myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
-$myConfigClass->getConfigData($intConfigId,"method",$intMethod);
-$myConfigClass->getConfigData($intConfigId,"basedir",$strBaseDir);
-$myConfigClass->getConfigData($intConfigId,"hostconfig",$strHostDir);
-$myConfigClass->getConfigData($intConfigId,"serviceconfig",$strServiceDir);
+$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
+$myConfigClass->getConfigValues($intConfigId, 'basedir', $strBaseDir);
+$myConfigClass->getConfigValues($intConfigId, 'hostconfig', $strHostDir);
+$myConfigClass->getConfigValues($intConfigId, 'serviceconfig', $strServiceDir);
//
// Process form inputs
// ===================
-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);
- }
- }
+/** @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);
+ }
+ }
}
//
// 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 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));
+$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 more than one entry'));
+$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
+$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
// Build a local file list
if ($intMethod == 1) {
- $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);
- }
+ $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);
+ }
}
-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->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
-$conttp->parse("main");
-$conttp->show("main");
+if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
+ $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
+}
+$conttp->parse('main');
+$conttp->show('main');
//
// Footer ausgeben
// ===============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/download.php b/admin/download.php
index c78e611..1677275 100644
--- a/admin/download.php
+++ b/admin/download.php
@@ -5,18 +5,22 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Download config file
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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');
@@ -25,44 +29,33 @@ session_cache_limiter('private_no_expire');
// ==========================
$preNoMain = 1;
$preNoLogin = 1;
-require("../functions/prepend_adm.php");
+require $preBasePath.'functions/prepend_adm.php';
//
// Process post parameters
// =======================
-$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;
+$chkTable = filter_input(INPUT_GET, 'table', FILTER_SANITIZE_STRING);
+$chkConfig = filter_input(INPUT_GET, 'config', FILTER_SANITIZE_STRING);
+$chkLine = filter_input(INPUT_GET, 'line', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
//
// Header output
// ===============
-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";
+$arrConfig = $myConfigClass->getConfData();
+if (isset($arrConfig[$chkTable])) {
+ $strFile = $arrConfig[$chkTable]['filename'];
+} else {
+ $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);
-?>
\ No newline at end of file
+$myDataClass->writeLog(translate('Download'). ' ' .$strFile);
diff --git a/admin/group.php b/admin/group.php
index ea8e043..14ecf77 100644
--- a/admin/group.php
+++ b/admin/group.php
@@ -5,161 +5,197 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Group administration
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'group';
-$preTableName = 'tbl_group';
-$preKeyField = 'groupname';
-$preAccess = 1;
-$preFieldvars = 1;
-$preNoAccessGrp = 1;
+$prePageId = 33;
+$preContent = 'admin/group.htm.tpl';
+$preListTpl = 'admin/datalist_common.htm.tpl';
+$preSearchSession = 'group';
+$preTableName = 'tbl_group';
+$preKeyField = 'groupname';
+$preAccess = 1;
+$preFieldvars = 1;
+$preNoAccessGrp = 1;
+$arrDataLines = array();
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
-//
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
+//
// Add or modify data
// ==================
-if (($chkModus == "insert") || ($chkModus == "modify")) {
- $strSQLx = "`$preTableName` SET `groupname`='$chkTfValue1', `description`='$chkTfValue2', `active`='$chkActive', `last_modified`=NOW()";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } 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 == '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 != "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->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");
+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');
}
//
// List view
// ==========
-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');
+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');
}
// Show messages
-$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1);
+$myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
//
// Process footer
// ==============
-$myContentClass->showFooter($maintp,$setFileVersion);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/groupusers.php b/admin/groupusers.php
index b33b215..a4896ad 100644
--- a/admin/groupusers.php
+++ b/admin/groupusers.php
@@ -5,146 +5,171 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin time definition list
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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("../functions/prepend_adm.php");
+require $preBasePath.'functions/prepend_adm.php';
//
// Process get parameters
// ======================
-$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;
+$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;
}
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->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;
- }
- }
- }
+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;
+ }
+ }
+ }
}
//
// 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'][] = $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'] = array();
+ $_SESSION['groupuser'][] = $arrTemp;
+ }
}
//
// Deletion mode
// =============
-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;
- }
- }
- }
+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;
+ }
+ }
}
?>
-
-
+
+
None
-
-
-
-
-
+
+
+
+
+
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']); ?>
-
-
+
+
@@ -152,8 +177,8 @@ if ($chkMode == "del") {
-
-
+
+
\ No newline at end of file
diff --git a/admin/helpedit.php b/admin/helpedit.php
index 1046209..40b7cc1 100644
--- a/admin/helpedit.php
+++ b/admin/helpedit.php
@@ -5,149 +5,174 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Help text editor
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
-$setSaveLangId = "private";
+$prePageId = 39;
+$preContent = 'admin/helpedit.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
+$setSaveLangId = 'private';
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Process post parameters
// =======================
-$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 (($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);
- }
+$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);
}
//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Help text editor'));
-$conttp->parse("header");
-$conttp->show("header");
+// Security function for text fields
+// =================================
+$chkHidVersion = $myVisClass->tfSecure($chkHidVersion);
+$chkKey1 = $myVisClass->tfSecure($chkKey1);
+$chkKey2 = $myVisClass->tfSecure($chkKey2);
+$chkVersion = $myVisClass->tfSecure($chkVersion);
+//
+// Add or modify data
+// ==================
+if (($chkTaFileTextRaw != '') && ($chkTfValue3 == '1')) {
+ $strSQL = "SELECT `infotext` FROM `tbl_info` WHERE `key1`='$chkTfValue1' AND `key2`='$chkTfValue2' "
+ . "AND `version`='$chkHidVersion' AND `language`='$setSaveLangId'";
+ $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);
+ }
+}
//
// Singe data 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']);
+$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("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
// =======
-$strSQL = "SELECT DISTINCT `key1` FROM `tbl_info` ORDER BY `key1`";
-$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
+$arrData = array();
+$strSQL = 'SELECT DISTINCT `key1` FROM `tbl_info` ORDER BY `key1`';
+$booReturn = $myDBClass->hasDataArray($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->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 != '') {
+ $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 != "") && ($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");
- }
- }
+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');
+ }
+ }
}
//
// 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->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
-$conttp->parse("helpedit");
-$conttp->show("helpedit");
+if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
+ $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
+}
+$conttp->parse('helpedit');
+$conttp->show('helpedit');
//
// Process footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/hostdependencies.php b/admin/hostdependencies.php
index a15e91a..63d8df4 100644
--- a/admin/hostdependencies.php
+++ b/admin/hostdependencies.php
@@ -5,225 +5,389 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Host dependencies definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'hostdependencies';
-$preTableName = 'tbl_hostdependency';
-$preKeyField = 'config_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 19;
+$preContent = 'admin/hostdependencies.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'hostdependencies';
+$preTableName = 'tbl_hostdependency';
+$preKeyField = 'config_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
-$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e,0,-1);
-$strNO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e,0,-1);
-//
+$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);
- } 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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define host dependencies (hostdependencies.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // 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') {
+ $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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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);
+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
+ );
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/hostescalations.php b/admin/hostescalations.php
index 3b2daf8..1b2d063 100644
--- a/admin/hostescalations.php
+++ b/admin/hostescalations.php
@@ -5,222 +5,386 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Host escalation definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'hostescalation';
-$preTableName = 'tbl_hostescalation';
-$preKeyField = 'config_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 20;
+$preContent = 'admin/hostescalations.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'hostescalation';
+$preTableName = 'tbl_hostescalation';
+$preKeyField = 'config_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'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);
- } 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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define host escalation (hostescalations.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // 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') {
+ $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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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);
+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
+ );
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/hostextinfo.php b/admin/hostextinfo.php
index 15d47b8..b98aca3 100644
--- a/admin/hostextinfo.php
+++ b/admin/hostextinfo.php
@@ -5,155 +5,198 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Host extended information definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'hostextinfo';
-$preTableName = 'tbl_hostextinfo';
-$preKeyField = 'host_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 21;
+$preContent = 'admin/hostextinfo.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'hostextinfo';
+$preTableName = 'tbl_hostextinfo';
+$preKeyField = 'host_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
-//
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- $strSQLx = "`$preTableName` SET `$preKeyField`=$chkSelValue1, `notes`='$chkTfValue1', `notes_url`='$chkTfValue2', `action_url`='$chkTfValue3', `icon_image`='$chkTfValue4',
- `icon_image_alt`='$chkTfValue5', `vrml_image`='$chkTfValue6', `statusmap_image`='$chkTfValue7', `2d_coords`='$chkTfValue8', `3d_coords`='$chkTfValue9',
- $preSQLCommon1";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } 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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define host extended information (hostextinfo.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // Process data
- $myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
- }
- $conttp->parse("datainsert");
- $conttp->show("datainsert");
+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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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');
+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');
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/hostgroups.php b/admin/hostgroups.php
index 0400047..6971795 100644
--- a/admin/hostgroups.php
+++ b/admin/hostgroups.php
@@ -5,178 +5,275 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Hostgroup definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'hostgroup';
-$preTableName = 'tbl_hostgroup';
-$preKeyField = 'hostgroup_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 10;
+$preContent = 'admin/hostgroups.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'hostgroup';
+$preTableName = 'tbl_hostgroup';
+$preKeyField = 'hostgroup_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
-//
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, `hostgroup_members`=$intMselValue2,
- `notes`='$chkTfValue3', `notes_url`='$chkTfValue4', `action_url`='$chkTfValue5', $preSQLCommon1";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } 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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define host groups (hostgroups.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // Process data
- $myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
- }
- $conttp->parse("datainsert");
- $conttp->show("datainsert");
+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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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');
+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');
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/hosts.php b/admin/hosts.php
index 3733be5..9a4d9b1 100644
--- a/admin/hosts.php
+++ b/admin/hosts.php
@@ -5,490 +5,726 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Host definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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 = 8;
-$preContent = "admin/hosts.tpl.htm";
-$preSearchSession = 'host';
-$preTableName = 'tbl_host';
-$preKeyField = 'host_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 8;
+$preContent = 'admin/hosts.htm.tpl';
+$preListTpl = 'admin/datalist_hosts.htm.tpl';
+$preSearchSession = 'host';
+$preTableName = 'tbl_host';
+$preKeyField = 'host_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
-$strNO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e,0,-1);
-$strIS = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c,0,-1);
-$strFL = substr($chkChbGr3a.$chkChbGr3b.$chkChbGr3c,0,-1);
-$strST = substr($chkChbGr4a.$chkChbGr4b.$chkChbGr4c,0,-1);
-if ($chkSelValue1 != "") {
- for ($i=1;$i<=8;$i++) {
- ${"chkTfArg$i"} = str_replace("!","::bang::",${"chkTfArg$i"});
- if (${"chkTfArg$i"} != "") $chkSelValue1 .= "!".${"chkTfArg$i"};
- }
+$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;
+ }
+ }
}
-//
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue3', `display_name`='$chkTfValue4', `address`='$chkTfValue5',
- `name`='$chkTfValue6', `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`='$chkTfValue7', `notes_url`='$chkTfValue9', `action_url`='$chkTfValue11',
- `icon_image`='$chkTfValue12', `icon_image_alt`='$chkTfValue13', `vrml_image`='$chkTfValue8', `statusmap_image`='$chkTfValue10', `2d_coords`='$chkTfValue14',
- `3d_coords`='$chkTfValue15', $preSQLCommon1";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } else {
- $strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
- }
- if ($intWriteAccessId == 0) {
- if (($chkTfValue1 != "") && ($chkTfValue5 != "")) {
- $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 host inserted:')." ".$chkTfValue1);
- if ($chkModus == "modify") $myDataClass->writeLog(translate('Host modified:')." ".$chkTfValue1);
- //
- // Insert/update relations
- // =======================
- if ($chkModus == "insert") {
- if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkHostToHost",$chkDataId,$chkMselValue1);
- if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkHostToHostgroup",$chkDataId,$chkMselValue2);
- if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkHostToContact",$chkDataId,$chkMselValue3);
- if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkHostToContactgroup",$chkDataId,$chkMselValue4);
- if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- } else if ($chkModus == "modify") {
- if ($intMselValue1 != 0) {
- $intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkHostToHost",$chkDataId,$chkMselValue1);
- } else {
- $intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkHostToHost",$chkDataId);
- }
- if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue2 != 0) {
- $intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkHostToHostgroup",$chkDataId,$chkMselValue2);
- } else {
- $intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkHostToHostgroup",$chkDataId);
- }
- if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue3 != 0) {
- $intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkHostToContact",$chkDataId,$chkMselValue3);
- } else {
- $intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkHostToContact",$chkDataId);
- }
- if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue4 != 0) {
- $intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkHostToContactgroup",$chkDataId,$chkMselValue4);
- } else {
- $intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkHostToContactgroup",$chkDataId);
- }
- if ($intRet4 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- }
- if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) $strInfoMessage = "";
- //
- // Removing the config file if an entry was deleted or renamed
- // ===========================================================
- if (($chkModus == "modify") && ($chkTfValue2 != $chkTfValue1) && ($chkDomainId != 0)) {
- $arrConfigID = $myConfigClass->getConfigSets();
- if (($arrConfigID != 1) && is_array($arrConfigID)) {
- $intReturn = 0;
- foreach($arrConfigID AS $intConfigID) {
- $intReturn += $myConfigClass->moveFile("host",$chkTfValue2.".cfg",$intConfigID);
- }
- if ($intReturn == 0) {
- $myVisClass->processMessage(translate('The assigned, no longer used configuration files were deleted successfully!'),$strInfoMessage);
- $myDataClass->writeLog(translate('Host file deleted:')." ".$chkTfValue2.".cfg");
- } else {
- if ($chkDomainId == 0) {
- $myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check manually'),$strErrorMessage);
- } else {
- $myVisClass->processMessage(translate('Errors while deleting the old configuration file - please check!:'),$strErrorMessage);
- $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
- }
- }
- }
- }
- //
- // Removing the config file if an entry was dectivated
- // ===================================================
- if (($chkModus == "modify") && ($chkActive == 0)) {
- $arrConfigID = $myConfigClass->getConfigSets();
- if (($arrConfigID != 1) && is_array($arrConfigID)) {
- $intReturn = 0;
- foreach($arrConfigID AS $intConfigID) {
- $intReturn += $myConfigClass->moveFile("host",$chkTfValue2.".cfg",$intConfigID);
- }
- if ($intReturn == 0) {
- $myVisClass->processMessage(translate('The assigned, no longer used configuration files were deleted successfully!'),$strInfoMessage);
- $myDataClass->writeLog(translate('Host file deleted:')." ".$chkTfValue1.".cfg");
- } else {
- if ($chkDomainId == 0) {
- $myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check manually'),$strErrorMessage);
- } else {
- $myVisClass->processMessage(translate('Errors while deleting the old configuration file - please check!:'),$strErrorMessage);
- $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
- }
- }
- }
- }
- //
- // Insert/update session data for templates
- // ========================================
- if ($chkModus == "modify") {
- $strSQL = "DELETE FROM `tbl_lnkHostToHosttemplate` 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_lnkHostToHosttemplate` (`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_lnkHostToVariabledefinition` 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_lnkHostToVariabledefinition` WHERE `idMaster`=$chkDataId";
- $intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
- if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- $strSQL = "UPDATE `tbl_host` SET `use_variables`=0 WHERE `id`=$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)) {
- $intCountVariable = 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_lnkHostToVariabledefinition` (`idMaster`,`idSlave`)
- VALUES ($chkDataId,$intInsertId)";
- $intReturn2 = $myDataClass->dataInsert($strSQL,$intInsertId);
- if ($intReturn2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if (($intReturn1 == 0) && ($intReturn2 == 0)) $intCountVariable++;
- }
- }
- if ($intCountVariable != 0) {
- $strSQL = "UPDATE `tbl_host` SET `use_variables`=1 WHERE `id`=$chkDataId";
- $intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
- if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- }
- }
- //
- // Insert/Update service <-> host relations
- // ========================================
- // Update service table last modified date
- $strSQL = "SELECT `idMaster` FROM `tbl_lnkServiceToHost` WHERE `idSlave`=$chkDataId";
- $booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount);
- if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
- if ($intDataCount != 0) {
- foreach ($arrData AS $elem) {
- $strSQL = "UPDATE `tbl_service` SET `last_modified` = NOW() WHERE `id`=".$elem['idMaster'];
- $intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
- if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- }
- }
- // Remove any link data from host to service
- $strSQL = "DELETE FROM `tbl_lnkServiceToHost` WHERE `idSlave`=$chkDataId";
- $intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
- if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- foreach ($chkMselValue5 AS $elem) {
- if ($elem != "") {
- $intExclude = 0;
- if (substr($elem,0,1) == "e") {
- $intExclude = 1;
- $elem = substr_replace($elem,"",0,1);
- }
- $strSQL = "INSERT INTO `tbl_lnkServiceToHost` (`idMaster`,`idSlave`,`exclude`)
- VALUES ($elem,$chkDataId,$intExclude)";
- $intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
- if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- // Update service table last modified date
- $strSQL = "UPDATE `tbl_service` SET `last_modified` = NOW() WHERE `id`=".$elem;
- $intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
- if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- // Check if Service ID is not 0
- $strSQL = "SELECT `$preKeyField` FROM `tbl_service` WHERE `id`=$elem";
- $strResult = $myDBClass->getFieldData($strSQL);
- if ($strResult == 0) {
- $strSQL = "UPDATE `tbl_service` SET `$preKeyField`=1 WHERE `id`=$elem";
- $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 == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
+ $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue3', "
+ . "`display_name`='$chkTfValue4', `address`='$chkTfValue5', `name`='$chkTfValue6', "
+ . "`parents`=$intMselValue1, `importance`=$chkTfNullVal9, `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`='$chkTfValue7', `notes_url`='$chkTfValue9', `action_url`='$chkTfValue11', "
+ . "`icon_image`='$chkTfValue12', `icon_image_alt`='$chkTfValue13', `vrml_image`='$chkTfValue8', "
+ . "`statusmap_image`='$chkTfValue10', `2d_coords`='$chkTfValue14', `3d_coords`='$chkTfValue15', "
+ . $preSQLCommon1;
+ if ($chkModus == 'insert') {
+ $strSQL = 'INSERT INTO ' .$strSQLx;
+ } else {
+ $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
+ }
+ if ($intWriteAccessId == 0) {
+ if (($chkTfValue1 != '') && ($chkTfValue5 != '')) {
+ $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 host inserted:'). ' ' .$chkTfValue1);
+ }
+ if ($chkModus == 'modify') {
+ $myDataClass->writeLog(translate('Host modified:'). ' ' .$chkTfValue1);
+ }
+ //
+ // Insert/update relations
+ // =======================
+ if ($chkModus == 'insert') {
+ if ($intMselValue1 != 0) {
+ $intRet1 = $myDataClass->dataInsertRelation('tbl_lnkHostToHost', $chkDataId, $chkMselValue1);
+ }
+ if (isset($intRet1) && ($intRet1 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue2 != 0) {
+ $intRet2 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkHostToHostgroup',
+ $chkDataId,
+ $chkMselValue2
+ );
+ }
+ if (isset($intRet2) && ($intRet2 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue3 != 0) {
+ $intRet3 = $myDataClass->dataInsertRelation('tbl_lnkHostToContact', $chkDataId, $chkMselValue3);
+ }
+ if (isset($intRet3) && ($intRet3 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue4 != 0) {
+ $intRet4 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkHostToContactgroup',
+ $chkDataId,
+ $chkMselValue4
+ );
+ }
+ if (isset($intRet4) && ($intRet4 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ } elseif ($chkModus == 'modify') {
+ if ($intMselValue1 != 0) {
+ $intRet1 = $myDataClass->dataUpdateRelation('tbl_lnkHostToHost', $chkDataId, $chkMselValue1);
+ } else {
+ $intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkHostToHost', $chkDataId);
+ }
+ if ($intRet1 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue2 != 0) {
+ $intRet2 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkHostToHostgroup',
+ $chkDataId,
+ $chkMselValue2
+ );
+ } else {
+ $intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkHostToHostgroup', $chkDataId);
+ }
+ if ($intRet2 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue3 != 0) {
+ $intRet3 = $myDataClass->dataUpdateRelation('tbl_lnkHostToContact', $chkDataId, $chkMselValue3);
+ } else {
+ $intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkHostToContact', $chkDataId);
+ }
+ if ($intRet3 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue4 != 0) {
+ $intRet4 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkHostToContactgroup',
+ $chkDataId,
+ $chkMselValue4
+ );
+ } else {
+ $intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkHostToContactgroup', $chkDataId);
+ }
+ if ($intRet4 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) {
+ $strInfoMessage = '';
+ }
+ //
+ // Removing the config file if an entry was deleted or renamed
+ // ===========================================================
+ if (($chkModus == 'modify') && ($chkTfValue2 != $chkTfValue1) && ($chkDomainId != 0)) {
+ $myConfigClass->getConfigTargets($arrConfigID);
+ if (($arrConfigID != 1) && is_array($arrConfigID)) {
+ $intReturn = 0;
+ foreach ($arrConfigID as $intConfigID) {
+ $intReturn += $myConfigClass->moveFile('host', $chkTfValue2. '.cfg', $intConfigID);
+ }
+ if ($intReturn == 0) {
+ $myVisClass->processMessage(translate('The assigned, no longer used configuration files '
+ . 'were deleted successfully!'), $strInfoMessage);
+ $myDataClass->writeLog(translate('Host file deleted:'). ' ' .$chkTfValue2. '.cfg');
+ } else {
+ if ($chkDomainId == 0) {
+ $myVisClass->processMessage(translate('Common files cannot be removed from target '
+ . 'systems - please check manually'), $strErrorMessage);
+ } else {
+ $myVisClass->processMessage(translate('Errors while deleting the old configuration '
+ . 'file - please check!:'), $strErrorMessage);
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ }
+ }
+ //
+ // Removing the config file if an entry was dectivated
+ // ===================================================
+ if (($chkModus == 'modify') && ($chkActive == 0)) {
+ $myConfigClass->getConfigTargets($arrConfigID);
+ if (($arrConfigID != 1) && is_array($arrConfigID)) {
+ $intReturn = 0;
+ foreach ($arrConfigID as $intConfigID) {
+ $intReturn += $myConfigClass->moveFile('host', $chkTfValue2. '.cfg', $intConfigID);
+ }
+ if ($intReturn == 0) {
+ $myVisClass->processMessage(translate('The assigned, no longer used configuration files '
+ . 'were deleted successfully!'), $strInfoMessage);
+ $myDataClass->writeLog(translate('Host file deleted:'). ' ' .$chkTfValue1. '.cfg');
+ } else {
+ if ($chkDomainId == 0) {
+ $myVisClass->processMessage(translate('Common files cannot be removed from target '
+ . 'systems - please check manually'), $strErrorMessage);
+ } else {
+ $myVisClass->processMessage(translate('Errors while deleting the old configuration '
+ . 'file - please check!:'), $strErrorMessage);
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ }
+ }
+ //
+ // Insert/update session data for templates
+ // ========================================
+ if ($chkModus == 'modify') {
+ $strSQL = 'DELETE FROM `tbl_lnkHostToHosttemplate` 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_lnkHostToHosttemplate` (`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_lnkHostToVariabledefinition` 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_lnkHostToVariabledefinition` WHERE `idMaster`=' .$chkDataId;
+ $intReturn1 = $myDataClass->dataInsert($strSQL, $intInsertId);
+ if ($intReturn1 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ $strSQL = 'UPDATE `tbl_host` SET `use_variables`=0 WHERE `id`=' .$chkDataId;
+ $intReturn2 = $myDataClass->dataInsert($strSQL, $intInsertId);
+ if ($intReturn2 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
+ (count($_SESSION['variabledefinition']) != 0)) {
+ $intCountVariable = 0;
+ /** @noinspection ForeachSourceInspection */
+ 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_lnkHostToVariabledefinition` (`idMaster`,`idSlave`) '
+ . "VALUES ($chkDataId,$intInsertId)";
+ $intReturn2 = $myDataClass->dataInsert($strSQL, $intInsertId);
+ if ($intReturn2 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if (($intReturn1 == 0) && ($intReturn2 == 0)) {
+ $intCountVariable++;
+ }
+ }
+ }
+ if ($intCountVariable != 0) {
+ $strSQL = 'UPDATE `tbl_host` SET `use_variables`=1 WHERE `id`=' .$chkDataId;
+ $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
+ if ($intReturn != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ }
+ //
+ // Insert/Update service <-> host relations
+ // ========================================
+ // Update service table last modified date
+ $strSQL = 'SELECT `idMaster` FROM `tbl_lnkServiceToHost` WHERE `idSlave`=' .$chkDataId;
+ $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
+ if ($booReturn == false) {
+ $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intDataCount != 0) {
+ foreach ($arrData as $elem) {
+ $strSQL = 'UPDATE `tbl_service` SET `last_modified` = NOW() WHERE `id`=' .$elem['idMaster'];
+ $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
+ if ($intReturn != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ }
+ // Remove any link data from host to service
+ $strSQL = 'DELETE FROM `tbl_lnkServiceToHost` WHERE `idSlave`=' .$chkDataId;
+ $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
+ if ($intReturn != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if (is_array($chkMselValue5)) {
+ foreach ($chkMselValue5 as $elem) {
+ if ($elem != '') {
+ $intExclude = 0;
+ if (0 === strpos($elem, 'e')) {
+ $intExclude = 1;
+ $elem = substr_replace($elem, '', 0, 1);
+ }
+ $strSQL1 = 'INSERT INTO `tbl_lnkServiceToHost` (`idMaster`,`idSlave`,`exclude`) '
+ . "VALUES ($elem,$chkDataId,$intExclude)";
+ $intReturn1 = $myDataClass->dataInsert($strSQL1, $intInsertId);
+ if ($intReturn1 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ // Update service table last modified date
+ $strSQL2 = 'UPDATE `tbl_service` SET `last_modified` = NOW() WHERE `id`=' . $elem;
+ $intReturn2 = $myDataClass->dataInsert($strSQL2, $intInsertId);
+ if ($intReturn2 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ // Check if Service ID is not 0
+ $strSQL3 = "SELECT `$preKeyField` FROM `tbl_service` WHERE `id`=$elem";
+ $strResult3 = $myDBClass->getFieldData($strSQL3);
+ if ($strResult3 == 0) {
+ $strSQL = "UPDATE `tbl_service` SET `$preKeyField`=1 WHERE `id`=$elem";
+ $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 != "add") $chkModus = "display";
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define hosts (hosts.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
//
// Singe data form
// ===============
-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`,`template_name`, `active` FROM `tbl_hosttemplate` 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 host selection field
- if (isset($arrModifyData['parents'])) {$intFieldId = $arrModifyData['parents'];} else {$intFieldId = 0;}
- if (isset($arrModifyData['id'])) {$intKeyId = $arrModifyData['id'];} else {$intKeyId = 0;}
- $intReturn = $myVisClass->parseSelectMulti($preTableName,$preKeyField,'host_parents','tbl_lnkHostToHost',0,$intFieldId,$intKeyId);
- 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_lnkHostToHostgroup',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',2,$intFieldId);
- if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- // Process check period selection field
- 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(translate('Attention, no time periods defined!'),$strDBWarning);
- $intDataWarning = 1;
- }
- // 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;}
- $intReturn1 = $myVisClass->parseSelectMulti('tbl_contact','contact_name','host_contacts','tbl_lnkHostToContact',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','host_contactgroups','tbl_lnkHostToContactgroup',2,$intFieldId);
- if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- if (($intReturn != 0) && ($intReturn2 != 0)) {
- $myVisClass->processMessage(translate('Attention, no contact groups 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);
- // Process service selection field
- if (isset($arrModifyData['contacts'])) {$intFieldId = $arrModifyData['id'];} else {$intFieldId = 0;}
- $intReturn = $myVisClass->parseSelectMulti('tbl_service','service_description','host_services','tbl_lnkServiceToHost',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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // 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 {
- $value = str_replace("::bang::","!",$value);
- $value = str_replace("::back::","\\",$value);
- $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') {
+ $conttp->setVariable('TITLE', translate('Define hosts (hosts.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`,`template_name`, `active` ' .
+ "FROM `tbl_hosttemplate` WHERE $strDomainWhere2 ORDER BY `template_name`";
+ $booReturn1 = $myDBClass->hasDataArray($strSQL1, $arrDataTpl, $intDataCountTpl);
+ if ($booReturn == 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');
+ }
+ }
+ $strSQL2 = 'SELECT `id`, `name`, `active` '
+ . "FROM `$preTableName` WHERE `name` <> '' $strWhere AND $strDomainWhere ORDER BY `name`";
+ $booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataHpl, $intDataCountHpl);
+ if ($booReturn == 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;
+ }
+ if (isset($arrModifyData['id'])) {
+ $intKeyId = $arrModifyData['id'];
+ } else {
+ $intKeyId = 0;
+ }
+ $intReturn3 = $myVisClass->parseSelectMulti(
+ $preTableName,
+ $preKeyField,
+ 'host_parents',
+ 'tbl_lnkHostToHost',
+ 0,
+ $intFieldId,
+ $intKeyId
+ );
+ if ($intReturn3 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process hostgroup selection field
+ if (isset($arrModifyData['hostgroups'])) {
+ $intFieldId = $arrModifyData['hostgroups'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn4 = $myVisClass->parseSelectMulti(
+ 'tbl_hostgroup',
+ 'hostgroup_name',
+ 'hostgroup',
+ 'tbl_lnkHostToHostgroup',
+ 0,
+ $intFieldId
+ );
+ if ($intReturn4 != 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;
+ }
+ $intReturn5 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'hostcommand', 2, $intFieldId);
+ if ($intReturn5 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process check period selection field
+ if (isset($arrModifyData['check_period'])) {
+ $intFieldId = $arrModifyData['check_period'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn6 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'checkperiod', 1, $intFieldId);
+ if ($intReturn6 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['notification_period'])) {
+ $intFieldId = $arrModifyData['notification_period'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn7 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'notifyperiod', 1, $intFieldId);
+ if ($intReturn7 != 0) {
+ $myVisClass->processMessage(translate('Attention, no time periods defined!'), $strDBWarning);
+ $intDataWarning = 1;
+ }
+ // Process event handler selection field
+ if (isset($arrModifyData['event_handler'])) {
+ $intFieldId = $arrModifyData['event_handler'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn8 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'eventhandler', 1, $intFieldId);
+ if ($intReturn8 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process contact and contact group selection field
+ if (isset($arrModifyData['contacts'])) {
+ $intFieldId = $arrModifyData['contacts'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn9 = $myVisClass->parseSelectMulti(
+ 'tbl_contact',
+ 'contact_name',
+ 'host_contacts',
+ 'tbl_lnkHostToContact',
+ 2,
+ $intFieldId
+ );
+ if ($intReturn9 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['contact_groups'])) {
+ $intFieldId = $arrModifyData['contact_groups'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn10 = $myVisClass->parseSelectMulti(
+ 'tbl_contactgroup',
+ 'contactgroup_name',
+ 'host_contactgroups',
+ 'tbl_lnkHostToContactgroup',
+ 2,
+ $intFieldId
+ );
+ if ($intReturn10 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (($intReturn8 != 0) && ($intReturn10 != 0)) {
+ $myVisClass->processMessage(translate('Attention, no contact groups defined!'), $strDBWarning);
+ $intDataWarning = 1;
+ }
+ // Process access group selection field
+ if (isset($arrModifyData['access_group'])) {
+ $intFieldId = $arrModifyData['access_group'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn11 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
+ if ($intReturn11 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process service selection field
+ if (isset($arrModifyData['contacts'])) {
+ $intFieldId = $arrModifyData['id'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn12 = $myVisClass->parseSelectMulti(
+ 'tbl_service',
+ 'service_description',
+ 'host_services',
+ 'tbl_lnkServiceToHost',
+ 0,
+ $intFieldId
+ );
+ if ($intReturn12 != 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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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 {
+ $value1 = str_replace('::bang::', '!', $value);
+ $value2 = str_replace('::back::', "\\", $value1);
+ $conttp->setVariable('DAT_ARG' .$key, htmlentities($value2, 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("FIELD_1",translate('Host 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
- `display_name` LIKE '%".$strSearchTxt."%' OR `address` 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',0);
- if ($myContentClass->strErrorMessage != "") $myVisClass->processMessage($myContentClass->strErrorMessage,$strErrorMessage);
+if ($chkModus == 'display') {
+ // Initial list view definitions
+ $myContentClass->listViewInit($mastertp);
+ $mastertp->setVariable('TITLE', translate('Define hosts (hosts.cfg)'));
+ $mastertp->setVariable('FIELD_1', translate('Host 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 "
+ . "`display_name` LIKE '%".$strSearchTxt."%' OR `address` 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`, `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($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', 0);
+ if ($myContentClass->strErrorMessage != '') {
+ $myVisClass->processMessage($myContentClass->strErrorMessage, $strErrorMessage);
+ }
}
// Show messages
-$arrTimeData = array();
-$strTimeInfoString = "";
-$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
+$arrTimeData = array();
+$strTimeInfoString = '';
+$myContentClass->showMessages(
+ $mastertp,
+ $strErrorMessage,
+ $strInfoMessage,
+ $strConsistMessage,
+ $arrTimeData,
+ $strTimeInfoString,
+ $intNoTime
+);
//
// Process footer
// ==============
-$myContentClass->showFooter($maintp,$setFileVersion);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/hosttemplates.php b/admin/hosttemplates.php
index ee1e30e..82dd6bd 100644
--- a/admin/hosttemplates.php
+++ b/admin/hosttemplates.php
@@ -5,378 +5,590 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Hosttemplate definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'hosttemplate';
-$preTableName = 'tbl_hosttemplate';
-$preKeyField = 'template_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 12;
+$preContent = 'admin/hosttemplates.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'hosttemplate';
+$preTableName = 'tbl_hosttemplate';
+$preKeyField = 'template_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
-$strNO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e,0,-1);
-$strIS = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c,0,-1);
-$strFL = substr($chkChbGr3a.$chkChbGr3b.$chkChbGr3c,0,-1);
-$strST = substr($chkChbGr4a.$chkChbGr4b.$chkChbGr4c,0,-1);
-if ($chkSelValue1 != "") {
- for ($i=1;$i<=8;$i++) {
- if (${"chkTfArg$i"} != "") $chkSelValue1 .= "!".${"chkTfArg$i"};
- }
+$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;
+ }
+ }
}
-//
+//
// Add or modify data
// ==================
-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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Host template definition (hosttemplates.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // 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");
+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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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');
}
//
// List view
// ==========
-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');
+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);
+ }
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/import.php b/admin/import.php
index 4564663..9e5ac1f 100644
--- a/admin/import.php
+++ b/admin/import.php
@@ -5,216 +5,294 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin configuration verification
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
-$intModus = 0;
+$prePageId = 25;
+$preContent = 'admin/import.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
+$intModus = 0;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Initialize import class
// =======================
-include("../functions/import_class.php");
-$myImportClass = new nagimport;
-$myImportClass->myDataClass =& $myDataClass;
-$myImportClass->myDBClass =& $myDBClass;
-$myImportClass->myConfigClass =& $myConfigClass;
+$myImportClass = new functions\NagImportClass($_SESSION);
+$myImportClass->myDBClass =& $myDBClass;
+$myImportClass->myDataClass =& $myDataClass;
+$myImportClass->myConfigClass =& $myConfigClass;
//
// Get configuration set ID
// ========================
-$arrConfigSet = $myConfigClass->getConfigSets();
+$myConfigClass->getConfigTargets($arrConfigSet);
$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 [overwite 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 [overwrite flag]:'). ' ' .
+ $_FILES['datValue1']['name']. ' [' .$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."]");
- }
- }
+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. ']');
+ }
+ }
}
//
// 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 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:commands -> timeperiods -> contacttemplates -> contacts -> contactgroups -> hosttemplates -> hosts -> hostgroups -> servicetemplates -> services -> servicegroups "));
-$conttp->setVariable("IMPORT_INFO_2","".translate("Check your configuration after import! In cause of an error or an uncomplete configuration, re-importing the wrong configuration can solve the problem.")." ");
-$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 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:commands -> '
+ . 'timeperiods -> contacttemplates -> contacts -> contactgroups -> hosttemplates -> hosts -> '
+ . 'hostgroups -> servicetemplates -> services -> servicegroups '));
+$conttp->setVariable('IMPORT_INFO_2', '' .translate('Check your configuration after '
+ . 'import! In cause of an error or an uncomplete configuration, re-importing the wrong configuration '
+ . 'can solve the problem.'). ' ');
+$conttp->parse('filelist1');
// Get settings
-$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);
+$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);
if ($intMethod == 1) {
- // 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);
- }
+ // 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);
+ }
}
// Check access rights for adding new objects
-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");
+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');
//
// Process footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/index.html b/admin/index.html
index e69de29..2c37267 100644
--- a/admin/index.html
+++ b/admin/index.html
@@ -0,0 +1,10 @@
+
+
+
+ NagiosQL
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/info.php b/admin/info.php
index d920e07..6ead80a 100644
--- a/admin/info.php
+++ b/admin/info.php
@@ -5,91 +5,105 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
-// Component : Admin information dialog
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Component : Admin information dialog
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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("../functions/prepend_adm.php");
+$preNoMain = 1;
+require $preBasePath.'functions/prepend_adm.php';
//
// Process get parameters
// ======================
-$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') : "";
+$chkKey1 = filter_input(INPUT_GET, 'key1', FILTER_SANITIZE_STRING);
+$chkKey2 = filter_input(INPUT_GET, 'key2', FILTER_SANITIZE_STRING);
+$chkVersion = filter_input(INPUT_GET, 'version', FILTER_SANITIZE_STRING);
//
// Get information data
// ===================================================
-if ($chkKey1 == "admin" and isset($_SESSION['updInfo'])) {
- // Exception for version check at admin.php
- $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 e.g. localhost"),
- "txtDBport" => translate("MySQL Server Port, default is 3306"),
- "txtDBname" => translate("Name of the NagiosQL database e.g. db_nagiosql_v3"),
- "txtDBuser" => translate("User with sufficient permission for the NagiosQL database 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 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];
+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 e.g. localhost'),
+ 'txtDBport' => translate('MySQL Server Port, default is 3306'),
+ 'txtDBname' => translate('Name of the NagiosQL database e.g. db_nagiosql_v3'),
+ 'txtDBuser' => translate('User with sufficient permission for the NagiosQL database 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 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];
} 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);
+ }
}
?>
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/admin/logbook.php b/admin/logbook.php
index b68f65f..0c73ce8 100644
--- a/admin/logbook.php
+++ b/admin/logbook.php
@@ -5,120 +5,136 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin logbook
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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/admin_master.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 37;
+$preContent = 'admin/logbook.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Delete log entries
// ==================
-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);
- }
+$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);
+ }
}
//
// 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->getDataArray($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->hasDataArray($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 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);
+$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);
// Legende einblenden
if ($chkFromLine > 1) {
- $intPrevNumber = $chkFromLine - 20;
- $conttp->setVariable("LANG_PREVIOUS", "<< ".translate('previous 20 entries')." ");
+ $intPrevNumber = $chkFromLine - 20;
+ $conttp->setVariable('LANG_PREVIOUS', '<< ' .translate('previous 20 entries'). ' ');
} else {
- $conttp->setVariable("LANG_PREVIOUS", "");
+ $conttp->setVariable('LANG_PREVIOUS', '');
}
if ($chkFromLine < $intNumRows-20) {
- $intNextNumber = $chkFromLine + 20;
- $conttp->setVariable("LANG_NEXT", "".translate('next 20 entries')." >> ");
+ $intNextNumber = $chkFromLine + 20;
+ $conttp->setVariable('LANG_NEXT', '' .translate('next 20 entries'). ' >> ');
} 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'] = " ";
- // 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'] = ' ';
+ }
+ // 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"," ".$strErrorMessage);
-$conttp->setVariable("INFOMESSAGE"," ".$strInfoMessage);
+$conttp->setVariable('ERRORMESSAGE', ' ' .$strErrorMessage);
+$conttp->setVariable('INFOMESSAGE', ' ' .$strInfoMessage);
// Check access rights for adding new objects
-if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
-$conttp->parse("logbooksite");
-$conttp->show("logbooksite");
+if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
+ $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
+}
+$conttp->parse('logbooksite');
+$conttp->show('logbooksite');
//
// Process footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/menuaccess.php b/admin/menuaccess.php
index c35aac8..3daac5d 100644
--- a/admin/menuaccess.php
+++ b/admin/menuaccess.php
@@ -5,95 +5,104 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Menu access administration
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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/admin_master.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
-$preNoAccessGrp = 1;
-$intFieldId = 0;
+$prePageId = 34;
+$preContent = 'admin/menuaccess.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
+$preNoAccessGrp = 1;
+$intFieldId = 0;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Process data
// ============
-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"));
- }
+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"));
+ }
}
//
// Include content
// ===============
-$conttp->setVariable("TITLE",translate('Define Menu Accessrights'));
-foreach($arrDescription AS $elem) {
- $conttp->setVariable($elem['name'],$elem['string']);
+$conttp->setVariable('TITLE', translate('Define Menu Access Rights'));
+foreach ($arrDescription as $elem) {
+ $conttp->setVariable($elem['name'], $elem['string']);
}
-$conttp->setVariable("LANG_ACCESSDESCRIPTION",translate('In order for a user to get access, he needs to be member of the group selected here.'));
+$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->getDataArray($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->hasDataArray($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"," ");
- $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', ' ');
+ $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","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/monitoring.php b/admin/monitoring.php
index aacf13c..c7b7023 100644
--- a/admin/monitoring.php
+++ b/admin/monitoring.php
@@ -5,86 +5,108 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin specials overview
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
+$prePageId = 2;
+$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Include content
// ===============
-$conttp->setVariable("TITLE",translate('Monitoring'));
-$conttp->parse("header");
-$conttp->show("header");
-$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'));
+$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'));
//
// Include statistical data
// ========================
// Get read access groups
-$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");
+$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');
}
-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($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`=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($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`=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($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`=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($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`=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");
+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');
}
-$conttp->parse("statistics");
-$conttp->parse("main");
-$conttp->show("main");
+$conttp->parse('statistics');
+$conttp->parse('main');
+$conttp->show('main');
//
// Include Footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/mutdialog.php b/admin/mutdialog.php
index 75d3e72..c8db35c 100644
--- a/admin/mutdialog.php
+++ b/admin/mutdialog.php
@@ -5,55 +5,60 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin timeperiod definitions
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Date : $LastChangedDate: 2018-04-10 10:48:30 +0200 (Tue, 10 Apr 2018) $
// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
+$preContent = 'admin/mutdialog.htm.tpl';
//
// Process post parameters
// =======================
-$chkObject = isset($_GET['object']) ? htmlspecialchars($_GET['object'], ENT_QUOTES, 'utf-8') : "";
-$intExclude = isset($_GET['exclude']) ? htmlspecialchars($_GET['exclude'], ENT_QUOTES, 'utf-8') : 0;
+$intExclude = filter_input(INPUT_GET, 'exclude', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
+$chkObject = filter_input(INPUT_GET, 'object', FILTER_SANITIZE_STRING);
//
// Include preprocessing file
// ==========================
$preAccess = 1;
$preFieldvars = 1;
$preNoMain = 1;
-require("../functions/prepend_adm.php");
+require $preBasePath.'functions/prepend_adm.php';
//
// Include content
// ===============
-$conttp->setVariable("BASE_PATH",$_SESSION['SETS']['path']['base_url']);
-$conttp->setVariable("OPENER_FIELD",$chkObject);
-$conttp->parse("header");
-$conttp->show("header");
+$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_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'));
+$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'));
if (($intExclude == 1) || ($intVersion < 3)) {
- $conttp->setVariable("DISABLE_HTML_BEGIN","");
+ $conttp->setVariable('DISABLE_HTML_BEGIN', '');
}
-$conttp->parse("datainsert");
-$conttp->show("datainsert");
-?>
\ No newline at end of file
+$conttp->parse('datainsert');
+$conttp->show('datainsert');
diff --git a/admin/nagioscfg.php b/admin/nagioscfg.php
index 3d12bb5..9603f7c 100644
--- a/admin/nagioscfg.php
+++ b/admin/nagioscfg.php
@@ -5,149 +5,161 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin timeperiod definitions
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
-$intRemoveTmp = 0;
-$strConfig = "";
+$prePageId = 28;
+$preContent = 'admin/nagioscfg.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
+$intRemoveTmp = 0;
+$strConfig = '';
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Get configuration set ID
// ========================
-$arrConfigSet = $myConfigClass->getConfigSets();
+$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
-$myConfigClass->getConfigData($intConfigId,"method",$intMethod);
-$myConfigClass->getConfigData($intConfigId,"nagiosbasedir",$strBaseDir);
-$myConfigClass->getConfigData($intConfigId,"conffile",$strConfigfile);
-$strLocalBackup = $strConfigfile."_old_".date("YmdHis",time());
+$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
+$myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strBaseDir);
+$myConfigClass->getConfigValues($intConfigId, 'conffile', $strConfigfile);
+$strLocalBackup = $strConfigfile. '_old_' .date('YmdHis');
//
-// 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 != "") {
- 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("".translate('Configuration file successfully written!')." ",$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("".translate('Configuration file successfully written!')." ",$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);
- }
- }
+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('' .translate('Configuration file successfully '
+ . 'written!'). ' ', $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('' .translate('Configuration file successfully '
+ . 'written!'). ' ', $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);
}
//
// Include content
// ===============
-$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']);
+$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']);
}
//
// Open configuration
// ==================
if ($intMethod == 1) {
- 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);
- }
+ 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);
+ }
+ }
}
-$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->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
-$conttp->parse("naginsert");
-$conttp->show("naginsert");
+if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
+ $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
+}
+$conttp->parse('naginsert');
+$conttp->show('naginsert');
//
// Process footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/password.php b/admin/password.php
index 34b36bd..06b2805 100644
--- a/admin/password.php
+++ b/admin/password.php
@@ -5,71 +5,84 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Password administration
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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/admin_master.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
-$preShowHeader = 0;
+$prePageId = 31;
+$preContent = 'admin/password.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
+$preShowHeader = 0;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Change password
// =======================
-if (($chkTfValue1 != "") && ($chkTfValue2 != "")) {
- // Check old password
- $strSQL = "SELECT * FROM `tbl_user` WHERE `username`='".$_SESSION['username']."' AND `password`=MD5('$chkTfValue1')";
- $booReturn = $myDBClass->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);
+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
+ );
}
//
// Output header variable
@@ -78,25 +91,29 @@ 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 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/");
+$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/');
// Check access rights for adding new objects
-if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
-$conttp->parse("passwordsite");
-$conttp->show("passwordsite");
+if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
+ $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
+}
+$conttp->parse('passwordsite');
+$conttp->show('passwordsite');
//
// Include footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/servicedependencies.php b/admin/servicedependencies.php
index adef4a0..4f5db58 100644
--- a/admin/servicedependencies.php
+++ b/admin/servicedependencies.php
@@ -5,384 +5,760 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Service dependencies definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// Path settings
+// ===================
+$strPattern = '(admin/[^/]*.php)';
+$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
+$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
+//
// Define common variables
// =======================
-$prePageId = 22;
-$preContent = "admin/servicedependencies.tpl.htm";
-$preSearchSession = 'servicedependencies';
-$preTableName = 'tbl_servicedependency';
-$preKeyField = 'config_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 22;
+$preContent = 'admin/servicedependencies.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'servicedependencies';
+$preTableName = 'tbl_servicedependency';
+$preKeyField = 'config_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
-$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f,0,-1);
-$strNO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f,0,-1);
-//
+$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f, 0, -1);
+$strNO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f, 0, -1);
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- $strSQLx = "`$preTableName` SET `dependent_host_name`=$intMselValue2, `dependent_hostgroup_name`=$intMselValue4, `dependent_service_description`=$intMselValue6,
- `dependent_servicegroup_name`=$intMselValue8, `host_name`=$intMselValue1, `hostgroup_name`=$intMselValue3, `service_description`=$intMselValue5,
- `servicegroup_name`=$intMselValue7,`$preKeyField`='$chkTfValue1', `inherits_parent`='$chkChbValue1', `execution_failure_criteria`='$strEO',
- `notification_failure_criteria`='$strNO', `dependency_period`=$chkSelValue1, $preSQLCommon1";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } else {
- $strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
- }
- if ($intWriteAccessId == 0) {
- if (($chkTfValue1 != "") && (($intMselValue5 != 0) || ($intMselValue7 != 0)) && (($intMselValue6 != 0) || ($intMselValue8 != 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 dependency inserted:')." ".$chkTfValue1);
- if ($chkModus == "modify") $myDataClass->writeLog(translate('Service dependency modified:')." ".$chkTfValue1);
- //
- // Insert/update relations
- // =======================
- if ($chkModus == "insert") {
- if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkServicedependencyToHost_H",$chkDataId,$chkMselValue1);
- if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkServicedependencyToHost_DH",$chkDataId,$chkMselValue2);
- if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkServicedependencyToHostgroup_H",$chkDataId,$chkMselValue3);
- if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkServicedependencyToHostgroup_DH",$chkDataId,$chkMselValue4);
- if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue5 != 0) $intRet5 = $myDataClass->dataInsertRelation("tbl_lnkServicedependencyToService_S",$chkDataId,$chkMselValue5);
- if (isset($intRet5) && ($intRet5 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue6 != 0) $intRet6 = $myDataClass->dataInsertRelation("tbl_lnkServicedependencyToService_DS",$chkDataId,$chkMselValue6);
- if (isset($intRet6) && ($intRet6 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue7 != 0) $intRet7 = $myDataClass->dataInsertRelation("tbl_lnkServicedependencyToServicegroup_S",$chkDataId,$chkMselValue7);
- if (isset($intRet7) && ($intRet7 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue8 != 0) $intRet8 = $myDataClass->dataInsertRelation("tbl_lnkServicedependencyToServicegroup_DS",$chkDataId,$chkMselValue8);
- if (isset($intRet8) && ($intRet8 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- } else if ($chkModus == "modify") {
- if ($intMselValue1 != 0) {
- $intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkServicedependencyToHost_H",$chkDataId,$chkMselValue1);
- } else {
- $intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkServicedependencyToHost_H",$chkDataId);
- }
- if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue2 != 0) {
- $intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkServicedependencyToHost_DH",$chkDataId,$chkMselValue2);
- } else {
- $intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkServicedependencyToHost_DH",$chkDataId);
- }
- if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue3 != 0) {
- $intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkServicedependencyToHostgroup_H",$chkDataId,$chkMselValue3);
- } else {
- $intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkServicedependencyToHostgroup_H",$chkDataId);
- }
- if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue4 != 0) {
- $intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkServicedependencyToHostgroup_DH",$chkDataId,$chkMselValue4);
- } else {
- $intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkServicedependencyToHostgroup_DH",$chkDataId);
- }
- if ($intRet4 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue5 != 0) {
- $intRet5 = $myDataClass->dataUpdateRelation("tbl_lnkServicedependencyToService_S",$chkDataId,$chkMselValue5);
- } else {
- $intRet5 = $myDataClass->dataDeleteRelation("tbl_lnkServicedependencyToService_S",$chkDataId);
- }
- if ($intRet5 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue6 != 0) {
- $intRet6 = $myDataClass->dataUpdateRelation("tbl_lnkServicedependencyToService_DS",$chkDataId,$chkMselValue6);
- } else {
- $intRet6 = $myDataClass->dataDeleteRelation("tbl_lnkServicedependencyToService_DS",$chkDataId);
- }
- if ($intRet6 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue7 != 0) {
- $intRet7 = $myDataClass->dataUpdateRelation("tbl_lnkServicedependencyToServicegroup_S",$chkDataId,$chkMselValue7);
- } else {
- $intRet7 = $myDataClass->dataDeleteRelation("tbl_lnkServicedependencyToServicegroup_S",$chkDataId);
- }
- if ($intRet7 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue8 != 0) {
- $intRet8 = $myDataClass->dataUpdateRelation("tbl_lnkServicedependencyToServicegroup_DS",$chkDataId,$chkMselValue8);
- } else {
- $intRet8 = $myDataClass->dataDeleteRelation("tbl_lnkServicedependencyToServicegroup_DS",$chkDataId);
- }
- if ($intRet8 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- }
- if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6 + $intRet7 + $intRet8) != 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 == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
+ $strSQLx = "`$preTableName` SET `dependent_host_name`=$intMselValue2, `dependent_hostgroup_name`=$intMselValue4, "
+ . "`dependent_service_description`=$intMselValue6, `dependent_servicegroup_name`=$intMselValue8, "
+ . "`host_name`=$intMselValue1, `hostgroup_name`=$intMselValue3, `service_description`=$intMselValue5, "
+ . "`servicegroup_name`=$intMselValue7, `$preKeyField`='$chkTfValue1', `inherits_parent`='$chkChbValue1', "
+ . "`execution_failure_criteria`='$strEO', `notification_failure_criteria`='$strNO', "
+ . "`dependency_period`=$chkSelValue1, $preSQLCommon1";
+ if ($chkModus == 'insert') {
+ $strSQL = 'INSERT INTO ' .$strSQLx;
+ } else {
+ $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
+ }
+ if ($intWriteAccessId == 0) {
+ if (($chkTfValue1 != '') && (($intMselValue5 != 0) || ($intMselValue7 != 0)) &&
+ (($intMselValue6 != 0) || ($intMselValue8 != 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 dependency inserted:'). ' ' .$chkTfValue1);
+ }
+ if ($chkModus == 'modify') {
+ $myDataClass->writeLog(translate('Service dependency modified:'). ' ' .$chkTfValue1);
+ }
+ //
+ // Insert/update relations
+ // =======================
+ if ($chkModus == 'insert') {
+ if ($intMselValue1 != 0) {
+ $intRet1 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicedependencyToHost_H',
+ $chkDataId,
+ $chkMselValue1
+ );
+ }
+ if (isset($intRet1) && ($intRet1 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue2 != 0) {
+ $intRet2 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicedependencyToHost_DH',
+ $chkDataId,
+ $chkMselValue2
+ );
+ }
+ if (isset($intRet2) && ($intRet2 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue3 != 0) {
+ $intRet3 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicedependencyToHostgroup_H',
+ $chkDataId,
+ $chkMselValue3
+ );
+ }
+ if (isset($intRet3) && ($intRet3 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue4 != 0) {
+ $intRet4 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicedependencyToHostgroup_DH',
+ $chkDataId,
+ $chkMselValue4
+ );
+ }
+ if (isset($intRet4) && ($intRet4 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue5 != 0) {
+ $intRet5 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicedependencyToService_S',
+ $chkDataId,
+ $chkMselValue5
+ );
+ }
+ if (isset($intRet5) && ($intRet5 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue6 != 0) {
+ $intRet6 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicedependencyToService_DS',
+ $chkDataId,
+ $chkMselValue6
+ );
+ }
+ if (isset($intRet6) && ($intRet6 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue7 != 0) {
+ $intRet7 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicedependencyToServicegroup_S',
+ $chkDataId,
+ $chkMselValue7
+ );
+ }
+ if (isset($intRet7) && ($intRet7 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue8 != 0) {
+ $intRet8 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicedependencyToServicegroup_DS',
+ $chkDataId,
+ $chkMselValue8
+ );
+ }
+ if (isset($intRet8) && ($intRet8 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ } elseif ($chkModus == 'modify') {
+ if ($intMselValue1 != 0) {
+ $intRet1 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicedependencyToHost_H',
+ $chkDataId,
+ $chkMselValue1
+ );
+ } else {
+ $intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkServicedependencyToHost_H', $chkDataId);
+ }
+ if ($intRet1 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue2 != 0) {
+ $intRet2 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicedependencyToHost_DH',
+ $chkDataId,
+ $chkMselValue2
+ );
+ } else {
+ $intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkServicedependencyToHost_DH', $chkDataId);
+ }
+ if ($intRet2 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue3 != 0) {
+ $intRet3 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicedependencyToHostgroup_H',
+ $chkDataId,
+ $chkMselValue3
+ );
+ } else {
+ $intRet3 = $myDataClass->dataDeleteRelation(
+ 'tbl_lnkServicedependencyToHostgroup_H',
+ $chkDataId
+ );
+ }
+ if ($intRet3 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue4 != 0) {
+ $intRet4 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicedependencyToHostgroup_DH',
+ $chkDataId,
+ $chkMselValue4
+ );
+ } else {
+ $intRet4 = $myDataClass->dataDeleteRelation(
+ 'tbl_lnkServicedependencyToHostgroup_DH',
+ $chkDataId
+ );
+ }
+ if ($intRet4 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue5 != 0) {
+ $intRet5 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicedependencyToService_S',
+ $chkDataId,
+ $chkMselValue5
+ );
+ } else {
+ $intRet5 = $myDataClass->dataDeleteRelation(
+ 'tbl_lnkServicedependencyToService_S',
+ $chkDataId
+ );
+ }
+ if ($intRet5 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue6 != 0) {
+ $intRet6 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicedependencyToService_DS',
+ $chkDataId,
+ $chkMselValue6
+ );
+ } else {
+ $intRet6 = $myDataClass->dataDeleteRelation(
+ 'tbl_lnkServicedependencyToService_DS',
+ $chkDataId
+ );
+ }
+ if ($intRet6 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue7 != 0) {
+ $intRet7 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicedependencyToServicegroup_S',
+ $chkDataId,
+ $chkMselValue7
+ );
+ } else {
+ $intRet7 = $myDataClass->dataDeleteRelation(
+ 'tbl_lnkServicedependencyToServicegroup_S',
+ $chkDataId
+ );
+ }
+ if ($intRet7 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue8 != 0) {
+ $intRet8 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicedependencyToServicegroup_DS',
+ $chkDataId,
+ $chkMselValue8
+ );
+ } else {
+ $intRet8 = $myDataClass->dataDeleteRelation(
+ 'tbl_lnkServicedependencyToServicegroup_DS',
+ $chkDataId
+ );
+ }
+ if ($intRet8 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6 + $intRet7 + $intRet8) != 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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define service dependencies (servicedependencies.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-if (($chkModus == "add") || ($chkModus == "refresh")) {
- if ($chkModus == "refresh") {
- $_SESSION['refresh']['sd_host'] = $chkMselValue1;
- $_SESSION['refresh']['sd_dependent_host'] = $chkMselValue2;
- $_SESSION['refresh']['sd_hostgroup'] = $chkMselValue3;
- $_SESSION['refresh']['sd_dependent_hostgroup'] = $chkMselValue4;
- $_SESSION['refresh']['sd_service'] = $chkMselValue5;
- $_SESSION['refresh']['sd_dependent_service'] = $chkMselValue6;
- $_SESSION['refresh']['sd_servicegroup'] = $chkMselValue7;
- $_SESSION['refresh']['sd_dependent_servicegroup'] = $chkMselValue8;
- } else {
- $_SESSION['refresh']['sd_host'] = $chkMselValue1;
- $_SESSION['refresh']['sd_dependent_host'] = $chkMselValue2;
- $_SESSION['refresh']['sd_hostgroup'] = $chkMselValue3;
- $_SESSION['refresh']['sd_dependent_hostgroup'] = $chkMselValue4;
- $_SESSION['refresh']['sd_service'] = $chkMselValue5;
- $_SESSION['refresh']['sd_dependent_service'] = $chkMselValue6;
- $_SESSION['refresh']['sd_servicegroup'] = $chkMselValue7;
- $_SESSION['refresh']['sd_dependent_servicegroup'] = $chkMselValue8;
- if (isset($arrModifyData['dependent_host_name']) && ($arrModifyData['dependent_host_name'] > 0 )) {
- $arrTemp = array();
- $strSQL = "SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHost_DH` WHERE `idMaster` = ".$arrModifyData['id'];
- $booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDC);
- if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
- if ($booReturn && ($intDC != 0)) {
- foreach ($arrData AS $elem) {
- if ($elem['exclude'] == 1) {
- $arrTemp[] = "e".$elem['idSlave'];
- } else {
- $arrTemp[] = $elem['idSlave'];
- }
- }
- }
- if ($arrModifyData['dependent_host_name'] == 2) $arrTemp[] = '*';
- $_SESSION['refresh']['sd_dependent_host'] = $arrTemp;
- }
- if (isset($arrModifyData['host_name']) && ($arrModifyData['host_name'] > 0 )){
- $arrTemp = array();
- $strSQL = "SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHost_H` WHERE `idMaster` = ".$arrModifyData['id'];
- $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']['sd_host'] = $arrTemp;
- }
- if (isset($arrModifyData['dependent_hostgroup_name']) && ($arrModifyData['dependent_hostgroup_name'] > 0 )){
- $arrTemp = array();
- $strSQL = "SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHostgroup_DH` WHERE `idMaster` = ".$arrModifyData['id'];
- $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['dependent_hostgroup_name'] == 2) $arrTemp[] = '*';
- $_SESSION['refresh']['sd_dependent_hostgroup'] = $arrTemp;
- }
- if (isset($arrModifyData['hostgroup_name']) && ($arrModifyData['hostgroup_name'] > 0 )){
- $arrTemp = array();
- $strSQL = "SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHostgroup_H` WHERE `idMaster` = ".$arrModifyData['id'];
- $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']['sd_hostgroup'] = $arrTemp;
- }
- }
- // Do not show modified time list
- $intNoTime = 1;
- // Process host selection field
- if (isset($arrModifyData['dependent_host_name'])) {$intFieldId = $arrModifyData['dependent_host_name'];} else {$intFieldId = 0;}
- if (($chkModus == "refresh") && (count($chkMselValue2) != 0)) {$strRefresh = 'sd_dependent_host';} else {$strRefresh = '';}
- $intReturn1 = $myVisClass->parseSelectMulti('tbl_host','host_name','dependent_host','tbl_lnkServicedependencyToHost_DH',0,$intFieldId,-9,$strRefresh);
- if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- if (isset($arrModifyData['host_name'])) {$intFieldId = $arrModifyData['host_name'];} else {$intFieldId = 0;}
- if (($chkModus == "refresh") && (count($chkMselValue1) != 0)) {$strRefresh = 'sd_host';} else {$strRefresh = '';}
- $intReturn1 = $myVisClass->parseSelectMulti('tbl_host','host_name','host','tbl_lnkServicedependencyToHost_H',0,$intFieldId,-9,$strRefresh);
- if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- // Process time period selection field
- if (isset($arrModifyData['dependency_period'])) {$intFieldId = $arrModifyData['dependency_period'];} else {$intFieldId = 0;}
- if ($chkModus == "refresh") {$intFieldId = $chkSelValue1;}
- $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;}
- if (($chkModus == "refresh") && (count($chkMselValue4) != 0)) {$strRefresh = 'sd_dependent_hostgroup';} else {$strRefresh = '';}
- $intReturn2 = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','dependent_hostgroup','tbl_lnkServicedependencyToHostgroup_DH',0,$intFieldId,-9,$strRefresh);
- if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- if (isset($arrModifyData['hostgroup_name'])) {$intFieldId = $arrModifyData['hostgroup_name'];} else {$intFieldId = 0;}
- if (($chkModus == "refresh") && (count($chkMselValue3) != 0)) {$strRefresh = 'sd_hostgroup';} else {$strRefresh = '';}
- $intReturn2 = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','hostgroup','tbl_lnkServicedependencyToHostgroup_H',0,$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 services selection field
- if (isset($arrModifyData['dependent_service_description'])) {$intFieldId = $arrModifyData['dependent_service_description'];} else {$intFieldId = 0;}
- if (($chkModus == "refresh") && (count($chkMselValue6) != 0)) {$strRefresh = 'sd_dependent_service';} else {$strRefresh = '';}
- $intReturn = $myVisClass->parseSelectMulti('tbl_service','service_description','dependent_service','tbl_lnkServicedependencyToService_DS',2,$intFieldId,-9,$strRefresh);
- if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- if (isset($arrModifyData['service_description'])) {$intFieldId = $arrModifyData['service_description'];} else {$intFieldId = 0;}
- if (($chkModus == "refresh") && (count($chkMselValue5) != 0)) {$strRefresh = 'sd_service';} else {$strRefresh = '';}
- $intReturn = $myVisClass->parseSelectMulti('tbl_service','service_description','service','tbl_lnkServicedependencyToService_S',2,$intFieldId,-9,$strRefresh);
- if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- // Process servicegroup selection field
- if (isset($arrModifyData['dependent_servicegroup_name'])) {$intFieldId = $arrModifyData['dependent_servicegroup_name'];} else {$intFieldId = 0;}
- if (($chkModus == "refresh") && (count($chkMselValue8) != 0)) {$strRefresh = 'sd_dependent_servicegroup';} else {$strRefresh = '';}
- $intReturn = $myVisClass->parseSelectMulti('tbl_servicegroup','servicegroup_name','dependent_servicegroup','tbl_lnkServicedependencyToServicegroup_DS',0,$intFieldId,-9,$strRefresh);
- if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- if (isset($arrModifyData['servicegroup_name'])) {$intFieldId = $arrModifyData['servicegroup_name'];} else {$intFieldId = 0;}
- if (($chkModus == "refresh") && (count($chkMselValue7) != 0)) {$strRefresh = 'sd_servicegroup';} else {$strRefresh = '';}
- $intReturn = $myVisClass->parseSelectMulti('tbl_servicegroup','servicegroup_name','servicegroup','tbl_lnkServicedependencyToServicegroup_S',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." ".translate('Saving not possible!'));
- if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,");
- if ($chkModus == "refresh") {
- if ($chkTfValue1 != "") $conttp->setVariable("DAT_CONFIG_NAME",$chkTfValue1);
- foreach(explode(",",$strEO) AS $elem) {
- $conttp->setVariable("DAT_EO".strtoupper($elem)."_CHECKED","checked");
- }
- foreach(explode(",",$strNO) AS $elem) {
- $conttp->setVariable("DAT_NO".strtoupper($elem)."_CHECKED","checked");
- }
- if ($chkActive != 1) $conttp->setVariable("ACT_CHECKED","");
- if ($chkRegister != 1) $conttp->setVariable("REG_CHECKED","");
- if ($chkChbValue1 == 1) $conttp->setVariable("ACT_INHERIT","checked");
- if ($chkDataId != 0) {
- $conttp->setVariable("DAT_ID",$chkDataId);
- $conttp->setVariable("MODUS","modify");
- }
- // 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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // Process data
- $myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
- // Setting special data
- 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') || ($chkModus == 'refresh')) {
+ $conttp->setVariable('TITLE', translate('Define service dependencies (servicedependencies.cfg)'));
+ if ($chkModus == 'refresh') {
+ $_SESSION['refresh']['sd_host'] = $chkMselValue1;
+ $_SESSION['refresh']['sd_dependent_host'] = $chkMselValue2;
+ $_SESSION['refresh']['sd_hostgroup'] = $chkMselValue3;
+ $_SESSION['refresh']['sd_dependent_hostgroup'] = $chkMselValue4;
+ $_SESSION['refresh']['sd_service'] = $chkMselValue5;
+ $_SESSION['refresh']['sd_dependent_service'] = $chkMselValue6;
+ $_SESSION['refresh']['sd_servicegroup'] = $chkMselValue7;
+ $_SESSION['refresh']['sd_dependent_servicegroup'] = $chkMselValue8;
+ $myVisClass->arrSession = $_SESSION;
+ } else {
+ $_SESSION['refresh']['sd_host'] = $chkMselValue1;
+ $_SESSION['refresh']['sd_dependent_host'] = $chkMselValue2;
+ $_SESSION['refresh']['sd_hostgroup'] = $chkMselValue3;
+ $_SESSION['refresh']['sd_dependent_hostgroup'] = $chkMselValue4;
+ $_SESSION['refresh']['sd_service'] = $chkMselValue5;
+ $_SESSION['refresh']['sd_dependent_service'] = $chkMselValue6;
+ $_SESSION['refresh']['sd_servicegroup'] = $chkMselValue7;
+ $_SESSION['refresh']['sd_dependent_servicegroup'] = $chkMselValue8;
+ if (isset($arrModifyData['dependent_host_name']) && ($arrModifyData['dependent_host_name'] > 0)) {
+ $arrTemp = array();
+ $strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHost_DH` '
+ . 'WHERE `idMaster` = ' .$arrModifyData['id'];
+ $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
+ if ($booReturn == false) {
+ $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($booReturn && ($intDC != 0)) {
+ foreach ($arrData as $elem) {
+ if ($elem['exclude'] == 1) {
+ $arrTemp[] = 'e' .$elem['idSlave'];
+ } else {
+ $arrTemp[] = $elem['idSlave'];
+ }
+ }
+ }
+ if ($arrModifyData['dependent_host_name'] == 2) {
+ $arrTemp[] = '*';
+ }
+ $_SESSION['refresh']['sd_dependent_host'] = $arrTemp;
+ }
+ if (isset($arrModifyData['host_name']) && ($arrModifyData['host_name'] > 0)) {
+ $arrTemp = array();
+ $strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHost_H` '
+ . 'WHERE `idMaster` = ' .$arrModifyData['id'];
+ $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']['sd_host'] = $arrTemp;
+ }
+ if (isset($arrModifyData['dependent_hostgroup_name']) && ($arrModifyData['dependent_hostgroup_name'] > 0)) {
+ $arrTemp = array();
+ $strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHostgroup_DH` '
+ . 'WHERE `idMaster` = ' .$arrModifyData['id'];
+ $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['dependent_hostgroup_name'] == 2) {
+ $arrTemp[] = '*';
+ }
+ $_SESSION['refresh']['sd_dependent_hostgroup'] = $arrTemp;
+ }
+ if (isset($arrModifyData['hostgroup_name']) && ($arrModifyData['hostgroup_name'] > 0)) {
+ $arrTemp = array();
+ $strSQL = 'SELECT `idSlave`, `exclude` FROM `tbl_lnkServicedependencyToHostgroup_H` '
+ . 'WHERE `idMaster` = ' .$arrModifyData['id'];
+ $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']['sd_hostgroup'] = $arrTemp;
+ }
+ $myVisClass->arrSession = $_SESSION;
+ }
+ // Do not show modified time list
+ $intNoTime = 1;
+ // Process host selection field
+ if (isset($arrModifyData['dependent_host_name'])) {
+ $intFieldId = $arrModifyData['dependent_host_name'];
+ } else {
+ $intFieldId = 0;
+ }
+ if (($chkModus == 'refresh') && is_array($chkMselValue2) && (count($chkMselValue2) != 0)) {
+ $strRefresh = 'sd_dependent_host';
+ } else {
+ $strRefresh = '';
+ }
+ $intReturn1 = $myVisClass->parseSelectMulti(
+ 'tbl_host',
+ 'host_name',
+ 'dependent_host',
+ 'tbl_lnkServicedependencyToHost_DH',
+ 0,
+ $intFieldId,
+ -9,
+ $strRefresh
+ );
+ if ($intReturn1 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['host_name'])) {
+ $intFieldId = $arrModifyData['host_name'];
+ } else {
+ $intFieldId = 0;
+ }
+ if (($chkModus == 'refresh') && is_array($chkMselValue1) && (count($chkMselValue1) != 0)) {
+ $strRefresh = 'sd_host';
+ } else {
+ $strRefresh = '';
+ }
+ $intReturn1 = $myVisClass->parseSelectMulti(
+ 'tbl_host',
+ 'host_name',
+ 'host',
+ 'tbl_lnkServicedependencyToHost_H',
+ 0,
+ $intFieldId,
+ -9,
+ $strRefresh
+ );
+ if ($intReturn1 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process time period selection field
+ if (isset($arrModifyData['dependency_period'])) {
+ $intFieldId = $arrModifyData['dependency_period'];
+ } else {
+ $intFieldId = 0;
+ }
+ if ($chkModus == 'refresh') {
+ $intFieldId = $chkSelValue1;
+ }
+ $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;
+ }
+ if (($chkModus == 'refresh') && is_array($chkMselValue4) && (count($chkMselValue4) != 0)) {
+ $strRefresh = 'sd_dependent_hostgroup';
+ } else {
+ $strRefresh = '';
+ }
+ $intReturn2 = $myVisClass->parseSelectMulti(
+ 'tbl_hostgroup',
+ 'hostgroup_name',
+ 'dependent_hostgroup',
+ 'tbl_lnkServicedependencyToHostgroup_DH',
+ 0,
+ $intFieldId,
+ -9,
+ $strRefresh
+ );
+ if ($intReturn2 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['hostgroup_name'])) {
+ $intFieldId = $arrModifyData['hostgroup_name'];
+ } else {
+ $intFieldId = 0;
+ }
+ if (($chkModus == 'refresh') && is_array($chkMselValue3) && (count($chkMselValue3) != 0)) {
+ $strRefresh = 'sd_hostgroup';
+ } else {
+ $strRefresh = '';
+ }
+ $intReturn2 = $myVisClass->parseSelectMulti(
+ 'tbl_hostgroup',
+ 'hostgroup_name',
+ 'hostgroup',
+ 'tbl_lnkServicedependencyToHostgroup_H',
+ 0,
+ $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 services selection field
+ if (isset($arrModifyData['dependent_service_description'])) {
+ $intFieldId = $arrModifyData['dependent_service_description'];
+ } else {
+ $intFieldId = 0;
+ }
+ if (($chkModus == 'refresh') && is_array($chkMselValue6) && (count($chkMselValue6) != 0)) {
+ $strRefresh = 'sd_dependent_service';
+ } else {
+ $strRefresh = '';
+ }
+ $intReturn = $myVisClass->parseSelectMulti(
+ 'tbl_service',
+ 'service_description',
+ 'dependent_service',
+ 'tbl_lnkServicedependencyToService_DS',
+ 2,
+ $intFieldId,
+ -9,
+ $strRefresh
+ );
+ if ($intReturn != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['service_description'])) {
+ $intFieldId = $arrModifyData['service_description'];
+ } else {
+ $intFieldId = 0;
+ }
+ if (($chkModus == 'refresh') && is_array($chkMselValue5) && (count($chkMselValue5) != 0)) {
+ $strRefresh = 'sd_service';
+ } else {
+ $strRefresh = '';
+ }
+ $intReturn = $myVisClass->parseSelectMulti(
+ 'tbl_service',
+ 'service_description',
+ 'service',
+ 'tbl_lnkServicedependencyToService_S',
+ 2,
+ $intFieldId,
+ -9,
+ $strRefresh
+ );
+ if ($intReturn != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process servicegroup selection field
+ if (isset($arrModifyData['dependent_servicegroup_name'])) {
+ $intFieldId = $arrModifyData['dependent_servicegroup_name'];
+ } else {
+ $intFieldId = 0;
+ }
+ if (($chkModus == 'refresh') && is_array($chkMselValue8) && (count($chkMselValue8) != 0)) {
+ $strRefresh = 'sd_dependent_servicegroup';
+ } else {
+ $strRefresh = '';
+ }
+ $intReturn = $myVisClass->parseSelectMulti(
+ 'tbl_servicegroup',
+ 'servicegroup_name',
+ 'dependent_servicegroup',
+ 'tbl_lnkServicedependencyToServicegroup_DS',
+ 0,
+ $intFieldId,
+ -9,
+ $strRefresh
+ );
+ if ($intReturn != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['servicegroup_name'])) {
+ $intFieldId = $arrModifyData['servicegroup_name'];
+ } else {
+ $intFieldId = 0;
+ }
+ if (($chkModus == 'refresh') && is_array($chkMselValue7) && (count($chkMselValue7) != 0)) {
+ $strRefresh = 'sd_servicegroup';
+ } else {
+ $strRefresh = '';
+ }
+ $intReturn = $myVisClass->parseSelectMulti(
+ 'tbl_servicegroup',
+ 'servicegroup_name',
+ 'servicegroup',
+ 'tbl_lnkServicedependencyToServicegroup_S',
+ 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. ' ' .translate('Saving not possible!'));
+ }
+ if ($intVersion < 3) {
+ $conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
+ }
+ if ($chkModus == 'refresh') {
+ if ($chkTfValue1 != '') {
+ $conttp->setVariable('DAT_CONFIG_NAME', $chkTfValue1);
+ }
+ foreach (explode(',', $strEO) as $elem) {
+ $conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
+ }
+ foreach (explode(',', $strNO) as $elem) {
+ $conttp->setVariable('DAT_NO' .strtoupper($elem). '_CHECKED', 'checked');
+ }
+ if ($chkActive != 1) {
+ $conttp->setVariable('ACT_CHECKED', '');
+ }
+ if ($chkRegister != 1) {
+ $conttp->setVariable('REG_CHECKED', '');
+ }
+ if ($chkChbValue1 == 1) {
+ $conttp->setVariable('ACT_INHERIT', 'checked');
+ }
+ if ($chkDataId != 0) {
+ $conttp->setVariable('DAT_ID', $chkDataId);
+ $conttp->setVariable('MODUS', 'modify');
+ }
+ // Insert data from database in "modify" mode
+ } elseif (isset($arrModifyData) && ($chkSelModify == 'modify')) {
+ // Check relation information to find out locked configuration datasets
+ $intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
+ $myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
+ $strInfo = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // Process data
+ $myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
+ // Setting special data
+ 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("FIELD_1",translate('Config name'));
- $mastertp->setVariable("FIELD_2",translate('Dependent services'));
- // Process search string
- if ($_SESSION['search'][$preSearchSession] != "") {
- $strSearchTxt = $_SESSION['search'][$preSearchSession];
- $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')";
- }
- // 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_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);
+if ($chkModus == 'display') {
+ // Initial list view definitions
+ $myContentClass->listViewInit($mastertp);
+ $mastertp->setVariable('TITLE', translate('Define service dependencies (servicedependencies.cfg)'));
+ $mastertp->setVariable('FIELD_1', translate('Config name'));
+ $mastertp->setVariable('FIELD_2', translate('Dependent services'));
+ // Process search string
+ if ($_SESSION['search'][$preSearchSession] != '') {
+ $strSearchTxt = $_SESSION['search'][$preSearchSession];
+ $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')";
+ }
+ // 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 datasetsk
+ $strSQL = "SELECT `id`, `$preKeyField`, `dependent_service_description`, `register`, `active`, `config_id`, "
+ . "`access_group` FROM `$preTableName`WHERE $strDomainWhere $strSearchWhere AND `access_group` "
+ . "IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
+ $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
+ );
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/serviceescalations.php b/admin/serviceescalations.php
index d7e8382..7412fc5 100644
--- a/admin/serviceescalations.php
+++ b/admin/serviceescalations.php
@@ -5,322 +5,611 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Service escalation definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'serviceescalation';
-$preTableName = 'tbl_serviceescalation';
-$preKeyField = 'config_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 23;
+$preContent = 'admin/serviceescalations.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'serviceescalation';
+$preTableName = 'tbl_serviceescalation';
+$preKeyField = 'config_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'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);
- } 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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define service escalation (serviceescalations.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // 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')) {
+ $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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ .'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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);
+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
+ );
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/serviceextinfo.php b/admin/serviceextinfo.php
index ac3dac5..226c29e 100644
--- a/admin/serviceextinfo.php
+++ b/admin/serviceextinfo.php
@@ -5,199 +5,275 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Service extended information definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Component : Service escalation definition
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'serviceextinfo';
-$preTableName = 'tbl_serviceextinfo';
-$preKeyField = 'host_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 24;
+$preContent = 'admin/serviceextinfo.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'serviceextinfo';
+$preTableName = 'tbl_serviceextinfo';
+$preKeyField = 'host_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
-//
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- $strSQLx = "`$preTableName` SET `$preKeyField`='$chkSelValue1', `service_description`='$chkSelValue2', `notes`='$chkTfValue1', `notes_url`='$chkTfValue2',
- `action_url`='$chkTfValue3', `icon_image`='$chkTfValue4', `icon_image_alt`='$chkTfValue5', $preSQLCommon1";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } 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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define service extended information (serviceextinfo.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // Process data
- $myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
- }
- $conttp->parse("datainsert");
- $conttp->show("datainsert");
+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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ .'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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');
+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'
+ );
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/servicegroups.php b/admin/servicegroups.php
index bd1e0bb..efdccd7 100644
--- a/admin/servicegroups.php
+++ b/admin/servicegroups.php
@@ -5,179 +5,277 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Admin servicegroup definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preSearchSession = 'servicegroup';
-$preTableName = 'tbl_servicegroup';
-$preKeyField = 'servicegroup_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 11;
+$preContent = 'admin/servicegroups.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'servicegroup';
+$preTableName = 'tbl_servicegroup';
+$preKeyField = 'servicegroup_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing file
// ==========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
-//
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, `servicegroup_members`=$intMselValue2,
- `notes`='$chkTfValue3', `notes_url`='$chkTfValue4', `action_url`='$chkTfValue5', $preSQLCommon1";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } 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 == '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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define service groups (servicegroups.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // Process data
- $myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo);
- }
- $conttp->parse("datainsert");
- $conttp->show("datainsert");
+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. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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("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');
+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');
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/services.php b/admin/services.php
index 13d4971..a0cb121 100644
--- a/admin/services.php
+++ b/admin/services.php
@@ -5,495 +5,789 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Service definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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 = 9;
-$preContent = "admin/services.tpl.htm";
-$preSearchSession = 'service';
-$preTableName = 'tbl_service';
-$preKeyField = 'config_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 9;
+$preContent = 'admin/services.htm.tpl';
+$preListTpl = 'admin/datalist_services.htm.tpl';
+$preSearchSession = 'service';
+$preTableName = 'tbl_service';
+$preKeyField = 'config_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
-$strNO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f,0,-1);
-$strIS = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d,0,-1);
-$strFL = substr($chkChbGr3a.$chkChbGr3b.$chkChbGr3c.$chkChbGr3d,0,-1);
-$strST = substr($chkChbGr4a.$chkChbGr4b.$chkChbGr4c.$chkChbGr4d,0,-1);
-if ($chkSelValue1 != "") {
- for ($i=1;$i<=8;$i++) {
- ${"chkTfArg$i"} = str_replace("!","::bang::",${"chkTfArg$i"});
- if (${"chkTfArg$i"} != "") $chkSelValue1 .= "!".${"chkTfArg$i"};
- }
+$strNO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f, 0, -1);
+$strIS = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d, 0, -1);
+$strFL = substr($chkChbGr3a.$chkChbGr3b.$chkChbGr3c.$chkChbGr3d, 0, -1);
+$strST = substr($chkChbGr4a.$chkChbGr4b.$chkChbGr4c.$chkChbGr4d, 0, -1);
+if ($chkSelValue1 != '') {
+ for ($i = 1; $i <= 8; $i++) {
+ $tmpVar = 'chkTfArg'.$i;
+ $$tmpVar = str_replace('!', '::bang::', $$tmpVar);
+ if ($$tmpVar != '') {
+ $chkSelValue1 .= '!' .$$tmpVar;
+ }
+ }
}
-//
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `host_name`=$intMselValue1, `host_name_tploptions`=$chkRadValue1, `hostgroup_name`=$intMselValue2,
- `hostgroup_name_tploptions`=$chkRadValue2, `service_description`='$chkTfValue3', `display_name`='$chkTfValue4', `servicegroups`=$intMselValue3,
- `servicegroups_tploptions`=$chkRadValue3, `check_command`='$chkSelValue1', `use_template`=$intTemplates, `is_volatile`=$chkRadValue14,
- `initial_state`='$strIS', `max_check_attempts`=$chkTfNullVal2, `check_interval`=$chkTfNullVal3, `retry_interval`=$chkTfNullVal1,
- `active_checks_enabled`=$chkRadValue4, `passive_checks_enabled`=$chkRadValue5, `check_period`=$chkSelValue2, `parallelize_check`=$chkRadValue6,
- `obsess_over_service`=$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`=$intMselValue4, `contacts_tploptions`=$chkRadValue15, `contact_groups`=$intMselValue5, `contact_groups_tploptions`=$chkRadValue16,
- `notification_interval`=$chkTfNullVal7, `notification_period`=$chkSelValue4, `first_notification_delay`=$chkTfNullVal8, `notification_options`='$strNO',
- `notifications_enabled`=$chkRadValue17, `stalking_options`='$strST', `notes`='$chkTfValue5', `notes_url`='$chkTfValue6', `action_url`='$chkTfValue7',
- `icon_image`='$chkTfValue8', `icon_image_alt`='$chkTfValue9', `name`='$chkTfValue10', $preSQLCommon1";
- if ($chkModus == "insert") {
- $strSQL = "INSERT INTO ".$strSQLx;
- } else {
- $strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId";
- }
- if ($intWriteAccessId == 0) {
- if (($chkTfValue1 != "") && ($chkTfValue3 != "")) {
- $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 service inserted:')." ".$chkTfValue1);
- if ($chkModus == "modify") $myDataClass->writeLog(translate('Service modified:')." ".$chkTfValue1);
- //
- // Insert/update relations
- // =======================
- if ($chkModus == "insert") {
- if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkServiceToHost",$chkDataId,$chkMselValue1);
- if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkServiceToHostgroup",$chkDataId,$chkMselValue2);
- if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkServiceToServicegroup",$chkDataId,$chkMselValue3);
- if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkServiceToContact",$chkDataId,$chkMselValue4);
- if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue5 != 0) $intRet5 = $myDataClass->dataInsertRelation("tbl_lnkServiceToContactgroup",$chkDataId,$chkMselValue5);
- if (isset($intRet5) && ($intRet5 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- } else if ($chkModus == "modify") {
- if ($intMselValue1 != 0) {
- $intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkServiceToHost",$chkDataId,$chkMselValue1);
- } else {
- $intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkServiceToHost",$chkDataId);
- }
- if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue2 != 0) {
- $intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkServiceToHostgroup",$chkDataId,$chkMselValue2);
- } else {
- $intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkServiceToHostgroup",$chkDataId);
- }
- if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue3 != 0) {
- $intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkServiceToServicegroup",$chkDataId,$chkMselValue3);
- } else {
- $intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkServiceToServicegroup",$chkDataId);
- }
- if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue4 != 0) {
- $intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkServiceToContact",$chkDataId,$chkMselValue4);
- } else {
- $intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkServiceToContact",$chkDataId);
- }
- if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue5 != 0) {
- $intRet5 = $myDataClass->dataUpdateRelation("tbl_lnkServiceToContactgroup",$chkDataId,$chkMselValue5);
- } else {
- $intRet5 = $myDataClass->dataDeleteRelation("tbl_lnkServiceToContactgroup",$chkDataId);
- }
- if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- }
- if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5) != 0) $strInfoMessage = "";
- //
- // Removing the config file if an entry was deleted or renamed
- // ===========================================================
- if (($chkModus == "modify") && ($chkTfValue2 != $chkTfValue1) && ($chkDomainId != 0)) {
- $intServiceCount = $myDBClass->countRows("SELECT * FROM `$preTableName`
- WHERE BINARY `$preKeyField`='$chkTfValue2' AND `config_id`=$chkDomainId AND `active`='1'");
- if ($intServiceCount == 0) {
- $arrConfigID = $myConfigClass->getConfigSets();
- if (($arrConfigID != 1) && is_array($arrConfigID)) {
- $intReturn = 0;
- foreach($arrConfigID AS $intConfigID) {
- $intReturn += $myConfigClass->moveFile("service",$chkTfValue2.".cfg",$intConfigID);
- }
- if ($intReturn == 0) {
- $myVisClass->processMessage(translate('The assigned, no longer used configuration files were deleted successfully!'),$strInfoMessage);
- $myDataClass->writeLog(translate('Service file deleted:')." ".$chkTfValue2.".cfg");
- } else {
- if ($chkDomainId == 0) {
- $myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check manually'),$strErrorMessage);
- } else {
- $myVisClass->processMessage(translate('Errors while deleting the old configuration file - please check!:'),$strErrorMessage);
- $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
- }
- }
- }
- }
- }
- //
- // Removing the config file if an entry was dectivated
- // ===================================================
- if (($chkModus == "modify") && ($chkActive == 0)) {
- $intServiceCount = $myDBClass->countRows("SELECT * FROM `$preTableName` WHERE `$preKeyField`='$chkTfValue2' AND `config_id`=$chkDomainId AND `active`='1'");
- if ($intServiceCount == 0) {
- $arrConfigID = $myConfigClass->getConfigSets();
- if (($arrConfigID != 1) && is_array($arrConfigID)) {
- $intReturn = 0;
- foreach($arrConfigID AS $intConfigID) {
- $intReturn += $myConfigClass->moveFile("service",$chkTfValue2.".cfg",$intConfigID);
- }
- if ($intReturn == 0) {
- $myVisClass->processMessage(translate('The assigned, no longer used configuration files were deleted successfully!'),$strInfoMessage);
- $myDataClass->writeLog(translate('Service file deleted:')." ".$chkTfValue2.".cfg");
- } else {
- $myVisClass->processMessage(translate('Errors while deleting the old configuration file - please check!:'),$strErrorMessage);
- $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
- }
- }
- }
- }
- //
- // Insert/update session data for templates
- // ========================================
- if ($chkModus == "modify") {
- $strSQL = "DELETE FROM `tbl_lnkServiceToServicetemplate` 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_lnkServiceToServicetemplate` (`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_lnkServiceToVariabledefinition` 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_lnkServiceToVariabledefinition` WHERE `idMaster`=$chkDataId";
- $intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
- if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- $strSQL = "UPDATE `tbl_service` SET `use_variables`=0 WHERE `id`=$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)) {
- $intCountVariable = 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_lnkServiceToVariabledefinition` (`idMaster`,`idSlave`)
- VALUES ($chkDataId,$intInsertId)";
- $intReturn2 = $myDataClass->dataInsert($strSQL,$intInsertId);
- if ($intReturn2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if (($intReturn1 == 0) && ($intReturn2 == 0)) $intCountVariable++;
- }
- }
- if ($intCountVariable != 0) {
- $strSQL = "UPDATE `tbl_service` SET `use_variables`=1 WHERE `id`=$chkDataId";
- $intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
- if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- }
- }
- //
- // Update Import HASH
- // ==================
- $intReturn = $myDataClass->updateHash($preTableName,$chkDataId);
- 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 == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
+ $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `host_name`=$intMselValue1, "
+ . "`host_name_tploptions`=$chkRadValue1, `hostgroup_name`=$intMselValue2, "
+ . "`hostgroup_name_tploptions`=$chkRadValue2, `service_description`='$chkTfValue3', "
+ . "`display_name`='$chkTfValue4', `parents`=$intMselValue6, `parents_tploptions`=$chkRadValue18, "
+ . "`importance`=$chkTfNullVal9, `servicegroups`=$intMselValue3, "
+ . "`servicegroups_tploptions`=$chkRadValue3, `check_command`='$chkSelValue1', "
+ . "`use_template`=$intTemplates, `is_volatile`=$chkRadValue14, `initial_state`='$strIS', "
+ . "`max_check_attempts`=$chkTfNullVal2, `check_interval`=$chkTfNullVal3, `retry_interval`=$chkTfNullVal1, "
+ . "`active_checks_enabled`=$chkRadValue4, `passive_checks_enabled`=$chkRadValue5, "
+ . "`check_period`=$chkSelValue2, `parallelize_check`=$chkRadValue6, `obsess_over_service`=$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`=$intMselValue4, `contacts_tploptions`=$chkRadValue15, `contact_groups`=$intMselValue5, "
+ . "`contact_groups_tploptions`=$chkRadValue16, `notification_interval`=$chkTfNullVal7, "
+ . "`notification_period`=$chkSelValue4, `first_notification_delay`=$chkTfNullVal8, "
+ . "`notification_options`='$strNO', `notifications_enabled`=$chkRadValue17, `stalking_options`='$strST', "
+ . "`notes`='$chkTfValue5', `notes_url`='$chkTfValue6', `action_url`='$chkTfValue7', "
+ . "`icon_image`='$chkTfValue8', `icon_image_alt`='$chkTfValue9', `name`='$chkTfValue10', $preSQLCommon1";
+ if ($chkModus == 'insert') {
+ $strSQL = 'INSERT INTO ' .$strSQLx;
+ } else {
+ $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
+ }
+ if ($intWriteAccessId == 0) {
+ if (($chkTfValue1 != '') && ($chkTfValue3 != '')) {
+ $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 service inserted:'). ' ' .$chkTfValue1);
+ }
+ if ($chkModus == 'modify') {
+ $myDataClass->writeLog(translate('Service modified:'). ' ' .$chkTfValue1);
+ }
+ //
+ // Insert/update relations
+ // =======================
+ if ($chkModus == 'insert') {
+ if ($intMselValue1 != 0) {
+ $intRet1 = $myDataClass->dataInsertRelation('tbl_lnkServiceToHost', $chkDataId, $chkMselValue1);
+ }
+ if (isset($intRet1) && ($intRet1 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue2 != 0) {
+ $intRet2 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServiceToHostgroup',
+ $chkDataId,
+ $chkMselValue2
+ );
+ }
+ if (isset($intRet2) && ($intRet2 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue3 != 0) {
+ $intRet3 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServiceToServicegroup',
+ $chkDataId,
+ $chkMselValue3
+ );
+ }
+ if (isset($intRet3) && ($intRet3 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue4 != 0) {
+ $intRet4 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServiceToContact',
+ $chkDataId,
+ $chkMselValue4
+ );
+ }
+ if (isset($intRet4) && ($intRet4 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue5 != 0) {
+ $intRet5 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServiceToContactgroup',
+ $chkDataId,
+ $chkMselValue5
+ );
+ }
+ if (isset($intRet5) && ($intRet5 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue6 != 0) {
+ $intRet6 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServiceToService',
+ $chkDataId,
+ $chkMselValue6
+ );
+ }
+ if (isset($intRet6) && ($intRet6 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ } elseif ($chkModus == 'modify') {
+ if ($intMselValue1 != 0) {
+ $intRet1 = $myDataClass->dataUpdateRelation('tbl_lnkServiceToHost', $chkDataId, $chkMselValue1);
+ } else {
+ $intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkServiceToHost', $chkDataId);
+ }
+ if (isset($intRet1) && ($intRet1 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue2 != 0) {
+ $intRet2 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServiceToHostgroup',
+ $chkDataId,
+ $chkMselValue2
+ );
+ } else {
+ $intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkServiceToHostgroup', $chkDataId);
+ }
+ if (isset($intRet1) && ($intRet1 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue3 != 0) {
+ $intRet3 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServiceToServicegroup',
+ $chkDataId,
+ $chkMselValue3
+ );
+ } else {
+ $intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkServiceToServicegroup', $chkDataId);
+ }
+ if (isset($intRet1) && ($intRet1 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue4 != 0) {
+ $intRet4 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServiceToContact',
+ $chkDataId,
+ $chkMselValue4
+ );
+ } else {
+ $intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkServiceToContact', $chkDataId);
+ }
+ if (isset($intRet1) && ($intRet1 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue5 != 0) {
+ $intRet5 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServiceToContactgroup',
+ $chkDataId,
+ $chkMselValue5
+ );
+ } else {
+ $intRet5 = $myDataClass->dataDeleteRelation('tbl_lnkServiceToContactgroup', $chkDataId);
+ }
+ if (isset($intRet5) && ($intRet1 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue6 != 0) {
+ $intRet6 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServiceToService',
+ $chkDataId,
+ $chkMselValue6
+ );
+ } else {
+ $intRet6 = $myDataClass->dataDeleteRelation('tbl_lnkServiceToService', $chkDataId);
+ }
+ if ($intRet6 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6) != 0) {
+ $strInfoMessage = '';
+ }
+ //
+ // Removing the config file if an entry was deleted or renamed
+ // ===========================================================
+ if (($chkModus == 'modify') && ($chkTfValue2 != $chkTfValue1) && ($chkDomainId != 0)) {
+ $intServiceCount = $myDBClass->countRows("SELECT * FROM `$preTableName` "
+ . "WHERE BINARY `$preKeyField`='$chkTfValue2' AND `config_id`=$chkDomainId "
+ . "AND `active`='1'");
+ if ($intServiceCount == 0) {
+ $myConfigClass->getConfigTargets($arrConfigID);
+ if (($arrConfigID != 1) && is_array($arrConfigID)) {
+ $intReturn = 0;
+ foreach ($arrConfigID as $intConfigID) {
+ $intReturn += $myConfigClass->moveFile('service', $chkTfValue2. '.cfg', $intConfigID);
+ }
+ if ($intReturn == 0) {
+ $myVisClass->processMessage(translate('The assigned, no longer used configuration '
+ . 'files were deleted successfully!'), $strInfoMessage);
+ $myDataClass->writeLog(translate('Service file deleted:'). ' ' .$chkTfValue2. '.cfg');
+ } else {
+ if ($chkDomainId == 0) {
+ $myVisClass->processMessage(translate('Common files cannot be removed from target '
+ . 'systems - please check manually'), $strErrorMessage);
+ } else {
+ $myVisClass->processMessage(translate('Errors while deleting the old configuration '
+ . 'file - please check!:'), $strErrorMessage);
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ }
+ }
+ }
+ //
+ // Removing the config file if an entry was dectivated
+ // ===================================================
+ if (($chkModus == 'modify') && ($chkActive == 0)) {
+ $intServiceCount = $myDBClass->countRows("SELECT * FROM `$preTableName` "
+ . "WHERE `$preKeyField`='$chkTfValue2' AND `config_id`=$chkDomainId AND `active`='1'");
+ if ($intServiceCount == 0) {
+ $myConfigClass->getConfigTargets($arrConfigID);
+ if (($arrConfigID != 1) && is_array($arrConfigID)) {
+ $intReturn = 0;
+ foreach ($arrConfigID as $intConfigID) {
+ $intReturn += $myConfigClass->moveFile('service', $chkTfValue2. '.cfg', $intConfigID);
+ }
+ if ($intReturn == 0) {
+ $myVisClass->processMessage(translate('The assigned, no longer used configuration '
+ . 'files were deleted successfully!'), $strInfoMessage);
+ $myDataClass->writeLog(translate('Service file deleted:'). ' ' .$chkTfValue2. '.cfg');
+ } else {
+ $myVisClass->processMessage(translate('Errors while deleting the old configuration '
+ . 'file - please check!:'), $strErrorMessage);
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ }
+ }
+ //
+ // Insert/update session data for templates
+ // ========================================
+ if ($chkModus == 'modify') {
+ $strSQL = 'DELETE FROM `tbl_lnkServiceToServicetemplate` 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_lnkServiceToServicetemplate` (`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_lnkServiceToVariabledefinition` 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);
+ }
+ }
+ }
+ $strSQL1 = 'DELETE FROM `tbl_lnkServiceToVariabledefinition` WHERE `idMaster`=' .$chkDataId;
+ $intReturn1 = $myDataClass->dataInsert($strSQL1, $intInsertId);
+ if ($intReturn1 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ $strSQL2 = 'UPDATE `tbl_service` SET `use_variables`=0 WHERE `id`=' .$chkDataId;
+ $intReturn2 = $myDataClass->dataInsert($strSQL2, $intInsertId);
+ if ($intReturn2 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
+ (count($_SESSION['variabledefinition']) != 0)) {
+ $intCountVariable = 0;
+ /** @noinspection ForeachSourceInspection */
+ 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_lnkServiceToVariabledefinition` (`idMaster`,`idSlave`) '
+ . "VALUES ($chkDataId,$intInsertId)";
+ $intReturn2 = $myDataClass->dataInsert($strSQL, $intInsertId);
+ if ($intReturn2 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if (($intReturn1 == 0) && ($intReturn2 == 0)) {
+ $intCountVariable++;
+ }
+ }
+ }
+ if ($intCountVariable != 0) {
+ $strSQL = 'UPDATE `tbl_service` SET `use_variables`=1 WHERE `id`=' .$chkDataId;
+ $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
+ if ($intReturn != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ }
+ //
+ // Update Import HASH
+ // ==================
+ $intReturn = $myDataClass->updateHash($preTableName, $chkDataId);
+ 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 != "add") $chkModus = "display";
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define services (services.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
//
// Singe data form
// ===============
-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`,`template_name`, `active` FROM `tbl_servicetemplate` 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 host selection field
- if (isset($arrModifyData['host_name'])) {$intFieldId = $arrModifyData['host_name'];} else {$intFieldId = 0;}
- $intReturn1 = $myVisClass->parseSelectMulti('tbl_host','host_name','hosts','tbl_lnkServiceToHost',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_lnkServiceToHostgroup',2,$intFieldId);
- if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- if (($intReturn1 != 0) && ($intReturn2 != 0)) {
- $myVisClass->processMessage(translate('Attention, no hosts or hostgroups defined!'),$strDBWarning);
- $intDataWarning = 1;
- }
- // Process service groups selection field
- if (isset($arrModifyData['servicegroups'])) {$intFieldId = $arrModifyData['servicegroups'];} else {$intFieldId = 0;}
- $intReturn = $myVisClass->parseSelectMulti('tbl_servicegroup','servicegroup_name','servicegroup','tbl_lnkServiceToServicegroup',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','servicecommand',2,$intFieldId);
- if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- if ($intReturn != 0) {
- $myVisClass->processMessage(translate('Attention, no check commands defined!'),$strDBWarning);
- $intDataWarning = 1;
- }
- // Process check period selection field
- 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);
- if ($intReturn != 0) {
- $myVisClass->processMessage(translate('Attention, no time periods defined!'),$strDBWarning);
- $intDataWarning = 1;
- }
- // 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;}
- $intReturn1 = $myVisClass->parseSelectMulti('tbl_contact','contact_name','service_contacts','tbl_lnkServiceToContact',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','service_contactgroups','tbl_lnkServiceToContactgroup',2,$intFieldId);
- if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- if (($intReturn != 0) && ($intReturn2 != 0)) {
- $myVisClass->processMessage(translate('Attention, no contacts or contact groups 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
- $strChbFields = "ACE,PCE,PAC,FRE,OBS,EVH,FLE,STI,NSI,PED,ISV,NOE,HOS,HOG,SEG,COT,COG,TPL";
- $myContentClass->addFormInit($conttp,$strChbFields);
- if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // 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_PAC".$arrModifyData['parallelize_check']."_CHECKED","checked");
- $conttp->setVariable("DAT_FRE".$arrModifyData['check_freshness']."_CHECKED","checked");
- $conttp->setVariable("DAT_OBS".$arrModifyData['obsess_over_service']."_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_ISV".$arrModifyData['is_volatile']."_CHECKED","checked");
- $conttp->setVariable("DAT_NOE".$arrModifyData['notifications_enabled']."_CHECKED","checked");
- $conttp->setVariable("DAT_HOS".$arrModifyData['host_name_tploptions']."_CHECKED","checked");
- $conttp->setVariable("DAT_HOG".$arrModifyData['hostgroup_name_tploptions']."_CHECKED","checked");
- $conttp->setVariable("DAT_SEG".$arrModifyData['servicegroups_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 {
- $value = str_replace("::bang::","!",$value);
- $value = str_replace("::back::","\\",$value);
- $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') {
+ $conttp->setVariable('TITLE', translate('Define services (services.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`,`template_name`, `active` FROM `tbl_servicetemplate` '
+ . "WHERE $strDomainWhere2 ORDER BY `template_name`";
+ $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['template_name'], ENT_QUOTES, 'UTF-8').
+ $strActive);
+ $conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::1');
+ $conttp->parse('template');
+ }
+ }
+ $strSQL2 = "SELECT `id`, `name`, `active` FROM `$preTableName` "
+ . "WHERE `name` <> '' $strWhere AND $strDomainWhere 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['host_name'])) {
+ $intFieldId = $arrModifyData['host_name'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn3 = $myVisClass->parseSelectMulti(
+ 'tbl_host',
+ 'host_name',
+ 'hosts',
+ 'tbl_lnkServiceToHost',
+ 2,
+ $intFieldId
+ );
+ if ($intReturn3 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['hostgroup_name'])) {
+ $intFieldId = $arrModifyData['hostgroup_name'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn4 = $myVisClass->parseSelectMulti(
+ 'tbl_hostgroup',
+ 'hostgroup_name',
+ 'hostgroup',
+ 'tbl_lnkServiceToHostgroup',
+ 2,
+ $intFieldId
+ );
+ if ($intReturn4 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (($intReturn3 != 0) && ($intReturn4 != 0)) {
+ $myVisClass->processMessage(translate('Attention, no hosts or hostgroups defined!'), $strDBWarning);
+ $intDataWarning = 1;
+ }
+ // Process service selection field
+ if (isset($arrModifyData['parents'])) {
+ $intFieldId = $arrModifyData['parents'];
+ } else {
+ $intFieldId = 0;
+ }
+ if (isset($arrModifyData['id'])) {
+ $intKeyId = $arrModifyData['id'];
+ } else {
+ $intKeyId = 0;
+ }
+ $intReturn3 = $myVisClass->parseSelectMulti(
+ $preTableName,
+ $preKeyField,
+ 'service_parents',
+ 'tbl_lnkServiceToService',
+ 0,
+ $intFieldId,
+ $intKeyId
+ );
+ if ($intReturn3 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process service groups selection field
+ if (isset($arrModifyData['servicegroups'])) {
+ $intFieldId = $arrModifyData['servicegroups'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn5 = $myVisClass->parseSelectMulti(
+ 'tbl_servicegroup',
+ 'servicegroup_name',
+ 'servicegroup',
+ 'tbl_lnkServiceToServicegroup',
+ 0,
+ $intFieldId
+ );
+ if ($intReturn5 != 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;
+ }
+ $intReturn6 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'servicecommand', 2, $intFieldId);
+ if ($intReturn6 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intReturn6 != 0) {
+ $myVisClass->processMessage(translate('Attention, no check commands defined!'), $strDBWarning);
+ $intDataWarning = 1;
+ }
+ // Process check period selection field
+ if (isset($arrModifyData['check_period'])) {
+ $intFieldId = $arrModifyData['check_period'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn7 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'checkperiod', 1, $intFieldId);
+ if ($intReturn7 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['notification_period'])) {
+ $intFieldId = $arrModifyData['notification_period'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn8 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'notifyperiod', 1, $intFieldId);
+ if ($intReturn8 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intReturn8 != 0) {
+ $myVisClass->processMessage(translate('Attention, no time periods defined!'), $strDBWarning);
+ $intDataWarning = 1;
+ }
+ // Process event handler selection field
+ if (isset($arrModifyData['event_handler'])) {
+ $intFieldId = $arrModifyData['event_handler'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn9 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'eventhandler', 1, $intFieldId);
+ if ($intReturn9 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process contact and contact group selection field
+ if (isset($arrModifyData['contacts'])) {
+ $intFieldId = $arrModifyData['contacts'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn10 = $myVisClass->parseSelectMulti(
+ 'tbl_contact',
+ 'contact_name',
+ 'service_contacts',
+ 'tbl_lnkServiceToContact',
+ 2,
+ $intFieldId
+ );
+ if ($intReturn10 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['contact_groups'])) {
+ $intFieldId = $arrModifyData['contact_groups'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn12 = $myVisClass->parseSelectMulti(
+ 'tbl_contactgroup',
+ 'contactgroup_name',
+ 'service_contactgroups',
+ 'tbl_lnkServiceToContactgroup',
+ 2,
+ $intFieldId
+ );
+ if ($intReturn12 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (($intReturn9 != 0) && ($intReturn12 != 0)) {
+ $myVisClass->processMessage(translate('Attention, no contacts or contact groups defined!'), $strDBWarning);
+ $intDataWarning = 1;
+ }
+ // Process access group selection field
+ if (isset($arrModifyData['access_group'])) {
+ $intFieldId = $arrModifyData['access_group'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn13 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
+ if ($intReturn13 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Initial add/modify form definitions
+ $strChbFields = 'ACE,PCE,PAC,FRE,OBS,EVH,FLE,STI,NSI,PED,ISV,NOE,HOS,HOG,SEG,COT,COG,TPL';
+ $myContentClass->addFormInit($conttp, $strChbFields);
+ if ($intDataWarning == 1) {
+ $conttp->setVariable('WARNING', $strDBWarning. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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_PAC' .$arrModifyData['parallelize_check']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_FRE' .$arrModifyData['check_freshness']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_OBS' .$arrModifyData['obsess_over_service']. '_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_ISV' .$arrModifyData['is_volatile']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_NOE' .$arrModifyData['notifications_enabled']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_HOS' .$arrModifyData['host_name_tploptions']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_HOG' .$arrModifyData['hostgroup_name_tploptions']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_SEG' .$arrModifyData['servicegroups_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,';
+ $strIntegerfelder .= 'low_flap_threshold,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($value2, 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("FIELD_1",translate('Config name'));
- $mastertp->setVariable("FIELD_2",translate('Service name'));
- // Configuration name selection
- $mastertp->setVariable("DAT_CONFIGNAME",translate('All configs'));
- $mastertp->parse("configlist");
- $strSQL = "SELECT DISTINCT `$preKeyField` FROM `$preTableName` WHERE $strDomainWhere ORDER BY `$preKeyField`";
- $booReturn = $myDBClass->getDataArray($strSQL,$arrDataConfig,$intDataCount);
- if ($booReturn == false) {
- $myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage);
- $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
- } else if ($intDataCount != 0) {
- for ($i=0;$i<$intDataCount;$i++) {
- $mastertp->setVariable("DAT_CONFIGNAME",$arrDataConfig[$i][$preKeyField]);
- if ($_SESSION['search']['config_selection'] == $arrDataConfig[$i][$preKeyField]) {
- $mastertp->setVariable("DAT_CONFIGNAME_SEL","selected");
- }
- $mastertp->parse("configlist");
- }
- }
- // Process filter string
- if ($_SESSION['search'][$preSearchSession] != "") {
- $strSearchTxt = $_SESSION['search'][$preSearchSession];
- $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `service_description` LIKE '%".$strSearchTxt."%' OR
- `display_name` LIKE '%".$strSearchTxt."%')";
- }
- if ($_SESSION['search']['config_selection'] != "") {
- $strSearchTxt2 = $_SESSION['search']['config_selection'];
- if ($strSearchTxt2 != translate('All configs')) {
- $strSearchWhere2 = " AND `$preKeyField` = '".$strSearchTxt2."' ";
- }
- }
- // Row sorting
- $strOrderString = "ORDER BY `config_id`,`$preKeyField` $hidSortDir";
- if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `service_description` $hidSortDir";
- // Count datasets
- $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere2 $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;
- }
- // Datensätze holen
- $strSQL = "SELECT `id`, `$preKeyField`, `service_description`, `register`, `active`, `last_modified`, `config_id`, `access_group`
- FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere2 $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,'service_description',0);
- if ($myContentClass->strErrorMessage != "") $myVisClass->processMessage($myContentClass->strErrorMessage,$strErrorMessage);
+if ($chkModus == 'display') {
+ // Initial list view definitions
+ $myContentClass->listViewInit($mastertp);
+ $mastertp->setVariable('TITLE', translate('Define services (services.cfg)'));
+ $mastertp->setVariable('FIELD_1', translate('Config name'));
+ $mastertp->setVariable('FIELD_2', translate('Service name'));
+ // Configuration name selection
+ $mastertp->setVariable('DAT_CONFIGNAME', translate('All configs'));
+ $mastertp->parse('configlist');
+ $strSQL1 = "SELECT DISTINCT `$preKeyField` FROM `$preTableName` WHERE $strDomainWhere ORDER BY `$preKeyField`";
+ $booReturn1 = $myDBClass->hasDataArray($strSQL1, $arrDataConfig, $intDataCount);
+ if ($booReturn == false) {
+ $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
+ $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
+ } elseif ($intDataCount != 0) {
+ for ($i = 0; $i < $intDataCount; $i++) {
+ $mastertp->setVariable('DAT_CONFIGNAME', $arrDataConfig[$i][$preKeyField]);
+ if ($_SESSION['search']['config_selection'] == $arrDataConfig[$i][$preKeyField]) {
+ $mastertp->setVariable('DAT_CONFIGNAME_SEL', 'selected');
+ }
+ $mastertp->parse('configlist');
+ }
+ }
+ // Process filter string
+ if ($_SESSION['search'][$preSearchSession] != '') {
+ $strSearchTxt = $_SESSION['search'][$preSearchSession];
+ $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `service_description` "
+ . "LIKE '%".$strSearchTxt."%' OR `display_name` LIKE '%".$strSearchTxt."%')";
+ }
+ if ($_SESSION['search']['config_selection'] != '') {
+ $strSearchTxt2 = $_SESSION['search']['config_selection'];
+ if ($strSearchTxt2 != translate('All configs')) {
+ $strSearchWhere2 = " AND `$preKeyField` = '".$strSearchTxt2."' ";
+ }
+ }
+ // Row sorting
+ $strOrderString = "ORDER BY `config_id`,`$preKeyField` $hidSortDir";
+ if ($hidSortBy == 2) {
+ $strOrderString = "ORDER BY `config_id`, `service_description` $hidSortDir";
+ }
+ // Count datasets
+ $strSQL2 = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere2 "
+ . "$strSearchWhere AND `access_group` IN ($strAccess)";
+ $booReturn2 = $myDBClass->hasSingleDataset($strSQL2, $arrDataLinesCount);
+ if ($booReturn2 == 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;
+ }
+ }
+ // Datensätze holen
+ $strSQL3 = "SELECT `id`, `$preKeyField`, `service_description`, `register`, `active`, `last_modified`, "
+ . "`config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere2 "
+ . "$strSearchWhere AND `access_group` IN ($strAccess) $strOrderString "
+ . "LIMIT $chkLimit,".$SETS['common']['pagelines'];
+ $booReturn3 = $myDBClass->hasDataArray($strSQL3, $arrDataLines, $intDataCount);
+ if ($booReturn3 == 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',
+ 0
+ );
+ if ($myContentClass->strErrorMessage != '') {
+ $myVisClass->processMessage($myContentClass->strErrorMessage, $strErrorMessage);
+ }
}
// Show messages
-$arrTimeData = array();
-$strTimeInfoString = "";
-$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime);
+$arrTimeData = array();
+$strTimeInfoString = '';
+$myContentClass->showMessages(
+ $mastertp,
+ $strErrorMessage,
+ $strInfoMessage,
+ $strConsistMessage,
+ $arrTimeData,
+ $strTimeInfoString,
+ $intNoTime
+);
//
// Process footer
// ==============
-$myContentClass->showFooter($maintp,$setFileVersion);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/servicetemplates.php b/admin/servicetemplates.php
index 0df5e81..bf38cfa 100644
--- a/admin/servicetemplates.php
+++ b/admin/servicetemplates.php
@@ -5,392 +5,679 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Service template definition
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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 = 13;
-$preContent = "admin/servicetemplates.tpl.htm";
-$preSearchSession = 'servicetemplate';
-$preTableName = 'tbl_servicetemplate';
-$preKeyField = 'template_name';
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 13;
+$preContent = 'admin/servicetemplates.htm.tpl';
+$preListTpl = 'admin/datalist.htm.tpl';
+$preSearchSession = 'servicetemplate';
+$preTableName = 'tbl_servicetemplate';
+$preKeyField = 'template_name';
+$preAccess = 1;
+$preFieldvars = 1;
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Data processing
// ===============
-$strNO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f,0,-1);
-$strIS = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d,0,-1);
-$strFL = substr($chkChbGr3a.$chkChbGr3b.$chkChbGr3c.$chkChbGr3d,0,-1);
-$strST = substr($chkChbGr4a.$chkChbGr4b.$chkChbGr4c.$chkChbGr4d,0,-1);
-if ($chkSelValue1 != "") {
- for ($i=1;$i<=8;$i++) {
- if (${"chkTfArg$i"} != "") $chkSelValue1 .= "!".${"chkTfArg$i"};
- }
+$strNO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f, 0, -1);
+$strIS = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d, 0, -1);
+$strFL = substr($chkChbGr3a.$chkChbGr3b.$chkChbGr3c.$chkChbGr3d, 0, -1);
+$strST = substr($chkChbGr4a.$chkChbGr4b.$chkChbGr4c.$chkChbGr4d, 0, -1);
+if ($chkSelValue1 != '') {
+ for ($i = 1; $i <= 8; $i++) {
+ $tmpVar = 'chkTfArg'.$i;
+ if ($$tmpVar != '') {
+ $chkSelValue1 .= '!' .$$tmpVar;
+ }
+ }
}
-//
+//
// Add or modify data
// ==================
-if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) {
- $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `host_name`=$intMselValue1, `host_name_tploptions`=$chkRadValue1, `hostgroup_name`=$intMselValue2,
- `hostgroup_name_tploptions`=$chkRadValue2, `service_description`='$chkTfValue2', `display_name`='$chkTfValue3', `servicegroups`=$intMselValue3,
- `servicegroups_tploptions`=$chkRadValue3, `check_command`='$chkSelValue1', `use_template`=$intTemplates, `is_volatile`=$chkRadValue16, `initial_state`='$strIS',
- `max_check_attempts`=$chkTfNullVal2, `check_interval`=$chkTfNullVal3, `retry_interval`=$chkTfNullVal1, `active_checks_enabled`=$chkRadValue6,
- `passive_checks_enabled`=$chkRadValue7, `check_period`=$chkSelValue2, `parallelize_check`=$chkRadValue8, `obsess_over_service`=$chkRadValue10,
- `check_freshness`=$chkRadValue9, `freshness_threshold`=$chkTfNullVal4, `event_handler`=$chkSelValue3, `event_handler_enabled`=$chkRadValue11,
- `low_flap_threshold`=$chkTfNullVal5, `high_flap_threshold`=$chkTfNullVal6, `flap_detection_enabled`=$chkRadValue12, `flap_detection_options`='$strFL',
- `process_perf_data`=$chkRadValue15, `retain_status_information`=$chkRadValue13, `retain_nonstatus_information`=$chkRadValue14, `contacts`=$intMselValue4,
- `contacts_tploptions`=$chkRadValue4, `contact_groups`=$intMselValue5, `contact_groups_tploptions`=$chkRadValue5, `notification_interval`=$chkTfNullVal7,
- `notification_period`=$chkSelValue4, `first_notification_delay`=$chkTfNullVal8, `notification_options`='$strNO', `notifications_enabled`=$chkRadValue17,
- `stalking_options`='$strST', `notes`='$chkTfValue4', `notes_url`='$chkTfValue5', `action_url`='$chkTfValue6', `icon_image`='$chkTfValue7',
- `icon_image_alt`='$chkTfValue8', `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 service template inserted:')." ".$chkTfValue1);
- if ($chkModus == "modify") $myDataClass->writeLog(translate('Service template modified:')." ".$chkTfValue1);
- //
- // Insert/update relations
- // =======================
- if ($chkModus == "insert") {
- if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkServicetemplateToHost",$chkDataId,$chkMselValue1);
- if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkServicetemplateToHostgroup",$chkDataId,$chkMselValue2);
- if (isset($intRet2) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkServicetemplateToServicegroup",$chkDataId,$chkMselValue3);
- if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkServicetemplateToContact",$chkDataId,$chkMselValue4);
- if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue5 != 0) $intRet5 = $myDataClass->dataInsertRelation("tbl_lnkServicetemplateToContactgroup",$chkDataId,$chkMselValue5);
- if (isset($intRet5) && ($intRet5 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- } else if ($chkModus == "modify") {
- if ($intMselValue1 != 0) {
- $intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkServicetemplateToHost",$chkDataId,$chkMselValue1);
- } else {
- $intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkServicetemplateToHost",$chkDataId);
- }
- if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue2 != 0) {
- $intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkServicetemplateToHostgroup",$chkDataId,$chkMselValue2);
- } else {
- $intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkServicetemplateToHostgroup",$chkDataId);
- }
- if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue3 != 0) {
- $intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkServicetemplateToServicegroup",$chkDataId,$chkMselValue3);
- } else {
- $intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkServicetemplateToServicegroup",$chkDataId);
- }
- if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue4 != 0) {
- $intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkServicetemplateToContact",$chkDataId,$chkMselValue4);
- } else {
- $intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkServicetemplateToContact",$chkDataId);
- }
- if ($intRet4 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- if ($intMselValue5 != 0) {
- $intRet5 = $myDataClass->dataUpdateRelation("tbl_lnkServicetemplateToContactgroup",$chkDataId,$chkMselValue5);
- } else {
- $intRet5 = $myDataClass->dataDeleteRelation("tbl_lnkServicetemplateToContactgroup",$chkDataId);
- }
- if ($intRet5 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
- }
- if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5) != 0) $strInfoMessage = "";
- //
- // Insert/update session data for templates
- // ========================================
- if ($chkModus == "modify") {
- $strSQL = "DELETE FROM `tbl_lnkServicetemplateToServicetemplate` 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_lnkServicetemplateToServicetemplate` (`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_lnkServicetemplateToVariabledefinition` 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_lnkServicetemplateToVariabledefinition` 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_lnkServicetemplateToVariabledefinition` (`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 == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
+ $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `host_name`=$intMselValue1, "
+ . "`host_name_tploptions`=$chkRadValue1, `hostgroup_name`=$intMselValue2, "
+ . "`hostgroup_name_tploptions`=$chkRadValue2, `service_description`='$chkTfValue2', "
+ . "`display_name`='$chkTfValue3', `parents`=$intMselValue6, `parents_tploptions`=$chkRadValue18, "
+ . "`importance`=$chkTfNullVal9, `servicegroups`=$intMselValue3, "
+ . "`servicegroups_tploptions`=$chkRadValue3, `check_command`='$chkSelValue1', "
+ . "`use_template`=$intTemplates, `is_volatile`=$chkRadValue16, `initial_state`='$strIS', "
+ . "`max_check_attempts`=$chkTfNullVal2, `check_interval`=$chkTfNullVal3, `retry_interval`=$chkTfNullVal1, "
+ . "`active_checks_enabled`=$chkRadValue6, `passive_checks_enabled`=$chkRadValue7, "
+ . "`check_period`=$chkSelValue2, `parallelize_check`=$chkRadValue8, `obsess_over_service`=$chkRadValue10, "
+ . "`check_freshness`=$chkRadValue9, `freshness_threshold`=$chkTfNullVal4, `event_handler`=$chkSelValue3, "
+ . "`event_handler_enabled`=$chkRadValue11, `low_flap_threshold`=$chkTfNullVal5, "
+ . "`high_flap_threshold`=$chkTfNullVal6, `flap_detection_enabled`=$chkRadValue12, "
+ . "`flap_detection_options`='$strFL', `process_perf_data`=$chkRadValue15, "
+ . "`retain_status_information`=$chkRadValue13, `retain_nonstatus_information`=$chkRadValue14, "
+ . "`contacts`=$intMselValue4, `contacts_tploptions`=$chkRadValue4, `contact_groups`=$intMselValue5, "
+ . "`contact_groups_tploptions`=$chkRadValue5, `notification_interval`=$chkTfNullVal7, "
+ . "`notification_period`=$chkSelValue4, `first_notification_delay`=$chkTfNullVal8, "
+ . "`notification_options`='$strNO', `notifications_enabled`=$chkRadValue17, `stalking_options`='$strST', "
+ . "`notes`='$chkTfValue4', `notes_url`='$chkTfValue5', `action_url`='$chkTfValue6', "
+ . "`icon_image`='$chkTfValue7', `icon_image_alt`='$chkTfValue8', `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 service template inserted:'). ' ' .$chkTfValue1);
+ }
+ if ($chkModus == 'modify') {
+ $myDataClass->writeLog(translate('Service template modified:'). ' ' .$chkTfValue1);
+ }
+ //
+ // Insert/update relations
+ // =======================
+ if ($chkModus == 'insert') {
+ if ($intMselValue1 != 0) {
+ $intRet1 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicetemplateToHost',
+ $chkDataId,
+ $chkMselValue1
+ );
+ }
+ if (isset($intRet1) && ($intRet1 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue2 != 0) {
+ $intRet2 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicetemplateToHostgroup',
+ $chkDataId,
+ $chkMselValue2
+ );
+ }
+ if (isset($intRet2) && ($intRet3 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue3 != 0) {
+ $intRet3 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicetemplateToServicegroup',
+ $chkDataId,
+ $chkMselValue3
+ );
+ }
+ if (isset($intRet3) && ($intRet3 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue4 != 0) {
+ $intRet4 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicetemplateToContact',
+ $chkDataId,
+ $chkMselValue4
+ );
+ }
+ if (isset($intRet4) && ($intRet4 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue5 != 0) {
+ $intRet5 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicetemplateToContactgroup',
+ $chkDataId,
+ $chkMselValue5
+ );
+ }
+ if (isset($intRet5) && ($intRet5 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue6 != 0) {
+ $intRet6 = $myDataClass->dataInsertRelation(
+ 'tbl_lnkServicetemplateToService',
+ $chkDataId,
+ $chkMselValue6
+ );
+ }
+ if (isset($intRet6) && ($intRet6 != 0)) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ } elseif ($chkModus == 'modify') {
+ if ($intMselValue1 != 0) {
+ $intRet1 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicetemplateToHost',
+ $chkDataId,
+ $chkMselValue1
+ );
+ } else {
+ $intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkServicetemplateToHost', $chkDataId);
+ }
+ if ($intRet1 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue2 != 0) {
+ $intRet2 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicetemplateToHostgroup',
+ $chkDataId,
+ $chkMselValue2
+ );
+ } else {
+ $intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkServicetemplateToHostgroup', $chkDataId);
+ }
+ if ($intRet2 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue3 != 0) {
+ $intRet3 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicetemplateToServicegroup',
+ $chkDataId,
+ $chkMselValue3
+ );
+ } else {
+ $intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkServicetemplateToServicegroup', $chkDataId);
+ }
+ if ($intRet3 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue4 != 0) {
+ $intRet4 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicetemplateToContact',
+ $chkDataId,
+ $chkMselValue4
+ );
+ } else {
+ $intRet4 = $myDataClass->dataDeleteRelation('tbl_lnkServicetemplateToContact', $chkDataId);
+ }
+ if ($intRet4 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue5 != 0) {
+ $intRet5 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicetemplateToContactgroup',
+ $chkDataId,
+ $chkMselValue5
+ );
+ } else {
+ $intRet5 = $myDataClass->dataDeleteRelation('tbl_lnkServicetemplateToContactgroup', $chkDataId);
+ }
+ if ($intRet5 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ if ($intMselValue6 != 0) {
+ $intRet1 = $myDataClass->dataUpdateRelation(
+ 'tbl_lnkServicetemplateToService',
+ $chkDataId,
+ $chkMselValue6
+ );
+ } else {
+ $intRet6 = $myDataClass->dataDeleteRelation('tbl_lnkServicetemplateToService', $chkDataId);
+ }
+ if ($intRet6 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ }
+ if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6) != 0) {
+ $strInfoMessage = '';
+ }
+ //
+ // Insert/update session data for templates
+ // ========================================
+ if ($chkModus == 'modify') {
+ $strSQL = 'DELETE FROM `tbl_lnkServicetemplateToServicetemplate` 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_lnkServicetemplateToServicetemplate` (`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_lnkServicetemplateToVariabledefinition` '
+ . '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_lnkServicetemplateToVariabledefinition` '
+ . '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) {
+ $strSQL1 = 'INSERT INTO `tbl_variabledefinition` (`name`,`value`,`last_modified`) '
+ . "VALUES ('".$elem['definition']."','".$elem['range']."',now())";
+ $intReturn1 = $myDataClass->dataInsert($strSQL1, $intInsertId);
+ if ($intReturn1 != 0) {
+ $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
+ }
+ $strSQL2 = 'INSERT INTO `tbl_lnkServicetemplateToVariabledefinition` (`idMaster`, '
+ . "`idSlave`) VALUES ($chkDataId,$intInsertId)";
+ $intReturn2 = $myDataClass->dataInsert($strSQL2, $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 != "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);
-//
-// Start content
-// =============
-$conttp->setVariable("TITLE",translate('Define service templates (servicetemplates.cfg)'));
-$conttp->parse("header");
-$conttp->show("header");
+$intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
+if ($intReturn != 0) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+}
//
// Singe data form
// ===============
-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 $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_service` 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 host selection field
- if (isset($arrModifyData['host_name'])) {$intFieldId = $arrModifyData['host_name'];} else {$intFieldId = 0;}
- $intReturn = $myVisClass->parseSelectMulti('tbl_host','host_name','hosts','tbl_lnkServicetemplateToHost',2,$intFieldId);
- if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- if (isset($arrModifyData['hostgroup_name'])) {$intFieldId = $arrModifyData['hostgroup_name'];} else {$intFieldId = 0;}
- $intReturn = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','hostgroup','tbl_lnkServicetemplateToHostgroup',2,$intFieldId);
- if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- // Process service groups selection field
- if (isset($arrModifyData['servicegroups'])) {$intFieldId = $arrModifyData['servicegroups'];} else {$intFieldId = 0;}
- $intReturn = $myVisClass->parseSelectMulti('tbl_servicegroup','servicegroup_name','servicegroup','tbl_lnkServicetemplateToServicegroup',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','servicecommand',2,$intFieldId);
- if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage);
- // Process check period selection field
- 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','service_contacts','tbl_lnkServicetemplateToContact',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','service_contactgroups','tbl_lnkServicetemplateToContactgroup',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,PAC,FRE,OBS,EVH,FLE,STI,NSI,PED,ISV,NOE,HOS,HOG,SEG,COT,COG,TPL";
- $myContentClass->addFormInit($conttp,$strChbFields);
- if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning." ".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 = "".translate('Entry cannot be activated because it is used by another configuration').": ";
- $strInfo .= "".$strRelMessage." ";
- // 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_PAC".$arrModifyData['parallelize_check']."_CHECKED","checked");
- $conttp->setVariable("DAT_FRE".$arrModifyData['check_freshness']."_CHECKED","checked");
- $conttp->setVariable("DAT_OBS".$arrModifyData['obsess_over_service']."_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_ISV".$arrModifyData['is_volatile']."_CHECKED","checked");
- $conttp->setVariable("DAT_NOE".$arrModifyData['notifications_enabled']."_CHECKED","checked");
- $conttp->setVariable("DAT_HOS".$arrModifyData['host_name_tploptions']."_CHECKED","checked");
- $conttp->setVariable("DAT_HOG".$arrModifyData['hostgroup_name_tploptions']."_CHECKED","checked");
- $conttp->setVariable("DAT_SEG".$arrModifyData['servicegroups_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");
+if ($chkModus == 'add') {
+ $conttp->setVariable('TITLE', translate('Define service templates (servicetemplates.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 $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_service` '
+ . "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 host selection field
+ if (isset($arrModifyData['host_name'])) {
+ $intFieldId = $arrModifyData['host_name'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn1 = $myVisClass->parseSelectMulti(
+ 'tbl_host',
+ 'host_name',
+ 'hosts',
+ 'tbl_lnkServicetemplateToHost',
+ 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_lnkServicetemplateToHostgroup',
+ 2,
+ $intFieldId
+ );
+ if ($intReturn2 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process service selection field
+ if (isset($arrModifyData['parents'])) {
+ $intFieldId = $arrModifyData['parents'];
+ } else {
+ $intFieldId = 0;
+ }
+ if (isset($arrModifyData['id'])) {
+ $intKeyId = $arrModifyData['id'];
+ } else {
+ $intKeyId = 0;
+ }
+ $intReturn3 = $myVisClass->parseSelectMulti(
+ $preTableName,
+ $preKeyField,
+ 'service_parents',
+ 'tbl_lnkServicetemplateToService',
+ 0,
+ $intFieldId,
+ $intKeyId
+ );
+ if ($intReturn3 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process service groups selection field
+ if (isset($arrModifyData['servicegroups'])) {
+ $intFieldId = $arrModifyData['servicegroups'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn3 = $myVisClass->parseSelectMulti(
+ 'tbl_servicegroup',
+ 'servicegroup_name',
+ 'servicegroup',
+ 'tbl_lnkServicetemplateToServicegroup',
+ 0,
+ $intFieldId
+ );
+ if ($intReturn3 != 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;
+ }
+ $intReturn4 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'servicecommand', 2, $intFieldId);
+ if ($intReturn4 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process check period selection field
+ if (isset($arrModifyData['check_period'])) {
+ $intFieldId = $arrModifyData['check_period'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn5 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'checkperiod', 1, $intFieldId);
+ if ($intReturn5 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['notification_period'])) {
+ $intFieldId = $arrModifyData['notification_period'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn6 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'notifyperiod', 1, $intFieldId);
+ if ($intReturn6 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process event handler selection field
+ if (isset($arrModifyData['event_handler'])) {
+ $intFieldId = $arrModifyData['event_handler'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn7 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'eventhandler', 1, $intFieldId);
+ if ($intReturn7 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process contact and contact group selection field
+ if (isset($arrModifyData['contacts'])) {
+ $intFieldId = $arrModifyData['contacts'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn8 = $myVisClass->parseSelectMulti(
+ 'tbl_contact',
+ 'contact_name',
+ 'service_contacts',
+ 'tbl_lnkServicetemplateToContact',
+ 2,
+ $intFieldId
+ );
+ if ($intReturn8 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ if (isset($arrModifyData['contact_groups'])) {
+ $intFieldId = $arrModifyData['contact_groups'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn9 = $myVisClass->parseSelectMulti(
+ 'tbl_contactgroup',
+ 'contactgroup_name',
+ 'service_contactgroups',
+ 'tbl_lnkServicetemplateToContactgroup',
+ 2,
+ $intFieldId
+ );
+ if ($intReturn9 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Process access group selection field
+ if (isset($arrModifyData['access_group'])) {
+ $intFieldId = $arrModifyData['access_group'];
+ } else {
+ $intFieldId = 0;
+ }
+ $intReturn10 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
+ if ($intReturn10 != 0) {
+ $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
+ }
+ // Initial add/modify form definitions
+ $strChbFields = 'ACE,PCE,PAC,FRE,OBS,EVH,FLE,STI,NSI,PED,ISV,NOE,HOS,HOG,SEG,COT,COG,TPL';
+ $myContentClass->addFormInit($conttp, $strChbFields);
+ if ($intDataWarning == 1) {
+ $conttp->setVariable('WARNING', $strDBWarning. ' ' .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 = '' .translate('Entry cannot be activated because it is used by '
+ . 'another configuration'). ': ';
+ $strInfo .= '' .$strRelMessage. ' ';
+ // 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_PAC' .$arrModifyData['parallelize_check']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_FRE' .$arrModifyData['check_freshness']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_OBS' .$arrModifyData['obsess_over_service']. '_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_ISV' .$arrModifyData['is_volatile']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_NOE' .$arrModifyData['notifications_enabled']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_HOS' .$arrModifyData['host_name_tploptions']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_HOG' .$arrModifyData['hostgroup_name_tploptions']. '_CHECKED', 'checked');
+ $conttp->setVariable('DAT_SEG' .$arrModifyData['servicegroups_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 {
+ $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("FIELD_1",translate('Template name'));
- $mastertp->setVariable("FIELD_2",translate('Service description'));
- // Process filter string
- if ($_SESSION['search'][$preSearchSession] != "") {
- $strSearchTxt = $_SESSION['search'][$preSearchSession];
- $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `service_description` LIKE '%".$strSearchTxt."%' OR
- `display_name` LIKE '%".$strSearchTxt."%')";
- }
- // Row sorting
- $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
- if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `service_description` $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`, `service_description`, `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,'service_description',0);
+if ($chkModus == 'display') {
+ // Initial list view definitions
+ $myContentClass->listViewInit($mastertp);
+ $mastertp->setVariable('TITLE', translate('Define service templates (servicetemplates.cfg)'));
+ $mastertp->setVariable('FIELD_1', translate('Template name'));
+ $mastertp->setVariable('FIELD_2', translate('Service description'));
+ // Process filter string
+ if ($_SESSION['search'][$preSearchSession] != '') {
+ $strSearchTxt = $_SESSION['search'][$preSearchSession];
+ $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `service_description` "
+ . "LIKE '%".$strSearchTxt."%' OR `display_name` LIKE '%".$strSearchTxt."%')";
+ }
+ // Row sorting
+ $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
+ if ($hidSortBy == 2) {
+ $strOrderString = "ORDER BY `config_id`, `service_description` $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`, `service_description`, `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,
+ 'service_description',
+ 0
+ );
}
// 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);
-?>
\ No newline at end of file
+$myContentClass->showFooter($maintp, $setFileVersion);
diff --git a/admin/settings.php b/admin/settings.php
index 28f23f9..2166921 100644
--- a/admin/settings.php
+++ b/admin/settings.php
@@ -5,257 +5,325 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Settings configuration
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
+$prePageId = 38;
+$preContent = 'admin/settings.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
+$arrSQL = array();
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Process initial values
// ======================
-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'];
+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'];
+}
+
//
// Save changes
// ============
-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,"\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);
- }
+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, "\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);
+ }
}
//
// Start content
// =============
-$conttp->setVariable("TITLE",translate('Configure Settings'));
-$conttp->parse("header");
-$conttp->show("header");
-foreach($arrDescription AS $elem) {
- $conttp->setVariable($elem['name'],$elem['string']);
+$conttp->setVariable('TITLE', translate('Configure Settings'));
+foreach ($arrDescription as $elem) {
+ $conttp->setVariable($elem['name'], $elem['string']);
}
-$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).'));
+$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).'));
//
// 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->getDataArray($strSQL,$arrData,$intDataCount);
+$strSQL = "SELECT * FROM `tbl_language` WHERE `active`='1' ORDER BY `id`";
+$booReturn = $myDBClass->hasDataArray($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->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
-$conttp->parse("settingssite");
-$conttp->show("settingssite");
+if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
+ $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
+}
+$conttp->parse('settingssite');
+$conttp->show('settingssite');
//
// Footer ausgeben
// ===============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/specials.php b/admin/specials.php
index 4f0e17f..1de5261 100644
--- a/admin/specials.php
+++ b/admin/specials.php
@@ -5,85 +5,108 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Specials overview
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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.tpl.htm";
+$prePageId = 5;
+$preContent = 'admin/mainpages.htm.tpl';
//
// Include preprocessing file
// ==========================
-require("../functions/prepend_adm.php");
+require $preBasePath.'functions/prepend_adm.php';
//
// Include content
// ===============
-$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'));
+$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'));
//
// Include statistical data
// ========================
// Get read access groups
-$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");
+$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');
}
-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($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`=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($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`=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($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`=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($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`=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");
+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');
}
-$conttp->parse("statistics");
-$conttp->parse("main");
-$conttp->show("main");
+$conttp->parse('statistics');
+$conttp->parse('main');
+$conttp->show('main');
//
// Include Footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/support.php b/admin/support.php
index a27639c..2266c9e 100644
--- a/admin/support.php
+++ b/admin/support.php
@@ -5,626 +5,703 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Support page
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// Path settings
+// ===================
+$strPattern = '(admin/[^/]*.php)';
+$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
+$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
+//
// Define common variables
// =======================
-$prePageId = 40;
-$preContent = "admin/support.tpl.htm";
-$preAccess = 1;
-$preFieldvars = 1;
-$setSaveLangId = "private";
+$prePageId = 40;
+$preContent = 'admin/support.htm.tpl';
+$preAccess = 1;
+$preFieldvars = 1;
+$setSaveLangId = 'private';
//
// Include preprocessing files
// ===========================
-require("../functions/prepend_adm.php");
-require("../functions/prepend_content.php");
-//
-// Process post parameters
-// =======================
-$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 (($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);
- }
-}
+require $preBasePath.'functions/prepend_adm.php';
+require $preBasePath.'functions/prepend_content.php';
//
// Start content
// =============
-$conttp->setVariable("TITLE",translate('NagiosQL support page'));
-$conttp->parse("header");
-$conttp->show("header");
+$conttp->setVariable('TITLE', translate('NagiosQL support page'));
+$conttp->parse('header');
+$conttp->show('header');
//
// Single data form
// ================
-$conttp->setVariable("MAINSITE",$_SESSION['SETS']['path']['base_url']."admin.php");
-foreach($arrDescription AS $elem) {
- $conttp->setVariable($elem['name'],$elem['string']);
+$conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url']. 'admin.php');
+foreach ($arrDescription as $elem) {
+ $conttp->setVariable($elem['name'], $elem['string']);
}
-$conttp->setVariable("SUBTITLE_1",translate('Support contact information'));
-$conttp->setVariable("SUPPORT_TEXT_1",translate('For questions, the online support forum or contact information visit our website:'));
+$conttp->setVariable('SUBTITLE_1', translate('Support contact information'));
+$conttp->setVariable('SUPPORT_TEXT_1', translate('For questions, the online support forum or contact information '
+ . 'visit our website:'));
+$conttp->setVariable('WEBSITE_LINK', translate('NagiosQL on sourceforge'));
//
// Donation
// ========
-$conttp->setVariable("SUBTITLE_2",translate('Donate to support NagiosQL'));
-$conttp->setVariable("SUPPORT_TEXT_2",translate('If you like NagiosQL and it simplifies your daily work, then you may want to support the project by making a donation. This helps us to keep NagiosQL alive and to cover our costs. Thank you for your donation!'));
-$conttp->setVariable("DONATE_LINK",translate('Donate for NagiosQL on sourceforge'));
+$conttp->setVariable('SUBTITLE_2', translate('Donate to support NagiosQL'));
+$conttp->setVariable('SUPPORT_TEXT_2', translate('If you like NagiosQL and it simplifies your daily work, then you '
+ . 'may want to support the project by making a donation. This helps us to keep NagiosQL alive and to cover '
+ . 'our costs. Thank you for your donation!'));
+$conttp->setVariable('DONATE_LINK', translate('Donate for NagiosQL on sourceforge'));
//
// Translations
// ============
-$conttp->setVariable("SUBTITLE_3",translate('Translation services'));
-$conttp->setVariable("SUPPORT_TEXT_3",translate('NagiosQL was translated into various languages. Since some translators are no longer available in later versions, there may be untranslated words or phrases. If you want to help us complete the translation, correct them or introduce a new language, then sign up with us now! The translations are simply feasible online - we use an open translation service where you can register for free at any time:'));
-$conttp->setVariable("TRANSLATION_LINK",translate('Transifex translation service'));
+$conttp->setVariable('SUBTITLE_3', translate('Translation services'));
+$conttp->setVariable('SUPPORT_TEXT_3', translate('NagiosQL was translated into various languages. Since some '
+ . 'translators are no longer available in later versions, there may be untranslated words or phrases. If '
+ . 'you want to help us complete the translation, correct them or introduce a new language, then sign up '
+ . 'with us now! The translations are simply feasible online - we use an open translation service where '
+ . 'you can register for free at any time:'));
+$conttp->setVariable('TRANSLATION_LINK', translate('Transifex translation service'));
+//
+// GIT repository
+// ==============
+$conttp->setVariable('SUBTITLE_8', translate('GIT software repository'));
+$conttp->setVariable('SUPPORT_TEXT_5', translate('The NagiosQL sources are available on GitLab. There you will '
+ .'always find the latest bugfixes and changes as well as older branches.'));
+$conttp->setVariable('GIT_LINK', translate('GitLab'));
//
// Online version check
// ====================
-$conttp->setVariable("SUBTITLE_4",translate('Version check'));
+$conttp->setVariable('SUBTITLE_4', translate('Version check'));
if (!isset($SETS['common']['updcheck']) || ($SETS['common']['updcheck'] == '0')) {
- $conttp->setVariable("SUPPORT_TEXT_4",translate('The online version check is not enabled. You can enable it on the settings page.'));
-} else if (isset($SETS['common']['updcheck']) && ($SETS['common']['updcheck'] == '1')) {
- $conttp->setVariable("SUPPORT_TEXT_4",translate('The online version check connects the NagiosQL page to find out, if your version is still up to date.'));
- $conttp->setVariable("LOADER_IMAGE",$_SESSION['SETS']['path']['base_url']."images/loader.gif");
- $conttp->setVariable("VERSION_IF_SRC",$_SESSION['SETS']['path']['base_url']."admin/versioncheck.php?show=0");
- $conttp->parse("versioncheck_frame");
- $conttp->setVariable("VERSION_IF_SRC_RELOAD",$_SESSION['SETS']['path']['base_url']."admin/versioncheck.php?show=1");
- $conttp->parse("versioncheck_js");
+ $conttp->setVariable('SUPPORT_TEXT_4', translate('The online version check is not enabled. You can enable it '
+ . 'on the settings page.'));
+} elseif (isset($SETS['common']['updcheck']) && ($SETS['common']['updcheck'] == '1')) {
+ $conttp->setVariable('SUPPORT_TEXT_4', translate('The online version check connects the NagiosQL page to find '
+ . 'out, if your version is still up to date.'));
+ $conttp->setVariable('LOADER_IMAGE', $_SESSION['SETS']['path']['base_url']. 'images/loader.gif');
+ $conttp->setVariable('VERSION_IF_SRC', $_SESSION['SETS']['path']['base_url']. 'admin/versioncheck.php?show=0');
+ $conttp->parse('versioncheck_frame');
+ $conttp->setVariable('VERSION_IF_SRC_RELOAD', $_SESSION['SETS']['path']['base_url'].
+ 'admin/versioncheck.php?show=1');
+ $conttp->parse('versioncheck_js');
}
//
// Environment check
// =================
-$conttp->setVariable("SUBTITLE_5",translate('Environment check'));
+$conttp->setVariable('SUBTITLE_5', translate('Environment check'));
// Javascript check
-$conttp->setVariable("FAILED",translate("failed"));
-$conttp->setVariable("OK",translate("ok"));
+$conttp->setVariable('FAILED', translate('failed'));
+$conttp->setVariable('OK', translate('ok'));
// PHP version check
-define('MIN_PHP_VERSION', '5.2.0');
-$conttp->setVariable("PHP_VERSION",translate("PHP version"));
-if (version_compare(PHP_VERSION, MIN_PHP_VERSION, '>=')) {
- $conttp->setVariable("PHP_CLASS","checkgreen");
- $conttp->setVariable("PHP_RESULT",translate("ok")." (".PHP_VERSION.")");
+$conttp->setVariable('PHP_VERSION', translate('PHP version'));
+if (PHP_VERSION_ID >= 50500) {
+ $conttp->setVariable('PHP_CLASS', 'checkgreen');
+ $conttp->setVariable('PHP_RESULT', translate('ok'). ' (' .PHP_VERSION. ')');
} else {
- $conttp->setVariable("PHP_CLASS","checkred");
- $conttp->setVariable("PHP_RESULT",translate("failed")." (".PHP_VERSION." - ".translate("Required:")." ".MIN_PHP_VERSION.")");
+ $conttp->setVariable('PHP_CLASS', 'checkred');
+ $conttp->setVariable('PHP_RESULT', translate('failed'). ' (' .PHP_VERSION. ' - '
+ .translate('Required:'). ' 5.5.0)');
}
// PHP modules / extensions
$strExtPath = ini_get('extension_dir');
-$strPrefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
-$conttp->setVariable("PHP_SESSION_MODULE",translate("PHP module:")." session");
+$strPrefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
+$conttp->setVariable('PHP_SESSION_MODULE', translate('PHP module:'). ' session');
if (extension_loaded('session')) {
- $conttp->setVariable("PHP_SESSION_CLASS","checkgreen");
- $conttp->setVariable("PHP_SESSION_RESULT",translate("ok"));
+ $conttp->setVariable('PHP_SESSION_CLASS', 'checkgreen');
+ $conttp->setVariable('PHP_SESSION_RESULT', translate('ok'));
} else {
- $conttp->setVariable("PHP_SESSION_CLASS","checkred");
- $conttp->setVariable("PHP_SESSION_RESULT",translate("failed"));
+ $conttp->setVariable('PHP_SESSION_CLASS', 'checkred');
+ $conttp->setVariable('PHP_SESSION_RESULT', translate('failed'));
}
-$conttp->setVariable("PHP_GETTEXT_MODULE",translate("PHP module:")." gettext");
+$conttp->setVariable('PHP_GETTEXT_MODULE', translate('PHP module:'). ' gettext');
if (extension_loaded('gettext')) {
- $conttp->setVariable("PHP_GETTEXT_CLASS","checkgreen");
- $conttp->setVariable("PHP_GETTEXT_RESULT",translate("ok"));
+ $conttp->setVariable('PHP_GETTEXT_CLASS', 'checkgreen');
+ $conttp->setVariable('PHP_GETTEXT_RESULT', translate('ok'));
} else {
- $conttp->setVariable("PHP_GETTEXT_CLASS","checkred");
- $conttp->setVariable("PHP_GETTEXT_RESULT",translate("failed"));
+ $conttp->setVariable('PHP_GETTEXT_CLASS', 'checkred');
+ $conttp->setVariable('PHP_GETTEXT_RESULT', translate('failed'));
}
-$conttp->setVariable("PHP_FTP_MODULE",translate("PHP module:")." ftp");
+$conttp->setVariable('PHP_FTP_MODULE', translate('PHP module:'). ' ftp');
if (extension_loaded('ftp')) {
- $conttp->setVariable("PHP_FTP_CLASS","checkgreen");
- $conttp->setVariable("PHP_FTP_RESULT",translate("ok"));
- $intFTP_ok = 1;
+ $conttp->setVariable('PHP_FTP_CLASS', 'checkgreen');
+ $conttp->setVariable('PHP_FTP_RESULT', translate('ok'));
+ $intFTP_ok = 1;
} else {
- $conttp->setVariable("PHP_FTP_CLASS","checkorange");
- $conttp->setVariable("PHP_FTP_RESULT",translate("failed"));
- $intFTP_ok = 0;
+ $conttp->setVariable('PHP_FTP_CLASS', 'checkorange');
+ $conttp->setVariable('PHP_FTP_RESULT', translate('failed'));
+ $intFTP_ok = 0;
}
-$conttp->setVariable("PHP_SSH2_MODULE",translate("PHP module:")." ssh");
+$conttp->setVariable('PHP_SSH2_MODULE', translate('PHP module:'). ' ssh');
if (extension_loaded('ssh2')) {
- $conttp->setVariable("PHP_SSH2_CLASS","checkgreen");
- $conttp->setVariable("PHP_SSH2_RESULT",translate("ok"));
- $intSSH_ok = 1;
+ $conttp->setVariable('PHP_SSH2_CLASS', 'checkgreen');
+ $conttp->setVariable('PHP_SSH2_RESULT', translate('ok'));
+ $intSSH_ok = 1;
} else {
- $conttp->setVariable("PHP_SSH2_CLASS","checkorange");
- $conttp->setVariable("PHP_SSH2_RESULT",translate("failed"));
- $intSSH_ok = 0;
+ $conttp->setVariable('PHP_SSH2_CLASS', 'checkorange');
+ $conttp->setVariable('PHP_SSH2_RESULT', translate('failed'));
+ $intSSH_ok = 0;
}
// Datenbankversion
-if ($SETS['db']['type'] == "mysql") {
- $conttp->setVariable("DB_VERSION",translate("MySQL version"));
- $strSQL = "SHOW VARIABLES LIKE 'version'";
- $booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataset);
- if ($booReturn && (count($arrDataset) != 0)) {
- $strDBVersion = $arrDataset['Value'];
- if (version_compare($strDBVersion, "5.0.0", '>=')) {
- $conttp->setVariable("DB_CLASS","checkgreen");
- $conttp->setVariable("DB_RESULT",translate("ok")." (".$strDBVersion.")");
- } else {
- $conttp->setVariable("DB_CLASS","checkorange");
- $conttp->setVariable("DB_RESULT",translate("failed")." (".$strDBVersion." - ".translate("Required:")." 5.0.0)");
- }
- }
+if ($SETS['db']['type'] == 'mysql') {
+ $conttp->setVariable('DB_VERSION', translate('MySQL version'));
+ $strSQL = "SHOW VARIABLES LIKE 'version'";
+ $booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataset);
+ if ($booReturn && (count($arrDataset) != 0)) {
+ $strDBVersion = $arrDataset['Value'];
+ if (version_compare($strDBVersion, '5.0.0', '>=')) {
+ $conttp->setVariable('DB_CLASS', 'checkgreen');
+ $conttp->setVariable('DB_RESULT', translate('ok'). ' (' .$strDBVersion. ')');
+ } else {
+ $conttp->setVariable('DB_CLASS', 'checkorange');
+ $conttp->setVariable('DB_RESULT', translate('failed'). ' (' .$strDBVersion. ' - ' .translate('Required:').
+ ' 5.0.0)');
+ }
+ }
}
// INI settings
-$conttp->setVariable("INI_FILE_UPLOADS",translate("PHP ini settings:")." file_uploads");
-$strStatus = ini_get('file_uploads');
-if (empty($strStatus) || ($strStatus == 1)) {
- $conttp->setVariable("INI_FILE_UPLOADS_CLASS","checkgreen");
- $conttp->setVariable("INI_FILE_UPLOADS_RESULT",translate("ok"));
+$conttp->setVariable('INI_FILE_UPLOADS', translate('PHP ini settings:'). ' file_uploads');
+$strStatus1 = ini_get('file_uploads');
+if (empty($strStatus1) || ($strStatus1 == 1)) {
+ $conttp->setVariable('INI_FILE_UPLOADS_CLASS', 'checkgreen');
+ $conttp->setVariable('INI_FILE_UPLOADS_RESULT', translate('ok'));
} else {
- $conttp->setVariable("INI_FILE_UPLOADS_CLASS","checkred");
- $conttp->setVariable("INI_FILE_UPLOADS_RESULT",translate("failed"));
+ $conttp->setVariable('INI_FILE_UPLOADS_CLASS', 'checkred');
+ $conttp->setVariable('INI_FILE_UPLOADS_RESULT', translate('failed'));
}
-$conttp->setVariable("INI_AUTO_START",translate("PHP ini settings:")." session.auto_start");
-$strStatus = ini_get('session.auto_start');
-if (empty($strStatus) || ($strStatus == 0)) {
- $conttp->setVariable("INI_AUTO_START_CLASS","checkgreen");
- $conttp->setVariable("INI_AUTO_START_RESULT",translate("ok"));
+$conttp->setVariable('INI_AUTO_START', translate('PHP ini settings:'). ' session.auto_start');
+$strStatus2 = ini_get('session.auto_start');
+if (empty($strStatus2) || ($strStatus2 == 0)) {
+ $conttp->setVariable('INI_AUTO_START_CLASS', 'checkgreen');
+ $conttp->setVariable('INI_AUTO_START_RESULT', translate('ok'));
} else {
- $conttp->setVariable("INI_AUTO_START_CLASS","checkred");
- $conttp->setVariable("INI_AUTO_START_RESULT",translate("failed"));
+ $conttp->setVariable('INI_AUTO_START_CLASS', 'checkred');
+ $conttp->setVariable('INI_AUTO_START_RESULT', translate('failed'));
}
-$conttp->setVariable("INI_SUHO_SESS_ENC",translate("PHP ini settings:")." suhosin.session.encrypt");
-$strStatus = ini_get('suhosin.session.encrypt');
-if (empty($strStatus) || ($strStatus == 0)) {
- $conttp->setVariable("INI_SUHO_SESS_ENC_CLASS","checkgreen");
- $conttp->setVariable("INI_SUHO_SESS_ENC_RESULT",translate("ok"));
+$conttp->setVariable('INI_SUHO_SESS_ENC', translate('PHP ini settings:'). ' suhosin.session.encrypt');
+$strStatus3 = ini_get('suhosin.session.encrypt');
+if (empty($strStatus3) || ($strStatus3 == 0)) {
+ $conttp->setVariable('INI_SUHO_SESS_ENC_CLASS', 'checkgreen');
+ $conttp->setVariable('INI_SUHO_SESS_ENC_RESULT', translate('ok'));
} else {
- $conttp->setVariable("INI_SUHO_SESS_ENC_CLASS","checkred");
- $conttp->setVariable("INI_SUHO_SESS_ENC_RESULT",translate("failed"));
+ $conttp->setVariable('INI_SUHO_SESS_ENC_CLASS', 'checkred');
+ $conttp->setVariable('INI_SUHO_SESS_ENC_RESULT', translate('failed'));
}
-$conttp->setVariable("INI_DATE_TIMEZONE",translate("PHP ini settings:")." date.timezone");
-$strStatus = ini_get('date.timezone');
-if (!empty($strStatus)) {
- $conttp->setVariable("INI_DATE_TIMEZONE_CLASS","checkgreen");
- $conttp->setVariable("INI_DATE_TIMEZONE_RESULT",translate("ok")." (".$strStatus.")");
+$conttp->setVariable('INI_DATE_TIMEZONE', translate('PHP ini settings:'). ' date.timezone');
+$strStatus4 = ini_get('date.timezone');
+if (!empty($strStatus4)) {
+ $conttp->setVariable('INI_DATE_TIMEZONE_CLASS', 'checkgreen');
+ $conttp->setVariable('INI_DATE_TIMEZONE_RESULT', translate('ok'). ' (' .$strStatus4. ')');
} else {
- $conttp->setVariable("INI_DATE_TIMEZONE_CLASS","checkred");
- $conttp->setVariable("INI_DATE_TIMEZONE_RESULT",translate("failed"));
+ $conttp->setVariable('INI_DATE_TIMEZONE_CLASS', 'checkred');
+ $conttp->setVariable('INI_DATE_TIMEZONE_RESULT', translate('failed'));
}
// File access checks
-$conttp->setVariable("RW_CONFIG",translate("Read/Write access:")." settings.php");
-$strConfigFile = "../config/settings.php";
+$conttp->setVariable('RW_CONFIG', translate('Read/Write access:'). ' settings.php');
+$strConfigFile = '../config/settings.php';
if (file_exists($strConfigFile) && is_readable($strConfigFile) && is_writable($strConfigFile)) {
- $conttp->setVariable("RW_CONFIG_CLASS","checkgreen");
- $conttp->setVariable("RW_CONFIG_RESULT",translate("ok"));
-} else {
- $conttp->setVariable("RW_CONFIG_CLASS","checkred");
- $conttp->setVariable("RW_CONFIG_RESULT",translate("failed"));
+ $conttp->setVariable('RW_CONFIG_CLASS', 'checkgreen');
+ $conttp->setVariable('RW_CONFIG_RESULT', translate('ok'));
+} else {
+ $conttp->setVariable('RW_CONFIG_CLASS', 'checkred');
+ $conttp->setVariable('RW_CONFIG_RESULT', translate('failed'));
}
//
// Domain checks
// =============
-$arrConfigSet = $myConfigClass->getConfigSets();
+$myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0];
-$myConfigClass->getConfigData($intConfigId,"method",$intMethod);
+$myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
if ($intConfigId != 0) {
- $conttp->setVariable("SUBTITLE_6",translate('Config domain checks'));
- $conttp->setVariable("SUPPORT_TEXT_6",translate('The checks below are based on your data domain and config domain settings. To change the data domain, use the pull down menu in the upper right corner. Repeat this check for any data domain you have configured. To change the config domain, use the data domain menu and select a different config domain value.'));
- $myConfigClass->getConfigData($intConfigId,"conffile",$strConffile);
- $myConfigClass->getConfigData($intConfigId,"target",$strConfName);
- $conttp->setVariable("DOMAIN_NAME",translate("Config domain name"));
- $conttp->setVariable("DOMAIN_NAME_VALUE",$strConfName);
- $conttp->setVariable("CONNECT_TYPE",translate("Connection type"));
- if ($intMethod == 1) {
- $conttp->setVariable("CONNECT_TYPE_CLASS","checkgreen");
- $conttp->setVariable("CONNECT_TYPE_RESULT","Fileaccess");
- } else if ($intMethod == 2) {
- if ($intFTP_ok == 1) {
- $conttp->setVariable("CONNECT_TYPE_CLASS","checkgreen");
- $conttp->setVariable("CONNECT_TYPE_RESULT","FTP");
- } else {
- $conttp->setVariable("CONNECT_TYPE_CLASS","checkred");
- $conttp->setVariable("CONNECT_TYPE_RESULT","FTP (no FTP module)");
- }
- } else if ($intMethod == 3) {
- if ($intSSH_ok == 1) {
- $conttp->setVariable("CONNECT_TYPE_CLASS","checkgreen");
- $conttp->setVariable("CONNECT_TYPE_RESULT","SSH/SFTP");
- } else {
- $conttp->setVariable("CONNECT_TYPE_CLASS","checkred");
- $conttp->setVariable("CONNECT_TYPE_RESULT","SSH/SFTP (no SSH2 module)");
- }
- }
- $conttp->setVariable("CONNECT_CHECK",translate("Connection check"));
- if ($intMethod == 1) {
- $conttp->setVariable("CONNECT_CHECK_CLASS","checkgreen");
- $conttp->setVariable("CONNECT_CHECK_RESULT",translate("ok"));
- } else if ($intMethod == 2) {
- $booReturn = 0;
- if (!isset($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
- $booReturn = $myConfigClass->getFTPConnection($intConfigId);
- }
- if ($booReturn == 1) {
- $conttp->setVariable("CONNECT_CHECK_CLASS","checkred");
- $conttp->setVariable("CONNECT_CHECK_RESULT",translate("failed"));
- $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
- $intConnectCheck = 0;
- } else {
- $conttp->setVariable("CONNECT_CHECK_CLASS","checkgreen");
- $conttp->setVariable("CONNECT_CHECK_RESULT",translate("ok"));
- $intConnectCheck = 1;
- }
- } else if ($intMethod == 3) {
- $booReturn = 0;
- if (!isset($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
- $booReturn = $myConfigClass->getSSHConnection($intConfigId);
- }
- if ($booReturn == 1) {
- $conttp->setVariable("CONNECT_CHECK_CLASS","checkred");
- $conttp->setVariable("CONNECT_CHECK_RESULT",translate("failed"));
- $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
- $intConnectCheck = 0;
- } else {
- $conttp->setVariable("CONNECT_CHECK_CLASS","checkgreen");
- $conttp->setVariable("CONNECT_CHECK_RESULT",translate("ok"));
- $intConnectCheck = 1;
- }
- }
- $conttp->setVariable("RW_NAG_CONF",translate("Nagios config file"));
- if ($intMethod == 1) {
- if (file_exists($strConffile) && is_readable($strConffile) && is_writable($strConffile)) {
- $conttp->setVariable("RW_NAG_CONF_CLASS","checkgreen");
- $conttp->setVariable("RW_NAG_CONF_RESULT",translate("ok"));
- } else if (file_exists($strConffile) && is_readable($strConffile)) {
- $conttp->setVariable("RW_NAG_CONF_CLASS","checkorange");
- $conttp->setVariable("RW_NAG_CONF_RESULT",translate("ok")." (".translate("readonly").")");
- } else{
- $conttp->setVariable("RW_NAG_CONF_CLASS","checkred");
- $conttp->setVariable("RW_NAG_CONF_RESULT",translate("failed"));
- }
- } else if (($intMethod == 2) || ($intMethod == 3)) {
- // Write file to temporary
- $strFileName = tempnam($SETS['path']['tempdir'], 'nagiosql_conf');
- // Copy configuration from remote system
- $intReturn = $myConfigClass->configCopy($strConffile,$intConfigId,$strFileName,0);
- if ($intReturn == 0) {
- $intCheck = 0;
- } else {
- $intCheck = 1;
- $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
- if (file_exists($strFileName)) unlink($strFileName);
- }
- // Copy configuration to remote system
- if ($intCheck == 0) {
- $intReturn = $myConfigClass->configCopy($strConffile,$intConfigId,$strFileName,1);
- if ($intReturn == 0) {
- $intCheck = 0;
- if (file_exists($strFileName)) unlink($strFileName);
- } else {
- $intCheck = 2;
- if (file_exists($strFileName)) unlink($strFileName);
- }
- }
- // Write Results
- if ($intCheck == 0) {
- $conttp->setVariable("RW_NAG_CONF_CLASS","checkgreen");
- $conttp->setVariable("RW_NAG_CONF_RESULT",translate("ok"));
- } else if ($intCheck == 1) {
- $conttp->setVariable("RW_NAG_CONF_CLASS","checkred");
- $conttp->setVariable("RW_NAG_CONF_RESULT",translate("failed"));
- } else if ($intCheck == 2) {
- $conttp->setVariable("RW_NAG_CONF_CLASS","checkorange");
- $conttp->setVariable("RW_NAG_CONF_RESULT",translate("ok")." (".translate("readonly").")");
- }
- }
- $myConfigClass->getConfigData($intConfigId,"pidfile",$strPidfile);
- $myConfigClass->getConfigData($intConfigId,"binaryfile",$strBinary);
- $myConfigClass->getConfigData($intConfigId,"commandfile",$strCommandfile);
- $conttp->setVariable("CHECK_NAG_LOCK",translate("Nagios process file"));
- if ($intMethod == 1) {
- if (substr_count(PHP_OS,"Linux") != 0) {
- exec('ps -ef | grep '.basename($strBinary).' | grep -v grep',$arrExec);
- } else {
- $arrExec[0] = 1;
- }
- if (file_exists($strPidfile) && isset($arrExec[0])) {
- $conttp->setVariable("CHECK_NAG_LOCK_CLASS","checkgreen");
- $conttp->setVariable("CHECK_NAG_LOCK_RESULT",translate("ok"));
- $intDemonOk = 0;
- } else if (!file_exists($strPidfile) && isset($arrExec[0])) {
- $conttp->setVariable("CHECK_NAG_LOCK_CLASS","checkred");
- $conttp->setVariable("CHECK_NAG_LOCK_RESULT",translate("failed")." (".translate("file is missed").")");
- $intDemonOk = 1;
- } else {
- $conttp->setVariable("CHECK_NAG_LOCK_CLASS","checkred");
- $conttp->setVariable("CHECK_NAG_LOCK_RESULT",translate("failed"));
- $myVisClass->processMessage(translate('Nagios daemon is not running'),$strErrorMessage);
- $intDemonOk = 1;
- }
- } else if ($intMethod == 2) {
- $conttp->setVariable("CHECK_NAG_LOCK_CLASS","checkorange");
- $conttp->setVariable("CHECK_NAG_LOCK_RESULT",translate("ok")." (".translate("not used with FTP").")");
- $intDemonOk = 1;
- } else if ($intMethod == 3) {
- $arrResult1 = $myConfigClass->sendSSHCommand('ps -ef | grep '.basename($strBinary).' | grep '.basename($strConffile).' | grep -v grep');
- $arrResult2 = $myConfigClass->sendSSHCommand('ls '.$strPidfile);
- if (is_array($arrResult1) && is_array($arrResult2)) {
- $conttp->setVariable("CHECK_NAG_LOCK_CLASS","checkgreen");
- $conttp->setVariable("CHECK_NAG_LOCK_RESULT",translate("ok"));
- $intDemonOk = 0;
- } else if (is_array($arrResult1) && !is_array($arrResult2)) {
- $conttp->setVariable("CHECK_NAG_LOCK_CLASS","checkred");
- $conttp->setVariable("CHECK_NAG_LOCK_RESULT",translate("failed")." (".translate("file is missed").")");
- $intDemonOk = 1;
- } else {
- $conttp->setVariable("CHECK_NAG_LOCK_CLASS","checkred");
- $conttp->setVariable("CHECK_NAG_LOCK_RESULT",translate("failed")." (".translate("demon dead").")");
- $myVisClass->processMessage(translate('Nagios daemon is not running'),$strErrorMessage);
- $intDemonOk = 1;
- }
- }
- // Command file
- $conttp->setVariable("RW_NAG_COMMAND",translate("Nagios command file"));
- if ($intMethod == 1) {
- if (file_exists($strCommandfile) && is_readable($strCommandfile) && is_writable($strCommandfile) && ($intDemonOk == 0)) {
- $conttp->setVariable("RW_NAG_COMMAND_CLASS","checkgreen");
- $conttp->setVariable("RW_NAG_COMMAND_RESULT",translate("ok"));
- } else if (file_exists($strCommandfile) && is_readable($strCommandfile) && is_writable($strCommandfile) && ($intDemonOk == 1)) {
- $conttp->setVariable("RW_NAG_COMMAND_CLASS","checkorange");
- $conttp->setVariable("RW_NAG_COMMAND_RESULT",translate("ok")." (".translate("demon dead")."?)");
- } else if (!file_exists($strCommandfile)) {
- $conttp->setVariable("RW_NAG_COMMAND_CLASS","checkred");
- $conttp->setVariable("RW_NAG_COMMAND_RESULT",translate("failed")." (".translate("file is missed").")");
- } else if (!is_writable($strCommandfile)) {
- $conttp->setVariable("RW_NAG_COMMAND_CLASS","checkred");
- $conttp->setVariable("RW_NAG_COMMAND_RESULT",translate("failed")." (".translate("readonly").")");
- } else {
- $conttp->setVariable("RW_NAG_COMMAND_CLASS","checkred");
- $conttp->setVariable("RW_NAG_COMMAND_RESULT",translate("failed"));
- }
- } else if ($intMethod == 2) {
- $conttp->setVariable("RW_NAG_COMMAND_CLASS","checkorange");
- $conttp->setVariable("RW_NAG_COMMAND_RESULT",translate("ok")." (".translate("not used with FTP").")");
- } else if ($intMethod == 3) {
- if (is_array($myConfigClass->sendSSHCommand('ls '.$strCommandfile)) && ($intDemonOk == 0)) {
- $timeout = 3;
- $old = ini_set('default_socket_timeout', $timeout);
- $resCmdFile = fopen($strCommandfile,"w");
- ini_set('default_socket_timeout', $old);
- stream_set_timeout($resCmdFile, $timeout);
- stream_set_blocking($resCmdFile, 0);
- if ($resCmdFile) {
- $conttp->setVariable("RW_NAG_COMMAND_CLASS","checkgreen");
- $conttp->setVariable("RW_NAG_COMMAND_RESULT",translate("ok"));
- fclose($resCmdFile);
- } else {
- $conttp->setVariable("RW_NAG_COMMAND_CLASS","checkred");
- $conttp->setVariable("RW_NAG_COMMAND_RESULT",translate("failed")." (".translate("readonly").")");
- }
- } else if ($intDemonOk == 1) {
- $conttp->setVariable("RW_NAG_COMMAND_CLASS","checkred");
- $conttp->setVariable("RW_NAG_COMMAND_RESULT",translate("failed")." (".translate("demon dead").")");
- } else {
- $conttp->setVariable("RW_NAG_COMMAND_CLASS","checkred");
- $conttp->setVariable("RW_NAG_COMMAND_RESULT",translate("failed")." (".translate("file is missed").")");
- }
-
- }
- // Binary file
- $conttp->setVariable("EXE_NAG_BINARY",translate("Nagios binary file"));
- if ($intMethod == 1) {
- if (file_exists($strBinary) && is_executable($strBinary)) {
- $conttp->setVariable("EXE_NAG_BINARY_CLASS","checkgreen");
- $conttp->setVariable("EXE_NAG_BINARY_RESULT",translate("ok"));
- } else if (!file_exists($strBinary)) {
- $conttp->setVariable("EXE_NAG_BINARY_CLASS","checkred");
- $conttp->setVariable("EXE_NAG_BINARY_RESULT",translate("failed")." (".translate("file is missed").")");
- } else {
- $conttp->setVariable("EXE_NAG_BINARY_CLASS","checkred");
- $conttp->setVariable("EXE_NAG_BINARY_RESULT",translate("failed")." (".translate("not executable").")");
- }
- } else if ($intMethod == 2) {
- $conttp->setVariable("EXE_NAG_BINARY_CLASS","checkorange");
- $conttp->setVariable("EXE_NAG_BINARY_RESULT",translate("ok")." (".translate("not used with FTP").")");
- } else if ($intMethod == 3) {
- $booReturn = 0;
- if (!isset($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
- $booReturn = $myConfigClass->getSSHConnection($intConfigId);
- }
- if ($booReturn == 1) {
- $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
- } else {
- if (($strBinary != "") && ($strConffile != "") && (is_array($myConfigClass->sendSSHCommand('ls '.$strBinary)))) {
- $arrResult = $myConfigClass->sendSSHCommand($strBinary.' -V');
- if (!is_array($arrResult) || ($arrResult == false)) {
- $conttp->setVariable("EXE_NAG_BINARY_CLASS","checkred");
- $conttp->setVariable("EXE_NAG_BINARY_RESULT",translate("failed")." (".translate("not executable").")");
- } else {
- $conttp->setVariable("EXE_NAG_BINARY_CLASS","checkgreen");
- $conttp->setVariable("EXE_NAG_BINARY_RESULT",translate("ok"));
- }
- } else {
- $conttp->setVariable("EXE_NAG_BINARY_CLASS","checkred");
- $conttp->setVariable("EXE_NAG_BINARY_RESULT",translate("failed")." (".translate("file is missed").")");
- }
- }
- }
- // Check config files
- $myConfigClass->getConfigData($intConfigId,"basedir",$strBasedir);
- $myConfigClass->getConfigData($intConfigId,"hostconfig",$strHostdir);
- $myConfigClass->getConfigData($intConfigId,"serviceconfig",$strServicedir);
- $conttp->setVariable("SUBTITLE_7",translate('Verify configuration files and demon configuration'));
- $conttp->setVariable("CONFIGURATION_NAME",translate('Configuration name'));
- $conttp->setVariable("USED",translate('Used in data domain'));
- $conttp->setVariable("DEMON_CONFIG",translate('Included in demon configuration')." (".basename($strConffile).")");
- $arrConfigFiles = array (
- 'Hosts' => array( 'table' => 'tbl_host', 'file' => 'directory'),
- 'Services' => array( 'table' => 'tbl_service', 'file' => 'directory'),
- 'Hostgroups' => array( 'table' => 'tbl_hostgroup', 'file' => 'hostgroups.cfg'),
- 'Servicegroups' => array( 'table' => 'tbl_servicegroup', 'file' => 'servicegroups.cfg'),
- 'Hosttemplates' => array( 'table' => 'tbl_hosttemplate', 'file' => 'hosttemplates.cfg'),
- 'servicetemplates' => array( 'table' => 'tbl_servicetemplate', 'file' => 'servicetemplates.cfg'),
- 'Contacts' => array( 'table' => 'tbl_contact', 'file' => 'contacts.cfg'),
- 'Contactgroups' => array( 'table' => 'tbl_contactgroup', 'file' => 'contactgroups.cfg'),
- 'Timeperiods' => array( 'table' => 'tbl_timeperiod', 'file' => 'timeperiods.cfg'),
- 'Contacttemplates' => array( 'table' => 'tbl_contacttemplate', 'file' => 'contacttemplates.cfg'),
- 'Commands' => array( 'table' => 'tbl_command', 'file' => 'commands.cfg'),
- 'Hostdependencies' => array( 'table' => 'tbl_hostdependency', 'file' => 'hostdependencies.cfg'),
- 'Hostescalations' => array( 'table' => 'tbl_hostescalation', 'file' => 'hostescalations.cfg'),
- 'Hostextinfo' => array( 'table' => 'tbl_hostextinfo', 'file' => 'hostextinfo.cfg'),
- 'Servicedependencies' => array( 'table' => 'tbl_servicedependency', 'file' => 'servicedependencies.cfg'),
- 'Serviceescalations' => array( 'table' => 'tbl_serviceescalation', 'file' => 'serviceescalations.cfg'),
- 'Serviceextinfo' => array( 'table' => 'tbl_serviceextinfo', 'file' => 'serviceextinfo.cfg'));
- if ($intMethod == 1) {
- $intCheck = 1;
- if (file_exists($strConffile) && is_readable($strConffile)) {
- $resFile = fopen($strConffile,'r');
- while (!feof($resFile)) {
- $strLine = trim(fgets($resFile));
- if ((substr($strLine,0,1) == 'c') && ((substr_count($strLine,'cfg_dir') != 0) || (substr_count($strLine,'cfg_file') != 0))) {
- $arrConfig[] = $strLine;
- }
- }
- $intCheck = 0;
- fclose($resFile);
- }
- } else if (($intMethod == 2) || ($intMethod == 3)) {
- $intCheck = 1;
- // Write file to temporary
- $strFileName = tempnam($SETS['path']['tempdir'], 'nagiosql_conf');
- // Copy configuration from remote system
- $intReturn = $myConfigClass->configCopy($strConffile,$intConfigId,$strFileName,0);
- if ($intReturn == 0) {
- $intCheck = 0;
- if (file_exists($strFileName) && is_readable($strFileName)) {
- $resFile = fopen($strFileName,'r');
- while (!feof($resFile)) {
- $strLine = trim(fgets($resFile));
- if ((substr($strLine,0,1) == 'c') && ((substr_count($strLine,'cfg_dir') != 0) || (substr_count($strLine,'cfg_file') != 0))) {
- $arrConfig[] = $strLine;
- }
- }
- fclose($resFile);
- $intCheck = 0;
- }
- } else {
- $intCheck = 1;
- $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage);
- if (file_exists($strFileName)) unlink($strFileName);
- }
- }
- $i = 0;
- foreach ($arrConfigFiles AS $key => $elem){
- // Line colours
- $strClassL = "tdlb"; $strClassM = "tdmb";
- if ($i%2 == 1) {$strClassL = "tdld"; $strClassM = "tdmd";}
- $conttp->setVariable("CLASS_L",$strClassL);
- $conttp->setVariable("CLASS_M",$strClassM);
- // Write configuiration name
- $conttp->setVariable("CONFIG_NAME",$key);
- // Count active datasets
- $strSQL = "SELECT * FROM `".$elem['table']."` WHERE `active`='1' AND `config_id`=$chkDomainId";
- $booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
- if ($booReturn && ($intDataCount != 0)) {
- $conttp->setVariable("ACTIVE_CONFIG_COUNT","".translate("ok")." (".$intDataCount.") ");
- } else if ($intDataCount == 0) {
- $conttp->setVariable("ACTIVE_CONFIG_COUNT","".translate("not used")." ");
- } else {
- $conttp->setVariable("ACTIVE_CONFIG_COUNT","".translate("failed")." ");
- $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage);
- }
- $conttp->setVariable("DEMON_CFG_OK","".translate("failed")." (".translate("cfg definition missed").")");
- if (($intCheck == 0) && is_array($arrConfig) && (count($arrConfig) != 0)) {
- foreach ($arrConfig AS $line) {
- if ($elem['file'] != 'directory') {
- if ((substr_count($line,"cfg_dir=".$strBasedir) != 0) && (substr_count($line,"cfg_dir=".substr($strHostdir,0,-1)) == 0) &&
- (substr_count($line,"cfg_dir=".substr($strServicedir,0,-1)) == 0)) {
- $conttp->setVariable("DEMON_CFG_OK","".translate("ok")." (".$line.")");
- } else if (substr_count($line,$strBasedir.$elem['file']) != 0) {
- $conttp->setVariable("DEMON_CFG_OK","".translate("ok")." (".$line.")");
- } else if ($intDataCount == 0) {
- $conttp->setVariable("DEMON_CFG_OK","".translate("ok")." (".translate("cfg definition missed, but actually not used").")");
- } else if (substr_count($line,$elem['file']) != 0) {
- $conttp->setVariable("DEMON_CFG_OK","".translate("failed")." (".translate("wrong base path:")." ".$line.")");
- }
- } else if ($elem['table'] == 'tbl_host'){
- if (substr_count($line,"cfg_dir=".substr($strHostdir,0,-1)) != 0) {
- $conttp->setVariable("DEMON_CFG_OK","".translate("ok")." (".$line.")");
- } else if ($intDataCount == 0) {
- $conttp->setVariable("DEMON_CFG_OK","".translate("ok")." (".translate("cfg definition missed, but actually not used").")");
- }
- } else if ($elem['table'] == 'tbl_service'){
- if (substr_count($line,"cfg_dir=".substr($strServicedir,0,-1)) != 0) {
- $conttp->setVariable("DEMON_CFG_OK","".translate("ok")." (".$line.")");
- } else if ($intDataCount == 0) {
- $conttp->setVariable("DEMON_CFG_OK","".translate("ok")." (".translate("cfg definition missed, but actually not used").")");
- }
- }
- }
- } else {
- $conttp->setVariable("DEMON_CFG_OK","".translate("failed")." (".translate("cfg file not readable").")");
- }
- $conttp->parse("configfileline");
- $i++;
- }
- // Check for unused config
- if (($intCheck == 0) && is_array($arrConfig) && (count($arrConfig) != 0)) {
- foreach ($arrConfig AS $line) {
- $intTest=0;
- foreach ($arrConfigFiles AS $elem) {
- if (substr_count($line,$elem['file']) != 0) $intTest = 1;
- }
- if ($intTest == 0) {
- if (substr_count($line,substr("cfg_dir=".$strHostdir,0,-1)) != 0) $intTest = 1;
- if (substr_count($line,substr("cfg_dir=".$strServicedir,0,-1)) != 0) $intTest = 1;
- //if (substr_count($line,substr("cfg_dir=".$strBasedir,0,-1)) != 0) $intTest = 1;
- }
- if ($intTest == 0) {
- // Line colours
- $strClassL = "tdlb"; $strClassM = "tdmb";
- if ($i%2 == 1) {$strClassL = "tdld"; $strClassM = "tdmd";}
- $conttp->setVariable("CLASS_L",$strClassL);
- $conttp->setVariable("CLASS_M",$strClassM);
- $conttp->setVariable("CONFIG_NAME",translate("Not used"));
- $conttp->setVariable("ACTIVE_CONFIG_COUNT","".translate("failed")." ");
- $conttp->setVariable("DEMON_CFG_OK","".translate("unused - please delete!")." (".$line.")");
- $conttp->parse("configfileline");
- $i++;
- }
- }
- }
- $conttp->parse("configdomain");
+ $conttp->setVariable('SUBTITLE_6', translate('Config domain checks'));
+ $conttp->setVariable('SUPPORT_TEXT_6', translate('The checks below are based on your data domain and config '
+ . 'domain settings. To change the data domain, use the pull down menu in the upper right corner. Repeat '
+ . 'this check for any data domain you have configured. To change the config domain, use the data domain '
+ . 'menu and select a different config domain value.'));
+ $myConfigClass->getConfigValues($intConfigId, 'conffile', $strConffile);
+ $myConfigClass->getConfigValues($intConfigId, 'target', $strConfName);
+ $conttp->setVariable('DOMAIN_NAME', translate('Config domain name'));
+ $conttp->setVariable('DOMAIN_NAME_VALUE', $strConfName);
+ $conttp->setVariable('CONNECT_TYPE', translate('Connection type'));
+ if ($intMethod == 1) {
+ $conttp->setVariable('CONNECT_TYPE_CLASS', 'checkgreen');
+ $conttp->setVariable('CONNECT_TYPE_RESULT', 'Fileaccess');
+ } elseif ($intMethod == 2) {
+ if ($intFTP_ok == 1) {
+ $conttp->setVariable('CONNECT_TYPE_CLASS', 'checkgreen');
+ $conttp->setVariable('CONNECT_TYPE_RESULT', 'FTP');
+ } else {
+ $conttp->setVariable('CONNECT_TYPE_CLASS', 'checkred');
+ $conttp->setVariable('CONNECT_TYPE_RESULT', 'FTP (no FTP module)');
+ }
+ } elseif ($intMethod == 3) {
+ if ($intSSH_ok == 1) {
+ $conttp->setVariable('CONNECT_TYPE_CLASS', 'checkgreen');
+ $conttp->setVariable('CONNECT_TYPE_RESULT', 'SSH/SFTP');
+ } else {
+ $conttp->setVariable('CONNECT_TYPE_CLASS', 'checkred');
+ $conttp->setVariable('CONNECT_TYPE_RESULT', 'SSH/SFTP (no SSH2 module)');
+ }
+ }
+ $conttp->setVariable('CONNECT_CHECK', translate('Connection check'));
+ if ($intMethod == 1) {
+ $conttp->setVariable('CONNECT_CHECK_CLASS', 'checkgreen');
+ $conttp->setVariable('CONNECT_CHECK_RESULT', translate('ok'));
+ } elseif ($intMethod == 2) {
+ $booReturn = 0;
+ if (empty($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
+ $booReturn = $myConfigClass->getFTPConnection($intConfigId);
+ }
+ if ($booReturn == 1) {
+ $conttp->setVariable('CONNECT_CHECK_CLASS', 'checkred');
+ $conttp->setVariable('CONNECT_CHECK_RESULT', translate('failed'));
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+ $intConnectCheck = 0;
+ } else {
+ $conttp->setVariable('CONNECT_CHECK_CLASS', 'checkgreen');
+ $conttp->setVariable('CONNECT_CHECK_RESULT', translate('ok'));
+ $intConnectCheck = 1;
+ }
+ } elseif ($intMethod == 3) {
+ $booReturn = 0;
+ if (empty($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
+ $booReturn = $myConfigClass->getSSHConnection($intConfigId);
+ }
+ if ($booReturn == 1) {
+ $conttp->setVariable('CONNECT_CHECK_CLASS', 'checkred');
+ $conttp->setVariable('CONNECT_CHECK_RESULT', translate('failed'));
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+ $intConnectCheck = 0;
+ } else {
+ $conttp->setVariable('CONNECT_CHECK_CLASS', 'checkgreen');
+ $conttp->setVariable('CONNECT_CHECK_RESULT', translate('ok'));
+ $intConnectCheck = 1;
+ }
+ }
+ $conttp->setVariable('RW_NAG_CONF', translate('Nagios config file'));
+ if ($intMethod == 1) {
+ if (file_exists($strConffile) && is_readable($strConffile)) {
+ if (is_writable($strConffile)) {
+ $conttp->setVariable('RW_NAG_CONF_CLASS', 'checkgreen');
+ $conttp->setVariable('RW_NAG_CONF_RESULT', translate('ok'));
+ } else {
+ $conttp->setVariable('RW_NAG_CONF_CLASS', 'checkorange');
+ $conttp->setVariable('RW_NAG_CONF_RESULT', translate('ok'). ' (' .translate('readonly'). ')');
+ }
+ } else {
+ $conttp->setVariable('RW_NAG_CONF_CLASS', 'checkred');
+ $conttp->setVariable('RW_NAG_CONF_RESULT', translate('failed'));
+ }
+ } elseif (($intMethod == 2) || ($intMethod == 3)) {
+ // Write file to temporary
+ $strFileName = tempnam($SETS['path']['tempdir'], 'nagiosql_conf');
+ // Copy configuration from remote system
+ $intReturn = $myConfigClass->remoteFileCopy($strConffile, $intConfigId, $strFileName, 0);
+ if ($intReturn == 0) {
+ $intCheck = 0;
+ } else {
+ $intCheck = 1;
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+ if (file_exists($strFileName)) {
+ unlink($strFileName);
+ }
+ }
+ // Copy configuration to remote system
+ if ($intCheck == 0) {
+ $intReturn = $myConfigClass->remoteFileCopy($strConffile, $intConfigId, $strFileName, 1);
+ if ($intReturn == 0) {
+ $intCheck = 0;
+ if (file_exists($strFileName)) {
+ unlink($strFileName);
+ }
+ } else {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+ $intCheck = 2;
+ if (file_exists($strFileName)) {
+ unlink($strFileName);
+ }
+ }
+ }
+ // Write Results
+ if ($intCheck == 0) {
+ $conttp->setVariable('RW_NAG_CONF_CLASS', 'checkgreen');
+ $conttp->setVariable('RW_NAG_CONF_RESULT', translate('ok'));
+ } elseif ($intCheck == 1) {
+ $conttp->setVariable('RW_NAG_CONF_CLASS', 'checkred');
+ $conttp->setVariable('RW_NAG_CONF_RESULT', translate('failed'));
+ } elseif ($intCheck == 2) {
+ $conttp->setVariable('RW_NAG_CONF_CLASS', 'checkorange');
+ $conttp->setVariable('RW_NAG_CONF_RESULT', translate('ok'). ' (' .translate('readonly'). ')');
+ }
+ }
+ $myConfigClass->getConfigValues($intConfigId, 'pidfile', $strPidfile);
+ $myConfigClass->getConfigValues($intConfigId, 'binaryfile', $strBinary);
+ $myConfigClass->getConfigValues($intConfigId, 'commandfile', $strCommandfile);
+ $conttp->setVariable('CHECK_NAG_LOCK', translate('Nagios process file'));
+ if ($intMethod == 1) {
+ if (substr_count(PHP_OS, 'Linux') != 0) {
+ exec('ps -ef | grep '.basename($strBinary).' | grep -v grep', $arrExec);
+ } else {
+ $arrExec[0] = 1;
+ }
+ if (isset($arrExec[0])) {
+ if (file_exists($strPidfile)) {
+ $conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkgreen');
+ $conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('ok'));
+ $intDemonOk = 0;
+ } else {
+ $conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkred');
+ $conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('failed') . ' ('
+ . translate('file is missed') . ')');
+ $intDemonOk = 1;
+ }
+ } else {
+ $conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkred');
+ $conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('failed'));
+ $myVisClass->processMessage(translate('Nagios daemon is not running'), $strErrorMessage);
+ $intDemonOk = 1;
+ }
+ } elseif ($intMethod == 2) {
+ $conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkorange');
+ $conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('ok'). ' (' .translate('not used with FTP'). ')');
+ $intDemonOk = 1;
+ } elseif ($intMethod == 3) {
+ $arrResultBinary = array();
+ $arrResultPid = array();
+ $intBinary = 1;
+ $intPid = 1;
+ if ($strBinary != '') {
+ $intBinary = $myConfigClass->sendSSHCommand('ps -ef | grep '.basename($strBinary).' | grep '.
+ basename($strConffile).' | grep -v grep', $arrResultBinary);
+ }
+ if ($strPidfile != '') {
+ $intPid = $myConfigClass->sendSSHCommand('ls ' . $strPidfile, $arrResult2);
+ }
+ if (($intBinary == 0) && ($intPid == 0)) {
+ $conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkgreen');
+ $conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('ok'));
+ $intDemonOk = 0;
+ } elseif (($intBinary == 0) && ($intPid == 1)) {
+ $conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkred');
+ $conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('failed'). ' (' .translate('file is missed'). ')');
+ $intDemonOk = 1;
+ } else {
+ $conttp->setVariable('CHECK_NAG_LOCK_CLASS', 'checkred');
+ $conttp->setVariable('CHECK_NAG_LOCK_RESULT', translate('failed'). ' (' .translate('demon dead'). ')');
+ $myVisClass->processMessage(translate('Nagios daemon is not running'), $strErrorMessage);
+ $intDemonOk = 1;
+ }
+ }
+ // Command file
+ $conttp->setVariable('RW_NAG_COMMAND', translate('Nagios command file'));
+ if ($intMethod == 1) {
+ if (file_exists($strCommandfile) && is_readable($strCommandfile) && is_writable($strCommandfile)) {
+ if ($intDemonOk == 0) {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkgreen');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('ok'));
+ } else {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkorange');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('ok'). ' (' .translate('demon dead'). '?)');
+ }
+ }
+ if (!file_exists($strCommandfile)) {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' (' .translate('file is missed'). ')');
+ } elseif (!is_writable($strCommandfile)) {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' (' .translate('readonly'). ')');
+ } elseif (!is_readable($strCommandfile)) {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'));
+ }
+ } elseif ($intMethod == 2) {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkorange');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('ok'). ' (' .translate('not used with FTP'). ')');
+ } elseif ($intMethod == 3) {
+ if ($strCommandfile != '') {
+ if ($intDemonOk == 0) {
+ $myConfigClass->sendSSHCommand('echo "TEST" >>' . $strCommandfile . '; echo $?; echo ""', $arrTemp);
+ if ($arrTemp[0] == 0) {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkgreen');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('ok'));
+ } else {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' ('
+ .translate('readonly'). ')');
+ }
+ } elseif ($intDemonOk == 1) {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' (' .translate('demon dead'). ')');
+ } else {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' ('
+ .translate('file is missed'). ')');
+ }
+ } else {
+ $conttp->setVariable('RW_NAG_COMMAND_CLASS', 'checkred');
+ $conttp->setVariable('RW_NAG_COMMAND_RESULT', translate('failed'). ' (' .translate('file is missed'). ')');
+ }
+ }
+ // Binary file
+ $conttp->setVariable('EXE_NAG_BINARY', translate('Nagios binary file'));
+ if ($intMethod == 1) {
+ if (file_exists($strBinary)) {
+ if (is_executable($strBinary)) {
+ $conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkgreen');
+ $conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('ok'));
+ } else {
+ $conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkred');
+ $conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed'). ' ('
+ .translate('not executable'). ')');
+ }
+ } else {
+ $conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkred');
+ $conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed'). ' (' .translate('file is missed'). ')');
+ }
+ } elseif ($intMethod == 2) {
+ $conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkorange');
+ $conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('ok'). ' (' .translate('not used with FTP'). ')');
+ } elseif ($intMethod == 3) {
+ $booReturn = 0;
+ /** @noinspection IsEmptyFunctionUsageInspection */
+ if (empty($myConfigClass->resConnectId) || !is_resource($myConfigClass->resConnectId)) {
+ $booReturn = $myConfigClass->getSSHConnection($intConfigId);
+ }
+ if ($booReturn == 1) {
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+ } else {
+ if (($strBinary != '') && ($strConffile != '') &&
+ ($myConfigClass->sendSSHCommand('ls '.$strBinary, $arrTemp) == 0)) {
+ $myConfigClass->sendSSHCommand($strBinary.' -V', $arrResult);
+ if (!is_array($arrResult) || ($arrResult == false)) {
+ $conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkred');
+ $conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed'). ' (' .
+ translate('not executable'). ')');
+ } else {
+ $conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkgreen');
+ $conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('ok'));
+ }
+ } else {
+ $conttp->setVariable('EXE_NAG_BINARY_CLASS', 'checkred');
+ $conttp->setVariable('EXE_NAG_BINARY_RESULT', translate('failed'). ' (' .
+ translate('file is missed'). ')');
+ }
+ }
+ }
+ // Check config files
+ $myConfigClass->getConfigValues($intConfigId, 'basedir', $strBasedir);
+ $myConfigClass->getConfigValues($intConfigId, 'hostconfig', $strHostdir);
+ $myConfigClass->getConfigValues($intConfigId, 'serviceconfig', $strServicedir);
+ $conttp->setVariable('SUBTITLE_7', translate('Verify configuration files and demon configuration'));
+ $conttp->setVariable('CONFIGURATION_NAME', translate('Configuration name'));
+ $conttp->setVariable('USED', translate('Used in data domain'));
+ $conttp->setVariable('DEMON_CONFIG', translate('Included in demon configuration'). ' ('
+ .basename($strConffile). ')');
+ $arrConfig = array();
+ $arrConfigFiles = array(
+ 'Hosts' => array( 'table' => 'tbl_host', 'file' => 'directory'),
+ 'Services' => array( 'table' => 'tbl_service', 'file' => 'directory'),
+ 'Hostgroups' => array( 'table' => 'tbl_hostgroup', 'file' => 'hostgroups.cfg'),
+ 'Servicegroups' => array( 'table' => 'tbl_servicegroup', 'file' => 'servicegroups.cfg'),
+ 'Hosttemplates' => array( 'table' => 'tbl_hosttemplate', 'file' => 'hosttemplates.cfg'),
+ 'servicetemplates' => array( 'table' => 'tbl_servicetemplate', 'file' => 'servicetemplates.cfg'),
+ 'Contacts' => array( 'table' => 'tbl_contact', 'file' => 'contacts.cfg'),
+ 'Contactgroups' => array( 'table' => 'tbl_contactgroup', 'file' => 'contactgroups.cfg'),
+ 'Timeperiods' => array( 'table' => 'tbl_timeperiod', 'file' => 'timeperiods.cfg'),
+ 'Contacttemplates' => array( 'table' => 'tbl_contacttemplate', 'file' => 'contacttemplates.cfg'),
+ 'Commands' => array( 'table' => 'tbl_command', 'file' => 'commands.cfg'),
+ 'Hostdependencies' => array( 'table' => 'tbl_hostdependency', 'file' => 'hostdependencies.cfg'),
+ 'Hostescalations' => array( 'table' => 'tbl_hostescalation', 'file' => 'hostescalations.cfg'),
+ 'Hostextinfo' => array( 'table' => 'tbl_hostextinfo', 'file' => 'hostextinfo.cfg'),
+ 'Servicedependencies' => array( 'table' => 'tbl_servicedependency', 'file' => 'servicedependencies.cfg'),
+ 'Serviceescalations' => array( 'table' => 'tbl_serviceescalation', 'file' => 'serviceescalations.cfg'),
+ 'Serviceextinfo' => array( 'table' => 'tbl_serviceextinfo', 'file' => 'serviceextinfo.cfg'));
+ if ($intMethod == 1) {
+ $intCheck = 1;
+ if (file_exists($strConffile) && is_readable($strConffile)) {
+ $resFile = fopen($strConffile, 'rb');
+ while (!feof($resFile)) {
+ $strLine = trim(fgets($resFile));
+ if ((0 === strpos($strLine, 'c')) && ((substr_count($strLine, 'cfg_dir') != 0) ||
+ (substr_count($strLine, 'cfg_file') != 0))) {
+ $arrConfig[] = $strLine;
+ }
+ }
+ $intCheck = 0;
+ fclose($resFile);
+ }
+ } elseif (($intMethod == 2) || ($intMethod == 3)) {
+ $intCheck = 1;
+ // Write file to temporary
+ $strFileName = tempnam($SETS['path']['tempdir'], 'nagiosql_conf');
+ // Copy configuration from remote system
+ $intReturn = $myConfigClass->remoteFileCopy($strConffile, $intConfigId, $strFileName, 0);
+ if ($intReturn == 0) {
+ $intCheck = 0;
+ if (file_exists($strFileName) && is_readable($strFileName)) {
+ $resFile = fopen($strFileName, 'rb');
+ while (!feof($resFile)) {
+ $strLine = trim(fgets($resFile));
+ if ((0 === strpos($strLine, 'c')) && ((substr_count($strLine, 'cfg_dir') != 0) ||
+ (substr_count($strLine, 'cfg_file') != 0))) {
+ $arrConfig[] = $strLine;
+ }
+ }
+ fclose($resFile);
+ $intCheck = 0;
+ }
+ } else {
+ $intCheck = 1;
+ $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
+ if (file_exists($strFileName)) {
+ unlink($strFileName);
+ }
+ }
+ }
+ $i = 0;
+ foreach ($arrConfigFiles as $key => $elem) {
+ // Line colours
+ $strClassL = 'tdlb';
+ $strClassM = 'tdmb';
+ if ($i%2 == 1) {
+ $strClassL = 'tdld';
+ $strClassM = 'tdmd';
+ }
+ $conttp->setVariable('CLASS_L', $strClassL);
+ $conttp->setVariable('CLASS_M', $strClassM);
+ // Write configuiration name
+ $conttp->setVariable('CONFIG_NAME', $key);
+ // Count active datasets
+ $strSQL = 'SELECT * FROM `' .$elem['table']."` WHERE `active`='1' AND `config_id`=$chkDomainId";
+ $booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
+ if ($booReturn && ($intDataCount != 0)) {
+ $conttp->setVariable('ACTIVE_CONFIG_COUNT', '' .translate('ok'). ' (' .
+ $intDataCount. ') ');
+ } elseif ($intDataCount == 0) {
+ $conttp->setVariable('ACTIVE_CONFIG_COUNT', '' .translate('not used'). ' ');
+ } else {
+ $conttp->setVariable('ACTIVE_CONFIG_COUNT', '' .translate('failed'). ' ');
+ $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
+ }
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('failed'). ' (' .
+ translate('cfg definition missed'). ')');
+ if (($intCheck == 0) && is_array($arrConfig) && (count($arrConfig) != 0)) {
+ foreach ($arrConfig as $line) {
+ if ($elem['file'] != 'directory') {
+ if ((substr_count($line, 'cfg_dir=' .$strBasedir) != 0) && (substr_count($line, 'cfg_dir=' .
+ substr($strHostdir, 0, -1)) == 0) && (substr_count($line, 'cfg_dir=' .
+ substr($strServicedir, 0, -1)) == 0)) {
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('ok').
+ ' (' .$line. ')');
+ break;
+ }
+ if (substr_count($line, $strBasedir.$elem['file']) != 0) {
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('ok').
+ ' (' .$line. ')');
+ break;
+ }
+ if ($intDataCount == 0) {
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('ok').
+ ' (' .translate('cfg definition missed, but actually not used'). ')');
+ } elseif (substr_count($line, $elem['file']) != 0) {
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('failed').
+ ' (' .translate('wrong base path:'). ' ' .$line. ')');
+ break;
+ }
+ } elseif ($elem['table'] == 'tbl_host') {
+ if (substr_count($line, 'cfg_dir=' .substr($strHostdir, 0, -1)) != 0) {
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('ok').
+ ' (' .$line. ')');
+ break;
+ }
+ if ($intDataCount == 0) {
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('ok').
+ ' (' .translate('cfg definition missed, but actually not used'). ')');
+ break;
+ }
+ } elseif ($elem['table'] == 'tbl_service') {
+ if (substr_count($line, 'cfg_dir=' .substr($strServicedir, 0, -1)) != 0) {
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('ok').
+ ' (' .$line. ')');
+ break;
+ }
+ if ($intDataCount == 0) {
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('ok').
+ ' (' .translate('cfg definition missed, but actually not used'). ')');
+ break;
+ }
+ }
+ }
+ } else {
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('failed').
+ ' (' .translate('cfg file not readable'). ')');
+ }
+ $conttp->parse('configfileline');
+ $i++;
+ }
+ // Check for unused config
+ if (($intCheck == 0) && is_array($arrConfig) && (count($arrConfig) != 0)) {
+ foreach ($arrConfig as $line) {
+ $intTest=0;
+ foreach ($arrConfigFiles as $elem) {
+ if (substr_count($line, $elem['file']) != 0) {
+ $intTest = 1;
+ }
+ }
+ if ($intTest == 0) {
+ if (substr_count($line, substr('cfg_dir=' .$strHostdir, 0, -1)) != 0) {
+ $intTest = 1;
+ }
+ if (substr_count($line, substr('cfg_dir=' .$strServicedir, 0, -1)) != 0) {
+ $intTest = 1;
+ }
+ //if (substr_count($line,substr("cfg_dir=".$strBasedir,0,-1)) != 0) $intTest = 1;
+ }
+ if ($intTest == 0) {
+ // Line colours
+ $strClassL = 'tdlb';
+ $strClassM = 'tdmb';
+ if ($i%2 == 1) {
+ $strClassL = 'tdld';
+ $strClassM = 'tdmd';
+ }
+ $conttp->setVariable('CLASS_L', $strClassL);
+ $conttp->setVariable('CLASS_M', $strClassM);
+ $conttp->setVariable('CONFIG_NAME', translate('Not used'));
+ $conttp->setVariable('ACTIVE_CONFIG_COUNT', '' .translate('failed'). ' ');
+ $conttp->setVariable('DEMON_CFG_OK', '' .translate('unused - please delete!').
+ ' (' .$line. ')');
+ $conttp->parse('configfileline');
+ $i++;
+ }
+ }
+ }
+ $conttp->parse('configdomain');
}
// 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->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\"");
-$conttp->parse("support");
-$conttp->show("support");
+if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
+ $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
+}
+$conttp->parse('support');
+$conttp->show('support');
//
// Process footer
// ==============
-$maintp->setVariable("VERSION_INFO","NagiosQL $setFileVersion");
-$maintp->parse("footer");
-$maintp->show("footer");
-?>
\ No newline at end of file
+$maintp->setVariable('VERSION_INFO', "NagiosQL $setFileVersion");
+$maintp->parse('footer');
+$maintp->show('footer');
diff --git a/admin/templatedefinitions.php b/admin/templatedefinitions.php
index 9c2a9d9..1ad330e 100644
--- a/admin/templatedefinitions.php
+++ b/admin/templatedefinitions.php
@@ -5,245 +5,281 @@
//
///////////////////////////////////////////////////////////////////////////////
//
-// (c) 2005-2017 by Martin Willisegger
+// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Template definition list
-// Website : http://www.nagiosql.org
-// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
-// Author : $LastChangedBy: martin $
-// Version : 3.3.0
-// Revision : $LastChangedRevision: 2 $
+// Website : https://sourceforge.net/projects/nagiosql/
+// Version : 3.4.0
+// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
+// 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("../functions/prepend_adm.php");
+require $preBasePath.'functions/prepend_adm.php';
//
// Process post parameters
// =======================
-$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;
+$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;
+}
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->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;
- }
- }
- }
+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;
+ }
+ }
+ }
}
//
// Add mode
// ========
-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;
- }
+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;
+ }
}
//
// Deletion mode
// =============
-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;
- }
- }
- }
+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;
+ }
+ }
}
//
// Sort mode
// =========
-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 == '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 == "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;
- }
+if ($chkMode == 'sortdown') {
+ $chkKey = (int)$chkKey;
+ if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
+ (count($_SESSION['templatedefinition']) > 1) && ($chkKey < (count($_SESSION['templatedefinition'])-1))) {
+ $arrTemp = array();
+ $arrWait = array();
+ $intNow = 0;
+ foreach ($_SESSION['templatedefinition'] as $key => $elem) {
+ if ($key != $chkKey) {
+ $arrTemp[] = $elem;
+ if ($intNow == 1) {
+ $intNow = 0;
+ $arrTemp[] = $arrWait;
+ }
+ } else {
+ $arrWait = $elem;
+ $intNow = 1;
+ }
+ }
+ $_SESSION['templatedefinition'] = $arrTemp;
+ }
}
//
// Clean up data structure
// =======================
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition'])) {
- $arrTemp = "";
- foreach ($_SESSION['templatedefinition'] AS $key => $elem) {
- if ($elem['status'] == 0) {
- $arrTemp[] = $elem;
- }
- }
- $_SESSION['templatedefinition'] = $arrTemp;
+ $arrTemp = array();
+ foreach ($_SESSION['templatedefinition'] as $key => $elem) {
+ if ($elem['status'] == 0) {
+ $arrTemp[] = $elem;
+ }
+ }
+ $_SESSION['templatedefinition'] = $arrTemp;
}
?>
-
-
- None
-
-
-
-
-
+
+
+ None
+
+
+
+
+
$elem) {
- if ($elem['status'] == 0) {
-?>
-
-
- ')" style="cursor:pointer"> ')" style="cursor:pointer"> ')" style="cursor:pointer">
-
+if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
+ (count($_SESSION['templatedefinition']) != 0)) {
+ foreach ($_SESSION['templatedefinition'] as $key => $elem) {
+ if ($elem['status'] == 0) {
+ ?>
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
\ No newline at end of file
+
+
+