Merge tag 'upstream/3.4.0'

Upstream version 3.4.0
This commit is contained in:
Mario Fetka 2019-04-17 11:40:51 +02:00
commit b169bfe074
236 changed files with 48199 additions and 37546 deletions

View File

@ -5,42 +5,47 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin main site // Component : Admin main site
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// 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 // Define common variables
// ======================= // =======================
$prePageId = 1; $prePageId = 1;
$preContent = "admin/mainpages.tpl.htm"; $preContent = 'admin/mainpages.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Include Content // Include Content
// =============== // ===============
$conttp->setVariable("TITLE",translate('NagiosQL Administration')); $conttp->setVariable('TITLE', translate('NagiosQL Administration'));
$conttp->parse("header"); $conttp->parse('header');
$conttp->show("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->setVariable('DESC', translate('Welcome to NagiosQL, the administration module that can be used to easily '
$conttp->parse("main"); . 'create, modify and delete configuration files for Nagios. The data is stored in a database '
$conttp->show("main"); . 'and can be written directly to the standard files at any time you want.'));
$conttp->parse('main');
$conttp->show('main');
// //
// Include footer // Include footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,39 +5,43 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Administration overview // Component : Administration overview
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 7; $prePageId = 7;
$preContent = "admin/mainpages.tpl.htm"; $preContent = 'admin/mainpages.htm.tpl';
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
require("../functions/prepend_adm.php"); require $preBasePath. 'functions/prepend_adm.php';
// //
// Include content // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate('Administration')); $conttp->setVariable('TITLE', translate('Administration'));
$conttp->parse("header"); $conttp->parse('header');
$conttp->show("header"); $conttp->show('header');
$conttp->setVariable("DESC",translate('Functions to administrate NagiosQL V3')); $conttp->setVariable('DESC', translate('Functions to administrate NagiosQL V3'));
$conttp->parse("main"); $conttp->parse('main');
$conttp->show("main"); $conttp->show('main');
// //
// Include Footer // Include Footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,73 +5,88 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Alarming overview // Component : Alarming overview
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 3; $prePageId = 3;
$preContent = "admin/mainpages.tpl.htm"; $preContent = 'admin/mainpages.htm.tpl';
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
// //
// Include content // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate('Alarming')); $conttp->setVariable('TITLE', translate('Alarming'));
$conttp->parse("header"); $conttp->setVariable('DESC', translate('To define contact data, contact templates and contact groups and time '
$conttp->show("header"); . 'periods.'));
$conttp->setVariable("DESC",translate('To define contact data, contact templates and contact groups and time periods.')); $conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable("STATISTICS",translate('Statistical datas')); $conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable("TYPE",translate('Group')); $conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable("ACTIVE",translate('Active')); $conttp->setVariable('INACTIVE', translate('Inactive'));
$conttp->setVariable("INACTIVE",translate('Inactive'));
// //
// Include statistical data // Include statistical data
// ======================== // ========================
// Get read access groups // Get read access groups
$strAccess = $myVisClass->getAccGroups('read'); $strAccess = $myVisClass->getAccessGroups('read');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=14")+0,'read') == 0) { $intGroupId14 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=14');
$conttp->setVariable("NAME",translate('Contact data')); $intGroupId15 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=15');
$conttp->setVariable("ACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_contact WHERE active='1' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)")); $intGroupId16 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=16');
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_contact WHERE active='0' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)")); $intGroupId17 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=17');
$conttp->parse("statisticrow"); 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) { if ($myVisClass->checkAccountGroup($intGroupId15, 'read') == 0) {
$conttp->setVariable("NAME",translate('Contact groups')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contactgroup` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_contactgroup WHERE active='0' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intGroupId16, 'read') == 0) {
$conttp->setVariable("NAME",translate('Time periods')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_timeperiod` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_timeperiod WHERE active='0' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intGroupId17, 'read') == 0) {
$conttp->setVariable("NAME",translate('Contact templates')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_contacttemplate` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_contacttemplate WHERE active='0' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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('statistics');
$conttp->parse("main"); $conttp->parse('main');
$conttp->show("main"); $conttp->show('main');
// //
// Include Footer // Include Footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,149 +5,162 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : File editor cgi.cfg // Component : File editor cgi.cfg
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 29; $prePageId = 29;
$preContent = "admin/nagioscfg.tpl.htm"; $preContent = 'admin/nagioscfg.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
$intRemoveTmp = 0; $intRemoveTmp = 0;
$strConfig = ""; $strConfig = '';
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Get configuration set ID // Get configuration set ID
// ======================== // ========================
$arrConfigSet = $myConfigClass->getConfigSets(); $myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0]; $intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigData($intConfigId,"method",$intMethod); $myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$myConfigClass->getConfigData($intConfigId,"nagiosbasedir",$strBaseDir); $myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strBaseDir);
$strConfigfile = str_replace("//","/",$strBaseDir."/cgi.cfg"); $strConfigfile = str_replace('//', '/', $strBaseDir. '/cgi.cfg');
$strLocalBackup = str_replace("//","/",$strBaseDir."/cgi.cfg_old_").date("YmdHis",time()); $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 // Process data
// ============ // ============
if ($chkTaFileText != "") { if (($chkTaFileText != '') && ($arrConfigSet[0] != 0)) {
if ($intMethod == 1) { if ($intMethod == 1) {
if (file_exists($strBaseDir) && (is_writable($strBaseDir) && (is_writable($strConfigfile)))) { if (file_exists($strBaseDir) && (is_writable($strBaseDir) && is_writable($strConfigfile))) {
// Backup config file // Backup config file
$intReturn = $myConfigClass->moveFile("nagiosbasic","cgi.cfg",$intConfigId); $intReturn = $myConfigClass->moveFile('nagiosbasic', 'cgi.cfg', $intConfigId);
if ($intReturn == 1) { if ($intReturn == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} }
// Write configuration // Write configuration
$resFile = fopen($strConfigfile,"w"); $resFile = fopen($strConfigfile, 'wb');
fputs($resFile,$chkTaFileText); fwrite($resFile, $chkTaFileText);
fclose($resFile); fclose($resFile);
$myVisClass->processMessage("<span style=\"color:green\">".translate('Configuration file successfully written!')."</span>",$strInfoMessage); $myVisClass->processMessage('<span style="color:green">' .translate('Configuration file successfully '
$myDataClass->writeLog(translate('Configuration successfully written:')." ".$strConfigfile); . 'written!'). '</span>', $strInfoMessage);
} else { $myDataClass->writeLog(translate('Configuration successfully written:'). ' ' .$strConfigfile);
$myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the permissions)!'),$strErrorMessage); } else {
$myDataClass->writeLog(translate('Configuration write failed:')." ".$strConfigfile); $myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the '
} . 'permissions)!'), $strErrorMessage);
} else if (($intMethod == 2) || ($intMethod == 3)) { $myDataClass->writeLog(translate('Configuration write failed:'). ' ' .$strConfigfile);
// Backup config file }
$intReturn = $myConfigClass->moveFile("nagiosbasic","cgi.cfg",$intConfigId); } elseif (($intMethod == 2) || ($intMethod == 3)) {
if ($intReturn == 1) { // Backup config file
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); $intReturn1 = $myConfigClass->moveFile('nagiosbasic', 'cgi.cfg', $intConfigId);
} if ($intReturn1 == 1) {
// Write file to temporary $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_cgi'); }
$resFile = fopen($strFileName,"w"); // Write file to temporary
fputs($resFile,$chkTaFileText); $strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_cgi');
fclose($resFile); $resFile = fopen($strFileName, 'wb');
// Copy configuration to remoty system fwrite($resFile, $chkTaFileText);
$intReturn = $myConfigClass->configCopy($strConfigfile,$intConfigId,$strFileName,1); fclose($resFile);
if ($intReturn == 0) { // Copy configuration to remoty system
$myVisClass->processMessage("<span style=\"color:green\">".translate('Configuration file successfully written!')."</span>",$strInfoMessage); $intReturn2 = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName, 1);
$myDataClass->writeLog(translate('Configuration successfully written:')." ".$strConfigfile); if ($intReturn2 == 0) {
unlink($strFileName); $myVisClass->processMessage('<span style="color:green">' .translate('Configuration file successfully '
} else { . 'written!'). '</span>', $strInfoMessage);
$myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the permissions on remote system)!'),$strErrorMessage); $myDataClass->writeLog(translate('Configuration successfully written:'). ' ' .$strConfigfile);
$myDataClass->writeLog(translate('Configuration write failed (remote):')." ".$strConfigfile); unlink($strFileName);
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 // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate('CGI configuration file')); $conttp->setVariable('TITLE', translate('CGI configuration file'));
$conttp->parse("header"); $conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->show("header"); $conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url']. 'admin.php');
// foreach ($arrDescription as $elem) {
// Include input form $conttp->setVariable($elem['name'], $elem['string']);
// =================== }
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
$conttp->setVariable("MAINSITE",$_SESSION['SETS']['path']['base_url']."admin.php");
foreach($arrDescription AS $elem) {
$conttp->setVariable($elem['name'],$elem['string']);
}
// //
// Open configuration // Open configuration
// ================== // ==================
if ($intMethod == 1) { if ($intMethod == 1) {
if (file_exists($strConfigfile) && is_readable($strConfigfile)) { if (file_exists($strConfigfile) && is_readable($strConfigfile)) {
$resFile = fopen($strConfigfile,"r"); $resFile = fopen($strConfigfile, 'rb');
if ($resFile) { if ($resFile) {
while(!feof($resFile)) { while (!feof($resFile)) {
$strConfig .= fgets($resFile,1024); $strConfig .= fgets($resFile, 1024);
} }
} }
} else { } else {
$myVisClass->processMessage(translate('Cannot open the data file (check the permissions)!'),$strErrorMessage); $myVisClass->processMessage(translate('Cannot open the data file (check the permissions)!'), $strErrorMessage);
} }
} else if (($intMethod == 2) || ($intMethod == 3)) { } elseif (($intMethod == 2) || ($intMethod == 3)) {
// Write file to temporary // Write file to temporary
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_cgi'); $strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_cgi');
// Copy configuration from remoty system // Copy configuration from remoty system
$intReturn = $myConfigClass->configCopy($strConfigfile,$intConfigId,$strFileName,0); $myConfigClass->strErrorMessage = '';
if ($intReturn == 0) { $intReturn = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName, 0);
$resFile = fopen($strFileName,"r"); if ($intReturn == 0) {
if (is_resource($resFile)) { $resFile = fopen($strFileName, 'rb');
while(!feof($resFile)) { if (is_resource($resFile)) {
$strConfig .= fgets($resFile,1024); while (!feof($resFile)) {
} $strConfig .= fgets($resFile, 1024);
unlink($strFileName); }
} else { unlink($strFileName);
$myVisClass->processMessage(translate('Cannot open the temporary file'),$strErrorMessage); } else {
} $myVisClass->processMessage(translate('Cannot open the temporary file'), $strErrorMessage);
} else { }
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); } else {
$myDataClass->writeLog(translate('Configuration read failed (remote):')." ".$strErrorMessage); $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
if (file_exists($strFileName)) unlink($strFileName); $myDataClass->writeLog(translate('Configuration read failed (remote):'). ' ' .$strErrorMessage);
} if (file_exists($strFileName)) {
unlink($strFileName);
}
}
} }
$conttp->setVariable("DAT_NAGIOS_CONFIG",$strConfig); $conttp->setVariable('DAT_NAGIOS_CONFIG', $strConfig);
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage); if ($strErrorMessage != '') {
$conttp->setVariable("INFOMESSAGE",$strInfoMessage); $conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// Check access rights for adding new objects // Check access rights for adding new objects
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\""); if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->parse("naginsert"); $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
$conttp->show("naginsert"); }
$conttp->parse('naginsert');
$conttp->show('naginsert');
// //
// Process footer // Process footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,148 +5,192 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Command definitions // Component : Command definitions
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 18; $prePageId = 18;
$preContent = "admin/checkcommands.tpl.htm"; $preContent = 'admin/checkcommands.htm.tpl';
$preSearchSession = 'checkcommand'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_command'; $preSearchSession = 'checkcommand';
$preKeyField = 'command_name'; $preTableName = 'tbl_command';
$preAccess = 1; $preKeyField = 'command_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `command_line`='$chkTfValue2', `command_type`=$chkSelValue1, $preSQLCommon1"; $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `command_line`='$chkTfValue2', "
if ($chkModus == "insert") { . "`command_type`=$chkSelValue1, $preSQLCommon1";
$strSQL = "INSERT INTO ".$strSQLx; if ($chkModus == 'insert') {
} else { $strSQL = 'INSERT INTO ' .$strSQLx;
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; } else {
} $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ($intWriteAccessId == 0) { }
if (($chkTfValue1 != "") && ($chkTfValue2 != "")) { if ($intWriteAccessId == 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
if ($chkModus == "insert") $chkDataId = $intInsertId; $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn == 1) { if ($chkModus == 'insert') {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId = $intInsertId;
} else { }
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($intReturn == 1) {
$myDataClass->updateStatusTable($preTableName); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "insert") $myDataClass->writeLog(translate('New command inserted:')." ".$chkTfValue1); } else {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Command modified:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
} $myDataClass->updateStatusTable($preTableName);
} else { if ($chkModus == 'insert') {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); $myDataClass->writeLog(translate('New command inserted:'). ' ' .$chkTfValue1);
} }
} else { if ($chkModus == 'modify') {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); $myDataClass->writeLog(translate('Command modified:'). ' ' .$chkTfValue1);
} }
$chkModus = "display"; }
} 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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Command definitions'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list // Do not show modified time list
$intNoTime = 1; $intNoTime = 1;
// Process access group selection field // Process access group selection field
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} if (isset($arrModifyData['access_group'])) {
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); $intFieldId = $arrModifyData['access_group'];
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); } else {
// Initial add/modify form definitions $intFieldId = 0;
$myContentClass->addFormInit($conttp); }
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); $intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,"); if ($intReturn != 0) {
$conttp->setVariable("NO_TYPE",translate('unclassified')); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$conttp->setVariable("CHECK_TYPE",translate('check command')); }
$conttp->setVariable("MISC_TYPE",translate('misc command')); // Initial add/modify form definitions
// Insert data from database in "modify" mode $myContentClass->addFormInit($conttp);
if (isset($arrModifyData) && ($chkSelModify == "modify")) { if ($intDataWarning == 1) {
// Check relation information to find out locked configuration datasets $conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); }
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); if ($intVersion < 3) {
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; $conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; }
// Process data $conttp->setVariable('TITLE', translate('Command definitions'));
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo); $conttp->setVariable('NO_TYPE', translate('unclassified'));
// Insert command type $conttp->setVariable('CHECK_TYPE', translate('check command'));
if ($arrModifyData['command_type'] == 1) {$conttp->setVariable("CHECK_TYPE_SELECTED","selected");} $conttp->setVariable('MISC_TYPE', translate('misc command'));
if ($arrModifyData['command_type'] == 2) {$conttp->setVariable("MISC_TYPE_SELECTED","selected");} // Insert data from database in "modify" mode
} if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
$conttp->parse("datainsert"); // Check relation information to find out locked configuration datasets
$conttp->show("datainsert"); $intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
// Insert command type
if ($arrModifyData['command_type'] == 1) {
$conttp->setVariable('CHECK_TYPE_SELECTED', 'selected');
}
if ($arrModifyData['command_type'] == 2) {
$conttp->setVariable('MISC_TYPE_SELECTED', 'selected');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Command name')); $mastertp->setVariable('TITLE', translate('Command definitions'));
$mastertp->setVariable("FIELD_2",translate('Command line')); $mastertp->setVariable('FIELD_1', translate('Command name'));
// Process search string $mastertp->setVariable('FIELD_2', translate('Command line'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process search string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `command_line` LIKE '%".$strSearchTxt."%')"; $strSearchTxt = $_SESSION['search'][$preSearchSession];
} $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' "
// Row sorting . "OR `command_line` LIKE '%".$strSearchTxt."%')";
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; }
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `command_line` $hidSortDir"; // Row sorting
// Count datasets $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; if ($hidSortBy == 2) {
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); $strOrderString = "ORDER BY `config_id`, `command_line` $hidSortDir";
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:')); // Count datasets
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
} else { . "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$intLineCount = (int)$arrDataLinesCount['number']; $booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($intLineCount < $chkLimit) $chkLimit = 0; if ($booReturn1 == false) {
} $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
// Get datasets $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$strSQL = "SELECT `id`, `$preKeyField`, `command_line`, `register`, `active`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere } else {
AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; $intLineCount = (int)$arrDataLinesCount['number'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); if ($intLineCount < $chkLimit) {
if ($booReturn == false) { $chkLimit = 0;
$myVisClass->processMessage(translate('Error while selecting data from database:')); }
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); }
} // Get datasets
// Process data $strSQL = "SELECT `id`, `$preKeyField`, `command_line`, `register`, `active`, `config_id`, `access_group` "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'command_line',40); . "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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,82 +5,86 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Command line visualization // Component : Command line visualization
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$preNoMain = 1; $preNoMain = 1;
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
require("../functions/prepend_adm.php"); require $preBasePath. 'functions/prepend_adm.php';
$strCommandLine = "&nbsp;"; $strCommandLine = '&nbsp;';
$intCount = 0; $intCount = 0;
// //
// Get database values // Get database values
// =================== // ===================
if (isset($_GET['cname']) && ($_GET['cname'] != "")) { 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)."'"); $strResult = $myDBClass->getFieldData("SELECT command_line FROM tbl_command WHERE id='".
if (($strResult != false) && ($strResult != "")) { filter_var($_GET['cname'], FILTER_SANITIZE_NUMBER_INT)."'");
$strCommandLine = $strResult; if (($strResult != false) && ($strResult != '')) {
$intCount = substr_count($strCommandLine,"ARG"); $strCommandLine = $strResult;
if (substr_count($strCommandLine,"ARG8") != 0) { $intCount = substr_count($strCommandLine, 'ARG');
$intCount = 8; if (substr_count($strCommandLine, 'ARG8') != 0) {
} else if (substr_count($strCommandLine,"ARG7") != 0) { $intCount = 8;
$intCount = 7; } elseif (substr_count($strCommandLine, 'ARG7') != 0) {
} else if (substr_count($strCommandLine,"ARG6") != 0) { $intCount = 7;
$intCount = 6; } elseif (substr_count($strCommandLine, 'ARG6') != 0) {
} else if (substr_count($strCommandLine,"ARG5") != 0) { $intCount = 6;
$intCount = 5; } elseif (substr_count($strCommandLine, 'ARG5') != 0) {
} else if (substr_count($strCommandLine,"ARG4") != 0) { $intCount = 5;
$intCount = 4; } elseif (substr_count($strCommandLine, 'ARG4') != 0) {
} else if (substr_count($strCommandLine,"ARG3") != 0) { $intCount = 4;
$intCount = 3; } elseif (substr_count($strCommandLine, 'ARG3') != 0) {
} else if (substr_count($strCommandLine,"ARG2") != 0) { $intCount = 3;
$intCount = 2; } elseif (substr_count($strCommandLine, 'ARG2') != 0) {
} else if (substr_count($strCommandLine,"ARG1") != 0) { $intCount = 2;
$intCount = 1; } elseif (substr_count($strCommandLine, 'ARG1') != 0) {
} else { $intCount = 1;
$intCount = 0; } else {
} $intCount = 0;
}
} }
} }
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head> <head>
<title>Commandline</title> <title>Commandline</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css"> <style type="text/css">
<!-- <!--
body { body {
font-family: Verdana, Arial, Helvetica, sans-serif; font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px; font-size: 10px;
color: #000000; color: #000000;
background-color: #EDF5FF; background-color: #EDF5FF;
margin: 3px; margin: 3px;
border: none; border: none;
} }
--> -->
</style> </style>
</head> </head>
<body> <body>
<?php echo $strCommandLine; ?> <?php echo $strCommandLine; ?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
<!-- <!--
parent.argcount = <?php echo $intCount; ?>; parent.argcount = <?php echo $intCount; ?>;
//--> //-->
</script> </script>
</body> </body>
</html> </html>

View File

@ -5,55 +5,61 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Commands overview // Component : Commands overview
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 4; $prePageId = 4;
$preContent = "admin/mainpages.tpl.htm"; $preContent = 'admin/mainpages.htm.tpl';
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
// //
// Include content // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate('Check commands')); $conttp->setVariable('TITLE', translate('Check commands'));
$conttp->parse("header"); $conttp->setVariable('DESC', translate('To define check and misc commands, notification commands and special '
$conttp->show("header"); . 'commands.'));
$conttp->setVariable("DESC",translate('To define check and misc commands, notification commands and special commands.')); $conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable("STATISTICS",translate('Statistical datas')); $conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable("TYPE",translate('Group')); $conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable("ACTIVE",translate('Active')); $conttp->setVariable('INACTIVE', translate('Inactive'));
$conttp->setVariable("INACTIVE",translate('Inactive'));
// //
// Include statistical data // Include statistical data
// ======================== // ========================
// Get read access groups // Get read access groups
$strAccess = $myVisClass->getAccGroups('read'); $strAccess = $myVisClass->getAccessGroups('read');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=18")+0,'read') == 0) { $intGroupId = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=18');
$conttp->setVariable("NAME",translate('Check commands')); if ($myVisClass->checkAccountGroup($intGroupId, 'read') == 0) {
$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('NAME', translate('Check commands'));
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM tbl_command WHERE active='0' AND config_id=$chkDomainId AND `access_group` IN ($strAccess)")); $conttp->setVariable('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_command` '
$conttp->parse("statisticrow"); . "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('statistics');
$conttp->parse("main"); $conttp->parse('main');
$conttp->show("main"); $conttp->show('main');
// //
// Include Footer // Include Footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,33 +5,38 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin configuration target administration // Component : Admin configuration target administration
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 36; $prePageId = 36;
$preContent = "admin/configtargets.tpl.htm"; $preContent = 'admin/configtargets.htm.tpl';
$preTableName = 'tbl_configtarget'; $preListTpl = 'admin/datalist_common.htm.tpl';
$preKeyField = 'target'; $preTableName = 'tbl_configtarget';
$preAccess = 1; $preKeyField = 'target';
$preFieldvars = 1; $preAccess = 1;
$intIsError = 0; $preFieldvars = 1;
$strPathMessage = ""; $intIsError = 0;
$strPathMessage = '';
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Process path values (add slashes) // Process path values (add slashes)
// ================================= // =================================
@ -47,241 +52,295 @@ $chkTfValue16 = $myVisClass->addSlash($chkTfValue16);
// //
// Check if the permissions and other parameters // Check if the permissions and other parameters
// ============================================= // =============================================
if (($chkModus == "modify" || $chkModus == "insert")) { if (($chkModus == 'modify' || $chkModus == 'insert') && $chkDataId != 0) {
if ($chkDataId != 0) { if ($chkSelValue1 == 1) {
if ($chkSelValue1 == 1) { $arrPaths = array($chkTfValue8,$chkTfValue9,$chkTfValue10,$chkTfValue11,$chkTfValue12,$chkTfValue13);
$arrPaths = array($chkTfValue8,$chkTfValue9,$chkTfValue10,$chkTfValue11,$chkTfValue12,$chkTfValue13); foreach ($arrPaths as $elem) {
foreach ($arrPaths AS $elem) { if ($myConfigClass->isDirWriteable($elem) == 1) {
if (!$myConfigClass->dir_is_writable($elem)) { $myVisClass->processMessage($elem. ' ' .translate('is not writeable'), $strPathMessage);
$myVisClass->processMessage($elem." ".translate("is not writeable"),$strPathMessage); $intIsError = 1;
$intIsError = 1; }
} }
} // Nagios base configuration files
// Nagios base configuration files if (!is_writable($chkTfValue20)) {
if (!is_writable($chkTfValue20)) { $myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios config file'). ' ' .$chkTfValue20
$myVisClass->processMessage(str_replace(" "," ",translate("Nagios config file")." ".$chkTfValue20." ".translate("is not writeable")),$strPathMessage); . ' ' .translate('is not writeable')), $strPathMessage);
$intIsError = 1; $intIsError = 1;
} else { } else {
$intCheck = 0; $intCheck = 0;
if (file_exists($chkTfValue20) && is_readable($chkTfValue20)) { if (file_exists($chkTfValue20) && is_readable($chkTfValue20)) {
$resFile = fopen($chkTfValue20,'r'); $resFile = fopen($chkTfValue20, 'rb');
while (!feof($resFile)) { while (!feof($resFile)) {
$strLine = trim(fgets($resFile)); $strLine = trim(fgets($resFile));
if ((substr_count($strLine,'cfg_dir') != 0) || (substr_count($strLine,'cfg_file') != 0)) { if ((substr_count($strLine, 'cfg_dir') != 0) || (substr_count($strLine, 'cfg_file') != 0)) {
$intCheck = 1; $intCheck = 1;
} }
} }
fclose($resFile); fclose($resFile);
} }
if ($intCheck == 0) { if ($intCheck == 0) {
$myVisClass->processMessage(str_replace(" "," ",translate("Nagios config file")." ".$chkTfValue20." ".translate("is not a valid configuration file!")),$strPathMessage); $myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios config file'). ' ' .
$intIsError = 1; $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); if (!is_writable($chkTfValue14)) {
$intIsError = 1; $myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios base directory'). ' ' .
} $chkTfValue14. ' ' .translate('is not writeable')), $strPathMessage);
$intIsError = 1;
} }
// Check SSH Method if (!is_writable($chkTfValue21)) {
if (($chkSelValue1 == 3) && !function_exists('ssh2_connect')) { $myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios cgi config file'). ' ' .
$myVisClass->processMessage(translate('SSH module not loaded!'),$strPathMessage); $chkTfValue21. ' ' .translate('is not writeable')), $strPathMessage);
$intIsError = 1; $intIsError = 1;
} }
// Check FTP Method if (!is_readable($chkTfValue22)) {
if (($chkSelValue1 == 2) && !function_exists('ftp_connect')) { $myVisClass->processMessage(str_replace(' ', ' ', translate('Nagios resource config file'). ' ' .
$myVisClass->processMessage(translate('FTP module not loaded!'),$strPathMessage); $chkTfValue22. ' ' .translate('is not readable')), $strPathMessage);
$intIsError = 1; $intIsError = 1;
} }
if ($intIsError == 1) { }
$chkModus = "add"; // Check SSH Method
$chkSelModify = "errormodify"; 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 // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `server`='$chkTfValue4', `method`='$chkSelValue1', $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `server`='$chkTfValue4', "
`user`='$chkTfValue5', `password`='$chkTfValue6', `ssh_key_path`='$chkTfValue7', `basedir`='$chkTfValue8', . "`method`='$chkSelValue1', `user`='$chkTfValue5', `password`='$chkTfValue6', "
`hostconfig`='$chkTfValue9', `serviceconfig`='$chkTfValue10', `backupdir`='$chkTfValue11', . "`ssh_key_path`='$chkTfValue7', `ftp_secure`=$chkChbValue1, `basedir`='$chkTfValue8', "
`hostbackup`='$chkTfValue12', `servicebackup`='$chkTfValue13', `nagiosbasedir`='$chkTfValue14', . "`hostconfig`='$chkTfValue9', `serviceconfig`='$chkTfValue10', `backupdir`='$chkTfValue11', "
`importdir`='$chkTfValue15', `picturedir`='$chkTfValue16', `commandfile`='$chkTfValue17', . "`hostbackup`='$chkTfValue12', `servicebackup`='$chkTfValue13', `nagiosbasedir`='$chkTfValue14', "
`binaryfile`='$chkTfValue18', `pidfile`='$chkTfValue19', `conffile`='$chkTfValue20', `version`=$chkSelValue2, . "`importdir`='$chkTfValue15', `picturedir`='$chkTfValue16', `commandfile`='$chkTfValue17', "
`access_group`=$chkSelAccGr, `active`='$chkActive', . "`binaryfile`='$chkTfValue18', `pidfile`='$chkTfValue19', `conffile`='$chkTfValue20', "
`last_modified`=NOW()"; . "`cgifile`='$chkTfValue21', `resourcefile`='$chkTfValue22',`version`=$chkSelValue2, "
if ($chkModus == "insert") { . "`access_group`=$chkSelAccGr, `active`='$chkActive',`last_modified`=NOW()";
$strSQL = "INSERT INTO ".$strSQLx; if ($chkModus == 'insert') {
} else { $strSQL = 'INSERT INTO ' .$strSQLx;
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; } else {
} $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ($intWriteAccessId == 0) { }
if (($chkTfValue1 != "") && ($chkTfValue2 != "") && (($chkTfValue4 != "") || ($chkDataId == 0))) { if ($intWriteAccessId == 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($chkTfValue4 != '') || ($chkDataId == 0))) {
if ($intReturn == 1) { $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($intReturn == 1) {
} else { $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); } else {
if ($chkModus == "insert") $myDataClass->writeLog(translate('New Domain inserted:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
if ($chkModus == "modify") $myDataClass->writeLog(translate('Domain modified:')." ".$chkTfValue1); if ($chkModus == 'insert') {
} $myDataClass->writeLog(translate('New Domain inserted:'). ' ' .$chkTfValue1);
} else { }
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); if ($chkModus == 'modify') {
} $myDataClass->writeLog(translate('Domain modified:'). ' ' .$chkTfValue1);
} else { }
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); }
} } else {
$chkModus = "display"; $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","<h2 style=\"padding-bottom:5px;\">".translate("Warning, at least one error occured, please check!")."</h2>".$strPathMessage);
$conttp->parse("header");
$conttp->show("header");
// //
// Single view // Single view
// =========== // ===========
if ($chkModus == "add") { if ($chkModus == 'add') {
// Process acces group selection field // Process acces group selection field
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} if (isset($arrModifyData['access_group'])) {
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); $intFieldId = $arrModifyData['access_group'];
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); } else {
// Initial add/modify form definitions $intFieldId = 0;
$myContentClass->addFormInit($conttp); }
$conttp->setVariable("CLASS_NAME_1","elementHide"); $intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
$conttp->setVariable("CLASS_NAME_2","elementHide"); if ($intReturn != 0) {
$conttp->setVariable("FILL_ALLFIELDS",translate('Please fill in all fields marked with an *')); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$conttp->setVariable("FILL_ILLEGALCHARS",translate('The following field contains not permitted characters:')); }
// Insert data from database in "modify" mode // Initial add/modify form definitions
// Insert data from database in "modify" mode $myContentClass->addFormInit($conttp);
if (isset($arrModifyData) && ($chkSelModify == "modify")) { $conttp->setVariable('TITLE', translate('Configuration domain administration'));
// Process data if ($intIsError == 1) {
$myContentClass->addInsertData($conttp,$arrModifyData,0,''); $conttp->setVariable('PATHMESSAGE', '<h2 style="padding-bottom:5px;">' .translate('Warning, at least one ' .
// Connection method 'error occured, please check!'). '</h2>' .$strPathMessage);
if ($arrModifyData['method'] == 1) $conttp->setVariable("FILE_SELECTED","selected"); }
if ($arrModifyData['method'] == 2) { $conttp->setVariable('CLASS_NAME_1', 'elementHide');
$conttp->setVariable("FTP_SELECTED","selected"); $conttp->setVariable('CLASS_NAME_2', 'elementHide');
$conttp->setVariable("CLASS_NAME_1","elementShow"); $conttp->setVariable('CLASS_NAME_3', 'elementHide');
} $conttp->setVariable('FILL_ALLFIELDS', translate('Please fill in all fields marked with an *'));
if ($arrModifyData['method'] == 3) { $conttp->setVariable('FILL_ILLEGALCHARS', translate('The following field contains illegal characters:'));
$conttp->setVariable("SFTP_SELECTED","selected"); // Insert data from database in "modify" mode
$conttp->setVariable("CLASS_NAME_1","elementShow"); if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
$conttp->setVariable("CLASS_NAME_2","elementShow"); // Process data
} $myContentClass->addInsertData($conttp, $arrModifyData, 0, '');
// Nagios version // Connection method
if ($arrModifyData['version'] == 1) $conttp->setVariable("VER_SELECTED_1","selected"); if ($arrModifyData['method'] == 1) {
if ($arrModifyData['version'] == 2) $conttp->setVariable("VER_SELECTED_2","selected"); $conttp->setVariable('FILE_SELECTED', 'selected');
if ($arrModifyData['version'] == 3) $conttp->setVariable("VER_SELECTED_3","selected"); }
// Domain localhost cant' be renamed if ($arrModifyData['method'] == 2) {
if ($arrModifyData[$preKeyField] == "localhost") { $conttp->setVariable('FTP_SELECTED', 'selected');
$conttp->setVariable("DOMAIN_DISABLE","readonly"); $conttp->setVariable('CLASS_NAME_1', 'elementShow');
$conttp->setVariable("LOCKCLASS","inputlock"); $conttp->setVariable('CLASS_NAME_2', 'elementHide');
} else if ($arrModifyData[$preKeyField] == "common") { $conttp->setVariable('CLASS_NAME_3', 'elementShow');
$conttp->setVariable("DOMAIN_DISABLE","readonly"); }
$conttp->setVariable("COMMON_INVISIBLE","class=\"elementHide\""); if ($arrModifyData['method'] == 3) {
$conttp->setVariable("LOCKCLASS","inputlock"); $conttp->setVariable('SFTP_SELECTED', 'selected');
} $conttp->setVariable('CLASS_NAME_1', 'elementShow');
} $conttp->setVariable('CLASS_NAME_2', 'elementShow');
if ($chkSelModify == "errormodify") { $conttp->setVariable('CLASS_NAME_3', 'elementHide');
$conttp->setVariable("DAT_TARGET",$chkTfValue1); }
// Domain localhost cant' be renamed if ($arrModifyData['ftp_secure'] == 1) {
if ($chkTfValue1 == "localhost") { $conttp->setVariable('FTPS_CHECKED', 'checked');
$conttp->setVariable("DOMAIN_DISABLE","readonly"); }
$conttp->setVariable("LOCKCLASS","inputlock"); // Nagios version
} else if ($chkTfValue1 == "common") { $conttp->setVariable('VER_SELECTED_' .$arrModifyData['version'], 'selected');
$conttp->setVariable("DOMAIN_DISABLE","readonly"); // Domain localhost cant' be renamed
$conttp->setVariable("COMMON_INVISIBLE","class=\"elementHide\""); if ($arrModifyData[$preKeyField] == 'localhost') {
$conttp->setVariable("LOCKCLASS","inputlock"); $conttp->setVariable('DOMAIN_DISABLE', 'readonly');
} else { $conttp->setVariable('LOCKCLASS', 'inputlock');
$conttp->setVariable("LOCKCLASS","inpmust"); } elseif ($arrModifyData[$preKeyField] == 'common') {
} $conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable("DAT_ALIAS",$chkTfValue2); $conttp->setVariable('COMMON_INVISIBLE', 'class="elementHide"');
$conttp->setVariable("DAT_SERVER",$chkTfValue4); $conttp->setVariable('LOCKCLASS', 'inputlock');
// Connection method }
if ($chkSelValue1 == 1) $conttp->setVariable("FILE_SELECTED","selected"); }
if ($chkSelValue1 == 2) { if ($chkSelModify == 'errormodify') {
$conttp->setVariable("FTP_SELECTED","selected"); $conttp->setVariable('DAT_TARGET', $chkTfValue1);
$conttp->setVariable("CLASS_NAME_1","elementShow"); // Domain localhost cant' be renamed
} if ($chkTfValue1 == 'localhost') {
if ($chkSelValue1 == 3) { $conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->setVariable("SFTP_SELECTED","selected"); $conttp->setVariable('LOCKCLASS', 'inputlock');
$conttp->setVariable("CLASS_NAME_1","elementShow"); } elseif ($chkTfValue1 == 'common') {
$conttp->setVariable("CLASS_NAME_2","elementShow"); $conttp->setVariable('DOMAIN_DISABLE', 'readonly');
} $conttp->setVariable('COMMON_INVISIBLE', 'class="elementHide"');
$conttp->setVariable("DAT_USER",$chkTfValue5); $conttp->setVariable('LOCKCLASS', 'inputlock');
$conttp->setVariable("DAT_SSH_KEY_PATH",$chkTfValue7); } else {
$conttp->setVariable("DAT_BASEDIR",$chkTfValue8); $conttp->setVariable('LOCKCLASS', 'inpmust');
$conttp->setVariable("DAT_HOSTCONFIG",$chkTfValue9); }
$conttp->setVariable("DAT_SERVICECONFIG",$chkTfValue10); $conttp->setVariable('DAT_ALIAS', $chkTfValue2);
$conttp->setVariable("DAT_BACKUPDIR",$chkTfValue11); $conttp->setVariable('DAT_SERVER', $chkTfValue4);
$conttp->setVariable("DAT_HOSTBACKUP",$chkTfValue12); // Connection method
$conttp->setVariable("DAT_SERVICEBACKUP",$chkTfValue13); if ($chkSelValue1 == 1) {
$conttp->setVariable("DAT_NAGIOSBASEDIR",$chkTfValue14); $conttp->setVariable('FILE_SELECTED', 'selected');
$conttp->setVariable("DAT_IMPORTDIR",$chkTfValue15); $conttp->setVariable('CLASS_NAME_1', 'elementHide');
$conttp->setVariable("DAT_COMMANDFILE",$chkTfValue17); $conttp->setVariable('CLASS_NAME_2', 'elementHide');
$conttp->setVariable("DAT_BINARYFILE",$chkTfValue18); $conttp->setVariable('CLASS_NAME_3', 'elementHide');
$conttp->setVariable("DAT_PIDFILE",$chkTfValue19); }
$conttp->setVariable("DAT_CONFFILE",$chkTfValue20); if ($chkSelValue1 == 2) {
$conttp->setVariable("DAT_PICTUREDIR",$chkTfValue16); $conttp->setVariable('FTP_SELECTED', 'selected');
// NagiosQL version $conttp->setVariable('CLASS_NAME_1', 'elementShow');
if ($chkSelValue2 == 1) $conttp->setVariable("VER_SELECTED_1","selected"); $conttp->setVariable('CLASS_NAME_2', 'elementHide');
if ($chkSelValue2 == 2) $conttp->setVariable("VER_SELECTED_2","selected"); $conttp->setVariable('CLASS_NAME_3', 'elementShow');
if ($chkSelValue2 == 3) $conttp->setVariable("VER_SELECTED_3","selected"); }
// Hidden variables if ($chkSelValue1 == 3) {
$conttp->setVariable("MODUS",$_POST['modus']); $conttp->setVariable('SFTP_SELECTED', 'selected');
$conttp->setVariable("DAT_ID",$_POST['hidId']); $conttp->setVariable('CLASS_NAME_1', 'elementShow');
$conttp->setVariable("LIMIT",$_POST['hidLimit']); $conttp->setVariable('CLASS_NAME_2', 'elementShow');
// Active $conttp->setVariable('CLASS_NAME_3', 'elementHide');
if (isset ($_POST['chbActive'])) { }
$conttp->setVariable("ACT_CHECKED","checked"); $conttp->setVariable('DAT_USER', $chkTfValue5);
} else { $conttp->setVariable('DAT_SSH_KEY_PATH', $chkTfValue7);
$conttp->setVariable("ACT_CHECKED",""); if ($chkChbValue1== 1) {
} $conttp->setVariable('FTPS_CHECKED', 'checked');
} }
$conttp->parse("datainsert"); $conttp->setVariable('DAT_BASEDIR', $chkTfValue8);
$conttp->show("datainsert"); $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 // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Configuration target')); $mastertp->setVariable('TITLE', translate('Configuration domain administration'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Configuration target'));
// Row sorting $mastertp->setVariable('FIELD_2', translate('Description'));
$strOrderString = "ORDER BY `$preKeyField` $hidSortDir"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `alias` $hidSortDir"; $strOrderString = "ORDER BY `$preKeyField` $hidSortDir";
// Count datasets if ($hidSortBy == 2) {
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)"; $strOrderString = "ORDER BY `alias` $hidSortDir";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); }
if ($booReturn == false) { // Count datasets
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)";
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
} else { if ($booReturn1 == false) {
$intLineCount = (int)$arrDataLinesCount['number']; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} } else {
// Get datasets $intLineCount = (int)$arrDataLinesCount['number'];
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `nodelete`, `access_group` FROM `$preTableName` WHERE `access_group` IN ($strAccess) if ($intLineCount < $chkLimit) {
$strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; $chkLimit = 0;
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); }
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); // Get datasets
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `nodelete`, `access_group` "
} . "FROM `$preTableName` WHERE `access_group` IN ($strAccess) $strOrderString "
// Process data . "LIMIT $chkLimit,".$SETS['common']['pagelines'];
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias'); $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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1); $myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,178 +5,271 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Contactgroup definition // Component : Contactgroup definition
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 15; $prePageId = 15;
$preContent = "admin/contactgroups.tpl.htm"; $preContent = 'admin/contactgroups.htm.tpl';
$preSearchSession = 'contactgroup'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_contactgroup'; $preSearchSession = 'contactgroup';
$preKeyField = 'contactgroup_name'; $preTableName = 'tbl_contactgroup';
$preAccess = 1; $preKeyField = 'contactgroup_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, `contactgroup_members`=$intMselValue2, $preSQLCommon1"; $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, "
if ($chkModus == "insert") { . "`contactgroup_members`=$intMselValue2, $preSQLCommon1";
$strSQL = "INSERT INTO ".$strSQLx; if ($chkModus == 'insert') {
} else { $strSQL = 'INSERT INTO ' .$strSQLx;
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; } else {
} $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ($intWriteAccessId == 0) { }
if (($chkTfValue1 != "") && ($chkTfValue2 != "") && ($intMselValue1 != 0)) { if ($intWriteAccessId == 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if (($chkTfValue1 != '') && ($chkTfValue2 != '') && ($intMselValue1 != 0)) {
if ($chkModus == "insert") $chkDataId = $intInsertId; $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn == 1) { if ($chkModus == 'insert') {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId = $intInsertId;
} else { }
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($intReturn == 1) {
$myDataClass->updateStatusTable($preTableName); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "insert") $myDataClass->writeLog(translate('New contact group inserted:')." ".$chkTfValue1); } else {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Contact group modified:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
// $myDataClass->updateStatusTable($preTableName);
// Insert/update relations if ($chkModus == 'insert') {
// ======================= $myDataClass->writeLog(translate('New contact group inserted:'). ' ' .$chkTfValue1);
if ($chkModus == "insert") { }
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkContactgroupToContact",$chkDataId,$chkMselValue1); if ($chkModus == 'modify') {
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myDataClass->writeLog(translate('Contact group modified:'). ' ' .$chkTfValue1);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkContactgroupToContactgroup",$chkDataId,$chkMselValue2); }
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); //
} else if ($chkModus == "modify") { // Insert/update relations
if ($intMselValue1 != 0) { // =======================
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkContactgroupToContact",$chkDataId,$chkMselValue1); if ($chkModus == 'insert') {
} else { if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkContactgroupToContact",$chkDataId); $intRet1 = $myDataClass->dataInsertRelation(
} 'tbl_lnkContactgroupToContact',
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId,
if ($intMselValue2 != 0) { $chkMselValue1
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkContactgroupToContactgroup",$chkDataId,$chkMselValue2); );
} else { }
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkContactgroupToContactgroup",$chkDataId); if (isset($intRet1) && ($intRet1 != 0)) {
} $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} if ($intMselValue2 != 0) {
if (($intRet1 + $intRet2) != 0) $strInfoMessage = ""; $intRet2 = $myDataClass->dataInsertRelation(
} 'tbl_lnkContactgroupToContactgroup',
} else { $chkDataId,
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); $chkMselValue2
} );
} else { }
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); if (isset($intRet2) && ($intRet2 != 0)) {
} $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$chkModus = "display"; }
} 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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Define contact groups (contactgroups.cfg)'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Define contact groups (contactgroups.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Process contact member selection fields $intNoTime = 1;
$intReturn = 0; // Process contact member selection fields
if (isset($arrModifyData['members'])) {$intFieldId = $arrModifyData['members'];} else {$intFieldId = 0;} if (isset($arrModifyData['members'])) {
$intReturn = $myVisClass->parseSelectMulti('tbl_contact','contact_name','contacts','tbl_lnkContactgroupToContact',2,$intFieldId); $intFieldId = $arrModifyData['members'];
if ($intReturn != 0) { } else {
$myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId = 0;
$myVisClass->processMessage(translate('Attention, no contacts defined!'),$strDBWarning); }
$intDataWarning = 1; $intReturn1 = $myVisClass->parseSelectMulti(
} 'tbl_contact',
// Process contactgroup member selection fields 'contact_name',
if (isset($arrModifyData['contactgroup_members'])) {$intFieldId = $arrModifyData['contactgroup_members'];} else {$intFieldId = 0;} 'contacts',
$intReturn = $myVisClass->parseSelectMulti($preTableName,$preKeyField,'contactgroups','tbl_lnkContactgroupToContactgroup',0,$intFieldId,$chkListId); 'tbl_lnkContactgroupToContact',
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); 2,
// Process acces group selection field $intFieldId
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} );
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); if ($intReturn1 != 0) {
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
// Initial add/modify form definitions $myVisClass->processMessage(translate('Attention, no contacts defined!'), $strDBWarning);
$myContentClass->addFormInit($conttp); $intDataWarning = 1;
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); }
if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,"); // Process contactgroup member selection fields
// Insert data from database in "modify" mode if (isset($arrModifyData['contactgroup_members'])) {
if (isset($arrModifyData) && ($chkSelModify == "modify")) { $intFieldId = $arrModifyData['contactgroup_members'];
// Check relation information to find out locked configuration datasets } else {
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); $intFieldId = 0;
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); }
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; $intReturn2 = $myVisClass->parseSelectMulti(
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; $preTableName,
// Process data $preKeyField,
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo); 'contactgroups',
} 'tbl_lnkContactgroupToContactgroup',
$conttp->parse("datainsert"); 0,
$conttp->show("datainsert"); $intFieldId,
$chkListId
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Contact group')); $mastertp->setVariable('TITLE', translate('Define contact groups (contactgroups.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Contact group'));
// Process filter string $mastertp->setVariable('FIELD_2', translate('Description'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process filter string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%')"; $strSearchTxt = $_SESSION['search'][$preSearchSession];
} $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%')";
// Row sorting }
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir"; $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
// Count datasets if ($hidSortBy == 2) {
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); }
if ($booReturn == false) { // Count datasets
$myVisClass->processMessage(translate('Error while selecting data from database:')); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
} else { $booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
$intLineCount = (int)$arrDataLinesCount['number']; if ($booReturn1 == false) {
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
} $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
// Get datasets } else {
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere $intLineCount = (int)$arrDataLinesCount['number'];
AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; if ($intLineCount < $chkLimit) {
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); $chkLimit = 0;
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:')); }
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); // Get datasets
} $strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
// Process data . "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias'); . "$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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,338 +5,506 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Contact definitions // Component : Contact definitions
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 14; $prePageId = 14;
$preContent = "admin/contacts.tpl.htm"; $preContent = 'admin/contacts.htm.tpl';
$preSearchSession = 'contact'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_contact'; $preSearchSession = 'contact';
$preKeyField = 'contact_name'; $preTableName = 'tbl_contact';
$preAccess = 1; $preKeyField = 'contact_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Checkbox data processing // Checkbox data processing
// ======================== // ========================
if ($intVersion == 3) { if (($intVersion == 3) || ($intVersion == 4)) {
$strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f,0,-1); $strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f.$chkChbGr2g,0,-1); $strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f.$chkChbGr2g, 0, -1);
} else { } else {
$strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1f,0,-1); $strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2g,0,-1); $strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2g, 0, -1);
} }
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `contactgroups`=$intMselValue1, `contactgroups_tploptions`=$chkRadValue1, $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', "
`host_notifications_enabled`='$chkRadValue2', `service_notifications_enabled`='$chkRadValue3', `host_notification_period`='$chkSelValue1', . "`contactgroups`=$intMselValue1, `contactgroups_tploptions`=$chkRadValue1, "
`service_notification_period`='$chkSelValue2', `host_notification_options`='$strHO', `host_notification_commands_tploptions`=$chkRadValue4, . "`minimum_importance`=$chkTfNullVal1, "
`service_notification_options`='$strSO', `host_notification_commands`=$intMselValue2, `service_notification_commands`=$intMselValue3, . "`host_notifications_enabled`='$chkRadValue2', `service_notifications_enabled`='$chkRadValue3', "
`service_notification_commands_tploptions`=$chkRadValue5, `can_submit_commands`='$chkRadValue8', `retain_status_information`='$chkRadValue6', . "`host_notification_period`='$chkSelValue1', `service_notification_period`='$chkSelValue2', "
`retain_nonstatus_information`='$chkRadValue7', `email`='$chkTfValue3', `pager`='$chkTfValue4', `address1`='$chkTfValue5', `address2`='$chkTfValue6', . "`host_notification_options`='$strHO', `host_notification_commands_tploptions`=$chkRadValue4, "
`address3`='$chkTfValue7', `address4`='$chkTfValue8', `address5`='$chkTfValue9', `address6`='$chkTfValue10', `name`='$chkTfValue11', . "`service_notification_options`='$strSO', `host_notification_commands`=$intMselValue2, "
`use_variables`='$intVariables', `use_template`=$intTemplates, $preSQLCommon1"; . "`service_notification_commands`=$intMselValue3, "
if ($chkModus == "insert") { . "`service_notification_commands_tploptions`=$chkRadValue5, `can_submit_commands`='$chkRadValue8', "
$strSQL = "INSERT INTO ".$strSQLx; . "`retain_status_information`='$chkRadValue6', `retain_nonstatus_information`='$chkRadValue7', "
} else { . "`email`='$chkTfValue3', `pager`='$chkTfValue4', `address1`='$chkTfValue5', `address2`='$chkTfValue6', "
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; . "`address3`='$chkTfValue7', `address4`='$chkTfValue8', `address5`='$chkTfValue9', "
} . "`address6`='$chkTfValue10', `name`='$chkTfValue11', `use_variables`='$intVariables', "
if ($intWriteAccessId == 0) { . "`use_template`=$intTemplates, $preSQLCommon1";
if ($chkTfValue1 != "") { if ($chkModus == 'insert') {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $strSQL = 'INSERT INTO ' .$strSQLx;
if ($chkModus == "insert") $chkDataId = $intInsertId; } else {
if ($intReturn == 1) { $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} else { if ($intWriteAccessId == 0) {
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($chkTfValue1 != '') {
$myDataClass->updateStatusTable($preTableName); $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == "insert") $myDataClass->writeLog(translate('New contact inserted:')." ".$chkTfValue1); if ($chkModus == 'insert') {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Contact modified:')." ".$chkTfValue1); $chkDataId = $intInsertId;
// }
// Insert/update relations if ($intReturn == 1) {
// ======================= $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "insert") { } else {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkContactToContactgroup",$chkDataId,$chkMselValue1); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myDataClass->updateStatusTable($preTableName);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkContactToCommandHost",$chkDataId,$chkMselValue2); if ($chkModus == 'insert') {
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myDataClass->writeLog(translate('New contact inserted:'). ' ' .$chkTfValue1);
if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkContactToCommandService",$chkDataId,$chkMselValue3); }
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($chkModus == 'modify') {
} else if ($chkModus == "modify") { $myDataClass->writeLog(translate('Contact modified:'). ' ' .$chkTfValue1);
if ($intMselValue1 != 0) { }
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkContactToContactgroup",$chkDataId,$chkMselValue1); //
} else { // Insert/update relations
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkContactToContactgroup",$chkDataId); // =======================
} if ($chkModus == 'insert') {
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($intMselValue1 != 0) {
if ($intMselValue2 != 0) { $intRet1 = $myDataClass->dataInsertRelation(
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkContactToCommandHost",$chkDataId,$chkMselValue2); 'tbl_lnkContactToContactgroup',
} else { $chkDataId,
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkContactToCommandHost",$chkDataId); $chkMselValue1
} );
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
if ($intMselValue3 != 0) { if (isset($intRet1) && ($intRet1 != 0)) {
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkContactToCommandService",$chkDataId,$chkMselValue3); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else { }
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkContactToCommandService",$chkDataId); if ($intMselValue2 != 0) {
} $intRet2 = $myDataClass->dataInsertRelation(
if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); 'tbl_lnkContactToCommandHost',
} $chkDataId,
if (($intRet1 + $intRet2 + $intRet3) != 0) $strInfoMessage = ""; $chkMselValue2
// );
// Insert/update templates from session data }
// ========================================= if (isset($intRet2) && ($intRet2 != 0)) {
if ($chkModus == "modify") { $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$strSQL = "DELETE FROM `tbl_lnkContactToContacttemplate` WHERE `idMaster`=$chkDataId"; }
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if ($intMselValue3 != 0) {
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $intRet3 = $myDataClass->dataInsertRelation(
} 'tbl_lnkContactToCommandService',
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) && (count($_SESSION['templatedefinition']) != 0)) { $chkDataId,
$intSortId = 1; $chkMselValue3
foreach($_SESSION['templatedefinition'] AS $elem) { );
if ($elem['status'] == 0) { }
$strSQL = "INSERT INTO `tbl_lnkContactToContacttemplate` (`idMaster`,`idSlave`,`idTable`,`idSort`) if (isset($intRet3) && ($intRet3 != 0)) {
VALUES ($chkDataId,".$elem['idSlave'].",".$elem['idTable'].",".$intSortId.")"; $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); }
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); } elseif ($chkModus == 'modify') {
} if ($intMselValue1 != 0) {
$intSortId++; $intRet1 = $myDataClass->dataUpdateRelation(
} 'tbl_lnkContactToContactgroup',
} $chkDataId,
// $chkMselValue1
// Insert/update variables from session data );
// ========================================= } else {
if ($chkModus == "modify") { $intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkContactToContactgroup', $chkDataId);
$strSQL = "SELECT * FROM `tbl_lnkContactToVariabledefinition` WHERE `idMaster`=$chkDataId"; }
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); if ($intRet1 != 0) {
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($intDataCount != 0) { }
foreach ($arrData AS $elem) { if ($intMselValue2 != 0) {
$strSQL = "DELETE FROM `tbl_variabledefinition` WHERE `id`=".$elem['idSlave']; $intRet2 = $myDataClass->dataUpdateRelation(
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); 'tbl_lnkContactToCommandHost',
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId,
} $chkMselValue2
} );
$strSQL = "DELETE FROM `tbl_lnkContactToVariabledefinition` WHERE `idMaster`=$chkDataId"; } else {
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkContactToCommandHost', $chkDataId);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} if ($intRet2 != 0) {
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) && (count($_SESSION['variabledefinition']) != 0)) { $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
foreach($_SESSION['variabledefinition'] AS $elem) { }
if ($elem['status'] == 0) { if ($intMselValue3 != 0) {
$strSQL = "INSERT INTO `tbl_variabledefinition` (`name`,`value`,`last_modified`) $intRet3 = $myDataClass->dataUpdateRelation(
VALUES ('".$elem['definition']."','".$elem['range']."',now())"; 'tbl_lnkContactToCommandService',
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $chkDataId,
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkMselValue3
$strSQL = "INSERT INTO `tbl_lnkContactToVariabledefinition` (`idMaster`,`idSlave`) );
VALUES ($chkDataId,$intInsertId)"; } else {
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkContactToCommandService', $chkDataId);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} if ($intRet3 != 0) {
} $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
} }
} else { //if (($intRet1 + $intRet2 + $intRet3) != 0) {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); //$strInfoMessage = "";
} //}
} else { //
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); // Insert/update templates from session data
} // =========================================
$chkModus = "display"; 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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate("Define contacts (contacts.cfg)"));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Define contacts (contacts.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Process template selection fields (Spezial) $intNoTime = 1;
$strWhere = ""; // Process template selection fields (Spezial)
if (isset($arrModifyData) && ($chkSelModify == "modify")) { $strWhere = '';
$strWhere = "AND `id` <> ".$arrModifyData['id']; 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); $strSQL5 = 'SELECT `id`,`template_name`, `active` '
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "FROM `tbl_contacttemplate` WHERE $strDomainWhere2 ORDER BY `template_name`";
if ($intDataCountTpl != 0) { $booReturn5 = $myDBClass->hasDataArray($strSQL5, $arrDataTpl, $intDataCountTpl);
foreach ($arrDataTpl AS $elem) { if ($booReturn5 == false) {
if ($elem['active'] == 0) { $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$strActive = " [inactive]"; }
$conttp->setVariable("SPECIAL_STYLE","inactive_option"); if ($intDataCountTpl != 0) {
} else { /** @var array $arrDataTpl */
$strActive = ""; foreach ($arrDataTpl as $elem) {
$conttp->setVariable("SPECIAL_STYLE",""); if ($elem['active'] == 0) {
} $strActive = ' [inactive]';
$conttp->setVariable("DAT_TEMPLATE",htmlspecialchars($elem['template_name'],ENT_QUOTES,'UTF-8').$strActive); $conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
$conttp->setVariable("DAT_TEMPLATE_ID",$elem['id']."::1"); } else {
$conttp->parse("template"); $strActive = '';
} $conttp->setVariable('SPECIAL_STYLE', '');
} }
$strSQL = "SELECT `id`, `name`, `active` FROM `$preTableName` WHERE `name` <> '' $strWhere AND $strDomainWhere ORDER BY `name`"; $conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['template_name'], ENT_QUOTES, 'UTF-8').
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataHpl,$intDataCount); $strActive);
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::1');
if ($arrDataHpl != 0) { $conttp->parse('template');
foreach ($arrDataHpl AS $elem) { }
if ($elem['active'] == 0) { }
$strActive = " [inactive]"; $strSQL6 = 'SELECT `id`, `name`, `active` '
$conttp->setVariable("SPECIAL_STYLE","inactive_option"); . "FROM `$preTableName` WHERE `name` <> '' $strWhere AND $strDomainWhere ORDER BY `name`";
} else { $booReturn6 = $myDBClass->hasDataArray($strSQL6, $arrDataHpl, $intDataCount);
$strActive = ""; if ($booReturn6 == false) {
$conttp->setVariable("SPECIAL_STYLE",""); $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} }
$conttp->setVariable("DAT_TEMPLATE",htmlspecialchars($elem['name'],ENT_QUOTES,'UTF-8').$strActive); if ($intDataCount != 0) {
$conttp->setVariable("DAT_TEMPLATE_ID",$elem['id']."::2"); /** @var array $arrDataHpl */
$conttp->parse("template"); foreach ($arrDataHpl as $elem) {
} if ($elem['active'] == 0) {
} $strActive = ' [inactive]';
// Process timeperiod selection fields $conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
$intReturn = 0; } else {
if (isset($arrModifyData['host_notification_period'])) {$intFieldId = $arrModifyData['host_notification_period'];} else {$intFieldId = 0;} $strActive = '';
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','host_time',1,$intFieldId); $conttp->setVariable('SPECIAL_STYLE', '');
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
if (isset($arrModifyData['service_notification_period'])) {$intFieldId = $arrModifyData['service_notification_period'];} else {$intFieldId = 0;} $conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['name'], ENT_QUOTES, 'UTF-8').$strActive);
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','service_time',1,$intFieldId); $conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::2');
if ($intReturn != 0) { $conttp->parse('template');
$myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
$myVisClass->processMessage(translate('Attention, no time periods defined!'),$strDBWarning); }
$intDataWarning = 1; // Process timeperiod selection fields
} if (isset($arrModifyData['host_notification_period'])) {
// Process command selection fields $intFieldId = $arrModifyData['host_notification_period'];
if (isset($arrModifyData['host_notification_commands'])) {$intFieldId = $arrModifyData['host_notification_commands'];} else {$intFieldId = 0;} } else {
$intReturn = $myVisClass->parseSelectMulti('tbl_command','command_name','host_command','tbl_lnkContactToCommandHost',0,$intFieldId); $intFieldId = 0;
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
if (isset($arrModifyData['service_notification_commands'])) {$intFieldId = $arrModifyData['service_notification_commands'];} else {$intFieldId = 0;} $intReturn1 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'host_time', 1, $intFieldId);
$intReturn = $myVisClass->parseSelectMulti('tbl_command','command_name','service_command','tbl_lnkContactToCommandService',0,$intFieldId); if ($intReturn1 != 0) {
if ($intReturn != 0) { $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
$myVisClass->processMessage(translate('Attention, no commands defined!'),$strDBWarning); if (isset($arrModifyData['service_notification_period'])) {
$intDataWarning = 1; $intFieldId = $arrModifyData['service_notification_period'];
} } else {
// Process contactgroup selection field $intFieldId = 0;
if (isset($arrModifyData['contactgroups'])) {$intFieldId = $arrModifyData['contactgroups'];} else {$intFieldId = 0;} }
$intReturn = $myVisClass->parseSelectMulti('tbl_contactgroup','contactgroup_name','contactgroup','tbl_lnkContactToContactgroup',2,$intFieldId); $intReturn2 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'service_time', 1, $intFieldId);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); if ($intReturn2 != 0) {
// Process access group selection field $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} $myVisClass->processMessage(translate('Attention, no time periods defined!'), $strDBWarning);
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); $intDataWarning = 1;
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Initial add/modify form definitions // Process command selection fields
$strChbFields = "HNE,SNE,RSI,CSC,RNS,TPL,SEC,HOC,COG"; if (isset($arrModifyData['host_notification_commands'])) {
$myContentClass->addFormInit($conttp,$strChbFields); $intFieldId = $arrModifyData['host_notification_commands'];
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); } else {
if ($intVersion == 3) { $intFieldId = 0;
$conttp->setVariable("HOST_OPTION_FIELDS","chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1e,chbGr1f"); }
$conttp->setVariable("SERVICE_OPTION_FIELDS","chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2f,chbGr2g"); $intReturn3 = $myVisClass->parseSelectMulti(
} else { 'tbl_command',
$conttp->setVariable("HOST_OPTION_FIELDS","chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1f"); 'command_name',
$conttp->setVariable("SERVICE_OPTION_FIELDS","chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2g"); 'host_command',
$conttp->setVariable("VERSION_20_VALUE_MUST",",tfValue2"); 'tbl_lnkContactToCommandHost',
} 0,
// Insert data from database in "modify" mode $intFieldId
if (isset($arrModifyData) && ($chkSelModify == "modify")) { );
// Check relation information to find out locked configuration datasets if ($intReturn3 != 0) {
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); }
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; if (isset($arrModifyData['service_notification_commands'])) {
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; $intFieldId = $arrModifyData['service_notification_commands'];
// Process data } else {
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo,$strChbFields); $intFieldId = 0;
// Process radio fields }
$conttp->setVariable("DAT_HNE".$arrModifyData['host_notifications_enabled']."_CHECKED","checked"); $intReturn4 = $myVisClass->parseSelectMulti(
$conttp->setVariable("DAT_SNE".$arrModifyData['service_notifications_enabled']."_CHECKED","checked"); 'tbl_command',
$conttp->setVariable("DAT_RSI".$arrModifyData['retain_status_information']."_CHECKED","checked"); 'command_name',
$conttp->setVariable("DAT_CSC".$arrModifyData['can_submit_commands']."_CHECKED","checked"); 'service_command',
$conttp->setVariable("DAT_RNS".$arrModifyData['retain_nonstatus_information']."_CHECKED","checked"); 'tbl_lnkContactToCommandService',
$conttp->setVariable("DAT_TPL".$arrModifyData['use_template_tploptions']."_CHECKED","checked"); 0,
$conttp->setVariable("DAT_SEC".$arrModifyData['service_notification_commands_tploptions']."_CHECKED","checked"); $intFieldId
$conttp->setVariable("DAT_HOC".$arrModifyData['host_notification_commands_tploptions']."_CHECKED","checked"); );
$conttp->setVariable("DAT_COG".$arrModifyData['contactgroups_tploptions']."_CHECKED","checked"); if ($intReturn4 != 0) {
// Process option fields $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
foreach(explode(",",$arrModifyData['host_notification_options']) AS $elem) { $myVisClass->processMessage(translate('Attention, no commands defined!'), $strDBWarning);
$conttp->setVariable("DAT_HO".strtoupper($elem)."_CHECKED","checked"); $intDataWarning = 1;
} }
foreach(explode(",",$arrModifyData['service_notification_options']) AS $elem) { // Process contactgroup selection field
$conttp->setVariable("DAT_SO".strtoupper($elem)."_CHECKED","checked"); if (isset($arrModifyData['contactgroups'])) {
} $intFieldId = $arrModifyData['contactgroups'];
} } else {
$conttp->parse("datainsert"); $intFieldId = 0;
$conttp->show("datainsert"); }
$intReturn5 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
'contactgroup',
'tbl_lnkContactToContactgroup',
2,
$intFieldId
);
if ($intReturn5 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
$intReturn6 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn6 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$strChbFields = 'HNE,SNE,RSI,CSC,RNS,TPL,SEC,HOC,COG';
$myContentClass->addFormInit($conttp, $strChbFields);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
$conttp->setVariable('DISABLE_SAVE', 'disabled');
}
if ($intVersion == 4) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1e,chbGr1f');
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2f,chbGr2g');
}
if ($intVersion == 3) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1e,chbGr1f');
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2f,chbGr2g');
}
if ($intVersion < 3) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1f');
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2g');
$conttp->setVariable('VERSION_20_VALUE_MUST', ',tfValue2');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo, $strChbFields);
// Process radio fields
$conttp->setVariable('DAT_HNE' .$arrModifyData['host_notifications_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_SNE' .$arrModifyData['service_notifications_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_RSI' .$arrModifyData['retain_status_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_CSC' .$arrModifyData['can_submit_commands']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_RNS' .$arrModifyData['retain_nonstatus_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_TPL' .$arrModifyData['use_template_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable(
'DAT_SEC' .$arrModifyData['service_notification_commands_tploptions']. '_CHECKED',
'checked'
);
$conttp->setVariable('DAT_HOC' .$arrModifyData['host_notification_commands_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_COG' .$arrModifyData['contactgroups_tploptions']. '_CHECKED', 'checked');
// Process option fields
foreach (explode(',', $arrModifyData['host_notification_options']) as $elem) {
$conttp->setVariable('DAT_HO' .strtoupper($elem). '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['service_notification_options']) as $elem) {
$conttp->setVariable('DAT_SO' .strtoupper($elem). '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Contact name')); $mastertp->setVariable('TITLE', translate('Define contacts (contacts.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Contact name'));
// Process search string $mastertp->setVariable('FIELD_2', translate('Description'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process search string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' OR $strSearchTxt = $_SESSION['search'][$preSearchSession];
`email` LIKE '%".$strSearchTxt."%' OR `pager` LIKE '%".$strSearchTxt."%' OR $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' OR "
`address1` LIKE '%".$strSearchTxt."%' OR `address2` LIKE '%".$strSearchTxt."%' OR . "`email` LIKE '%".$strSearchTxt."%' OR `pager` LIKE '%".$strSearchTxt."%' OR "
`address3` LIKE '%".$strSearchTxt."%' OR `address4` LIKE '%".$strSearchTxt."%' OR . "`address1` LIKE '%".$strSearchTxt."%' OR `address2` LIKE '%".$strSearchTxt."%' OR "
`address5` LIKE '%".$strSearchTxt."%' OR `address6` LIKE '%".$strSearchTxt."%' OR . "`address3` LIKE '%".$strSearchTxt."%' OR `address4` LIKE '%".$strSearchTxt."%' OR "
`name` LIKE '%".$strSearchTxt."%')"; . "`address5` LIKE '%".$strSearchTxt."%' OR `address6` LIKE '%".$strSearchTxt."%' OR "
} . "`name` LIKE '%".$strSearchTxt."%')";
// Row sorting }
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir"; $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
// Count datasets if ($hidSortBy == 2) {
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); }
if ($booReturn == false) { // Count datasets
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $strSQL7 = 'SELECT count(*) AS `number` '
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
} else { $booReturn7 = $myDBClass->hasSingleDataset($strSQL7, $arrDataLinesCount);
$intLineCount = (int)$arrDataLinesCount['number']; if ($booReturn7 == false) {
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
} $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
// Get datasets } else {
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `register`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere $intLineCount = (int)$arrDataLinesCount['number'];
AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; if ($intLineCount < $chkLimit) {
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); $chkLimit = 0;
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); }
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); // Get datasets
} $strSQL8 = "SELECT `id`, `$preKeyField`, `alias`, `active`, `register`, `config_id`, `access_group` "
// Process data . "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias'); . "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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,330 +5,504 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Contact template definitions // Component : Contact template definitions
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 17; $prePageId = 17;
$preContent = "admin/contacttemplates.tpl.htm"; $preContent = 'admin/contacttemplates.htm.tpl';
$preSearchSession = 'contacttemplate'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_contacttemplate'; $preSearchSession = 'contacttemplate';
$preKeyField = 'template_name'; $preTableName = 'tbl_contacttemplate';
$preAccess = 1; $preKeyField = 'template_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Checkbox data processing // Checkbox data processing
// ======================== // ========================
if ($intVersion == 3) { if (($intVersion == 3) || ($intVersion == 4)) {
$strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f,0,-1); $strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e.$chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f.$chkChbGr2g,0,-1); $strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2f.$chkChbGr2g, 0, -1);
} else { } else {
$strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1f,0,-1); $strHO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1f, 0, -1);
$strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2g,0,-1); $strSO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e.$chkChbGr2g, 0, -1);
} }
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `contactgroups`=$intMselValue1, `contactgroups_tploptions`=$chkRadValue1, $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', "
`host_notifications_enabled`='$chkRadValue2', `service_notifications_enabled`='$chkRadValue3', `host_notification_period`='$chkSelValue1', . "`contactgroups`=$intMselValue1, `contactgroups_tploptions`=$chkRadValue1, "
`service_notification_period`='$chkSelValue2', `host_notification_options`='$strHO', `host_notification_commands_tploptions`=$chkRadValue4, . "`minimum_importance`=$chkTfNullVal1, "
`service_notification_options`='$strSO', `host_notification_commands`=$intMselValue2, `service_notification_commands`=$intMselValue3, . "`host_notifications_enabled`='$chkRadValue2', `service_notifications_enabled`='$chkRadValue3', "
`service_notification_commands_tploptions`=$chkRadValue5, `can_submit_commands`='$chkRadValue8', `retain_status_information`='$chkRadValue6', . "`host_notification_period`='$chkSelValue1', `service_notification_period`='$chkSelValue2', "
`retain_nonstatus_information`='$chkRadValue7', `email`='$chkTfValue3', `pager`='$chkTfValue4', `address1`='$chkTfValue5', `address2`='$chkTfValue6', . "`host_notification_options`='$strHO', `host_notification_commands_tploptions`=$chkRadValue4, "
`address3`='$chkTfValue7', `address4`='$chkTfValue8', `address5`='$chkTfValue9', `address6`='$chkTfValue10', . "`service_notification_options`='$strSO', `host_notification_commands`=$intMselValue2, "
`use_variables`='$intVariables', `use_template`=$intTemplates, $preSQLCommon2"; . "`service_notification_commands`=$intMselValue3, "
if ($chkModus == "insert") { . "`service_notification_commands_tploptions`=$chkRadValue5, `can_submit_commands`='$chkRadValue8', "
$strSQL = "INSERT INTO ".$strSQLx; . "`retain_status_information`='$chkRadValue6', `retain_nonstatus_information`='$chkRadValue7', "
} else { . "`email`='$chkTfValue3', `pager`='$chkTfValue4', `address1`='$chkTfValue5', `address2`='$chkTfValue6', "
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; . "`address3`='$chkTfValue7', `address4`='$chkTfValue8', `address5`='$chkTfValue9', "
} . "`address6`='$chkTfValue10', `use_variables`='$intVariables', `use_template`=$intTemplates, "
if ($intWriteAccessId == 0) { . $preSQLCommon2;
if ($chkTfValue1 != "") { if ($chkModus == 'insert') {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $strSQL = 'INSERT INTO ' .$strSQLx;
if ($chkModus == "insert") $chkDataId = $intInsertId; } else {
if ($intReturn == 1) { $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} else { if ($intWriteAccessId == 0) {
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($chkTfValue1 != '') {
$myDataClass->updateStatusTable($preTableName); $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == "insert") $myDataClass->writeLog(translate('New contact template inserted:')." ".$chkTfValue1); if ($chkModus == 'insert') {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Contact template modified:')." ".$chkTfValue1); $chkDataId = $intInsertId;
// }
// Insert/update relations if ($intReturn == 1) {
// ======================= $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "insert") { } else {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkContacttemplateToContactgroup",$chkDataId,$chkMselValue1); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myDataClass->updateStatusTable($preTableName);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkContacttemplateToCommandHost",$chkDataId,$chkMselValue2); if ($chkModus == 'insert') {
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myDataClass->writeLog(translate('New contact template inserted:'). ' ' .$chkTfValue1);
if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkContacttemplateToCommandService",$chkDataId,$chkMselValue3); }
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($chkModus == 'modify') {
} else if ($chkModus == "modify") { $myDataClass->writeLog(translate('Contact template modified:'). ' ' .$chkTfValue1);
if ($intMselValue1 != 0) { }
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkContacttemplateToContactgroup",$chkDataId,$chkMselValue1); //
} else { // Insert/update relations
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkContacttemplateToContactgroup",$chkDataId); // =======================
} if ($chkModus == 'insert') {
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($intMselValue1 != 0) {
if ($intMselValue2 != 0) { $intRet1 = $myDataClass->dataInsertRelation(
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkContacttemplateToCommandHost",$chkDataId,$chkMselValue2); 'tbl_lnkContacttemplateToContactgroup',
} else { $chkDataId,
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkContacttemplateToCommandHost",$chkDataId); $chkMselValue1
} );
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
if ($intMselValue3 != 0) { if (isset($intRet1) && ($intRet1 != 0)) {
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkContacttemplateToCommandService",$chkDataId,$chkMselValue3); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else { }
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkContacttemplateToCommandService",$chkDataId); if ($intMselValue2 != 0) {
} $intRet2 = $myDataClass->dataInsertRelation(
if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); 'tbl_lnkContacttemplateToCommandHost',
} $chkDataId,
if (($intRet1 + $intRet2 + $intRet3) != 0) $strInfoMessage = ""; $chkMselValue2
// );
// Insert/update templates from session data }
// ========================================= if (isset($intRet2) && ($intRet2 != 0)) {
if ($chkModus == "modify") { $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$strSQL = "DELETE FROM `tbl_lnkContacttemplateToContacttemplate` WHERE `idMaster`=$chkDataId"; }
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if ($intMselValue3 != 0) {
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $intRet3 = $myDataClass->dataInsertRelation(
} 'tbl_lnkContacttemplateToCommandService',
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) && (count($_SESSION['templatedefinition']) != 0)) { $chkDataId,
$intSortId = 1; $chkMselValue3
foreach($_SESSION['templatedefinition'] AS $elem) { );
if ($elem['status'] == 0) { }
$strSQL = "INSERT INTO `tbl_lnkContacttemplateToContacttemplate` (`idMaster`,`idSlave`,`idTable`,`idSort`) if (isset($intRet3) && ($intRet3 != 0)) {
VALUES ($chkDataId,".$elem['idSlave'].",".$elem['idTable'].",".$intSortId.")"; $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); }
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); } elseif ($chkModus == 'modify') {
} if ($intMselValue1 != 0) {
$intSortId++; $intRet1 = $myDataClass->dataUpdateRelation(
} 'tbl_lnkContacttemplateToContactgroup',
} $chkDataId,
// $chkMselValue1
// Insert/update variables from session data );
// ========================================= } else {
if ($chkModus == "modify") { $intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkContacttemplateToContactgroup', $chkDataId);
$strSQL = "SELECT * FROM `tbl_lnkContacttemplateToVariabledefinition` WHERE `idMaster`=$chkDataId"; }
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); if ($intRet1 != 0) {
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($intDataCount != 0) { }
foreach ($arrData AS $elem) { if ($intMselValue2 != 0) {
$strSQL = "DELETE FROM `tbl_variabledefinition` WHERE `id`=".$elem['idSlave']; $intRet2 = $myDataClass->dataUpdateRelation(
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); 'tbl_lnkContacttemplateToCommandHost',
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId,
} $chkMselValue2
} );
$strSQL = "DELETE FROM `tbl_lnkContacttemplateToVariabledefinition` WHERE `idMaster`=$chkDataId"; } else {
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkContacttemplateToCommandHost', $chkDataId);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} if ($intRet2 != 0) {
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) && (count($_SESSION['variabledefinition']) != 0)) { $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
foreach($_SESSION['variabledefinition'] AS $elem) { }
if ($elem['status'] == 0) { if ($intMselValue3 != 0) {
$strSQL = "INSERT INTO `tbl_variabledefinition` (`name`,`value`,`last_modified`) $intRet3 = $myDataClass->dataUpdateRelation(
VALUES ('".$elem['definition']."','".$elem['range']."',now())"; 'tbl_lnkContacttemplateToCommandService',
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $chkDataId,
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkMselValue3
$strSQL = "INSERT INTO `tbl_lnkContacttemplateToVariabledefinition` (`idMaster`,`idSlave`) );
VALUES ($chkDataId,$intInsertId)"; } else {
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $intRet3 = $myDataClass->dataDeleteRelation(
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); 'tbl_lnkContacttemplateToCommandService',
} $chkDataId
} );
} }
} if ($intRet3 != 0) {
} else { $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); }
} }
} else { //if (($intRet1 + $intRet2 + $intRet3) != 0) {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); //$strInfoMessage = "";
} //}
$chkModus = "display"; //
// 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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate("Define contact templates (contacttemplates.cfg)"));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Define contact templates (contacttemplates.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Process template selection fields (Spezial) $intNoTime = 1;
$strWhere = ""; // Process template selection fields (Spezial)
if (isset($arrModifyData) && ($chkSelModify == "modify")) { $strWhere = '';
$strWhere = "AND `id` <> ".$arrModifyData['id']; 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); $strSQL1 = "SELECT `id`,`$preKeyField`, `active` FROM `$preTableName` "
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "WHERE $strDomainWhere $strWhere ORDER BY `$preKeyField`";
if ($intDataCountTpl != 0) { $booReturn1 = $myDBClass->hasDataArray($strSQL1, $arrDataTpl, $intDataCountTpl);
foreach ($arrDataTpl AS $elem) { if ($booReturn1 == false) {
if ($elem['active'] == 0) { $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$strActive = " [inactive]"; }
$conttp->setVariable("SPECIAL_STYLE","inactive_option"); if ($intDataCountTpl != 0) {
} else { /** @var array $arrDataTpl */
$strActive = ""; foreach ($arrDataTpl as $elem) {
$conttp->setVariable("SPECIAL_STYLE",""); if ($elem['active'] == 0) {
} $strActive = ' [inactive]';
$conttp->setVariable("DAT_TEMPLATE",htmlspecialchars($elem[$preKeyField],ENT_QUOTES,'UTF-8').$strActive); $conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
$conttp->setVariable("DAT_TEMPLATE_ID",$elem['id']."::1"); } else {
$conttp->parse("template"); $strActive = '';
} $conttp->setVariable('SPECIAL_STYLE', '');
} }
$strSQL = "SELECT `id`, `name`, `active` FROM `tbl_contact` WHERE `name` <> '' AND $strDomainWhere2 ORDER BY name"; $conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem[$preKeyField], ENT_QUOTES, 'UTF-8').$strActive);
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataHpl,$intDataCount); $conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::1');
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $conttp->parse('template');
if ($arrDataHpl != 0) { }
foreach ($arrDataHpl AS $elem) { }
if ($elem['active'] == 0) { $strSQL2 = 'SELECT `id`, `name`, `active` FROM `tbl_contact` '
$strActive = " [inactive]"; . "WHERE `name` <> '' AND $strDomainWhere2 ORDER BY name";
$conttp->setVariable("SPECIAL_STYLE","inactive_option"); $booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataHpl, $intDataCountHpl);
} else { if ($booReturn2 == false) {
$strActive = ""; $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$conttp->setVariable("SPECIAL_STYLE",""); }
} if ($intDataCountHpl != 0) {
$conttp->setVariable("DAT_TEMPLATE",htmlspecialchars($elem['name'],ENT_QUOTES,'UTF-8').$strActive); /** @var array $arrDataHpl */
$conttp->setVariable("DAT_TEMPLATE_ID",$elem['id']."::2"); foreach ($arrDataHpl as $elem) {
$conttp->parse("template"); if ($elem['active'] == 0) {
} $strActive = ' [inactive]';
} $conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
// Process timeperiod selection fields } else {
$intReturn = 0; $strActive = '';
if (isset($arrModifyData['host_notification_period'])) {$intFieldId = $arrModifyData['host_notification_period'];} else {$intFieldId = 0;} $conttp->setVariable('SPECIAL_STYLE', '');
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','host_time',1,$intFieldId); }
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['name'], ENT_QUOTES, 'UTF-8').$strActive);
if (isset($arrModifyData['service_notification_period'])) {$intFieldId = $arrModifyData['service_notification_period'];} else {$intFieldId = 0;} $conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::2');
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','service_time',1,$intFieldId); $conttp->parse('template');
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;} // Process timeperiod selection fields
$intReturn = $myVisClass->parseSelectMulti('tbl_command','command_name','host_command','tbl_lnkContacttemplateToCommandHost',0,$intFieldId); if (isset($arrModifyData['host_notification_period'])) {
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId = $arrModifyData['host_notification_period'];
if (isset($arrModifyData['service_notification_commands'])) {$intFieldId = $arrModifyData['service_notification_commands'];} else {$intFieldId = 0;} } else {
$intReturn = $myVisClass->parseSelectMulti('tbl_command','command_name','service_command','tbl_lnkContacttemplateToCommandService',0,$intFieldId); $intFieldId = 0;
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Process contactgroup selection field $intReturn1 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'host_time', 1, $intFieldId);
if (isset($arrModifyData['contactgroups'])) {$intFieldId = $arrModifyData['contactgroups'];} else {$intFieldId = 0;} if ($intReturn1 != 0) {
$intReturn = $myVisClass->parseSelectMulti('tbl_contactgroup','contactgroup_name','contactgroup','tbl_lnkContacttemplateToContactgroup',2,$intFieldId); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Process acces group selection field if (isset($arrModifyData['service_notification_period'])) {
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} $intFieldId = $arrModifyData['service_notification_period'];
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); } else {
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId = 0;
// Initial add/modify form definitions }
$strChbFields = "HNE,SNE,RSI,CSC,RNS,TPL,SEC,HOC,COG"; $intReturn2 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'service_time', 1, $intFieldId);
$myContentClass->addFormInit($conttp,$strChbFields); if ($intReturn2 != 0) {
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
if ($intVersion == 3) { }
$conttp->setVariable("HOST_OPTION_FIELDS","chbHOd3,chbHOu3,chbHOr3,chbHOf3,chbHOs3,chbHOn3"); // Process command selection fields
$conttp->setVariable("SERVICE_OPTION_FIELDS","chbSOw3,chbSOu3,chbSOc3,chbSOr3,chbSOf3,chbSOs3,chbSOn3"); if (isset($arrModifyData['host_notification_commands'])) {
} else { $intFieldId = $arrModifyData['host_notification_commands'];
$conttp->setVariable("HOST_OPTION_FIELDS","chbHOd2,chbHOu2,chbHOr2,chbHOf2,chbHOn2"); } else {
$conttp->setVariable("SERVICE_OPTION_FIELDS","chbSOw2,chbSOu2,chbSOc2,chbSOr2,chbSOf2,chbSOn2"); $intFieldId = 0;
$conttp->setVariable("VERSION_20_VALUE_MUST",",tfFriendly"); }
} $intReturn3 = $myVisClass->parseSelectMulti(
// Insert data from database in "modify" mode 'tbl_command',
if (isset($arrModifyData) && ($chkSelModify == "modify")) { 'command_name',
// Check relation information to find out locked configuration datasets 'host_command',
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); 'tbl_lnkContacttemplateToCommandHost',
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); 0,
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; $intFieldId
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; );
// Process data if ($intReturn3 != 0) {
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo,$strChbFields); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
// Process radio fields }
$conttp->setVariable("DAT_HNE".$arrModifyData['host_notifications_enabled']."_CHECKED","checked"); if (isset($arrModifyData['service_notification_commands'])) {
$conttp->setVariable("DAT_SNE".$arrModifyData['service_notifications_enabled']."_CHECKED","checked"); $intFieldId = $arrModifyData['service_notification_commands'];
$conttp->setVariable("DAT_RSI".$arrModifyData['retain_status_information']."_CHECKED","checked"); } else {
$conttp->setVariable("DAT_CSC".$arrModifyData['can_submit_commands']."_CHECKED","checked"); $intFieldId = 0;
$conttp->setVariable("DAT_RNS".$arrModifyData['retain_nonstatus_information']."_CHECKED","checked"); }
$conttp->setVariable("DAT_TPL".$arrModifyData['use_template_tploptions']."_CHECKED","checked"); $intReturn4 = $myVisClass->parseSelectMulti(
$conttp->setVariable("DAT_SEC".$arrModifyData['service_notification_commands_tploptions']."_CHECKED","checked"); 'tbl_command',
$conttp->setVariable("DAT_HOC".$arrModifyData['host_notification_commands_tploptions']."_CHECKED","checked"); 'command_name',
$conttp->setVariable("DAT_COG".$arrModifyData['contactgroups_tploptions']."_CHECKED","checked"); 'service_command',
// Process option fields 'tbl_lnkContacttemplateToCommandService',
foreach(explode(",",$arrModifyData['host_notification_options']) AS $elem) { 0,
$conttp->setVariable("DAT_HO".strtoupper($elem)."_CHECKED","checked"); $intFieldId
} );
foreach(explode(",",$arrModifyData['service_notification_options']) AS $elem) { if ($intReturn4 != 0) {
$conttp->setVariable("DAT_SO".strtoupper($elem)."_CHECKED","checked"); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
} }
} // Process contactgroup selection field
$conttp->parse("datainsert"); if (isset($arrModifyData['contactgroups'])) {
$conttp->show("datainsert"); $intFieldId = $arrModifyData['contactgroups'];
} else {
$intFieldId = 0;
}
$intReturn5 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
'contactgroup',
'tbl_lnkContacttemplateToContactgroup',
2,
$intFieldId
);
if ($intReturn5 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
$intReturn6 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn6 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$strChbFields = 'HNE,SNE,RSI,CSC,RNS,TPL,SEC,HOC,COG';
$myContentClass->addFormInit($conttp, $strChbFields);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
if ($intVersion == 4) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1e,chbGr1f');
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2f,chbGr2g');
}
if ($intVersion == 3) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1e,chbGr1f');
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2f,chbGr2g');
}
if ($intVersion < 3) {
$conttp->setVariable('HOST_OPTION_FIELDS', 'chbGr1a,chbGr1b,chbGr1c,chbGr1d,chbGr1f');
$conttp->setVariable('SERVICE_OPTION_FIELDS', 'chbGr2a,chbGr2b,chbGr2c,chbGr2d,chbGr2e,chbGr2g');
$conttp->setVariable('VERSION_20_VALUE_MUST', ',tfValue2');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo, $strChbFields);
// Process radio fields
$conttp->setVariable('DAT_HNE' .$arrModifyData['host_notifications_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_SNE' .$arrModifyData['service_notifications_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_RSI' .$arrModifyData['retain_status_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_CSC' .$arrModifyData['can_submit_commands']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_RNS' .$arrModifyData['retain_nonstatus_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_TPL' .$arrModifyData['use_template_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable(
'DAT_SEC' .$arrModifyData['service_notification_commands_tploptions']. '_CHECKED',
'checked'
);
$conttp->setVariable('DAT_HOC' .$arrModifyData['host_notification_commands_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_COG' .$arrModifyData['contactgroups_tploptions']. '_CHECKED', 'checked');
// Process option fields
foreach (explode(',', $arrModifyData['host_notification_options']) as $elem) {
$conttp->setVariable('DAT_HO' .strtoupper($elem). '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['service_notification_options']) as $elem) {
$conttp->setVariable('DAT_SO' .strtoupper($elem). '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Contact name')); $mastertp->setVariable('TITLE', translate('Define contact templates (contacttemplates.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Contact name'));
// Process filter string $mastertp->setVariable('FIELD_2', translate('Description'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process filter string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' OR $strSearchTxt = $_SESSION['search'][$preSearchSession];
`email` LIKE '%".$strSearchTxt."%' OR `pager` LIKE '%".$strSearchTxt."%' OR $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' OR "
`address1` LIKE '%".$strSearchTxt."%' OR `address2` LIKE '%".$strSearchTxt."%' OR . "`email` LIKE '%".$strSearchTxt."%' OR `pager` LIKE '%".$strSearchTxt."%' OR "
`address3` LIKE '%".$strSearchTxt."%' OR `address4` LIKE '%".$strSearchTxt."%' OR . "`address1` LIKE '%".$strSearchTxt."%' OR `address2` LIKE '%".$strSearchTxt."%' OR "
`address5` LIKE '%".$strSearchTxt."%' OR `address6` LIKE '%".$strSearchTxt."%')"; . "`address3` LIKE '%".$strSearchTxt."%' OR `address4` LIKE '%".$strSearchTxt."%' OR "
. "`address5` LIKE '%".$strSearchTxt."%' OR `address6` LIKE '%".$strSearchTxt."%')";
} }
// Row sorting // Row sorting
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir"; if ($hidSortBy == 2) {
// Count datasets $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; }
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); // Count datasets
if ($booReturn == false) { $strSQL = 'SELECT count(*) AS `number` '
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); . "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
} else { if ($booReturn1 == false) {
$intLineCount = (int)$arrDataLinesCount['number']; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} } else {
// Get datasets $intLineCount = (int)$arrDataLinesCount['number'];
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `register`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere if ($intLineCount < $chkLimit) {
AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; $chkLimit = 0;
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); }
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); // Get datasets
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `register`, `config_id`, `access_group` "
} . "FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) "
// Process data . "$strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias'); $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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,156 +5,183 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin domain administration // Component : Admin domain administration
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 35; $prePageId = 35;
$preContent = "admin/datadomain.tpl.htm"; $preContent = 'admin/datadomain.htm.tpl';
$preTableName = 'tbl_datadomain'; $preListTpl = 'admin/datalist_common.htm.tpl';
$preKeyField = 'domain'; $preTableName = 'tbl_datadomain';
$preAccess = 1; $preKeyField = 'domain';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
if ($chkTfValue1 == 'common') $chkSelValue1 = 0; if ($chkTfValue1 == 'common') {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `targets`=$chkSelValue1, `version`=$chkSelValue2, $chkSelValue1 = 0;
`access_group`=$chkSelAccGr, `enable_common`=$chkSelValue3, `active`='$chkActive', }
`last_modified`=NOW()"; $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `targets`=$chkSelValue1, "
if ($chkModus == "insert") { . "`version`=$chkSelValue2, `access_group`=$chkSelAccGr, `enable_common`=$chkSelValue3, "
$strSQL = "INSERT INTO ".$strSQLx; . "`active`='$chkActive', `last_modified`=NOW()";
} else { if ($chkModus == 'insert') {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; $strSQL = 'INSERT INTO ' .$strSQLx;
} } else {
if ($intWriteAccessId == 0) { $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if (($chkTfValue1 != "") && ($chkTfValue2 != "") && (($chkTfValue1 == 'common') || ($chkSelValue1 != 0))) { }
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if ($intWriteAccessId == 0) {
if ($chkModus == "insert") $chkDataId = $intInsertId; if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($chkTfValue1 == 'common') || ($chkSelValue1 != 0))) {
if ($intReturn == 1) { $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($chkModus == 'insert') {
} else { $chkDataId = $intInsertId;
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); }
if ($chkModus == "insert") $myDataClass->writeLog(translate('New Domain inserted:')." ".$chkTfValue1); if ($intReturn == 1) {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Domain modified:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} } else {
} else { $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); if ($chkModus == 'insert') {
} $myDataClass->writeLog(translate('New Domain inserted:'). ' ' .$chkTfValue1);
} else { }
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); if ($chkModus == 'modify') {
} $myDataClass->writeLog(translate('Domain modified:'). ' ' .$chkTfValue1);
$chkModus = "display"; }
}
} 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 // Single view
// =========== // ===========
if ($chkModus == "add") { if ($chkModus == 'add') {
// Process configuration target selection fields // Process configuration target selection fields
$intReturn = 0;
if (isset($arrModifyData['targets'])) {$intFieldId = $arrModifyData['targets'];} else {$intFieldId = 0;} if (isset($arrModifyData['targets'])) {
$intReturn = $myVisClass->parseSelectSimple('tbl_configtarget','target','target',0,$intFieldId); $intFieldId = $arrModifyData['targets'];
if ($intReturn != 0) { } else {
$myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId = 0;
$myVisClass->processMessage(translate('Attention, no configuration targets defined!'),$strDBWarning); }
$intDataWarning = 1; $intReturn1 = $myVisClass->parseSelectSimple('tbl_configtarget', 'target', 'target', 0, $intFieldId);
} if ($intReturn1 != 0) {
// Process acces group selection field $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} $myVisClass->processMessage(translate('Attention, no configuration targets defined!'), $strDBWarning);
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); $intDataWarning = 1;
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Initial add/modify form definitions // Process acces group selection field
$myContentClass->addFormInit($conttp); if (isset($arrModifyData['access_group'])) {
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); $intFieldId = $arrModifyData['access_group'];
$conttp->setVariable("FILL_ALLFIELDS",translate('Please fill in all fields marked with an *')); } else {
$conttp->setVariable("FILL_ILLEGALCHARS",translate('The following field contains not permitted characters:')); $intFieldId = 0;
$conttp->setVariable("ENABLE",translate('Enable')); }
$conttp->setVariable("DISABLE",translate('Disable')); $intReturn2 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
// Insert data from database in "modify" mode if ($intReturn2 != 0) {
if (isset($arrModifyData) && ($chkSelModify == "modify")) { $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
// Process data }
$myContentClass->addInsertData($conttp,$arrModifyData,0,''); // Initial add/modify form definitions
// Nagios version $myContentClass->addFormInit($conttp);
if ($arrModifyData['version'] == 1) $conttp->setVariable("VER_SELECTED_1","selected"); if ($intDataWarning == 1) {
if ($arrModifyData['version'] == 2) $conttp->setVariable("VER_SELECTED_2","selected"); $conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
if ($arrModifyData['version'] == 3) $conttp->setVariable("VER_SELECTED_3","selected"); }
// Enable common domain $conttp->setVariable('TITLE', translate('Data domain administration'));
if ($arrModifyData['enable_common'] == 0) $conttp->setVariable("ENA_COMMON_SELECTED_0","selected"); $conttp->setVariable('FILL_ALLFIELDS', translate('Please fill in all fields marked with an *'));
if ($arrModifyData['enable_common'] == 1) $conttp->setVariable("ENA_COMMON_SELECTED_1","selected"); $conttp->setVariable('FILL_ILLEGALCHARS', translate('The following field contains illegal characters:'));
// Domain localhost cant' be renamed $conttp->setVariable('ENABLE', translate('Enable'));
if ($arrModifyData['domain'] == "localhost") { $conttp->setVariable('DISABLE', translate('Disable'));
$conttp->setVariable("DOMAIN_DISABLE","readonly"); // Insert data from database in "modify" mode
$conttp->setVariable("LOCKCLASS","inputlock"); if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
} else if ($arrModifyData['domain'] == "common") { // Process data
$conttp->setVariable("DOMAIN_DISABLE","readonly"); $myContentClass->addInsertData($conttp, $arrModifyData, 0, '');
$conttp->setVariable("COMMON_INVISIBLE","class=\"elementHide\""); // Nagios version
$conttp->setVariable("LOCKCLASS","inputlock"); $conttp->setVariable('VER_SELECTED_' .$arrModifyData['version'], 'selected');
} else { // Enable common domain
$conttp->setVariable("CHECK_TARGETS",",selValue1"); $conttp->setVariable('ENA_COMMON_SELECTED_' .$arrModifyData['enable_common'], 'selected');
} // Domain localhost cant' be renamed
} if ($arrModifyData['domain'] == 'localhost') {
$conttp->parse("datainsert"); $conttp->setVariable('DOMAIN_DISABLE', 'readonly');
$conttp->show("datainsert"); $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 // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Data domain')); $mastertp->setVariable('TITLE', translate('Data domain administration'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Data domain'));
// Row sorting $mastertp->setVariable('FIELD_2', translate('Description'));
$strOrderString = "ORDER BY `domain` $hidSortDir"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `alias` $hidSortDir"; $strOrderString = "ORDER BY `domain` $hidSortDir";
// Count datasets if ($hidSortBy == 2) {
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)"; $strOrderString = "ORDER BY `alias` $hidSortDir";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); }
if ($booReturn == false) { // Count datasets
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE `access_group` IN ($strAccess)";
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
} else { if ($booReturn1 == false) {
$intLineCount = (int)$arrDataLinesCount['number']; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} } else {
// Get datasets $intLineCount = (int)$arrDataLinesCount['number'];
$strSQL = "SELECT `id`, `domain`, `alias`, `active`, `nodelete`, `access_group` FROM `$preTableName` WHERE `access_group` IN ($strAccess) if ($intLineCount < $chkLimit) {
$strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; $chkLimit = 0;
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); }
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); // Get datasets
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $strSQL = 'SELECT `id`, `domain`, `alias`, `active`, `nodelete`, `access_group` '
} . "FROM `$preTableName` WHERE `access_group` IN ($strAccess) $strOrderString "
// Process data . "LIMIT $chkLimit,".$SETS['common']['pagelines'];
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias'); $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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1); $myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,145 +5,176 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin file deletion // Component : Admin file deletion
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 26; $prePageId = 26;
$preContent = "admin/delbackup.tpl.htm"; $preContent = 'admin/delbackup.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Get configuration set ID // Get configuration set ID
// ======================== // ========================
$arrConfigSet = $myConfigClass->getConfigSets(); $myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0]; $intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigData($intConfigId,"method",$intMethod); $myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$myConfigClass->getConfigData($intConfigId,"backupdir",$strBackupDir); $myConfigClass->getConfigValues($intConfigId, 'backupdir', $strBackupDir);
$myConfigClass->getConfigData($intConfigId,"hostbackup",$strHostBackupDir); $myConfigClass->getConfigValues($intConfigId, 'hostbackup', $strHostBackupDir);
$myConfigClass->getConfigData($intConfigId,"servicebackup",$strServiceBackupDir); $myConfigClass->getConfigValues($intConfigId, 'servicebackup', $strServiceBackupDir);
// //
// Process form inputs // Process form inputs
// =================== // ===================
if (($chkMselValue1[0] != "") && ($chkStatus == 1)) { if (($chkMselValue1[0] != '') && ($chkStatus == 1)) {
foreach($chkMselValue1 AS $elem) { /** @var array $chkMselValue1 */
$intCheck = $myConfigClass->removeFile(trim($elem),$intConfigId); foreach ($chkMselValue1 as $elem) {
$strFile = str_replace($strServiceBackupDir,"",$elem); $intCheck = $myConfigClass->removeFile(trim($elem), $intConfigId);
$strFile = str_replace($strHostBackupDir,"",$strFile); $strFileTmp1 = str_replace($strServiceBackupDir, '', $elem);
$strFile = str_replace($strBackupDir,"",$strFile); $strFileTmp2 = str_replace($strHostBackupDir, '', $strFileTmp1);
if ($intCheck == 0) { $strFile = str_replace($strBackupDir, '', $strFileTmp2);
$myDataClass->writeLog(translate("File deleted").": ".trim($strFile)); if ($intCheck == 0) {
$myVisClass->processMessage($strFile." ".translate("successfully deleted")."!",$strInfoMessage); $myDataClass->writeLog(translate('File deleted'). ': ' .trim($strFile));
} else { $myVisClass->processMessage($strFile. ' ' .translate('successfully deleted'). '!', $strInfoMessage);
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); } else {
} $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} }
}
} }
// //
// Include content // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate("Delete backup files")); $conttp->setVariable('TITLE', translate('Delete backup files'));
$conttp->parse("header"); $conttp->parse('header');
$conttp->show("header"); $conttp->show('header');
$conttp->setVariable("LANG_SEARCH_STRING",translate('Filter string')); $conttp->setVariable('LANG_SEARCH_STRING', translate('Filter string'));
$conttp->setVariable("LANG_SEARCH",translate('Search')); $conttp->setVariable('LANG_SEARCH', translate('Search'));
$conttp->setVariable("LANG_DELETE",translate('Delete')); $conttp->setVariable('LANG_DELETE', translate('Delete'));
$conttp->setVariable("LANG_DELETE_SEARCH",translate("Reset filter")); $conttp->setVariable('LANG_DELETE_SEARCH', translate('Reset filter'));
$conttp->setVariable("DAT_SEARCH",$chkTfSearch); $conttp->setVariable('DAT_SEARCH', $chkTfSearch);
$conttp->setVariable("BACKUPFILE",translate("Backup file")); $conttp->setVariable('BACKUPFILE', translate('Backup file'));
$conttp->setVariable("LANG_REQUIRED",translate("required")); $conttp->setVariable('LANG_REQUIRED', translate('required'));
$conttp->setVariable("MAKE",translate("Delete")); $conttp->setVariable('MAKE', translate('Delete'));
$conttp->setVariable("ABORT",translate("Abort")); $conttp->setVariable('ABORT', translate('Abort'));
$conttp->setVariable("CTRL_INFO",translate("Hold CTRL to select<br>more than one entry")); $conttp->setVariable('CTRL_INFO', translate('Hold CTRL to select<br>more than one entry'));
$conttp->setVariable("IMAGE_PATH",$_SESSION['SETS']['path']['base_url']."images/"); $conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)); $conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
// Build a local file list // Build a local file list
if ($intMethod == 1) { if ($intMethod == 1) {
$output = array(); $output = array();
$temp=$myConfigClass->DirToArray($strBackupDir, "\.cfg_", "",$output,$strErrorMessage); $myConfigClass->storeDirToArray($strBackupDir, "\.cfg_old", '', $output, $strErrorMessage);
if (is_array($output) && (count($output) != 0)) { if (is_array($output) && (count($output) != 0)) {
foreach ($output AS $elem) { foreach ($output as $elem) {
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) { if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
$conttp->setVariable("DAT_BACKUPFILE",$elem); $conttp->setVariable('DAT_BACKUPFILE', $elem);
$conttp->parse("filelist"); $conttp->parse('filelist');
} }
} }
} }
} else if ($intMethod == 2) { } elseif ($intMethod == 2) {
// Set up basic connection // Set up basic connection
if ($myConfigClass->getFTPConnection($intConfigId) == "0") { if ($myConfigClass->getFTPConnection($intConfigId) == '0') {
$arrFiles = array(); $arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId,$strBackupDir); $arrFiles1 = ftp_nlist($myConfigClass->resConnectId, $strBackupDir);
if (is_array($arrFiles1)) $arrFiles = array_merge($arrFiles,$arrFiles1); if (is_array($arrFiles1)) {
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId,$strHostBackupDir); $arrFiles = array_merge($arrFiles, $arrFiles1);
if (is_array($arrFiles2)) $arrFiles = array_merge($arrFiles,$arrFiles2); }
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId,$strServiceBackupDir); $arrFiles2 = ftp_nlist($myConfigClass->resConnectId, $strHostBackupDir);
if (is_array($arrFiles1)) $arrFiles = array_merge($arrFiles,$arrFiles1); if (is_array($arrFiles2)) {
if (is_array($arrFiles) && (count($arrFiles) != 0)) { $arrFiles = array_merge($arrFiles, $arrFiles2);
foreach ($arrFiles AS $elem) { }
if (!substr_count($elem,"cfg")) continue; $arrFiles3 = ftp_nlist($myConfigClass->resConnectId, $strServiceBackupDir);
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) { if (is_array($arrFiles3)) {
$conttp->setVariable("DAT_BACKUPFILE",$elem); $arrFiles = array_merge($arrFiles, $arrFiles3);
$conttp->parse("filelist"); }
} if (is_array($arrFiles) && (count($arrFiles) != 0)) {
} foreach ($arrFiles as $elem) {
} else { if (!substr_count($elem, 'cfg')) {
$myVisClass->processMessage(translate("No backup files or no permission to read the backup files"),$strErrorMessage); continue;
} }
ftp_close($myConfigClass->resConnectId); if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
} else { $conttp->setVariable('DAT_BACKUPFILE', $elem);
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); $conttp->parse('filelist');
} }
} else if ($intMethod == 3) { }
// Set up basic connection } else {
if ($myConfigClass->getSSHConnection($intConfigId) == "0") { $myVisClass->processMessage(
$arrFiles = array(); translate('No backup files or no permission to read the backup files'),
$arrFiles1 = $myConfigClass->sendSSHCommand("ls ".$strBackupDir."*.cfg_old*"); $strErrorMessage
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); ftp_close($myConfigClass->resConnectId);
$arrFiles3 = $myConfigClass->sendSSHCommand("ls ".$strServiceBackupDir."*.cfg_old*"); } else {
if (is_array($arrFiles3)) $arrFiles = array_merge($arrFiles,$arrFiles3); $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
if (is_array($arrFiles) && (count($arrFiles) != 0)) { }
foreach ($arrFiles AS $elem) { } elseif ($intMethod == 3) {
if (!substr_count($elem,"cfg_old")) continue; // Set up basic connection
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) { if ($myConfigClass->getSSHConnection($intConfigId) == '0') {
$conttp->setVariable("DAT_BACKUPFILE",str_replace("//","/",$elem)); $arrFiles = array();
$conttp->parse("filelist"); $intReturn = $myConfigClass->sendSSHCommand('ls ' .$strBackupDir. '*.cfg_old*', $arrFiles1);
} if (($intReturn == 0) && is_array($arrFiles1)) {
} $arrFiles = array_merge($arrFiles, $arrFiles1);
} else { }
$myVisClass->processMessage(translate("No backup files or no permission to read the backup files"),$strErrorMessage); $intReturn = $myConfigClass->sendSSHCommand('ls ' .$strHostBackupDir. '*.cfg_old*', $arrFiles2);
} if (($intReturn == 0) && is_array($arrFiles2)) {
} else { $arrFiles = array_merge($arrFiles, $arrFiles2);
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); }
} $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); if ($strErrorMessage != '') {
$conttp->setVariable("INFOMESSAGE",$strInfoMessage); $conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// Check access rights for adding new objects // Check access rights for adding new objects
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\""); if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->parse("main"); $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
$conttp->show("main"); }
$conttp->parse('main');
$conttp->show('main');
// //
// Footer ausgeben // Footer ausgeben
// =============== // ===============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,160 +5,187 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin file deletion // Component : Admin file deletion
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 27; $prePageId = 27;
$preContent = "admin/delbackup.tpl.htm"; $preContent = 'admin/delbackup.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Get configuration set ID // Get configuration set ID
// ======================== // ========================
$arrConfigSet = $myConfigClass->getConfigSets(); $myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0]; $intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigData($intConfigId,"method",$intMethod); $myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$myConfigClass->getConfigData($intConfigId,"basedir",$strBaseDir); $myConfigClass->getConfigValues($intConfigId, 'basedir', $strBaseDir);
$myConfigClass->getConfigData($intConfigId,"hostconfig",$strHostDir); $myConfigClass->getConfigValues($intConfigId, 'hostconfig', $strHostDir);
$myConfigClass->getConfigData($intConfigId,"serviceconfig",$strServiceDir); $myConfigClass->getConfigValues($intConfigId, 'serviceconfig', $strServiceDir);
// //
// Process form inputs // Process form inputs
// =================== // ===================
if (($chkMselValue1[0] != "") && ($chkStatus == 1)) { /** @var array $chkMselValue1 */
foreach($chkMselValue1 AS $elem) { if (($chkMselValue1[0] != '') && ($chkStatus == 1)) {
$intCheck = $myConfigClass->removeFile(trim($elem),$intConfigId); foreach ($chkMselValue1 as $elem) {
$strFile = str_replace($strServiceDir,"",$elem); $intCheck = $myConfigClass->removeFile(trim($elem), $intConfigId);
$strFile = str_replace($strHostDir,"",$strFile); $strFileTmp1 = str_replace($strServiceDir, '', $elem);
$strFile = str_replace($strBaseDir,"",$strFile); $strFileTmp2 = str_replace($strHostDir, '', $strFileTmp1);
if ($intCheck == 0) { $strFile = str_replace($strBaseDir, '', $strFileTmp2);
$myDataClass->writeLog(translate("File deleted").": ".trim($strFile)); if ($intCheck == 0) {
$myVisClass->processMessage($strFile." ".translate("successfully deleted")."!",$strInfoMessage); $myDataClass->writeLog(translate('File deleted'). ': ' .trim($strFile));
} else { $myVisClass->processMessage($strFile. ' ' .translate('successfully deleted'). '!', $strInfoMessage);
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); } else {
} $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} }
}
} }
// //
// Include content // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate("Delete config files")); $conttp->setVariable('TITLE', translate('Delete config files'));
$conttp->parse("header"); $conttp->parse('header');
$conttp->show("header"); $conttp->show('header');
$conttp->setVariable("LANG_SEARCH_STRING",translate('Filter string')); $conttp->setVariable('LANG_SEARCH_STRING', translate('Filter string'));
$conttp->setVariable("LANG_SEARCH",translate('Search')); $conttp->setVariable('LANG_SEARCH', translate('Search'));
$conttp->setVariable("LANG_DELETE",translate('Delete')); $conttp->setVariable('LANG_DELETE', translate('Delete'));
$conttp->setVariable("LANG_DELETE_SEARCH",translate("Reset filter")); $conttp->setVariable('LANG_DELETE_SEARCH', translate('Reset filter'));
$conttp->setVariable("DAT_SEARCH",$chkTfSearch); $conttp->setVariable('DAT_SEARCH', $chkTfSearch);
$conttp->setVariable("BACKUPFILE",translate("Configuration file")); $conttp->setVariable('BACKUPFILE', translate('Configuration file'));
$conttp->setVariable("LANG_REQUIRED",translate("required")); $conttp->setVariable('LANG_REQUIRED', translate('required'));
$conttp->setVariable("MAKE",translate("Delete")); $conttp->setVariable('MAKE', translate('Delete'));
$conttp->setVariable("ABORT",translate("Abort")); $conttp->setVariable('ABORT', translate('Abort'));
$conttp->setVariable("CTRL_INFO",translate("Hold CTRL to select<br>more than one entry")); $conttp->setVariable('CTRL_INFO', translate('Hold CTRL to select<br>more than one entry'));
$conttp->setVariable("IMAGE_PATH",$_SESSION['SETS']['path']['base_url']."images/"); $conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)); $conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
// Build a local file list // Build a local file list
if ($intMethod == 1) { if ($intMethod == 1) {
$output = array(); $output = array();
$temp=$myConfigClass->DirToArray($strBaseDir, "\.cfg", "",$output,$strErrorMessage); $myConfigClass->storeDirToArray($strBaseDir, "\.cfg", '\.cfg_old', $output, $strErrorMessage);
if (is_array($output) && (count($output) != 0)) { if (is_array($output) && (count($output) != 0)) {
foreach ($output AS $elem2) { foreach ($output as $elem2) {
if (($chkTfSearch == "") || (substr_count($elem2,$chkTfSearch) != 0)) { if (($chkTfSearch == '') || (substr_count($elem2, $chkTfSearch) != 0)) {
$conttp->setVariable("DAT_BACKUPFILE",$elem2); $conttp->setVariable('DAT_BACKUPFILE', $elem2);
$conttp->parse("filelist"); $conttp->parse('filelist');
} }
} }
} }
} else if ($intMethod == 2) { } elseif ($intMethod == 2) {
// Open ftp connection // Open ftp connection
if ($myConfigClass->getFTPConnection($intConfigId) == "0") { if ($myConfigClass->getFTPConnection($intConfigId) == '0') {
$arrFiles = array(); $arrFiles = array();
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId,$strBaseDir); $arrFiles1 = ftp_nlist($myConfigClass->resConnectId, $strBaseDir);
if (is_array($arrFiles1)) $arrFiles = array_merge($arrFiles,$arrFiles1); if (is_array($arrFiles1)) {
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId,$strHostDir); $arrFiles = array_merge($arrFiles, $arrFiles1);
if (is_array($arrFiles2)) $arrFiles = array_merge($arrFiles,$arrFiles2); }
$arrFiles3 = ftp_nlist($myConfigClass->resConnectId,$strServiceDir); $arrFiles2 = ftp_nlist($myConfigClass->resConnectId, $strHostDir);
if (is_array($arrFiles3)) $arrFiles = array_merge($arrFiles,$arrFiles3); if (is_array($arrFiles2)) {
if (is_array($arrFiles) && (count($arrFiles) != 0)) { $arrFiles = array_merge($arrFiles, $arrFiles2);
foreach ($arrFiles AS $elem) { }
if (!substr_count($elem,"cfg")) continue; $arrFiles3 = ftp_nlist($myConfigClass->resConnectId, $strServiceDir);
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) { if (is_array($arrFiles3)) {
$conttp->setVariable("DAT_BACKUPFILE",str_replace("//","/",$elem)); $arrFiles = array_merge($arrFiles, $arrFiles3);
$conttp->parse("filelist"); }
} if (is_array($arrFiles) && (count($arrFiles) != 0)) {
} foreach ($arrFiles as $elem) {
} if (!substr_count($elem, 'cfg')) {
ftp_close($myConfigClass->resConnectId); continue;
} else { }
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
} $conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $elem));
} else if ($intMethod == 3) { $conttp->parse('filelist');
// Open ssh connection }
if ($myConfigClass->getSSHConnection($intConfigId) == "0") { }
$arrFiles1 = $myConfigClass->sendSSHCommand('ls '.$strBaseDir); }
if (is_array($arrFiles1) && (count($arrFiles1) != 0)) { ftp_close($myConfigClass->resConnectId);
foreach ($arrFiles1 AS $elem) { } else {
if (!substr_count($elem,"cfg")) continue; $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
if (substr_count($elem,"cgi.cfg") != 0) continue; }
if (substr_count($elem,"nagios.cfg") != 0) continue; } elseif ($intMethod == 3) {
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) { // Open ssh connection
$conttp->setVariable("DAT_BACKUPFILE",str_replace("//","/",$strBaseDir."/".$elem)); if ($myConfigClass->getSSHConnection($intConfigId) == '0') {
$conttp->setVariable("DAT_BACKUPFILE_FULL",str_replace("//","/",$strBaseDir."/".$elem)); $intReturn = $myConfigClass->sendSSHCommand('ls '.$strBaseDir, $arrFiles1);
$conttp->parse("filelist"); if (($intReturn == 0) && is_array($arrFiles1) && (count($arrFiles1) != 0)) {
} foreach ($arrFiles1 as $elem) {
} if (!substr_count($elem, 'cfg')) {
} continue;
$arrFiles2 = $myConfigClass->sendSSHCommand('ls '.$strHostDir); }
if (is_array($arrFiles2) && (count($arrFiles2) != 0)) { if (substr_count($elem, 'cgi.cfg') != 0) {
foreach ($arrFiles2 AS $elem) { continue;
if (!substr_count($elem,"cfg")) continue; }
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) { if (substr_count($elem, 'nagios.cfg') != 0) {
$conttp->setVariable("DAT_BACKUPFILE",str_replace("//","/",$strHostDir."/".$elem)); continue;
$conttp->setVariable("DAT_BACKUPFILE_FULL",str_replace("//","/",$strHostDir."/".$elem)); }
$conttp->parse("filelist"); 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');
$arrFiles3 = $myConfigClass->sendSSHCommand('ls '.$strServiceDir); }
if (is_array($arrFiles3) && (count($arrFiles3) != 0)) { }
foreach ($arrFiles3 AS $elem) { }
if (!substr_count($elem,"cfg")) continue; $intReturn = $myConfigClass->sendSSHCommand('ls '.$strHostDir, $arrFiles2);
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) { if (($intReturn == 0) && is_array($arrFiles2) && (count($arrFiles2) != 0)) {
$conttp->setVariable("DAT_BACKUPFILE",str_replace("//","/",$strServiceDir."/".$elem)); foreach ($arrFiles2 as $elem) {
$conttp->setVariable("DAT_BACKUPFILE_FULL",str_replace("//","/",$strServiceDir."/".$elem)); if (!substr_count($elem, 'cfg')) {
$conttp->parse("filelist"); continue;
} }
} if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
} $conttp->setVariable('DAT_BACKUPFILE', str_replace('//', '/', $strHostDir. '/' .$elem));
} else { $conttp->setVariable('DAT_BACKUPFILE_FULL', str_replace('//', '/', $strHostDir. '/' .$elem));
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); $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); if ($strErrorMessage != '') {
$conttp->setVariable("INFOMESSAGE",$strInfoMessage); $conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// Check access rights for adding new objects // Check access rights for adding new objects
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\""); if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->parse("main"); $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
$conttp->show("main"); }
$conttp->parse('main');
$conttp->show('main');
// //
// Footer ausgeben // Footer ausgeben
// =============== // ===============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,18 +5,22 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Download config file // Component : Download config file
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Version control // Version control
// =============== // ===============
session_cache_limiter('private_no_expire'); session_cache_limiter('private_no_expire');
@ -25,44 +29,33 @@ session_cache_limiter('private_no_expire');
// ========================== // ==========================
$preNoMain = 1; $preNoMain = 1;
$preNoLogin = 1; $preNoLogin = 1;
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
// //
// Process post parameters // Process post parameters
// ======================= // =======================
$chkTable = isset($_GET['table']) ? htmlspecialchars($_GET['table'], ENT_QUOTES, 'utf-8') : ""; $chkTable = filter_input(INPUT_GET, 'table', FILTER_SANITIZE_STRING);
$chkConfig = isset($_GET['config']) ? htmlspecialchars($_GET['config'], ENT_QUOTES, 'utf-8') : ""; $chkConfig = filter_input(INPUT_GET, 'config', FILTER_SANITIZE_STRING);
$chkLine = isset($_GET['line']) ? htmlspecialchars($_GET['line'], ENT_QUOTES, 'utf-8') : 0; $chkLine = filter_input(INPUT_GET, 'line', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
// //
// Header output // Header output
// =============== // ===============
switch($chkTable) { $arrConfig = $myConfigClass->getConfData();
case "tbl_timeperiod": $strFile = "timeperiods.cfg"; break; if (isset($arrConfig[$chkTable])) {
case "tbl_command": $strFile = "commands.cfg"; break; $strFile = $arrConfig[$chkTable]['filename'];
case "tbl_contact": $strFile = "contacts.cfg"; break; } else {
case "tbl_contacttemplate": $strFile = "contacttemplates.cfg"; break; $strFile = $chkConfig. '.cfg';
case "tbl_contactgroup": $strFile = "contactgroups.cfg"; break;
case "tbl_hosttemplate": $strFile = "hosttemplates.cfg"; break;
case "tbl_servicetemplate": $strFile = "servicetemplates.cfg"; break;
case "tbl_hostgroup": $strFile = "hostgroups.cfg"; break;
case "tbl_servicegroup": $strFile = "servicegroups.cfg"; break;
case "tbl_servicedependency": $strFile = "servicedependencies.cfg"; break;
case "tbl_hostdependency": $strFile = "hostdependencies.cfg"; break;
case "tbl_serviceescalation": $strFile = "serviceescalations.cfg"; break;
case "tbl_hostescalation": $strFile = "hostescalations.cfg"; break;
case "tbl_hostextinfo": $strFile = "hostextinfo.cfg"; break;
case "tbl_serviceextinfo": $strFile = "serviceextinfo.cfg"; break;
default: $strFile = $chkConfig.".cfg";
} }
if ($strFile == ".cfg") exit; if ($strFile == '.cfg') {
header("Content-Disposition: attachment; filename=".$strFile); exit;
header("Content-Type: text/plain"); }
header('Content-Disposition: attachment; filename=' .$strFile);
header('Content-Type: text/plain');
// //
// Get data // Get data
// ======== // ========
if ($chkLine == 0) { if ($chkLine == 0) {
$myConfigClass->createConfig($chkTable,1); $myConfigClass->createConfig($chkTable, 1);
} else { } else {
$myConfigClass->createConfigSingle($chkTable,$chkLine,1); $myConfigClass->createConfigSingle($chkTable, $chkLine, 1);
} }
$myDataClass->writeLog(translate('Download')." ".$strFile); $myDataClass->writeLog(translate('Download'). ' ' .$strFile);
?>

View File

@ -5,161 +5,197 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Group administration // Component : Group administration
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 33; $prePageId = 33;
$preContent = "admin/group.tpl.htm"; $preContent = 'admin/group.htm.tpl';
$preSearchSession = 'group'; $preListTpl = 'admin/datalist_common.htm.tpl';
$preTableName = 'tbl_group'; $preSearchSession = 'group';
$preKeyField = 'groupname'; $preTableName = 'tbl_group';
$preAccess = 1; $preKeyField = 'groupname';
$preFieldvars = 1; $preAccess = 1;
$preNoAccessGrp = 1; $preFieldvars = 1;
$preNoAccessGrp = 1;
$arrDataLines = array();
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Add or modify data // Add or modify data
// ================== // ==================
if (($chkModus == "insert") || ($chkModus == "modify")) { if (($chkModus == 'insert') || ($chkModus == 'modify')) {
$strSQLx = "`$preTableName` SET `groupname`='$chkTfValue1', `description`='$chkTfValue2', `active`='$chkActive', `last_modified`=NOW()"; $strSQLx = "`$preTableName` SET `groupname`='$chkTfValue1', `description`='$chkTfValue2', `active`='$chkActive', "
if ($chkModus == "insert") { . '`last_modified`=NOW()';
$strSQL = "INSERT INTO ".$strSQLx; if ($chkModus == 'insert') {
} else { $strSQL = 'INSERT INTO ' .$strSQLx;
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; } else {
} $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ($intWriteAccessId == 0) { }
if (($chkTfValue1 != "") && ($chkTfValue2 != "")) { if ($intWriteAccessId == 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
if ($chkModus == "insert") $chkDataId = $intInsertId; $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn == 1) { if ($chkModus == 'insert') {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId = $intInsertId;
} else { }
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($intReturn == 1) {
if ($chkModus == "insert") $myDataClass->writeLog(translate('A new group added:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "modify") $myDataClass->writeLog(translate('User modified:')." ".$chkTfValue1); } else {
// $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
// Insert/update user/group data from session data if ($chkModus == 'insert') {
// =============================================== $myDataClass->writeLog(translate('A new group added:'). ' ' .$chkTfValue1);
if ($chkModus == "modify") { }
$strSQL = "DELETE FROM `tbl_lnkGroupToUser` WHERE `idMaster`=$chkDataId"; if ($chkModus == 'modify') {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $myDataClass->writeLog(translate('User modified:'). ' ' .$chkTfValue1);
if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} //
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser']) && (count($_SESSION['groupuser']) != 0)) { // Insert/update user/group data from session data
foreach($_SESSION['groupuser'] AS $elem) { // ===============================================
if ($elem['status'] == 0) { if ($chkModus == 'modify') {
$intRead = 0; $intWrite = 0; $intLink = 0; $strSQL = "DELETE FROM `tbl_lnkGroupToUser` WHERE `idMaster`=$chkDataId";
if (substr_count($elem['rights'],"READ") != 0) $intRead = 1; $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if (substr_count($elem['rights'],"WRITE") != 0) $intWrite = 1; if ($intReturn != 0) {
if (substr_count($elem['rights'],"LINK") != 0) $intLink = 1; $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($intWrite == 1) {$intRead = 1;$intLink = 1;} }
if ($intRead == 1) {$intLink = 1;} }
// if ($intLink == 1) $intRead = 1; if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser']) &&
$strSQL = "INSERT INTO `tbl_lnkGroupToUser` (`idMaster`,`idSlave`,`read`,`write`,`link`) (count($_SESSION['groupuser']) != 0)) {
VALUES ($chkDataId,".$elem['user'].",'$intRead','$intWrite','$intLink')"; foreach ($_SESSION['groupuser'] as $elem) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if ($elem['status'] == 0) {
if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $intRead = 0;
} $intWrite = 0;
} $intLink = 0;
} if (substr_count($elem['rights'], 'READ') != 0) {
} $intRead = 1;
} else { }
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); if (substr_count($elem['rights'], 'WRITE') != 0) {
} $intWrite = 1;
} else { }
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); if (substr_count($elem['rights'], 'LINK') != 0) {
$intLink = 1;
} }
$chkModus = "display"; 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 // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Process data fields // Process data fields
$strSQL = "SELECT * FROM tbl_user WHERE id <> 1 ORDER BY username"; $strSQL = 'SELECT * FROM `tbl_user` WHERE `id`<>1 ORDER BY `username`';
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); $booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
if ($booReturn && ($intDataCount != 0)) { if ($booReturn && ($intDataCount != 0)) {
foreach($arrDataLines AS $elem) { foreach ($arrDataLines as $elem) {
$conttp->setVariable("DAT_USER_ID",$elem['id']); $conttp->setVariable('DAT_USER_ID', $elem['id']);
$conttp->setVariable("DAT_USER",$elem['username']); $conttp->setVariable('DAT_USER', $elem['username']);
$conttp->parse("users"); $conttp->parse('users');
} }
} }
// Initial add/modify form definitions // Initial add/modify form definitions
$myContentClass->addFormInit($conttp); $myContentClass->addFormInit($conttp);
$conttp->setVariable("LANG_READ",translate("Read")); $conttp->setVariable('TITLE', translate('Group administration'));
$conttp->setVariable("LANG_WRITE",translate("Write")); $conttp->setVariable('LANG_READ', translate('Read'));
$conttp->setVariable("LANG_LINK",translate("Link")); $conttp->setVariable('LANG_WRITE', translate('Write'));
$conttp->setVariable("DAT_ID",$chkListId); $conttp->setVariable('LANG_LINK', translate('Link'));
$conttp->setVariable("FILL_ALLFIELDS",translate('Please fill in all fields marked with an *')); $conttp->setVariable('DAT_ID', $chkListId);
$conttp->setVariable("FILL_ILLEGALCHARS",translate('The following field contains not permitted characters:')); $conttp->setVariable('FILL_ALLFIELDS', translate('Please fill in all fields marked with an *'));
// Insert data from database in "modify" mode $conttp->setVariable('FILL_ILLEGALCHARS', translate('The following field contains illegal characters:'));
if (isset($arrModifyData) && ($chkSelModify == "modify")) { // Insert data from database in "modify" mode
// Process data if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
$myContentClass->addInsertData($conttp,$arrModifyData,0,''); // Process data
} $myContentClass->addInsertData($conttp, $arrModifyData, 0, '');
$conttp->parse("datainsert"); }
$conttp->show("datainsert"); $conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Groupname')); $mastertp->setVariable('TITLE', translate('Group administration'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Groupname'));
// Row sorting $mastertp->setVariable('FIELD_2', translate('Description'));
$strOrderString = "ORDER BY `groupname` $hidSortDir"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `description` $hidSortDir"; $strOrderString = "ORDER BY `groupname` $hidSortDir";
// Count datasets if ($hidSortBy == 2) {
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName`"; $strOrderString = "ORDER BY `description` $hidSortDir";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); }
if ($booReturn == false) { // Count datasets
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName`";
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
} else { if ($booReturn1 == false) {
$intLineCount = (int)$arrDataLinesCount['number']; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} } else {
// Get datasets $intLineCount = (int)$arrDataLinesCount['number'];
$strSQL = "SELECT `id`, `groupname`, `description`, `active` FROM `$preTableName` $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; if ($intLineCount < $chkLimit) {
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); $chkLimit = 0;
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); }
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); // Get datasets
} $strSQL = 'SELECT `id`, `groupname`, `description`, `active` '
// Process data . "FROM `$preTableName` $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'description'); $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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1); $myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,146 +5,171 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin time definition list // Component : Admin time definition list
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$preAccess = 1; $preAccess = 1;
//$prePageId = 33;
$preNoMain = 1; $preNoMain = 1;
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
// //
// Process get parameters // Process get parameters
// ====================== // ======================
$chkDataId = isset($_GET['dataId']) ? htmlspecialchars($_GET['dataId'], ENT_QUOTES, 'utf-8') : 0; $chkDataId = filter_input(INPUT_GET, 'dataId', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkMode = isset($_GET['mode']) ? htmlspecialchars($_GET['mode'], ENT_QUOTES, 'utf-8') : ""; $chkVersion = filter_input(INPUT_GET, 'version', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkUser = isset($_GET['user']) ? htmlspecialchars($_GET['user'], ENT_QUOTES, 'utf-8') : ""; $chkMode = filter_input(INPUT_GET, 'mode', FILTER_SANITIZE_STRING);
$chkRights = isset($_GET['rights']) ? htmlspecialchars($_GET['rights'], ENT_QUOTES, 'utf-8') : ""; $chkUser = filter_input(INPUT_GET, 'user', FILTER_SANITIZE_STRING);
$chkId = isset($_GET['id']) ? htmlspecialchars($_GET['id'], ENT_QUOTES, 'utf-8') : ""; $chkRights = filter_input(INPUT_GET, 'rights', FILTER_SANITIZE_STRING);
$chkVersion = isset($_GET['version']) ? htmlspecialchars($_GET['version'], ENT_QUOTES, 'utf-8') : 0; $chkId = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_STRING);
$chkLinkTab = isset($_GET['linktab']) ? htmlspecialchars($_GET['linktab'], ENT_QUOTES, 'utf-8') : ""; $chkLinkTab = filter_input(INPUT_GET, 'linktab', FILTER_SANITIZE_STRING);
if (substr_count($chkRights,"-")) { if (substr_count($chkRights, '-')) {
$arrRights = explode("-",$chkRights); $arrRights = explode('-', $chkRights);
$strRights = ""; $strRights = '';
if ($arrRights[0] == 1) $strRights .= "READ,"; if ($arrRights[0] == 1) {
if ($arrRights[1] == 1) $strRights .= "WRITE,"; $strRights .= 'READ,';
if ($arrRights[2] == 1) $strRights .= "LINK,"; }
if ($strRights != "") $strRights = substr($strRights,0,-1); if ($arrRights[1] == 1) {
$chkRights = $strRights; $strRights .= 'WRITE,';
}
if ($arrRights[2] == 1) {
$strRights .= 'LINK,';
}
if ($strRights != '') {
$strRights = substr($strRights, 0, -1);
}
$chkRights = $strRights;
} }
if (get_magic_quotes_gpc() == 0) { if (get_magic_quotes_gpc() == 0) {
$chkUser = addslashes($chkUser); $chkUser = addslashes($chkUser);
$chkRights = addslashes($chkRights); $chkRights = addslashes($chkRights);
} }
// //
// Get datasets // Get datasets
// ============ // ============
if ($chkLinkTab != "") { if ($chkLinkTab != '') {
$strSQL = "SELECT * FROM `tbl_user` LEFT JOIN `".$chkLinkTab."` ON `id`=`idSlave` WHERE `idMaster`=$chkDataId ORDER BY `username`"; $strSQL = 'SELECT * FROM `tbl_user` LEFT JOIN `' .$chkLinkTab. '` ON `id`=`idSlave` '
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); . "WHERE `idMaster`=$chkDataId ORDER BY `username`";
// $booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
// Write data to session //
// ===================== // Write data to session
if ($chkMode == "") { // =====================
$_SESSION['groupuser'] = ""; if ($chkMode == '') {
if ($intDataCount != 0) { $_SESSION['groupuser'] = array();
foreach ($arrDataLines AS $elem) { if ($intDataCount != 0) {
$arrTemp['id'] = $elem['id']; foreach ($arrDataLines as $elem) {
$arrTemp['user'] = $elem['id']; $arrTemp['id'] = $elem['id'];
$strRights = ""; $arrTemp['user'] = $elem['id'];
if ($elem['read'] == 1) $strRights .= "READ,"; $strRights = '';
if ($elem['write'] == 1) $strRights .= "WRITE,"; if ($elem['read'] == 1) {
if ($elem['link'] == 1) $strRights .= "LINK,"; $strRights .= 'READ,';
if ($strRights != "") $strRights = substr($strRights,0,-1); }
$arrTemp['rights'] = $strRights; if ($elem['write'] == 1) {
$arrTemp['status'] = 0; $strRights .= 'WRITE,';
$_SESSION['groupuser'][] = $arrTemp; }
} if ($elem['link'] == 1) {
} $strRights .= 'LINK,';
} }
if ($strRights != '') {
$strRights = substr($strRights, 0, -1);
}
$arrTemp['rights'] = $strRights;
$arrTemp['status'] = 0;
$_SESSION['groupuser'][] = $arrTemp;
}
}
}
} }
// //
// Add mode // Add mode
// ======== // ========
if ($chkMode == "add") { if ($chkMode == 'add') {
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser'])) { if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser'])) {
$intCheck = 0; $intCheck = 0;
foreach ($_SESSION['groupuser'] AS $key => $elem) { foreach ($_SESSION['groupuser'] as $key => $elem) {
if (($elem['user'] == $chkUser) && ($elem['status'] == 0)) { if (($elem['user'] == $chkUser) && ($elem['status'] == 0)) {
$_SESSION['groupuser'][$key]['user'] = $chkUser; $_SESSION['groupuser'][$key]['user'] = $chkUser;
$_SESSION['groupuser'][$key]['rights'] = $chkRights; $_SESSION['groupuser'][$key]['rights'] = $chkRights;
$intCheck = 1; $intCheck = 1;
} }
} }
if ($intCheck == 0) { if ($intCheck == 0) {
$arrTemp['id'] = 0; $arrTemp['id'] = 0;
$arrTemp['user'] = $chkUser; $arrTemp['user'] = $chkUser;
$arrTemp['rights'] = $chkRights; $arrTemp['rights'] = $chkRights;
$arrTemp['status'] = 0; $arrTemp['status'] = 0;
$_SESSION['groupuser'][] = $arrTemp; $_SESSION['groupuser'][] = $arrTemp;
} }
} else { } else {
$arrTemp['id'] = 0; $arrTemp['id'] = 0;
$arrTemp['user'] = $chkUser; $arrTemp['user'] = $chkUser;
$arrTemp['rights'] = $chkRights; $arrTemp['rights'] = $chkRights;
$arrTemp['status'] = 0; $arrTemp['status'] = 0;
$_SESSION['groupuser'][] = $arrTemp; $_SESSION['groupuser'] = array();
} $_SESSION['groupuser'][] = $arrTemp;
}
} }
// //
// Deletion mode // Deletion mode
// ============= // =============
if ($chkMode == "del") { if ($chkMode == 'del' && isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser'])) {
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser'])) { foreach ($_SESSION['groupuser'] as $key => $elem) {
foreach ($_SESSION['groupuser'] AS $key => $elem) { if (($elem['user'] == $chkUser) && ($elem['status'] == 0)) {
if (($elem['user'] == $chkUser) && ($elem['status'] == 0)) { $_SESSION['groupuser'][$key]['status'] = 1;
$_SESSION['groupuser'][$key]['status'] = 1; }
} }
}
}
} }
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>None</title> <title>None</title>
<link href="<?php echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css"> <link href="<?php
<script type="text/javascript" language="javascript"> echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
<!-- <script type="text/javascript" language="javascript">
function doDel(key) { <!--
document.location.href = "<?php echo $_SESSION['SETS']['path']['base_url']; ?>admin/groupusers.php?dataId=<?php echo $chkDataId; ?>&mode=del&user="+key; function doDel(key) {
} document.location.href = "<?php
//--> echo $_SESSION['SETS']['path']['base_url']; ?>admin/groupusers.php?dataId=<?php
</script> echo $chkDataId; ?>&mode=del&user="+key;
</head> }
<body style="margin:0"> //-->
<table cellpadding="0" cellspacing="0" border="0" width="100%"> </script>
</head>
<body style="margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<?php <?php
if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser']) && (count($_SESSION['groupuser']) != 0)) { if (isset($_SESSION['groupuser']) && is_array($_SESSION['groupuser']) && (count($_SESSION['groupuser']) != 0)) {
foreach($_SESSION['groupuser'] AS $elem) { foreach ($_SESSION['groupuser'] as $elem) {
if ($elem['status'] == 0) { if ($elem['status'] == 0) {
$strUser = $myDBClass->getFieldData("SELECT username FROM tbl_user WHERE id=".$elem['user']); $strUser = $myDBClass->getFieldData('SELECT `username` FROM `tbl_user` WHERE `id`=' .$elem['user']); ?>
?>
<tr> <tr>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php echo $strUser; ?></td> <td class="tablerow" style="padding-bottom:2px; width:260px"><?php echo $strUser; ?></td>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php echo htmlspecialchars(stripslashes($elem['rights']),ENT_COMPAT,'UTF-8'); ?></td> <td class="tablerow" style="padding-bottom:2px; width:260px"><?php
<td class="tablerow" style="width:50px" align="right"><img src="<?php echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18" alt="<?php echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>" onClick="doDel('<?php echo $elem['user']; ?>')" style="cursor:pointer"></td> echo htmlspecialchars(stripslashes($elem['rights']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="width:50px" align="right"><img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18" alt="<?php
echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>" onClick="doDel('<?php
echo $elem['user']; ?>')" style="cursor:pointer"></td>
</tr> </tr>
<?php <?php
} }
} }
} else { } else {
?> ?>
<tr> <tr>
<td class="tablerow"><?php echo translate('No data'); ?></td> <td class="tablerow"><?php echo translate('No data'); ?></td>
@ -152,8 +177,8 @@ if ($chkMode == "del") {
<td class="tablerow" align="right">&nbsp;</td> <td class="tablerow" align="right">&nbsp;</td>
</tr> </tr>
<?php <?php
} }
?> ?>
</table> </table>
</body> </body>
</html> </html>

View File

@ -5,149 +5,174 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Help text editor // Component : Help text editor
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 39; $prePageId = 39;
$preContent = "admin/helpedit.tpl.htm"; $preContent = 'admin/helpedit.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
$setSaveLangId = "private"; $setSaveLangId = 'private';
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Process post parameters // Process post parameters
// ======================= // =======================
$chkHidVersion = isset($_POST['hidVersion']) ? $_POST['hidVersion'] : "all"; $chkHidVersion = filter_input(INPUT_POST, 'hidVersion', 513, array('options' => array('default' => 'all')));
$chkKey1 = isset($_POST['selInfoKey1']) ? $_POST['selInfoKey1'] : ""; $chkKey1 = filter_input(INPUT_POST, 'selInfoKey1', FILTER_SANITIZE_STRING);
$chkKey2 = isset($_POST['selInfoKey2']) ? $_POST['selInfoKey2'] : ""; $chkKey2 = filter_input(INPUT_POST, 'selInfoKey2', FILTER_SANITIZE_STRING);
$chkVersion = isset($_POST['selInfoVersion']) ? $_POST['selInfoVersion'] : ""; $chkVersion = filter_input(INPUT_POST, 'selInfoVersion', FILTER_SANITIZE_STRING);
// //
// Add or modify data // Quote special characters
// ================== // ==========================
if (($chkTaValue1 != "") && ($chkTfValue3 == "1")) { if (get_magic_quotes_gpc() == 0) {
$strSQL = "SELECT `infotext` FROM `tbl_info` $chkHidVersion = addslashes($chkHidVersion);
WHERE `key1` = '$chkTfValue1' AND `key2` = '$chkTfValue2' AND `version` = '$chkHidVersion' $chkKey1 = addslashes($chkKey1);
AND `language` = '$setSaveLangId'"; $chkKey2 = addslashes($chkKey2);
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); $chkVersion = addslashes($chkVersion);
if ($intDataCount == 0) {
$strSQL = "INSERT INTO `tbl_info` (`key1`,`key2`,`version`,`language`,`infotext`)
VALUES ('$chkTfValue1','$chkTfValue2','$chkHidVersion','$setSaveLangId','$chkTaValue1')";
} else {
$strSQL = "UPDATE `tbl_info` SET `infotext` = '$chkTaValue1'
WHERE `key1` = '$chkTfValue1' AND `key2` = '$chkTfValue2' AND `version` = '$chkHidVersion'
AND `language` = '$setSaveLangId'";
}
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId);
if ($intReturn != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage);
} else {
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage);
}
} }
// //
// Start content // Security function for text fields
// ============= // =================================
$conttp->setVariable("TITLE",translate('Help text editor')); $chkHidVersion = $myVisClass->tfSecure($chkHidVersion);
$conttp->parse("header"); $chkKey1 = $myVisClass->tfSecure($chkKey1);
$conttp->show("header"); $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 // Singe data form
// =============== // ===============
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)); $conttp->setVariable('TITLE', translate('Help text editor'));
$conttp->setVariable("MAINSITE",$_SESSION['SETS']['path']['base_url']."admin.php"); $conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
foreach($arrDescription AS $elem) { $conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url']. 'admin.php');
$conttp->setVariable($elem['name'],$elem['string']); 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 // Get Key
// ======= // =======
$strSQL = "SELECT DISTINCT `key1` FROM `tbl_info` ORDER BY `key1`"; $arrData = array();
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); $strSQL = 'SELECT DISTINCT `key1` FROM `tbl_info` ORDER BY `key1`';
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($intDataCount != 0) { if ($intDataCount != 0) {
foreach ($arrData AS $elem) { foreach ($arrData as $elem) {
$conttp->setVariable("INFOKEY_1_VAL",$elem['key1']); $conttp->setVariable('INFOKEY_1_VAL', $elem['key1']);
if ($chkKey1 == $elem['key1']) { if ($chkKey1 == $elem['key1']) {
$conttp->setVariable("INFOKEY_1_SEL","selected"); $conttp->setVariable('INFOKEY_1_SEL', 'selected');
$conttp->setVariable("INFOKEY_1_SEL_VAL",$elem['key1']); $conttp->setVariable('INFOKEY_1_SEL_VAL', $elem['key1']);
} }
$conttp->parse("infokey1"); $conttp->parse('infokey1');
} }
} }
if ($chkKey1 != "") { if ($chkKey1 != '') {
$strSQL = "SELECT DISTINCT `key2` FROM `tbl_info` WHERE `key1` = '$chkKey1' ORDER BY `key1`"; $strSQL = "SELECT DISTINCT `key2` FROM `tbl_info` WHERE `key1` = '$chkKey1' ORDER BY `key1`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($intDataCount != 0) { if ($intDataCount != 0) {
foreach ($arrData AS $elem) { foreach ($arrData as $elem) {
$conttp->setVariable("INFOKEY_2_VAL",$elem['key2']); $conttp->setVariable('INFOKEY_2_VAL', $elem['key2']);
if ($chkKey2 == $elem['key2']) { if ($chkKey2 == $elem['key2']) {
$conttp->setVariable("INFOKEY_2_SEL","selected"); $conttp->setVariable('INFOKEY_2_SEL', 'selected');
$conttp->setVariable("INFOKEY_2_SEL_VAL",$elem['key2']); $conttp->setVariable('INFOKEY_2_SEL_VAL', $elem['key2']);
} }
$conttp->parse("infokey2"); $conttp->parse('infokey2');
} }
} }
} }
if (($chkKey1 != "") && ($chkKey2 != "")) { if (($chkKey1 != '') && ($chkKey2 != '')) {
$strSQL = "SELECT DISTINCT `version` FROM `tbl_info` WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' ORDER BY `version`"; $strSQL = 'SELECT DISTINCT `version` FROM `tbl_info` '
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); . "WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' ORDER BY `version`";
if ($intDataCount != 0) { $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if (($intDataCount == 1) && ($chkVersion == "")) $chkVersion = $arrData[0]['version']; if ($intDataCount != 0) {
foreach ($arrData AS $elem) { if (($intDataCount == 1) && ($chkVersion == '')) {
$conttp->setVariable("INFOVERSION_2_VAL",$elem['version']); $chkVersion = $arrData[0]['version'];
if ($chkVersion == $elem['version']) { }
$conttp->setVariable("INFOVERSION_2_SEL","selected"); foreach ($arrData as $elem) {
$conttp->setVariable("INFOVERSION_2_SEL_VAL",$elem['version']); $conttp->setVariable('INFOVERSION_2_VAL', $elem['version']);
} if ($chkVersion == $elem['version']) {
$conttp->parse("infoversion"); $conttp->setVariable('INFOVERSION_2_SEL', 'selected');
} $conttp->setVariable('INFOVERSION_2_SEL_VAL', $elem['version']);
} }
$conttp->parse('infoversion');
}
}
} }
// //
// Insert content // Insert content
// ============== // ==============
if (($chkKey1 != "") && ($chkKey2 != "") && ($chkVersion != "")) { if (($chkKey1 != '') && ($chkKey2 != '') && ($chkVersion != '')) {
$strSQL = "SELECT `infotext` FROM `tbl_info` $strSQL = "SELECT `infotext` FROM `tbl_info` WHERE `key1`='$chkKey1' AND `key2`='$chkKey2' "
WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' AND `version` = '$chkVersion' AND `language` = '$setSaveLangId'"; . "AND `version`='$chkVersion' AND `language`='$setSaveLangId'";
$strContentDB = $myDBClass->getFieldData($strSQL); $strContentDB = $myDBClass->getFieldData($strSQL);
if (($chkChbValue1 == 1) || ($strContentDB == "")) { if (($chkChbValue1 == 1) || ($strContentDB == '')) {
$strSQL = "SELECT `infotext` FROM `tbl_info` $strSQL = "SELECT `infotext` FROM `tbl_info` WHERE `key1`='$chkKey1' AND `key2`='$chkKey2' "
WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' AND `version` = '$chkVersion' AND `language` = 'default'"; . "AND `version`='$chkVersion' AND `language`='default'";
$strContentDB = $myDBClass->getFieldData($strSQL); $strContentDB = $myDBClass->getFieldData($strSQL);
} }
$conttp->setVariable("DAT_HELPTEXT",$strContentDB); $conttp->setVariable('DAT_HELPTEXT', $strContentDB);
} }
// Messages // Messages
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage); if ($strErrorMessage != '') {
if ($strInfoMessage != "") $conttp->setVariable("INFOMESSAGE",$strInfoMessage); $conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
if ($strInfoMessage != '') {
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
}
// Check access rights for adding new objects // Check access rights for adding new objects
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\""); if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->parse("helpedit"); $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
$conttp->show("helpedit"); }
$conttp->parse('helpedit');
$conttp->show('helpedit');
// //
// Process footer // Process footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,225 +5,389 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Host dependencies definition // Component : Host dependencies definition
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 19; $prePageId = 19;
$preContent = "admin/hostdependencies.tpl.htm"; $preContent = 'admin/hostdependencies.htm.tpl';
$preSearchSession = 'hostdependencies'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_hostdependency'; $preSearchSession = 'hostdependencies';
$preKeyField = 'config_name'; $preTableName = 'tbl_hostdependency';
$preAccess = 1; $preKeyField = 'config_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Data processing // Data processing
// =============== // ===============
$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e,0,-1); $strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e, 0, -1);
$strNO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e,0,-1); $strNO = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c.$chkChbGr2d.$chkChbGr2e, 0, -1);
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `dependent_host_name`=$intMselValue1, `host_name`=$intMselValue2, `dependent_hostgroup_name`=$intMselValue3, $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `dependent_host_name`=$intMselValue1, "
`hostgroup_name`=$intMselValue4, `inherits_parent`='$chkChbValue1', `execution_failure_criteria`='$strEO', `notification_failure_criteria`='$strNO', . "`host_name`=$intMselValue2, `dependent_hostgroup_name`=$intMselValue3, `hostgroup_name`=$intMselValue4, "
`dependency_period`=$chkSelValue1, $preSQLCommon1"; . "`inherits_parent`='$chkChbValue1', `execution_failure_criteria`='$strEO', "
if ($chkModus == "insert") { . "`notification_failure_criteria`='$strNO', `dependency_period`=$chkSelValue1, $preSQLCommon1";
$strSQL = "INSERT INTO ".$strSQLx; if ($chkModus == 'insert') {
} else { $strSQL = 'INSERT INTO ' .$strSQLx;
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; } else {
} $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ($intWriteAccessId == 0) { }
if ((($intMselValue1 != 0) && ($intMselValue2 != 0)) || (($intMselValue3 != 0) && ($intMselValue4 != 0)) || if ($intWriteAccessId == 0) {
(($intMselValue1 != 0) && ($intMselValue4 != 0)) || (($intMselValue3 != 0) && ($intMselValue2 != 0))) { if ((($intMselValue1 != 0) && ($intMselValue2 != 0)) || (($intMselValue3 != 0) && ($intMselValue4 != 0)) ||
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); (($intMselValue1 != 0) && ($intMselValue4 != 0)) || (($intMselValue3 != 0) && ($intMselValue2 != 0))) {
if ($chkModus == "insert") $chkDataId = $intInsertId; $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn == 1) { if ($chkModus == 'insert') {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId = $intInsertId;
} else { }
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($intReturn == 1) {
$myDataClass->updateStatusTable($preTableName); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "insert") $myDataClass->writeLog(translate('New host dependency inserted:')." ".$chkTfValue1); } else {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Host dependency modified:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
// $myDataClass->updateStatusTable($preTableName);
// Insert/update relations if ($chkModus == 'insert') {
// ======================= $myDataClass->writeLog(translate('New host dependency inserted:'). ' ' .$chkTfValue1);
if ($chkModus == "insert") { }
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkHostdependencyToHost_DH",$chkDataId,$chkMselValue1); if ($chkModus == 'modify') {
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myDataClass->writeLog(translate('Host dependency modified:'). ' ' .$chkTfValue1);
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); // Insert/update relations
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); // =======================
if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkHostdependencyToHostgroup_H",$chkDataId,$chkMselValue4); if ($chkModus == 'insert') {
if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($intMselValue1 != 0) {
} else if ($chkModus == "modify") { $intRet1 = $myDataClass->dataInsertRelation(
if ($intMselValue1 != 0) { 'tbl_lnkHostdependencyToHost_DH',
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkHostdependencyToHost_DH",$chkDataId,$chkMselValue1); $chkDataId,
} else { $chkMselValue1
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkHostdependencyToHost_DH",$chkDataId); );
} }
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if (isset($intRet1) && ($intRet1 != 0)) {
if ($intMselValue2 != 0) { $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkHostdependencyToHost_H",$chkDataId,$chkMselValue2); }
} else { if ($intMselValue2 != 0) {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkHostdependencyToHost_H",$chkDataId); $intRet2 = $myDataClass->dataInsertRelation(
} 'tbl_lnkHostdependencyToHost_H',
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId,
if ($intMselValue3 != 0) { $chkMselValue2
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkHostdependencyToHostgroup_DH",$chkDataId,$chkMselValue3); );
} else { }
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkHostdependencyToHostgroup_DH",$chkDataId); if (isset($intRet2) && ($intRet2 != 0)) {
} $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
if ($intMselValue4 != 0) { if ($intMselValue3 != 0) {
$intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkHostdependencyToHostgroup_H",$chkDataId,$chkMselValue4); $intRet3 = $myDataClass->dataInsertRelation(
} else { 'tbl_lnkHostdependencyToHostgroup_DH',
$intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkHostdependencyToHostgroup_H",$chkDataId); $chkDataId,
} $chkMselValue3
if ($intRet4 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); );
} }
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) $strInfoMessage = ""; if (isset($intRet3) && ($intRet3 != 0)) {
// $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
// Update Import HASH }
// ================== if ($intMselValue4 != 0) {
$booReturn = $myDataClass->updateHash($preTableName,$chkDataId); $intRet4 = $myDataClass->dataInsertRelation(
if ($booReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); 'tbl_lnkHostdependencyToHostgroup_H',
} $chkDataId,
} else { $chkMselValue4
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); );
} }
} else { if (isset($intRet4) && ($intRet4 != 0)) {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
$chkModus = "display"; } 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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Define host dependencies (hostdependencies.cfg)'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Define host dependencies (hostdependencies.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Process host selection field $intNoTime = 1;
if (isset($arrModifyData['dependent_host_name'])) {$intFieldId = $arrModifyData['dependent_host_name'];} else {$intFieldId = 0;} // Process host selection field
$intReturn = $myVisClass->parseSelectMulti('tbl_host','host_name','depend_host','tbl_lnkHostdependencyToHost_DH',2,$intFieldId); if (isset($arrModifyData['dependent_host_name'])) {
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId = $arrModifyData['dependent_host_name'];
if (isset($arrModifyData['host_name'])) {$intFieldId = $arrModifyData['host_name'];} else {$intFieldId = 0;} } else {
$intReturn1 = $myVisClass->parseSelectMulti('tbl_host','host_name','host','tbl_lnkHostdependencyToHost_H',2,$intFieldId); $intFieldId = 0;
if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Process time period selection field $intReturn = $myVisClass->parseSelectMulti(
if (isset($arrModifyData['dependency_period'])) {$intFieldId = $arrModifyData['dependency_period'];} else {$intFieldId = 0;} 'tbl_host',
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','timeperiod',1,$intFieldId); 'host_name',
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); 'depend_host',
// Process host group selection field 'tbl_lnkHostdependencyToHost_DH',
if (isset($arrModifyData['dependent_hostgroup_name'])) {$intFieldId = $arrModifyData['dependent_hostgroup_name'];} else {$intFieldId = 0;} 2,
$intReturn = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','depend_hostgroup','tbl_lnkHostdependencyToHostgroup_DH',2,$intFieldId); $intFieldId
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); );
if (isset($arrModifyData['hostgroup_name'])) {$intFieldId = $arrModifyData['hostgroup_name'];} else {$intFieldId = 0;} if ($intReturn != 0) {
$intReturn2 = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','hostgroup','tbl_lnkHostdependencyToHostgroup_H',2,$intFieldId); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
if (($intReturn1 != 0) && ($intReturn2 != 0)) { if (isset($arrModifyData['host_name'])) {
$myVisClass->processMessage(translate('Attention, no hosts and hostgroups defined!'),$strDBWarning); $intFieldId = $arrModifyData['host_name'];
$intDataWarning = 1; } else {
} $intFieldId = 0;
// Process access group selection field }
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} $intReturn1 = $myVisClass->parseSelectMulti(
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); 'tbl_host',
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); 'host_name',
// Initial add/modify form definitions 'host',
$myContentClass->addFormInit($conttp); 'tbl_lnkHostdependencyToHost_H',
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); 2,
// Insert data from database in "modify" mode $intFieldId
if (isset($arrModifyData) && ($chkSelModify == "modify")) { );
// Check relation information to find out locked configuration datasets if ($intReturn1 != 0) {
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); }
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; // Process time period selection field
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; if (isset($arrModifyData['dependency_period'])) {
// Process data $intFieldId = $arrModifyData['dependency_period'];
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo); } else {
if ($arrModifyData['inherits_parent'] == 1) $conttp->setVariable("ACT_INHERIT","checked"); $intFieldId = 0;
foreach(explode(",",$arrModifyData['execution_failure_criteria']) AS $elem) { }
$conttp->setVariable("DAT_EO".strtoupper($elem)."_CHECKED","checked"); $intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'timeperiod', 1, $intFieldId);
} if ($intReturn != 0) {
foreach(explode(",",$arrModifyData['notification_failure_criteria']) AS $elem) { $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$conttp->setVariable("DAT_NO".strtoupper($elem)."_CHECKED","checked"); }
} // Process host group selection field
} if (isset($arrModifyData['dependent_hostgroup_name'])) {
$conttp->parse("datainsert"); $intFieldId = $arrModifyData['dependent_hostgroup_name'];
$conttp->show("datainsert"); } else {
$intFieldId = 0;
}
$intReturn = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
'depend_hostgroup',
'tbl_lnkHostdependencyToHostgroup_DH',
2,
$intFieldId
);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['hostgroup_name'])) {
$intFieldId = $arrModifyData['hostgroup_name'];
} else {
$intFieldId = 0;
}
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_hostgroup',
'hostgroup_name',
'hostgroup',
'tbl_lnkHostdependencyToHostgroup_H',
2,
$intFieldId
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intReturn2 != 0)) {
$myVisClass->processMessage(translate('Attention, no hosts and hostgroups defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
if ($arrModifyData['inherits_parent'] == 1) {
$conttp->setVariable('ACT_INHERIT', 'checked');
}
foreach (explode(',', $arrModifyData['execution_failure_criteria']) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['notification_failure_criteria']) as $elem) {
$conttp->setVariable('DAT_NO' .strtoupper($elem). '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Config name')); $mastertp->setVariable('TITLE', translate('Define host dependencies (hostdependencies.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Dependent hosts')." / ".translate('Dependent hostgroups')); $mastertp->setVariable('FIELD_1', translate('Config name'));
$mastertp->setVariable("DISABLE_SORT_2","disable"); $mastertp->setVariable('FIELD_2', translate('Dependent hosts'). ' / ' .translate('Dependent hostgroups'));
// Process search string $mastertp->setVariable('DISABLE_SORT_2', 'disable');
if ($_SESSION['search'][$preSearchSession] != "") { // Process search string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')"; $strSearchTxt = $_SESSION['search'][$preSearchSession];
} $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')";
// Row sorting }
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
$mastertp->setVariable("DISABLE_SORT_2","disable"); if ($hidSortBy == 2) {
// Count datasets $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; }
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); $mastertp->setVariable('DISABLE_SORT_2', 'disable');
if ($booReturn == false) { // Count datasets
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
} else { $booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
$intLineCount = (int)$arrDataLinesCount['number']; if ($booReturn == false) {
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
} $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
// Get datasets } else {
$strSQL = "SELECT `id`, `$preKeyField`, `dependent_host_name`, `dependent_hostgroup_name`, `register`, `active`, `config_id`, `access_group` $intLineCount = (int)$arrDataLinesCount['number'];
FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) if ($intLineCount < $chkLimit) {
$strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; $chkLimit = 0;
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); }
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); // Get datasets
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $strSQL = "SELECT `id`, `$preKeyField`, `dependent_host_name`, `dependent_hostgroup_name`, `register`, "
} . "`active`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND "
// Process data . "`access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'process_field',40); $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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,222 +5,386 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Host escalation definition // Component : Host escalation definition
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 20; $prePageId = 20;
$preContent = "admin/hostescalations.tpl.htm"; $preContent = 'admin/hostescalations.htm.tpl';
$preSearchSession = 'hostescalation'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_hostescalation'; $preSearchSession = 'hostescalation';
$preKeyField = 'config_name'; $preTableName = 'tbl_hostescalation';
$preAccess = 1; $preKeyField = 'config_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Data processing // Data processing
// =============== // ===============
$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c,0,-1); $strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c, 0, -1);
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `host_name`=$intMselValue3, `hostgroup_name`=$intMselValue4, `contacts`=$intMselValue1, $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `host_name`=$intMselValue3, "
`contact_groups`=$intMselValue2, `first_notification`=$chkTfNullVal1, `last_notification`=$chkTfNullVal2, `notification_interval`=$chkTfNullVal3, . "`hostgroup_name`=$intMselValue4, `contacts`=$intMselValue1, `contact_groups`=$intMselValue2, "
`escalation_period`='$chkSelValue1', `escalation_options`='$strEO', $preSQLCommon1"; . "`first_notification`=$chkTfNullVal1, `last_notification`=$chkTfNullVal2, "
if ($chkModus == "insert") { . "`notification_interval`=$chkTfNullVal3, `escalation_period`='$chkSelValue1', "
$strSQL = "INSERT INTO ".$strSQLx; . "`escalation_options`='$strEO', $preSQLCommon1";
} else { if ($chkModus == 'insert') {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; $strSQL = 'INSERT INTO ' .$strSQLx;
} } else {
if ($intWriteAccessId == 0) { $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ((($intMselValue3 != 0) || ($chkMselValue4 != 0)) && (($intMselValue1 != 0) || ($intMselValue2 != 0)) && }
($chkTfNullVal1 != "NULL") && ($chkTfNullVal2 != "NULL") && ($chkTfNullVal3 != "NULL")) { if ($intWriteAccessId == 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if ((($intMselValue3 != 0) || ($chkMselValue4 != 0)) && (($intMselValue1 != 0) || ($intMselValue2 != 0)) &&
if ($chkModus == "insert") $chkDataId = $intInsertId; ($chkTfNullVal1 != 'NULL') && ($chkTfNullVal2 != 'NULL') && ($chkTfNullVal3 != 'NULL')) {
if ($intReturn == 1) { $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($chkModus == 'insert') {
} else { $chkDataId = $intInsertId;
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); }
$myDataClass->updateStatusTable($preTableName); if ($intReturn == 1) {
if ($chkModus == "insert") $myDataClass->writeLog(translate('New host escalation inserted:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "modify") $myDataClass->writeLog(translate('Host escalation modified:')." ".$chkTfValue1); } else {
// $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
// Insert/update relations $myDataClass->updateStatusTable($preTableName);
// ======================= if ($chkModus == 'insert') {
if ($chkModus == "insert") { $myDataClass->writeLog(translate('New host escalation inserted:'). ' ' .$chkTfValue1);
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkHostescalationToContact",$chkDataId,$chkMselValue1); }
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($chkModus == 'modify') {
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkHostescalationToContactgroup",$chkDataId,$chkMselValue2); $myDataClass->writeLog(translate('Host escalation modified:'). ' ' .$chkTfValue1);
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); // Insert/update relations
if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkHostescalationToHostgroup",$chkDataId,$chkMselValue4); // =======================
if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($chkModus == 'insert') {
} else if ($chkModus == "modify") { if ($intMselValue1 != 0) {
if ($intMselValue1 != 0) { $intRet1 = $myDataClass->dataInsertRelation(
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkHostescalationToContact",$chkDataId,$chkMselValue1); 'tbl_lnkHostescalationToContact',
} else { $chkDataId,
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkHostescalationToContact",$chkDataId); $chkMselValue1
} );
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
if ($intMselValue2 != 0) { if (isset($intRet1) && ($intRet1 != 0)) {
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkHostescalationToContactgroup",$chkDataId,$chkMselValue2); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else { }
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkHostescalationToContactgroup",$chkDataId); if ($intMselValue2 != 0) {
} $intRet2 = $myDataClass->dataInsertRelation(
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); 'tbl_lnkHostescalationToContactgroup',
if ($intMselValue3 != 0) { $chkDataId,
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkHostescalationToHost",$chkDataId,$chkMselValue3); $chkMselValue2
} else { );
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkHostescalationToHost",$chkDataId); }
} if (isset($intRet2) && ($intRet2 != 0)) {
if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($intMselValue4 != 0) { }
$intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkHostescalationToHostgroup",$chkDataId,$chkMselValue4); if ($intMselValue3 != 0) {
} else { $intRet3 = $myDataClass->dataInsertRelation(
$intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkHostescalationToHostgroup",$chkDataId); 'tbl_lnkHostescalationToHost',
} $chkDataId,
if ($intRet4 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkMselValue3
} );
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) $strInfoMessage = ""; }
// if (isset($intRet3) && ($intRet3 != 0)) {
// Update Import HASH $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
// ================== }
$booReturn = $myDataClass->updateHash($preTableName,$chkDataId); if ($intMselValue4 != 0) {
if ($booReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $intRet4 = $myDataClass->dataInsertRelation(
} 'tbl_lnkHostescalationToHostgroup',
} else { $chkDataId,
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); $chkMselValue4
} );
} else { }
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); if (isset($intRet4) && ($intRet4 != 0)) {
} $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$chkModus = "display"; }
} 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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Define host escalation (hostescalations.cfg)'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Define host escalation (hostescalations.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Process host and host group selection field $intNoTime = 1;
if (isset($arrModifyData['host_name'])) {$intFieldId = $arrModifyData['host_name'];} else {$intFieldId = 0;} // Process host and host group selection field
$intReturn1 = $myVisClass->parseSelectMulti('tbl_host','host_name','host','tbl_lnkHostescalationToHost',2,$intFieldId); if (isset($arrModifyData['host_name'])) {
if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId = $arrModifyData['host_name'];
if (isset($arrModifyData['hostgroup_name'])) {$intFieldId = $arrModifyData['hostgroup_name'];} else {$intFieldId = 0;} } else {
$intReturn2 = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','hostgroup','tbl_lnkHostescalationToHostgroup',2,$intFieldId); $intFieldId = 0;
if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
if (($intReturn1 != 0) && ($intReturn2 != 0)) { $intReturn1 = $myVisClass->parseSelectMulti(
$myVisClass->processMessage(translate('Attention, no hosts and hostgroups defined!'),$strDBWarning); 'tbl_host',
$intDataWarning = 1; 'host_name',
} 'host',
// Process timeperiod selection field 'tbl_lnkHostescalationToHost',
if (isset($arrModifyData['escalation_period'])) {$intFieldId = $arrModifyData['escalation_period'];} else {$intFieldId = 0;} 2,
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','escperiod',1,$intFieldId); $intFieldId
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); );
// Process contact and contact group selection field if ($intReturn1 != 0) {
if (isset($arrModifyData['contacts'])) {$intFieldId = $arrModifyData['contacts'];} else {$intFieldId = 0;} $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$intReturn1 = $myVisClass->parseSelectMulti('tbl_contact','contact_name','contact','tbl_lnkHostescalationToContact',2,$intFieldId); }
if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); if (isset($arrModifyData['hostgroup_name'])) {
if (isset($arrModifyData['contact_groups'])) {$intFieldId = $arrModifyData['contact_groups'];} else {$intFieldId = 0;} $intFieldId = $arrModifyData['hostgroup_name'];
$intReturn2 = $myVisClass->parseSelectMulti('tbl_contactgroup','contactgroup_name','contactgroup','tbl_lnkHostescalationToContactgroup',2,$intFieldId); } else {
if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId = 0;
if (($intReturn1 != 0) && ($intReturn2 != 0)) { }
$myVisClass->processMessage(translate('Attention, no contacts and contactgroups defined!'),$strDBWarning); $intReturn2 = $myVisClass->parseSelectMulti(
$intDataWarning = 1; 'tbl_hostgroup',
} 'hostgroup_name',
// Process access group selection field 'hostgroup',
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} 'tbl_lnkHostescalationToHostgroup',
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); 2,
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId
// Initial add/modify form definitions );
$myContentClass->addFormInit($conttp); if ($intReturn2 != 0) {
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
// Insert data from database in "modify" mode }
if (isset($arrModifyData) && ($chkSelModify == "modify")) { if (($intReturn1 != 0) && ($intReturn2 != 0)) {
// Check relation information to find out locked configuration datasets $myVisClass->processMessage(translate('Attention, no hosts and hostgroups defined!'), $strDBWarning);
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); $intDataWarning = 1;
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); }
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; // Process timeperiod selection field
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; if (isset($arrModifyData['escalation_period'])) {
// Process data $intFieldId = $arrModifyData['escalation_period'];
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo); } else {
foreach(explode(",",$arrModifyData['escalation_options']) AS $elem) { $intFieldId = 0;
$conttp->setVariable("DAT_EO".strtoupper($elem)."_CHECKED","checked"); }
} $intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'escperiod', 1, $intFieldId);
} if ($intReturn != 0) {
$conttp->parse("datainsert"); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$conttp->show("datainsert"); }
// Process contact and contact group selection field
if (isset($arrModifyData['contacts'])) {
$intFieldId = $arrModifyData['contacts'];
} else {
$intFieldId = 0;
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_contact',
'contact_name',
'contact',
'tbl_lnkHostescalationToContact',
2,
$intFieldId
);
if ($intReturn1 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['contact_groups'])) {
$intFieldId = $arrModifyData['contact_groups'];
} else {
$intFieldId = 0;
}
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
'contactgroup',
'tbl_lnkHostescalationToContactgroup',
2,
$intFieldId
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intReturn2 != 0)) {
$myVisClass->processMessage(translate('Attention, no contacts and contactgroups defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
foreach (explode(',', $arrModifyData['escalation_options']) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Config name')); $mastertp->setVariable('TITLE', translate('Define host escalation (hostescalations.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Hosts')." / ".translate('Host groups')); $mastertp->setVariable('FIELD_1', translate('Config name'));
// Process search string $mastertp->setVariable('FIELD_2', translate('Hosts'). ' / ' .translate('Host groups'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process search string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')"; $strSearchTxt = $_SESSION['search'][$preSearchSession];
} $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')";
// Row sorting }
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
$mastertp->setVariable("DISABLE_SORT_2","disable"); if ($hidSortBy == 2) {
// Count datasets $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; }
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); $mastertp->setVariable('DISABLE_SORT_2', 'disable');
if ($booReturn == false) { // Count datasets
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
} else { $booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
$intLineCount = (int)$arrDataLinesCount['number']; if ($booReturn == false) {
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
} $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
// Get datasets } else {
$strSQL = "SELECT `id`, `$preKeyField`, `host_name`, `hostgroup_name`, `register`, `active`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $intLineCount = (int)$arrDataLinesCount['number'];
$strSearchWhere AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; if ($intLineCount < $chkLimit) {
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); $chkLimit = 0;
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); }
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); // Get datasets
} $strSQL = "SELECT `id`, `$preKeyField`, `host_name`, `hostgroup_name`, `register`, `active`, `config_id`, "
// Process data . "`access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'process_field',40); . "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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,155 +5,198 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Host extended information definition // Component : Host extended information definition
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 21; $prePageId = 21;
$preContent = "admin/hostextinfo.tpl.htm"; $preContent = 'admin/hostextinfo.htm.tpl';
$preSearchSession = 'hostextinfo'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_hostextinfo'; $preSearchSession = 'hostextinfo';
$preKeyField = 'host_name'; $preTableName = 'tbl_hostextinfo';
$preAccess = 1; $preKeyField = 'host_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`=$chkSelValue1, `notes`='$chkTfValue1', `notes_url`='$chkTfValue2', `action_url`='$chkTfValue3', `icon_image`='$chkTfValue4', $strSQLx = "`$preTableName` SET `$preKeyField`=$chkSelValue1, `notes`='$chkTfValue1', `notes_url`='$chkTfValue2', "
`icon_image_alt`='$chkTfValue5', `vrml_image`='$chkTfValue6', `statusmap_image`='$chkTfValue7', `2d_coords`='$chkTfValue8', `3d_coords`='$chkTfValue9', . "`action_url`='$chkTfValue3', `icon_image`='$chkTfValue4', `icon_image_alt`='$chkTfValue5', "
$preSQLCommon1"; . "`vrml_image`='$chkTfValue6', `statusmap_image`='$chkTfValue7', `2d_coords`='$chkTfValue8', "
if ($chkModus == "insert") { . "`3d_coords`='$chkTfValue9', $preSQLCommon1";
$strSQL = "INSERT INTO ".$strSQLx; if ($chkModus == 'insert') {
} else { $strSQL = 'INSERT INTO ' .$strSQLx;
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; } else {
} $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ($intWriteAccessId == 0) { }
if ($chkSelValue1 != 0) { if ($intWriteAccessId == 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if ($chkSelValue1 != 0) {
if ($chkModus == "insert") $chkDataId = $intInsertId; $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn == 1) { if ($chkModus == 'insert') {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId = $intInsertId;
} else { }
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($intReturn == 1) {
$myDataClass->updateStatusTable($preTableName); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "insert") $myDataClass->writeLog(translate('New host extended information inserted:')." ".$chkSelValue1); } else {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Host extended information modified:')." ".$chkSelValue1); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
} $myDataClass->updateStatusTable($preTableName);
} else { if ($chkModus == 'insert') {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); $myDataClass->writeLog(translate('New host extended information inserted:'). ' ' .$chkSelValue1);
} }
} else { if ($chkModus == 'modify') {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); $myDataClass->writeLog(translate('Host extended information modified:'). ' ' .$chkSelValue1);
} }
$chkModus = "display"; }
} 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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Define host extended information (hostextinfo.cfg)'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Define host extended information (hostextinfo.cfg)'));
$intNoTime = 1; // Do not show modified time list
if (isset($arrModifyData[$preKeyField])) {$intFieldId = $arrModifyData[$preKeyField];} else {$intFieldId = 0;} $intNoTime = 1;
$intReturn1 = $myVisClass->parseSelectSimple('tbl_host',$preKeyField,'host',0,$intFieldId); if (isset($arrModifyData[$preKeyField])) {
if ($intReturn1 != 0) { $intFieldId = $arrModifyData[$preKeyField];
$myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); } else {
$myVisClass->processMessage(translate('Attention, no hosts defined!'),$strDBWarning); $intFieldId = 0;
$intDataWarning = 1; }
} $intReturn1 = $myVisClass->parseSelectSimple('tbl_host', $preKeyField, 'host', 0, $intFieldId);
// Process access group selection field if ($intReturn1 != 0) {
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); $myVisClass->processMessage(translate('Attention, no hosts defined!'), $strDBWarning);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intDataWarning = 1;
// Initial add/modify form definitions }
$myContentClass->addFormInit($conttp); // Process access group selection field
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); if (isset($arrModifyData['access_group'])) {
if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,"); $intFieldId = $arrModifyData['access_group'];
// Insert data from database in "modify" mode } else {
if (isset($arrModifyData) && ($chkSelModify == "modify")) { $intFieldId = 0;
// Check relation information to find out locked configuration datasets }
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); $intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); if ($intReturn != 0) {
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; }
// Process data // Initial add/modify form definitions
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo); $myContentClass->addFormInit($conttp);
} if ($intDataWarning == 1) {
$conttp->parse("datainsert"); $conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
$conttp->show("datainsert"); }
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Host name')); $mastertp->setVariable('TITLE', translate('Define host extended information (hostextinfo.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Notes')); $mastertp->setVariable('FIELD_1', translate('Host name'));
// Process search string $mastertp->setVariable('FIELD_2', translate('Notes'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process search string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`tbl_host`.`$preKeyField` LIKE '%".$strSearchTxt."%' OR `$preTableName`.`notes` LIKE '%".$strSearchTxt."%' $strSearchTxt = $_SESSION['search'][$preSearchSession];
OR `$preTableName`.`notes_url` LIKE '%".$strSearchTxt."%')"; $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"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `$preTableName`.`config_id`, `notes` $hidSortDir"; $strOrderString = "ORDER BY `$preTableName`.`config_id`, `$preKeyField` $hidSortDir";
// Count datasets if ($hidSortBy == 2) {
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField`=`tbl_host`.`id` $strOrderString = "ORDER BY `$preTableName`.`config_id`, `notes` $hidSortDir";
WHERE $strDomainWhere $strSearchWhere AND `$preTableName`.`access_group` IN ($strAccess)"; }
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); // Count datasets
if ($booReturn == false) { $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); . "LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField`=`tbl_host`.`id` "
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "WHERE $strDomainWhere $strSearchWhere AND `$preTableName`.`access_group` IN ($strAccess)";
} else { $booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
$intLineCount = (int)$arrDataLinesCount['number']; if ($booReturn == false) {
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
} $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
// Get datasets } else {
$strSQL = "SELECT `$preTableName`.`id`, `tbl_host`.`$preKeyField`, `$preTableName`.`notes`, `$preTableName`.`register`, `$preTableName`.`active`, $intLineCount = (int)$arrDataLinesCount['number'];
`$preTableName`.`config_id`, `$preTableName`.`access_group` if ($intLineCount < $chkLimit) {
FROM `$preTableName` LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField` = `tbl_host`.`id` $chkLimit = 0;
WHERE $strDomainWhere $strSearchWhere AND `$preTableName`.`access_group` IN ($strAccess) }
$strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; }
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); // Get datasets
if ($booReturn == false) { $strSQL = "SELECT `$preTableName`.`id`, `tbl_host`.`$preKeyField`, `$preTableName`.`notes`, "
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); . "`$preTableName`.`register`, `$preTableName`.`active`, `$preTableName`.`config_id`, "
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "`$preTableName`.`access_group` FROM `$preTableName` "
} . "LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField` = `tbl_host`.`id` "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'notes'); . "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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,178 +5,275 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Hostgroup definition // Component : Hostgroup definition
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 10; $prePageId = 10;
$preContent = "admin/hostgroups.tpl.htm"; $preContent = 'admin/hostgroups.htm.tpl';
$preSearchSession = 'hostgroup'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_hostgroup'; $preSearchSession = 'hostgroup';
$preKeyField = 'hostgroup_name'; $preTableName = 'tbl_hostgroup';
$preAccess = 1; $preKeyField = 'hostgroup_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, `hostgroup_members`=$intMselValue2, $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, "
`notes`='$chkTfValue3', `notes_url`='$chkTfValue4', `action_url`='$chkTfValue5', $preSQLCommon1"; . "`hostgroup_members`=$intMselValue2, `notes`='$chkTfValue3', `notes_url`='$chkTfValue4', "
if ($chkModus == "insert") { . "`action_url`='$chkTfValue5', $preSQLCommon1";
$strSQL = "INSERT INTO ".$strSQLx; if ($chkModus == 'insert') {
} else { $strSQL = 'INSERT INTO ' .$strSQLx;
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; } else {
} $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ($intWriteAccessId == 0) { }
if (($chkTfValue1 != "") && ($chkTfValue2 != "") && (($intMselValue1 != 0) || ($intVersion == 3))) { if ($intWriteAccessId == 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($intMselValue1 != 0) || ($intVersion >= 3))) {
if ($chkModus == "insert") $chkDataId = $intInsertId; $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn == 1) { if ($chkModus == 'insert') {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId = $intInsertId;
} else { }
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($intReturn == 1) {
$myDataClass->updateStatusTable($preTableName); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "insert") $myDataClass->writeLog(translate('New host group inserted:')." ".$chkTfValue1); } else {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Host group modified:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
// $myDataClass->updateStatusTable($preTableName);
// Insert/update relations if ($chkModus == 'insert') {
// ======================= $myDataClass->writeLog(translate('New host group inserted:'). ' ' .$chkTfValue1);
if ($chkModus == "insert") { }
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkHostgroupToHost",$chkDataId,$chkMselValue1); if ($chkModus == 'modify') {
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myDataClass->writeLog(translate('Host group modified:'). ' ' .$chkTfValue1);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkHostgroupToHostgroup",$chkDataId,$chkMselValue2); }
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); //
} else if ($chkModus == "modify") { // Insert/update relations
if ($intMselValue1 != 0) { // =======================
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkHostgroupToHost",$chkDataId,$chkMselValue1); if ($chkModus == 'insert') {
} else { if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkHostgroupToHost",$chkDataId); $intRet1 = $myDataClass->dataInsertRelation(
} 'tbl_lnkHostgroupToHost',
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId,
if ($intMselValue2 != 0) { $chkMselValue1
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkHostgroupToHostgroup",$chkDataId,$chkMselValue2); );
} else { }
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkHostgroupToHostgroup",$chkDataId); if (isset($intRet1) && ($intRet1 != 0)) {
} $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} if ($intMselValue2 != 0) {
if (($intRet1 + $intRet2) != 0) $strInfoMessage = ""; $intRet2 = $myDataClass->dataInsertRelation(
} 'tbl_lnkHostgroupToHostgroup',
} else { $chkDataId,
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); $chkMselValue2
} );
} else { }
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); if (isset($intRet2) && ($intRet2 != 0)) {
} $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$chkModus = "display"; }
} 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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Define host groups (hostgroups.cfg)'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Define host groups (hostgroups.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Process host selection field $intNoTime = 1;
if (isset($arrModifyData['members'])) {$intFieldId = $arrModifyData['members'];} else {$intFieldId = 0;} // Process host selection field
$intReturn = $myVisClass->parseSelectMulti('tbl_host','host_name','host_members','tbl_lnkHostgroupToHost',2,$intFieldId); if (isset($arrModifyData['members'])) {
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId = $arrModifyData['members'];
if (($intReturn != 0) && ($intVersion != 3)) { } else {
$myVisClass->processMessage(translate('Attention, no hosts defined!'),$strDBWarning); $intFieldId = 0;
$intDataWarning = 1; }
} $intReturn1 = $myVisClass->parseSelectMulti(
// Process host group selection field 'tbl_host',
if (isset($arrModifyData['hostgroup_members'])) {$intFieldId = $arrModifyData['hostgroup_members'];} else {$intFieldId = 0;} 'host_name',
$intReturn = $myVisClass->parseSelectMulti($preTableName,$preKeyField,'hostgroups','tbl_lnkHostgroupToHostgroup',0,$intFieldId,$chkListId); 'host_members',
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); 'tbl_lnkHostgroupToHost',
// Process access group selection field 2,
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} $intFieldId
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); );
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); if ($intReturn1 != 0) {
// Initial add/modify form definitions $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myContentClass->addFormInit($conttp); }
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); if (($intReturn1 != 0) && ($intVersion < 3)) {
if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,"); $myVisClass->processMessage(translate('Attention, no hosts defined!'), $strDBWarning);
// Insert data from database in "modify" mode $intDataWarning = 1;
if (isset($arrModifyData) && ($chkSelModify == "modify")) { }
// Check relation information to find out locked configuration datasets // Process host group selection field
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); if (isset($arrModifyData['hostgroup_members'])) {
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); $intFieldId = $arrModifyData['hostgroup_members'];
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; } else {
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; $intFieldId = 0;
// Process data }
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo); $intReturn2 = $myVisClass->parseSelectMulti(
} $preTableName,
$conttp->parse("datainsert"); $preKeyField,
$conttp->show("datainsert"); 'hostgroups',
'tbl_lnkHostgroupToHostgroup',
0,
$intFieldId,
$chkListId
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Host group')); $mastertp->setVariable('TITLE', translate('Define host groups (hostgroups.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Host group'));
// Process search string $mastertp->setVariable('FIELD_2', translate('Description'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process search string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' OR `notes` LIKE '%".$strSearchTxt."%')"; $strSearchTxt = $_SESSION['search'][$preSearchSession];
} $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' "
// Row sorting . "OR `notes` LIKE '%".$strSearchTxt."%')";
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; }
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir"; // Row sorting
// Count datasets $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; if ($hidSortBy == 2) {
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); // Count datasets
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $strSQL1 = "SELECT count(*) AS `number` FROM `$preTableName` "
} else { . "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
$intLineCount = (int)$arrDataLinesCount['number']; $booReturn1 = $myDBClass->hasSingleDataset($strSQL1, $arrDataLinesCount);
if ($intLineCount < $chkLimit) $chkLimit = 0; if ($booReturn1 == false) {
} $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
// Get datasets $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere } else {
AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; $intLineCount = (int)$arrDataLinesCount['number'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); if ($intLineCount < $chkLimit) {
if ($booReturn == false) { $chkLimit = 0;
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); }
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); }
} // Get datasets
// Process data $strSQL2 = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias'); . "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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

File diff suppressed because it is too large Load Diff

View File

@ -5,378 +5,590 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Hosttemplate definition // Component : Hosttemplate definition
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 12; $prePageId = 12;
$preContent = "admin/hosttemplates.tpl.htm"; $preContent = 'admin/hosttemplates.htm.tpl';
$preSearchSession = 'hosttemplate'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_hosttemplate'; $preSearchSession = 'hosttemplate';
$preKeyField = 'template_name'; $preTableName = 'tbl_hosttemplate';
$preAccess = 1; $preKeyField = 'template_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Data processing // Data processing
// =============== // ===============
$strNO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e,0,-1); $strNO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d.$chkChbGr1e, 0, -1);
$strIS = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c,0,-1); $strIS = substr($chkChbGr2a.$chkChbGr2b.$chkChbGr2c, 0, -1);
$strFL = substr($chkChbGr3a.$chkChbGr3b.$chkChbGr3c,0,-1); $strFL = substr($chkChbGr3a.$chkChbGr3b.$chkChbGr3c, 0, -1);
$strST = substr($chkChbGr4a.$chkChbGr4b.$chkChbGr4c,0,-1); $strST = substr($chkChbGr4a.$chkChbGr4b.$chkChbGr4c, 0, -1);
if ($chkSelValue1 != "") { if ($chkSelValue1 != '') {
for ($i=1;$i<=8;$i++) { for ($i = 1; $i <= 8; $i++) {
if (${"chkTfArg$i"} != "") $chkSelValue1 .= "!".${"chkTfArg$i"}; $tmpVar = 'chkTfArg'.$i;
} $$tmpVar = str_replace('!', '::bang::', $$tmpVar);
if ($$tmpVar != '') {
$chkSelValue1 .= '!' .$$tmpVar;
}
}
} }
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `parents`=$intMselValue1, `parents_tploptions`=$chkRadValue1, $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `parents`=$intMselValue1, "
`hostgroups`=$intMselValue2, `hostgroups_tploptions`=$chkRadValue2, `check_command`='$chkSelValue1', `use_template`=$intTemplates, `initial_state`='$strIS', . "`parents_tploptions`=$chkRadValue1, `importance`=$chkTfNullVal9, `hostgroups`=$intMselValue2, "
`max_check_attempts`=$chkTfNullVal2, `check_interval`=$chkTfNullVal3, `retry_interval`=$chkTfNullVal1, `active_checks_enabled`=$chkRadValue5, . "`hostgroups_tploptions`=$chkRadValue2, `check_command`='$chkSelValue1', `use_template`=$intTemplates, "
`passive_checks_enabled`=$chkRadValue6, `check_period`=$chkSelValue2, `obsess_over_host`=$chkRadValue8, `check_freshness`=$chkRadValue7, . "`initial_state`='$strIS', `max_check_attempts`=$chkTfNullVal2, `check_interval`=$chkTfNullVal3, "
`freshness_threshold`=$chkTfNullVal4, `event_handler`=$chkSelValue3, `event_handler_enabled`=$chkRadValue9, `low_flap_threshold`=$chkTfNullVal5, . "`retry_interval`=$chkTfNullVal1, `active_checks_enabled`=$chkRadValue5, "
`high_flap_threshold`=$chkTfNullVal6, `flap_detection_enabled`=$chkRadValue10, `flap_detection_options`='$strFL', `process_perf_data`=$chkRadValue13, . "`passive_checks_enabled`=$chkRadValue6, `check_period`=$chkSelValue2, "
`retain_status_information`=$chkRadValue11, `retain_nonstatus_information`=$chkRadValue12, `contacts`=$intMselValue3, `contacts_tploptions`=$chkRadValue3, . "`obsess_over_host`=$chkRadValue8, `check_freshness`=$chkRadValue7, "
`contact_groups`=$intMselValue4, `contact_groups_tploptions`=$chkRadValue4, `notification_interval`=$chkTfNullVal7, `notification_period`=$chkSelValue4, . "`freshness_threshold`=$chkTfNullVal4, `event_handler`=$chkSelValue3, "
`first_notification_delay`=$chkTfNullVal8, `notification_options`='$strNO', `notifications_enabled`=$chkRadValue14, `stalking_options`='$strST', . "`event_handler_enabled`=$chkRadValue9, `low_flap_threshold`=$chkTfNullVal5, "
`notes`='$chkTfValue3', `notes_url`='$chkTfValue5', `action_url`='$chkTfValue7', `icon_image`='$chkTfValue8', `icon_image_alt`='$chkTfValue10', . "`high_flap_threshold`=$chkTfNullVal6, `flap_detection_enabled`=$chkRadValue10, "
`vrml_image`='$chkTfValue4', `statusmap_image`='$chkTfValue6', `2d_coords`='$chkTfValue9', `3d_coords`='$chkTfValue11', `use_variables`=$intVariables, . "`flap_detection_options`='$strFL', `process_perf_data`=$chkRadValue13, "
$preSQLCommon2"; . "`retain_status_information`=$chkRadValue11, `retain_nonstatus_information`=$chkRadValue12, "
if ($chkModus == "insert") { . "`contacts`=$intMselValue3, `contacts_tploptions`=$chkRadValue3, `contact_groups`=$intMselValue4, "
$strSQL = "INSERT INTO ".$strSQLx; . "`contact_groups_tploptions`=$chkRadValue4, `notification_interval`=$chkTfNullVal7, "
} else { . "`notification_period`=$chkSelValue4, `first_notification_delay`=$chkTfNullVal8, "
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; . "`notification_options`='$strNO', `notifications_enabled`=$chkRadValue14, `stalking_options`='$strST', "
} . "`notes`='$chkTfValue3', `notes_url`='$chkTfValue5', `action_url`='$chkTfValue7', "
if ($intWriteAccessId == 0) { . "`icon_image`='$chkTfValue8', `icon_image_alt`='$chkTfValue10', `vrml_image`='$chkTfValue4', "
if ($chkTfValue1 != "") { . "`statusmap_image`='$chkTfValue6', `2d_coords`='$chkTfValue9', `3d_coords`='$chkTfValue11', "
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); . "`use_variables`=$intVariables, $preSQLCommon2";
if ($chkModus == "insert") $chkDataId = $intInsertId; if ($chkModus == 'insert') {
if ($intReturn == 1) { $strSQL = 'INSERT INTO ' .$strSQLx;
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); } else {
} else { $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); }
$myDataClass->updateStatusTable($preTableName); if ($intWriteAccessId == 0) {
if ($chkModus == "insert") $myDataClass->writeLog(translate('New host template inserted:')." ".$chkTfValue1); if ($chkTfValue1 != '') {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Host template modified:')." ".$chkTfValue1); $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
// if ($chkModus == 'insert') {
// Insert/update relations $chkDataId = $intInsertId;
// ======================= }
if ($chkModus == "insert") { if ($intReturn == 1) {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkHosttemplateToHost",$chkDataId,$chkMselValue1); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); } else {
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkHosttemplateToHostgroup",$chkDataId,$chkMselValue2); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myDataClass->updateStatusTable($preTableName);
if ($intMselValue3 != 0) $intRet3 = $myDataClass->dataInsertRelation("tbl_lnkHosttemplateToContact",$chkDataId,$chkMselValue3); if ($chkModus == 'insert') {
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myDataClass->writeLog(translate('New host template inserted:'). ' ' .$chkTfValue1);
if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkHosttemplateToContactgroup",$chkDataId,$chkMselValue4); }
if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($chkModus == 'modify') {
} else if ($chkModus == "modify") { $myDataClass->writeLog(translate('Host template modified:'). ' ' .$chkTfValue1);
if ($intMselValue1 != 0) { }
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkHosttemplateToHost",$chkDataId,$chkMselValue1); //
} else { // Insert/update relations
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkHosttemplateToHost",$chkDataId); // =======================
} if ($chkModus == 'insert') {
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($intMselValue1 != 0) {
if ($intMselValue2 != 0) { $intRet1 = $myDataClass->dataInsertRelation(
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkHosttemplateToHostgroup",$chkDataId,$chkMselValue2); 'tbl_lnkHosttemplateToHost',
} else { $chkDataId,
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkHosttemplateToHostgroup",$chkDataId); $chkMselValue1
} );
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
if ($intMselValue3 != 0) { if (isset($intRet1) && ($intRet1 != 0)) {
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkHosttemplateToContact",$chkDataId,$chkMselValue3); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else { }
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkHosttemplateToContact",$chkDataId); if ($intMselValue2 != 0) {
} $intRet2 = $myDataClass->dataInsertRelation(
if ($intRet3 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); 'tbl_lnkHosttemplateToHostgroup',
if ($intMselValue4 != 0) { $chkDataId,
$intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkHosttemplateToContactgroup",$chkDataId,$chkMselValue4); $chkMselValue2
} else { );
$intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkHosttemplateToContactgroup",$chkDataId); }
} if (isset($intRet2) && ($intRet2 != 0)) {
if ($intRet4 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
if (($intRet1 + $intRet2 + $intRet3 + $intRet4) != 0) $strInfoMessage = ""; if ($intMselValue3 != 0) {
// $intRet3 = $myDataClass->dataInsertRelation(
// Insert/update session data for templates 'tbl_lnkHosttemplateToContact',
// ======================================== $chkDataId,
if ($chkModus == "modify") { $chkMselValue3
$strSQL = "DELETE FROM `tbl_lnkHosttemplateToHosttemplate` WHERE `idMaster`=$chkDataId"; );
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); }
if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if (isset($intRet3) && ($intRet3 != 0)) {
} $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) && (count($_SESSION['templatedefinition']) != 0)) { }
$intSortId = 1; if ($intMselValue4 != 0) {
foreach($_SESSION['templatedefinition'] AS $elem) { $intRet4 = $myDataClass->dataInsertRelation(
if ($elem['status'] == 0) { 'tbl_lnkHosttemplateToContactgroup',
$strSQL = "INSERT INTO `tbl_lnkHosttemplateToHosttemplate` (`idMaster`,`idSlave`,`idTable`,`idSort`) $chkDataId,
VALUES ($chkDataId,".$elem['idSlave'].",".$elem['idTable'].",".$intSortId.")"; $chkMselValue4
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); );
if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} if (isset($intRet4) && ($intRet4 != 0)) {
$intSortId++; $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
} } elseif ($chkModus == 'modify') {
// if ($intMselValue1 != 0) {
// Insert/update session data for free variables $intRet1 = $myDataClass->dataUpdateRelation(
// ============================================= 'tbl_lnkHosttemplateToHost',
if ($chkModus == "modify") { $chkDataId,
$strSQL = "SELECT * FROM `tbl_lnkHosttemplateToVariabledefinition` WHERE `idMaster`=$chkDataId"; $chkMselValue1
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); );
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); } else {
if ($intDataCount != 0) { $intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToHost', $chkDataId);
foreach ($arrData AS $elem) { }
$strSQL = "DELETE FROM `tbl_variabledefinition` WHERE `id`=".$elem['idSlave']; if ($intRet1 != 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} if ($intMselValue2 != 0) {
} $intRet2 = $myDataClass->dataUpdateRelation(
$strSQL = "DELETE FROM `tbl_lnkHosttemplateToVariabledefinition` WHERE `idMaster`=$chkDataId"; 'tbl_lnkHosttemplateToHostgroup',
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $chkDataId,
if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkMselValue2
} );
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) && (count($_SESSION['variabledefinition']) != 0)) { } else {
foreach($_SESSION['variabledefinition'] AS $elem) { $intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToHostgroup', $chkDataId);
if ($elem['status'] == 0) { }
$strSQL = "INSERT INTO `tbl_variabledefinition` (`name`,`value`,`last_modified`) if ($intRet2 != 0) {
VALUES ('".$elem['definition']."','".$elem['range']."',now())"; $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); }
if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($intMselValue3 != 0) {
$strSQL = "INSERT INTO `tbl_lnkHosttemplateToVariabledefinition` (`idMaster`,`idSlave`) $intRet3 = $myDataClass->dataUpdateRelation(
VALUES ($chkDataId,$intInsertId)"; 'tbl_lnkHosttemplateToContact',
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $chkDataId,
if ($intReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkMselValue3
} );
} } else {
} $intRet3 = $myDataClass->dataDeleteRelation('tbl_lnkHosttemplateToContact', $chkDataId);
} }
} else { if ($intRet3 != 0) {
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
} else { if ($intMselValue4 != 0) {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); $intRet4 = $myDataClass->dataUpdateRelation(
} 'tbl_lnkHosttemplateToContactgroup',
$chkModus = "display"; $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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Host template definition (hosttemplates.cfg)'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Host template definition (hosttemplates.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Process template fields $intNoTime = 1;
$strWhere = ""; // Process template fields
if (isset($arrModifyData) && ($chkSelModify == "modify")) { $strWhere = '';
$strWhere = "AND `id` <> ".$arrModifyData['id']; 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); $strSQL1 = "SELECT `id`,`$preKeyField`, `active` FROM `$preTableName` "
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "WHERE `config_id` = $chkDomainId $strWhere ORDER BY `$preKeyField`";
if ($intDataCountTpl != 0) { $booReturn1 = $myDBClass->hasDataArray($strSQL1, $arrDataTpl, $intDataCountTpl);
foreach ($arrDataTpl AS $elem) { if ($booReturn1 == false) {
if ($elem['active'] == 0) { $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$strActive = " [inactive]"; }
$conttp->setVariable("SPECIAL_STYLE","inactive_option"); if ($intDataCountTpl != 0) {
} else { /** @var array $arrDataTpl */
$strActive = ""; foreach ($arrDataTpl as $elem) {
$conttp->setVariable("SPECIAL_STYLE",""); if ($elem['active'] == 0) {
} $strActive = ' [inactive]';
$conttp->setVariable("DAT_TEMPLATE",htmlspecialchars($elem[$preKeyField],ENT_QUOTES,'UTF-8').$strActive); $conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
$conttp->setVariable("DAT_TEMPLATE_ID",$elem['id']."::1"); } else {
$conttp->parse("template"); $strActive = '';
} $conttp->setVariable('SPECIAL_STYLE', '');
} }
$strSQL = "SELECT `id`, `name`, `active` FROM `tbl_host` WHERE `name` <> '' AND `config_id` = $chkDomainId ORDER BY `name`"; $conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem[$preKeyField], ENT_QUOTES, 'UTF-8').$strActive);
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataHpl,$intDataCount); $conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::1');
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $conttp->parse('template');
if ($arrDataHpl != 0) { }
foreach ($arrDataHpl AS $elem) { }
if ($elem['active'] == 0) { $strSQL2 = 'SELECT `id`, `name`, `active` FROM `tbl_host` '
$strActive = " [inactive]"; . "WHERE `name` <> '' AND `config_id` = $chkDomainId ORDER BY `name`";
$conttp->setVariable("SPECIAL_STYLE","inactive_option"); $booReturn2 = $myDBClass->hasDataArray($strSQL2, $arrDataHpl, $intDataCountHpl);
} else { if ($booReturn2 == false) {
$strActive = ""; $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$conttp->setVariable("SPECIAL_STYLE",""); }
} if ($intDataCountHpl != 0) {
$conttp->setVariable("DAT_TEMPLATE",htmlspecialchars($elem['name'],ENT_QUOTES,'UTF-8').$strActive); /** @var array $arrDataHpl */
$conttp->setVariable("DAT_TEMPLATE_ID",$elem['id']."::2"); foreach ($arrDataHpl as $elem) {
$conttp->parse("template"); if ($elem['active'] == 0) {
} $strActive = ' [inactive]';
} $conttp->setVariable('SPECIAL_STYLE', 'inactive_option');
// Process host selection field } else {
if (isset($arrModifyData['parents'])) {$intFieldId = $arrModifyData['parents'];} else {$intFieldId = 0;} $strActive = '';
$intReturn = $myVisClass->parseSelectMulti('tbl_host','host_name','host_parents','tbl_lnkHosttemplateToHost',0,$intFieldId); $conttp->setVariable('SPECIAL_STYLE', '');
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Process hostgroup selection field $conttp->setVariable('DAT_TEMPLATE', htmlspecialchars($elem['name'], ENT_QUOTES, 'UTF-8').$strActive);
if (isset($arrModifyData['hostgroups'])) {$intFieldId = $arrModifyData['hostgroups'];} else {$intFieldId = 0;} $conttp->setVariable('DAT_TEMPLATE_ID', $elem['id']. '::2');
$intReturn = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','hostgroup','tbl_lnkHosttemplateToHostgroup',0,$intFieldId); $conttp->parse('template');
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Process check command selection field }
if (isset($arrModifyData['check_command']) && ($arrModifyData['check_command'] != "")) { // Process host selection field
$arrCommand = explode("!",$arrModifyData['check_command']); if (isset($arrModifyData['parents'])) {
$intFieldId = $arrCommand[0]; $intFieldId = $arrModifyData['parents'];
} else { } else {
$intFieldId = 0; $intFieldId = 0;
} }
$intReturn = $myVisClass->parseSelectSimple('tbl_command','command_name','hostcommand',1,$intFieldId); $intReturn1 = $myVisClass->parseSelectMulti(
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); 'tbl_host',
// Process check period selection field 'host_name',
$intReturn = 0; 'host_parents',
if (isset($arrModifyData['check_period'])) {$intFieldId = $arrModifyData['check_period'];} else {$intFieldId = 0;} 'tbl_lnkHosttemplateToHost',
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','checkperiod',1,$intFieldId); 0,
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId
if (isset($arrModifyData['notification_period'])) {$intFieldId = $arrModifyData['notification_period'];} else {$intFieldId = 0;} );
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','notifyperiod',1,$intFieldId); if ($intReturn1 != 0) {
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
// Process event handler selection field }
if (isset($arrModifyData['event_handler'])) {$intFieldId = $arrModifyData['event_handler'];} else {$intFieldId = 0;} // Process hostgroup selection field
$intReturn = $myVisClass->parseSelectSimple('tbl_command','command_name','eventhandler',1,$intFieldId); if (isset($arrModifyData['hostgroups'])) {
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId = $arrModifyData['hostgroups'];
// Process contact and contact group selection field } else {
if (isset($arrModifyData['contacts'])) {$intFieldId = $arrModifyData['contacts'];} else {$intFieldId = 0;} $intFieldId = 0;
$intReturn = $myVisClass->parseSelectMulti('tbl_contact','contact_name','host_contacts','tbl_lnkHosttemplateToContact',2,$intFieldId); }
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intReturn2 = $myVisClass->parseSelectMulti(
if (isset($arrModifyData['contact_groups'])) {$intFieldId = $arrModifyData['contact_groups'];} else {$intFieldId = 0;} 'tbl_hostgroup',
$intReturn = $myVisClass->parseSelectMulti('tbl_contactgroup','contactgroup_name','host_contactgroups','tbl_lnkHosttemplateToContactgroup',2,$intFieldId); 'hostgroup_name',
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); 'hostgroup',
// Process access group selection field 'tbl_lnkHosttemplateToHostgroup',
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} 0,
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); $intFieldId
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); );
// Initial add/modify form definitions if ($intReturn2 != 0) {
$strChbFields = "ACE,PCE,FRE,OBS,EVH,FLE,STI,NSI,PED,NOE,PAR,HOG,COT,COG,TPL"; $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myContentClass->addFormInit($conttp,$strChbFields); }
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); // Process check command selection field
if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,"); if (isset($arrModifyData['check_command']) && ($arrModifyData['check_command'] != '')) {
// Insert data from database in "modify" mode $arrCommand = explode('!', $arrModifyData['check_command']);
if (isset($arrModifyData) && ($chkSelModify == "modify")) { $intFieldId = $arrCommand[0];
// Check relation information to find out locked configuration datasets } else {
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); $intFieldId = 0;
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); }
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; $intReturn3 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'hostcommand', 1, $intFieldId);
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; if ($intReturn3 != 0) {
// Process data $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo,$strChbFields); }
$conttp->setVariable("DAT_ACE".$arrModifyData['active_checks_enabled']."_CHECKED","checked"); // Process check period selection field
$conttp->setVariable("DAT_PCE".$arrModifyData['passive_checks_enabled']."_CHECKED","checked"); if (isset($arrModifyData['check_period'])) {
$conttp->setVariable("DAT_FRE".$arrModifyData['check_freshness']."_CHECKED","checked"); $intFieldId = $arrModifyData['check_period'];
$conttp->setVariable("DAT_OBS".$arrModifyData['obsess_over_host']."_CHECKED","checked"); } else {
$conttp->setVariable("DAT_EVH".$arrModifyData['event_handler_enabled']."_CHECKED","checked"); $intFieldId = 0;
$conttp->setVariable("DAT_FLE".$arrModifyData['flap_detection_enabled']."_CHECKED","checked"); }
$conttp->setVariable("DAT_STI".$arrModifyData['retain_status_information']."_CHECKED","checked"); $intReturn4 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'checkperiod', 1, $intFieldId);
$conttp->setVariable("DAT_NSI".$arrModifyData['retain_nonstatus_information']."_CHECKED","checked"); if ($intReturn4 != 0) {
$conttp->setVariable("DAT_PED".$arrModifyData['process_perf_data']."_CHECKED","checked"); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$conttp->setVariable("DAT_NOE".$arrModifyData['notifications_enabled']."_CHECKED","checked"); }
$conttp->setVariable("DAT_PAR".$arrModifyData['parents_tploptions']."_CHECKED","checked"); if (isset($arrModifyData['notification_period'])) {
$conttp->setVariable("DAT_HOG".$arrModifyData['hostgroups_tploptions']."_CHECKED","checked"); $intFieldId = $arrModifyData['notification_period'];
$conttp->setVariable("DAT_COT".$arrModifyData['contacts_tploptions']."_CHECKED","checked"); } else {
$conttp->setVariable("DAT_COG".$arrModifyData['contact_groups_tploptions']."_CHECKED","checked"); $intFieldId = 0;
$conttp->setVariable("DAT_TPL".$arrModifyData['use_template_tploptions']."_CHECKED","checked"); }
// Special processing for -1 values - write 'null' to integer fields $intReturn5 = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'notifyperiod', 1, $intFieldId);
$strIntegerfelder = "max_check_attempts,check_interval,retry_interval,freshness_threshold,low_flap_threshold,high_flap_threshold,"; if ($intReturn5 != 0) {
$strIntegerfelder .= "notification_interval,first_notification_delay"; $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
foreach(explode(",",$strIntegerfelder) AS $elem) { }
if ($arrModifyData[$elem] == -1) { // Process event handler selection field
$conttp->setVariable("DAT_".strtoupper($elem),"null"); if (isset($arrModifyData['event_handler'])) {
} $intFieldId = $arrModifyData['event_handler'];
} } else {
if ($arrModifyData['check_command'] != "") { $intFieldId = 0;
$arrArgument = explode("!",$arrModifyData['check_command']); }
foreach ($arrArgument AS $key => $value) { $intReturn6 = $myVisClass->parseSelectSimple('tbl_command', 'command_name', 'eventhandler', 1, $intFieldId);
if ($key == 0) { if ($intReturn6 != 0) {
$conttp->setVariable("IFRAME_SRC",$_SESSION['SETS']['path']['base_url']."admin/commandline.php?cname=".$value); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
} else { }
$conttp->setVariable("DAT_ARG".$key,htmlentities($value,ENT_QUOTES,'UTF-8')); // Process contact and contact group selection field
} if (isset($arrModifyData['contacts'])) {
} $intFieldId = $arrModifyData['contacts'];
} } else {
// Process option fields $intFieldId = 0;
foreach(explode(",",$arrModifyData['initial_state']) AS $elem) { }
$conttp->setVariable("DAT_IS".strtoupper($elem)."_CHECKED","checked"); $intReturn7 = $myVisClass->parseSelectMulti(
} 'tbl_contact',
foreach(explode(",",$arrModifyData['flap_detection_options']) AS $elem) { 'contact_name',
$conttp->setVariable("DAT_FL".strtoupper($elem)."_CHECKED","checked"); 'host_contacts',
} 'tbl_lnkHosttemplateToContact',
foreach(explode(",",$arrModifyData['notification_options']) AS $elem) { 2,
$conttp->setVariable("DAT_NO".strtoupper($elem)."_CHECKED","checked"); $intFieldId
} );
foreach(explode(",",$arrModifyData['stalking_options']) AS $elem) { if ($intReturn7 != 0) {
$conttp->setVariable("DAT_ST".strtoupper($elem)."_CHECKED","checked"); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
} }
} if (isset($arrModifyData['contact_groups'])) {
$conttp->parse("datainsert"); $intFieldId = $arrModifyData['contact_groups'];
$conttp->show("datainsert"); } else {
$intFieldId = 0;
}
$intReturn8 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
'host_contactgroups',
'tbl_lnkHosttemplateToContactgroup',
2,
$intFieldId
);
if ($intReturn8 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
$intReturn9 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn9 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$strChbFields = 'ACE,PCE,FRE,OBS,EVH,FLE,STI,NSI,PED,NOE,PAR,HOG,COT,COG,TPL';
$myContentClass->addFormInit($conttp, $strChbFields);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo, $strChbFields);
$conttp->setVariable('DAT_ACE' .$arrModifyData['active_checks_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_PCE' .$arrModifyData['passive_checks_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_FRE' .$arrModifyData['check_freshness']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_OBS' .$arrModifyData['obsess_over_host']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_EVH' .$arrModifyData['event_handler_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_FLE' .$arrModifyData['flap_detection_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_STI' .$arrModifyData['retain_status_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_NSI' .$arrModifyData['retain_nonstatus_information']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_PED' .$arrModifyData['process_perf_data']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_NOE' .$arrModifyData['notifications_enabled']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_PAR' .$arrModifyData['parents_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_HOG' .$arrModifyData['hostgroups_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_COT' .$arrModifyData['contacts_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_COG' .$arrModifyData['contact_groups_tploptions']. '_CHECKED', 'checked');
$conttp->setVariable('DAT_TPL' .$arrModifyData['use_template_tploptions']. '_CHECKED', 'checked');
// Special processing for -1 values - write 'null' to integer fields
$strIntegerfelder = 'max_check_attempts,check_interval,retry_interval,freshness_threshold,low_flap_threshold,';
$strIntegerfelder .= 'high_flap_threshold,notification_interval,first_notification_delay';
foreach (explode(',', $strIntegerfelder) as $elem) {
if ($arrModifyData[$elem] == -1) {
$conttp->setVariable('DAT_' .strtoupper($elem), 'null');
}
}
if ($arrModifyData['check_command'] != '') {
$arrArgument = explode('!', $arrModifyData['check_command']);
foreach ($arrArgument as $key => $value) {
if ($key == 0) {
$conttp->setVariable('IFRAME_SRC', $_SESSION['SETS']['path']['base_url'].
'admin/commandline.php?cname=' .$value);
} else {
$value1 = str_replace('::bang::', '!', $value);
$value2 = str_replace('::back::', "\\", $value1);
$conttp->setVariable('DAT_ARG' .$key, htmlentities($value, ENT_QUOTES, 'UTF-8'));
}
}
}
// Process option fields
foreach (explode(',', $arrModifyData['initial_state']) as $elem) {
$conttp->setVariable('DAT_IS' .strtoupper($elem). '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['flap_detection_options']) as $elem) {
$conttp->setVariable('DAT_FL' .strtoupper($elem). '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['notification_options']) as $elem) {
$conttp->setVariable('DAT_NO' .strtoupper($elem). '_CHECKED', 'checked');
}
foreach (explode(',', $arrModifyData['stalking_options']) as $elem) {
$conttp->setVariable('DAT_ST' .strtoupper($elem). '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Host template name')); $mastertp->setVariable('TITLE', translate('Host template definition (hosttemplates.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Host template name'));
// Process search string $mastertp->setVariable('FIELD_2', translate('Description'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process search string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%')"; $strSearchTxt = $_SESSION['search'][$preSearchSession];
} $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%')";
// Row sorting }
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir"; $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
// Count datasets if ($hidSortBy == 2) {
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); }
if ($booReturn == false) { // Count datasets
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $strSQL1 = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "AND `access_group` IN ($strAccess)";
} else { $booReturn1 = $myDBClass->hasSingleDataset($strSQL1, $arrDataLinesCount);
$intLineCount = (int)$arrDataLinesCount['number']; if ($booReturn1 == false) {
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
} $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
// Get datasets } else {
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `last_modified`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $intLineCount = (int)$arrDataLinesCount['number'];
$strSearchWhere AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; if ($intLineCount < $chkLimit) {
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); $chkLimit = 0;
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); }
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); // Get datasets
} $strSQL2 = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `last_modified`, `config_id`, "
// Process data . "`access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias'); . "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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,216 +5,294 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin configuration verification // Component : Admin configuration verification
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 25; $prePageId = 25;
$preContent = "admin/import.tpl.htm"; $preContent = 'admin/import.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
$intModus = 0; $intModus = 0;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Initialize import class // Initialize import class
// ======================= // =======================
include("../functions/import_class.php"); $myImportClass = new functions\NagImportClass($_SESSION);
$myImportClass = new nagimport; $myImportClass->myDBClass =& $myDBClass;
$myImportClass->myDataClass =& $myDataClass; $myImportClass->myDataClass =& $myDataClass;
$myImportClass->myDBClass =& $myDBClass; $myImportClass->myConfigClass =& $myConfigClass;
$myImportClass->myConfigClass =& $myConfigClass;
// //
// Get configuration set ID // Get configuration set ID
// ======================== // ========================
$arrConfigSet = $myConfigClass->getConfigSets(); $myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0]; $intConfigId = $arrConfigSet[0];
// //
// Process form variables // Process form variables
// ====================== // ======================
if (isset($_FILES['datValue1']) && ($_FILES['datValue1']['name'] != "") && ($chkStatus == 1)) { if (isset($_FILES['datValue1']) && ($_FILES['datValue1']['name'] != '') && ($chkStatus == 1)) {
// Upload Error // Upload Error
if ($_FILES['datValue1']['error'] !== UPLOAD_ERR_OK) { if ($_FILES['datValue1']['error'] !== UPLOAD_ERR_OK) {
$myVisClass->processMessage(translate('File upload error:')." ".$_FILES['filMedia']['error'],$strErrorMessage); $myVisClass->processMessage(
} else { translate('File upload error:'). ' ' .$_FILES['filMedia']['error'],
$intModus = 1; $strErrorMessage
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_local_imp'); );
} else {
$intModus = 1;
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_local_imp');
move_uploaded_file($_FILES['datValue1']['tmp_name'], $strFileName); move_uploaded_file($_FILES['datValue1']['tmp_name'], $strFileName);
$intReturn = $myImportClass->fileImport($strFileName,$intConfigId,$chkChbValue1); $intReturn = $myImportClass->fileImport($strFileName, $intConfigId, $chkChbValue1);
if ($intReturn != 0) { if ($intReturn != 0) {
$myVisClass->processMessage($myImportClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myImportClass->strErrorMessage, $strErrorMessage);
} else { } else {
$myVisClass->processMessage($myImportClass->strInfoMessage,$strInfoMessage); $myVisClass->processMessage($myImportClass->strInfoMessage, $strInfoMessage);
$myDataClass->writeLog(translate('File imported - File [overwite flag]:')." ".$_FILES['datValue1']['name']." [".$chkChbValue1."]"); $myDataClass->writeLog(translate('File imported - File [overwrite flag]:'). ' ' .
} $_FILES['datValue1']['name']. ' [' .$chkChbValue1. ']');
} }
}
} }
if (($chkMselValue1[0] != "") && ($chkStatus == 1)) { if (($chkMselValue1[0] != '') && ($chkStatus == 1)) {
foreach($chkMselValue1 AS $elem) { /** @var array $chkMselValue1 */
$intModus = 1; foreach ($chkMselValue1 as $elem) {
$myImportClass->strErrorMessage = ""; $intModus = 1;
$myImportClass->strInfoMessage = ""; $myImportClass->strErrorMessage = '';
$intReturn = $myImportClass->fileImport($elem,$intConfigId,$chkChbValue1); $myImportClass->strInfoMessage = '';
if ($intReturn != 0) { $intReturn = $myImportClass->fileImport($elem, $intConfigId, $chkChbValue1);
$myVisClass->processMessage($myImportClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
} else { $myVisClass->processMessage($myImportClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage($myImportClass->strInfoMessage,$strInfoMessage); } else {
$myDataClass->writeLog(translate('File imported - File [overwite flag]:')." ".$elem." [".$chkChbValue1."]"); $myVisClass->processMessage($myImportClass->strInfoMessage, $strInfoMessage);
} $myDataClass->writeLog(translate('File imported - File [overwrite flag]:'). ' ' .$elem. ' ['
} .$chkChbValue1. ']');
}
}
} }
// //
// Start content // Start content
// ============= // =============
$conttp->setVariable("TITLE",translate('Configuration import')); $conttp->setVariable('TITLE', translate('Configuration import'));
$conttp->parse("header"); $conttp->parse('header');
$conttp->show("header"); $conttp->show('header');
$conttp->setVariable("LANG_SEARCH_STRING",translate('Filter string')); $conttp->setVariable('LANG_SEARCH_STRING', translate('Filter string'));
$conttp->setVariable("LANG_SEARCH",translate('Search')); $conttp->setVariable('LANG_SEARCH', translate('Search'));
$conttp->setVariable("LANG_DELETE",translate('Delete')); $conttp->setVariable('LANG_DELETE', translate('Delete'));
$conttp->setVariable("LANG_DELETE_SEARCH",translate("Reset filter")); $conttp->setVariable('LANG_DELETE_SEARCH', translate('Reset filter'));
$conttp->setVariable("DAT_SEARCH",$chkTfSearch); $conttp->setVariable('DAT_SEARCH', $chkTfSearch);
$conttp->setVariable("TEMPLATE",translate('Template definition')); $conttp->setVariable('TEMPLATE', translate('Template definition'));
$conttp->setVariable("IMPORTFILE",translate('Import file')); $conttp->setVariable('IMPORTFILE', translate('Import file'));
$conttp->setVariable("LOCAL_FILE",translate('Local import file')); $conttp->setVariable('LOCAL_FILE', translate('Local import file'));
$conttp->setVariable("OVERWRITE",translate('Overwrite database')); $conttp->setVariable('OVERWRITE', translate('Overwrite database'));
$conttp->setVariable("MAKE",translate('Import')); $conttp->setVariable('MAKE', translate('Import'));
$conttp->setVariable("ABORT",translate('Abort')); $conttp->setVariable('ABORT', translate('Abort'));
$conttp->setVariable("CTRL_INFO",translate('Hold CTRL to select<br>more than one')); $conttp->setVariable('CTRL_INFO', translate('Hold CTRL to select<br>more than one'));
$conttp->setVariable("IMAGE_PATH",$_SESSION['SETS']['path']['base_url']."images/"); $conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)); $conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable("DAT_IMPORTFILE_1",""); $conttp->setVariable('DAT_IMPORTFILE_1', '');
$conttp->setVariable("IMPORT_INFO_1",translate("To prevent errors or misconfigurations, you should import your configurations in an useful order. We recommend to do it like this:<br><br><b><i>commands -> timeperiods -> contacttemplates -> contacts -> contactgroups -> hosttemplates -> hosts -> hostgroups -> servicetemplates -> services -> servicegroups</i></b><br><br>")); $conttp->setVariable('IMPORT_INFO_1', translate('To prevent errors or misconfigurations, you should import your '
$conttp->setVariable("IMPORT_INFO_2","<span style=\"color:#FF0000\">".translate("<b>Check your configuration after import!</b><br>In cause of an error or an uncomplete configuration, re-importing the wrong configuration can solve the problem.")."</span>"); . 'configurations in an useful order. We recommend to do it like this:<br><br><b><i>commands -> '
$conttp->parse("filelist1"); . 'timeperiods -> contacttemplates -> contacts -> contactgroups -> hosttemplates -> hosts -> '
. 'hostgroups -> servicetemplates -> services -> servicegroups</i></b><br><br>'));
$conttp->setVariable('IMPORT_INFO_2', '<span style="color:#FF0000">' .translate('<b>Check your configuration after '
. 'import!</b><br>In cause of an error or an uncomplete configuration, re-importing the wrong configuration '
. 'can solve the problem.'). '</span>');
$conttp->parse('filelist1');
// Get settings // Get settings
$myConfigClass->getConfigData($intConfigId,"method",$intMethod); $myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$myConfigClass->getConfigData($intConfigId,"basedir",$strBaseDir); $myConfigClass->getConfigValues($intConfigId, 'basedir', $strBaseDir);
$myConfigClass->getConfigData($intConfigId,"hostconfig",$strHostDir); $myConfigClass->getConfigValues($intConfigId, 'hostconfig', $strHostDir);
$myConfigClass->getConfigData($intConfigId,"serviceconfig",$strServiceDir); $myConfigClass->getConfigValues($intConfigId, 'serviceconfig', $strServiceDir);
$myConfigClass->getConfigData($intConfigId,"backupdir",$strBackupDir); $myConfigClass->getConfigValues($intConfigId, 'backupdir', $strBackupDir);
$myConfigClass->getConfigData($intConfigId,"hostbackup",$strHostBackupDir); $myConfigClass->getConfigValues($intConfigId, 'hostbackup', $strHostBackupDir);
$myConfigClass->getConfigData($intConfigId,"servicebackup",$strServiceBackupDir); $myConfigClass->getConfigValues($intConfigId, 'servicebackup', $strServiceBackupDir);
$myConfigClass->getConfigData($intConfigId,"importdir",$strImportDir); $myConfigClass->getConfigValues($intConfigId, 'importdir', $strImportDir);
$myConfigClass->getConfigData($intConfigId,"nagiosbasedir",$strNagiosBaseDir); $myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strNagiosBaseDir);
if ($intMethod == 1) { if ($intMethod == 1) {
// Building local file list // Building local file list
$output = array(); $arrOutput1 = array();
$temp=$myConfigClass->DirToArray($strBaseDir, "\.cfg", "cgi.cfg|nagios.cfg|nrpe.cfg|nsca.cfg",$output,$strErrorMessage); $myConfigClass->storeDirToArray(
if ($strNagiosBaseDir != $strBaseDir) { $strBaseDir,
$temp=$myConfigClass->DirToArray($strNagiosBaseDir, "\.cfg", "cgi.cfg|nagios.cfg|nrpe.cfg|nsca.cfg",$output,$strErrorMessage); "\.cfg",
} 'cgi.cfg|nagios.cfg|nrpe.cfg|nsca.cfg',
$temp=$myConfigClass->DirToArray($strHostDir, "\.cfg", "",$output,$strErrorMessage); $arrOutput1,
$temp=$myConfigClass->DirToArray($strServiceDir, "\.cfg", "",$output,$strErrorMessage); $strErrorMessage
$temp=$myConfigClass->DirToArray($strHostBackupDir, "\.cfg_", "",$output,$strErrorMessage); );
$temp=$myConfigClass->DirToArray($strServiceBackupDir, "\.cfg_", "",$output,$strErrorMessage); if ($strNagiosBaseDir != $strBaseDir) {
if (($strImportDir != "") && ($strImportDir != $strBaseDir) && ($strImportDir != $strNagiosBaseDir)) { $myConfigClass->storeDirToArray(
$temp=$myConfigClass->DirToArray($strImportDir, "\.cfg", "",$output,$strErrorMessage); $strNagiosBaseDir,
} "\.cfg",
$output=array_unique($output); 'cgi.cfg|nagios.cfg|nrpe.cfg|nsca.cfg',
if (is_array($output) && (count($output) != 0)) { $arrOutput1,
foreach ($output AS $elem) { $strErrorMessage
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) { );
$conttp->setVariable("DAT_IMPORTFILE_2",$elem); }
$conttp->parse("filelist2"); $myConfigClass->storeDirToArray($strHostDir, "\.cfg", '', $arrOutput1, $strErrorMessage);
} $myConfigClass->storeDirToArray($strServiceDir, "\.cfg", '', $arrOutput1, $strErrorMessage);
} $myConfigClass->storeDirToArray($strHostBackupDir, "\.cfg_", '', $arrOutput1, $strErrorMessage);
} $myConfigClass->storeDirToArray($strServiceBackupDir, "\.cfg_", '', $arrOutput1, $strErrorMessage);
} else if ($intMethod == 2) { if (($strImportDir != '') && ($strImportDir != $strBaseDir) && ($strImportDir != $strNagiosBaseDir)) {
// Set up basic connection $myConfigClass->storeDirToArray($strImportDir, "\.cfg", '', $arrOutput1, $strErrorMessage);
if ($myConfigClass->getFTPConnection($intConfigId) == "0") { }
$arrFiles = array(); $arrOutput2=array_unique($arrOutput1);
$arrFiles1 = ftp_nlist($myConfigClass->resConnectId,$strBaseDir); if (is_array($arrOutput2) && (count($arrOutput2) != 0)) {
if (is_array($arrFiles1)) $arrFiles = array_merge($arrFiles,$arrFiles1); foreach ($arrOutput2 as $elem) {
$arrFiles2 = ftp_nlist($myConfigClass->resConnectId,$strHostDir); if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
if (is_array($arrFiles2)) $arrFiles = array_merge($arrFiles,$arrFiles2); $conttp->setVariable('DAT_IMPORTFILE_2', $elem);
$arrFiles3 = ftp_nlist($myConfigClass->resConnectId,$strServiceDir); $conttp->parse('filelist2');
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); } elseif ($intMethod == 2) {
if (is_array($arrFiles5)) $arrFiles = array_merge($arrFiles,$arrFiles5); // Set up basic connection
if ($strImportDir != "" ) { if ($myConfigClass->getFTPConnection($intConfigId) == '0') {
$arrFiles6 = ftp_nlist($myConfigClass->resConnectId,$strImportDir); $arrFiles = array();
if (is_array($arrFiles6)) $arrFiles = array_merge($arrFiles,$arrFiles6); $arrFiles1 = ftp_nlist($myConfigClass->resConnectId, $strBaseDir);
} if (is_array($arrFiles1)) {
if (is_array($arrFiles) && (count($arrFiles) != 0)) { $arrFiles = array_merge($arrFiles, $arrFiles1);
foreach ($arrFiles AS $elem) { }
if (!substr_count($elem,"cfg")) continue; $arrFiles2 = ftp_nlist($myConfigClass->resConnectId, $strHostDir);
if (substr_count($elem,"resource.cfg")) continue; if (is_array($arrFiles2)) {
if (substr_count($elem,"nagios.cfg")) continue; $arrFiles = array_merge($arrFiles, $arrFiles2);
if (substr_count($elem,"cgi.cfg")) continue; }
if (substr_count($elem,"nrpe.cfg")) continue; $arrFiles3 = ftp_nlist($myConfigClass->resConnectId, $strServiceDir);
if (substr_count($elem,"nsca.cfg")) continue; if (is_array($arrFiles3)) {
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) { $arrFiles = array_merge($arrFiles, $arrFiles3);
$conttp->setVariable("DAT_IMPORTFILE_2",str_replace("//","/",$elem)); }
$conttp->parse("filelist2"); $arrFiles4 = ftp_nlist($myConfigClass->resConnectId, $strHostBackupDir);
} if (is_array($arrFiles4)) {
} $arrFiles = array_merge($arrFiles, $arrFiles4);
} }
ftp_close($myConfigClass->resConnectId); $arrFiles5 = ftp_nlist($myConfigClass->resConnectId, $strServiceBackupDir);
} else { if (is_array($arrFiles5)) {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); $arrFiles = array_merge($arrFiles, $arrFiles5);
} }
} else if ($intMethod == 3) { if ($strImportDir != '') {
// Set up basic connection $arrFiles6 = ftp_nlist($myConfigClass->resConnectId, $strImportDir);
if ($myConfigClass->getSSHConnection($intConfigId) == "0") { if (is_array($arrFiles6)) {
$arrFiles = array(); $arrFiles = array_merge($arrFiles, $arrFiles6);
$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($arrFiles) && (count($arrFiles) != 0)) {
if (is_array($arrFiles2)) $arrFiles = array_merge($arrFiles,$arrFiles2); foreach ($arrFiles as $elem) {
$arrFiles3 = $myConfigClass->sendSSHCommand("ls ".$strServiceDir."*.cfg"); if (!substr_count($elem, 'cfg')) {
if (is_array($arrFiles3)) $arrFiles = array_merge($arrFiles,$arrFiles3); continue;
$arrFiles4 = $myConfigClass->sendSSHCommand("ls ".$strHostBackupDir."*.cfg*"); }
if (is_array($arrFiles4)) $arrFiles = array_merge($arrFiles,$arrFiles4); if (substr_count($elem, 'resource.cfg')) {
$arrFiles5 = $myConfigClass->sendSSHCommand("ls ".$strServiceBackupDir."*.cfg*"); continue;
if (is_array($arrFiles5)) $arrFiles = array_merge($arrFiles,$arrFiles5); }
if ($strImportDir != "" ) { if (substr_count($elem, 'nagios.cfg')) {
$arrFiles6 = $myConfigClass->sendSSHCommand("ls ".$strImportDir."*.cfg"); continue;
if (is_array($arrFiles6)) $arrFiles = array_merge($arrFiles,$arrFiles6); }
} if (substr_count($elem, 'cgi.cfg')) {
if (is_array($arrFiles) && (count($arrFiles) != 0)) { continue;
foreach ($arrFiles AS $elem) { }
if (!substr_count($elem,"cfg")) continue; if (substr_count($elem, 'nrpe.cfg')) {
if (substr_count($elem,"resource.cfg")) continue; continue;
if (substr_count($elem,"nagios.cfg")) continue; }
if (substr_count($elem,"cgi.cfg")) continue; if (substr_count($elem, 'nsca.cfg')) {
if (substr_count($elem,"nrpe.cfg")) continue; continue;
if (substr_count($elem,"nsca.cfg")) continue; }
if (($chkTfSearch == "") || (substr_count($elem,$chkTfSearch) != 0)) { if (($chkTfSearch == '') || (substr_count($elem, $chkTfSearch) != 0)) {
$conttp->setVariable("DAT_IMPORTFILE_2",str_replace("//","/",$elem)); $conttp->setVariable('DAT_IMPORTFILE_2', str_replace('//', '/', $elem));
$conttp->parse("filelist2"); $conttp->parse('filelist2');
} }
} }
} }
} else { ftp_close($myConfigClass->resConnectId);
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); } 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 // Check access rights for adding new objects
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\""); if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage); $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
$conttp->setVariable("INFOMESSAGE",$strInfoMessage); }
$conttp->parse("main"); if ($strErrorMessage != '') {
$conttp->show("main"); $conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
$conttp->parse('main');
$conttp->show('main');
// //
// Process footer // Process footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

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

View File

@ -5,91 +5,105 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin information dialog // Component : Admin information dialog
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
$preNoMain = 1; $preNoMain = 1;
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
// //
// Process get parameters // Process get parameters
// ====================== // ======================
$chkKey1 = isset($_GET['key1']) ? htmlspecialchars($_GET['key1'], ENT_QUOTES, 'utf-8') : ""; $chkKey1 = filter_input(INPUT_GET, 'key1', FILTER_SANITIZE_STRING);
$chkKey2 = isset($_GET['key2']) ? htmlspecialchars($_GET['key2'], ENT_QUOTES, 'utf-8') : ""; $chkKey2 = filter_input(INPUT_GET, 'key2', FILTER_SANITIZE_STRING);
$chkVersion = isset($_GET['version']) ? htmlspecialchars($_GET['version'], ENT_QUOTES, 'utf-8') : ""; $chkVersion = filter_input(INPUT_GET, 'version', FILTER_SANITIZE_STRING);
// //
// Get information data // Get information data
// =================================================== // ===================================================
if ($chkKey1 == "admin" and isset($_SESSION['updInfo'])) { if ($chkKey1 == 'admin' and isset($_SESSION['updInfo'])) {
// Exception for version check at admin.php // Exception for version check at admin.php
$strContentDB = $_SESSION['updInfo']; $strContentDB = $_SESSION['updInfo'];
} elseif ($chkKey1 == "settings") { } elseif ($chkKey1 == 'settings') {
// Exception for settings page to have gettext translated text // Exception for settings page to have gettext translated text
$arrTrans = array ( $arrTrans = array(
"txtRootPath" => translate("This is relative path of your NagiosQL Installation"), 'txtRootPath' => translate('This is relative path of your NagiosQL Installation'),
"txtBasePath" => translate("This is the absolut path to 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"), '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"), 'txtTempdir' => translate('Please choose a temporary directory with write permissions. The default is the ' .
"selLanguage" => translate("Please choose your application language"), 'temp directory provided by your OS'),
"txtEncoding" => translate("Encoding should be set to nothing else than utf-8. Any changes at your own risk"), 'selLanguage' => translate('Please choose your application language for new users and login portal'),
"txtDBserver" => translate("IP-Address or hostname of the database server<br>e.g. localhost"), 'txtEncoding' => translate('Encoding should be set to nothing else than utf-8. Any changes at your own risk'),
"txtDBport" => translate("MySQL Server Port, default is 3306"), 'txtDBserver' => translate('IP-Address or hostname of the database server<br>e.g. localhost'),
"txtDBname" => translate("Name of the NagiosQL database<br>e.g. db_nagiosql_v3"), 'txtDBport' => translate('MySQL Server Port, default is 3306'),
"txtDBuser" => translate("User with sufficient permission for the NagiosQL database<br>At least this user should have SELECT, INSERT, UPDATE, DELETE permissions"), 'txtDBname' => translate('Name of the NagiosQL database<br>e.g. db_nagiosql_v3'),
"txtDBpass" => translate("Password for the above mentioned user"), 'txtDBuser' => translate('User with sufficient permission for the NagiosQL database<br>At least this user ' .
"txtLogoff" => translate("After the defined amount of seconds the session will terminate for security reasons"), 'should have SELECT, INSERT, UPDATE, DELETE permissions'),
"selWSAuth" => translate("Decide between authentication based on your Webserver<br>e.g. Apache configuration (config file or htaccess) or NagiosQL"), 'txtDBpass' => translate('Password for the above mentioned user'),
"txtLines" => translate("How many entries per side should be visibile (e.g. services or hosts)"), 'txtLogoff' => translate('After the defined amount of seconds the session will terminate for security ' .
"selSeldisable" => translate("Selection of multiple entries by using the new dialog or by holding CTRL + left click like in NagiosQL2"), 'reasons'),
"templatecheck" => translate("Enable or disable the warning if a required field contains no data in objects with templates"), 'selWSAuth' => translate('Decide between authentication based on your Webserver<br>e.g. Apache ' .
"updatecheck" => translate("Enable or disable the automatic online version check."), 'configuration (config file or htaccess) or NagiosQL'),
"chkUpdProxy" => translate("If you require a Proxyserver to connect to the Internet (Port 80), please define one."), 'txtLines' => translate('Number of entries per side that should be visible (e.g. services or hosts)'),
"txtProxyServer"=> translate("Address of your Proxyserver e.g. proxy.yourdomain.com:3128"), 'selSeldisable' => translate('Method of selection of multiple entries by using the new dialog or by holding ' .
"txtProxyUser" => translate("Username to connect through your proxy (optional)"), 'CTRL + left mouse button, as in NagiosQL 2'),
"txtProxyPasswd"=> translate("Password to connect through your proxy (optional)"), 'templatecheck' => translate('Enable or disable the warning if a required field contains no data in objects ' .
); 'with templates'),
$strContentDB = $arrTrans[$chkKey2]; '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 { } else {
// Get information from tbl_info // Get information from tbl_info
$strSQL = "SELECT `infotext` FROM `tbl_info` $strSQL = 'SELECT `infotext` FROM `tbl_info` ' .
WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' AND `version` = '$chkVersion' AND `language` = 'private'"; "WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' AND `version` = '$chkVersion' ".
$strContentDB = $myDBClass->getFieldData($strSQL); "AND `language` = 'private'";
if ($strContentDB == "") { $strContentDB = $myDBClass->getFieldData($strSQL);
$strSQL = "SELECT `infotext` FROM `tbl_info` if ($strContentDB == '') {
WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' AND `version` = '$chkVersion' AND `language` = 'default'"; $strSQL = 'SELECT `infotext` FROM `tbl_info` ' .
$strContentDB = $myDBClass->getFieldData($strSQL); "WHERE `key1` = '$chkKey1' AND `key2` = '$chkKey2' AND `version` = '$chkVersion' ".
} "AND `language` = 'default'";
$strContentDB = $myDBClass->getFieldData($strSQL);
}
} }
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo translate("Information PopUp");?></title> <title><?php echo translate('Information PopUp');?></title>
<style> <style type="text/css">
.infobody { .infobody {
font-family:"Courier New", Courier, monospace; font-family:"Courier New", Courier, monospace;
font-size:12px; font-size:12px;
} }
</style> </style>
</head> </head>
<body class="infobody"> <body class="infobody">
<?php <?php
if ($strContentDB != "") { if ($strContentDB != '') {
echo $strContentDB; echo $strContentDB;
} else { } else {
echo translate("No information available"); echo translate('No information available');
} }
?> ?>
</body> </body>
</html> </html>

View File

@ -5,120 +5,136 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin logbook // Component : Admin logbook
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 37; $prePageId = 37;
$preContent = "admin/admin_master.tpl.htm"; $preContent = 'admin/logbook.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Delete log entries // Delete log entries
// ================== // ==================
if (isset($_POST['tfValue1']) && (($chkTfValue1 != "") || ($chkTfValue2 != ""))) { $strWhere = '';
$strWhere = ""; if ($chkTfValue1 != '') {
if ($chkTfValue1 != "") { $strWhere .= "AND `time` > '$chkTfValue1 00:00:00'";
$strWhere .= "AND `time` > '$chkTfValue1 00:00:00'"; }
} if ($chkTfValue2 != '') {
if ($chkTfValue2 != "") { $strWhere .= "AND `time` < '$chkTfValue2 23:59:59'";
$strWhere .= "AND `time` < '$chkTfValue2 23:59:59'"; }
} if ($strWhere != '') {
$strSQL = "DELETE FROM `tbl_logbook` WHERE 1=1 $strWhere"; $strSQL = 'DELETE FROM `tbl_logbook` WHERE 1=1 ';
$booReturn = $myDBClass->insertData($strSQL); $strSQL .= $strWhere;
if ($booReturn == false) { $booReturn = $myDBClass->insertData($strSQL);
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); if ($booReturn == false) {
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
} else { $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Dataset successfully deleted. Affected rows:')." ".$myDBClass->intAffectedRows,$strInfoMessage); } else {
} $myVisClass->processMessage(translate('Dataset successfully deleted. Affected rows:'). ' ' .
$myDBClass->intAffectedRows, $strInfoMessage);
}
} }
// //
// Search data // Search data
// =========== // ===========
if ($chkTfSearch != "") { if ($chkTfSearch != '') {
$strWhere = "WHERE `user` LIKE '%$chkTfSearch%' OR `ipadress` LIKE '%$chkTfSearch%' OR `domain` LIKE '%$chkTfSearch%' OR `entry` LIKE '%$chkTfSearch%'"; $strWhere = "WHERE `user` LIKE '%$chkTfSearch%' OR `ipadress` LIKE '%$chkTfSearch%' "
. "OR `domain` LIKE '%$chkTfSearch%' OR `entry` LIKE '%$chkTfSearch%'";
} else { } else {
$strWhere = ""; $strWhere = '';
} }
// //
// Get data // Get data
// ======== // ========
$intNumRows = $myDBClass->getFieldData("SELECT count(*) FROM `tbl_logbook` $strWhere"); $intNumRows = $myDBClass->getFieldData("SELECT count(*) FROM `tbl_logbook` $strWhere");
if ($intNumRows <= $chkFromLine) $chkFromLine = 0; if ($intNumRows <= $chkFromLine) {
$strSQL = "SELECT DATE_FORMAT(time,'%Y-%m-%d %H:%i:%s') AS `time`, `user`, `ipadress`, `domain`, `entry` $chkFromLine = 0;
FROM `tbl_logbook` $strWhere ORDER BY `time` DESC LIMIT $chkFromLine,".$SETS['common']['pagelines']; }
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); $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) { if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} }
// //
// Start content // Start content
// ============= // =============
$conttp->setVariable("TITLE",translate('View logbook')); $conttp->setVariable('TITLE', translate('View logbook'));
foreach($arrDescription AS $elem) { foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'],$elem['string']); $conttp->setVariable($elem['name'], $elem['string']);
} }
$conttp->setVariable("LANG_ENTRIES_BEFORE",translate('Delete logentries between:')); $conttp->setVariable('LANG_ENTRIES_BEFORE', translate('Delete logentries between:'));
$conttp->setVariable("LOCALE",$SETS['data']['locale']); $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_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('LANG_DELETELOG', translate('Do you really want to delete all log entries between the '
$conttp->setVariable("DAT_SEARCH",$chkTfSearch); . 'selected dates?'));
$conttp->setVariable('DAT_SEARCH', $chkTfSearch);
// Legende einblenden // Legende einblenden
if ($chkFromLine > 1) { if ($chkFromLine > 1) {
$intPrevNumber = $chkFromLine - 20; $intPrevNumber = $chkFromLine - 20;
$conttp->setVariable("LANG_PREVIOUS", "<a href=\"".filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)."?from_line=".$intPrevNumber."\"><< ".translate('previous 20 entries')."</a>"); $conttp->setVariable('LANG_PREVIOUS', '<a href="' .filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING).
'?from_line=' .$intPrevNumber. '"><< ' .translate('previous 20 entries'). '</a>');
} else { } else {
$conttp->setVariable("LANG_PREVIOUS", ""); $conttp->setVariable('LANG_PREVIOUS', '');
} }
if ($chkFromLine < $intNumRows-20) { if ($chkFromLine < $intNumRows-20) {
$intNextNumber = $chkFromLine + 20; $intNextNumber = $chkFromLine + 20;
$conttp->setVariable("LANG_NEXT", "<a href=\"".filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)."?from_line=".$intNextNumber."\">".translate('next 20 entries')." >></a>"); $conttp->setVariable('LANG_NEXT', '<a href="' .filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING).
'?from_line=' .$intNextNumber. '">' .translate('next 20 entries'). ' >></a>');
} else { } else {
$conttp->setVariable("LANG_NEXT", ""); $conttp->setVariable('LANG_NEXT', '');
} }
// //
// Output log data // Output log data
// =============== // ===============
if ($intDataCount != 0) { if ($intDataCount != 0) {
for ($i=0;$i<$intDataCount;$i++) { for ($i = 0; $i < $intDataCount; $i++) {
// Set default values // Set default values
if ($arrDataLines[$i]['ipadress'] == "") $arrDataLines[$i]['ipadress'] = "&nbsp;"; if ($arrDataLines[$i]['ipadress'] == '') {
// Insert data values $arrDataLines[$i]['ipadress'] = '&nbsp;';
$conttp->setVariable("DAT_TIME", $arrDataLines[$i]['time']); }
$conttp->setVariable("DAT_ACCOUNT", $arrDataLines[$i]['user']); // Insert data values
$conttp->setVariable("DAT_ACTION", $arrDataLines[$i]['entry']); $conttp->setVariable('DAT_TIME', $arrDataLines[$i]['time']);
$conttp->setVariable("DAT_IPADRESS", $arrDataLines[$i]['ipadress']); $conttp->setVariable('DAT_ACCOUNT', $arrDataLines[$i]['user']);
$conttp->setVariable("DAT_DOMAIN", $arrDataLines[$i]['domain']); $conttp->setVariable('DAT_ACTION', $arrDataLines[$i]['entry']);
$conttp->parse("logdatacell"); $conttp->setVariable('DAT_IPADRESS', $arrDataLines[$i]['ipadress']);
} $conttp->setVariable('DAT_DOMAIN', $arrDataLines[$i]['domain']);
$conttp->parse('logdatacell');
}
} }
$conttp->setVariable("ERRORMESSAGE","<br>".$strErrorMessage); $conttp->setVariable('ERRORMESSAGE', '<br>' .$strErrorMessage);
$conttp->setVariable("INFOMESSAGE","<br>".$strInfoMessage); $conttp->setVariable('INFOMESSAGE', '<br>' .$strInfoMessage);
// Check access rights for adding new objects // Check access rights for adding new objects
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\""); if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->parse("logbooksite"); $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
$conttp->show("logbooksite"); }
$conttp->parse('logbooksite');
$conttp->show('logbooksite');
// //
// Process footer // Process footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,95 +5,104 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Menu access administration // Component : Menu access administration
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 34; $prePageId = 34;
$preContent = "admin/admin_master.tpl.htm"; $preContent = 'admin/menuaccess.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
$preNoAccessGrp = 1; $preNoAccessGrp = 1;
$intFieldId = 0; $intFieldId = 0;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Process data // Process data
// ============ // ============
if (isset($_POST['subSave']) && ($chkSelValue1 != 0)) { if (filter_input(INPUT_POST, 'subSave') && ($chkSelValue1 != 0)) {
$strSQL = "UPDATE `tbl_menu` SET `mnuGrpId`='$chkSelValue2' WHERE `mnuId`=$chkSelValue1"; $strSQL = "UPDATE `tbl_menu` SET `mnuGrpId`='$chkSelValue2' WHERE `mnuId`=$chkSelValue1";
$booReturn = $myDBClass->insertData($strSQL); $booReturn = $myDBClass->insertData($strSQL);
if ($booReturn == false) { if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while inserting the data to the data base:'),$strErrorMessage); $myVisClass->processMessage(translate('Error while inserting the data into the database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else { } else {
$myVisClass->processMessage(translate('Data were successfully inserted to the data base!'),$strInfoMessage); $myVisClass->processMessage(translate('Data were successfully inserted to the data base!'), $strInfoMessage);
$myDataClass->writeLog(translate('Access group set for menu item:')." ".$myDBClass->getFieldData("SELECT `mnuName` FROM `tbl_menu` WHERE `mnuId`=$chkSelValue1")); $myDataClass->writeLog(translate('Access group set for menu item:'). ' ' .
} $myDBClass->getFieldData("SELECT `mnuName` FROM `tbl_menu` WHERE `mnuId`=$chkSelValue1"));
}
} }
// //
// Include content // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate('Define Menu Accessrights')); $conttp->setVariable('TITLE', translate('Define Menu Access Rights'));
foreach($arrDescription AS $elem) { foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'],$elem['string']); $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 // Auswahlfeld einlesen
// ==================== // ====================
$strSQL = "SELECT A.`mnuId` , B.`mnuName` AS `mainitem`, A.`mnuName` AS `subitem`, A.`mnuGrpId` $strSQL = 'SELECT A.`mnuId` , B.`mnuName` AS `mainitem`, A.`mnuName` AS `subitem`, A.`mnuGrpId` '
FROM `tbl_menu` AS A . 'FROM `tbl_menu` AS A LEFT JOIN `tbl_menu` AS B ON A.`mnuTopId` = B.`mnuId` '
LEFT JOIN `tbl_menu` AS B ON A.`mnuTopId` = B.`mnuId` . 'ORDER BY A.`mnuTopId`, A.`mnuOrderId`';
ORDER BY A.`mnuTopId`, A.`mnuOrderId`"; $booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount);
if ($booReturn == false) { if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else { } else {
$conttp->setVariable("SUBMENU_VALUE","0"); $conttp->setVariable('SUBMENU_VALUE', '0');
$conttp->setVariable("SUBMENU_NAME","&nbsp;"); $conttp->setVariable('SUBMENU_NAME', '&nbsp;');
$conttp->parse("submenu"); $conttp->parse('submenu');
foreach($arrDataLines AS $elem) { foreach ($arrDataLines as $elem) {
$conttp->setVariable("SUBMENU_VALUE",$elem['mnuId']); $conttp->setVariable('SUBMENU_VALUE', $elem['mnuId']);
if ($elem['mainitem'] != '') { if ($elem['mainitem'] != '') {
$conttp->setVariable("SUBMENU_NAME",translate($elem['mainitem'])." - ".translate($elem['subitem'])); $conttp->setVariable('SUBMENU_NAME', translate($elem['mainitem']). ' - ' .translate($elem['subitem']));
} else { } else {
$conttp->setVariable("SUBMENU_NAME",translate($elem['subitem'])); $conttp->setVariable('SUBMENU_NAME', translate($elem['subitem']));
} }
if ($chkSelValue1 == $elem['mnuId']) { if ($chkSelValue1 == $elem['mnuId']) {
$conttp->setVariable("SUBMENU_SELECTED","selected"); $conttp->setVariable('SUBMENU_SELECTED', 'selected');
$intFieldId = $elem['mnuGrpId']; $intFieldId = $elem['mnuGrpId'];
} }
// Bypass main site // Bypass main site
if ($elem['mnuId'] != 1) $conttp->parse("submenu"); if ($elem['mnuId'] != 1) {
} $conttp->parse('submenu');
// Process access group selection field }
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); }
// Process access group selection field
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
} }
$conttp->setVariable("ERRORMESSAGE",$strErrorMessage); $conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
$conttp->setVariable("INFOMESSAGE",$strInfoMessage); $conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// Check access rights for adding new objects // Check access rights for adding new objects
if ($intGlobalWriteAccess == 1) $conttp->setVariable("DISABLE_SAVE","disabled=\"disabled\""); if ($intGlobalWriteAccess == 1) {
$conttp->parse("menuaccesssite"); $conttp->setVariable('DISABLE_SAVE', 'disabled="disabled"');
$conttp->show("menuaccesssite"); }
$conttp->parse('menuaccesssite');
$conttp->show('menuaccesssite');
// //
// Process footer // Process footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,86 +5,108 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin specials overview // Component : Admin specials overview
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 2; $prePageId = 2;
$preContent = "admin/mainpages.tpl.htm"; $preContent = 'admin/mainpages.htm.tpl';
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Include content // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate('Monitoring')); $conttp->setVariable('TITLE', translate('Monitoring'));
$conttp->parse("header"); $conttp->parse('header');
$conttp->show("header"); $conttp->show('header');
$conttp->setVariable("DESC",translate('To define host and service supervisions as well as host and service groups.')); $conttp->setVariable('DESC', translate('Define host and service supervisions as well as host and service groups.'));
$conttp->setVariable("STATISTICS",translate('Statistical datas')); $conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable("TYPE",translate('Group')); $conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable("ACTIVE",translate('Active')); $conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable("INACTIVE",translate('Inactive')); $conttp->setVariable('INACTIVE', translate('Inactive'));
// //
// Include statistical data // Include statistical data
// ======================== // ========================
// Get read access groups // Get read access groups
$strAccess = $myVisClass->getAccGroups('read'); $strAccess = $myVisClass->getAccessGroups('read');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=8")+0,'read') == 0) { $intAccessGrp8 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=8');
$conttp->setVariable("NAME",translate('Hosts')); $intAccessGrp9 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=9');
$conttp->setVariable("ACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_host` WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); $intAccessGrp10 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=10');
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_host` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); $intAccessGrp11 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=11');
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intAccessGrp9, 'read') == 0) {
$conttp->setVariable("NAME",translate('Services')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_service` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_service` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intAccessGrp10, 'read') == 0) {
$conttp->setVariable("NAME",translate('Host groups')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostgroup` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hostgroup` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intAccessGrp11, 'read') == 0) {
$conttp->setVariable("NAME",translate('Service groups')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicegroup` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_servicegroup` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intAccessGrp12, 'read') == 0) {
$conttp->setVariable("NAME",translate('Host templates')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hosttemplate` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hosttemplate` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intAccessGrp13, 'read') == 0) {
$conttp->setVariable("NAME",translate('Service templates')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicetemplate` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_servicetemplate` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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('statistics');
$conttp->parse("main"); $conttp->parse('main');
$conttp->show("main"); $conttp->show('main');
// //
// Include Footer // Include Footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,55 +5,60 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin timeperiod definitions // Component : Admin timeperiod definitions
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Date : $LastChangedDate: 2018-04-10 10:48:30 +0200 (Tue, 10 Apr 2018) $
// Author : $LastChangedBy: martin $ // Author : $LastChangedBy: martin $
// Version : 3.3.0 // Version : 3.4.0
// Revision : $LastChangedRevision: 2 $ // 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 // Define common variables
// ======================= // =======================
$preContent = "admin/mutdialog.tpl.htm"; $preContent = 'admin/mutdialog.htm.tpl';
// //
// Process post parameters // Process post parameters
// ======================= // =======================
$chkObject = isset($_GET['object']) ? htmlspecialchars($_GET['object'], ENT_QUOTES, 'utf-8') : ""; $intExclude = filter_input(INPUT_GET, 'exclude', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$intExclude = isset($_GET['exclude']) ? htmlspecialchars($_GET['exclude'], ENT_QUOTES, 'utf-8') : 0; $chkObject = filter_input(INPUT_GET, 'object', FILTER_SANITIZE_STRING);
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
$preNoMain = 1; $preNoMain = 1;
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
// //
// Include content // Include content
// =============== // ===============
$conttp->setVariable("BASE_PATH",$_SESSION['SETS']['path']['base_url']); $conttp->setVariable('BASE_PATH', $_SESSION['SETS']['path']['base_url']);
$conttp->setVariable("OPENER_FIELD",$chkObject); $conttp->setVariable('OPENER_FIELD', $chkObject);
$conttp->parse("header"); $conttp->parse('header');
$conttp->show("header"); $conttp->show('header');
// //
// Form // Form
// ==== // ====
foreach($arrDescription AS $elem) { foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'],$elem['string']); $conttp->setVariable($elem['name'], $elem['string']);
} }
$conttp->setVariable("OPENER_FIELD",$chkObject); $conttp->setVariable('OPENER_FIELD', $chkObject);
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)); $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('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
$conttp->setVariable("AVAILABLE",translate('Available')); $conttp->setVariable('AVAILABLE', translate('Available'));
$conttp->setVariable("SELECTED",translate('Selected')); $conttp->setVariable('SELECTED', translate('Selected'));
if (($intExclude == 1) || ($intVersion < 3)) { if (($intExclude == 1) || ($intVersion < 3)) {
$conttp->setVariable("DISABLE_HTML_BEGIN","<!--"); $conttp->setVariable('DISABLE_HTML_BEGIN', '<!--');
$conttp->setVariable("DISABLE_HTML_END","-->"); $conttp->setVariable('DISABLE_HTML_END', '-->');
} }
$conttp->parse("datainsert"); $conttp->parse('datainsert');
$conttp->show("datainsert"); $conttp->show('datainsert');
?>

View File

@ -5,149 +5,161 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin timeperiod definitions // Component : Admin timeperiod definitions
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 28; $prePageId = 28;
$preContent = "admin/nagioscfg.tpl.htm"; $preContent = 'admin/nagioscfg.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
$intRemoveTmp = 0; $intRemoveTmp = 0;
$strConfig = ""; $strConfig = '';
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Get configuration set ID // Get configuration set ID
// ======================== // ========================
$arrConfigSet = $myConfigClass->getConfigSets(); $myConfigClass->getConfigTargets($arrConfigSet);
$intConfigId = $arrConfigSet[0]; $intConfigId = $arrConfigSet[0];
$myConfigClass->getConfigData($intConfigId,"method",$intMethod); $myConfigClass->getConfigValues($intConfigId, 'method', $intMethod);
$myConfigClass->getConfigData($intConfigId,"nagiosbasedir",$strBaseDir); $myConfigClass->getConfigValues($intConfigId, 'nagiosbasedir', $strBaseDir);
$myConfigClass->getConfigData($intConfigId,"conffile",$strConfigfile); $myConfigClass->getConfigValues($intConfigId, 'conffile', $strConfigfile);
$strLocalBackup = $strConfigfile."_old_".date("YmdHis",time()); $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 // Process data
// ============ // ============
if ($chkTaFileText != "") { if (($chkTaFileText != '') && ($arrConfigSet[0] != 0)) {
if ($intMethod == 1) { if ($intMethod == 1) {
if (file_exists($strBaseDir) && (is_writable($strBaseDir) && (is_writable($strConfigfile)))) { if (file_exists($strBaseDir) && (is_writable($strBaseDir) && is_writable($strConfigfile))) {
// Backup config file // Backup config file
$intReturn = $myConfigClass->moveFile("nagiosbasic",basename($strConfigfile),$intConfigId); $intReturn = $myConfigClass->moveFile('nagiosbasic', basename($strConfigfile), $intConfigId);
if ($intReturn == 1) { if ($intReturn == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} }
// Write configuration // Write configuration
$resFile = fopen($strConfigfile,"w"); $resFile = fopen($strConfigfile, 'wb');
fputs($resFile,$chkTaFileText); fwrite($resFile, $chkTaFileText);
fclose($resFile); fclose($resFile);
$myVisClass->processMessage("<span style=\"color:green\">".translate('Configuration file successfully written!')."</span>",$strInfoMessage); $myVisClass->processMessage('<span style="color:green">' .translate('Configuration file successfully '
$myDataClass->writeLog(translate('Configuration successfully written:')." ".$strConfigfile); . 'written!'). '</span>', $strInfoMessage);
} else { $myDataClass->writeLog(translate('Configuration successfully written:'). ' ' .$strConfigfile);
$myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the permissions)!'),$strErrorMessage); } else {
$myDataClass->writeLog(translate('Configuration write failed:')." ".$strConfigfile); $myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the '
} . 'permissions)!'), $strErrorMessage);
} else if (($intMethod == 2) || ($intMethod == 3)) { $myDataClass->writeLog(translate('Configuration write failed:'). ' ' .$strConfigfile);
// Backup config file }
$intReturn = $myConfigClass->moveFile("nagiosbasic",basename($strConfigfile),$intConfigId); } elseif (($intMethod == 2) || ($intMethod == 3)) {
if ($intReturn == 1) { // Backup config file
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); $intReturn1 = $myConfigClass->moveFile('nagiosbasic', basename($strConfigfile), $intConfigId);
} if ($intReturn1 == 1) {
// Write file to temporary $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_conf'); }
$resFile = fopen($strFileName,"w"); // Write file to temporary
fputs($resFile,$chkTaFileText); $strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_conf');
fclose($resFile); $resFile = fopen($strFileName, 'wb');
// Copy configuration to remoty system fwrite($resFile, $chkTaFileText);
$intReturn = $myConfigClass->configCopy($strConfigfile,$intConfigId,$strFileName,1); fclose($resFile);
if ($intReturn == 0) { // Copy configuration to remoty system
$myVisClass->processMessage("<span style=\"color:green\">".translate('Configuration file successfully written!')."</span>",$strInfoMessage); $intReturn2 = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName, 1);
$myDataClass->writeLog(translate('Configuration successfully written:')." ".$strConfigfile); if ($intReturn2 == 0) {
unlink($strFileName); $myVisClass->processMessage('<span style="color:green">' .translate('Configuration file successfully '
} else { . 'written!'). '</span>', $strInfoMessage);
$myVisClass->processMessage(translate('Cannot open/overwrite the configuration file (check the permissions on remote system)!'),$strErrorMessage); $myDataClass->writeLog(translate('Configuration successfully written:'). ' ' .$strConfigfile);
$myDataClass->writeLog(translate('Configuration write failed (remote):')." ".$strConfigfile); unlink($strFileName);
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 // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate('Nagios main configuration file')); $conttp->setVariable('TITLE', translate('Nagios main configuration file'));
$conttp->parse("header"); $conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->show("header"); $conttp->setVariable('MAINSITE', $_SESSION['SETS']['path']['base_url']. 'admin.php');
// foreach ($arrDescription as $elem) {
// Include input form $conttp->setVariable($elem['name'], $elem['string']);
// ===================
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
$conttp->setVariable("MAINSITE",$_SESSION['SETS']['path']['base_url']."admin.php");
foreach($arrDescription AS $elem) {
$conttp->setVariable($elem['name'],$elem['string']);
} }
// //
// Open configuration // Open configuration
// ================== // ==================
if ($intMethod == 1) { if ($intMethod == 1) {
if (file_exists($strConfigfile) && is_readable($strConfigfile)) { if (file_exists($strConfigfile) && is_readable($strConfigfile)) {
$resFile = fopen($strConfigfile,"r"); $resFile = fopen($strConfigfile, 'rb');
if ($resFile) { if ($resFile) {
while(!feof($resFile)) { while (!feof($resFile)) {
$strConfig .= fgets($resFile,1024); $strConfig .= fgets($resFile, 1024);
} }
} }
} else { } else {
$myVisClass->processMessage(translate('Cannot open the data file (check the permissions)!'),$strErrorMessage); $myVisClass->processMessage(translate('Cannot open the data file (check the permissions)!'), $strErrorMessage);
} }
} else if (($intMethod == 2) || ($intMethod == 3)) { } elseif (($intMethod == 2) || ($intMethod == 3)) {
// Write file to temporary // Write file to temporary
$strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_conf'); $strFileName = tempnam($_SESSION['SETS']['path']['tempdir'], 'nagiosql_conf');
// Copy configuration from remoty system // Copy configuration from remoty system
$intReturn = $myConfigClass->configCopy($strConfigfile,$intConfigId,$strFileName,0); $intReturn = $myConfigClass->remoteFileCopy($strConfigfile, $intConfigId, $strFileName, 0);
if ($intReturn == 0) { if ($intReturn == 0) {
$resFile = fopen($strFileName,"r"); $resFile = fopen($strFileName, 'rb');
if (is_resource($resFile)) { if (is_resource($resFile)) {
while(!feof($resFile)) { while (!feof($resFile)) {
$strConfig .= fgets($resFile,1024); $strConfig .= fgets($resFile, 1024);
} }
unlink($strFileName); unlink($strFileName);
} else { } else {
$myVisClass->processMessage(translate('Cannot open the temporary file'),$strErrorMessage); $myVisClass->processMessage(translate('Cannot open the temporary file'), $strErrorMessage);
} }
} else { } else {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
$myDataClass->writeLog(translate('Configuration read failed (remote):')." ".$strErrorMessage); $myDataClass->writeLog(translate('Configuration read failed (remote):'). ' ' .$strErrorMessage);
if (file_exists($strFileName)) unlink($strFileName); if (file_exists($strFileName)) {
} unlink($strFileName);
}
}
} }
$conttp->setVariable("DAT_NAGIOS_CONFIG",$strConfig); $conttp->setVariable('DAT_NAGIOS_CONFIG', $strConfig);
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage); if ($strErrorMessage != '') {
$conttp->setVariable("INFOMESSAGE",$strInfoMessage); $conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
}
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// Check access rights for adding new objects // Check access rights for adding new objects
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\""); if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->parse("naginsert"); $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
$conttp->show("naginsert"); }
$conttp->parse('naginsert');
$conttp->show('naginsert');
// //
// Process footer // Process footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,71 +5,84 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Password administration // Component : Password administration
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 31; $prePageId = 31;
$preContent = "admin/admin_master.tpl.htm"; $preContent = 'admin/password.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
$preShowHeader = 0; $preShowHeader = 0;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Change password // Change password
// ======================= // =======================
if (($chkTfValue1 != "") && ($chkTfValue2 != "")) { if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
// Check old password // Check old password
$strSQL = "SELECT * FROM `tbl_user` WHERE `username`='".$_SESSION['username']."' AND `password`=MD5('$chkTfValue1')"; $strSQL = 'SELECT * FROM `tbl_user` '
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); . "WHERE `username`='".$_SESSION['username']."' AND `password`=MD5('$chkTfValue1')";
if ($booReturn == false) { $booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); if ($booReturn == false) {
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
} else if ($intDataCount == 1) { $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
// Check equality and password length } elseif ($intDataCount == 1) {
if (($chkTfValue2 === $chkTfValue3) && (strlen($chkTfValue2) >=5)) { // Check equality and password length
// Update database if (($chkTfValue2 === $chkTfValue3) && (strlen($chkTfValue2) >=5)) {
$strSQLUpdate = "UPDATE `tbl_user` SET `password`=MD5('$chkTfValue2'), // Update database
`last_login`=NOW() WHERE `username`='".$_SESSION['username']."'"; $strSQLUpdate = "UPDATE `tbl_user` SET `password`=MD5('$chkTfValue2'), `last_login`=NOW() "
$booReturn = $myDBClass->insertData($strSQLUpdate); . "WHERE `username`='".$_SESSION['username']."'";
if ($booReturn == true) { $booReturn = $myDBClass->insertData($strSQLUpdate);
$myDataClass->writeLog(translate('Password successfully modified')); if ($booReturn == true) {
// Force new login $myDataClass->writeLog(translate('Password successfully modified'));
$_SESSION['logged_in'] = 0; // Force new login
$_SESSION['username'] = ""; $_SESSION['logged_in'] = 0;
$_SESSION['userid'] = 0; $_SESSION['username'] = '';
$_SESSION['groupadm'] = 0; $_SESSION['userid'] = 0;
$_SESSION['domain'] = 0; $_SESSION['groupadm'] = 0;
header("Location: ".$SETS['path']['protocol']."://".$_SERVER['HTTP_HOST'].$_SESSION['SETS']['path']['base_url']."index.php"); $_SESSION['domain'] = 0;
} else { header('Location: ' .$SETS['path']['protocol']. '://' .
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING).
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $_SESSION['SETS']['path']['base_url']. 'index.php');
} } else {
} else { $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
// New password wrong $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Password too short or password fields unequally!'),$strErrorMessage); }
} } else {
} else { // New password wrong
// Old password wrong $myVisClass->processMessage(
$myVisClass->processMessage(translate('Old password is wrong'),$strErrorMessage); translate('Password too short or password fields do not match!'),
} $strErrorMessage
} else if (isset($_POST['submit'])) { );
// Wrong data }
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$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 // Output header variable
@ -78,25 +91,29 @@ echo $tplHeaderVar;
// //
// Include content // Include content
// =============== // ===============
foreach($arrDescription AS $elem) { foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'],$elem['string']); $conttp->setVariable($elem['name'], $elem['string']);
} }
$conttp->setVariable("LANG_SAVE",translate('Save')); $conttp->setVariable('LANG_SAVE', translate('Save'));
$conttp->setVariable("LANG_ABORT",translate('Abort')); $conttp->setVariable('LANG_ABORT', translate('Abort'));
$conttp->setVariable("FILL_ALLFIELDS",translate('Please fill in all fields marked with an *')); $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_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!')); $conttp->setVariable('FILL_NEW_PWDSHORT', translate('The new password is too short - use at least 6 characters!'));
if ($strErrorMessage != "") $conttp->setVariable("ERRORMESSAGE",$strErrorMessage); if ($strErrorMessage != '') {
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)); $conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
$conttp->setVariable("IMAGE_PATH",$_SESSION['SETS']['path']['base_url']."images/"); }
$conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable('IMAGE_PATH', $_SESSION['SETS']['path']['base_url']. 'images/');
// Check access rights for adding new objects // Check access rights for adding new objects
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\""); if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->parse("passwordsite"); $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
$conttp->show("passwordsite"); }
$conttp->parse('passwordsite');
$conttp->show('passwordsite');
// //
// Include footer // Include footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

File diff suppressed because it is too large Load Diff

View File

@ -5,322 +5,611 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Service escalation definition // Component : Service escalation definition
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 23; $prePageId = 23;
$preContent = "admin/serviceescalations.tpl.htm"; $preContent = 'admin/serviceescalations.htm.tpl';
$preSearchSession = 'serviceescalation'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_serviceescalation'; $preSearchSession = 'serviceescalation';
$preKeyField = 'config_name'; $preTableName = 'tbl_serviceescalation';
$preAccess = 1; $preKeyField = 'config_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Data processing // Data processing
// =============== // ===============
$strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d,0,-1); $strEO = substr($chkChbGr1a.$chkChbGr1b.$chkChbGr1c.$chkChbGr1d, 0, -1);
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `host_name`=$intMselValue1, `service_description`=$intMselValue3, `hostgroup_name`=$intMselValue2, $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `host_name`=$intMselValue1, "
`contacts`=$intMselValue4, `contact_groups`=$intMselValue5, `servicegroup_name`=$intMselValue6, `first_notification`=$chkTfNullVal1, . "`service_description`=$intMselValue3, `hostgroup_name`=$intMselValue2, `contacts`=$intMselValue4, "
`last_notification`=$chkTfNullVal2, `notification_interval`=$chkTfNullVal3, `escalation_period`='$chkSelValue1', `escalation_options`='$strEO', . "`contact_groups`=$intMselValue5, `servicegroup_name`=$intMselValue6, `first_notification`=$chkTfNullVal1, "
$preSQLCommon1"; . "`last_notification`=$chkTfNullVal2, `notification_interval`=$chkTfNullVal3, "
if ($chkModus == "insert") { . "`escalation_period`='$chkSelValue1', `escalation_options`='$strEO', $preSQLCommon1";
$strSQL = "INSERT INTO ".$strSQLx; if ($chkModus == 'insert') {
} else { $strSQL = 'INSERT INTO ' .$strSQLx;
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; } else {
} $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ($intWriteAccessId == 0) { }
if ((($intMselValue1 != 0) || ($intMselValue2 != 0) || ($intMselValue6 != 0)) && (($intMselValue3 != 0) || ($intMselValue6 != 0)) && if ($intWriteAccessId == 0) {
(($intMselValue5 != 0) || ($intMselValue4 != 0)) && ($chkTfNullVal1 != "NULL") && ($chkTfNullVal2 != "NULL") && ($chkTfNullVal3 != "NULL")) { if ((($intMselValue1 != 0) || ($intMselValue2 != 0) || ($intMselValue6 != 0)) && (($intMselValue3 != 0) ||
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); ($intMselValue6 != 0)) && (($intMselValue5 != 0) || ($intMselValue4 != 0)) && ($chkTfNullVal1 != 'NULL') &&
if ($chkModus == "insert") $chkDataId = $intInsertId; ($chkTfNullVal2 != 'NULL') && ($chkTfNullVal3 != 'NULL')) {
if ($intReturn == 1) { $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($chkModus == 'insert') {
} else { $chkDataId = $intInsertId;
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); }
$myDataClass->updateStatusTable($preTableName); if ($intReturn == 1) {
if ($chkModus == "insert") $myDataClass->writeLog(translate('New service escalation inserted:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "modify") $myDataClass->writeLog(translate('Service escalation modified:')." ".$chkTfValue1); } else {
// $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
// Insert/update relations $myDataClass->updateStatusTable($preTableName);
// ======================= if ($chkModus == 'insert') {
if ($chkModus == "insert") { $myDataClass->writeLog(translate('New service escalation inserted:'). ' ' .$chkTfValue1);
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToHost",$chkDataId,$chkMselValue1); }
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($chkModus == 'modify') {
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToHostgroup",$chkDataId,$chkMselValue2); $myDataClass->writeLog(translate('Service escalation modified:'). ' ' .$chkTfValue1);
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); // Insert/update relations
if ($intMselValue4 != 0) $intRet4 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToContact",$chkDataId,$chkMselValue4); // =======================
if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($chkModus == 'insert') {
if ($intMselValue5 != 0) $intRet5 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToContactgroup",$chkDataId,$chkMselValue5); if ($intMselValue1 != 0) {
if (isset($intRet5) && ($intRet5 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $intRet1 = $myDataClass->dataInsertRelation(
if ($intMselValue6 != 0) $intRet6 = $myDataClass->dataInsertRelation("tbl_lnkServiceescalationToServicegroup",$chkDataId,$chkMselValue6); 'tbl_lnkServiceescalationToHost',
if (isset($intRet6) && ($intRet6 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId,
} else if ($chkModus == "modify") { $chkMselValue1
if ($intMselValue1 != 0) { );
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToHost",$chkDataId,$chkMselValue1); }
} else { if (isset($intRet1) && ($intRet1 != 0)) {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToHost",$chkDataId); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($intMselValue2 != 0) {
if ($intMselValue2 != 0) { $intRet2 = $myDataClass->dataInsertRelation(
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToHostgroup",$chkDataId,$chkMselValue2); 'tbl_lnkServiceescalationToHostgroup',
} else { $chkDataId,
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToHostgroup",$chkDataId); $chkMselValue2
} );
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
if ($intMselValue3 != 0) { if (isset($intRet2) && ($intRet2 != 0)) {
$intRet3 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToService",$chkDataId,$chkMselValue3); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else { }
$intRet3 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToService",$chkDataId); if ($intMselValue3 != 0) {
} $intRet3 = $myDataClass->dataInsertRelation(
if (isset($intRet3) && ($intRet3 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); 'tbl_lnkServiceescalationToService',
if ($intMselValue4 != 0) { $chkDataId,
$intRet4 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToContact",$chkDataId,$chkMselValue4); $chkMselValue3
} else { );
$intRet4 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToContact",$chkDataId); }
} if (isset($intRet3) && ($intRet3 != 0)) {
if (isset($intRet4) && ($intRet4 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($intMselValue5 != 0) { }
$intRet5 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToContactgroup",$chkDataId,$chkMselValue5); if ($intMselValue4 != 0) {
} else { $intRet4 = $myDataClass->dataInsertRelation(
$intRet5 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToContactgroup",$chkDataId); 'tbl_lnkServiceescalationToContact',
} $chkDataId,
if (isset($intRet5) && ($intRet5 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkMselValue4
if ($intMselValue6 != 0) { );
$intRet6 = $myDataClass->dataUpdateRelation("tbl_lnkServiceescalationToServicegroup",$chkDataId,$chkMselValue6); }
} else { if (isset($intRet4) && ($intRet4 != 0)) {
$intRet6 = $myDataClass->dataDeleteRelation("tbl_lnkServiceescalationToServicegroup",$chkDataId); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
if (isset($intRet6) && ($intRet6 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($intMselValue5 != 0) {
} $intRet5 = $myDataClass->dataInsertRelation(
if (($intRet1 + $intRet2 + $intRet3 + $intRet4 + $intRet5 + $intRet6) != 0) $strInfoMessage = ""; 'tbl_lnkServiceescalationToContactgroup',
// $chkDataId,
// Update Import HASH $chkMselValue5
// ================== );
$booReturn = $myDataClass->updateHash($preTableName,$chkDataId); }
if ($booReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if (isset($intRet5) && ($intRet5 != 0)) {
} $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} else { }
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); if ($intMselValue6 != 0) {
} $intRet6 = $myDataClass->dataInsertRelation(
} else { 'tbl_lnkServiceescalationToServicegroup',
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); $chkDataId,
} $chkMselValue6
$chkModus = "display"; );
}
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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Define service escalation (serviceescalations.cfg)'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if (($chkModus == "add") || ($chkModus == "refresh")) { if (($chkModus == 'add') || ($chkModus == 'refresh')) {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Define service escalation (serviceescalations.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Refresh mode $intNoTime = 1;
if ($chkModus == "refresh") { // Refresh mode
$_SESSION['refresh']['se_host'] = $chkMselValue1; if ($chkModus == 'refresh') {
$_SESSION['refresh']['se_hostgroup'] = $chkMselValue2; $_SESSION['refresh']['se_host'] = $chkMselValue1;
$_SESSION['refresh']['se_service'] = $chkMselValue3; $_SESSION['refresh']['se_hostgroup'] = $chkMselValue2;
$_SESSION['refresh']['se_contact'] = $chkMselValue4; $_SESSION['refresh']['se_service'] = $chkMselValue3;
$_SESSION['refresh']['se_contactgroup'] = $chkMselValue5; $_SESSION['refresh']['se_contact'] = $chkMselValue4;
$_SESSION['refresh']['se_servicegroup'] = $chkMselValue6; $_SESSION['refresh']['se_contactgroup'] = $chkMselValue5;
} else { $_SESSION['refresh']['se_servicegroup'] = $chkMselValue6;
$_SESSION['refresh']['se_host'] = $chkMselValue1; $myVisClass->arrSession = $_SESSION;
$_SESSION['refresh']['se_hostgroup'] = $chkMselValue2; } else {
$_SESSION['refresh']['se_service'] = $chkMselValue3; $_SESSION['refresh']['se_host'] = $chkMselValue1;
$_SESSION['refresh']['se_contact'] = $chkMselValue4; $_SESSION['refresh']['se_hostgroup'] = $chkMselValue2;
$_SESSION['refresh']['se_contactgroup'] = $chkMselValue5; $_SESSION['refresh']['se_service'] = $chkMselValue3;
$_SESSION['refresh']['se_servicegroup'] = $chkMselValue6; $_SESSION['refresh']['se_contact'] = $chkMselValue4;
if (isset($arrModifyData['host_name']) && ($arrModifyData['host_name'] > 0 )){ $_SESSION['refresh']['se_contactgroup'] = $chkMselValue5;
$arrTemp = array(); $_SESSION['refresh']['se_servicegroup'] = $chkMselValue6;
$strSQL = "SELECT `idSlave`, `exclude` FROM `tbl_lnkServiceescalationToHost` WHERE `idMaster` = ".$arrModifyData['id']; if (isset($arrModifyData['host_name']) && ($arrModifyData['host_name'] > 0)) {
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDC); $arrTemp = array();
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $strSQL = 'SELECT `idSlave`, `exclude` '
if ($intDC != 0) { . 'FROM `tbl_lnkServiceescalationToHost` WHERE `idMaster` = ' .$arrModifyData['id'];
foreach ($arrData AS $elem) { $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
if ($elem['exclude'] == 1) { if ($booReturn == false) {
$arrTemp[] = "e".$elem['idSlave']; $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else { }
$arrTemp[] = $elem['idSlave']; if ($intDC != 0) {
} foreach ($arrData as $elem) {
} if ($elem['exclude'] == 1) {
} $arrTemp[] = 'e' .$elem['idSlave'];
if ($arrModifyData['host_name'] == 2) $arrTemp[] = '*'; } else {
$_SESSION['refresh']['se_host'] = $arrTemp; $arrTemp[] = $elem['idSlave'];
} }
if (isset($arrModifyData['hostgroup_name']) && ($arrModifyData['hostgroup_name'] > 0 )){ }
$arrTemp = array(); }
$strSQL = "SELECT `idSlave`, `exclude` FROM `tbl_lnkServiceescalationToHostgroup` WHERE `idMaster` = ".$arrModifyData['id']; if ($arrModifyData['host_name'] == 2) {
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDC); $arrTemp[] = '*';
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); }
if ($intDC != 0) { $_SESSION['refresh']['se_host'] = $arrTemp;
}
foreach ($arrData AS $elem) { if (isset($arrModifyData['hostgroup_name']) && ($arrModifyData['hostgroup_name'] > 0)) {
if ($elem['exclude'] == 1) { $arrTemp = array();
$arrTemp[] = "e".$elem['idSlave']; $strSQL = 'SELECT `idSlave`, `exclude` '
} else { . 'FROM `tbl_lnkServiceescalationToHostgroup` WHERE `idMaster` = ' .$arrModifyData['id'];
$arrTemp[] = $elem['idSlave']; $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
} if ($booReturn == false) {
} $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} }
if ($arrModifyData['hostgroup_name'] == 2) $arrTemp[] = '*'; if ($intDC != 0) {
$_SESSION['refresh']['se_hostgroup'] = $arrTemp; foreach ($arrData as $elem) {
} if ($elem['exclude'] == 1) {
} $arrTemp[] = 'e' .$elem['idSlave'];
// Process host selection field } else {
if (isset($arrModifyData['host_name'])) {$intFieldId = $arrModifyData['host_name'];} else {$intFieldId = 0;} $arrTemp[] = $elem['idSlave'];
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 ($arrModifyData['hostgroup_name'] == 2) {
if (($chkModus == "refresh") && (count($chkMselValue2) != 0)) {$strRefresh = 'se_hostgroup';} else {$strRefresh = '';} $arrTemp[] = '*';
$intReturn2 = $myVisClass->parseSelectMulti('tbl_hostgroup','hostgroup_name','hostgroup','tbl_lnkServiceescalationToHostgroup',2,$intFieldId,-9,$strRefresh); }
if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $_SESSION['refresh']['se_hostgroup'] = $arrTemp;
if (($intReturn1 != 0) && ($intReturn2 != 0)) { }
$myVisClass->processMessage(translate('Attention, no hosts and hostgroups defined!'),$strDBWarning); $myVisClass->arrSession = $_SESSION;
$intDataWarning = 1; }
} // Process host selection field
// Process time period selection field if (isset($arrModifyData['host_name'])) {
if (isset($arrModifyData['escalation_period'])) {$intFieldId = $arrModifyData['escalation_period'];} else {$intFieldId = 0;} $intFieldId = $arrModifyData['host_name'];
if ($chkModus == "refresh") $intFieldId = $chkSelValue1; } else {
$intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod','timeperiod_name','timeperiod',1,$intFieldId); $intFieldId = 0;
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Process contact and contact group selection field if (($chkModus == 'refresh') && is_array($chkMselValue1) && (count($chkMselValue1) != 0)) {
if (isset($arrModifyData['contacts'])) {$intFieldId = $arrModifyData['contacts'];} else {$intFieldId = 0;} $strRefresh = 'se_host';
if (($chkModus == "refresh") && (count($chkMselValue4) != 0)) {$strRefresh = 'se_contact';} else {$strRefresh = '';} } else {
$intReturn1 = $myVisClass->parseSelectMulti('tbl_contact','contact_name','contact','tbl_lnkServiceescalationToContact',2,$intFieldId,-9,$strRefresh); $strRefresh = '';
if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
if (isset($arrModifyData['contact_groups'])) {$intFieldId = $arrModifyData['contact_groups'];} else {$intFieldId = 0;} $intReturn1 = $myVisClass->parseSelectMulti(
if (($chkModus == "refresh") && (count($chkMselValue5) != 0)) {$strRefresh = 'se_contactgroup';} else {$strRefresh = '';} 'tbl_host',
$intReturn2 = $myVisClass->parseSelectMulti('tbl_contactgroup','contactgroup_name','contactgroup','tbl_lnkServiceescalationToContactgroup',2,$intFieldId,-9,$strRefresh); 'host_name',
if ($intReturn2 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); 'host',
if (($intReturn1 != 0) && ($intReturn2 != 0)) { 'tbl_lnkServiceescalationToHost',
$myVisClass->processMessage(translate('Attention, no contacts and contactgroups defined!'),$strDBWarning); 2,
$intDataWarning = 1; $intFieldId,
} -9,
// Process services selection field $strRefresh
if (isset($arrModifyData['service_description'])) {$intFieldId = $arrModifyData['service_description'];} else {$intFieldId = 0;} );
if (($chkModus == "refresh") && (count($chkMselValue3) != 0)) {$strRefresh = 'se_service';} else {$strRefresh = '';} if ($intReturn1 != 0) {
$intReturn = $myVisClass->parseSelectMulti('tbl_service','service_description','service','tbl_lnkServiceescalationToService',2,$intFieldId,-9,$strRefresh); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Process servicegroup selection field if (isset($arrModifyData['hostgroup_name'])) {
if (isset($arrModifyData['servicegroup_name'])) {$intFieldId = $arrModifyData['servicegroup_name'];} else {$intFieldId = 0;} $intFieldId = $arrModifyData['hostgroup_name'];
if (($chkModus == "refresh") && (count($chkMselValue6) != 0)) {$strRefresh = 'se_servicegroup';} else {$strRefresh = '';} } else {
$intReturn = $myVisClass->parseSelectMulti('tbl_servicegroup','servicegroup_name','servicegroup','tbl_lnkServiceescalationToServicegroup',0,$intFieldId,-9,$strRefresh); $intFieldId = 0;
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Process access group selection field if (($chkModus == 'refresh') && is_array($chkMselValue2) && (count($chkMselValue2) != 0)) {
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} $strRefresh = 'se_hostgroup';
if ($chkModus == "refresh") $intFieldId = $chkSelAccGr; } else {
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); $strRefresh = '';
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Initial add/modify form definitions $intReturn2 = $myVisClass->parseSelectMulti(
$myContentClass->addFormInit($conttp); 'tbl_hostgroup',
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); 'hostgroup_name',
if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,"); 'hostgroup',
if ($chkModus == "refresh") { 'tbl_lnkServiceescalationToHostgroup',
if ($chkTfNullVal1 != "NULL") $conttp->setVariable("DAT_FIRST_NOTIFICATION",$chkTfNullVal1); 2,
if ($chkTfNullVal2 != "NULL") $conttp->setVariable("DAT_LAST_NOTIFICATION",$chkTfNullVal2); $intFieldId,
if ($chkTfNullVal3 != "NULL") $conttp->setVariable("DAT_NOTIFICATION_INTERVAL",$chkTfNullVal3); -9,
if ($chkTfValue1 != "") $conttp->setVariable("DAT_CONFIG_NAME",$chkTfValue1); $strRefresh
foreach(explode(",",$strEO) AS $elem) { );
$conttp->setVariable("DAT_EO".strtoupper($elem)."_CHECKED","checked"); if ($intReturn2 != 0) {
} $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
if ($chkActive != 1) $conttp->setVariable("ACT_CHECKED",""); }
if ($chkRegister != 1) $conttp->setVariable("REG_CHECKED",""); if (($intReturn1 != 0) && ($intReturn2 != 0)) {
if ($chkDataId != 0) { $myVisClass->processMessage(translate('Attention, no hosts and hostgroups defined!'), $strDBWarning);
$conttp->setVariable("MODUS","modify"); $intDataWarning = 1;
$conttp->setVariable("DAT_ID",$chkDataId); }
} // Process time period selection field
// Insert data from database in "modify" mode if (isset($arrModifyData['escalation_period'])) {
} else if (isset($arrModifyData) && ($chkSelModify == "modify")) { $intFieldId = $arrModifyData['escalation_period'];
// Check relation information to find out locked configuration datasets } else {
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); $intFieldId = 0;
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); }
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; if ($chkModus == 'refresh') {
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; $intFieldId = $chkSelValue1;
// Process data }
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo); $intReturn = $myVisClass->parseSelectSimple('tbl_timeperiod', 'timeperiod_name', 'timeperiod', 1, $intFieldId);
// Process option fields if ($intReturn != 0) {
foreach(explode(",",$arrModifyData['escalation_options']) AS $elem) { $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$conttp->setVariable("DAT_EO".strtoupper($elem)."_CHECKED","checked"); }
} // Process contact and contact group selection field
} if (isset($arrModifyData['contacts'])) {
$conttp->parse("datainsert"); $intFieldId = $arrModifyData['contacts'];
$conttp->show("datainsert"); } else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue4) && (count($chkMselValue4) != 0)) {
$strRefresh = 'se_contact';
} else {
$strRefresh = '';
}
$intReturn1 = $myVisClass->parseSelectMulti(
'tbl_contact',
'contact_name',
'contact',
'tbl_lnkServiceescalationToContact',
2,
$intFieldId,
-9,
$strRefresh
);
if ($intReturn1 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (isset($arrModifyData['contact_groups'])) {
$intFieldId = $arrModifyData['contact_groups'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue5) && (count($chkMselValue5) != 0)) {
$strRefresh = 'se_contactgroup';
} else {
$strRefresh = '';
}
$intReturn2 = $myVisClass->parseSelectMulti(
'tbl_contactgroup',
'contactgroup_name',
'contactgroup',
'tbl_lnkServiceescalationToContactgroup',
2,
$intFieldId,
-9,
$strRefresh
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
if (($intReturn1 != 0) && ($intReturn2 != 0)) {
$myVisClass->processMessage(translate('Attention, no contacts and contactgroups defined!'), $strDBWarning);
$intDataWarning = 1;
}
// Process services selection field
if (isset($arrModifyData['service_description'])) {
$intFieldId = $arrModifyData['service_description'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue3) && (count($chkMselValue3) != 0)) {
$strRefresh = 'se_service';
} else {
$strRefresh = '';
}
$intReturn = $myVisClass->parseSelectMulti(
'tbl_service',
'service_description',
'service',
'tbl_lnkServiceescalationToService',
2,
$intFieldId,
-9,
$strRefresh
);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process servicegroup selection field
if (isset($arrModifyData['servicegroup_name'])) {
$intFieldId = $arrModifyData['servicegroup_name'];
} else {
$intFieldId = 0;
}
if (($chkModus == 'refresh') && is_array($chkMselValue6) && (count($chkMselValue6) != 0)) {
$strRefresh = 'se_servicegroup';
} else {
$strRefresh = '';
}
$intReturn = $myVisClass->parseSelectMulti(
'tbl_servicegroup',
'servicegroup_name',
'servicegroup',
'tbl_lnkServiceescalationToServicegroup',
0,
$intFieldId,
-9,
$strRefresh
);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
if ($chkModus == 'refresh') {
$intFieldId = $chkSelAccGr;
}
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
if ($chkModus == 'refresh') {
if ($chkTfNullVal1 != 'NULL') {
$conttp->setVariable('DAT_FIRST_NOTIFICATION', $chkTfNullVal1);
}
if ($chkTfNullVal2 != 'NULL') {
$conttp->setVariable('DAT_LAST_NOTIFICATION', $chkTfNullVal2);
}
if ($chkTfNullVal3 != 'NULL') {
$conttp->setVariable('DAT_NOTIFICATION_INTERVAL', $chkTfNullVal3);
}
if ($chkTfValue1 != '') {
$conttp->setVariable('DAT_CONFIG_NAME', $chkTfValue1);
}
foreach (explode(',', $strEO) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
}
if ($chkActive != 1) {
$conttp->setVariable('ACT_CHECKED', '');
}
if ($chkRegister != 1) {
$conttp->setVariable('REG_CHECKED', '');
}
if ($chkDataId != 0) {
$conttp->setVariable('MODUS', 'modify');
$conttp->setVariable('DAT_ID', $chkDataId);
}
// Insert data from database in "modify" mode
} elseif (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
.'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
// Process option fields
foreach (explode(',', $arrModifyData['escalation_options']) as $elem) {
$conttp->setVariable('DAT_EO' .strtoupper($elem). '_CHECKED', 'checked');
}
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Config name')); $mastertp->setVariable('TITLE', translate('Define service escalation (serviceescalations.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Services')); $mastertp->setVariable('FIELD_1', translate('Config name'));
// Process search string $mastertp->setVariable('FIELD_2', translate('Services'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process search string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')"; $strSearchTxt = $_SESSION['search'][$preSearchSession];
} $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%')";
// Row sorting }
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
$mastertp->setVariable("DISABLE_SORT_2","disable"); if ($hidSortBy == 2) {
// Count datasets $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; }
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); $mastertp->setVariable('DISABLE_SORT_2', 'disable');
if ($booReturn == false) { // Count datasets
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)";
} else { $booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
$intLineCount = (int)$arrDataLinesCount['number']; if ($booReturn == false) {
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
} $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
// Get datasets } else {
$strSQL = "SELECT `id`, `$preKeyField`, `service_description`, `register`, `active`, `config_id`, `access_group` FROM `$preTableName` $intLineCount = (int)$arrDataLinesCount['number'];
WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; if ($intLineCount < $chkLimit) {
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); $chkLimit = 0;
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); }
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); // Get datasets
} $strSQL = "SELECT `id`, `$preKeyField`, `service_description`, `register`, `active`, `config_id`, "
// Process data . "`access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'process_field',40); . "($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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,199 +5,275 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Service extended information definition // Component : Service extended information definition
// Website : http://www.nagiosql.org // Component : Service escalation definition
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Website : https://sourceforge.net/projects/nagiosql/
// Author : $LastChangedBy: martin $ // Version : 3.4.0
// Version : 3.3.0 // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 24; $prePageId = 24;
$preContent = "admin/serviceextinfo.tpl.htm"; $preContent = 'admin/serviceextinfo.htm.tpl';
$preSearchSession = 'serviceextinfo'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_serviceextinfo'; $preSearchSession = 'serviceextinfo';
$preKeyField = 'host_name'; $preTableName = 'tbl_serviceextinfo';
$preAccess = 1; $preKeyField = 'host_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkSelValue1', `service_description`='$chkSelValue2', `notes`='$chkTfValue1', `notes_url`='$chkTfValue2', $strSQLx = "`$preTableName` SET `$preKeyField`='$chkSelValue1', `service_description`='$chkSelValue2', "
`action_url`='$chkTfValue3', `icon_image`='$chkTfValue4', `icon_image_alt`='$chkTfValue5', $preSQLCommon1"; . "`notes`='$chkTfValue1', `notes_url`='$chkTfValue2', `action_url`='$chkTfValue3', "
if ($chkModus == "insert") { . "`icon_image`='$chkTfValue4', `icon_image_alt`='$chkTfValue5', $preSQLCommon1";
$strSQL = "INSERT INTO ".$strSQLx; if ($chkModus == 'insert') {
} else { $strSQL = 'INSERT INTO ' .$strSQLx;
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; } else {
} $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ($intWriteAccessId == 0) { }
if (($chkSelValue1 != 0) && ($chkSelValue2 != 0)) { if ($intWriteAccessId == 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if (($chkSelValue1 != 0) && ($chkSelValue2 != 0)) {
if ($chkModus == "insert") $chkDataId = $intInsertId; $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn == 1) { if ($chkModus == 'insert') {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId = $intInsertId;
} else { }
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($intReturn == 1) {
$myDataClass->updateStatusTable($preTableName); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "insert") $myDataClass->writeLog(translate('New service extended information inserted:')." ".$chkSelValue1."::".$chkSelValue2); } else {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Service extended information modified:')." ".$chkSelValue1."::".$chkSelValue2); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
// $myDataClass->updateStatusTable($preTableName);
// Update Import HASH if ($chkModus == 'insert') {
// ================== $myDataClass->writeLog(translate('New service extended information inserted:'). ' ' .$chkSelValue1.
$booReturn = $myDataClass->updateHash($preTableName,$chkDataId); '::' .$chkSelValue2);
if ($booReturn != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} if ($chkModus == 'modify') {
} else { $myDataClass->writeLog(translate('Service extended information modified:'). ' ' .$chkSelValue1.
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); '::' .$chkSelValue2);
} }
} else { //
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); // Update Import HASH
} // ==================
$chkModus = "display"; $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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Define service extended information (serviceextinfo.cfg)'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if (($chkModus == "add") || ($chkModus == "refresh")) { if (($chkModus == 'add') || ($chkModus == 'refresh')) {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Define service extended information (serviceextinfo.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Refresh mode $intNoTime = 1;
if ($chkModus == "refresh") { // Refresh mode
$_SESSION['refresh']['se_host'] = $chkSelValue1; if ($chkModus == 'refresh') {
} else { $_SESSION['refresh']['se_host'] = $chkSelValue1;
$_SESSION['refresh']['se_host'] = $chkSelValue1; $myVisClass->arrSession = $_SESSION;
if (isset($arrModifyData[$preKeyField]) && ($arrModifyData[$preKeyField] != 0 )){ } else {
$strSQL = "SELECT `$preKeyField` FROM `$preTableName` WHERE `id` = ".$arrModifyData['id']; $_SESSION['refresh']['se_host'] = $chkSelValue1;
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDC); if (isset($arrModifyData[$preKeyField]) && ($arrModifyData[$preKeyField] != 0)) {
if ($intDC != 0) { $strSQL = "SELECT `$preKeyField` FROM `$preTableName` WHERE `id` = ".$arrModifyData['id'];
$_SESSION['refresh']['se_host'] = $arrData[0][$preKeyField]; $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDC);
} if ($intDC != 0) {
} else { $_SESSION['refresh']['se_host'] = $arrData[0][$preKeyField];
$strSQL = "SELECT `id` FROM `tbl_host` WHERE `active`='1' AND `config_id`=$chkDomainId ORDER BY `$preKeyField`"; }
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDC); } else {
if ($intDC != 0) { $strSQL = 'SELECT `id` FROM `tbl_host` '
$_SESSION['refresh']['se_host'] = $arrData[0]['id']; . "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'];
// Process host selection field }
if (isset($arrModifyData[$preKeyField])) {$intFieldId = $arrModifyData[$preKeyField];} else {$intFieldId = 0;} }
if (($chkModus == "refresh") && ($chkSelValue1 != 0)) $intFieldId = $chkSelValue1; $myVisClass->arrSession = $_SESSION;
$intReturn1 = $myVisClass->parseSelectSimple('tbl_host',$preKeyField,'host',0,$intFieldId); }
if ($intReturn1 != 0) { // Process host selection field
$myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); if (isset($arrModifyData[$preKeyField])) {
$myVisClass->processMessage(translate('Attention, no hosts defined!'),$strDBWarning); $intFieldId = $arrModifyData[$preKeyField];
$intDataWarning = 1; } else {
} $intFieldId = 0;
// Process service selection field }
if (isset($arrModifyData['service_description'])) {$intFieldId = $arrModifyData['service_description'];} else {$intFieldId = 0;} if (($chkModus == 'refresh') && ($chkSelValue1 != 0)) {
$intReturn1 = $myVisClass->parseSelectSimple('tbl_service','service_description','service_extinfo',0,$intFieldId); $intFieldId = $chkSelValue1;
if ($intReturn1 != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); }
// Process access group selection field $intReturn1 = $myVisClass->parseSelectSimple('tbl_host', $preKeyField, 'host', 0, $intFieldId);
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} if ($intReturn1 != 0) {
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage(translate('Attention, no hosts defined!'), $strDBWarning);
// Initial add/modify form definitions $intDataWarning = 1;
$myContentClass->addFormInit($conttp); }
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); // Process service selection field
if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,"); if (isset($arrModifyData['service_description'])) {
if ($chkModus == "refresh") { $intFieldId = $arrModifyData['service_description'];
$conttp->setVariable("DAT_NOTES",$chkTfValue1); } else {
$conttp->setVariable("DAT_NOTES_URL",$chkTfValue2); $intFieldId = 0;
$conttp->setVariable("DAT_ACTION_URL",$chkTfValue3); }
$conttp->setVariable("DAT_ICON_IMAGE",$chkTfValue4); $intReturn1 = $myVisClass->parseSelectSimple(
$conttp->setVariable("DAT_ICON_IMAGE_ALT",$chkTfValue5); 'tbl_service',
if ($chkActive != 1) $conttp->setVariable("ACT_CHECKED",""); 'service_description',
if ($chkRegister != 1) $conttp->setVariable("REG_CHECKED",""); 'service_extinfo',
if ($chkDataId != 0) { 0,
$conttp->setVariable("MODUS","modify"); $intFieldId
$conttp->setVariable("DAT_ID",$chkDataId); );
} if ($intReturn1 != 0) {
// Insert data from database in "modify" mode $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
} else if (isset($arrModifyData) && ($chkSelModify == "modify")) { }
// Check relation information to find out locked configuration datasets // Process access group selection field
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); if (isset($arrModifyData['access_group'])) {
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); $intFieldId = $arrModifyData['access_group'];
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; } else {
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; $intFieldId = 0;
// Process data }
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo); $intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
} if ($intReturn != 0) {
$conttp->parse("datainsert"); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$conttp->show("datainsert"); }
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
if ($chkModus == 'refresh') {
$conttp->setVariable('DAT_NOTES', $chkTfValue1);
$conttp->setVariable('DAT_NOTES_URL', $chkTfValue2);
$conttp->setVariable('DAT_ACTION_URL', $chkTfValue3);
$conttp->setVariable('DAT_ICON_IMAGE', $chkTfValue4);
$conttp->setVariable('DAT_ICON_IMAGE_ALT', $chkTfValue5);
if ($chkActive != 1) {
$conttp->setVariable('ACT_CHECKED', '');
}
if ($chkRegister != 1) {
$conttp->setVariable('REG_CHECKED', '');
}
if ($chkDataId != 0) {
$conttp->setVariable('MODUS', 'modify');
$conttp->setVariable('DAT_ID', $chkDataId);
}
// Insert data from database in "modify" mode
} elseif (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
.'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Hostname')); $mastertp->setVariable('TITLE', translate('Define service extended information (serviceextinfo.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Service')); $mastertp->setVariable('FIELD_1', translate('Hostname'));
// Process search string $mastertp->setVariable('FIELD_2', translate('Service'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process search string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`tbl_host`.`$preKeyField` LIKE '%".$strSearchTxt."%' OR `$preTableName`.`notes` LIKE '%".$strSearchTxt."%' $strSearchTxt = $_SESSION['search'][$preSearchSession];
OR `$preTableName`.`notes_url` LIKE '%".$strSearchTxt."%')"; $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"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `$preTableName`.`config_id`, `tbl_service`.`service_description` $hidSortDir"; $strOrderString = "ORDER BY `$preTableName`.`config_id`, `$preKeyField` $hidSortDir";
// Count datasets if ($hidSortBy == 2) {
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField` = `tbl_host`.`id` $strOrderString = "ORDER BY `$preTableName`.`config_id`, `tbl_service`.`service_description` $hidSortDir";
LEFT JOIN `tbl_service` ON `$preTableName`.`service_description` = `tbl_service`.`id` }
WHERE $strDomainWhere $strSearchWhere AND `$preTableName`.`access_group` IN ($strAccess)"; // Count datasets
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` "
if ($booReturn == false) { . "LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField` = `tbl_host`.`id` "
$myVisClass->processMessage(translate('Error while selecting data from database:')); . "LEFT JOIN `tbl_service` ON `$preTableName`.`service_description` = `tbl_service`.`id` "
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "WHERE $strDomainWhere $strSearchWhere AND `$preTableName`.`access_group` IN ($strAccess)";
} else { $booReturn = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
$intCount = (int)$arrDataLinesCount['number']; if ($booReturn == false) {
if ($intCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
} $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
// Get datasets } else {
$strSQL = "SELECT `$preTableName`.`id`, `tbl_host`.`$preKeyField`, `tbl_service`.`service_description`, `$preTableName`.`notes`, `$preTableName`.`register`, $intLineCount = (int)$arrDataLinesCount['number'];
`$preTableName`.`active`, `$preTableName`.`config_id`, `$preTableName`.`access_group` FROM `$preTableName` if ($intLineCount < $chkLimit) {
LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField` = `tbl_host`.`id` $chkLimit = 0;
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']; // Get datasets
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); $strSQL = "SELECT `$preTableName`.`id`, `tbl_host`.`$preKeyField`, `tbl_service`.`service_description`, "
if ($booReturn == false) { . "`$preTableName`.`notes`, `$preTableName`.`register`, `$preTableName`.`active`, `$preTableName`.`config_id`, "
$myVisClass->processMessage(translate('Error while selecting data from database:')); . "`$preTableName`.`access_group` FROM `$preTableName` "
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "LEFT JOIN `tbl_host` ON `$preTableName`.`$preKeyField` = `tbl_host`.`id` "
} . "LEFT JOIN `tbl_service` ON `$preTableName`.`service_description` = `tbl_service`.`id` "
// Process data . "WHERE $strDomainWhere $strSearchWhere AND `$preTableName`.`access_group` IN ($strAccess) $strOrderString "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'service_description'); . "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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,179 +5,277 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Admin servicegroup definition // Component : Admin servicegroup definition
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 11; $prePageId = 11;
$preContent = "admin/servicegroups.tpl.htm"; $preContent = 'admin/servicegroups.htm.tpl';
$preSearchSession = 'servicegroup'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_servicegroup'; $preSearchSession = 'servicegroup';
$preKeyField = 'servicegroup_name'; $preTableName = 'tbl_servicegroup';
$preAccess = 1; $preKeyField = 'servicegroup_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, `servicegroup_members`=$intMselValue2, $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `members`=$intMselValue1, "
`notes`='$chkTfValue3', `notes_url`='$chkTfValue4', `action_url`='$chkTfValue5', $preSQLCommon1"; . "`servicegroup_members`=$intMselValue2, `notes`='$chkTfValue3', `notes_url`='$chkTfValue4', "
if ($chkModus == "insert") { . "`action_url`='$chkTfValue5', $preSQLCommon1";
$strSQL = "INSERT INTO ".$strSQLx; if ($chkModus == 'insert') {
} else { $strSQL = 'INSERT INTO ' .$strSQLx;
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; } else {
} $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
if ($intWriteAccessId == 0) { }
if (($chkTfValue1 != "") && ($chkTfValue2 != "") && (($intMselValue1 != 0) || ($intVersion == 3))) { if ($intWriteAccessId == 0) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); if (($chkTfValue1 != '') && ($chkTfValue2 != '') && (($intMselValue1 != 0) || ($intVersion >= 3))) {
if ($chkModus == "insert") $chkDataId = $intInsertId; $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($intReturn == 1) { if ($chkModus == 'insert') {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId = $intInsertId;
} else { }
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($intReturn == 1) {
$myDataClass->updateStatusTable($preTableName); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($chkModus == "insert") $myDataClass->writeLog(translate('New service group inserted:')." ".$chkTfValue1); } else {
if ($chkModus == "modify") $myDataClass->writeLog(translate('Service group modified:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
// $myDataClass->updateStatusTable($preTableName);
// Insert/update relations if ($chkModus == 'insert') {
// ======================= $myDataClass->writeLog(translate('New service group inserted:'). ' ' .$chkTfValue1);
if ($chkModus == "insert") { }
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkServicegroupToService",$chkDataId,$chkMselValue1,1); if ($chkModus == 'modify') {
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myDataClass->writeLog(translate('Service group modified:'). ' ' .$chkTfValue1);
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkServicegroupToServicegroup",$chkDataId,$chkMselValue2); }
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); //
} else if ($chkModus == "modify") { // Insert/update relations
if ($intMselValue1 != 0) { // =======================
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkServicegroupToService",$chkDataId,$chkMselValue1,1); if ($chkModus == 'insert') {
} else { if ($intMselValue1 != 0) {
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkServicegroupToService",$chkDataId); $intRet1 = $myDataClass->dataInsertRelation(
} 'tbl_lnkServicegroupToService',
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkDataId,
if ($intMselValue2 != 0) { $chkMselValue1,
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkServicegroupToServicegroup",$chkDataId,$chkMselValue2); 1
} else { );
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkServicegroupToServicegroup",$chkDataId); }
} if (isset($intRet1) && ($intRet1 != 0)) {
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
if (($intRet1 + $intRet2) != 0) $strInfoMessage = ""; if ($intMselValue2 != 0) {
} $intRet2 = $myDataClass->dataInsertRelation(
} else { 'tbl_lnkServicegroupToServicegroup',
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); $chkDataId,
} $chkMselValue2
} else { );
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); }
} if (isset($intRet2) && ($intRet2 != 0)) {
$chkModus = "display"; $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 // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Define service groups (servicegroups.cfg)'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Define service groups (servicegroups.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Process service selection field $intNoTime = 1;
$intReturn = 0; // Process service selection field
if (isset($arrModifyData['members'])) {$intFieldId = $arrModifyData['members'];} else {$intFieldId = 0;} if (isset($arrModifyData['members'])) {
$intReturn = $myVisClass->parseSelectMulti('tbl_service','service_description','service_members','tbl_lnkServicegroupToService',0,$intFieldId); $intFieldId = $arrModifyData['members'];
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); } else {
if (($intReturn != 0) && ($intVersion != 3)) { $intFieldId = 0;
$myVisClass->processMessage(translate('Attention, no services defined!'),$strDBWarning); }
$intDataWarning = 1; $intReturn1 = $myVisClass->parseSelectMulti(
} 'tbl_service',
// Process service group selection field 'service_description',
if (isset($arrModifyData['servicegroup_members'])) {$intFieldId = $arrModifyData['servicegroup_members'];} else {$intFieldId = 0;} 'service_members',
$intReturn = $myVisClass->parseSelectMulti($preTableName,$preKeyField,'servicegroups','tbl_lnkServicegroupToServicegroup',0,$intFieldId,$chkListId); 'tbl_lnkServicegroupToService',
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); 0,
// Process access group selection field $intFieldId
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} );
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); if ($intReturn1 != 0) {
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
// Initial add/modify form definitions }
$myContentClass->addFormInit($conttp); if (($intReturn1 != 0) && ($intVersion < 3)) {
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); $myVisClass->processMessage(translate('Attention, no services defined!'), $strDBWarning);
if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,"); $intDataWarning = 1;
// Insert data from database in "modify" mode }
if (isset($arrModifyData) && ($chkSelModify == "modify")) { // Process service group selection field
// Check relation information to find out locked configuration datasets if (isset($arrModifyData['servicegroup_members'])) {
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); $intFieldId = $arrModifyData['servicegroup_members'];
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); } else {
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; $intFieldId = 0;
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; }
// Process data $intReturn2 = $myVisClass->parseSelectMulti(
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo); $preTableName,
} $preKeyField,
$conttp->parse("datainsert"); 'servicegroups',
$conttp->show("datainsert"); 'tbl_lnkServicegroupToServicegroup',
0,
$intFieldId,
$chkListId
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process access group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Service group')); $mastertp->setVariable('TITLE', translate('Define service groups (servicegroups.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Service group'));
// Process search string $mastertp->setVariable('FIELD_2', translate('Description'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process search string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' OR `notes` LIKE '%".$strSearchTxt."%')"; $strSearchTxt = $_SESSION['search'][$preSearchSession];
} $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' "
// Row sorting . "OR `notes` LIKE '%".$strSearchTxt."%')";
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; }
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir"; // Row sorting
// Count datasets $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; if ($hidSortBy == 2) {
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); // Count datasets
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $strSQL1 = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
} else { . "AND `access_group` IN ($strAccess)";
$intLineCount = (int)$arrDataLinesCount['number']; $booReturn1 = $myDBClass->hasSingleDataset($strSQL1, $arrDataLinesCount);
if ($intLineCount < $chkLimit) $chkLimit = 0; if ($booReturn1 == false) {
} $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
// Get datasets $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere } else {
AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; $intLineCount = (int)$arrDataLinesCount['number'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); if ($intLineCount < $chkLimit) {
if ($booReturn == false) { $chkLimit = 0;
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); }
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); }
} // Get datasets
// Process data $strSQL2 = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias'); . "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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,257 +5,325 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Settings configuration // Component : Settings configuration
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 38; $prePageId = 38;
$preContent = "admin/settings.tpl.htm"; $preContent = 'admin/settings.htm.tpl';
$preAccess = 1; $preAccess = 1;
$preFieldvars = 1; $preFieldvars = 1;
$arrSQL = array();
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Process initial values // Process initial values
// ====================== // ======================
if (!isset($_POST['tfValue1'])) $chkTfValue1 = $SETS['path']['tempdir']; if (filter_input(INPUT_POST, 'tfValue1') == null) {
if (!isset($_POST['tfValue2'])) $chkTfValue2 = $SETS['data']['encoding']; $chkTfValue1 = $SETS['path']['tempdir'];
if (!isset($_POST['tfValue3'])) $chkTfValue3 = $SETS['db']['server']; }
if (!isset($_POST['tfValue4'])) $chkTfValue4 = $SETS['db']['port']; if (filter_input(INPUT_POST, 'tfValue2') == null) {
if (!isset($_POST['tfValue5'])) $chkTfValue5 = $SETS['db']['database']; $chkTfValue2 = $SETS['data']['encoding'];
if (!isset($_POST['tfValue6'])) $chkTfValue6 = $SETS['db']['username']; }
if (!isset($_POST['tfValue7'])) $chkTfValue7 = $SETS['db']['password']; if (filter_input(INPUT_POST, 'tfValue3') == null) {
if (!isset($_POST['tfValue8'])) $chkTfValue8 = $SETS['security']['logofftime']; $chkTfValue3 = $SETS['db']['server'];
if (!isset($_POST['tfValue9'])) $chkTfValue9 = $SETS['common']['pagelines']; }
if (!isset($_POST['tfValue10'])) $chkTfValue10 = $SETS['network']['proxyserver']; if (filter_input(INPUT_POST, 'tfValue4') == null) {
if (!isset($_POST['tfValue11'])) $chkTfValue11 = $SETS['network']['proxyuser']; $chkTfValue4 = $SETS['db']['port'];
if (!isset($_POST['tfValue12'])) $chkTfValue12 = $SETS['network']['proxypasswd']; }
if (!isset($_POST['selValue3'])) $chkSelValue3 = $SETS['security']['wsauth']; if (filter_input(INPUT_POST, 'tfValue5') == null) {
if (!isset($_POST['selValue4'])) $chkSelValue4 = $SETS['common']['seldisable']; $chkTfValue5 = $SETS['db']['database'];
if (!isset($_POST['radValue1'])) $chkRadValue1 = $SETS['common']['tplcheck']; }
if (!isset($_POST['radValue2'])) $chkRadValue2 = $SETS['common']['updcheck']; if (filter_input(INPUT_POST, 'tfValue6') == null) {
if (!isset($_POST['radValue3'])) $chkRadValue3 = $SETS['network']['proxy']; $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 // Save changes
// ============ // ============
if (isset($_POST) && isset($_POST['selValue1'])) { if (filter_input(INPUT_POST, 'selValue1')) {
// //
// Write settings to database // Write settings to database
// ========================== // ==========================
if ($chkSelValue1 == 2) {$strProtocol = "https";} else {$strProtocol = "http";} if ($chkSelValue1 == 2) {
$strLocale = $myDBClass->getFieldData("SELECT `locale` FROM `tbl_language` WHERE `id`='".$chkSelValue2."'"); $strProtocol = 'https';
if ($strLocale == "") $strLocale = "en_GB"; } else {
// Check Proxy via curl $strProtocol = 'http';
if (!function_exists('curl_init')) { }
$myVisClass->processMessage(translate('Curl module not loaded, Proxy will be deactivated!'),$strErrorMessage); $strLocale = $myDBClass->getFieldData("SELECT `locale` FROM `tbl_language` WHERE `id`='".$chkSelValue2."'");
$chkRadValue3 = 0; if ($strLocale == '') {
} $strLocale = 'en_GB';
// Check base paths }
$strBaseURL = str_replace("admin/settings.php","",$_SERVER["PHP_SELF"]); $SETS['path']['protocol'] = $strProtocol;
$strBasePath = substr(realpath('.'),0,-5); $SETS['data']['locale'] = $strLocale;
$arrSQL = ""; // Check Proxy via curl
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$strProtocol."' WHERE `category` = 'path' AND `name`='protocol'"; if (!function_exists('curl_init')) {
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue1."' WHERE `category` = 'path' AND `name`='tempdir'"; $myVisClass->processMessage(translate('Curl module not loaded, Proxy will be deactivated!'), $strErrorMessage);
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$strBaseURL."' WHERE `category` = 'path' AND `name`='base_url'"; $chkRadValue3 = 0;
$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'"; // Check base paths
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue2."' WHERE `category` = 'data' AND `name`='encoding'"; $strSQLBase = "UPDATE `tbl_settings` SET `value`='%s' WHERE `category`='%s' AND `name`='%s'";
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue8."' WHERE `category` = 'security' AND `name`='logofftime'"; $arrSQL[] = sprintf($strSQLBase, $strProtocol, 'path', 'protocol');
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkSelValue3."' WHERE `category` = 'security' AND `name`='wsauth'"; $arrSQL[] = sprintf($strSQLBase, $chkTfValue1, 'path', 'tempdir');
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue9."' WHERE `category` = 'common' AND `name`='pagelines'"; $arrSQL[] = sprintf($strSQLBase, $preRelPath, 'path', 'base_url');
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkSelValue4."' WHERE `category` = 'common' AND `name`='seldisable'"; $arrSQL[] = sprintf($strSQLBase, $preBasePath, 'path', 'base_path');
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkRadValue1."' WHERE `category` = 'common' AND `name`='tplcheck'"; $arrSQL[] = sprintf($strSQLBase, $strLocale, 'data', 'locale');
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkRadValue2."' WHERE `category` = 'common' AND `name`='updcheck'"; $arrSQL[] = sprintf($strSQLBase, $chkTfValue2, 'data', 'encoding');
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkRadValue3."' WHERE `category` = 'network' AND `name`='proxy'"; $arrSQL[] = sprintf($strSQLBase, $chkTfValue8, 'security', 'logofftime');
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue10."' WHERE `category` = 'network' AND `name`='proxyserver'"; $arrSQL[] = sprintf($strSQLBase, $chkSelValue3, 'security', 'wsauth');
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue11."' WHERE `category` = 'network' AND `name`='proxyuser'"; $arrSQL[] = sprintf($strSQLBase, $chkTfValue9, 'common', 'pagelines');
$arrSQL[] = "UPDATE `tbl_settings` SET `value` = '".$chkTfValue12."' WHERE `category` = 'network' AND `name`='proxypasswd'"; $arrSQL[] = sprintf($strSQLBase, $chkSelValue4, 'common', 'seldisable');
$arrSQL[] = sprintf($strSQLBase, $chkRadValue1, 'common', 'tplcheck');
foreach ($arrSQL AS $elem) { $arrSQL[] = sprintf($strSQLBase, $chkRadValue2, 'common', 'updcheck');
$booReturn = $myDBClass->insertData($elem); $arrSQL[] = sprintf($strSQLBase, $chkRadValue3, 'network', 'proxy');
if ($booReturn == false) { $arrSQL[] = sprintf($strSQLBase, $chkTfValue10, 'network', 'proxyserver');
$myVisClass->processMessage(translate('An error occured while writing settings to database:'),$strErrorMessage); $arrSQL[] = sprintf($strSQLBase, $chkTfValue11, 'network', 'proxyuser');
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $arrSQL[] = sprintf($strSQLBase, $chkTfValue12, 'network', 'proxypasswd');
} foreach ($arrSQL as $elem) {
} $booReturn = $myDBClass->insertData($elem);
// Write db settings to file if ($booReturn == false) {
if (is_writable($strBasePath."config/settings.php")) { $myVisClass->processMessage(
$filSettings = fopen($strBasePath."config/settings.php","w"); translate('An error occured while writing settings to database:'),
if ($filSettings) { $strErrorMessage
fwrite($filSettings,"<?php\n"); );
fwrite($filSettings,"exit;\n"); $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
fwrite($filSettings,"?>\n"); }
fwrite($filSettings,";///////////////////////////////////////////////////////////////////////////////\n"); }
fwrite($filSettings,";\n"); // Write db settings to file
fwrite($filSettings,"; NagiosQL\n"); if (is_writable($preBasePath. 'config/settings.php')) {
fwrite($filSettings,";\n"); $filSettings = fopen($preBasePath. 'config/settings.php', 'wb');
fwrite($filSettings,";///////////////////////////////////////////////////////////////////////////////\n"); if ($filSettings) {
fwrite($filSettings,";\n"); fwrite($filSettings, "<?php\n");
fwrite($filSettings,"; Project : NagiosQL\n"); fwrite($filSettings, "exit;\n");
fwrite($filSettings,"; Component: Database Configuration\n"); fwrite($filSettings, "?>\n");
fwrite($filSettings,"; Website : http://www.nagiosql.org\n"); fwrite($filSettings, ";///////////////////////////////////////////////////////////////////////////////\n");
fwrite($filSettings,"; Date : ".date("F j, Y, g:i a")."\n"); fwrite($filSettings, ";\n");
fwrite($filSettings,"; Version : ".$setFileVersion."\n"); fwrite($filSettings, "; NagiosQL\n");
fwrite($filSettings,";\n"); fwrite($filSettings, ";\n");
fwrite($filSettings,";///////////////////////////////////////////////////////////////////////////////\n"); fwrite($filSettings, ";///////////////////////////////////////////////////////////////////////////////\n");
fwrite($filSettings,"[db]\n"); fwrite($filSettings, ";\n");
fwrite($filSettings,"server = ".$chkTfValue3."\n"); fwrite($filSettings, "; Project : NagiosQL\n");
fwrite($filSettings,"port = ".$chkTfValue4."\n"); fwrite($filSettings, "; Component: Database Configuration\n");
fwrite($filSettings,"database = ".$chkTfValue5."\n"); fwrite($filSettings, "; Website : https://sourceforge.net/projects/nagiosql/\n");
fwrite($filSettings,"username = ".$chkTfValue6."\n"); fwrite($filSettings, '; Date : ' .date('F j, Y, g:i a')."\n");
fwrite($filSettings,"password = ".$chkTfValue7."\n"); fwrite($filSettings, '; Version : ' .$setFileVersion."\n");
fwrite($filSettings,"[path]\n"); fwrite($filSettings, ";\n");
fwrite($filSettings,"base_url = ".$strBaseURL."\n"); fwrite($filSettings, ";///////////////////////////////////////////////////////////////////////////////\n");
fwrite($filSettings,"base_path = ".$strBasePath."\n"); fwrite($filSettings, "[db]\n");
fclose($filSettings); fwrite($filSettings, "type = mysqli\n");
// Activate new language settings fwrite($filSettings, 'server = ' .$chkTfValue3."\n");
$arrLocale = explode(".",$strLocale); fwrite($filSettings, 'port = ' .$chkTfValue4."\n");
$strDomain = $arrLocale[0]; fwrite($filSettings, 'database = ' .$chkTfValue5."\n");
$loc = setlocale(LC_ALL, $strLocale, $strLocale.".utf-8", $strLocale.".utf-8", $strLocale.".utf8", "en_GB", "en_GB.utf-8", "en_GB.utf8"); fwrite($filSettings, 'username = ' .$chkTfValue6."\n");
if (!isset($loc)) { fwrite($filSettings, 'password = ' .$chkTfValue7."\n");
$myVisClass->processMessage(translate("Error in setting the correct locale, please report this error with the associated output of 'locale -a'"),$strErrorMessage); fwrite($filSettings, "[path]\n");
} fwrite($filSettings, 'base_url = ' .$preRelPath."\n");
putenv("LC_ALL=".$strLocale.".utf-8"); fwrite($filSettings, 'base_path = ' .$preBasePath."\n");
putenv("LANG=".$strLocale.".utf-8"); fclose($filSettings);
bindtextdomain($strLocale, $strBasePath."config/locale"); // Activate new language settings
bind_textdomain_codeset($strLocale, $chkTfValue2); $arrLocale = explode('.', $strLocale);
textdomain($strLocale); $strDomain = $arrLocale[0];
$myVisClass->processMessage(translate("Settings were changed"),$strInfoMessage); $loc = setlocale(
} else { LC_ALL,
$myVisClass->processMessage(translate("An error occured while writing settings.php, please check permissions!"),$strErrorMessage); $strLocale,
} $strLocale. '.utf-8',
} else { $strLocale. '.utf-8',
$myVisClass->processMessage($strBasePath."config/settings.php ".translate("is not writeable, please check permissions!"),$strErrorMessage); $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 // Start content
// ============= // =============
$conttp->setVariable("TITLE",translate('Configure Settings')); $conttp->setVariable('TITLE', translate('Configure Settings'));
$conttp->parse("header"); foreach ($arrDescription as $elem) {
$conttp->show("header"); $conttp->setVariable($elem['name'], $elem['string']);
foreach($arrDescription AS $elem) {
$conttp->setVariable($elem['name'],$elem['string']);
} }
$conttp->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING)); $conttp->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$conttp->setVariable("LANG_DESCRIPTION",translate('Change your current NagiosQL settings (e.g. Database user, Language).')); $conttp->setVariable('LANG_DESCRIPTION', translate('Change your current NagiosQL settings (e.g. Database user, '
. 'Language).'));
// //
// Path settings // Path settings
// ============= // =============
$conttp->setVariable("PATH",translate('Path')); $conttp->setVariable('PATH', translate('Path'));
$conttp->setVariable("TEMPDIR_NAME",translate('Temporary Directory')); $conttp->setVariable('TEMPDIR_NAME', translate('Temporary Directory'));
$conttp->setVariable("TEMPDIR_VALUE",htmlspecialchars($chkTfValue1, ENT_QUOTES, 'utf-8')); $conttp->setVariable('TEMPDIR_VALUE', htmlspecialchars($chkTfValue1, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("PROTOCOL_NAME",translate('Server protocol')); $conttp->setVariable('PROTOCOL_NAME', translate('Server protocol'));
$conttp->setVariable(strtoupper($SETS['path']['protocol'])."_SELECTED","selected"); $conttp->setVariable(strtoupper($SETS['path']['protocol']). '_SELECTED', 'selected');
// //
// Data settings // Data settings
// ============= // =============
$conttp->setVariable("DATA",translate('Language')); $conttp->setVariable('DATA', translate('Language'));
$conttp->setVariable("LOCALE",translate('Language')); $conttp->setVariable('LOCALE', translate('Language'));
// Process language selection field // Process language selection field
$strSQL = "SELECT * FROM `tbl_language` WHERE `active`='1' ORDER BY `id`"; $strSQL = "SELECT * FROM `tbl_language` WHERE `active`='1' ORDER BY `id`";
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
if ($booReturn && ($intDataCount != 0)) { if ($booReturn && ($intDataCount != 0)) {
foreach($arrData AS $elem) { foreach ($arrData as $elem) {
$conttp->setVariable("LANGUAGE_ID",$elem['id']); $conttp->setVariable('LANGUAGE_ID', $elem['id']);
$conttp->setVariable("LANGUAGE_NAME",translate($elem['language'])); $conttp->setVariable('LANGUAGE_NAME', translate($elem['language']));
if ($elem['locale'] == $SETS['data']['locale']) $conttp->setVariable("LANGUAGE_SELECTED","selected"); if ($elem['locale'] == $SETS['data']['locale']) {
$conttp->parse("language"); $conttp->setVariable('LANGUAGE_SELECTED', 'selected');
} }
$conttp->parse('language');
}
} else { } else {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} }
$conttp->setVariable("ENCODING_NAME",translate('Encoding')); $conttp->setVariable('ENCODING_NAME', translate('Encoding'));
$conttp->setVariable("ENCODING_VALUE",htmlspecialchars($chkTfValue2, ENT_QUOTES, 'utf-8')); $conttp->setVariable('ENCODING_VALUE', htmlspecialchars($chkTfValue2, ENT_QUOTES, 'utf-8'));
// //
// Database settings // Database settings
// ================= // =================
$conttp->setVariable("DB",translate('Database')); $conttp->setVariable('DB', translate('Database'));
$conttp->setVariable("SERVER_NAME",translate('MySQL Server')); $conttp->setVariable('SERVER_NAME', translate('MySQL Server'));
$conttp->setVariable("SERVER_VALUE",htmlspecialchars($chkTfValue3, ENT_QUOTES, 'utf-8')); $conttp->setVariable('SERVER_VALUE', htmlspecialchars($chkTfValue3, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("SERVER_PORT",translate('MySQL Server Port')); $conttp->setVariable('SERVER_PORT', translate('MySQL Server Port'));
$conttp->setVariable("PORT_VALUE",htmlspecialchars($chkTfValue4, ENT_QUOTES, 'utf-8')); $conttp->setVariable('PORT_VALUE', htmlspecialchars($chkTfValue4, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("DATABASE_NAME",translate('Database name')); $conttp->setVariable('DATABASE_NAME', translate('Database name'));
$conttp->setVariable("DATABASE_VALUE",htmlspecialchars($chkTfValue5, ENT_QUOTES, 'utf-8')); $conttp->setVariable('DATABASE_VALUE', htmlspecialchars($chkTfValue5, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("USERNAME_NAME",translate('Database user')); $conttp->setVariable('USERNAME_NAME', translate('Database user'));
$conttp->setVariable("USERNAME_VALUE",htmlspecialchars($chkTfValue6, ENT_QUOTES, 'utf-8')); $conttp->setVariable('USERNAME_VALUE', htmlspecialchars($chkTfValue6, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("PASSWORD_NAME",translate('Database password')); $conttp->setVariable('PASSWORD_NAME', translate('Database password'));
$conttp->setVariable("PASSWORD_VALUE",htmlspecialchars($chkTfValue7, ENT_QUOTES, 'utf-8')); $conttp->setVariable('PASSWORD_VALUE', htmlspecialchars($chkTfValue7, ENT_QUOTES, 'utf-8'));
// //
// Security settings // Security settings
// ================= // =================
$conttp->setVariable("SECURITY",translate('Security')); $conttp->setVariable('SECURITY', translate('Security'));
$conttp->setVariable("LOGOFFTIME_NAME",translate('Session auto logoff time')); $conttp->setVariable('LOGOFFTIME_NAME', translate('Session auto logoff time'));
$conttp->setVariable("LOGOFFTIME_VALUE",htmlspecialchars($chkTfValue8, ENT_QUOTES, 'utf-8')); $conttp->setVariable('LOGOFFTIME_VALUE', htmlspecialchars($chkTfValue8, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("WSAUTH_NAME",translate('Authentication type')); $conttp->setVariable('WSAUTH_NAME', translate('Authentication type'));
$conttp->setVariable("WSAUTH_".$chkSelValue3."_SELECTED","selected"); $conttp->setVariable('WSAUTH_' .$chkSelValue3. '_SELECTED', 'selected');
// //
// Common settings // Common settings
// =============== // ===============
$conttp->setVariable("COMMON",translate('Common')); $conttp->setVariable('COMMON', translate('Common'));
$conttp->setVariable("PAGELINES_NAME",translate('Data lines per page')); $conttp->setVariable('PAGELINES_NAME', translate('Data lines per page'));
$conttp->setVariable("PAGELINES_VALUE",htmlspecialchars($chkTfValue9, ENT_QUOTES, 'utf-8')); $conttp->setVariable('PAGELINES_VALUE', htmlspecialchars($chkTfValue9, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("SELDISABLE_NAME",translate('Selection method')); $conttp->setVariable('SELDISABLE_NAME', translate('Selection method'));
$conttp->setVariable("SELDISABLE_".$chkSelValue4."_SELECTED","selected"); $conttp->setVariable('SELDISABLE_' .$chkSelValue4. '_SELECTED', 'selected');
// //
// Template Check // Template Check
// ============== // ==============
$conttp->setVariable("TEMPLATE_CHECK", translate('Template warn message')); $conttp->setVariable('TEMPLATE_CHECK', translate('Template warn message'));
$conttp->setVariable("LANG_ENABLE", translate('Enable')); $conttp->setVariable('LANG_ENABLE', translate('Enable'));
$conttp->setVariable("LANG_DISABLE", translate('Disable')); $conttp->setVariable('LANG_DISABLE', translate('Disable'));
$conttp->setVariable("TPL_CHECK_".$chkRadValue1."_CHECKED","checked"); $conttp->setVariable('TPL_CHECK_' .$chkRadValue1. '_CHECKED', 'checked');
// //
// Online version check // Online version check
// ==================== // ====================
$conttp->setVariable("CLASS_NAME_1","elementHide"); $conttp->setVariable('CLASS_NAME_1', 'elementHide');
$conttp->setVariable("CLASS_NAME_2","elementHide"); $conttp->setVariable('CLASS_NAME_2', 'elementHide');
$conttp->setVariable("UPDATE_CHECK", translate('Online version check')); $conttp->setVariable('UPDATE_CHECK', translate('Online version check'));
$conttp->setVariable("UPD_CHECK_".$chkRadValue2."_CHECKED","checked"); $conttp->setVariable('UPD_CHECK_' .$chkRadValue2. '_CHECKED', 'checked');
if ($chkRadValue2 == 1) $conttp->setVariable("CLASS_NAME_1","elementShow"); if ($chkRadValue2 == 1) {
$conttp->setVariable('CLASS_NAME_1', 'elementShow');
}
// //
// Online update proxy settings // Online update proxy settings
// ============================ // ============================
$conttp->setVariable("UPD_PROXY_CHECK", translate('Proxyserver')); $conttp->setVariable('UPD_PROXY_CHECK', translate('Proxyserver'));
$conttp->setVariable("UPD_PROXY_".$chkRadValue3."_CHECKED","checked"); $conttp->setVariable('UPD_PROXY_' .$chkRadValue3. '_CHECKED', 'checked');
if (($chkRadValue3 == 1) && ($chkRadValue2 == 1)) $conttp->setVariable("CLASS_NAME_2","elementShow"); if (($chkRadValue3 == 1) && ($chkRadValue2 == 1)) {
$conttp->setVariable("UPD_PROXY_SERVER", translate('Proxy Address')); $conttp->setVariable('CLASS_NAME_2', 'elementShow');
$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_SERVER', translate('Proxy Address'));
$conttp->setVariable("UPD_PROXY_USERNAME_VALUE",htmlspecialchars($chkTfValue11, ENT_QUOTES, 'utf-8')); $conttp->setVariable('UPD_PROXY_SERVER_VALUE', htmlspecialchars($chkTfValue10, ENT_QUOTES, 'utf-8'));
$conttp->setVariable("UPD_PROXY_PASSWORD", translate('Proxy Password (optional)')); $conttp->setVariable('UPD_PROXY_USERNAME', translate('Proxy Username (optional)'));
$conttp->setVariable("UPD_PROXY_PASSWORD_VALUE",htmlspecialchars($chkTfValue12, ENT_QUOTES, 'utf-8')); $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 // Requirements of form
// ==================== // ====================
$conttp->setVariable("LANG_SAVE", translate('Save')); $conttp->setVariable('LANG_SAVE', translate('Save'));
$conttp->setVariable("LANG_ABORT", translate('Abort')); $conttp->setVariable('LANG_ABORT', translate('Abort'));
$conttp->setVariable("LANG_REQUIRED", translate('required')); $conttp->setVariable('LANG_REQUIRED', translate('required'));
$conttp->setVariable("ERRORMESSAGE",$strErrorMessage); $conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
$conttp->setVariable("INFOMESSAGE",$strInfoMessage); $conttp->setVariable('INFOMESSAGE', $strInfoMessage);
// //
// Check access rights for adding new objects // Check access rights for adding new objects
// ========================================== // ==========================================
if ($myVisClass->checkAccGroup($prePageKey,'write') != 0) $conttp->setVariable("ADD_CONTROL","disabled=\"disabled\""); if ($myVisClass->checkAccountGroup($prePageKey, 'write') != 0) {
$conttp->parse("settingssite"); $conttp->setVariable('ADD_CONTROL', 'disabled="disabled"');
$conttp->show("settingssite"); }
$conttp->parse('settingssite');
$conttp->show('settingssite');
// //
// Footer ausgeben // Footer ausgeben
// =============== // ===============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,85 +5,108 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Specials overview // Component : Specials overview
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 5; $prePageId = 5;
$preContent = "admin/mainpages.tpl.htm"; $preContent = 'admin/mainpages.htm.tpl';
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
// //
// Include content // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate('Misc commands')); $conttp->setVariable('TITLE', translate('Misc commands'));
$conttp->parse("header"); $conttp->parse('header');
$conttp->show("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('DESC', translate('Define host and service dependencies, host and service escalations as well '.
$conttp->setVariable("STATISTICS",translate('Statistical datas')); 'as host and service additional data.'));
$conttp->setVariable("TYPE",translate('Group')); $conttp->setVariable('STATISTICS', translate('Statistical datas'));
$conttp->setVariable("ACTIVE",translate('Active')); $conttp->setVariable('TYPE', translate('Group'));
$conttp->setVariable("INACTIVE",translate('Inactive')); $conttp->setVariable('ACTIVE', translate('Active'));
$conttp->setVariable('INACTIVE', translate('Inactive'));
// //
// Include statistical data // Include statistical data
// ======================== // ========================
// Get read access groups // Get read access groups
$strAccess = $myVisClass->getAccGroups('read'); $strAccess = $myVisClass->getAccessGroups('read');
if ($myVisClass->checkAccGroup($myDBClass->getFieldData("SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=19")+0,'read') == 0) { $intAccessGrp19 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=19');
$conttp->setVariable("NAME",translate('Host dependencies')); $intAccessGrp20 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=20');
$conttp->setVariable("ACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hostdependency` WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); $intAccessGrp21 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=21');
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hostdependency` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); $intAccessGrp22 = (int)$myDBClass->getFieldData('SELECT `mnuGrpId` FROM `tbl_menu` WHERE `mnuId`=22');
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intAccessGrp20, 'read') == 0) {
$conttp->setVariable("NAME",translate('Host escalations')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostescalation` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hostescalation` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intAccessGrp21, 'read') == 0) {
$conttp->setVariable("NAME",translate('Host ext. info')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_hostextinfo` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_hostextinfo` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intAccessGrp22, 'read') == 0) {
$conttp->setVariable("NAME",translate('Service dependencies')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_servicedependency` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_servicedependency` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intAccessGrp23, 'read') == 0) {
$conttp->setVariable("NAME",translate('Service escalations')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_serviceescalation` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_serviceescalation` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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) { if ($myVisClass->checkAccountGroup($intAccessGrp24, 'read') == 0) {
$conttp->setVariable("NAME",translate('Service ext. info')); $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('ACT_COUNT', $myDBClass->getFieldData('SELECT count(*) FROM `tbl_serviceextinfo` '
$conttp->setVariable("INACT_COUNT",$myDBClass->getFieldData("SELECT count(*) FROM `tbl_serviceextinfo` WHERE `active`='0' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)")); . "WHERE `active`='1' AND `config_id`=$chkDomainId AND `access_group` IN ($strAccess)"));
$conttp->parse("statisticrow"); $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('statistics');
$conttp->parse("main"); $conttp->parse('main');
$conttp->show("main"); $conttp->show('main');
// //
// Include Footer // Include Footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -5,197 +5,300 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Timeperiod definitions // Component : Timeperiod definitions
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 16; $prePageId = 16;
$preContent = "admin/timeperiods.tpl.htm"; $preContent = 'admin/timeperiods.htm.tpl';
$preSearchSession = 'timeperiod'; $preListTpl = 'admin/datalist.htm.tpl';
$preTableName = 'tbl_timeperiod'; $preSearchSession = 'timeperiod';
$preKeyField = 'timeperiod_name'; $preTableName = 'tbl_timeperiod';
$preAccess = 1; $preKeyField = 'timeperiod_name';
$preFieldvars = 1; $preAccess = 1;
$preFieldvars = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `exclude`=$intMselValue1, `use_template`=$intMselValue2, $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', `exclude`=$intMselValue1, "
`name`='$chkTfValue3', $preSQLCommon1"; . "`use_template`=$intMselValue2, `name`='$chkTfValue3', $preSQLCommon1";
if ($chkModus == "insert") { if ($chkModus == 'insert') {
$strSQL = "INSERT INTO ".$strSQLx; $strSQL = 'INSERT INTO ' .$strSQLx;
} else { } else {
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
} }
if ($intWriteAccessId == 0) { if ($intWriteAccessId == 0) {
if (($chkTfValue1 != "") && ($chkTfValue2 != "")) { if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($chkModus == "insert") $chkDataId = $intInsertId; if ($chkModus == 'insert') {
if ($intReturn == 1) { $chkDataId = $intInsertId;
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} else { if ($intReturn == 1) {
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$myDataClass->updateStatusTable($preTableName); } else {
if ($chkModus == "insert") $myDataClass->writeLog(translate('New time period inserted:')." ".$chkTfValue1); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
if ($chkModus == "modify") $myDataClass->writeLog(translate('Time period modified:')." ".$chkTfValue1); $myDataClass->updateStatusTable($preTableName);
// if ($chkModus == 'insert') {
// Insert/update relations $myDataClass->writeLog(translate('New time period inserted:'). ' ' .$chkTfValue1);
// ======================= }
if ($chkModus == "insert") { if ($chkModus == 'modify') {
if ($intMselValue1 != 0) $intRet1 = $myDataClass->dataInsertRelation("tbl_lnkTimeperiodToTimeperiod",$chkDataId,$chkMselValue1); $myDataClass->writeLog(translate('Time period modified:'). ' ' .$chkTfValue1);
if (isset($intRet1) && ($intRet1 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
if ($intMselValue2 != 0) $intRet2 = $myDataClass->dataInsertRelation("tbl_lnkTimeperiodToTimeperiodUse",$chkDataId,$chkMselValue2); //
if (isset($intRet2) && ($intRet2 != 0)) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); // Insert/update relations
} else if ($chkModus == "modify") { // =======================
if ($intMselValue1 != 0) { if ($chkModus == 'insert') {
$intRet1 = $myDataClass->dataUpdateRelation("tbl_lnkTimeperiodToTimeperiod",$chkDataId,$chkMselValue1); if ($intMselValue1 != 0) {
} else { $intRet1 = $myDataClass->dataInsertRelation(
$intRet1 = $myDataClass->dataDeleteRelation("tbl_lnkTimeperiodToTimeperiod",$chkDataId); 'tbl_lnkTimeperiodToTimeperiod',
} $chkDataId,
if ($intRet1 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $chkMselValue1
if ($intMselValue2 != 0) { );
$intRet2 = $myDataClass->dataUpdateRelation("tbl_lnkTimeperiodToTimeperiodUse",$chkDataId,$chkMselValue2); }
} else { if (isset($intRet1) && ($intRet1 != 0)) {
$intRet2 = $myDataClass->dataDeleteRelation("tbl_lnkTimeperiodToTimeperiodUse",$chkDataId); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
if ($intRet2 != 0) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($intMselValue2 != 0) {
} $intRet2 = $myDataClass->dataInsertRelation(
if (($intRet1 + $intRet2) != 0) $strInfoMessage = ""; 'tbl_lnkTimeperiodToTimeperiodUse',
// $chkDataId,
// Insert/update time defintions $chkMselValue2
// ============================= );
if ($chkModus == "modify") { }
$strSQL = "DELETE FROM `tbl_timedefinition` WHERE `tipId`=$chkDataId"; if (isset($intRet2) && ($intRet2 != 0)) {
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
} } elseif ($chkModus == 'modify') {
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition']) && (count($_SESSION['timedefinition']) != 0)) { if ($intMselValue1 != 0) {
foreach($_SESSION['timedefinition'] AS $elem) { $intRet1 = $myDataClass->dataUpdateRelation(
if ($elem['status'] == 0) { 'tbl_lnkTimeperiodToTimeperiod',
if ($elem['definition'] != "use") { $chkDataId,
$elem['range'] = str_replace(" ","",$elem['range']); $chkMselValue1
} );
$strSQL = "INSERT INTO `tbl_timedefinition` (`tipId`,`definition`,`range`,`last_modified`) } else {
VALUES ($chkDataId,'".$elem['definition']."','".$elem['range']."',now())"; $intRet1 = $myDataClass->dataDeleteRelation('tbl_lnkTimeperiodToTimeperiod', $chkDataId);
$booReturn = $myDataClass->dataInsert($strSQL,$intInsertId); }
if ($booReturn == false) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); if ($intRet1 != 0) {
} $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
} if ($intMselValue2 != 0) {
} $intRet2 = $myDataClass->dataUpdateRelation(
} else { 'tbl_lnkTimeperiodToTimeperiodUse',
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); $chkDataId,
} $chkMselValue2
} else { );
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); } else {
} $intRet2 = $myDataClass->dataDeleteRelation('tbl_lnkTimeperiodToTimeperiodUse', $chkDataId);
$chkModus = "display"; }
if ($intRet2 != 0) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (($intRet1 + $intRet2) != 0) {
$strInfoMessage = '';
}
//
// Insert/update time defintions
// =============================
if ($chkModus == 'modify') {
$strSQL = "DELETE FROM `tbl_timedefinition` WHERE `tipId`=$chkDataId";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition']) &&
(count($_SESSION['timedefinition']) != 0)) {
foreach ($_SESSION['timedefinition'] as $elem) {
if ($elem['status'] == 0) {
if ($elem['definition'] != 'use') {
$elem['range'] = str_replace(' ', '', $elem['range']);
}
$strSQL = 'INSERT INTO `tbl_timedefinition` (`tipId`,`definition`,`range`, '
. "`last_modified`) VALUES ($chkDataId,'".$elem['definition']."',"
. "'".$elem['range']."',now())";
$booReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
if ($booReturn == false) {
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
}
}
}
}
}
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
} }
if ($chkModus != "add") $chkModus = "display";
// //
// Get date/time of last database and config file manipulation // Get date/time of last database and config file manipulation
// =========================================================== // ===========================================================
$intReturn = $myConfigClass->lastModifiedFile($preTableName,$arrTimeData,$strTimeInfoString); $intReturn = $myConfigClass->lastModifiedFile($preTableName, $arrTimeData, $strTimeInfoString);
if ($intReturn != 0) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); if ($intReturn != 0) {
// $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
// Start content }
// =============
$conttp->setVariable("TITLE",translate('Timeperiod definitions'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Do not show modified time list $conttp->setVariable('TITLE', translate('Time period definitions (timeperiods.cfg)'));
$intNoTime = 1; // Do not show modified time list
// Process exclude selection fields $intNoTime = 1;
if (isset($arrModifyData['exclude'])) {$intFieldId = $arrModifyData['exclude'];} else {$intFieldId = 0;} // Process exclude selection fields
$intReturn = $myVisClass->parseSelectMulti($preTableName,'name','excludes','tbl_lnkTimeperiodToTimeperiod',0,$intFieldId,$chkListId); if (isset($arrModifyData['exclude'])) {
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intFieldId = $arrModifyData['exclude'];
// Process include selection fields } else {
if (isset($arrModifyData['use_template'])) {$intFieldId = $arrModifyData['use_template'];} else {$intFieldId = 0;} $intFieldId = 0;
$intReturn = $myVisClass->parseSelectMulti($preTableName,'name','uses','tbl_lnkTimeperiodToTimeperiodUse',0,$intFieldId,$chkListId); }
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); $intReturn1 = $myVisClass->parseSelectMulti(
// Process acces group selection field $preTableName,
if (isset($arrModifyData['access_group'])) {$intFieldId = $arrModifyData['access_group'];} else {$intFieldId = 0;} 'name',
$intReturn = $myVisClass->parseSelectSimple('tbl_group','groupname','acc_group',0,$intFieldId); 'excludes',
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); 'tbl_lnkTimeperiodToTimeperiod',
// Initial add/modify form definitions 0,
$myContentClass->addFormInit($conttp); $intFieldId,
if ($intDataWarning == 1) $conttp->setVariable("WARNING",$strDBWarning."<br>".translate('Saving not possible!')); $chkListId
if ($intVersion != 3) $conttp->setVariable("VERSION_20_VALUE_MUST","mselValue1,"); );
$conttp->setVariable("LANG_INSERT_ALL_TIMERANGE",translate('Please insert a time definition and a time range')); if ($intReturn1 != 0) {
// Insert data from database in "modify" mode $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
if (isset($arrModifyData) && ($chkSelModify == "modify")) { }
// Check relation information to find out locked configuration datasets // Process include selection fields
$intLocked = $myDataClass->infoRelation($preTableName,$arrModifyData['id'],$preKeyField); if (isset($arrModifyData['use_template'])) {
$myVisClass->processMessage($myDataClass->strInfoMessage,$strRelMessage); $intFieldId = $arrModifyData['use_template'];
$strInfo = "<br><span class=\"redmessage\">".translate('Entry cannot be activated because it is used by another configuration').":</span>"; } else {
$strInfo .= "<br><span class=\"greenmessage\">".$strRelMessage."</span>"; $intFieldId = 0;
// Process data }
$myContentClass->addInsertData($conttp,$arrModifyData,$intLocked,$strInfo); $intReturn2 = $myVisClass->parseSelectMulti(
$conttp->setVariable("TIP_ID",$arrModifyData['id']); $preTableName,
} 'name',
$conttp->parse("datainsert"); 'uses',
$conttp->show("datainsert"); 'tbl_lnkTimeperiodToTimeperiodUse',
0,
$intFieldId,
$chkListId
);
if ($intReturn2 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Process acces group selection field
if (isset($arrModifyData['access_group'])) {
$intFieldId = $arrModifyData['access_group'];
} else {
$intFieldId = 0;
}
$intReturn3 = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
if ($intReturn3 != 0) {
$myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
}
// Initial add/modify form definitions
$myContentClass->addFormInit($conttp);
if ($intDataWarning == 1) {
$conttp->setVariable('WARNING', $strDBWarning. '<br>' .translate('Saving not possible!'));
}
if ($intVersion < 3) {
$conttp->setVariable('VERSION_20_VALUE_MUST', 'mselValue1,');
}
$conttp->setVariable('LANG_INSERT_ALL_TIMERANGE', translate('Please insert a time definition and a time range'));
// Insert data from database in "modify" mode
if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
// Check relation information to find out locked configuration datasets
$intLocked = $myDataClass->infoRelation($preTableName, $arrModifyData['id'], $preKeyField);
$myVisClass->processMessage($myDataClass->strInfoMessage, $strRelMessage);
$strInfo = '<br><span class="redmessage">' .translate('Entry cannot be activated because it is used by '
. 'another configuration'). ':</span>';
$strInfo .= '<br><span class="greenmessage">' .$strRelMessage. '</span>';
// Process data
$myContentClass->addInsertData($conttp, $arrModifyData, $intLocked, $strInfo);
$conttp->setVariable('TIP_ID', $arrModifyData['id']);
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// List view // List view
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Time period')); $mastertp->setVariable('TITLE', translate('Time period definitions (timeperiods.cfg)'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Time period'));
// Process filter string $mastertp->setVariable('FIELD_2', translate('Description'));
if ($_SESSION['search'][$preSearchSession] != "") { // Process filter string
$strSearchTxt = $_SESSION['search'][$preSearchSession]; if ($_SESSION['search'][$preSearchSession] != '') {
$strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' OR `name` LIKE '%".$strSearchTxt."%')"; $strSearchTxt = $_SESSION['search'][$preSearchSession];
} $strSearchWhere = "AND (`$preKeyField` LIKE '%".$strSearchTxt."%' OR `alias` LIKE '%".$strSearchTxt."%' "
// Row sorting . "OR `name` LIKE '%".$strSearchTxt."%')";
$strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir"; }
if ($hidSortBy == 2) $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir"; // Row sorting
// Count datasets $strOrderString = "ORDER BY `config_id`, `$preKeyField` $hidSortDir";
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere AND `access_group` IN ($strAccess)"; if ($hidSortBy == 2) {
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); $strOrderString = "ORDER BY `config_id`, `alias` $hidSortDir";
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); // Count datasets
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere "
} else { . "AND `access_group` IN ($strAccess)";
$intLineCount = (int)$arrDataLinesCount['number']; $booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
if ($intLineCount < $chkLimit) $chkLimit = 0; if ($booReturn1 == false) {
} $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
// Get datasets $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` FROM `$preTableName` WHERE $strDomainWhere $strSearchWhere } else {
AND `access_group` IN ($strAccess) $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; $intLineCount = (int)$arrDataLinesCount['number'];
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); if ($intLineCount < $chkLimit) {
if ($booReturn == false) { $chkLimit = 0;
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); }
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); }
} // Get datasets
// Process data $strSQL = "SELECT `id`, `$preKeyField`, `alias`, `register`, `active`, `config_id`, `access_group` "
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias'); . "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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime); $myContentClass->showMessages(
$mastertp,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime
);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,39 +5,41 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Tools overview // Component : Tools overview
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 6; $prePageId = 6;
$preContent = "admin/mainpages.tpl.htm"; $preContent = 'admin/mainpages.htm.tpl';
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
// //
// Include content // Include content
// =============== // ===============
$conttp->setVariable("TITLE",translate('Different tools')); $conttp->setVariable('TITLE', translate('Different tools'));
$conttp->parse("header"); $conttp->setVariable('DESC', translate('Useful functions for data import, main configuration, daemon control, etc.'));
$conttp->show("header"); $conttp->parse('main');
$conttp->setVariable("DESC",translate('Useful functions for data import, main configuration, daemon control and so on.')); $conttp->show('main');
$conttp->parse("main");
$conttp->show("main");
// //
// Include Footer // Include Footer
// ============== // ==============
$maintp->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion"); $maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
$maintp->parse("footer"); . "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->show("footer"); $maintp->parse('footer');
?> $maintp->show('footer');

View File

@ -5,171 +5,208 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : User administration // Component : User administration
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$prePageId = 32; $prePageId = 32;
$preContent = "admin/user.tpl.htm"; $preContent = 'admin/user.htm.tpl';
$preSearchSession = 'user'; $preListTpl = 'admin/datalist_common.htm.tpl';
$preTableName = 'tbl_user'; $preSearchSession = 'user';
$preKeyField = 'username'; $preTableName = 'tbl_user';
$preAccess = 1; $preKeyField = 'username';
$preFieldvars = 1; $preAccess = 1;
//$preNoAccessGrp = 1; $preFieldvars = 1;
$preNoAccessGrp = 1;
// //
// Include preprocessing files // Include preprocessing files
// =========================== // ===========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
require("../functions/prepend_content.php"); require $preBasePath.'functions/prepend_content.php';
// //
// Add or modify data // Add or modify data
// ================== // ==================
if ((($chkModus == "insert") || ($chkModus == "modify")) && ($intGlobalWriteAccess == 0)) { if ((($chkModus == 'insert') || ($chkModus == 'modify')) && ($intGlobalWriteAccess == 0)) {
// Check password // Check password
if ((($chkTfValue3 === $chkTfValue4) && (strlen($chkTfValue3) > 5)) || (($chkModus == "modify") && ($chkTfValue3 == ""))) { if ((($chkTfValue3 === $chkTfValue4) && (strlen($chkTfValue3) > 5)) ||
if ($chkTfValue3 == "") {$strPasswd = "";} else {$strPasswd = "`password`=MD5('$chkTfValue3'),";} (($chkModus == 'modify') && ($chkTfValue3 == ''))) {
// Grant admin rights if ($chkTfValue3 == '') {
if ($chkTfValue5 == "Admin") { $strPasswd = '';
$chkTfValue1 = "Admin"; } else {
$chkActive = "1"; $strPasswd = "`password`=MD5('$chkTfValue3'),";
$chkChbValue1 = "1"; }
} // Grant admin rights
$strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', $strPasswd `admin_enable`='$chkChbValue1', if ($chkTfValue5 == 'Admin') {
`wsauth`='$chkChbValue2', `active`='$chkActive', `language`='$chkSelValue1', `domain`='$chkSelValue2', `last_modified`=NOW()"; $chkTfValue1 = 'Admin';
if ($chkModus == "insert") { $chkActive = '1';
$strSQL = "INSERT INTO ".$strSQLx; $chkChbValue1 = '1';
} else { }
$strSQL = "UPDATE ".$strSQLx." WHERE `id`=$chkDataId"; $strSQLx = "`$preTableName` SET `$preKeyField`='$chkTfValue1', `alias`='$chkTfValue2', $strPasswd "
} . "`admin_enable`='$chkChbValue1', `wsauth`='$chkChbValue2', `active`='$chkActive', "
if ($intWriteAccessId == 0) { . "`language`='$chkSelValue1', `domain`='$chkSelValue2', `last_modified`=NOW()";
if (($chkTfValue1 != "") && ($chkTfValue2 != "")) { if ($chkModus == 'insert') {
$intReturn = $myDataClass->dataInsert($strSQL,$intInsertId); $strSQL = 'INSERT INTO ' .$strSQLx;
if ($intReturn == 1) { } else {
$myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $strSQL = 'UPDATE ' .$strSQLx. ' WHERE `id`=' .$chkDataId;
} else { }
$myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); if ($intWriteAccessId == 0) {
if ($chkModus == "insert") $myDataClass->writeLog(translate('A new user added:')." ".$chkTfValue1); if (($chkTfValue1 != '') && ($chkTfValue2 != '')) {
if ($chkModus == "modify") $myDataClass->writeLog(translate('User modified:')." ".$chkTfValue1); $intReturn = $myDataClass->dataInsert($strSQL, $intInsertId);
} if ($intReturn == 1) {
} else { $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$myVisClass->processMessage(translate('Database entry failed! Not all necessary data filled in!'),$strErrorMessage); } else {
} $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
} else { if ($chkModus == 'insert') {
$myVisClass->processMessage(translate('Database entry failed! No write access!'),$strErrorMessage); $myDataClass->writeLog(translate('New user added:'). ' ' .$chkTfValue1);
} }
} else { if ($chkModus == 'modify') {
$myVisClass->processMessage(translate('Password too short or password fields unequally!'),$strErrorMessage); $myDataClass->writeLog(translate('User modified:'). ' ' .$chkTfValue1);
} }
$chkModus = "display"; }
} else {
$myVisClass->processMessage(
translate('Database entry failed! Not all necessary data filled in!'),
$strErrorMessage
);
}
} else {
$myVisClass->processMessage(translate('Database entry failed! No write access!'), $strErrorMessage);
}
} else {
$myVisClass->processMessage(translate('Password too short or password fields do not match!'), $strErrorMessage);
}
$chkModus = 'display';
}
if ($chkModus != 'add') {
$chkModus = 'display';
} }
if ($chkModus != "add") $chkModus = "display";
//
// Start content
// =============
$conttp->setVariable("TITLE",translate('User administration'));
$conttp->parse("header");
$conttp->show("header");
// //
// Singe data form // Singe data form
// =============== // ===============
if ($chkModus == "add") { if ($chkModus == 'add') {
// Process domain selection field // Process domain selection field
if (isset($arrModifyData['domain'])) {$intFieldId = $arrModifyData['domain'];} else {$intFieldId = 1;} if (isset($arrModifyData['domain'])) {
$intReturn = $myVisClass->parseSelectSimple('tbl_datadomain','domain','std_domain',0,$intFieldId,0); $intFieldId = $arrModifyData['domain'];
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); } else {
// Process language selection field $intFieldId = 1;
if (isset($arrModifyData['language'])) {$intFieldId = $arrModifyData['language'];} else {$intFieldId = 0;} }
if ($intFieldId == 0) { $intReturn1 = $myVisClass->parseSelectSimple('tbl_datadomain', 'domain', 'std_domain', 0, $intFieldId, 0);
$intFieldId = $myDBClass->getFieldData("SELECT `id` FROM `tbl_language` WHERE `locale`='".$_SESSION['SETS']['data']['locale']."'")+0; if ($intReturn1 != 0) {
} $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$intReturn = $myVisClass->parseSelectSimple('tbl_language','language','language_name',0,$intFieldId); }
if ($intReturn != 0) $myVisClass->processMessage($myVisClass->strErrorMessage,$strErrorMessage); // Process language selection field
// Initial add/modify form definitions if (isset($arrModifyData['language'])) {
$myContentClass->addFormInit($conttp); $intFieldId = $arrModifyData['language'];
$conttp->setVariable("WSAUTH_DISABLE","disabled"); } else {
$conttp->setVariable("FILL_ALLFIELDS",translate('Please fill in all fields marked with an *')); $intFieldId = 0;
$conttp->setVariable("FILL_ILLEGALCHARS",translate('The following field contains not permitted characters:')); }
$conttp->setVariable("FILL_PASSWD_NOT_EQUAL",translate('The passwords are not equal!')); if ($intFieldId == 0) {
$conttp->setVariable("FILL_PASSWORD",translate('Please fill in the password')); $intFieldId = $myDBClass->getFieldData('SELECT `id` FROM `tbl_language` '
$conttp->setVariable("FILL_PWDSHORT",translate('The password is too short - use at least 6 characters!')); . "WHERE `locale`='".$_SESSION['SETS']['data']['locale']."'");
$conttp->setVariable("LANG_WEBSERVER_AUTH",translate('Webserver authentification')); $intFieldId = (int)$intFieldId;
$conttp->setVariable("PASSWORD_MUST","class=\"inpmust\""); }
$conttp->setVariable("PASSWORD_MUST_STAR","*"); $intReturn2 = $myVisClass->parseSelectSimple('tbl_language', 'language', 'language_name', 0, $intFieldId);
// If webserver authetification is enabled - show option field if ($intReturn2 != 0) {
if (isset($SETS['security']['wsauth']) && ($SETS['security']['wsauth'] == 1)) { $myVisClass->processMessage($myVisClass->strErrorMessage, $strErrorMessage);
$conttp->setVariable("WSAUTH_DISABLE",""); }
} // Initial add/modify form definitions
// Insert data from database in "modify" mode $myContentClass->addFormInit($conttp);
if (isset($arrModifyData) && ($chkSelModify == "modify")) { $conttp->setVariable('TITLE', translate('User administration'));
// Process data $conttp->setVariable('WSAUTH_DISABLE', 'disabled');
$myContentClass->addInsertData($conttp,$arrModifyData,0,''); $conttp->setVariable('FILL_ALLFIELDS', translate('Please fill in all fields marked with an *'));
// Webserver authentification $conttp->setVariable('FILL_ILLEGALCHARS', translate('The following field contains illegal characters:'));
$conttp->setVariable("WSAUTH_CHECKED",""); $conttp->setVariable('FILL_PASSWD_NOT_EQUAL', translate('The passwords do not match!'));
if ($arrModifyData['wsauth'] == 1) $conttp->setVariable("WSAUTH_CHECKED","checked"); $conttp->setVariable('FILL_PASSWORD', translate('Please fill in the password'));
// Object based group administration $conttp->setVariable('FILL_PWDSHORT', translate('The password is too short - use at least 6 characters!'));
$conttp->setVariable("ADMINENABLE_CHECKED",""); $conttp->setVariable('LANG_WEBSERVER_AUTH', translate('Webserver authentification'));
if ($arrModifyData['admin_enable'] == 1) $conttp->setVariable("ADMINENABLE_CHECKED","checked"); $conttp->setVariable('PASSWORD_MUST', 'class="inpmust"');
// Admin rules $conttp->setVariable('PASSWORD_MUST_STAR', '*');
if ($arrModifyData[$preKeyField] == "Admin") { // If webserver authetification is enabled - show option field
$conttp->setVariable("NAME_DISABLE","disabled"); if (isset($SETS['security']['wsauth']) && ($SETS['security']['wsauth'] == 1)) {
$conttp->setVariable("ACT_DISABLE","disabled"); $conttp->setVariable('WSAUTH_DISABLE', '');
$conttp->setVariable("WSAUTH_DISABLE","disabled"); }
$conttp->setVariable("ADMINENABLE_DISABLE","disabled"); // Insert data from database in "modify" mode
$conttp->setVariable("ADMINENABLE_CHECKED","checked"); if (isset($arrModifyData) && ($chkSelModify == 'modify')) {
} // Process data
$conttp->setVariable("PASSWORD_MUST",""); $myContentClass->addInsertData($conttp, $arrModifyData, 0, '');
$conttp->setVariable("PASSWORD_MUST_STAR",""); // Webserver authentification
} $conttp->setVariable('WSAUTH_CHECKED', '');
$conttp->parse("datainsert"); if ($arrModifyData['wsauth'] == 1) {
$conttp->show("datainsert"); $conttp->setVariable('WSAUTH_CHECKED', 'checked');
}
// Object based group administration
$conttp->setVariable('ADMINENABLE_CHECKED', '');
if ($arrModifyData['admin_enable'] == 1) {
$conttp->setVariable('ADMINENABLE_CHECKED', 'checked');
}
// Admin rules
if ($arrModifyData[$preKeyField] == 'Admin') {
$conttp->setVariable('NAME_DISABLE', 'disabled');
$conttp->setVariable('ACT_DISABLE', 'disabled');
$conttp->setVariable('WSAUTH_DISABLE', 'disabled');
$conttp->setVariable('ADMINENABLE_DISABLE', 'disabled');
$conttp->setVariable('ADMINENABLE_CHECKED', 'checked');
}
$conttp->setVariable('PASSWORD_MUST', '');
$conttp->setVariable('PASSWORD_MUST_STAR', '');
}
$conttp->parse('datainsert');
$conttp->show('datainsert');
} }
// //
// Data table // Data table
// ========== // ==========
if ($chkModus == "display") { if ($chkModus == 'display') {
// Initial list view definitions // Initial list view definitions
$myContentClass->listViewInit($mastertp); $myContentClass->listViewInit($mastertp);
$mastertp->setVariable("FIELD_1",translate('Username')); $mastertp->setVariable('TITLE', translate('User administration'));
$mastertp->setVariable("FIELD_2",translate('Description')); $mastertp->setVariable('FIELD_1', translate('Username'));
// Row sorting $mastertp->setVariable('FIELD_2', translate('Description'));
$strOrderString = "ORDER BY `$preKeyField` $hidSortDir"; // Row sorting
if ($hidSortBy == 2) $strOrderString = "ORDER BY `alias` $hidSortDir"; $strOrderString = "ORDER BY `$preKeyField` $hidSortDir";
// Count datasets if ($hidSortBy == 2) {
$strSQL = "SELECT count(*) AS `number` FROM `$preTableName`"; $strOrderString = "ORDER BY `alias` $hidSortDir";
$booReturn = $myDBClass->getSingleDataset($strSQL,$arrDataLinesCount); }
if ($booReturn == false) { // Count datasets
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $strSQL = "SELECT count(*) AS `number` FROM `$preTableName`";
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $booReturn1 = $myDBClass->hasSingleDataset($strSQL, $arrDataLinesCount);
} else { if ($booReturn1 == false) {
$intLineCount = (int)$arrDataLinesCount['number']; $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
if ($intLineCount < $chkLimit) $chkLimit = 0; $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} } else {
// Get datasets $intLineCount = (int)$arrDataLinesCount['number'];
$strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `nodelete` if ($intLineCount < $chkLimit) {
FROM `$preTableName` $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines']; $chkLimit = 0;
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); }
if ($booReturn == false) { }
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); // Get datasets
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); $strSQL = "SELECT `id`, `$preKeyField`, `alias`, `active`, `nodelete` "
} . "FROM `$preTableName` $strOrderString LIMIT $chkLimit,".$SETS['common']['pagelines'];
// Process data $booReturn2 = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
$myContentClass->listData($mastertp,$arrDataLines,$intDataCount,$intLineCount,$preKeyField,'alias'); 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 // Show messages
$myContentClass->showMessages($mastertp,$strErrorMessage,$strInfoMessage,$strConsistMessage,'','',1); $myContentClass->showMessages($mastertp, $strErrorMessage, $strInfoMessage, $strConsistMessage, array(), '', 1);
// //
// Process footer // Process footer
// ============== // ==============
$myContentClass->showFooter($maintp,$setFileVersion); $myContentClass->showFooter($maintp, $setFileVersion);
?>

View File

@ -5,136 +5,151 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Variable definition list // Component : Variable definition list
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$preAccess = 1; $preAccess = 1;
$preNoMain = 1; $preNoMain = 1;
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
// //
// Process post parameters // Process post parameters
// ======================= // =======================
$chkDataId = isset($_GET['dataId']) ? htmlspecialchars($_GET['dataId'], ENT_QUOTES, 'utf-8') : 0; $chkDataId = filter_input(INPUT_GET, 'dataId', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkMode = isset($_GET['mode']) ? htmlspecialchars($_GET['mode'], ENT_QUOTES, 'utf-8') : ""; $chkMode = filter_input(INPUT_GET, 'mode', FILTER_SANITIZE_STRING);
$chkDef = isset($_GET['def']) ? $_GET['def'] : ""; $chkDef = filter_input(INPUT_GET, 'def', FILTER_SANITIZE_STRING);
$chkRange = isset($_GET['range']) ? $_GET['range'] : ""; $chkRange = filter_input(INPUT_GET, 'range', FILTER_SANITIZE_STRING);
$chkId = isset($_GET['id']) ? htmlspecialchars($_GET['id'], ENT_QUOTES, 'utf-8') : ""; $chkLinkTab = filter_input(INPUT_GET, 'linktab', FILTER_SANITIZE_STRING);
$chkVersion = isset($_GET['version']) ? htmlspecialchars($_GET['version'], ENT_QUOTES, 'utf-8') : 0;
$chkLinkTab = isset($_GET['linktab']) ? htmlspecialchars($_GET['linktab'], ENT_QUOTES, 'utf-8') : "";
if (get_magic_quotes_gpc() == 0) { if (get_magic_quotes_gpc() == 0) {
$chkDef = addslashes($chkDef); $chkDef = addslashes($chkDef);
$chkRange = addslashes($chkRange); $chkRange = addslashes($chkRange);
} }
// //
// Get data // Get data
// ======== // ========
if ($chkLinkTab != "") { if ($chkLinkTab != '') {
$strSQL = "SELECT * FROM `tbl_variabledefinition` LEFT JOIN `".$chkLinkTab."` ON `id`=`idSlave` WHERE `idMaster`=$chkDataId ORDER BY `name`"; $strSQL = 'SELECT * FROM `tbl_variabledefinition` LEFT JOIN `' .$chkLinkTab. '` ON `id`=`idSlave` ' .
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); "WHERE `idMaster`=$chkDataId ORDER BY `name`";
// $booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
// Store data to session //
// ============================ // Store data to session
if ($chkMode == "") { // ============================
$_SESSION['variabledefinition'] = ""; if ($chkMode == '') {
if ($booReturn && ($intDataCount != 0)) { $arrTemp = array();
foreach ($arrDataLines AS $elem) { $_SESSION['variabledefinition'] = array();
$arrTemp['id'] = $elem['id']; if ($booReturn && ($intDataCount != 0)) {
$arrTemp['definition'] = addslashes($elem['name']); foreach ($arrDataLines as $elem) {
$arrTemp['range'] = addslashes($elem['value']); $arrTemp['id'] = $elem['id'];
$arrTemp['status'] = 0; $arrTemp['definition'] = addslashes($elem['name']);
$_SESSION['variabledefinition'][] = $arrTemp; $arrTemp['range'] = addslashes($elem['value']);
} $arrTemp['status'] = 0;
} $_SESSION['variabledefinition'][] = $arrTemp;
} }
}
}
} }
// //
// Add mode // Add mode
// ======== // ========
if ($chkMode == "add") { if ($chkMode == 'add') {
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition'])) { $arrTemp = array();
$intCheck = 0; if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition'])) {
foreach ($_SESSION['variabledefinition'] AS $key => $elem) { $intCheck = 0;
if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) { foreach ($_SESSION['variabledefinition'] as $key => $elem) {
$_SESSION['variabledefinition'][$key]['definition'] = $chkDef; if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) {
$_SESSION['variabledefinition'][$key]['range'] = $chkRange; $_SESSION['variabledefinition'][$key]['definition'] = $chkDef;
$intCheck = 1; $_SESSION['variabledefinition'][$key]['range'] = $chkRange;
} $intCheck = 1;
} }
if ($intCheck == 0) { }
$arrTemp['id'] = 0; if ($intCheck == 0) {
$arrTemp['definition'] = $chkDef; $arrTemp['id'] = 0;
$arrTemp['range'] = $chkRange; $arrTemp['definition'] = $chkDef;
$arrTemp['status'] = 0; $arrTemp['range'] = $chkRange;
$_SESSION['variabledefinition'][] = $arrTemp; $arrTemp['status'] = 0;
} $_SESSION['variabledefinition'][] = $arrTemp;
} else { }
$arrTemp['id'] = 0; } else {
$arrTemp['definition'] = $chkDef; $arrTemp['id'] = 0;
$arrTemp['range'] = $chkRange; $arrTemp['definition'] = $chkDef;
$arrTemp['status'] = 0; $arrTemp['range'] = $chkRange;
$_SESSION['variabledefinition'][] = $arrTemp; $arrTemp['status'] = 0;
} $_SESSION['variabledefinition'][] = $arrTemp;
}
} }
// //
// Deletion mode // Deletion mode
// ============= // =============
if ($chkMode == "del") { if ($chkMode == 'del' && isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition'])) {
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition'])) { foreach ($_SESSION['variabledefinition'] as $key => $elem) {
foreach ($_SESSION['variabledefinition'] AS $key => $elem) { if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) {
if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) { $_SESSION['variabledefinition'][$key]['status'] = 1;
$_SESSION['variabledefinition'][$key]['status'] = 1; }
} }
}
}
} }
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>None</title> <title>None</title>
<link href="<?php echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css"> <link href="<?php echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="javascript"> <!--suppress JSUnresolvedVariable -->
<!-- <script type="text/javascript">
function doEdit(key,range) { function doEdit(key,range) {
parent.document.frmDetail.txtVariablename.value = decodeURIComponent(key); parent.document.frmDetail.txtVariablename.value = decodeURIComponent(key);
parent.document.frmDetail.txtVariablevalue.value = decodeURIComponent(range); parent.document.frmDetail.txtVariablevalue.value = decodeURIComponent(range);
} }
function doDel(key) { function doDel(key) {
document.location.href = "<?php echo $_SESSION['SETS']['path']['base_url']; ?>admin/variabledefinitions.php?dataId=<?php echo $chkDataId; ?>&mode=del&def="+key; let link;
} link = '<?php echo $_SESSION['SETS']['path']['base_url']; ?>';
//--> link = link+'admin/variabledefinitions.php?dataId=<?php echo $chkDataId; ?>&mode=del&def='+key;
</script> document.location.href = link;
}
</script>
</head> </head>
<body style="margin:0"> <body style="margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%"> <table cellpadding="0" cellspacing="0" border="0" width="100%">
<?php <?php
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) && (count($_SESSION['variabledefinition']) != 0)) { if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
foreach($_SESSION['variabledefinition'] AS $elem) { (count($_SESSION['variabledefinition']) != 0)) {
if ($elem['status'] == 0) { foreach ($_SESSION['variabledefinition'] as $elem) {
if ($elem['status'] == 0) {
?> ?>
<tr> <tr>
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php echo htmlentities(stripslashes($elem['definition']),ENT_COMPAT,'UTF-8'); ?></td> <td class="tablerow" style="padding-bottom:2px; width:260px"><?php
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php echo htmlentities(stripslashes($elem['range']),ENT_COMPAT,'UTF-8'); ?></td> echo htmlentities(stripslashes($elem['definition']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="width:50px" align="right"><img src="<?php echo $_SESSION['SETS']['path']['base_url']; ?>images/edit.gif" width="18" height="18" alt="<?php echo translate('Modify'); ?>" title="<?php echo translate('Modify'); ?>" onClick="doEdit('<?php echo rawurlencode(stripslashes($elem['definition'])); ?>','<?php echo rawurlencode(stripslashes($elem['range'])); ?>')" style="cursor:pointer">&nbsp;<img src="<?php echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18" alt="<?php echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>" onClick="doDel('<?php echo rawurlencode(stripslashes($elem['definition'])); ?>')" style="cursor:pointer"></td> <td class="tablerow" style="padding-bottom:2px; width:260px"><?php
</tr> echo htmlentities(stripslashes($elem['range']), ENT_COMPAT, 'UTF-8'); ?></td>
<td class="tablerow" style="width:50px" align="right"><img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/edit.gif" width="18" height="18" alt="<?php
echo translate('Modify'); ?>" title="<?php echo translate('Modify'); ?>" onClick="doEdit('<?php
echo rawurlencode(stripslashes($elem['definition'])); ?>','<?php
echo rawurlencode(stripslashes($elem['range'])); ?>')" style="cursor:pointer">&nbsp;<img src="<?php
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18" alt="<?php
echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>" onClick="doDel('<?php
echo rawurlencode(stripslashes($elem['definition'])); ?>')" style="cursor:pointer"></td>
</tr>
<?php <?php
} }
} }
} else { } else {
?> ?>
<tr> <tr>
@ -143,8 +158,8 @@ if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefini
<td class="tablerow" align="right">&nbsp;</td> <td class="tablerow" align="right">&nbsp;</td>
</tr> </tr>
<?php <?php
} }
?> ?>
</table> </table>
</body> </body>
</html> </html>

File diff suppressed because it is too large Load Diff

View File

@ -5,168 +5,193 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Command line visualization // Component : Online version check
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
// Define common variables // Define common variables
// ======================= // =======================
$preNoMain = 1; $preNoMain = 1;
$chkShow = isset($_GET['show']) ? $_GET['show']+0 : 0; $chkShow = filter_input(INPUT_GET, 'show', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
// //
// Include preprocessing file // Include preprocessing file
// ========================== // ==========================
require("../functions/prepend_adm.php"); require $preBasePath.'functions/prepend_adm.php';
$strCommandLine = "&nbsp;"; $strCommandLine = '&nbsp;';
$intCount = 0; $intCount = 0;
// //
// Get database values // Get database values
// =================== // ===================
if ($chkShow == 1) { if ($chkShow == 1) {
$versionfeed = "http://api.wizonet.ch/nagiosql/versioncheck.php?myversion=".urlencode($setFileVersion); $versionfeed = 'http://api.wizonet.ch/nagiosql/versioncheck.php?myversion=' .urlencode($setFileVersion);
$strError = ""; $strError = '';
if ((isset($SETS['network']['proxy']) && ($SETS['network']['proxy'] == '1')) && if ((isset($SETS['network']['proxy']) && ($SETS['network']['proxy'] == '1')) &&
(isset($SETS['network']['proxyserver']) && ($SETS['network']['proxyserver'] != ""))) { (isset($SETS['network']['proxyserver']) && ($SETS['network']['proxyserver'] != ''))) {
if ((isset($SETS['network']['proxyuser']) && ($SETS['network']['proxyuser'] != "")) && if ((isset($SETS['network']['proxyuser']) && ($SETS['network']['proxyuser'] != '')) &&
(isset($SETS['network']['proxypasswd']) && ($SETS['network']['proxypasswd'] != ""))) { (isset($SETS['network']['proxypasswd']) && ($SETS['network']['proxypasswd'] != ''))) {
$strProxyAuth = base64_encode($SETS['network']['proxyuser'].":".$SETS['network']['proxypasswd']); $strProxyAuth = base64_encode($SETS['network']['proxyuser']. ':' .$SETS['network']['proxypasswd']);
$aContext = array( $aContext = array(
'http' => array( 'http' => array(
'proxy' => 'tcp://'.$SETS['network']['proxyserver'], 'proxy' => 'tcp://'.$SETS['network']['proxyserver'],
'request_fulluri' => true, 'request_fulluri' => true,
'header' => "Proxy-Authorization: Basic $strProxyAuth", 'header' => "Proxy-Authorization: Basic $strProxyAuth",
'timeout' => 1, 'timeout' => 1,
), ),
); );
} else { } else {
$aContext = array( $aContext = array(
'http' => array( 'http' => array(
'proxy' => 'tcp://'.$SETS['network']['proxyserver'], 'proxy' => 'tcp://'.$SETS['network']['proxyserver'],
'request_fulluri' => true, 'request_fulluri' => true,
'timeout' => 1, 'timeout' => 1,
), ),
); );
} }
$intErrorReporting = error_reporting(); $intErrorReporting = error_reporting();
error_reporting(0); error_reporting(0);
$cxContext = stream_context_create($aContext); $cxContext = stream_context_create($aContext);
$arrFile = file($versionfeed, false, $cxContext); $arrFile = file($versionfeed, false, $cxContext);
$arrError = error_get_last(); $arrError = error_get_last();
error_reporting($intErrorReporting); error_reporting($intErrorReporting);
if ($arrError['message'] != "") $strError .= utf8_encode($arrError['message'])." (".translate("check proxy settings").")"; if ($arrError['message'] != '') {
} else { $strError .= utf8_encode($arrError['message']). ' (' .translate('check proxy settings'). ')';
$intErrorReporting = error_reporting(); }
error_reporting(0); } else {
$cxContext = stream_context_create(array('http' => array('timeout' => 1))); $intErrorReporting = error_reporting();
$arrFile = file($versionfeed, false, $cxContext); error_reporting(0);
$arrError = error_get_last(); $cxContext = stream_context_create(array('http' => array('timeout' => 1)));
error_reporting($intErrorReporting); $arrFile = file($versionfeed, false, $cxContext);
if ($arrError['message'] != "") $strError .= utf8_encode($arrError['message'])." (".translate("check proxy settings").")"; $arrError = error_get_last();
error_reporting($intErrorReporting);
} if ($arrError['message'] != '') {
$strInstalled = translate('Installed'); $strError .= utf8_encode($arrError['message']). ' (' .translate('check proxy settings'). ')';
$strAvailable = translate('Available'); }
$strInformation = translate('Information'); }
$strVersion = ""; $strInstalled = translate('Installed');
$strRelease = ""; $strAvailable = translate('Available');
$strRelInfo = ""; $strInformation = translate('Information');
if (is_array($arrFile) && (count($arrFile)) != 0) { $strVersion = '';
foreach ($arrFile AS $elem) { $strRelease = '';
if (substr_count($elem,"version") != 0) $strVersion = trim(strip_tags($elem)); $strRelInfo = '';
if (substr_count($elem,"release_date") != 0) $strRelease = trim(strip_tags($elem)); if (is_array($arrFile) && count($arrFile) != 0) {
if (substr_count($elem,"error") != 0) $strError = trim(strip_tags($elem)); foreach ($arrFile as $elem) {
if (substr_count($elem,"information") != 0) $strRelInfo = trim(strip_tags($elem)); if (substr_count($elem, 'version') != 0) {
} $strVersion = trim(strip_tags($elem));
} }
$setFileAvailable = $strVersion; if (substr_count($elem, 'release_date') != 0) {
if (version_compare($strVersion, $setFileVersion,'==')) { $strRelease = trim(strip_tags($elem));
$setFileInformation = "<span class='greenmessage'>".translate('You already have the latest version installed')."</span>"; }
} else if (version_compare($strVersion, $setFileVersion,'>=')) { if (substr_count($elem, 'error') != 0) {
$setFileInformation = "<span class='redmessage'>".translate('You are using an old NagiosQL version. Please update to the latest stable version')."</span>: "; $strError = trim(strip_tags($elem));
$setFileInformation .= "<a href=\"http://sourceforge.net/projects/nagiosql/files/\" target=\"_blank\">NagiosQL on Sourceforge</a>"; }
} else if (version_compare($strVersion, $setFileVersion,'<=')) { if (substr_count($elem, 'information') != 0) {
$setFileInformation = "<span class='redmessage'>".translate('You are using a newer development version without official support')."</span>"; $strRelInfo = trim(strip_tags($elem));
} }
if (($strError != "none") && ($strError != "")) $setFileInformation = "<span class='redmessage'>".$strError."</span>"; }
?> }
$setFileAvailable = $strVersion;
if (version_compare($strVersion, $setFileVersion, '==')) {
$setFileInformation = "<span class='greenmessage'>".translate('You already have the latest version installed').
'</span>';
} elseif (version_compare($strVersion, $setFileVersion, '>=')) {
$setFileInformation = "<span class='redmessage'>".translate('You are using an old NagiosQL version. Please '.
'update to the latest stable version'). '</span>: ';
$setFileInformation .= '<a href="http://sourceforge.net/projects/nagiosql/files/" target="_blank">' .
'NagiosQL on Sourceforge</a>';
} elseif (version_compare($strVersion, $setFileVersion, '<=')) {
$setFileInformation = "<span class='redmessage'>".translate('You are using a newer development version '.
'without official support'). '</span>';
}
if (($strError != 'none') && ($strError != '')) {
$setFileInformation = "<span class='redmessage'>".$strError. '</span>';
} ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head> <head>
<title>Version check</title> <title>Version check</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<?php echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css"> <link href="<?php
<link href="<?php echo $_SESSION['SETS']['path']['base_url']; ?>config/content.css" rel="stylesheet" type="text/css"> echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
<style type="text/css"> <link href="<?php
<!-- echo $_SESSION['SETS']['path']['base_url']; ?>config/content.css" rel="stylesheet" type="text/css">
body { <style type="text/css">
font-family: Verdana, Arial, Helvetica, sans-serif; <!--
font-size: 10px; body {
color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: #FFFFFF; font-size: 10px;
margin: 0px; color: #000000;
border: none; background-color: #FFFFFF;
} margin: 0;
--> border: none;
</style> }
</head> -->
<body> </style>
<table width="100%" border="0" class="content_listtable" style="padding:0px; margin:0px; top:3px;"> </head>
<tr> <body>
<th style="text-align: center"><?php echo $strInstalled; ?></th> <table width="100%" border="0" class="content_listtable" style="padding:0; margin:0; top:3px;">
<th style="text-align: center"><?php echo $strAvailable; ?></th> <tr>
<th style="text-align: left; padding-left: 30px;"><?php echo $strInformation; ?></th> <th style="text-align: center"><?php echo $strInstalled; ?></th>
</tr> <th style="text-align: center"><?php echo $strAvailable; ?></th>
<tr> <th style="text-align: left; padding-left: 30px;"><?php echo $strInformation; ?></th>
<td class="tdmb" style="width:90px;vertical-align:top;padding-top:4px;"><?php echo $setFileVersion; ?></td> </tr>
<td class="tdmb" style="width:90px;vertical-align:top;padding-top:4px;"><?php echo $setFileAvailable; ?></td> <tr>
<td class="tdlb" style="width:470px;vertical-align:top;padding-top:4px;"><?php echo $setFileInformation; ?></td> <td class="tdmb" style="width:90px;vertical-align:top;padding-top:4px;"><?php
</tr> echo $setFileVersion; ?></td>
</table> <td class="tdmb" style="width:90px;vertical-align:top;padding-top:4px;"><?php
<script language="JavaScript"> echo $setFileAvailable; ?></td>
<!-- <td class="tdlb" style="width:470px;vertical-align:top;padding-top:4px;"><?php
parent.document.getElementById('vcheck').className = 'elementHide'; echo $setFileInformation; ?></td>
parent.document.getElementById('versioncheck').className = 'elementShow'; </tr>
</table>
<script type="text/javascript">
<!--
parent.document.getElementById('vcheck').className = 'elementHide';
parent.document.getElementById('versioncheck').className = 'elementShow';
<?php <?php
if (($strError != "none") && ($strError != "")) { if (($strError != 'none') && ($strError != '')) {
echo " parent.document.getElementById('versioncheck').height = '65';"; echo " parent.document.getElementById('versioncheck').height = '65';";
} }
?> ?>
//--> //-->
</script> </script>
</body> </body>
</html> </html>
<?php <?php
} else { } else {
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head> <head>
<title>Commandline</title> <title>Commandline</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css"> <style type="text/css">
<!-- <!--
body { body {
font-family: Verdana, Arial, Helvetica, sans-serif; font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px; font-size: 10px;
color: #000000; color: #000000;
background-color: #FFFFFF; background-color: #FFFFFF;
margin: 0px; margin: 0;
border: none; border: none;
} }
--> -->
</style> </style>
</head> </head>
<body> <body>
<p><br>Loading...</p> <p><br>Loading...</p>
</body> </body>
</html> </html>
<?php <?php
} }

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

64
functions/Autoloader.php Normal file
View File

@ -0,0 +1,64 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Autoloader Class
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
namespace functions;
class Autoloader
{
// Define class variables
public $preBasePath = DIRECTORY_SEPARATOR;
/**
* Autoloader constructor.
*/
public function __construct()
{
spl_autoload_register(array($this, 'loadClass'));
}
/**
* @param string $strBasePath Base path of project
*/
public static function register($strBasePath)
{
$object = new Autoloader();
$object->preBasePath = $strBasePath;
}
/**
* Load class from path
* @param string $strClassName Class name
*/
public function loadClass($strClassName)
{
$className = ltrim($strClassName, '\\');
$fileName = '';
$lastNsPos = strrpos($className, '\\');
if ($lastNsPos != 0) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
$strFilePath1 = $this->preBasePath.$fileName;
$strFilePath2 = $this->preBasePath.'install/'.$fileName;
if (file_exists($strFilePath1) && is_readable($strFilePath1)) {
require_once $strFilePath1;
}
if (file_exists($strFilePath2) && is_readable($strFilePath2)) {
require_once $strFilePath2;
}
}
}

412
functions/MysqliDbClass.php Normal file
View File

@ -0,0 +1,412 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// Common utilities
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : Common scripts
// Component : MySQLi data processing class
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Class: Common database functions for MySQL (mysqli database module)
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Includes any functions to communicate with an MySQL database server
//
// Name: MysqliDbClass
//
// Class variables: $arrParams Array including the server settings
// ---------------- $strErrorMessage Database error string
// $error Boolean - Error true/false
// $strDBId Database connection id
// $intLastId ID of last dataset
// $intAffectedRows Counter variable of all affected data dows
// $booSSLuse Use SSL connection
//
// Parameters: $arrParams['server'] -> DB server name
// ----------- $arrParams['port'] -> DB server port
// $arrParams['user'] -> DB server username
// $arrParams['password'] -> DB server password
// $arrParams['database'] -> DB server database name
//
///////////////////////////////////////////////////////////////////////////////////////////////
namespace functions;
class MysqliDbClass
{
// Define class variables
public $error = false; // Will be filled in functions
public $strDBId; // Will be filled in functions
public $intLastId = 0; // Will be filled in functions
public $intAffectedRows = 0; // Will be filled in functions
public $strErrorMessage = ''; // Will be filled in functions
public $booSSLuse = false; // Defines if SSL is used or not
public $arrParams = array(); // Must be filled in while initialization
/**
* MysqliDbClass constructor.
*/
public function __construct()
{
$this->arrParams['server'] = '';
$this->arrParams['port'] = 0;
$this->arrParams['username'] = '';
$this->arrParams['password'] = '';
$this->arrParams['database'] = '';
}
/**
* MysqliDbClass destructor.
*/
public function __destruct()
{
$this->dbDisconnect();
}
/**
* Opens a connection to the database server and select a database
* @param int $intMode 1 = connect only / 0 = connect + dbselect
* @return bool true = successful / false = error
* Status messages are stored in class variable
*/
public function hasDBConnection($intMode = 0)
{
$booReturn = true;
$this->dbconnect();
if ($this->error == true) {
$booReturn = false;
}
if (($booReturn == true) && ($intMode == 0)) {
$this->dbselect();
if ($this->error == true) {
$booReturn = false;
}
}
return $booReturn;
}
/**
* Sends an SQL statement to the server and returns the result of the first data field
* @param string $strSQL SQL Statement
* @return string <data> = successful / <empty> = error
* Status messages are stored in class variable
*/
public function getFieldData($strSQL)
{
// Reset error variables
$this->strErrorMessage = '';
$this->error = false;
$strReturn = '';
// Send the SQL statement to the server
$resQuery = mysqli_query($this->strDBId, $strSQL);
// Error processing
if ($resQuery && (mysqli_num_rows($resQuery) != 0) && (mysqli_error($this->strDBId) == '')) {
// Return the field value from position 0/0
$arrDataset = mysqli_fetch_array($resQuery, MYSQLI_NUM);
$strReturn = $arrDataset[0];
} elseif (mysqli_error($this->strDBId) != '') {
$this->strErrorMessage .= mysqli_error($this->strDBId). '::';
$this->error = true;
}
return $strReturn;
}
/**
* Sends an SQL statement to the server and returns the result of the first data set
* @param string $strSQL SQL Statement
* @param array|null $arrDataset Result array (by reference)
* @return bool true = successful / false = error
* Status messages are stored in class variable
*/
public function hasSingleDataset($strSQL, &$arrDataset)
{
//$arrDataset = array();
$booReturn = true;
// Reset error variables
$this->strErrorMessage = '';
$this->error = false;
// Send the SQL statement to the server
$resQuery = mysqli_query($this->strDBId, $strSQL);
// Error processing
if ($resQuery && (mysqli_num_rows($resQuery) != 0) && (mysqli_error($this->strDBId) == '')) {
// Put the values into the array
$arrDataset = mysqli_fetch_array($resQuery, MYSQLI_ASSOC);
} elseif (mysqli_error($this->strDBId) != '') {
$this->strErrorMessage .= mysqli_error($this->strDBId). '::';
$this->error = true;
$booReturn = false;
}
return $booReturn;
}
/**
* Sends an SQL statement to the server and returns the result of all dataset in a data array
* @param string $strSQL SQL Statement
* @param array $arrDataset Result array (by reference)
* @param int $intDataCount Number of data result sets
* @return bool true = successful / false = error
* Status messages are stored in class variable
*/
public function hasDataArray($strSQL, &$arrDataset, &$intDataCount)
{
$arrDataset = array();
$intDataCount = 0;
$booReturn = true;
// Reset error variables
$this->strErrorMessage = '';
$this->error = false;
// Send the SQL statement to the server
$resQuery = mysqli_query($this->strDBId, $strSQL);
// Error processing
if ($resQuery && (mysqli_num_rows($resQuery) != 0) && (mysqli_error($this->strDBId) == '')) {
$intDataCount = mysqli_num_rows($resQuery);
$intCount = 0;
// Put the values into the array
while ($arrDataTemp = mysqli_fetch_array($resQuery, MYSQLI_ASSOC)) {
foreach ($arrDataTemp as $key => $value) {
$arrDataset[$intCount][$key] = $value;
}
$intCount++;
}
} elseif (mysqli_error($this->strDBId) != '') {
$this->strErrorMessage .= mysqli_error($this->strDBId). '::';
$this->error = true;
$booReturn = false;
}
return $booReturn;
}
/**
* Insert/update or delete data
* @param string $strSQL SQL Statement
* @return bool true = successful / false = error
* Status messages are stored in class variable
*/
public function insertData($strSQL)
{
// Reset error variables
$this->strErrorMessage = '';
$this->error = false;
$booReturn = false;
// Send the SQL statement to the server
if ($strSQL != '') {
mysqli_query($this->strDBId, $strSQL);
// Error processing
if (mysqli_error($this->strDBId) == '') {
$this->intLastId = mysqli_insert_id($this->strDBId);
$this->intAffectedRows = mysqli_affected_rows($this->strDBId);
$booReturn = true;
} else {
$this->strErrorMessage .= mysqli_error($this->strDBId) . '::';
$this->error = true;
}
}
return $booReturn;
}
/**
* Count the sum of data records
* @param string $strSQL SQL Statement
* @return int <number> = successful / 0 = no dataset or error
* Status messages are stored in class variable
*/
public function countRows($strSQL)
{
// Reset error variables
$this->strErrorMessage = '';
$this->error = false;
$intReturn = 0;
// Send the SQL statement to the server
$resQuery = mysqli_query($this->strDBId, $strSQL);
// Error processing
if ($resQuery && (mysqli_error($this->strDBId) == '')) {
$intReturn = mysqli_num_rows($resQuery);
} else {
$this->strErrorMessage .= mysqli_error($this->strDBId);
$this->error = true;
}
return $intReturn;
}
/**
* Returns a safe insert string for database manipulations
* @param string $strInput Input String
* @return string Output String
*/
public function realEscape($strInput)
{
return mysqli_real_escape_string($this->strDBId, $strInput);
}
/**
* Initialize a mysql database connection
* @return bool true = successful / false = error
*/
private function dbinit()
{
$this->strDBId = mysqli_init();
return true;
}
/**
* Connect to database server
* @param string $dbserver Server name
* @param int $dbport TCP port
* @param string $dbuser Database user
* @param string $dbpasswd Database password
* @return bool true = successful / false = error
* Status messages are stored in class variable
*/
private function dbconnect($dbserver = null, $dbport = null, $dbuser = null, $dbpasswd = null)
{
// Reset error variables
$this->strErrorMessage = '';
$this->error = false;
$booReturn = true;
// Get parameters
if ($dbserver == null) {
$dbserver = $this->arrParams['server'];
}
if ($dbport == null) {
$dbport = $this->arrParams['port'];
}
if ($dbuser == null) {
$dbuser = $this->arrParams['username'];
}
if ($dbpasswd == null) {
$dbpasswd = $this->arrParams['password'];
}
// Not all parameters available
if (($dbserver == '') || ($dbuser == '') || ($dbpasswd == '')) {
$this->strErrorMessage .= gettext('Missing server connection parameter!'). '::';
$this->error = true;
$booReturn = false;
}
if ($booReturn == true) {
$this->dbinit();
//if ($this->booSSLuse == true) {
// TO BE DEFINED
//}
$intErrorReporting = error_reporting();
error_reporting(0);
if ($dbport == 0) {
$booReturn = mysqli_real_connect($this->strDBId, $dbserver, $dbuser, $dbpasswd);
} else {
$booReturn = mysqli_real_connect($this->strDBId, $dbserver, $dbuser, $dbpasswd, null, $dbport);
}
error_reporting($intErrorReporting);
// Connection fails
if ($booReturn == false) {
$this->strErrorMessage = '[' .$dbserver. '] ' .gettext('Connection to the database server has failed '
. 'by reason:'). ' ::';
$strError = mysqli_connect_error();
$this->strErrorMessage .= $strError. '::';
$this->error = true;
}
}
return $booReturn;
}
/**
* Select a database
* @param string $database Database name
* @return bool true = successful / false = error
* Status messages are stored in class variable
*/
private function dbselect($database = null)
{
// Reset error variables
$this->strErrorMessage = '';
$this->error = false;
$booReturn = true;
// Get parameters
if ($database == null) {
$database = $this->arrParams['database'];
}
// Not all parameters available
if ($database == '') {
$this->strErrorMessage .= gettext('Missing database connection parameter!'). '::';
$this->error = true;
$booReturn = false;
}
if ($booReturn == true) {
$bolConnect = mysqli_select_db($this->strDBId, $database);
// Session cannot be etablished
if (!$bolConnect) {
$this->strErrorMessage .= '[' .$database. '] ' .
gettext('Connection to the database has failed by reason:'). ' ::';
$this->strErrorMessage .= mysqli_error($this->strDBId). '::';
$this->error = true;
$booReturn = false;
}
}
if ($booReturn == true) {
mysqli_query($this->strDBId, "set names 'utf8'");
if (mysqli_error($this->strDBId) != '') {
$this->strErrorMessage .= mysqli_error($this->strDBId). '::';
$this->error = true;
$booReturn = false;
}
}
if ($booReturn == true) {
mysqli_query($this->strDBId, "set session sql_mode = 'NO_ENGINE_SUBSTITUTION'");
if (mysqli_error($this->strDBId) != '') {
$this->strErrorMessage .= mysqli_error($this->strDBId). '::';
$this->error = true;
$booReturn = false;
}
}
return $booReturn;
}
/*
/**
* Set SSL connection parameters
* @param string $sslkey SSL key
* @param string $sslcert SSL certificate
* @param string $sslca SSL CA file (optional)
* @param string $sslpath SSL certificate path (optional)
* @param string $sslcypher SSL cypher (optional)
* @return bool true = successful
* Status messages are stored in class variable
*/
/*
private function dbsetssl($sslkey, $sslcert, $sslca = null, $sslpath = null, $sslcypher = null)
{
// Reset error variables
$this->strErrorMessage = "";
$this->error = false;
$booReturn = true;
// Values are missing
if (($sslkey == "") || ($sslcert == "")) {
$this->strErrorMessage = gettext("Missing MySQL SSL parameter!")."::";
$this->error = true;
$booReturn = false;
}
if ($booReturn == true) {
mysqli_ssl_set($this->strDBId, $sslkey, $sslcert, $sslca, $sslpath, $sslcypher);
}
return($booReturn);
}
*/
/**
* Close database server connectuon
* @return bool true = successful / false = error
*/
private function dbDisconnect()
{
mysqli_close($this->strDBId);
return true;
}
}

2448
functions/NagConfigClass.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,645 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2018 by Martin Willisegger
//
// Project : NagiosQL
// Component : Content Class
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Class: Common content functions
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Includes all functions used to display the application data
//
// Name: nagcontent
//
///////////////////////////////////////////////////////////////////////////////////////////////
namespace functions;
class NagContentClass
{
// Define class variables
private $arrSettings = array(); // Array includes all global settings
//
public $arrSession = array(); // Session content
public $arrDescription = array(); // Text values from fieldvars.php
public $intLimit = 15; // Data limit value
public $intDomainId = 0; // Configuration domain ID
public $intSortBy = -1; // Sort by field id
public $intGlobalWriteAccess = -1; // Global write access id
public $intVersion = 0; // Nagios version id
public $intGroupAdm = 0; // Group admin enabled/disabled
public $intWriteAccessId = 0; // Write access id
public $strTableName = ''; // Data table name
public $strSearchSession = ''; // Search session name
public $strErrorMessage = ''; // String including error messages
public $strSortDir = 'ASC'; // SQL sort direction (ASC/DESC)
public $strBrowser = ''; // Browser string
// Class includes
/** @var MysqliDbClass */
public $myDBClass; // Database class reference
/** @var NagConfigClass */
public $myConfigClass; // NagiosQL configuration class object
/** @var NagVisualClass */
public $myVisClass; // NagiosQL visual class object
/**
* NagContentClass constructor.
* @param array $arrSession PHP Session array
*/
public function __construct($arrSession)
{
if (isset($arrSession['SETS'])) {
// Read global settings
$this->arrSettings = $arrSession['SETS'];
}
if (isset($arrSession['domain'])) {
$this->intDomainId = $arrSession['domain'];
}
$this->arrSession = $arrSession;
}
/**
* Data list view - form initialization
* @param \HTML_Template_IT $objTemplate Form template object
*/
public function listViewInit($objTemplate)
{
// Language text replacements from fieldvars.php file
foreach ($this->arrDescription as $elem) {
$objTemplate->setVariable($elem['name'], $elem['string']);
}
// Some single replacements
$objTemplate->setVariable('LIMIT', $this->intLimit);
$objTemplate->setVariable('ACTION_MODIFY', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$objTemplate->setVariable('TABLE_NAME', $this->strTableName);
if (isset($this->arrSession['search'][$this->strSearchSession])) {
$objTemplate->setVariable('DAT_SEARCH', $this->arrSession['search'][$this->strSearchSession]);
}
$objTemplate->setVariable('MAX_ID', '0');
$objTemplate->setVariable('MIN_ID', '0');
}
/**
* Data list view - value insertions
* @param \HTML_Template_IT $objTemplate Form template object
* @param array $arrData Database values
* @param int $intDLCount1 Total count of data lines for one page
* @param int $intDLCount2 Total count of data lines (all data)
* @param string $strField1 Field name for data field 1
* @param string $strField2 Field name for data field 2
* @param int $intLimit Actual data char limit for field 2
*/
public function listData(
$objTemplate,
$arrData,
$intDLCount1,
$intDLCount2,
$strField1,
$strField2,
$intLimit = 0
) {
// Template block names
$strTplPart = 'datatable';
$strTplRow = 'datarow';
if ($this->strTableName == 'tbl_host') {
$strTplPart = 'datatablehost';
$strTplRow = 'datarowhost';
}
if ($this->strTableName == 'tbl_service') {
$strTplPart = 'datatableservice';
$strTplRow = 'datarowservice';
}
if (($this->strTableName == 'tbl_user') || ($this->strTableName == 'tbl_group') ||
($this->strTableName == 'tbl_datadomain') || ($this->strTableName == 'tbl_configtarget')) {
$strTplPart = 'datatablecommon';
$strTplRow = 'datarowcommon';
}
// Some single replacements
$objTemplate->setVariable('IMAGE_PATH_HEAD', $this->arrSettings['path']['base_url']. 'images/');
$objTemplate->setVariable('CELLCLASS_L', 'tdlb');
$objTemplate->setVariable('CELLCLASS_M', 'tdmb');
$objTemplate->setVariable('DISABLED', 'disabled');
$objTemplate->setVariable('DATA_FIELD_1', translate('No data'));
$objTemplate->setVariable('DATA_FIELD_2', '&nbsp;');
$objTemplate->setVariable('DATA_REGISTERED', '&nbsp;');
$objTemplate->setVariable('DATA_ACTIVE', '&nbsp;');
$objTemplate->setVariable('DATA_FILE', '&nbsp;');
$objTemplate->setVariable('PICTURE_CLASS', 'elementHide');
$objTemplate->setVariable('DOMAIN_SPECIAL', '&nbsp;');
$objTemplate->setVariable('SORT_BY', $this->intSortBy);
// Inserting data values
if ($intDLCount1 != 0) {
$intMinID = 0;
$intMaxID = 0;
for ($i=0; $i<$intDLCount1; $i++) {
// Get biggest and smalest value
if ($i == 0) {
$intMinID = $arrData[$i]['id'];
$intMaxID = $arrData[$i]['id'];
}
if ($arrData[$i]['id'] < $intMinID) {
$intMinID = $arrData[$i]['id'];
}
if ($arrData[$i]['id'] > $intMaxID) {
$intMaxID = $arrData[$i]['id'];
}
$objTemplate->setVariable('MAX_ID', $intMaxID);
$objTemplate->setVariable('MIN_ID', $intMinID);
// Line colours
$strClassL = 'tdld';
$strClassM = 'tdmd';
if ($i%2 == 1) {
$strClassL = 'tdlb';
$strClassM = 'tdmb';
}
if (isset($arrData[$i]['register']) && ($arrData[$i]['register'] == 0)) {
$strRegister = translate('No');
} else {
$strRegister = translate('Yes');
}
if ($arrData[$i]['active'] == 0) {
$strActive = translate('No');
} else {
$strActive = translate('Yes');
}
// Get file date for hosts and services
$intTimeInfo = 0;
$arrTimeData = array();
if ($this->strTableName == 'tbl_host') {
$intReturn = $this->myConfigClass->lastModifiedDir(
$this->strTableName,
$arrData[$i]['host_name'],
$arrData[$i]['id'],
$arrTimeData,
$intTimeInfo
);
if ($intReturn == 1) {
$this->strErrorMessage = $this->myConfigClass->strErrorMessage;
}
}
if ($this->strTableName == 'tbl_service') {
$intReturn = $this->myConfigClass->lastModifiedDir(
$this->strTableName,
$arrData[$i]['config_name'],
$arrData[$i]['id'],
$arrTimeData,
$intTimeInfo
);
if ($intReturn == 1) {
$this->strErrorMessage = $this->myConfigClass->strErrorMessage;
}
}
// Set datafields
foreach ($this->arrDescription as $elem) {
$objTemplate->setVariable($elem['name'], $elem['string']);
}
if ($arrData[$i][$strField1] == '') {
$arrData[$i][$strField1] = 'NOT DEFINED - ' .$arrData[$i]['id'];
}
$objTemplate->setVariable('DATA_FIELD_1', htmlentities($arrData[$i][$strField1], ENT_COMPAT, 'UTF-8'));
$objTemplate->setVariable('DATA_FIELD_1S', addslashes(htmlentities(
$arrData[$i][$strField1],
ENT_COMPAT,
'UTF-8'
)));
if ($strField2 == 'process_field') {
$arrData[$i]['process_field'] = $this->processField($arrData[$i], $this->strTableName);
} else {
$objTemplate->setVariable('DATA_FIELD_2S', addslashes(htmlentities(
$arrData[$i][$strField2],
ENT_COMPAT,
'UTF-8'
)));
}
if ($intLimit != 0) {
if (\strlen($arrData[$i][$strField2]) > $intLimit) {
$strAdd = ' ...';
} else {
$strAdd = '';
}
$objTemplate->setVariable('DATA_FIELD_2', htmlentities(substr(
$arrData[$i][$strField2],
0,
$intLimit
), ENT_COMPAT, 'UTF-8').$strAdd);
} else {
$objTemplate->setVariable('DATA_FIELD_2', htmlentities(
$arrData[$i][$strField2],
ENT_COMPAT,
'UTF-8'
));
}
$objTemplate->setVariable('DATA_REGISTERED', $strRegister);
if (substr_count($this->strTableName, 'template') != 0) {
$objTemplate->setVariable('DATA_REGISTERED', '-');
}
$objTemplate->setVariable('DATA_ACTIVE', $strActive);
$objTemplate->setVariable('DATA_FILE', '<span class="redmessage">'.translate('out-of-date').'</span>');
if ($intTimeInfo == 4) {
$objTemplate->setVariable('DATA_FILE', translate('no target'));
}
if ($intTimeInfo == 3) {
$objTemplate->setVariable('DATA_FILE', '<span class="greenmessage">'.translate('missed').'</span>');
}
if ($intTimeInfo == 2) {
$objTemplate->setVariable('DATA_FILE', '<span class="redmessage">'.translate('missed').'</span>');
}
if ($intTimeInfo == 0) {
$objTemplate->setVariable('DATA_FILE', translate('up-to-date'));
}
$objTemplate->setVariable('LINE_ID', $arrData[$i]['id']);
$objTemplate->setVariable('CELLCLASS_L', $strClassL);
$objTemplate->setVariable('CELLCLASS_M', $strClassM);
$objTemplate->setVariable('IMAGE_PATH', $this->arrSettings['path']['base_url']. 'images/');
$objTemplate->setVariable('PICTURE_CLASS', 'elementShow');
$objTemplate->setVariable('DOMAIN_SPECIAL', '');
$objTemplate->setVariable('DISABLED', '');
// Disable common domain objects
if (isset($arrData[$i]['config_id'])) {
if ($arrData[$i]['config_id'] != $this->intDomainId) {
$objTemplate->setVariable('PICTURE_CLASS', 'elementHide');
$objTemplate->setVariable('DOMAIN_SPECIAL', ' [common]');
$objTemplate->setVariable('DISABLED', 'disabled');
} else {
// Inactive items should not be written/downloaded
if ($arrData[$i]['active'] == 0) {
$objTemplate->setVariable('ACTIVE_CONTROL', 'elementHide');
}
}
}
// Check access rights for list objects
if (isset($arrData[$i]['access_group'])) {
if ($this->myVisClass->checkAccountGroup($arrData[$i]['access_group'], 'write') != 0) {
$objTemplate->setVariable('LINE_CONTROL', 'elementHide');
}
} else {
if ($this->intGlobalWriteAccess != 0) {
$objTemplate->setVariable('LINE_CONTROL', 'elementHide');
}
}
// Check global access rights for list objects
if ($this->intGlobalWriteAccess != 0) {
$objTemplate->setVariable('LINE_CONTROL', 'elementHide');
}
$objTemplate->parse($strTplRow);
}
} else {
$objTemplate->setVariable('IMAGE_PATH', $this->arrSettings['path']['base_url']. 'images/');
$objTemplate->parse($strTplRow);
}
$objTemplate->setVariable('BUTTON_CLASS', 'elementShow');
if ($this->intDomainId == 0) {
$objTemplate->setVariable('BUTTON_CLASS', 'elementHide');
}
// Check access rights for adding new objects
if ($this->intGlobalWriteAccess != 0) {
$objTemplate->setVariable('ADD_CONTROL', 'disabled="disabled"');
}
// Show page numbers
$objTemplate->setVariable('PAGES', $this->myVisClass->buildPageLinks(filter_input(
INPUT_SERVER,
'PHP_SELF',
FILTER_SANITIZE_STRING
), $intDLCount2, $this->intLimit, $this->intSortBy, $this->strSortDir));
$objTemplate->parse($strTplPart);
$objTemplate->show($strTplPart);
}
/**
* Display information messages
* @param \HTML_Template_IT $objTemplate Form template object
* @param string $strErrorMessage Error messages
* @param string $strInfoMessage Information messages
* @param string $strConsistMessage Consistency messages
* @param array $arrTimeData Time data array
* @param string $strTimeInfoString Time information message
* @param int $intNoTime Status value for showing time information (0 = show time)
*/
public function showMessages(
$objTemplate,
$strErrorMessage,
$strInfoMessage,
$strConsistMessage,
$arrTimeData,
$strTimeInfoString,
$intNoTime = 0
) {
// Display info messages
if ($strInfoMessage != '') {
$objTemplate->setVariable('INFOMESSAGE', $strInfoMessage);
$objTemplate->parse('infomessage');
}
// Display error messages
if ($strErrorMessage != '') {
$objTemplate->setVariable('ERRORMESSAGE', $strErrorMessage);
$objTemplate->parse('errormessage');
}
// Display time informations
if (($this->intDomainId != 0) && ($intNoTime == 0)) {
foreach ($arrTimeData as $key => $elem) {
if ($key == 'table') {
$objTemplate->setVariable('LAST_MODIFIED_TABLE', translate('Last database update:'). ' <b>' .
$elem. '</b>');
$objTemplate->parse('table_time');
} else {
$objTemplate->setVariable('LAST_MODIFIED_FILE', translate('Last file change of the configuration '.
'target '). ' <i>' .$key. '</i>: <b>' .$elem. '</b>');
$objTemplate->parse('file_time');
}
}
if ($strTimeInfoString != '') {
$objTemplate->setVariable('MODIFICATION_STATUS', $strTimeInfoString);
$objTemplate->parse('modification_status');
}
}
// Display consistency messages
if ($strConsistMessage != '') {
$objTemplate->setVariable('CONSIST_USAGE', $strConsistMessage);
$objTemplate->parse('consistency');
}
$objTemplate->parse('msgfooter');
$objTemplate->show('msgfooter');
}
/**
* Display page footer
* @param \HTML_Template_IT $objTemplate Form template object
* @param string $setFileVersion NagiosQL version
*/
public function showFooter($objTemplate, $setFileVersion)
{
$objTemplate->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' ".
"target='_blank'>NagiosQL</a> $setFileVersion");
$objTemplate->parse('footer');
$objTemplate->show('footer');
}
/**
* Single data form initialization
* @param \HTML_Template_IT $objTemplate Form template object
* @param string $strChbFields Comma separated string of checkbox value names
*/
public function addFormInit($objTemplate, $strChbFields = '')
{
// Language text replacements from fieldvars.php file
foreach ($this->arrDescription as $elem) {
$objTemplate->setVariable($elem['name'], $elem['string']);
}
// Some single replacements
$objTemplate->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$objTemplate->setVariable('IMAGE_PATH', $this->arrSettings['path']['base_url']. 'images/');
$objTemplate->setVariable('DOCUMENT_ROOT', $this->arrSettings['path']['base_url']);
$objTemplate->setVariable('ACT_CHECKED', 'checked');
$objTemplate->setVariable('REG_CHECKED', 'checked');
$objTemplate->setVariable('MODUS', 'insert');
$objTemplate->setVariable('VERSION', $this->intVersion);
$objTemplate->setVariable('LIMIT', $this->intLimit);
$objTemplate->setVariable('RELATION_CLASS', 'elementHide');
$objTemplate->setVariable('IFRAME_SRC', $this->arrSettings['path']['base_url']. 'admin/commandline.php');
// Some conditional replacements
if ($this->strBrowser != 'msie') {
$objTemplate->setVariable('MSIE_DISABLED', 'disabled="disabled"');
}
if ($this->intGroupAdm == 0) {
$objTemplate->setVariable('RESTRICT_GROUP_ADMIN', 'class="elementHide"');
}
if ($this->arrSettings['common']['seldisable'] == 0) {
$objTemplate->setVariable('MSIE_DISABLED', '');
}
if ($this->arrSettings['common']['tplcheck'] == 0) {
$objTemplate->setVariable('CHECK_BYPASS', 'return true;');
$objTemplate->setVariable('CHECK_BYPASS_NEW', '1');
} else {
$objTemplate->setVariable('CHECK_BYPASS_NEW', '0');
}
// Some replacements based on nagios version
if ($this->intVersion < 3) {
$objTemplate->setVariable('VERSION_20_VISIBLE', 'elementShow');
$objTemplate->setVariable('VERSION_30_VISIBLE', 'elementHide');
$objTemplate->setVariable('VERSION_40_VISIBLE', 'elementHide');
$objTemplate->setVariable('VERSION_20_MUST', 'inpmust');
$objTemplate->setVariable('VERSION_30_MUST', '');
$objTemplate->setVariable('VERSION_40_MUST', '');
$objTemplate->setVariable('VERSION_20_STAR', '*');
$objTemplate->setVariable('NAGIOS_VERSION', '2');
}
if ($this->intVersion >= 3) {
$objTemplate->setVariable('VERSION_20_VISIBLE', 'elementHide');
$objTemplate->setVariable('VERSION_30_VISIBLE', 'elementShow');
$objTemplate->setVariable('VERSION_40_VISIBLE', 'elementHide');
$objTemplate->setVariable('VERSION_20_MUST', '');
$objTemplate->setVariable('VERSION_30_MUST', 'inpmust');
$objTemplate->setVariable('VERSION_40_MUST', '');
$objTemplate->setVariable('VERSION_20_STAR', '');
$objTemplate->setVariable('NAGIOS_VERSION', '3');
}
if ($this->intVersion >= 4) {
$objTemplate->setVariable('VERSION_40_VISIBLE', 'elementShow');
$objTemplate->setVariable('VERSION_40_MUST', 'inpmust');
$objTemplate->setVariable('NAGIOS_VERSION', '4');
}
// Checkbox and radio field value replacements
if ($strChbFields != '') {
foreach (explode(',', $strChbFields) as $elem) {
$objTemplate->setVariable('DAT_' .$elem. '0_CHECKED', '');
$objTemplate->setVariable('DAT_' .$elem. '1_CHECKED', '');
$objTemplate->setVariable('DAT_' .$elem. '2_CHECKED', 'checked');
}
}
}
/**
* Single data form - value insertion
* @param \HTML_Template_IT $objTemplate Form template object
* @param array $arrModifyData Database values
* @param int $intLocked Data is locked (0 = no / 1 = yes)
* @param string $strInfo Information string
* @param string $strChbFields Comma separated string of checkbox value names
*/
public function addInsertData($objTemplate, $arrModifyData, $intLocked, $strInfo, $strChbFields = '')
{
// Insert text data values
foreach ($arrModifyData as $key => $value) {
if (($key == 'active') || ($key == 'register') || ($key == 'last_modified') || ($key == 'access_rights')) {
continue;
}
$objTemplate->setVariable('DAT_' .strtoupper($key), htmlentities($value, ENT_QUOTES, 'UTF-8'));
}
// Insert checkbox data values
if (isset($arrModifyData['active']) && ($arrModifyData['active'] != 1)) {
$objTemplate->setVariable('ACT_CHECKED', '');
}
if (isset($arrModifyData['register']) && ($arrModifyData['register'] != 1)) {
$objTemplate->setVariable('REG_CHECKED', '');
}
// Deselect any checkboxes
if ($strChbFields != '') {
foreach (explode(',', $strChbFields) as $elem) {
$objTemplate->setVariable('DAT_' .$elem. '0_CHECKED', '');
$objTemplate->setVariable('DAT_' .$elem. '1_CHECKED', '');
$objTemplate->setVariable('DAT_' .$elem. '2_CHECKED', '');
}
}
// Change some status values in locked data sets
if ($intLocked != 0) {
$objTemplate->setVariable('ACT_DISABLED', 'disabled');
$objTemplate->setVariable('ACT_CHECKED', 'checked');
$objTemplate->setVariable('ACTIVE', '1');
$objTemplate->setVariable('CHECK_MUST_DATA', $strInfo);
$objTemplate->setVariable('RELATION_CLASS', 'elementShow');
}
// Change mode to modify
$objTemplate->setVariable('MODUS', 'modify');
// Check write permission
if ($this->intWriteAccessId == 1) {
$objTemplate->setVariable('DISABLE_SAVE', 'disabled="disabled"');
}
if ($this->intGlobalWriteAccess == 1) {
$objTemplate->setVariable('DISABLE_SAVE', 'disabled="disabled"');
}
}
/**
* Process field view
* @param array $arrData Data array
* @param string $strTableName Table name
* @return string String includung field data
*/
public function processField($arrData, $strTableName)
{
$strField = '';
$arrDataHosts = array();
$arrDataHostgroups = array();
$arrDataService = array();
$arrDataServices = array();
// Hostdependency table
if ($strTableName == 'tbl_hostdependency') {
if ($arrData['dependent_host_name'] != 0) {
$strSQLHost = 'SELECT `host_name`, `exclude` FROM `tbl_host` ' .
'LEFT JOIN `tbl_lnkHostdependencyToHost_DH` ON `id`=`idSlave` ' .
'WHERE `idMaster`=' .$arrData['id']. ' ORDER BY `host_name`';
$this->myDBClass->hasDataArray($strSQLHost, $arrDataHosts, $intDCHost);
if ($intDCHost != 0) {
foreach ($arrDataHosts as $elem) {
if ($elem['exclude'] == 1) {
$strField .= 'H:!' .$elem['host_name']. ',';
} else {
$strField .= 'H:' .$elem['host_name']. ',';
}
}
}
}
if ($arrData['dependent_hostgroup_name'] != 0) {
$strSQLHost = 'SELECT `hostgroup_name`, `exclude` FROM `tbl_hostgroup` ' .
'LEFT JOIN `tbl_lnkHostdependencyToHostgroup_DH` ON `id`=`idSlave` ' .
'WHERE `idMaster`=' .$arrData['id']. ' ORDER BY `hostgroup_name`';
$this->myDBClass->hasDataArray($strSQLHost, $arrDataHostgroups, $intDCHostgroup);
if ($intDCHostgroup != 0) {
foreach ($arrDataHostgroups as $elem) {
if ($elem['exclude'] == 1) {
$strField .= 'HG:!' .$elem['hostgroup_name']. ',';
} else {
$strField .= 'HG:' .$elem['hostgroup_name']. ',';
}
}
}
}
}
// Hostescalation table
if ($strTableName == 'tbl_hostescalation') {
if ($arrData['host_name'] != 0) {
$strSQLHost = 'SELECT `host_name` FROM `tbl_host` ' .
'LEFT JOIN `tbl_lnkHostescalationToHost` ON `id`=`idSlave` ' .
'WHERE `idMaster`=' .$arrData['id']. ' ORDER BY `host_name`';
$this->myDBClass->hasDataArray($strSQLHost, $arrDataHosts, $intDCHost);
if ($intDCHost != 0) {
foreach ($arrDataHosts as $elem) {
$strField .= 'H:' .$elem['host_name']. ',';
}
}
}
if ($arrData['hostgroup_name'] != 0) {
$strSQLHost = 'SELECT `hostgroup_name` FROM `tbl_hostgroup` ' .
'LEFT JOIN `tbl_lnkHostescalationToHostgroup` ON `id`=`idSlave` ' .
'WHERE `idMaster`=' .$arrData['id']. ' ORDER BY `hostgroup_name`';
$this->myDBClass->hasDataArray($strSQLHost, $arrDataHostgroups, $intDCHostgroup);
if ($intDCHostgroup != 0) {
foreach ($arrDataHostgroups as $elem) {
$strField .= 'HG:' .$elem['hostgroup_name']. ',';
}
}
}
}
// Servicedependency table
if ($strTableName == 'tbl_servicedependency') {
if ($arrData['dependent_service_description'] == 2) {
$strField .= '*';
} elseif ($arrData['dependent_service_description'] != 0) {
$strSQLService = 'SELECT `strSlave` FROM `tbl_lnkServicedependencyToService_DS` ' .
'WHERE `idMaster`=' .$arrData['id']. ' ORDER BY `strSlave`';
$this->myDBClass->hasDataArray($strSQLService, $arrDataService, $intDCService);
if ($intDCService != 0) {
foreach ($arrDataService as $elem) {
$strField .= $elem['strSlave']. ',';
}
}
}
if ($strField == '') {
$strSQLService = 'SELECT `servicegroup_name` FROM `tbl_servicegroup` ' .
'LEFT JOIN `tbl_lnkServicedependencyToServicegroup_DS` ON `idSlave`=`id` ' .
'WHERE `idMaster`=' .$arrData['id']. ' ORDER BY `servicegroup_name`';
$this->myDBClass->hasDataArray($strSQLService, $arrDataService, $intDCService);
if ($intDCService != 0) {
foreach ($arrDataService as $elem) {
$strField .= $elem['servicegroup_name']. ',';
}
}
}
}
// Serviceescalation table
if ($strTableName == 'tbl_serviceescalation') {
if ($arrData['service_description'] == 2) {
$strField .= '*';
} elseif ($arrData['service_description'] != 0) {
$strSQLService = 'SELECT `strSlave` FROM `tbl_lnkServiceescalationToService` ' .
'WHERE `idMaster`=' .$arrData['id'];
$this->myDBClass->hasDataArray($strSQLService, $arrDataServices, $intDCServices);
if ($intDCServices != 0) {
foreach ($arrDataServices as $elem) {
$strField .= $elem['strSlave']. ',';
}
}
}
if ($strField == '') {
$strSQLService = 'SELECT `servicegroup_name` FROM `tbl_servicegroup` ' .
'LEFT JOIN `tbl_lnkServiceescalationToServicegroup` ON `idSlave`=`id` ' .
'WHERE `idMaster`=' .$arrData['id']. ' ORDER BY `servicegroup_name`';
$this->myDBClass->hasDataArray($strSQLService, $arrDataService, $intDCService);
if ($intDCService != 0) {
foreach ($arrDataService as $elem) {
$strField .= $elem['servicegroup_name']. ',';
}
}
}
}
// Some string manipulations - remove comma on line end
if (substr($strField, -1) == ',') {
$strField = substr($strField, 0, -1);
}
return $strField;
}
}

1600
functions/NagDataClass.php Normal file

File diff suppressed because it is too large Load Diff

1946
functions/NagImportClass.php Normal file

File diff suppressed because it is too large Load Diff

1452
functions/NagVisualClass.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,435 +1,460 @@
popup = false; /*
(c) 2005-2018 by Martin Willisegger
Project : NagiosQL
Component : common JavaScript functions
Website : https://sourceforge.net/projects/nagiosql/
Version : 3.4.0
GIT Repo : https://gitlab.com/wizonet/NagiosQL
*/
let popup = false;
function info(key1,key2,ver) { function info(key1,key2,ver) {
if(popup&&popup.closed==false) popup.close(); if(popup && popup.closed === false) popup.close();
var top = (screen.availHeight - 240) / 2; const top = (screen.availHeight - 240) / 2;
var left = (screen.availWidth - 320) / 2; const left = (screen.availWidth - 320) / 2;
popup = window.open("info.php?key1=" + key1 + "&key2=" + key2 + "&version=" + ver, popup = window.open("info.php?key1=" + key1 + "&key2=" + key2 + "&version=" + ver,
"Information", "Information",
"width=320, height=240, top=" + top + ", left=" + left + ", SCROLLBARS=YES, MERNUBAR=NO, DEPENDENT=YES"); "width=320, height=240, top=" + top + ", left=" + left + ", SCROLLBARS=YES, MERNUBAR=NO, DEPENDENT=YES");
popup.focus(); popup.focus();
} }
var myFocusObject = new Object();
const myFocusObject = {};
function checkfields(fields,frm,object) { function checkfields(fields,frm,object) {
var error = false; const ar_field = fields.split(",");
var ar_field = fields.split(","); for (let i=0;i<ar_field.length;i++){
for (i=0;i<ar_field.length;i++){ if (frm[ar_field[i]].value === "") {
if (frm[ar_field[i]].value == "") { //frm[ar_field[i]].focus();
//frm[ar_field[i]].focus(); object.myValue = frm[ar_field[i]];
object.myValue = frm[ar_field[i]]; return false;
return false; }
break; }
} return true;
}
return true;
} }
function checkfields2(fields,frm,object) { function checkfields2(fields,frm,object) {
var error = false; const ar_field = fields.split(",");
var ar_field = fields.split(","); for (let i=0;i<ar_field.length;i++){
for (i=0;i<ar_field.length;i++){ if ((frm[ar_field[i]].value === "") || (frm[ar_field[i]].value === "0")) {
if ((frm[ar_field[i]].value == "") || (frm[ar_field[i]].value == "0")) { //frm[ar_field[i]].focus();
//frm[ar_field[i]].focus(); object.myValue = frm[ar_field[i]];
object.myValue = frm[ar_field[i]]; return false;
return false; }
break; }
} return true;
}
return true;
} }
function checkboxes(fields,frm) { function checkboxes(fields,frm) {
var retval = false; let retval = false;
var ar_field = fields.split(","); const ar_field = fields.split(",");
for (let i=0;i<ar_field.length;i++){
for (i=0;i<ar_field.length;i++){ if (frm[ar_field[i]].checked === true) {
if (frm[ar_field[i]].checked == true) { retval = true;
retval = true; }
} }
} return retval;
return retval;
} }
<!-- YUI message box --> <!-- YUI message box -->
function msginit(msg,header,type) { function msginit(msg,header,type) {
YAHOO.namespace("msg.container"); let iconobj;
var handleOK = function() { YAHOO.namespace("msg.container");
this.hide(); const handleOK = function () {
//myFocusObject.myValue.focus(); this.hide();
}; //myFocusObject.myValue.focus();
if (type == 1) { };
var iconobj = YAHOO.widget.SimpleDialog.ICON_WARN; if (type === 1) {
} iconobj = YAHOO.widget.SimpleDialog.ICON_WARN;
if (type == 2) { }
var iconobj = YAHOO.widget.SimpleDialog.ICON_HELP; if (type === 2) {
} iconobj = YAHOO.widget.SimpleDialog.ICON_HELP;
YAHOO.msg.container.domainmsg = new YAHOO.widget.SimpleDialog("domainmsg", }
{ width: "300px", YAHOO.msg.container.domainmsg = new YAHOO.widget.SimpleDialog("domainmsg",
fixedcenter: true, { width: "300px",
visible: false, fixedcenter: true,
draggable: false, visible: false,
close: true, draggable: false,
text: msg, close: true,
modal: true, text: msg,
icon: iconobj, modal: true,
constraintoviewport: true, icon: iconobj,
buttons: [ { text:"Ok", handler:handleOK, isDefault:true } ] constraintoviewport: true,
} ); buttons: [ { text:"Ok", handler:handleOK, isDefault:true } ]
YAHOO.msg.container.domainmsg.setHeader(header); } );
YAHOO.msg.container.domainmsg.render("msgcontainer"); YAHOO.msg.container.domainmsg.setHeader(header);
YAHOO.msg.container.domainmsg.show(); YAHOO.msg.container.domainmsg.render("msgcontainer");
YAHOO.msg.container.domainmsg.show();
} }
<!-- YUI confirm box --> <!-- YUI confirm box -->
function confirminit(msg,header,type,yes,no,key) { function confirminit(msg,header,type,yes,no,key) {
YAHOO.namespace("question.container"); let iconobj;
var handleYes = function() { YAHOO.namespace("question.container");
confOpenerYes(key); const handleYes = function () {
this.hide(); // noinspection JSUnresolvedFunction
}; confOpenerYes(key);
var handleNo = function() { this.hide();
this.hide(); };
}; const handleNo = function () {
if (type == 1) { this.hide();
var iconobj = YAHOO.widget.SimpleDialog.ICON_WARN; };
} if (type === 1) {
YAHOO.question.container.domainmsg = new YAHOO.widget.SimpleDialog("confirm1", iconobj = YAHOO.widget.SimpleDialog.ICON_WARN;
{ width: "400px", }
fixedcenter: true, YAHOO.question.container.domainmsg = new YAHOO.widget.SimpleDialog("confirm1",
visible: false, { width: "400px",
draggable: false, fixedcenter: true,
close: true, visible: false,
text: msg, draggable: false,
modal: true, close: true,
icon: iconobj, text: msg,
constraintoviewport: true, modal: true,
buttons: [ { text:yes, handler:handleYes, isDefault:true }, icon: iconobj,
{ text:no, handler:handleNo }] constraintoviewport: true,
} ); buttons: [ { text:yes, handler:handleYes, isDefault:true },
YAHOO.question.container.domainmsg.setHeader(header); { text:no, handler:handleNo }]
YAHOO.question.container.domainmsg.render("confirmcontainer"); } );
YAHOO.question.container.domainmsg.show(); YAHOO.question.container.domainmsg.setHeader(header);
YAHOO.question.container.domainmsg.render("confirmcontainer");
YAHOO.question.container.domainmsg.show();
} }
<!-- YUI dialog box --> <!-- YUI dialog box -->
function dialoginit(key1,key2,ver,header) { function dialoginit(key1,key2,ver,header) {
YAHOO.namespace("dialog.container"); YAHOO.namespace("dialog.container");
var handleCancel = function() { const handleCancel = function () {
this.cancel(); this.cancel();
}; };
var handleSuccess = function(o){ const handleSuccess = function (o) {
if(o.responseText !== undefined){ if (o.responseText !== undefined) {
document.getElementById('dialogcontent').innerHTML = o.responseText; document.getElementById('dialogcontent').innerHTML = o.responseText;
} }
} };
var handleFailure = function(o){ const handleFailure = function (o) {
if(o.responseText !== undefined){ if (o.responseText !== undefined) {
document.getElementById('dialogcontent').innerHTML = "No information found"; document.getElementById('dialogcontent').innerHTML = "No information found";
} }
} };
var callback = { const callback = {
success:handleSuccess, success: handleSuccess,
failure: handleFailure failure: handleFailure
}; };
if (key2 == "updInfo") { let sUrl;
sUrl = "admin/info.php?key1=" + key1 + "&key2=" + key2 + "&version=" + ver; if (key2 === "updInfo") {
} else { sUrl = "admin/info.php?key1=" + key1 + "&key2=" + key2 + "&version=" + ver;
sUrl = "info.php?key1=" + key1 + "&key2=" + key2 + "&version=" + ver; } else {
} sUrl = "info.php?key1=" + key1 + "&key2=" + key2 + "&version=" + ver;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); }
if (typeof YAHOO.dialog.container.infodialog == "undefined") { YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
YAHOO.dialog.container.infodialog = new YAHOO.widget.Dialog("infodialog",
{ width : "50em", if (typeof YAHOO.dialog.container.infodialog === "undefined") {
visible : false, YAHOO.dialog.container.infodialog = new YAHOO.widget.Dialog("infodialog",
draggable: true, { width : "50em",
fixedcenter: true, visible : false,
constraintoviewport : true, draggable: true,
buttons : [ { text:"Ok", handler:handleCancel, isDefault:true } ] fixedcenter: true,
}); constraintoviewport : true,
buttons : [ { text:"Ok", handler:handleCancel, isDefault:true } ]
} });
YAHOO.dialog.container.infodialog.setHeader(header); }
YAHOO.dialog.container.infodialog.render();
YAHOO.dialog.container.infodialog.show(); YAHOO.dialog.container.infodialog.setHeader(header);
YAHOO.dialog.container.infodialog.render();
YAHOO.dialog.container.infodialog.show();
} }
<!-- YUI calendar --> <!-- YUI calendar -->
function calendarinit(lang,start,field,key,cont,obj) { function calendarinit(lang,start,field,key,cont,obj) {
YAHOO.util.Event.onDOMReady(function(){ YAHOO.util.Event.onDOMReady(function(){
var dialog, calendar; let dialog, calendar;
calendar = new YAHOO.widget.Calendar(obj, { calendar = new YAHOO.widget.Calendar(obj, {
iframe:false, iframe:false,
hide_blank_weeks:true, hide_blank_weeks:true,
START_WEEKDAY:start START_WEEKDAY:start
}); });
if (lang == "de_DE") { if (lang === "de_DE") {
calendar.cfg.setProperty("MONTHS_LONG", ["Januar", "Februar", "M\u00E4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]); calendar.cfg.setProperty("MONTHS_LONG", ["Januar", "Februar", "M\u00E4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]);
calendar.cfg.setProperty("WEEKDAYS_SHORT", ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"]); calendar.cfg.setProperty("WEEKDAYS_SHORT", ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"]);
} }
function cancelHandler() { //function cancelHandler() {
this.hide(); // this.hide();
} //}
function handleSelect(type,args,obj) { //function handleSelect(type,args,obj) {
var dates = args[0]; function handleSelect(type,args) {
var date = dates[0]; const dates = args[0];
var year = date[0], month = date[1], day = date[2]; const date = dates[0];
const year = date[0];
var txtDate1 = document.getElementById(field); let month = date[1], day = date[2];
if (month < 10) { month = "0" + month;}
if (day < 10) { day = "0" + day;} const txtDate1 = document.getElementById(field);
txtDate1.value = year + "-" + month + "-" + day; if (month < 10) { month = "0" + month;}
dialog.hide(); if (day < 10) { day = "0" + day;}
} // noinspection JSUndefinedPropertyAssignment
txtDate1.value = year + "-" + month + "-" + day;
dialog = new YAHOO.widget.Dialog(cont, { dialog.hide();
context:[field, "tl", "bl"], }
width:"16em",
draggable:true, dialog = new YAHOO.widget.Dialog(cont, {
close:true context:[field, "tl", "bl"],
}); width:"16em",
calendar.render(); draggable:true,
dialog.render(); close:true
dialog.hide(); });
calendar.render();
calendar.renderEvent.subscribe(function() { dialog.render();
dialog.fireEvent("changeContent"); dialog.hide();
});
calendar.selectEvent.subscribe(handleSelect, calendar.cal1, true); calendar.renderEvent.subscribe(function() {
dialog.fireEvent("changeContent");
YAHOO.util.Event.on(key, "click", dialog.show, dialog, true); });
}); // noinspection JSUnresolvedVariable
calendar.selectEvent.subscribe(handleSelect, calendar.cal1, true);
YAHOO.util.Event.on(key, "click", dialog.show, dialog, true);
});
} }
// Open edit dialog for list boxes // Open edit dialog for list boxes
function openMutDlgInit(field,divbox,header,key,langkey1,langkey2,exclude) { function openMutDlgInit(field,divbox,header,key,langkey1,langkey2,exclude) {
YAHOO.util.Event.onDOMReady(function(){
var mutdialog;
var handleSuccess = function(o){
if(o.responseText !== undefined){
document.getElementById(divbox+'content').innerHTML = o.responseText;
}
}
var handleFailure = function(o){
if(o.responseText !== undefined){
document.getElementById(divbox+'content').innerHTML = "No information found";
}
}
var callback = {
success:handleSuccess,
failure: handleFailure
};
sUrl = "mutdialog.php?object=" + field + "&exclude=" + exclude;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
var handleSave = function() {
var source = document.getElementById(field);
var targetSelect = document.getElementById(field+'Selected');
var targetAvail = document.getElementById(field+'Avail');
for (i = 0; i < targetSelect.length; ++i) {
targetSelect.options[i].selected = true;
}
for (i = 0; i < source.length; ++i) {
source.options[i].selected = false;
source.options[i].className = source.options[i].className.replace(/ ieselected/g , '');
}
for (i = 0; i < targetSelect.length; ++i) {
for (y = 0; y < source.length; ++y) {
var value1 = targetSelect.options[i].value.replace(/^e/g , '');
var value2 = "e"+value1;
if ((source.options[y].value == value1) || (source.options[y].value == value2)) {
source.options[y].selected = true;
source.options[y].value = targetSelect.options[i].value;
source.options[y].text = targetSelect.options[i].text;
source.options[y].className = source.options[y].className+" ieselected";
}
}
}
this.cancel();
if ((typeof(update) == 'number') && (update == 1)) {
updateForm(field);
}
};
var handleCancel = function() {
this.cancel();
};
mutdialog = new YAHOO.widget.Dialog(divbox,
{ width : "60em",
fixedcenter : true,
visible : false,
draggable: true,
modal: true,
constraintoviewport : true,
buttons : [ { text:langkey1, handler:handleSave, isDefault:true },
{ text:langkey2, handler:handleCancel } ]
});
mutdialog.setHeader(header);
mutdialog.render();
mutdialog.hide();
mutdialog.beforeShowEvent.subscribe(function() {
getData(field);
});
YAHOO.util.Event.on(key, "click", mutdialog.show, mutdialog, true); YAHOO.util.Event.onDOMReady(function(){
});
let mutdialog;
const handleSuccess = function (o) {
if (o.responseText !== undefined) {
document.getElementById(divbox + 'content').innerHTML = o.responseText;
}
};
const handleFailure = function (o) {
if (o.responseText !== undefined) {
document.getElementById(divbox + 'content').innerHTML = "No information found";
}
};
const callback = {
success: handleSuccess,
failure: handleFailure
};
let sUrl;
sUrl = "mutdialog.php?object=" + field + "&exclude=" + exclude;
YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
const handleSave = function () {
const source = document.getElementById(field);
const targetSelect = document.getElementById(field + 'Selected');
//const targetAvail = document.getElementById(field + 'Avail');
for (let i = 0; i < targetSelect.length; ++i) {
targetSelect.options[i].selected = true;
}
for (let i = 0; i < source.length; ++i) {
source.options[i].selected = false;
source.options[i].className = source.options[i].className.replace(/ ieselected/g, '');
}
for (let i = 0; i < targetSelect.length; ++i) {
for (let y = 0; y < source.length; ++y) {
const value1 = targetSelect.options[i].value.replace(/^e/g, '');
const value2 = "e" + value1;
if ((source.options[y].value === value1) || (source.options[y].value === value2)) {
source.options[y].selected = true;
source.options[y].value = targetSelect.options[i].value;
source.options[y].text = targetSelect.options[i].text;
source.options[y].className = source.options[y].className + " ieselected";
}
}
}
this.cancel();
// noinspection JSUnresolvedVariable
if ((typeof(update) === 'number') && (update === 1)) {
// noinspection JSUnresolvedFunction
updateForm(field);
}
};
const handleCancel = function () {
this.cancel();
};
mutdialog = new YAHOO.widget.Dialog(divbox,
{ width : "60em",
fixedcenter : true,
visible : false,
draggable: true,
modal: true,
constraintoviewport : true,
buttons : [ { text:langkey1, handler:handleSave, isDefault:true },
{ text:langkey2, handler:handleCancel } ]
});
mutdialog.setHeader(header);
mutdialog.render();
mutdialog.hide();
mutdialog.beforeShowEvent.subscribe(function() {
getData(field);
});
YAHOO.util.Event.on(key, "click", mutdialog.show, mutdialog, true);
});
} }
// Additional functions for edit dialog // Additional functions for edit dialog
function getData(field) { function getData(field) {
var source = document.getElementById(field); const source = document.getElementById(field);
var targetSelect = document.getElementById(field+'Selected'); const targetSelect = document.getElementById(field + 'Selected');
var targetAvail = document.getElementById(field+'Avail'); const targetAvail = document.getElementById(field + 'Avail');
for (i=0; i < targetSelect.length; i++) { for (let i=0; i < targetSelect.length; i++) {
targetSelect.options[i] = null; targetSelect.options[i] = null;
} }
targetSelect.length = 0; // noinspection JSUndefinedPropertyAssignment
for (i=0; i < targetAvail.length; i++) { targetSelect.length = 0;
targetAvail.options[i] = null; for (let i=0; i < targetAvail.length; i++) {
} targetAvail.options[i] = null;
targetAvail.length = 0; }
for (i = 0; i < source.length; ++i) { // noinspection JSUndefinedPropertyAssignment
if (source.options[i].selected == true) { targetAvail.length = 0;
NeuerEintrag1 = new Option(source.options[i].text, source.options[i].value, false, false); let NeuerEintrag1;
NeuerEintrag1.className = source.options[i].className.replace(/ ieselected/g , ''); let NeuerEintrag2;
NeuerEintrag1.className = NeuerEintrag1.className.replace(/ inpmust/g , ''); for (let i = 0; i < source.length; ++i) {
targetSelect.options[targetSelect.length] = NeuerEintrag1; if (source.options[i].selected === true) {
} NeuerEintrag1 = new Option(source.options[i].text, source.options[i].value, false, false);
if (source.options[i].selected == false) { NeuerEintrag1.className = source.options[i].className.replace(/ ieselected/g, '');
if (source.options[i].text != "") { NeuerEintrag1.className = NeuerEintrag1.className.replace(/ inpmust/g, '');
NeuerEintrag2 = new Option(source.options[i].text, source.options[i].value, false, false); targetSelect.options[targetSelect.length] = NeuerEintrag1;
NeuerEintrag2.className = source.options[i].className.replace(/ ieselected/g , ''); }
NeuerEintrag2.className = NeuerEintrag2.className.replace(/ inpmust/g , ''); if (source.options[i].selected === false) {
targetAvail.options[targetAvail.length] = NeuerEintrag2; if (source.options[i].text !== "") {
} NeuerEintrag2 = new Option(source.options[i].text, source.options[i].value, false, false);
} NeuerEintrag2.className = source.options[i].className.replace(/ ieselected/g, '');
} NeuerEintrag2.className = NeuerEintrag2.className.replace(/ inpmust/g, '');
targetAvail.options[targetAvail.length] = NeuerEintrag2;
}
}
}
} }
// Insert selection // Insert selection
function selValue(field) { function selValue(field) {
var targetSelect = document.getElementById(field+'Selected'); const targetSelect = document.getElementById(field + 'Selected');
var targetAvail = document.getElementById(field+'Avail'); const targetAvail = document.getElementById(field + 'Avail');
if (targetAvail.selectedIndex != -1) { let NeuerEintrag;
var DelOptions = new Array(); if (targetAvail.selectedIndex !== -1) {
for (i = 0; i < targetAvail.length; ++i) { const DelOptions = [];
if (targetAvail.options[i].selected == true) { for (let i = 0; i < targetAvail.length; ++i) {
NeuerEintrag = new Option(targetAvail.options[i].text, targetAvail.options[i].value, false, false); if (targetAvail.options[i].selected === true) {
NeuerEintrag.className = targetAvail.options[i].className; NeuerEintrag = new Option(targetAvail.options[i].text, targetAvail.options[i].value, false, false);
targetSelect.options[targetSelect.length] = NeuerEintrag; NeuerEintrag.className = targetAvail.options[i].className;
DelOptions.push(i); targetSelect.options[targetSelect.length] = NeuerEintrag;
} DelOptions.push(i);
} }
sort(targetSelect); }
DelOptions.reverse(); sort(targetSelect);
for (var i = 0; i < DelOptions.length; ++i) { DelOptions.reverse();
targetAvail.options[DelOptions[i]] = null; for (let i=0; i<DelOptions.length; ++i) {
} targetAvail.options[DelOptions[i]] = null;
} }
}
} }
// Insert selection (exclude variant) // Insert selection (exclude variant)
function selValueEx(field) { function selValueEx(field) {
var targetSelect = document.getElementById(field+'Selected'); const targetSelect = document.getElementById(field + 'Selected');
var targetAvail = document.getElementById(field+'Avail'); const targetAvail = document.getElementById(field + 'Avail');
if (targetAvail.selectedIndex != -1) { let NeuerEintrag;
var DelOptions = new Array(); if (targetAvail.selectedIndex !== -1) {
for (i = 0; i < targetAvail.length; ++i) { const DelOptions = [];
if (targetAvail.options[i].selected == true) { for (let i = 0; i < targetAvail.length; ++i) {
if ((targetAvail.options[i].text != '*') && (targetAvail.options[i].value != '0')) { if (targetAvail.options[i].selected === true) {
NeuerEintrag = new Option("!"+targetAvail.options[i].text, "e"+targetAvail.options[i].value, false, false); if ((targetAvail.options[i].text !== '*') && (targetAvail.options[i].value !== '0')) {
} else { NeuerEintrag = new Option("!" + targetAvail.options[i].text, "e" + targetAvail.options[i].value, false, false);
NeuerEintrag = new Option(targetAvail.options[i].text, targetAvail.options[i].value, false, false); } else {
} NeuerEintrag = new Option(targetAvail.options[i].text, targetAvail.options[i].value, false, false);
NeuerEintrag.className = targetAvail.options[i].className; }
targetSelect.options[targetSelect.length] = NeuerEintrag; NeuerEintrag.className = targetAvail.options[i].className;
DelOptions.push(i); targetSelect.options[targetSelect.length] = NeuerEintrag;
} DelOptions.push(i);
} }
sort(targetSelect); }
DelOptions.reverse(); sort(targetSelect);
for (var i = 0; i < DelOptions.length; ++i) { DelOptions.reverse();
targetAvail.options[DelOptions[i]] = null; for (let i = 0; i < DelOptions.length; ++i) {
} targetAvail.options[DelOptions[i]] = null;
} }
}
} }
// Remove selection // Remove selection
function desValue(field) { function desValue(field) {
var targetSelect = document.getElementById(field+'Selected'); const targetSelect = document.getElementById(field + 'Selected');
var targetAvail = document.getElementById(field+'Avail'); const targetAvail = document.getElementById(field + 'Avail');
if (targetSelect.selectedIndex != -1) { let NeuerEintrag;
var DelOptions = new Array(); if (targetSelect.selectedIndex !== -1) {
for (i = 0; i < targetSelect.length; ++i) { const DelOptions = [];
if (targetSelect.options[i].selected == true) { for (let i = 0; i < targetSelect.length; ++i) {
var text = targetSelect.options[i].text.replace(/^!/g , ''); if (targetSelect.options[i].selected === true) {
var value = targetSelect.options[i].value.replace(/^e/g , ''); const text = targetSelect.options[i].text.replace(/^!/g, '');
NeuerEintrag = new Option(text, value, false, false); const value = targetSelect.options[i].value.replace(/^e/g, '');
NeuerEintrag.className = targetSelect.options[i].className; NeuerEintrag = new Option(text, value, false, false);
targetAvail.options[targetAvail.length] = NeuerEintrag; NeuerEintrag.className = targetSelect.options[i].className;
DelOptions.push(i); targetAvail.options[targetAvail.length] = NeuerEintrag;
} DelOptions.push(i);
} }
sort(targetAvail); }
DelOptions.reverse(); sort(targetAvail);
for (var i = 0; i < DelOptions.length; ++i) { DelOptions.reverse();
targetSelect.options[DelOptions[i]] = null; for (let i = 0; i < DelOptions.length; ++i) {
} targetSelect.options[DelOptions[i]] = null;
} }
}
} }
// Sort entries // Sort entries
function sort(obj){ function sort(obj){
var sortieren = new Array(); const sortieren = [];
var list = new Array(); const list = [];
var i; let i;
// Insert list to array // Insert list to array
for (i=0; i < obj.options.length; i++) { for (i=0; i < obj.options.length; i++) {
list[i] = new Array(); list[i] = [];
list[i]["text"] = obj.options[i].text; list[i]["text"] = obj.options[i].text;
list[i]["value"] = obj.options[i].value; list[i]["value"] = obj.options[i].value;
list[i]["className"] = obj.options[i].className; list[i]["className"] = obj.options[i].className;
} }
// Sort into a single dimension array // Sort into a single dimension array
for (i=0; i < obj.length; i++){ for (i=0; i < obj.length; i++){
sortieren[i]=list[i]["text"]+";"+list[i]["value"]+";"+list[i]["className"]; sortieren[i]=list[i]["text"]+";"+list[i]["value"]+";"+list[i]["className"];
} }
// Real sort // Real sort
sortieren.sort(); sortieren.sort();
// Make array to list // Make array to list
for (i=0; i < sortieren.length; i++) { for (i=0; i < sortieren.length; i++) {
var felder = sortieren[i].split(";"); const felder = sortieren[i].split(";");
list[i]["text"] = felder[0]; list[i]["text"] = felder[0];
list[i]["value"] = felder[1]; list[i]["value"] = felder[1];
list[i]["className"] = felder[2]; list[i]["className"] = felder[2];
} }
// Remove list field // Remove list field
for (i=0; i < obj.options.length; i++) { for (i=0; i < obj.options.length; i++) {
obj.options[i] = null; obj.options[i] = null;
} }
// insert list to dialog // insert list to dialog
for (i=0; i < list.length; i++){ let NeuerEintrag;
NeuerEintrag = new Option(list[i]["text"], list[i]["value"], false, false); for (i = 0; i < list.length; i++) {
NeuerEintrag.className = list[i]["className"]; NeuerEintrag = new Option(list[i]["text"], list[i]["value"], false, false);
obj.options[i] = NeuerEintrag; NeuerEintrag.className = list[i]["className"];
} obj.options[i] = NeuerEintrag;
}
} }
// Show relation data // Show relation data
function showRelationData(option) { function showRelationData(option) {
if (option == 1) { if (option === 1) {
document.getElementById("rel_text").className = "elementHide"; document.getElementById("rel_text").className = "elementHide";
document.getElementById("rel_info").className = "elementShow"; document.getElementById("rel_info").className = "elementShow";
} else { } else {
document.getElementById("rel_text").className = "elementShow"; document.getElementById("rel_text").className = "elementShow";
document.getElementById("rel_info").className = "elementHide"; document.getElementById("rel_info").className = "elementHide";
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,509 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2017 by Martin Willisegger
//
// Project : NagiosQL
// Component : Content Class
// 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 $
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Class: Common content functions
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Includes all functions used to display the application data
//
// Name: nagcontent
//
///////////////////////////////////////////////////////////////////////////////////////////////
class nagcontent {
// Define class variables
var $arrSettings; // Array includes all global settings
var $myVisClass; // NagiosQL visual class object
var $myDBClass; // NagiosQL data base class object
var $myConfigClass; // NagiosQL configuration class object
var $intLimit; // Data limit value
var $intVersion; // Nagios version id
var $strBrowser; // Browser string
var $intGroupAdm; // Group admin enabled/disabled
var $intWriteAccessId; // Write access id
var $intGlobalWriteAccess; // Global write access id
var $arrDescription; // Language field values from fieldvars.php
var $strTableName; // Data table name
var $strSearchSession; // Search session name
var $intSortBy; // Sort by field id
var $strSortDir; // SQL sort direction (ASC/DESC)
var $intDomainId = 0; // Domain id value
var $strErrorMessage = ""; // String including error messages
///////////////////////////////////////////////////////////////////////////////////////////
// Class constructor
///////////////////////////////////////////////////////////////////////////////////////////
//
// Activities during class initialization
//
///////////////////////////////////////////////////////////////////////////////////////////
function __construct() {
// Read global settings
$this->arrSettings = $_SESSION['SETS'];
if (isset($_SESSION['domain'])) $this->intDomainId = $_SESSION['domain'];
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Single data form initialization
///////////////////////////////////////////////////////////////////////////////////////////
//
// Parameter: $objTemplate Form template object
// $strChbFields Comma separated string of checkbox value names
//
// Return values: none
//
///////////////////////////////////////////////////////////////////////////////////////////
function addFormInit($objTemplate,$strChbFields='') {
// Language text replacements from fieldvars.php file
foreach($this->arrDescription AS $elem) {
$objTemplate->setVariable($elem['name'],$elem['string']);
}
// Some single replacements
$objTemplate->setVariable("ACTION_INSERT",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
$objTemplate->setVariable("IMAGE_PATH",$this->arrSettings['path']['base_url']."images/");
$objTemplate->setVariable("DOCUMENT_ROOT",$this->arrSettings['path']['base_url']);
$objTemplate->setVariable("ACT_CHECKED","checked");
$objTemplate->setVariable("REG_CHECKED","checked");
$objTemplate->setVariable("MODUS","insert");
$objTemplate->setVariable("VERSION",$this->intVersion);
$objTemplate->setVariable("LIMIT",$this->intLimit);
$objTemplate->setVariable("RELATION_CLASS","elementHide");
$objTemplate->setVariable("IFRAME_SRC",$this->arrSettings['path']['base_url']."admin/commandline.php");
// Some conditional replacements
if ($this->strBrowser != "msie") $objTemplate->setVariable("MSIE_DISABLED","disabled=\"disabled\"");
if ($this->intGroupAdm == 0) $objTemplate->setVariable("RESTRICT_GROUP_ADMIN","class=\"elementHide\"");
if ($this->arrSettings['common']['seldisable'] == 0) $objTemplate->setVariable("MSIE_DISABLED","");
if ($this->arrSettings['common']['tplcheck'] == 0) $objTemplate->setVariable("CHECK_BYPASS","return true;");
// Some replacements based on nagios version
if ($this->intVersion == 3) {
$objTemplate->setVariable("VERSION_20_VISIBLE","elementHide");
$objTemplate->setVariable("VERSION_30_VISIBLE","elementShow");
$objTemplate->setVariable("VERSION_20_MUST","");
$objTemplate->setVariable("VERSION_30_MUST","inpmust");
$objTemplate->setVariable("VERSION_20_STAR","");
$objTemplate->setVariable("NAGIOS_VERSION","3");
} else {
$objTemplate->setVariable("VERSION_20_VISIBLE","elementShow");
$objTemplate->setVariable("VERSION_30_VISIBLE","elementHide");
$objTemplate->setVariable("VERSION_20_MUST","inpmust");
$objTemplate->setVariable("VERSION_30_MUST","");
$objTemplate->setVariable("VERSION_20_STAR","*");
$objTemplate->setVariable("NAGIOS_VERSION","2");
}
// Checkbox and radio field value replacements
if ($strChbFields != '') {
foreach (explode(",",$strChbFields) AS $elem) {
$objTemplate->setVariable("DAT_".$elem."0_CHECKED","");
$objTemplate->setVariable("DAT_".$elem."1_CHECKED","");
$objTemplate->setVariable("DAT_".$elem."2_CHECKED","checked");
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Single data form - value insertions
///////////////////////////////////////////////////////////////////////////////////////////
//
// Parameter: $objTemplate Form template object
// $arrModifyData Database values
// $intLocked Data is locked (0=no / 1=yes)
// $strInfo Information string
// $strChbFields Comma separated string of checkbox value names
//
// Return values: none
//
///////////////////////////////////////////////////////////////////////////////////////////
function addInsertData($objTemplate,$arrModifyData,$intLocked,$strInfo,$strChbFields = '') {
// Insert text data values
foreach($arrModifyData AS $key => $value) {
if (($key == "active") || ($key == "register") || ($key == "last_modified") || ($key == "access_rights")) continue;
$objTemplate->setVariable("DAT_".strtoupper($key),htmlentities($value,ENT_QUOTES,'UTF-8'));
}
// Insert checkbox data values
if ((isset($arrModifyData['active'])) && ($arrModifyData['active'] != 1)) $objTemplate->setVariable("ACT_CHECKED","");
if ((isset($arrModifyData['register'])) && ($arrModifyData['register'] != 1)) $objTemplate->setVariable("REG_CHECKED","");
// Deselect any checkboxes
if ($strChbFields != '') {
foreach (explode(",",$strChbFields) AS $elem) {
$objTemplate->setVariable("DAT_".$elem."0_CHECKED","");
$objTemplate->setVariable("DAT_".$elem."1_CHECKED","");
$objTemplate->setVariable("DAT_".$elem."2_CHECKED","");
}
}
// Change some status values in locked data sets
if ($intLocked != 0) {
$objTemplate->setVariable("ACT_DISABLED","disabled");
$objTemplate->setVariable("ACT_CHECKED","checked");
$objTemplate->setVariable("ACTIVE","1");
$objTemplate->setVariable("CHECK_MUST_DATA",$strInfo);
$objTemplate->setVariable("RELATION_CLASS","elementShow");
}
// Change mode to modify
$objTemplate->setVariable("MODUS","modify");
// Check write permission
if ($this->intWriteAccessId == 1) $objTemplate->setVariable("DISABLE_SAVE","disabled=\"disabled\"");
if ($this->intGlobalWriteAccess == 1) $objTemplate->setVariable("DISABLE_SAVE","disabled=\"disabled\"");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: List view - form initialization
///////////////////////////////////////////////////////////////////////////////////////////
//
// Parameter: $objTemplate Form template object
//
// Return values: none
//
///////////////////////////////////////////////////////////////////////////////////////////
function listViewInit($objTemplate) {
// Language text replacements from fieldvars.php file
foreach($this->arrDescription AS $elem) {
$objTemplate->setVariable($elem['name'],$elem['string']);
}
// Some single replacements
$objTemplate->setVariable("LIMIT",$this->intLimit);
$objTemplate->setVariable("ACTION_MODIFY",filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING));
$objTemplate->setVariable("TABLE_NAME",$this->strTableName);
$objTemplate->setVariable("DAT_SEARCH",$_SESSION['search'][$this->strSearchSession]);
$objTemplate->setVariable("MAX_ID","0");
$objTemplate->setVariable("MIN_ID","0");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: List view - value insertions
///////////////////////////////////////////////////////////////////////////////////////////
//
// Parameter: $objTemplate Form template object
// $arrData Database values
// $intDataCount Total count of data lines for one page
// $intLineCount Total count of data lines (all data)
// $strField1 Field name for data field 1
// $strField2 Field name for data field 2
// $intLimit2 Actual data char limit for field 2
//
// Return values: none
//
///////////////////////////////////////////////////////////////////////////////////////////
function listData($objTemplate,$arrData,$intDataCount,$intLineCount,$strField1,$strField2,$intLimit2=0) {
// Template block names
$strTplPart = 'datatable';
$strTplRow = 'datarow';
if ($this->strTableName == "tbl_host") {
$strTplPart = 'datatablehost';
$strTplRow = 'datarowhost';
}
if ($this->strTableName == "tbl_service") {
$strTplPart = 'datatableservice';
$strTplRow = 'datarowservice';
}
if (($this->strTableName == "tbl_user") || ($this->strTableName == "tbl_group") || ($this->strTableName == "tbl_datadomain") || ($this->strTableName == "tbl_configtarget")) {
$strTplPart = 'datatablecommon';
$strTplRow = 'datarowcommon';
}
// Some single replacements
$objTemplate->setVariable("IMAGE_PATH_HEAD",$this->arrSettings['path']['base_url']."images/");
$objTemplate->setVariable("CELLCLASS_L","tdlb");
$objTemplate->setVariable("CELLCLASS_M","tdmb");
$objTemplate->setVariable("DISABLED","disabled");
$objTemplate->setVariable("DATA_FIELD_1",translate('No data'));
$objTemplate->setVariable("DATA_FIELD_2","&nbsp;");
$objTemplate->setVariable("DATA_REGISTERED","&nbsp;");
$objTemplate->setVariable("DATA_ACTIVE","&nbsp;");
$objTemplate->setVariable("DATA_FILE","&nbsp;");
$objTemplate->setVariable("PICTURE_CLASS","elementHide");
$objTemplate->setVariable("DOMAIN_SPECIAL","&nbsp;");
$objTemplate->setVariable("SORT_BY",$this->intSortBy);
// Inserting data values
if ($intDataCount != 0) {
for ($i=0;$i<$intDataCount;$i++) {
// Get biggest and smalest value
if ($i == 0) {$y = $arrData[$i]['id']; $z = $arrData[$i]['id'];}
if ($arrData[$i]['id'] < $y) $y = $arrData[$i]['id'];
if ($arrData[$i]['id'] > $z) $z = $arrData[$i]['id'];
$objTemplate->setVariable("MAX_ID",$z);
$objTemplate->setVariable("MIN_ID",$y);
// Line colours
$strClassL = "tdld"; $strClassM = "tdmd";
if ($i%2 == 1) {$strClassL = "tdlb"; $strClassM = "tdmb";}
if ((isset($arrData[$i]['register'])) && ($arrData[$i]['register'] == 0)) {$strRegister = translate('No');} else {$strRegister = translate('Yes');}
if ($arrData[$i]['active'] == 0) {$strActive = translate('No');} else {$strActive = translate('Yes');}
// Get file date for hosts and services
$intTimeInfo = 0;
if ($this->strTableName == "tbl_host") {
$intReturn = $this->myConfigClass->lastModifiedDir($this->strTableName,$arrData[$i]['host_name'],$arrData[$i]['id'],$arrTimeData,$intTimeInfo);
if ($intReturn == 1) $this->strErrorMessage = $this->myConfigClass->strErrorMessage;
}
if ($this->strTableName == "tbl_service") {
$intReturn = $this->myConfigClass->lastModifiedDir($this->strTableName,$arrData[$i]['config_name'],$arrData[$i]['id'],$arrTimeData,$intTimeInfo);
if ($intReturn == 1) $this->strErrorMessage = $this->myConfigClass->strErrorMessage;
}
// Set datafields
foreach($this->arrDescription AS $elem) {
$objTemplate->setVariable($elem['name'],$elem['string']);
}
if ($arrData[$i][$strField1] == '') $arrData[$i][$strField1] = "NOT DEFINED - ".$arrData[$i]['id'];
$objTemplate->setVariable("DATA_FIELD_1",htmlentities($arrData[$i][$strField1],ENT_COMPAT,'UTF-8'));
$objTemplate->setVariable("DATA_FIELD_1S",addslashes(htmlentities($arrData[$i][$strField1],ENT_COMPAT,'UTF-8')));
if ($strField2 == 'process_field') {
$arrData[$i]['process_field'] = $this->processField2($arrData[$i],$this->strTableName);
} else {
$objTemplate->setVariable("DATA_FIELD_2S",addslashes(htmlentities($arrData[$i][$strField2],ENT_COMPAT,'UTF-8')));
}
if ($intLimit2 != 0) {
if (strlen($arrData[$i][$strField2]) > $intLimit2) {$strAdd = " ...";} else {$strAdd = "";}
$objTemplate->setVariable("DATA_FIELD_2",htmlentities(substr($arrData[$i][$strField2],0,$intLimit2),ENT_COMPAT,'UTF-8').$strAdd);
} else {
$objTemplate->setVariable("DATA_FIELD_2",htmlentities($arrData[$i][$strField2],ENT_COMPAT,'UTF-8'));
}
$objTemplate->setVariable("DATA_REGISTERED",$strRegister);
if (substr_count($this->strTableName,'template') != 0) $objTemplate->setVariable("DATA_REGISTERED","-");
$objTemplate->setVariable("DATA_ACTIVE",$strActive);
$objTemplate->setVariable("DATA_FILE","<span class=\"redmessage\">".translate('out-of-date')."</span>");
if ($intTimeInfo == 4) $objTemplate->setVariable("DATA_FILE",translate('no target'));
if ($intTimeInfo == 3) $objTemplate->setVariable("DATA_FILE","<span class=\"greenmessage\">".translate('missed')."</span>");
if ($intTimeInfo == 2) $objTemplate->setVariable("DATA_FILE","<span class=\"redmessage\">".translate('missed')."</span>");
if ($intTimeInfo == 1) $objTemplate->setVariable("DATA_FILE","<span class=\"redmessage\">".translate('out-of-date')."</span>");
if ($intTimeInfo == 0) $objTemplate->setVariable("DATA_FILE",translate('up-to-date'));
$objTemplate->setVariable("LINE_ID",$arrData[$i]['id']);
$objTemplate->setVariable("CELLCLASS_L",$strClassL);
$objTemplate->setVariable("CELLCLASS_M",$strClassM);
$objTemplate->setVariable("IMAGE_PATH",$this->arrSettings['path']['base_url']."images/");
$objTemplate->setVariable("PICTURE_CLASS","elementShow");
$objTemplate->setVariable("DOMAIN_SPECIAL","");
$objTemplate->setVariable("DISABLED","");
// Disable common domain objects
if (isset($arrData[$i]['config_id'])) {
if ($arrData[$i]['config_id'] != $this->intDomainId) {
$objTemplate->setVariable("PICTURE_CLASS","elementHide");
$objTemplate->setVariable("DOMAIN_SPECIAL"," [common]");
$objTemplate->setVariable("DISABLED","disabled");
} else {
// Inactive items should not be written/downloaded
if ($arrData[$i]['active'] == 0) $objTemplate->setVariable("ACTIVE_CONTROL","elementHide");
}
}
// Check access rights for list objects
if (isset($arrData[$i]['access_group'])) {
if ($this->myVisClass->checkAccGroup($arrData[$i]['access_group'],'write') != 0) $objTemplate->setVariable("LINE_CONTROL","elementHide");
} else {
if ($this->intGlobalWriteAccess != 0) $objTemplate->setVariable("LINE_CONTROL","elementHide");
}
// Check global access rights for list objects
if ($this->intGlobalWriteAccess != 0) $objTemplate->setVariable("LINE_CONTROL","elementHide");
$objTemplate->parse($strTplRow);
}
} else {
$objTemplate->setVariable("IMAGE_PATH",$this->arrSettings['path']['base_url']."images/");
$objTemplate->parse($strTplRow);
}
$objTemplate->setVariable("BUTTON_CLASS","elementShow");
if ($this->intDomainId == 0) $objTemplate->setVariable("BUTTON_CLASS","elementHide");
// Check access rights for adding new objects
if ($this->intGlobalWriteAccess != 0) $objTemplate->setVariable("ADD_CONTROL","disabled=\"disabled\"");
// Show page numbers
$objTemplate->setVariable("PAGES",$this->myVisClass->buildPageLinks(filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING),$intLineCount,$this->intLimit,$this->intSortBy,$this->strSortDir));
$objTemplate->parse($strTplPart);
$objTemplate->show($strTplPart);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Display information messages
///////////////////////////////////////////////////////////////////////////////////////////
//
// Parameter: $objTemplate Form template object
// $strErrorMessage String including error messages
// $strInfoMessage String including information messages
// $strConsistMessage String including consistency messages
// $arrTimeData Array including time data
// $strTimeInfoString String including time information message
// $intNoTime Status value for showing time information (0=show time)
//
// Return values: none
//
///////////////////////////////////////////////////////////////////////////////////////////
function showMessages($objTemplate,$strErrorMessage,$strInfoMessage,$strConsistMessage,$arrTimeData,$strTimeInfoString,$intNoTime=0) {
// Display info messages
if ($strInfoMessage != "") {
$objTemplate->setVariable("INFOMESSAGE",$strInfoMessage);
$objTemplate->parse('infomessage');
}
// Display error messages
if ($strErrorMessage != "") {
$objTemplate->setVariable("ERRORMESSAGE",$strErrorMessage);
$objTemplate->parse('errormessage');
}
// Display time informations
if (($this->intDomainId != 0) && ($intNoTime == 0)) {
foreach($arrTimeData AS $key => $elem) {
if ($key == 'table') {
$objTemplate->setVariable("LAST_MODIFIED_TABLE",translate('Last database update:')." <b>".$elem."</b>");
$objTemplate->parse('table_time');
} else {
$objTemplate->setVariable("LAST_MODIFIED_FILE",translate('Last file change of the configuration target ')." <i>".$key."</i>: <b>".$elem."</b>");
$objTemplate->parse('file_time');
}
}
if ($strTimeInfoString != "") {
$objTemplate->setVariable("MODIFICATION_STATUS",$strTimeInfoString);
$objTemplate->parse('modification_status');
}
}
// Display consistency messages
if ($strConsistMessage != "") {
$objTemplate->setVariable("CONSIST_USAGE",$strConsistMessage);
$objTemplate->parse('consistency');
}
$objTemplate->parse("msgfooter");
$objTemplate->show("msgfooter");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Display page footer
///////////////////////////////////////////////////////////////////////////////////////////
//
// Parameter: $objTemplate Form template object
// $setFileVersion NagiosQL version
//
// Return values: none
//
///////////////////////////////////////////////////////////////////////////////////////////
function showFooter($objTemplate,$setFileVersion) {
$objTemplate->setVariable("VERSION_INFO","<a href='http://www.nagiosql.org' target='_blank'>NagiosQL</a> $setFileVersion");
$objTemplate->parse("footer");
$objTemplate->show("footer");
}
///////////////////////////////////////////////////////////////////////////////////////////
// --- HELP functions ---
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Process list view field 2
///////////////////////////////////////////////////////////////////////////////////////////
//
// Parameter: $arrData Data array
// $strTableName Table name
//
// Return values: String includung field 2 data
//
///////////////////////////////////////////////////////////////////////////////////////////
function processField2($arrData,$strTableName) {
$strField = "";
// Hostdependency table
if ($strTableName == "tbl_hostdependency") {
if ($arrData['dependent_host_name'] != 0) {
$strSQLHost = "SELECT `host_name`, `exclude` FROM `tbl_host` LEFT JOIN `tbl_lnkHostdependencyToHost_DH` ON `id`=`idSlave`
WHERE `idMaster`=".$arrData['id']." ORDER BY `host_name`";
$booReturn = $this->myDBClass->getDataArray($strSQLHost,$arrDataHosts,$intDCHost);
if ($intDCHost != 0) {
foreach($arrDataHosts AS $elem) {
if ($elem['exclude'] == 1) {
$strField .= "H:!".$elem['host_name'].",";
} else {
$strField .= "H:".$elem['host_name'].",";
}
}
}
}
if ($arrData['dependent_hostgroup_name'] != 0) {
$strSQLHost = "SELECT `hostgroup_name`, `exclude` FROM `tbl_hostgroup` LEFT JOIN `tbl_lnkHostdependencyToHostgroup_DH` ON `id`=`idSlave`
WHERE `idMaster`=".$arrData['id']." ORDER BY `hostgroup_name`";
$booReturn = $this->myDBClass->getDataArray($strSQLHost,$arrDataHostgroups,$intDCHostgroup);
if ($intDCHostgroup != 0) {
foreach($arrDataHostgroups AS $elem) {
if ($elem['exclude'] == 1) {
$strField .= "HG:!".$elem['hostgroup_name'].",";
} else {
$strField .= "HG:".$elem['hostgroup_name'].",";
}
}
}
}
}
// Hostescalation table
if ($strTableName == "tbl_hostescalation") {
if ($arrData['host_name'] != 0) {
$strSQLHost = "SELECT `host_name` FROM `tbl_host` LEFT JOIN `tbl_lnkHostescalationToHost` ON `id`=`idSlave`
WHERE `idMaster`=".$arrData['id']." ORDER BY `host_name`";
$booReturn = $this->myDBClass->getDataArray($strSQLHost,$arrDataHosts,$intDCHost);
if ($intDCHost != 0) {
foreach($arrDataHosts AS $elem) {
$strField .= "H:".$elem['host_name'].",";
}
}
}
if ($arrData['hostgroup_name'] != 0) {
$strSQLHost = "SELECT `hostgroup_name` FROM `tbl_hostgroup` LEFT JOIN `tbl_lnkHostescalationToHostgroup` ON `id`=`idSlave`
WHERE `idMaster`=".$arrData['id']." ORDER BY `hostgroup_name`";
$booReturn = $this->myDBClass->getDataArray($strSQLHost,$arrDataHostgroups,$intDCHostgroup);
if ($intDCHostgroup != 0) {
foreach($arrDataHostgroups AS $elem) {
$strField .= "HG:".$elem['hostgroup_name'].",";
}
}
}
}
// Servicedependency table
if ($strTableName == "tbl_servicedependency") {
if ($arrData['dependent_service_description'] == 2) {
$strField .= "*";
} else if ($arrData['dependent_service_description'] != 0) {
$strSQLService = "SELECT `strSlave` FROM `tbl_lnkServicedependencyToService_DS` WHERE `idMaster`=".$arrData['id']." ORDER BY `strSlave`";
$booReturn = $this->myDBClass->getDataArray($strSQLService,$arrDataService,$intDCService);
if ($intDCService != 0) {
foreach($arrDataService AS $elem) {
$strField .= $elem['strSlave'].",";
}
}
}
if ($strField == "") {
$strSQLService = "SELECT `servicegroup_name` FROM `tbl_servicegroup`
LEFT JOIN `tbl_lnkServicedependencyToServicegroup_DS` ON `idSlave`=`id`
WHERE `idMaster`=".$arrData['id']." ORDER BY `servicegroup_name`";
$booReturn = $this->myDBClass->getDataArray($strSQLService,$arrDataService,$intDCService);
if ($intDCService != 0) {
foreach($arrDataService AS $elem) {
$strField .= $elem['servicegroup_name'].",";
}
}
}
}
// Serviceescalation table
if ($strTableName == "tbl_serviceescalation") {
if ($arrData['service_description'] == 2) {
$strField .= "*";
} else if ($arrData['service_description'] != 0) {
$strSQLService = "SELECT `strSlave` FROM `tbl_lnkServiceescalationToService` WHERE `idMaster`=".$arrData['id'];
$booReturn = $this->myDBClass->getDataArray($strSQLService,$arrDataServices,$intDCServices);
if ($intDCServices != 0) {
foreach($arrDataServices AS $elem) {
$strField .= $elem['strSlave'].",";
}
}
}
if ($strField == "") {
$strSQLService = "SELECT `servicegroup_name` FROM `tbl_servicegroup`
LEFT JOIN `tbl_lnkServiceescalationToServicegroup` ON `idSlave`=`id`
WHERE `idMaster`=".$arrData['id']." ORDER BY `servicegroup_name`";
$booReturn = $this->myDBClass->getDataArray($strSQLService,$arrDataService,$intDCService);
if ($intDCService != 0) {
foreach($arrDataService AS $elem) {
$strField .= $elem['servicegroup_name'].",";
}
}
}
}
// Some string manipulations - remove comma on line end
if (substr($strField,-1) == ',') $strField = substr($strField,0,-1);
return($strField);
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,440 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////////
//
// Common utilities
//
///////////////////////////////////////////////////////////////////////////////
//
// (c) 2005-2017 by Martin Willisegger
//
// Project : Common scripts
// Component : MySQLi data processing class
// Date : $LastChangedDate: 2017-06-22 13:39:15 +0200 (Thu, 22 Jun 2017) $
// Author : $LastChangedBy: martin $
// Version : 3.3.0
// Revision : $LastChangedRevision: 7 $
// SVN-ID : $Id: mysqli_class.php 7 2017-06-22 11:39:15Z martin $
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Class: Common database functions for MySQL (mysqli database module)
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Includes any functions to communicate with an MySQL database server
//
// Name: mysqlidb
//
// Class variables: $arrParams Array including the server settings
// ---------------- $strErrorMessage Database error string
// $error Boolean - Error true/false
// $strDBId Database connection id
// $intLastId ID of last dataset
// $intAffectedRows Counter variable of all affected data dows
// $booSSLuse Use SSL connection
// (INSERT/DELETE/UPDATE)
//
// Parameters: $arrParams['server'] -> DB server name
// ----------- $arrParams['port'] -> DB server port
// $arrParams['user'] -> DB server username
// $arrParams['password'] -> DB server password
// $arrParams['database'] -> DB server database name
//
///////////////////////////////////////////////////////////////////////////////////////////////
class mysqlidb {
// Define class variables
var $error = false; // Will be filled in functions
var $strDBId = ""; // Will be filled in functions
var $intLastId = 0; // Will be filled in functions
var $intAffectedRows = 0; // Will be filled in functions
var $strErrorMessage = ""; // Will be filled in functions
var $booSSLuse = false; // Defines if SSL is used or not
var $arrParams = ""; // Must be filled in while initialization
var $arrSQLdef = ""; // Must be filled in while initialization
var $strSQLQuote1 = "`"; // Quote char for table or row names
var $strSQLQuote2 = "'"; // Quote char for table or row names
///////////////////////////////////////////////////////////////////////////////////////////
// Class constructor
///////////////////////////////////////////////////////////////////////////////////////////
//
// Activities during initialisation
//
///////////////////////////////////////////////////////////////////////////////////////////
function __construct() {
$this->arrParams['server'] = "";
$this->arrParams['port'] = 0;
$this->arrParams['username'] = "";
$this->arrParams['password'] = "";
$this->arrParams['database'] = "";
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Connect to database
///////////////////////////////////////////////////////////////////////////////////////////
//
// Opens a connection to the database server and select a database
//
//
// Return value: true successful
// false error
// Status message is stored in class variable $this->strErrorMessage
//
///////////////////////////////////////////////////////////////////////////////////////////
function getdatabase() {
$this->dbconnect();
if ($this->error == true) {
return false;
}
$this->dbselect();
if ($this->error == true) {
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Get a single dataset field value
///////////////////////////////////////////////////////////////////////////////////////////
//
// Sends an SQL statement to the server and returns the result of the first data field
//
// Parameters: $strSQL SQL Statement
//
// Return value: <data> = successful
// <empty> = error
// Status message is stored in class variable $this->strErrorMessage
//
///////////////////////////////////////////////////////////////////////////////////////////
function getFieldData($strSQL) {
// Reset error variables
$this->strErrorMessage = "";
$this->error = false;
// Send the SQL statement to the server
$resQuery = mysqli_query($this->strDBId,$strSQL);
// Error processing
if ($resQuery && (mysqli_num_rows($resQuery) != 0) && (mysqli_error($this->strDBId) == "")) {
// Return the field value from position 0/0
$arrDataset = mysqli_fetch_array($resQuery,MYSQLI_NUM);
return $arrDataset[0];
} else if (mysqli_error($this->strDBId) != "") {
$this->strErrorMessage .= mysqli_error($this->strDBId)."::";
$this->error = true;
return("");
}
return("");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Get a single dataset
///////////////////////////////////////////////////////////////////////////////////////////
//
// Sends an SQL statement to the server and returns the result of the first data set
//
// Parameters: $strSQL SQL Statement
// $arrDataset Return value including the data set
//
// Return value: true = successful
// false = error
// Status message is stored in class variable $this->strErrorMessage
//
///////////////////////////////////////////////////////////////////////////////////////////
function getSingleDataset($strSQL,&$arrDataset) {
$arrDataset = "";
// Reset error variables
$this->strErrorMessage = "";
$this->error = false;
// Send the SQL statement to the server
$resQuery = mysqli_query($this->strDBId,$strSQL);
// Error processing
if ($resQuery && (mysqli_num_rows($resQuery) != 0) && (mysqli_error($this->strDBId) == "")) {
// Put the values into the array
$arrDataset = mysqli_fetch_array($resQuery,MYSQLI_ASSOC);
return true;
} else if (mysqli_error($this->strDBId) != "") {
$this->strErrorMessage .= mysqli_error($this->strDBId)."::";
$this->error = true;
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Get a full data part
///////////////////////////////////////////////////////////////////////////////////////////
//
// Sends an SQL statement to the server and returns the result inside a data array
//
// Parameters: $strSQL SQL Statement
// $arrDataset Return value including the data records
// $intDataCount Return value including the number of the records
//
// Return value: true = successful
// false = error
// Status message is stored in class variable $this->strErrorMessage
//
///////////////////////////////////////////////////////////////////////////////////////////
function getDataArray($strSQL,&$arrDataset,&$intDataCount) {
$arrDataset = "";
$intDataCount = 0;
// Reset error variables
$this->strErrorMessage = "";
$this->error = false;
// Send the SQL statement to the server
$resQuery = mysqli_query($this->strDBId,$strSQL);
// Error processing
if ($resQuery && (mysqli_num_rows($resQuery) != 0) && (mysqli_error($this->strDBId) == "")) {
$intDataCount = mysqli_num_rows($resQuery);
$i = 0;
// Put the values into the array
while ($arrDataTemp = mysqli_fetch_array($resQuery,MYSQLI_ASSOC)) {
foreach ($arrDataTemp AS $key => $value) {
$arrDataset[$i][$key] = $value;
}
$i++;
}
return true;
} else if (mysqli_error($this->strDBId) != "") {
$this->strErrorMessage .= mysqli_error($this->strDBId)."::";
$this->error = true;
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Insert/update/delete data
///////////////////////////////////////////////////////////////////////////////////////////
//
// Insert/update or delete data
//
// Parameters: $strSQL SQL Statement
// $this->intLastId Dataset insert ID
// $this->intAffectedRows The number of the affected records
//
// Return value: true = successful
// false = error
// Status message is stored in class variable $this->strErrorMessage
//
///////////////////////////////////////////////////////////////////////////////////////////
function insertData($strSQL) {
// Reset error variables
$this->strErrorMessage = "";
$this->error = false;
// Send the SQL statement to the server
$resQuery = mysqli_query($this->strDBId,$strSQL);
// Error processing
if (mysqli_error($this->strDBId) == "") {
$this->intLastId = mysqli_insert_id($this->strDBId);
$this->intAffectedRows = mysqli_affected_rows($this->strDBId);
return true;
} else {
$this->strErrorMessage .= mysqli_error($this->strDBId)."::";
$this->error = true;
return false;
}
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Counts data rows
///////////////////////////////////////////////////////////////////////////////////////////
//
// Counts the number of records
//
// Parameters: $strSQL SQL Statement
//
// Return value: <number> = successful
// 0 = no datasets or error
// Status message is stored in class variable $this->strErrorMessage
//
///////////////////////////////////////////////////////////////////////////////////////////
function countRows($strSQL) {
// Reset error variables
$this->strErrorMessage = "";
$this->error = false;
// Send the SQL statement to the server
$resQuery = mysqli_query($this->strDBId,$strSQL);
// Error processing
if ($resQuery && (mysqli_error($this->strDBId) == "")) {
return mysqli_num_rows($resQuery);
} else {
$this->strErrorMessage .= mysqli_error($this->strDBId);
$this->error = true;
return 0;
}
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Use mysqli_real_escape_string
///////////////////////////////////////////////////////////////////////////////////////////
//
// Returns a safe insert string for database manipulations
//
// Value: $strInput Input String
//
// Return value: $strOutput Output String
//
///////////////////////////////////////////////////////////////////////////////////////////
function real_escape($strInput) {
return mysqli_real_escape_string($this->strDBId,$strInput);
}
///////////////////////////////////////////////////////////////////////////////////////////
//
// Assistant functions
//
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Initialize a mysql database connection
///////////////////////////////////////////////////////////////////////////////////////////
//
// Return value: true
//
///////////////////////////////////////////////////////////////////////////////////////////
function dbinit() {
$this->strDBId = mysqli_init();
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Connect to database server
///////////////////////////////////////////////////////////////////////////////////////////
//
// Parameters: $dbserver Server name
// $dbuser Database user
// $dbpasswd Database password
// $dbname Database name
// $dbport TCP port
//
// Return value: true successful
// false error
// Status message is stored in class variable $this->strErrorMessage
//
///////////////////////////////////////////////////////////////////////////////////////////
function dbconnect($dbserver=NULL,$dbport=NULL,$dbuser=NULL,$dbpasswd=NULL) {
// Reset error variables
$this->strErrorMessage = "";
$this->error = false;
// Get parameters
if ($dbserver == NULL) $dbserver = $this->arrParams['server'];
if ($dbport == NULL) $dbport = $this->arrParams['port'];
if ($dbuser == NULL) $dbuser = $this->arrParams['username'];
if ($dbpasswd == NULL) $dbpasswd = $this->arrParams['password'];
// Not all parameters available
if (($dbserver == "") || ($dbuser == "") || ($dbpasswd == "")) {
$this->strErrorMessage .= gettext("Missing server connection parameter!")."::";
$this->error = true;
return false;
}
$this->dbinit();
if ($this->booSSLuse == true) {
// TO BE DEFINED
}
$intErrorReporting = error_reporting();
error_reporting(0);
if ($dbport == 0) {
$booReturn = mysqli_real_connect($this->strDBId,$dbserver,$dbuser,$dbpasswd);
} else {
$booReturn = mysqli_real_connect($this->strDBId,$dbserver,$dbuser,$dbpasswd,NULL,$dbport);
}
$arrError = error_get_last();
error_reporting($intErrorReporting);
// Connection fails
if($booReturn == false) {
$this->strErrorMessage = "[".$dbserver."] ".gettext("Connection to the database server has failed by reason:")." ::";
if (mysqli_connect_error($this->strDBId) != "") $this->strErrorMessage .= mysqli_connect_error($this->strDBId)."::";
$this->error = true;
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: select database
///////////////////////////////////////////////////////////////////////////////////////////
//
// Parameters: $database Database name
//
// Return value: true = successful
// false = error
// Status message is stored in class variable $this->strErrorMessage
//
///////////////////////////////////////////////////////////////////////////////////////////
function dbselect($database=NULL) {
// Reset error variables
$this->strErrorMessage = "";
$this->error = false;
// Get parameters
if ($database == NULL) $database = $this->arrParams['database'];
// Not all parameters available
if ($database == "") {
$this->strErrorMessage .= gettext("Missing database connection parameter!")."::";
$this->error = true;
return false;
}
$bolConnect = mysqli_select_db($this->strDBId,$database);
// Session cannot be etablished
if(!$bolConnect) {
$this->strErrorMessage .= "[".$database."] ".gettext("Connection to the database has failed by reason:")." ::";
$this->strErrorMessage .= mysqli_error($this->strDBId)."::";
$this->error = true;
return false;
}
$resQuery = mysqli_query($this->strDBId,"set names 'utf8'");
if (mysqli_error($this->strDBId) != "") {
$this->strErrorMessage .= mysqli_error($this->strDBId)."::";
$this->error = true;
return false;
}
$resQuery = mysqli_query($this->strDBId,"set session sql_mode = 'NO_ENGINE_SUBSTITUTION'");
if (mysqli_error($this->strDBId) != "") {
$this->strErrorMessage .= mysqli_error($this->strDBId)."::";
$this->error = true;
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Set SSL parameters
///////////////////////////////////////////////////////////////////////////////////////////
//
// Parameters: $sslkey SSL key
// $sslcert SSL certificate
// $sslca SSL CA file (optional)
// $sslpath SSL certificate path (optional)
// $sslcypher SSL cypher (optional)
//
// Return value: true successful
// The mysqli_ssl_set function always returns TRUE!
//
///////////////////////////////////////////////////////////////////////////////////////////
function dbsetssl($sslkey,$sslcert,$sslca=NULL,$sslpath=NULL,$sslcypher=NULL) {
// Reset error variables
$this->strErrorMessage = "";
$this->error = false;
// Values are missing
if (($sslkey == "") || ($sslcert == "")) {
$this->strErrorMessage = gettext("Missing MySQL SSL parameter!")."::";
$this->error = true;
return false;
}
mysqli_ssl_set($this->strDBId,$sslkey,$sslcert,$sslca,$sslpath,$sslcypher);
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Function: Close database server connectuon
///////////////////////////////////////////////////////////////////////////////////////////
//
// Value: none
//
// Return value: true if successful, false if failed
//
///////////////////////////////////////////////////////////////////////////////////////////
function dbdisconnect() {
mysqli_close($this->strDBId);
return true;
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,517 +2,539 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// NagiosQL // NagiosQL
//
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Preprocessing script for content pages // Component : Preprocessing script for content pages
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:53:38 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 5 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Define common variables // Define common variables
// ======================= // =======================
$intLineCount = 0; // Database line count $intLineCount = 0; // Database line count
$intWriteAccessId = 0; // Write access to data id ($chkDataId) $intWriteAccessId = 0; // Write access to data id ($chkDataId)
$intReadAccessId = 0; // Read access to data id ($chkListId) $intReadAccessId = 0; // Read access to data id ($chkListId)
$intDataWarning = 0; // Missing data indicator $intDataWarning = 0; // Missing data indicator
$intNoTime = 0; // Show modified time list (0=show) $intNoTime = 0; // Show modified time list (0=show)
$strSearchWhere = ""; // SQL WHERE addon for searching $strSearchWhere = ''; // SQL WHERE addon for searching
$strSearchWhere2 = ""; // SQL WHERE addon for configuration selection list $strSearchWhere2 = ''; // SQL WHERE addon for configuration selection list
$chkTfValue3 = '';
$chkTfValue5 = '';
// //
// Define missing variables used in this prepend file // Define missing variables used in this prepend file
// ================================================== // ==================================================
if (!isset($preTableName)) $preTableName = ""; // Predefined variable table name if (!isset($preTableName)) {
if (!isset($preSearchSession)) $preSearchSession = ""; // Predefined variable search session $preTableName = '';
} // Predefined variable table name
if (!isset($preSearchSession)) {
$preSearchSession = '';
} // Predefined variable search session
// //
// Store some variables to content class // Store some variables to content class
// ===================================== // =====================================
$myContentClass->intLimit = $chkLimit; $myContentClass->intLimit = $chkLimit;
$myContentClass->intVersion = $intVersion; /** @var int $intVersion - defined in prepend_adm.php */
$myContentClass->strBrowser = $preBrowser; $myContentClass->intVersion = $intVersion;
$myContentClass->intGroupAdm = $chkGroupAdm; $myContentClass->strBrowser = $preBrowser;
$myContentClass->strTableName = $preTableName; $myContentClass->intGroupAdm = $chkGroupAdm;
$myContentClass->strSearchSession = $preSearchSession; $myContentClass->strTableName = $preTableName;
$myContentClass->intSortBy = $hidSortBy; $myContentClass->strSearchSession = $preSearchSession;
$myContentClass->strSortDir = $hidSortDir; $myContentClass->intSortBy = $hidSortBy;
$myContentClass->strSortDir = $hidSortDir;
// //
// Process get parameters // Process get parameters
// ====================== // ======================
$chkFromLine = isset($_GET['from_line']) ? filter_var($_GET['from_line'], FILTER_SANITIZE_NUMBER_INT) : 0; $chkFromLine = filter_input(INPUT_GET, 'from_line', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
// //
// Process post parameters // Process post parameters
// ======================= // =======================
$chkTfSearch = isset($_POST['txtSearch']) ? $_POST['txtSearch'] : ""; // Search field $chkTfSearchRaw = filter_input(INPUT_POST, 'txtSearch', FILTER_SANITIZE_STRING);
$chkSelAccGr = isset($_POST['selAccGr']) ? $_POST['selAccGr']+0 : 0; // Access group $chkSelAccGr = filter_input(INPUT_POST, 'selAccGr', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkSelCnfName = isset($_POST['selCnfName']) ? $_POST['selCnfName'] : ""; // Config name selection field $chkSelCnfName = filter_input(INPUT_POST, 'selCnfName', FILTER_SANITIZE_STRING);
// //
$chkTfValue1 = isset($_POST['tfValue1']) ? $_POST['tfValue1'] : ""; // Common text field value // Common text field value
$chkTfValue2 = isset($_POST['tfValue2']) ? $_POST['tfValue2'] : ""; // Common text field value for ($i = 1; $i <= 22; $i++) {
$chkTfValue3 = isset($_POST['tfValue3']) ? $_POST['tfValue3'] : ""; // Common text field value $tmpVar = 'chkTfValue'.$i;
$chkTfValue4 = isset($_POST['tfValue4']) ? $_POST['tfValue4'] : ""; // Common text field value $$tmpVar = filter_input(INPUT_POST, 'tfValue'.$i, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
$chkTfValue5 = isset($_POST['tfValue5']) ? $_POST['tfValue5'] : ""; // Common text field value if (get_magic_quotes_gpc() == 0) {
$chkTfValue6 = isset($_POST['tfValue6']) ? $_POST['tfValue6'] : ""; // Common text field value $$tmpVar = addslashes($$tmpVar);
$chkTfValue7 = isset($_POST['tfValue7']) ? $_POST['tfValue7'] : ""; // Common text field value }
$chkTfValue8 = isset($_POST['tfValue8']) ? $_POST['tfValue8'] : ""; // Common text field value if (isset($$tmpVar)) {
$chkTfValue9 = isset($_POST['tfValue9']) ? $_POST['tfValue9'] : ""; // Common text field value $$tmpVar = $myVisClass->tfSecure($$tmpVar);
$chkTfValue10 = isset($_POST['tfValue10']) ? $_POST['tfValue10'] : ""; // Common text field value }
$chkTfValue11 = isset($_POST['tfValue11']) ? $_POST['tfValue11'] : ""; // Common text field value }
$chkTfValue12 = isset($_POST['tfValue12']) ? $_POST['tfValue12'] : ""; // Common text field value // Common argument text field value
$chkTfValue13 = isset($_POST['tfValue13']) ? $_POST['tfValue13'] : ""; // Common text field value for ($i = 1; $i <= 8; $i++) {
$chkTfValue14 = isset($_POST['tfValue14']) ? $_POST['tfValue14'] : ""; // Common text field value $tmpVar = 'chkTfArg'.$i;
$chkTfValue15 = isset($_POST['tfValue15']) ? $_POST['tfValue15'] : ""; // Common text field value $$tmpVar = filter_input(INPUT_POST, 'tfArg'.$i, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
$chkTfValue16 = isset($_POST['tfValue16']) ? $_POST['tfValue16'] : ""; // Common text field value if (get_magic_quotes_gpc() == 0) {
$chkTfValue17 = isset($_POST['tfValue17']) ? $_POST['tfValue17'] : ""; // Common text field value $$tmpVar = addslashes($$tmpVar);
$chkTfValue18 = isset($_POST['tfValue18']) ? $_POST['tfValue18'] : ""; // Common text field value }
$chkTfValue19 = isset($_POST['tfValue19']) ? $_POST['tfValue19'] : ""; // Common text field value if (isset($$tmpVar)) {
$chkTfValue20 = isset($_POST['tfValue20']) ? $_POST['tfValue20'] : ""; // Common text field value $$tmpVar = $myVisClass->tfSecure($$tmpVar);
$chkTfArg1 = isset($_POST['tfArg1']) ? $_POST['tfArg1'] : ""; // Common argument text field value }
$chkTfArg2 = isset($_POST['tfArg2']) ? $_POST['tfArg2'] : ""; // Common argument text field value }
$chkTfArg3 = isset($_POST['tfArg3']) ? $_POST['tfArg3'] : ""; // Common argument text field value
$chkTfArg4 = isset($_POST['tfArg4']) ? $_POST['tfArg4'] : ""; // Common argument text field value // Common multi select field value
$chkTfArg5 = isset($_POST['tfArg5']) ? $_POST['tfArg5'] : ""; // Common argument text field value for ($i = 1; $i <= 8; $i++) {
$chkTfArg6 = isset($_POST['tfArg6']) ? $_POST['tfArg6'] : ""; // Common argument text field value $tmpVar = 'chkMselValue'.$i;
$chkTfArg7 = isset($_POST['tfArg7']) ? $_POST['tfArg7'] : ""; // Common argument text field value $tmpVar2 = 'intMselValue'.$i;
$chkTfArg8 = isset($_POST['tfArg8']) ? $_POST['tfArg8'] : ""; // Common argument text field value $$tmpVar = filter_input(INPUT_POST, 'mselValue'.$i, FILTER_SANITIZE_STRING, FILTER_FORCE_ARRAY);
$chkMselValue1 = isset($_POST['mselValue1']) ? $_POST['mselValue1'] : array(""); // Common multi select field value // Multiselect data processing
$chkMselValue2 = isset($_POST['mselValue2']) ? $_POST['mselValue2'] : array(""); // Common multi select field value if ((${$tmpVar}[0] == '') || (${$tmpVar}[0] == '0')) {
$chkMselValue3 = isset($_POST['mselValue3']) ? $_POST['mselValue3'] : array(""); // Common multi select field value $$tmpVar2 = 0;
$chkMselValue4 = isset($_POST['mselValue4']) ? $_POST['mselValue4'] : array(""); // Common multi select field value } elseif (${$tmpVar}[0] == '*') {
$chkMselValue5 = isset($_POST['mselValue5']) ? $_POST['mselValue5'] : array(""); // Common multi select field value $$tmpVar2 = 2;
$chkMselValue6 = isset($_POST['mselValue6']) ? $_POST['mselValue6'] : array(""); // Common multi select field value } else {
$chkMselValue7 = isset($_POST['mselValue7']) ? $_POST['mselValue7'] : array(""); // Common multi select field value $$tmpVar2 = 1;
$chkMselValue8 = isset($_POST['mselValue8']) ? $_POST['mselValue8'] : array(""); // Common multi select field value }
$chkChbValue1 = isset($_POST['chbValue1']) ? $_POST['chbValue1']+0 : 0; // Common checkbox field value }
$chkChbValue2 = isset($_POST['chbValue2']) ? $_POST['chbValue2']+0 : 0; // Common checkbox field value // Common select field value
$chkDatValue1 = isset($_POST['datValue1']) ? $_POST['datValue1'] : ""; // Common file selection field for ($i = 1; $i <= 5; $i++) {
$chkTaValue1 = isset($_POST['taValue1']) ? $_POST['taValue1'] : ""; // Common text area value $tmpVar = 'chkSelValue'.$i;
$chkTaFileText = isset($_POST['taFileText']) ? $_POST['taFileText'] : ""; // Common text area value for file import (not SQL) $$tmpVar = filter_input(INPUT_POST, 'selValue'.$i, FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkSelValue1 = isset($_POST['selValue1']) ? $_POST['selValue1']+0 : 0; // Common select field value }
$chkSelValue2 = isset($_POST['selValue2']) ? $_POST['selValue2']+0 : 0; // Common select field value //Common radio field value
$chkSelValue3 = isset($_POST['selValue3']) ? $_POST['selValue3']+0 : 0; // Common select field value for ($i = 1; $i <= 18; $i++) {
$chkSelValue4 = isset($_POST['selValue4']) ? $_POST['selValue4']+0 : 0; // Common select field value $tmpVar = 'chkRadValue'.$i;
$chkSelValue5 = isset($_POST['selValue5']) ? $_POST['selValue5']+0 : 0; // Common select field value $$tmpVar = filter_input(INPUT_POST, 'radValue'.$i, FILTER_VALIDATE_INT, array('options' => array('default' => 2)));
$chkRadValue1 = isset($_POST['radValue1']) ? $_POST['radValue1']+0 : 2; // Common radio field value }
$chkRadValue2 = isset($_POST['radValue2']) ? $_POST['radValue2']+0 : 2; // Common radio field value // Common checkbox group
$chkRadValue3 = isset($_POST['radValue3']) ? $_POST['radValue3']+0 : 2; // Common radio field value $arrChar = explode(';', 'a;b;c;d;e;f;g;h');
$chkRadValue4 = isset($_POST['radValue4']) ? $_POST['radValue4']+0 : 2; // Common radio field value for ($i = 1; $i <= 4; $i++) {
$chkRadValue5 = isset($_POST['radValue5']) ? $_POST['radValue5']+0 : 2; // Common radio field value foreach ($arrChar as $elem) {
$chkRadValue6 = isset($_POST['radValue6']) ? $_POST['radValue6']+0 : 2; // Common radio field value $tmpVar = 'chkChbGr'.$i.$elem;
$chkRadValue7 = isset($_POST['radValue7']) ? $_POST['radValue7']+0 : 2; // Common radio field value $$tmpVar = filter_input(INPUT_POST, 'chbGr'.$i.$elem, FILTER_SANITIZE_STRING);
$chkRadValue8 = isset($_POST['radValue8']) ? $_POST['radValue8']+0 : 2; // Common radio field value if ($$tmpVar != '') {
$chkRadValue9 = isset($_POST['radValue9']) ? $_POST['radValue9']+0 : 2; // Common radio field value $$tmpVar .= ',';
$chkRadValue10 = isset($_POST['radValue10']) ? $_POST['radValue10']+0 : 2; // Common radio field value }
$chkRadValue11 = isset($_POST['radValue11']) ? $_POST['radValue11']+0 : 2; // Common radio field value }
$chkRadValue12 = isset($_POST['radValue12']) ? $_POST['radValue12']+0 : 2; // Common radio field value }
$chkRadValue13 = isset($_POST['radValue13']) ? $_POST['radValue13']+0 : 2; // Common radio field value // Common button value
$chkRadValue14 = isset($_POST['radValue14']) ? $_POST['radValue14']+0 : 2; // Common radio field value for ($i = 1; $i <= 5; $i++) {
$chkRadValue15 = isset($_POST['radValue15']) ? $_POST['radValue15']+0 : 2; // Common radio field value $tmpVar = 'chkButValue'.$i;
$chkRadValue16 = isset($_POST['radValue16']) ? $_POST['radValue16']+0 : 2; // Common radio field value $$tmpVar = filter_input(INPUT_POST, 'butValue'.$i, FILTER_SANITIZE_STRING);
$chkRadValue17 = isset($_POST['radValue17']) ? $_POST['radValue17']+0 : 2; // Common radio field value }
$chkChbGr1a = isset($_POST['chbGr1a']) ? $_POST['chbGr1a']."," : ""; // Common checkbox group // Common text NULL field value
$chkChbGr1b = isset($_POST['chbGr1b']) ? $_POST['chbGr1b']."," : ""; // Common checkbox group for ($i = 1; $i <= 9; $i++) {
$chkChbGr1c = isset($_POST['chbGr1c']) ? $_POST['chbGr1c']."," : ""; // Common checkbox group $tmpVar = 'chkTfNullVal'.$i;
$chkChbGr1d = isset($_POST['chbGr1d']) ? $_POST['chbGr1d']."," : ""; // Common checkbox group $$tmpVar = filter_input(INPUT_POST, 'tfNullVal'.$i, FILTER_SANITIZE_STRING);
$chkChbGr1e = isset($_POST['chbGr1e']) ? $_POST['chbGr1e']."," : ""; // Common checkbox group if (isset($$tmpVar) && ($$tmpVar != '')) {
$chkChbGr1f = isset($_POST['chbGr1f']) ? $_POST['chbGr1f']."," : ""; // Common checkbox group $myVisClass->checkNull($$tmpVar);
$chkChbGr1g = isset($_POST['chbGr1g']) ? $_POST['chbGr1g']."," : ""; // Common checkbox group } else {
$chkChbGr1h = isset($_POST['chbGr1h']) ? $_POST['chbGr1h']."," : ""; // Common checkbox group $$tmpVar = 'NULL';
$chkChbGr2a = isset($_POST['chbGr2a']) ? $_POST['chbGr2a']."," : ""; // Common checkbox group }
$chkChbGr2b = isset($_POST['chbGr2b']) ? $_POST['chbGr2b']."," : ""; // Common checkbox group }
$chkChbGr2c = isset($_POST['chbGr2c']) ? $_POST['chbGr2c']."," : ""; // Common checkbox group // Common checkbox field value
$chkChbGr2d = isset($_POST['chbGr2d']) ? $_POST['chbGr2d']."," : ""; // Common checkbox group $chkChbValue1 = filter_input(INPUT_POST, 'chbValue1', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkChbGr2e = isset($_POST['chbGr2e']) ? $_POST['chbGr2e']."," : ""; // Common checkbox group $chkChbValue2 = filter_input(INPUT_POST, 'chbValue2', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$chkChbGr2f = isset($_POST['chbGr2f']) ? $_POST['chbGr2f']."," : ""; // Common checkbox group // Common file selection field
$chkChbGr2g = isset($_POST['chbGr2g']) ? $_POST['chbGr2g']."," : ""; // Common checkbox group $chkDatValue1 = filter_input(INPUT_POST, 'datValue1', FILTER_SANITIZE_STRING);
$chkChbGr2h = isset($_POST['chbGr2h']) ? $_POST['chbGr2h']."," : ""; // Common checkbox group // Common text area value
$chkChbGr3a = isset($_POST['chbGr3a']) ? $_POST['chbGr3a']."," : ""; // Common checkbox group $chkTaValue1Raw = filter_input(INPUT_POST, 'taValue1', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$chkChbGr3b = isset($_POST['chbGr3b']) ? $_POST['chbGr3b']."," : ""; // Common checkbox group // Common text area value for file import (not SQL)
$chkChbGr3c = isset($_POST['chbGr3c']) ? $_POST['chbGr3c']."," : ""; // Common checkbox group $chkTaFileTextRaw = filter_input(INPUT_POST, 'taFileText', FILTER_UNSAFE_RAW);
$chkChbGr3d = isset($_POST['chbGr3d']) ? $_POST['chbGr3d']."," : ""; // Common checkbox group
$chkChbGr4a = isset($_POST['chbGr4a']) ? $_POST['chbGr4a']."," : ""; // Common checkbox group
$chkChbGr4b = isset($_POST['chbGr4b']) ? $_POST['chbGr4b']."," : ""; // Common checkbox group
$chkChbGr4c = isset($_POST['chbGr4c']) ? $_POST['chbGr4c']."," : ""; // Common checkbox group
$chkChbGr4d = isset($_POST['chbGr4d']) ? $_POST['chbGr4d']."," : ""; // Common checkbox group
$chkButValue1 = isset($_POST['butValue1']) ? $_POST['butValue1'] : ""; // Common button value
$chkButValue2 = isset($_POST['butValue2']) ? $_POST['butValue2'] : ""; // Common button value
$chkButValue3 = isset($_POST['butValue3']) ? $_POST['butValue3'] : ""; // Common button value
$chkButValue4 = isset($_POST['butValue4']) ? $_POST['butValue4'] : ""; // Common button value
$chkButValue5 = isset($_POST['butValue5']) ? $_POST['butValue5'] : ""; // Common button value
$chkTfNullVal1 = (isset($_POST['tfNullVal1']) && ($_POST['tfNullVal1'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal1'])+0 : "NULL"; // Common text NULL field value
$chkTfNullVal2 = (isset($_POST['tfNullVal2']) && ($_POST['tfNullVal2'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal2'])+0 : "NULL"; // Common text NULL field value
$chkTfNullVal3 = (isset($_POST['tfNullVal3']) && ($_POST['tfNullVal3'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal3'])+0 : "NULL"; // Common text NULL field value
$chkTfNullVal4 = (isset($_POST['tfNullVal4']) && ($_POST['tfNullVal4'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal4'])+0 : "NULL"; // Common text NULL field value
$chkTfNullVal5 = (isset($_POST['tfNullVal5']) && ($_POST['tfNullVal5'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal5'])+0 : "NULL"; // Common text NULL field value
$chkTfNullVal6 = (isset($_POST['tfNullVal6']) && ($_POST['tfNullVal6'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal6'])+0 : "NULL"; // Common text NULL field value
$chkTfNullVal7 = (isset($_POST['tfNullVal7']) && ($_POST['tfNullVal7'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal7'])+0 : "NULL"; // Common text NULL field value
$chkTfNullVal8 = (isset($_POST['tfNullVal8']) && ($_POST['tfNullVal8'] != "")) ? $myVisClass->checkNull($_POST['tfNullVal8'])+0 : "NULL"; // Common text NULL field value
// //
// Quote special characters // Quote special characters
// ========================== // ==========================
if (get_magic_quotes_gpc() == 0) { if (get_magic_quotes_gpc() == 0) {
$chkTfSearch = addslashes($chkTfSearch); $chkTfSearchRaw = addslashes($chkTfSearchRaw);
$chkTfValue1 = addslashes($chkTfValue1); $chkTaValue1Raw = addslashes($chkTaValue1Raw);
$chkTfValue2 = addslashes($chkTfValue2); $chkTaFileTextRaw = addslashes($chkTaFileTextRaw);
$chkTfValue3 = addslashes($chkTfValue3);
$chkTfValue4 = addslashes($chkTfValue4);
$chkTfValue5 = addslashes($chkTfValue5);
$chkTfValue6 = addslashes($chkTfValue6);
$chkTfValue7 = addslashes($chkTfValue7);
$chkTfValue8 = addslashes($chkTfValue8);
$chkTfValue9 = addslashes($chkTfValue9);
$chkTfValue10 = addslashes($chkTfValue10);
$chkTfValue11 = addslashes($chkTfValue11);
$chkTfValue12 = addslashes($chkTfValue12);
$chkTfValue13 = addslashes($chkTfValue13);
$chkTfValue14 = addslashes($chkTfValue14);
$chkTfValue15 = addslashes($chkTfValue15);
$chkTfValue16 = addslashes($chkTfValue16);
$chkTfValue17 = addslashes($chkTfValue17);
$chkTfValue18 = addslashes($chkTfValue18);
$chkTfValue19 = addslashes($chkTfValue19);
$chkTfValue20 = addslashes($chkTfValue20);
$chkTaValue1 = addslashes($chkTaValue1);
$chkTfArg1 = addslashes($chkTfArg1);
$chkTfArg2 = addslashes($chkTfArg2);
$chkTfArg3 = addslashes($chkTfArg3);
$chkTfArg4 = addslashes($chkTfArg4);
$chkTfArg5 = addslashes($chkTfArg5);
$chkTfArg6 = addslashes($chkTfArg6);
$chkTfArg7 = addslashes($chkTfArg7);
$chkTfArg8 = addslashes($chkTfArg8);
$chkTaFileText = addslashes($chkTaFileText);
} }
// //
// Security function for text fields // Security function for text fields
// ================================= // =================================
$chkTfSearch = $myVisClass->tfSecure($chkTfSearch); $chkTfSearch = $myVisClass->tfSecure($chkTfSearchRaw);
$chkTfValue1 = $myVisClass->tfSecure($chkTfValue1); $chkTaValue1 = $myVisClass->tfSecure($chkTaValue1Raw);
$chkTfValue2 = $myVisClass->tfSecure($chkTfValue2); $chkTaFileText = stripslashes($chkTaFileTextRaw);
$chkTfValue3 = $myVisClass->tfSecure($chkTfValue3);
$chkTfValue4 = $myVisClass->tfSecure($chkTfValue4);
$chkTfValue5 = $myVisClass->tfSecure($chkTfValue5);
$chkTfValue6 = $myVisClass->tfSecure($chkTfValue6);
$chkTfValue7 = $myVisClass->tfSecure($chkTfValue7);
$chkTfValue8 = $myVisClass->tfSecure($chkTfValue8);
$chkTfValue9 = $myVisClass->tfSecure($chkTfValue9);
$chkTfValue10 = $myVisClass->tfSecure($chkTfValue10);
$chkTfValue11 = $myVisClass->tfSecure($chkTfValue11);
$chkTfValue12 = $myVisClass->tfSecure($chkTfValue12);
$chkTfValue13 = $myVisClass->tfSecure($chkTfValue13);
$chkTfValue14 = $myVisClass->tfSecure($chkTfValue14);
$chkTfValue15 = $myVisClass->tfSecure($chkTfValue15);
$chkTfValue16 = $myVisClass->tfSecure($chkTfValue16);
$chkTfValue17 = $myVisClass->tfSecure($chkTfValue17);
$chkTfValue18 = $myVisClass->tfSecure($chkTfValue18);
$chkTfValue19 = $myVisClass->tfSecure($chkTfValue19);
$chkTfValue20 = $myVisClass->tfSecure($chkTfValue20);
$chkTfArg1 = $myVisClass->tfSecure($chkTfArg1);
$chkTfArg2 = $myVisClass->tfSecure($chkTfArg2);
$chkTfArg3 = $myVisClass->tfSecure($chkTfArg3);
$chkTfArg4 = $myVisClass->tfSecure($chkTfArg4);
$chkTfArg5 = $myVisClass->tfSecure($chkTfArg5);
$chkTfArg6 = $myVisClass->tfSecure($chkTfArg6);
$chkTfArg7 = $myVisClass->tfSecure($chkTfArg7);
$chkTfArg8 = $myVisClass->tfSecure($chkTfArg8);
$chkTaValue1 = $myVisClass->tfSecure($chkTaValue1);
$chkTaFileText = stripslashes($chkTaFileText);
//
// Multiselect data processing
// ===========================
if (($chkMselValue1[0] == "") || ($chkMselValue1[0] == "0")) {$intMselValue1 = 0;} else {$intMselValue1 = 1;}
if ($chkMselValue1[0] == "*") $intMselValue1 = 2;
if (($chkMselValue2[0] == "") || ($chkMselValue2[0] == "0")) {$intMselValue2 = 0;} else {$intMselValue2 = 1;}
if ($chkMselValue2[0] == "*") $intMselValue2 = 2;
if (($chkMselValue3[0] == "") || ($chkMselValue3[0] == "0")) {$intMselValue3 = 0;} else {$intMselValue3 = 1;}
if ($chkMselValue3[0] == "*") $intMselValue3 = 2;
if (($chkMselValue4[0] == "") || ($chkMselValue4[0] == "0")) {$intMselValue4 = 0;} else {$intMselValue4 = 1;}
if ($chkMselValue4[0] == "*") $intMselValue4 = 2;
if (($chkMselValue5[0] == "") || ($chkMselValue5[0] == "0")) {$intMselValue5 = 0;} else {$intMselValue5 = 1;}
if ($chkMselValue5[0] == "*") $intMselValue5 = 2;
if (($chkMselValue6[0] == "") || ($chkMselValue6[0] == "0")) {$intMselValue6 = 0;} else {$intMselValue6 = 1;}
if ($chkMselValue6[0] == "*") $intMselValue6 = 2;
if (($chkMselValue7[0] == "") || ($chkMselValue7[0] == "0")) {$intMselValue7 = 0;} else {$intMselValue7 = 1;}
if ($chkMselValue7[0] == "*") $intMselValue7 = 2;
if (($chkMselValue8[0] == "") || ($chkMselValue8[0] == "0")) {$intMselValue8 = 0;} else {$intMselValue8 = 1;}
if ($chkMselValue8[0] == "*") $intMselValue8 = 2;
// //
// Search/sort/filter - session data // Search/sort/filter - session data
// ================================= // =================================
if (!isset($_SESSION['search']) || !isset($_SESSION['search'][$preSearchSession])) $_SESSION['search'][$preSearchSession] = ""; if (!isset($_SESSION['search']) || !isset($_SESSION['search'][$preSearchSession])) {
if (!isset($_SESSION['search']) || !isset($_SESSION['search']['config_selection'])) $_SESSION['search']['config_selection'] = ""; $_SESSION['search'][$preSearchSession] = '';
if (($chkModus == "checkform") || ($chkModus == "filter")) { }
$_SESSION['search'][$preSearchSession] = $chkTfSearch; if (!isset($_SESSION['search']) || !isset($_SESSION['search']['config_selection'])) {
$_SESSION['search']['config_selection'] = $chkSelCnfName; $_SESSION['search']['config_selection'] = '';
}
if (($chkModus == 'checkform') || ($chkModus == 'filter')) {
$_SESSION['search'][$preSearchSession] = $chkTfSearch;
$_SESSION['search']['config_selection'] = $chkSelCnfName;
$myContentClass->arrSession = $_SESSION;
} }
// //
// Process additional templates/variables // Process additional templates/variables
// ====================================== // ======================================
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) && (count($_SESSION['templatedefinition']) != 0)) { if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
$intTemplates = 1; (count($_SESSION['templatedefinition']) != 0)) {
$intTemplates = 1;
} else { } else {
$intTemplates = 0; $intTemplates = 0;
} }
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) && (count($_SESSION['variabledefinition']) != 0)) { if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
$intVariables = 1; (count($_SESSION['variabledefinition']) != 0)) {
$intVariables = 1;
} else { } else {
$intVariables = 0; $intVariables = 0;
} }
// //
// Common SQL parts // Common SQL parts
// ================ // ================
if ($hidActive == 1) $chkActive = 1; if ($hidActive == 1) {
if ($chkGroupAdm == 1) {$strGroupSQL = "`access_group`=$chkSelAccGr, ";} else {$strGroupSQL = "";} $chkActive = 1;
$preSQLCommon1 = "$strGroupSQL `active`='$chkActive', `register`='$chkRegister', `config_id`=$chkDomainId, `last_modified`=NOW()"; }
if ($chkGroupAdm == 1) {
$strGroupSQL = "`access_group`=$chkSelAccGr, ";
} else {
$strGroupSQL = '';
}
$preSQLCommon1 = "$strGroupSQL `active`='$chkActive', `register`='$chkRegister', `config_id`=$chkDomainId, "
. '`last_modified`=NOW()';
$preSQLCommon2 = "$strGroupSQL `active`='$chkActive', `register`='0', `config_id`=$chkDomainId, `last_modified`=NOW()"; $preSQLCommon2 = "$strGroupSQL `active`='$chkActive', `register`='0', `config_id`=$chkDomainId, `last_modified`=NOW()";
$intRet1=0;$intRet2=0;$intRet3=0;$intRet4=0;$intRet5=0;$intRet6=0;$intRet7=0;$intRet8=0; $intRet1 = 0;
$intRet2 = 0;
$intRet3 = 0;
$intRet4 = 0;
$intRet5 = 0;
$intRet6 = 0;
$intRet7 = 0;
$intRet8 = 0;
// //
// Check read and write access // Check read and write access
// =========================== // ===========================
if (isset($prePageKey)) { if (isset($prePageKey)) {
$intGlobalReadAccess = $myVisClass->checkAccGroup($prePageKey,'read'); // Global read access (0 = access granted) // Global read access (0 = access granted)
$intGlobalWriteAccess = $myVisClass->checkAccGroup($prePageKey,'write'); // Global write access (0 = access granted) $intGlobalReadAccess = $myVisClass->checkAccountGroup($prePageKey, 'read');
$myContentClass->intGlobalWriteAccess = $intGlobalWriteAccess; // Global write access (0 = access granted)
$intGlobalWriteAccess = $myVisClass->checkAccountGroup($prePageKey, 'write');
$myContentClass->intGlobalWriteAccess = $intGlobalWriteAccess;
} }
if (!isset($preNoAccessGrp) || ($preNoAccessGrp == 0)) { if (!isset($preNoAccessGrp) || ($preNoAccessGrp == 0)) {
if ($chkDataId != 0) { if ($chkDataId != 0) {
$strSQLWrite = "SELECT `access_group` FROM `$preTableName` WHERE id=$chkDataId"; $strSQLWrite = "SELECT `access_group` FROM `$preTableName` WHERE `id`=".$chkDataId;
$intWriteAccessId = $myVisClass->checkAccGroup(($myDBClass->getFieldData($strSQLWrite)+0),'write'); $intWriteAccessId = $myVisClass->checkAccountGroup((int)$myDBClass->getFieldData($strSQLWrite), 'write');
$myContentClass->intWriteAccessId = $intWriteAccessId; $myContentClass->intWriteAccessId = $intWriteAccessId;
} }
if ($chkListId != 0) { if ($chkListId != 0) {
$strSQLWrite = "SELECT `access_group` FROM `$preTableName` WHERE id=$chkListId"; $strSQLWrite = "SELECT `access_group` FROM `$preTableName` WHERE `id`=".$chkListId;
$intReadAccessId = $myVisClass->checkAccGroup(($myDBClass->getFieldData($strSQLWrite)+0),'read'); $intReadAccessId = $myVisClass->checkAccountGroup((int)$myDBClass->getFieldData($strSQLWrite), 'read');
$intWriteAccessId = $myVisClass->checkAccGroup(($myDBClass->getFieldData($strSQLWrite)+0),'write'); $intWriteAccessId = $myVisClass->checkAccountGroup((int)$myDBClass->getFieldData($strSQLWrite), 'write');
$myContentClass->intWriteAccessId = $intWriteAccessId; $myContentClass->intWriteAccessId = $intWriteAccessId;
} }
} }
// //
// Data processing // Data processing
// =============== // ===============
if (($chkModus == "make") && ($intGlobalWriteAccess == 0)) { if (($chkModus == 'make') && ($intGlobalWriteAccess == 0)) {
$intError = 0; $intError = 0;
$intSuccess = 0; $intSuccess = 0;
// Get write access groups // Get write access groups
$strAccess = $myVisClass->getAccGroups('write'); $strAccess = $myVisClass->getAccessGroups('write');
// Write configuration file // Write configuration file
if ($preTableName == 'tbl_host') { if ($preTableName == 'tbl_host') {
$strSQL = "SELECT `id` FROM `$preTableName` WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1'"; /** @var string $strDomainWhere - defined in prepend_adm.php */
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); $strSQL = "SELECT `id` FROM `$preTableName` "
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . "WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1'";
if ($booReturn && ($intDataCount != 0)) { $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
foreach ($arrData AS $data) { if ($booReturn == false) {
$intReturn = $myConfigClass->createConfigSingle("$preTableName",$data['id']); $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
if ($intReturn == 1){ }
$intError++; if ($booReturn && ($intDataCount != 0)) {
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); foreach ($arrData as $data) {
} else { $intReturn = $myConfigClass->createConfigSingle($preTableName, $data['id']);
$intSuccess++; if ($intReturn == 1) {
} $intError++;
} $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} else { } else {
$myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, not found or you do not have write permission!'),$strErrorMessage); $intSuccess++;
} }
if ($intSuccess != 0) $myVisClass->processMessage(translate('Configuration files successfully written!'),$strInfoMessage); }
if ($intError != 0) $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, not found or you do not have write permission!'),$strErrorMessage); } else {
} else if ($preTableName == 'tbl_service') { $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, '
$strSQL = "SELECT `id`, `$preKeyField` FROM `$preTableName` WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1' GROUP BY `$preKeyField`, `id`"; . 'not found or you do not have write permission!'), $strErrorMessage);
$myDBClass->getDataArray($strSQL,$arrData,$intDataCount); }
if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); if ($intSuccess != 0) {
if ($booReturn && ($intDataCount != 0)) { $myVisClass->processMessage(translate('Configuration files successfully written!'), $strInfoMessage);
foreach ($arrData AS $data) { }
$intReturn = $myConfigClass->createConfigSingle("$preTableName",$data['id']); if ($intError != 0) {
if ($intReturn == 1){ $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, '
$intError++; . 'not found or you do not have write permission!'), $strErrorMessage);
$myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); }
} else { } elseif ($preTableName == 'tbl_service') {
$intSuccess++; /** @var string $strDomainWhere - defined in prepend_adm.php */
} $strSQL = "SELECT `id`, `$preKeyField` FROM `$preTableName` "
} . "WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1' "
} else { . "GROUP BY `$preKeyField`, `id`";
$myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, not found or you do not have write permission!'),$strErrorMessage); $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
} if ($booReturn == false) {
if ($intSuccess != 0) $myVisClass->processMessage(translate('Configuration files successfully written!'),$strInfoMessage); $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
if ($intError != 0) $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, not found or you do not have write permission!'),$strErrorMessage); }
} else { if ($booReturn && ($intDataCount != 0)) {
$intReturn = $myConfigClass->createConfig($preTableName,0); foreach ($arrData as $data) {
if ($intReturn == 1) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); $intReturn = $myConfigClass->createConfigSingle($preTableName, $data['id']);
if ($intReturn == 0) $myVisClass->processMessage($myConfigClass->strInfoMessage,$strInfoMessage); if ($intReturn == 1) {
} $intError++;
$chkModus = "display"; $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} else if (($chkModus == "checkform") && ($chkSelModify == "info")) { } else {
// Display additional relation information $intSuccess++;
if ($preTableName == 'tbl_service') { }
$intReturn = $myDataClass->infoRelation($preTableName,$chkListId,"$preKeyField,service_description"); }
} else { } else {
$intReturn = $myDataClass->infoRelation($preTableName,$chkListId,$preKeyField); $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, '
} . 'not found or you do not have write permission!'), $strErrorMessage);
$myVisClass->processMessage($myDataClass->strInfoMessage,$strConsistMessage); }
$chkModus = "display"; if ($intSuccess != 0) {
} else if (($chkModus == "checkform") && ($chkSelModify == "delete") && ($intGlobalWriteAccess == 0)) { $myVisClass->processMessage(translate('Configuration files successfully written!'), $strInfoMessage);
// Delete selected datasets }
if (($preTableName == 'tbl_user') && ($chkTfValue5 == "Admin")) { if ($intError != 0) {
$myVisClass->processMessage(translate("Admin can't be deleted"),$strErrorMessage); $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, '
$intReturn = 0; . 'not found or you do not have write permission!'), $strErrorMessage);
} else if ((($preTableName == 'tbl_datadomain') || ($preTableName == 'tbl_configtarget')) && ($chkTfValue3 == "localhost")) { }
$myVisClass->processMessage(translate("Localhost can't be deleted"),$strErrorMessage); } else {
$intReturn = 0; $intReturn = $myConfigClass->createConfig($preTableName, 0);
} else if (($preTableName == 'tbl_user') || ($preTableName == 'tbl_datadomain') || ($preTableName == 'tbl_configtarget')) { if ($intReturn == 1) {
$intReturn = $myDataClass->dataDeleteEasy($preTableName,$chkListId); $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
} else { }
$intReturn = $myDataClass->dataDeleteFull($preTableName,$chkListId); if ($intReturn == 0) {
} $myVisClass->processMessage($myConfigClass->strInfoMessage, $strInfoMessage);
if ($intReturn == 1) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); }
if ($intReturn == 0) $myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); }
$chkModus = "display"; $chkModus = 'display';
} else if (($chkModus == "checkform") && ($chkSelModify == "copy") && ($intGlobalWriteAccess == 0)) { } elseif (($chkModus == 'checkform') && ($chkSelModify == 'info')) {
// Copy selected datasets // Display additional relation information
$intReturn = $myDataClass->dataCopyEasy($preTableName,$preKeyField,$chkListId,$chkSelTargetDomain); if ($preTableName == 'tbl_service') {
if ($intReturn == 1) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); $intReturn = $myDataClass->infoRelation($preTableName, $chkListId, "$preKeyField,service_description");
if ($intReturn == 0) $myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); } else {
$chkModus = "display"; $intReturn = $myDataClass->infoRelation($preTableName, $chkListId, $preKeyField);
} else if (($chkModus == "checkform") && ($chkSelModify == "activate") && ($intGlobalWriteAccess == 0)) { }
// Activate selected datasets $myVisClass->processMessage($myDataClass->strInfoMessage, $strConsistMessage);
$intReturn = $myDataClass->dataActivate($preTableName,$chkListId); $chkModus = 'display';
if ($intReturn == 1) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); } elseif (($chkModus == 'checkform') && ($chkSelModify == 'delete') && ($intGlobalWriteAccess == 0)) {
if ($intReturn == 0) $myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); $intReturn = 1;
$chkModus = "display"; // Delete selected datasets
} else if (($chkModus == "checkform") && ($chkSelModify == "deactivate") && ($intGlobalWriteAccess == 0)) { if (($preTableName == 'tbl_user') && ($chkTfValue5 == 'Admin')) {
// Deactivate selected datasets $myVisClass->processMessage(translate('Admin cannot be deleted'), $strErrorMessage);
$intReturn = $myDataClass->dataDeactivate($preTableName,$chkListId); $intReturn = 0;
if ($intReturn == 1) $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); } elseif ((($preTableName == 'tbl_datadomain') || ($preTableName == 'tbl_configtarget')) &&
if ($intReturn == 0) $myVisClass->processMessage($myDataClass->strInfoMessage,$strInfoMessage); ($chkTfValue3 == 'localhost')) {
// Remove deactivated files $myVisClass->processMessage(translate("Localhost can't be deleted"), $strErrorMessage);
if ($preTableName == 'tbl_host') { $intReturn = 0;
if ($chkListId != 0) { } elseif (($preTableName == 'tbl_user') || ($preTableName == 'tbl_datadomain') ||
$strChbName = "chbId_".$chkListId; ($preTableName == 'tbl_configtarget')) {
$_POST[$strChbName] = "on"; $intReturn = $myDataClass->dataDeleteEasy($preTableName, $chkListId);
} } else {
// Get write access groups $strInfoMessageTmp = $strInfoMessage;
$strAccess = $myVisClass->getAccGroups('write'); if ($preTableName == 'tbl_service') {
// Getting data sets $intRetVal = $myDataClass->infoRelation($preTableName, $chkListId, "$preKeyField,service_description");
$strSQL = "SELECT `id`, `host_name` FROM `".$preTableName."` WHERE `active`='0' AND `access_group` IN ($strAccess) AND `config_id`=".$chkDomainId; } else {
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); $intRetVal = $myDataClass->infoRelation($preTableName, $chkListId, $preKeyField);
if ($booReturn && ($intDataCount != 0) && ($chkDomainId != 0)) { }
$arrConfigID = $myConfigClass->getConfigSets(); if ($intRetVal == 0) {
$intError = 0; $strInfoMessage = $strInfoMessageTmp;
$intSuccess = 0; $intReturn = $myDataClass->dataDeleteFull($preTableName, $chkListId);
if (($arrConfigID != 1) && is_array($arrConfigID)) { }
foreach ($arrData AS $elem) { }
$strChbName = "chbId_".$elem['id']; $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
// was the current record is marked for deactivate? $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
if (isset($_POST[$strChbName]) && ($_POST[$strChbName] == "on")) { $chkModus = 'display';
$intCount = 0; } elseif (($chkModus == 'checkform') && ($chkSelModify == 'copy') && ($intGlobalWriteAccess == 0)) {
$intReturn = 0; // Copy selected datasets
foreach($arrConfigID AS $intConfigID) { $intReturn = $myDataClass->dataCopyEasy($preTableName, $preKeyField, $chkListId, $chkSelTarDom);
$intReturn += $myConfigClass->moveFile("host",$elem['host_name'].".cfg",$intConfigID); if ($intReturn == 1) {
if ($intReturn == 0) { $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$myDataClass->writeLog(translate('Host file deleted:')." ".$elem['host_name'].".cfg"); }
$intCount++; if ($intReturn == 0) {
} $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
} }
if ($intReturn == 0) $intSuccess++; $chkModus = 'display';
if ($intReturn != 0) $intError++; } elseif (($chkModus == 'checkform') && ($chkSelModify == 'activate') && ($intGlobalWriteAccess == 0)) {
} // Activate selected datasets
} $intReturn = $myDataClass->dataActivate($preTableName, $chkListId);
if (($intSuccess != 0) && ($intCount != 0)) { if ($intReturn == 1) {
$myVisClass->processMessage(translate('The assigned, no longer used configuration files were deleted successfully!').$intCount,$strInfoMessage); $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
} }
if ($intError != 0) { if ($intReturn == 0) {
$myVisClass->processMessage(translate('Errors while deleting the old configuration file - please check!:'),$strErrorMessage); $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
} }
} $chkModus = 'display';
} else if ($chkDomainId == 0) { } elseif (($chkModus == 'checkform') && ($chkSelModify == 'deactivate') && ($intGlobalWriteAccess == 0)) {
$myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check manually'),$strErrorMessage); // Deactivate selected datasets
} $intReturn = $myDataClass->dataDeactivate($preTableName, $chkListId);
} else if ($preTableName == 'tbl_service') { if ($intReturn == 1) {
if ($chkListId != 0) { $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
$strChbName = "chbId_".$chkListId; }
$_POST[$strChbName] = "on"; if ($intReturn == 0) {
} $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
// Get write access groups }
$strAccess = $myVisClass->getAccGroups('write'); // Remove deactivated files
// Getting data sets if ($preTableName == 'tbl_host') {
$strSQL = "SELECT `id`, `config_name` FROM `".$preTableName."` WHERE `active`='0' AND `access_group` IN ($strAccess) AND `config_id`=".$chkDomainId; if ($chkListId != 0) {
$booReturn = $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); $strChbName = 'chbId_' .$chkListId;
if ($booReturn && ($intDataCount != 0) && ($chkDomainId != 0)) { $_POST[$strChbName] = 'on';
$arrConfigID = $myConfigClass->getConfigSets(); }
$intError = 0; // Get write access groups
$intSuccess = 0; $strAccess = $myVisClass->getAccessGroups('write');
if (($arrConfigID != 1) && is_array($arrConfigID)) { // Getting data sets
$intCount = 0; $strSQL = 'SELECT `id`, `host_name` FROM `' .$preTableName. '` '
foreach ($arrData AS $elem) { . "WHERE `active`='0' AND `access_group` IN ($strAccess) AND `config_id`=".$chkDomainId;
$strChbName = "chbId_".$elem['id']; $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
// was the current record is marked for deactivate? if ($booReturn && ($intDataCount != 0) && ($chkDomainId != 0)) {
if (isset($_POST[$strChbName]) && ($_POST[$strChbName] == "on")) { $intReturn = $myConfigClass->getConfigTargets($arrConfigID);
$intServiceCount = $myDBClass->countRows("SELECT * FROM `$preTableName` WHERE `$preKeyField`='".$elem['config_name']."' $intError = 0;
AND `config_id`=$chkDomainId AND `active`='1'"); $intSuccess = 0;
if ($intServiceCount == 0) { if (($arrConfigID != 1) && is_array($arrConfigID)) {
$intReturn = 0; foreach ($arrData as $elem) {
foreach($arrConfigID AS $intConfigID) { $strChbName = 'chbId_' .$elem['id'];
$intReturn += $myConfigClass->moveFile("service",$elem['config_name'].".cfg",$intConfigID); // was the current record is marked for deactivate?
if ($intReturn == 0) $myDataClass->writeLog(translate('Service file deleted:')." ".$elem['config_name'].".cfg"); if ((filter_input(INPUT_POST, $strChbName) != null) &&
$intCount++; (filter_input(INPUT_POST, $strChbName, FILTER_SANITIZE_STRING) == 'on')) {
} $intCount = 0;
if ($intReturn == 0) $intSuccess++; $intReturn = 0;
if ($intReturn != 0) $intError++; foreach ($arrConfigID as $intConfigID) {
} $intReturn += $myConfigClass->moveFile('host', $elem['host_name']. '.cfg', $intConfigID);
} if ($intReturn == 0) {
} $myDataClass->writeLog(translate('Host file deleted:'). ' ' .$elem['host_name']
if (($intSuccess != 0) && ($intCount != 0)) { . '.cfg');
$myVisClass->processMessage(translate('The assigned, no longer used configuration files were deleted successfully!'),$strInfoMessage); $intCount++;
} }
if ($intError != 0) { }
$myVisClass->processMessage(translate('Errors while deleting the old configuration file - please check!:'),$strErrorMessage); if ($intReturn == 0) {
} $intSuccess++;
} }
} else if ($chkDomainId == 0) { if ($intReturn != 0) {
$myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check manually'),$strErrorMessage); $intError++;
} }
} }
$chkModus = "display"; }
} else if (($chkModus == "checkform") && ($chkSelModify == "modify")) { if (($intSuccess != 0) && ($intCount != 0)) {
// Open the dataset to modify $myVisClass->processMessage(translate('The assigned, no longer used configuration files were '
if ($intReadAccessId == 0) { . 'deleted successfully!').$intCount, $strInfoMessage);
$booReturn = $myDBClass->getSingleDataset("SELECT * FROM `$preTableName` WHERE `id`=".$chkListId,$arrModifyData); }
if ($booReturn == false) { if ($intError != 0) {
$myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); $myVisClass->processMessage(translate('Errors while deleting the old configuration file - please '
$myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); . 'check!:'), $strErrorMessage);
$chkModus = "display"; }
} else { }
$chkModus = "add"; } elseif ($chkDomainId == 0) {
} $myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check '
} else { . 'manually'), $strErrorMessage);
$myVisClass->processMessage(translate('No permission to open configuration!'),$strErrorMessage); }
$chkModus = "display"; } elseif ($preTableName == 'tbl_service') {
} if ($chkListId != 0) {
} else if (($chkModus == "checkform") && ($chkSelModify == "config") && ($intGlobalWriteAccess == 0)) { $strChbName = 'chbId_' .$chkListId;
// Write configuration file (hosts and services) $_POST[$strChbName] = 'on';
$intDSId = (int)substr(array_search("on",$_POST),6); }
if (isset($chkListId) && ($chkListId != 0)) $intDSId = $chkListId; // Get write access groups
$intValCount = 0; $strAccess = $myVisClass->getAccessGroups('write');
foreach($_POST AS $key => $elem) { // Getting data sets
if ($elem == "on") $intValCount++; $strSQL = 'SELECT `id`, `config_name` FROM `' .$preTableName. '` '
} . "WHERE `active`='0' AND `access_group` IN ($strAccess) AND `config_id`=".$chkDomainId;
if ($intValCount > 1) $intDSId = 0; $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
$intReturn = $myConfigClass->createConfigSingle($preTableName,$intDSId); if ($booReturn && ($intDataCount != 0) && ($chkDomainId != 0)) {
if ($intReturn == 1) $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); $intReturn = $myConfigClass->getConfigTargets($arrConfigID);
if ($intReturn == 0) $myVisClass->processMessage($myConfigClass->strInfoMessage,$strInfoMessage); $intError = 0;
$chkModus = "display"; $intSuccess = 0;
if (($arrConfigID != 1) && is_array($arrConfigID)) {
$intCount = 0;
foreach ($arrData as $elem) {
$strChbName = 'chbId_' .$elem['id'];
// was the current record is marked for deactivate?
if (filter_input(INPUT_POST, $strChbName) && (filter_input(INPUT_POST, $strChbName) == 'on')) {
$intServiceCount = $myDBClass->countRows("SELECT * FROM `$preTableName` "
. "WHERE `$preKeyField`='".$elem['config_name']."' "
. "AND `config_id`=$chkDomainId AND `active`='1'");
if ($intServiceCount == 0) {
$intReturn = 0;
foreach ($arrConfigID as $intConfigID) {
$intReturn += $myConfigClass->moveFile(
'service',
$elem['config_name']. '.cfg',
$intConfigID
);
if ($intReturn == 0) {
$myDataClass->writeLog(translate('Service file deleted:'). ' ' .
$elem['config_name']. '.cfg');
}
$intCount++;
}
if ($intReturn == 0) {
$intSuccess++;
}
if ($intReturn != 0) {
$intError++;
}
}
}
}
if (($intSuccess != 0) && ($intCount != 0)) {
$myVisClass->processMessage(translate('The assigned, no longer used configuration files were '
. 'deleted successfully!'), $strInfoMessage);
}
if ($intError != 0) {
$myVisClass->processMessage(translate('Errors while deleting the old configuration file - please '
. 'check!:'), $strErrorMessage);
}
}
} elseif ($chkDomainId == 0) {
$myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check '
. 'manually'), $strErrorMessage);
}
}
$chkModus = 'display';
} elseif (($chkModus == 'checkform') && ($chkSelModify == 'modify')) {
// Open the dataset to modify
if ($intReadAccessId == 0) {
$booReturn = $myDBClass->hasSingleDataset("SELECT * FROM `$preTableName` "
. 'WHERE `id`=' .$chkListId, $arrModifyData);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
$chkModus = 'display';
} else {
$chkModus = 'add';
}
} else {
$myVisClass->processMessage(translate('No permission to open configuration!'), $strErrorMessage);
$chkModus = 'display';
}
} elseif (($chkModus == 'checkform') && ($chkSelModify == 'config') && ($intGlobalWriteAccess == 0)) {
// Write configuration file (hosts and services)
$intDSId = (int)substr(array_search('on', filter_input_array(INPUT_POST), true), 6);
if (isset($chkListId) && ($chkListId != 0)) {
$intDSId = $chkListId;
}
$intValCount = 0;
foreach (filter_input_array(INPUT_POST) as $key => $elem) {
if ($elem == 'on') {
$intValCount++;
}
}
if ($intValCount > 1) {
$intDSId = 0;
}
$intReturn = $myConfigClass->createConfigSingle($preTableName, $intDSId);
if ($intReturn == 1) {
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
}
if ($intReturn == 0) {
$myVisClass->processMessage($myConfigClass->strInfoMessage, $strInfoMessage);
}
$chkModus = 'display';
} }
// //
// Some common list view functions // Some common list view functions
// =============================== // ===============================
if ($chkModus != "add") { if ($chkModus != 'add') {
// Get Group id's with READ // Get Group id's with READ
$strAccess = $myVisClass->getAccGroups('read'); $strAccess = $myVisClass->getAccessGroups('read');
// Include domain list // Include domain list
$myVisClass->insertDomainList($mastertp); /** @var HTML_Template_IT $mastertp */
// Process filter string $myVisClass->insertDomainList($mastertp);
// Process filter string
} }
?>

View File

@ -5,108 +5,99 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// (c) 2005-2017 by Martin Willisegger // (c) 2005-2018 by Martin Willisegger
// //
// Project : NagiosQL // Project : NagiosQL
// Component : Preprocessing script for scripting files // Component : Preprocessing script for scripting files
// Website : http://www.nagiosql.org // Website : https://sourceforge.net/projects/nagiosql/
// Date : $LastChangedDate: 2017-06-22 09:48:25 +0200 (Thu, 22 Jun 2017) $ // Version : 3.4.0
// Author : $LastChangedBy: martin $ // GIT Repo : https://gitlab.com/wizonet/NagiosQL
// Version : 3.3.0
// Revision : $LastChangedRevision: 4 $
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
error_reporting(E_ALL); //error_reporting(E_ALL);
//error_reporting(E_ERROR); //error_reporting(E_ERROR);
// //
// Security Protection // Security Protection
// =================== // ===================
if (isset($_GET['SETS']) || isset($_POST['SETS'])) { if (isset($_GET['SETS']) || isset($_POST['SETS'])) {
$SETS = ""; $SETS = '';
} }
// //
// Timezone settings (>=PHP5.1) // Timezone settings (>=PHP5.1)
// ============================ // ============================
if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) { if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
@date_default_timezone_set(@date_default_timezone_get()); @date_default_timezone_set(@date_default_timezone_get());
} }
// //
// Define common variables // Define common variables
// ======================= // =======================
$chkDomainId = 0; $chkDomainId = 0;
$intError = 0; $intError = 0;
// //
// Define path constants // Define path constants
// //
define('BASE_PATH', str_replace("functions","",dirname(__FILE__))); //define('BASE_PATH', str_replace("functions", "", dirname(__FILE__)));
// //
// Read settings file // Read settings file
// ================== // ==================
$preBasePath = str_replace("functions","",dirname(__FILE__)); $preBasePath = str_replace('functions', '', __DIR__);
$preIniFile = $preBasePath.'config/settings.php'; $preIniFile = $preBasePath.'config/settings.php';
// //
// Read file settings // Read file settings
// ================== // ==================
$SETS = parse_ini_file($preIniFile,true); $SETS = parse_ini_file($preIniFile, true);
// //
// Include external function/class files - part 1 // Include external function/class files - part 1
// ============================================== // ==============================================
include("mysqli_class.php"); require $preBasePath.'functions/Autoloader.php';
functions\Autoloader::register($preBasePath);
// //
// Initialize classes - part 1 // Initialize classes - part 1
// =========================== // ===========================
$myDBClass = new mysqlidb; $myDBClass = new functions\MysqliDbClass();
$myDBClass->arrParams = $SETS['db']; $myDBClass->arrParams = $SETS['db'];
$myDBClass->getDatabase(); $myDBClass->hasDBConnection();
if ($myDBClass->error == true) { if ($myDBClass->error == true) {
$strDBMessage = $myDBClass->strErrorMessage; $strDBMessage = $myDBClass->strErrorMessage;
$booError = $myDBClass->error; $booError = $myDBClass->error;
} }
// //
// Get additional configuration from the table tbl_settings // Get additional configuration from the table tbl_settings
// ======================================================== // ========================================================
if ($intError == 0) { if ($intError == 0) {
$strSQL = "SELECT `category`,`name`,`value` FROM `tbl_settings`"; $strSQL = 'SELECT `category`,`name`,`value` FROM `tbl_settings`';
$booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); $booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
if ($booReturn == false) { if ($booReturn == false) {
echo str_replace("::","\n","Error while selecting data from database: ".$myDBClass->strErrorMessage); echo str_replace('::', "\n", 'Error while selecting data from database: ' .$myDBClass->strErrorMessage);
$intError = 1; $intError = 1;
} else if ($intDataCount != 0) { } elseif ($intDataCount != 0) {
for ($i=0;$i<$intDataCount;$i++) { for ($i=0; $i<$intDataCount; $i++) {
$SETS[$arrDataLines[$i]['category']][$arrDataLines[$i]['name']] = $arrDataLines[$i]['value']; $SETS[$arrDataLines[$i]['category']][$arrDataLines[$i]['name']] = $arrDataLines[$i]['value'];
} }
} }
} else { } else {
echo "Could not load configuration settings from database - abort\n"; echo "Could not load configuration settings from database - abort\n";
exit; exit;
} }
// //
// Include external function/class files // Include external function/class files
// ===================================== // =====================================
include("translator.php"); include 'translator.php';
include("data_class.php");
include("config_class.php");
include("import_class.php");
require_once($preBasePath.'libraries/pear/HTML/Template/IT.php');
// //
// Initialize classes // Initialize classes
// ================== // ==================
$myDataClass = new nagdata; $arrSession = array();
$myConfigClass = new nagconfig; $arrSession['SETS'] = $SETS;
$myImportClass = new nagimport; $myDataClass = new functions\NagDataClass($arrSession);
$myConfigClass = new functions\NagConfigClass($arrSession);
$myImportClass = new functions\NagImportClass($arrSession);
// //
// Propagating the classes themselves // Propagating the classes themselves
// ================================== // ==================================
$myDataClass->myDBClass =& $myDBClass; $myDataClass->myDBClass =& $myDBClass;
$myDataClass->myConfigClass =& $myConfigClass; $myDataClass->myConfigClass =& $myConfigClass;
$myConfigClass->myDBClass =& $myDBClass; $myConfigClass->myDBClass =& $myDBClass;
$myConfigClass->myDataClass =& $myDataClass; $myConfigClass->myDataClass =& $myDataClass;
$myImportClass->myDataClass =& $myDataClass; $myImportClass->myDataClass =& $myDataClass;
$myImportClass->myDBClass =& $myDBClass; $myImportClass->myDBClass =& $myDBClass;
$myImportClass->myConfigClass =& $myConfigClass; $myImportClass->myConfigClass =& $myConfigClass;
//
// Set class variables
// ===================
$myDataClass->arrSettings = $SETS;
$myConfigClass->arrSettings = $SETS;
?>

View File

@ -1,223 +1,223 @@
tinyMCE.addI18n({en:{ tinyMCE.addI18n({en:{
common:{ common:{
edit_confirm:"Do you want to use the WYSIWYG mode for this textarea?", edit_confirm:"Do you want to use the WYSIWYG mode for this textarea?",
apply:"Apply", apply:"Apply",
insert:"Insert", insert:"Insert",
update:"Update", update:"Update",
cancel:"Cancel", cancel:"Cancel",
close:"Close", close:"Close",
browse:"Browse", browse:"Browse",
class_name:"Class", class_name:"Class",
not_set:"-- Not set --", not_set:"-- Not set --",
clipboard_msg:"Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?", clipboard_msg:"Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?",
clipboard_no_support:"Currently not supported by your browser, use keyboard shortcuts instead.", clipboard_no_support:"Currently not supported by your browser, use keyboard shortcuts instead.",
popup_blocked:"Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.", popup_blocked:"Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.",
invalid_data:"{#field} is invalid", invalid_data:"{#field} is invalid",
invalid_data_number:"{#field} must be a number", invalid_data_number:"{#field} must be a number",
invalid_data_min:"{#field} must be a number greater than {#min}", invalid_data_min:"{#field} must be a number greater than {#min}",
invalid_data_size:"{#field} must be a number or percentage", invalid_data_size:"{#field} must be a number or percentage",
more_colors:"More colors" more_colors:"More colors"
}, },
colors:{ colors:{
'000000':'Black', '000000':'Black',
'993300':'Burnt orange', '993300':'Burnt orange',
'333300':'Dark olive', '333300':'Dark olive',
'003300':'Dark green', '003300':'Dark green',
'003366':'Dark azure', '003366':'Dark azure',
'000080':'Navy Blue', '000080':'Navy Blue',
'333399':'Indigo', '333399':'Indigo',
'333333':'Very dark gray', '333333':'Very dark gray',
'800000':'Maroon', '800000':'Maroon',
'FF6600':'Orange', 'FF6600':'Orange',
'808000':'Olive', '808000':'Olive',
'008000':'Green', '008000':'Green',
'008080':'Teal', '008080':'Teal',
'0000FF':'Blue', '0000FF':'Blue',
'666699':'Grayish blue', '666699':'Grayish blue',
'808080':'Gray', '808080':'Gray',
'FF0000':'Red', 'FF0000':'Red',
'FF9900':'Amber', 'FF9900':'Amber',
'99CC00':'Yellow green', '99CC00':'Yellow green',
'339966':'Sea green', '339966':'Sea green',
'33CCCC':'Turquoise', '33CCCC':'Turquoise',
'3366FF':'Royal blue', '3366FF':'Royal blue',
'800080':'Purple', '800080':'Purple',
'999999':'Medium gray', '999999':'Medium gray',
'FF00FF':'Magenta', 'FF00FF':'Magenta',
'FFCC00':'Gold', 'FFCC00':'Gold',
'FFFF00':'Yellow', 'FFFF00':'Yellow',
'00FF00':'Lime', '00FF00':'Lime',
'00FFFF':'Aqua', '00FFFF':'Aqua',
'00CCFF':'Sky blue', '00CCFF':'Sky blue',
'993366':'Brown', '993366':'Brown',
'C0C0C0':'Silver', 'C0C0C0':'Silver',
'FF99CC':'Pink', 'FF99CC':'Pink',
'FFCC99':'Peach', 'FFCC99':'Peach',
'FFFF99':'Light yellow', 'FFFF99':'Light yellow',
'CCFFCC':'Pale green', 'CCFFCC':'Pale green',
'CCFFFF':'Pale cyan', 'CCFFFF':'Pale cyan',
'99CCFF':'Light sky blue', '99CCFF':'Light sky blue',
'CC99FF':'Plum', 'CC99FF':'Plum',
'FFFFFF':'White' 'FFFFFF':'White'
}, },
contextmenu:{ contextmenu:{
align:"Alignment", align:"Alignment",
left:"Left", left:"Left",
center:"Center", center:"Center",
right:"Right", right:"Right",
full:"Full" full:"Full"
}, },
insertdatetime:{ insertdatetime:{
date_fmt:"%Y-%m-%d", date_fmt:"%Y-%m-%d",
time_fmt:"%H:%M:%S", time_fmt:"%H:%M:%S",
insertdate_desc:"Insert date", insertdate_desc:"Insert date",
inserttime_desc:"Insert time", inserttime_desc:"Insert time",
months_long:"January,February,March,April,May,June,July,August,September,October,November,December", months_long:"January,February,March,April,May,June,July,August,September,October,November,December",
months_short:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec", months_short:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",
day_long:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday", day_long:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday",
day_short:"Sun,Mon,Tue,Wed,Thu,Fri,Sat,Sun" day_short:"Sun,Mon,Tue,Wed,Thu,Fri,Sat,Sun"
}, },
print:{ print:{
print_desc:"Print" print_desc:"Print"
}, },
preview:{ preview:{
preview_desc:"Preview" preview_desc:"Preview"
}, },
directionality:{ directionality:{
ltr_desc:"Direction left to right", ltr_desc:"Direction left to right",
rtl_desc:"Direction right to left" rtl_desc:"Direction right to left"
}, },
layer:{ layer:{
insertlayer_desc:"Insert new layer", insertlayer_desc:"Insert new layer",
forward_desc:"Move forward", forward_desc:"Move forward",
backward_desc:"Move backward", backward_desc:"Move backward",
absolute_desc:"Toggle absolute positioning", absolute_desc:"Toggle absolute positioning",
content:"New layer..." content:"New layer..."
}, },
save:{ save:{
save_desc:"Save", save_desc:"Save",
cancel_desc:"Cancel all changes" cancel_desc:"Cancel all changes"
}, },
nonbreaking:{ nonbreaking:{
nonbreaking_desc:"Insert non-breaking space character" nonbreaking_desc:"Insert non-breaking space character"
}, },
iespell:{ iespell:{
iespell_desc:"Run spell checking", iespell_desc:"Run spell checking",
download:"ieSpell not detected. Do you want to install it now?" download:"ieSpell not detected. Do you want to install it now?"
}, },
advhr:{ advhr:{
advhr_desc:"Horizontal rule" advhr_desc:"Horizontal rule"
}, },
emotions:{ emotions:{
emotions_desc:"Emotions" emotions_desc:"Emotions"
}, },
searchreplace:{ searchreplace:{
search_desc:"Find", search_desc:"Find",
replace_desc:"Find/Replace" replace_desc:"Find/Replace"
}, },
advimage:{ advimage:{
image_desc:"Insert/edit image" image_desc:"Insert/edit image"
}, },
advlink:{ advlink:{
link_desc:"Insert/edit link" link_desc:"Insert/edit link"
}, },
xhtmlxtras:{ xhtmlxtras:{
cite_desc:"Citation", cite_desc:"Citation",
abbr_desc:"Abbreviation", abbr_desc:"Abbreviation",
acronym_desc:"Acronym", acronym_desc:"Acronym",
del_desc:"Deletion", del_desc:"Deletion",
ins_desc:"Insertion", ins_desc:"Insertion",
attribs_desc:"Insert/Edit Attributes" attribs_desc:"Insert/Edit Attributes"
}, },
style:{ style:{
desc:"Edit CSS Style" desc:"Edit CSS Style"
}, },
paste:{ paste:{
paste_text_desc:"Paste as Plain Text", paste_text_desc:"Paste as Plain Text",
paste_word_desc:"Paste from Word", paste_word_desc:"Paste from Word",
selectall_desc:"Select All", selectall_desc:"Select All",
plaintext_mode_sticky:"Paste is now in plain text mode. Click again to toggle back to regular paste mode. After you paste something you will be returned to regular paste mode.", plaintext_mode_sticky:"Paste is now in plain text mode. Click again to toggle back to regular paste mode. After you paste something you will be returned to regular paste mode.",
plaintext_mode:"Paste is now in plain text mode. Click again to toggle back to regular paste mode." plaintext_mode:"Paste is now in plain text mode. Click again to toggle back to regular paste mode."
}, },
paste_dlg:{ paste_dlg:{
text_title:"Use CTRL+V on your keyboard to paste the text into the window.", text_title:"Use CTRL+V on your keyboard to paste the text into the window.",
text_linebreaks:"Keep linebreaks", text_linebreaks:"Keep linebreaks",
word_title:"Use CTRL+V on your keyboard to paste the text into the window." word_title:"Use CTRL+V on your keyboard to paste the text into the window."
}, },
table:{ table:{
desc:"Inserts a new table", desc:"Inserts a new table",
row_before_desc:"Insert row before", row_before_desc:"Insert row before",
row_after_desc:"Insert row after", row_after_desc:"Insert row after",
delete_row_desc:"Delete row", delete_row_desc:"Delete row",
col_before_desc:"Insert column before", col_before_desc:"Insert column before",
col_after_desc:"Insert column after", col_after_desc:"Insert column after",
delete_col_desc:"Remove column", delete_col_desc:"Remove column",
split_cells_desc:"Split merged table cells", split_cells_desc:"Split merged table cells",
merge_cells_desc:"Merge table cells", merge_cells_desc:"Merge table cells",
row_desc:"Table row properties", row_desc:"Table row properties",
cell_desc:"Table cell properties", cell_desc:"Table cell properties",
props_desc:"Table properties", props_desc:"Table properties",
paste_row_before_desc:"Paste table row before", paste_row_before_desc:"Paste table row before",
paste_row_after_desc:"Paste table row after", paste_row_after_desc:"Paste table row after",
cut_row_desc:"Cut table row", cut_row_desc:"Cut table row",
copy_row_desc:"Copy table row", copy_row_desc:"Copy table row",
del:"Delete table", del:"Delete table",
row:"Row", row:"Row",
col:"Column", col:"Column",
cell:"Cell" cell:"Cell"
}, },
autosave:{ autosave:{
unload_msg:"The changes you made will be lost if you navigate away from this page.", unload_msg:"The changes you made will be lost if you navigate away from this page.",
restore_content:"Restore auto-saved content.", restore_content:"Restore auto-saved content.",
warning_message:"If you restore the saved content, you will lose all the content that is currently in the editor.\n\nAre you sure you want to restore the saved content?." warning_message:"If you restore the saved content, you will lose all the content that is currently in the editor.\n\nAre you sure you want to restore the saved content?."
}, },
fullscreen:{ fullscreen:{
desc:"Toggle fullscreen mode" desc:"Toggle fullscreen mode"
}, },
media:{ media:{
desc:"Insert / edit embedded media", desc:"Insert / edit embedded media",
edit:"Edit embedded media" edit:"Edit embedded media"
}, },
fullpage:{ fullpage:{
desc:"Document properties" desc:"Document properties"
}, },
template:{ template:{
desc:"Insert predefined template content" desc:"Insert predefined template content"
}, },
visualchars:{ visualchars:{
desc:"Visual control characters on/off." desc:"Visual control characters on/off."
}, },
spellchecker:{ spellchecker:{
desc:"Toggle spellchecker", desc:"Toggle spellchecker",
menu:"Spellchecker settings", menu:"Spellchecker settings",
ignore_word:"Ignore word", ignore_word:"Ignore word",
ignore_words:"Ignore all", ignore_words:"Ignore all",
langs:"Languages", langs:"Languages",
wait:"Please wait...", wait:"Please wait...",
sug:"Suggestions", sug:"Suggestions",
no_sug:"No suggestions", no_sug:"No suggestions",
no_mpell:"No misspellings found.", no_mpell:"No misspellings found.",
learn_word:"Learn word" learn_word:"Learn word"
}, },
pagebreak:{ pagebreak:{
desc:"Insert page break." desc:"Insert page break."
}, },
advlist:{ advlist:{
types:"Types", types:"Types",
def:"Default", def:"Default",
lower_alpha:"Lower alpha", lower_alpha:"Lower alpha",
lower_greek:"Lower greek", lower_greek:"Lower greek",
lower_roman:"Lower roman", lower_roman:"Lower roman",
upper_alpha:"Upper alpha", upper_alpha:"Upper alpha",
upper_roman:"Upper roman", upper_roman:"Upper roman",
circle:"Circle", circle:"Circle",
disc:"Disc", disc:"Disc",
square:"Square" square:"Square"
}, },
aria:{ aria:{
rich_text_area:"Rich Text Area" rich_text_area:"Rich Text Area"
}, },
wordcount:{ wordcount:{
words: 'Words: ' words: 'Words: '
} }
}}); }});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
<!-- WebKit -->

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
.panel_wrapper {height:85px;} .panel_wrapper {height:85px;}
.panel_wrapper div.current {height:85px;} .panel_wrapper div.current {height:85px;}
/* IE */ /* IE */
* html .panel_wrapper {height:100px;} * html .panel_wrapper {height:100px;}
* html .panel_wrapper div.current {height:100px;} * html .panel_wrapper div.current {height:100px;}

View File

@ -1,142 +1,142 @@
tinyMCEPopup.requireLangPack(); tinyMCEPopup.requireLangPack();
var SearchReplaceDialog = { var SearchReplaceDialog = {
init : function(ed) { init : function(ed) {
var t = this, f = document.forms[0], m = tinyMCEPopup.getWindowArg("mode"); var t = this, f = document.forms[0], m = tinyMCEPopup.getWindowArg("mode");
t.switchMode(m); t.switchMode(m);
f[m + '_panel_searchstring'].value = tinyMCEPopup.getWindowArg("search_string"); f[m + '_panel_searchstring'].value = tinyMCEPopup.getWindowArg("search_string");
// Focus input field // Focus input field
f[m + '_panel_searchstring'].focus(); f[m + '_panel_searchstring'].focus();
mcTabs.onChange.add(function(tab_id, panel_id) { mcTabs.onChange.add(function(tab_id, panel_id) {
t.switchMode(tab_id.substring(0, tab_id.indexOf('_'))); t.switchMode(tab_id.substring(0, tab_id.indexOf('_')));
}); });
}, },
switchMode : function(m) { switchMode : function(m) {
var f, lm = this.lastMode; var f, lm = this.lastMode;
if (lm != m) { if (lm != m) {
f = document.forms[0]; f = document.forms[0];
if (lm) { if (lm) {
f[m + '_panel_searchstring'].value = f[lm + '_panel_searchstring'].value; f[m + '_panel_searchstring'].value = f[lm + '_panel_searchstring'].value;
f[m + '_panel_backwardsu'].checked = f[lm + '_panel_backwardsu'].checked; f[m + '_panel_backwardsu'].checked = f[lm + '_panel_backwardsu'].checked;
f[m + '_panel_backwardsd'].checked = f[lm + '_panel_backwardsd'].checked; f[m + '_panel_backwardsd'].checked = f[lm + '_panel_backwardsd'].checked;
f[m + '_panel_casesensitivebox'].checked = f[lm + '_panel_casesensitivebox'].checked; f[m + '_panel_casesensitivebox'].checked = f[lm + '_panel_casesensitivebox'].checked;
} }
mcTabs.displayTab(m + '_tab', m + '_panel'); mcTabs.displayTab(m + '_tab', m + '_panel');
document.getElementById("replaceBtn").style.display = (m == "replace") ? "inline" : "none"; document.getElementById("replaceBtn").style.display = (m == "replace") ? "inline" : "none";
document.getElementById("replaceAllBtn").style.display = (m == "replace") ? "inline" : "none"; document.getElementById("replaceAllBtn").style.display = (m == "replace") ? "inline" : "none";
this.lastMode = m; this.lastMode = m;
} }
}, },
searchNext : function(a) { searchNext : function(a) {
var ed = tinyMCEPopup.editor, se = ed.selection, r = se.getRng(), f, m = this.lastMode, s, b, fl = 0, w = ed.getWin(), wm = ed.windowManager, fo = 0; var ed = tinyMCEPopup.editor, se = ed.selection, r = se.getRng(), f, m = this.lastMode, s, b, fl = 0, w = ed.getWin(), wm = ed.windowManager, fo = 0;
// Get input // Get input
f = document.forms[0]; f = document.forms[0];
s = f[m + '_panel_searchstring'].value; s = f[m + '_panel_searchstring'].value;
b = f[m + '_panel_backwardsu'].checked; b = f[m + '_panel_backwardsu'].checked;
ca = f[m + '_panel_casesensitivebox'].checked; ca = f[m + '_panel_casesensitivebox'].checked;
rs = f['replace_panel_replacestring'].value; rs = f['replace_panel_replacestring'].value;
if (tinymce.isIE) { if (tinymce.isIE) {
r = ed.getDoc().selection.createRange(); r = ed.getDoc().selection.createRange();
} }
if (s == '') if (s == '')
return; return;
function fix() { function fix() {
// Correct Firefox graphics glitches // Correct Firefox graphics glitches
// TODO: Verify if this is actually needed any more, maybe it was for very old FF versions? // TODO: Verify if this is actually needed any more, maybe it was for very old FF versions?
r = se.getRng().cloneRange(); r = se.getRng().cloneRange();
ed.getDoc().execCommand('SelectAll', false, null); ed.getDoc().execCommand('SelectAll', false, null);
se.setRng(r); se.setRng(r);
}; };
function replace() { function replace() {
ed.selection.setContent(rs); // Needs to be duplicated due to selection bug in IE ed.selection.setContent(rs); // Needs to be duplicated due to selection bug in IE
}; };
// IE flags // IE flags
if (ca) if (ca)
fl = fl | 4; fl = fl | 4;
switch (a) { switch (a) {
case 'all': case 'all':
// Move caret to beginning of text // Move caret to beginning of text
ed.execCommand('SelectAll'); ed.execCommand('SelectAll');
ed.selection.collapse(true); ed.selection.collapse(true);
if (tinymce.isIE) { if (tinymce.isIE) {
ed.focus(); ed.focus();
r = ed.getDoc().selection.createRange(); r = ed.getDoc().selection.createRange();
while (r.findText(s, b ? -1 : 1, fl)) { while (r.findText(s, b ? -1 : 1, fl)) {
r.scrollIntoView(); r.scrollIntoView();
r.select(); r.select();
replace(); replace();
fo = 1; fo = 1;
if (b) { if (b) {
r.moveEnd("character", -(rs.length)); // Otherwise will loop forever r.moveEnd("character", -(rs.length)); // Otherwise will loop forever
} }
} }
tinyMCEPopup.storeSelection(); tinyMCEPopup.storeSelection();
} else { } else {
while (w.find(s, ca, b, false, false, false, false)) { while (w.find(s, ca, b, false, false, false, false)) {
replace(); replace();
fo = 1; fo = 1;
} }
} }
if (fo) if (fo)
tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.allreplaced')); tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.allreplaced'));
else else
tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound')); tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound'));
return; return;
case 'current': case 'current':
if (!ed.selection.isCollapsed()) if (!ed.selection.isCollapsed())
replace(); replace();
break; break;
} }
se.collapse(b); se.collapse(b);
r = se.getRng(); r = se.getRng();
// Whats the point // Whats the point
if (!s) if (!s)
return; return;
if (tinymce.isIE) { if (tinymce.isIE) {
ed.focus(); ed.focus();
r = ed.getDoc().selection.createRange(); r = ed.getDoc().selection.createRange();
if (r.findText(s, b ? -1 : 1, fl)) { if (r.findText(s, b ? -1 : 1, fl)) {
r.scrollIntoView(); r.scrollIntoView();
r.select(); r.select();
} else } else
tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound')); tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound'));
tinyMCEPopup.storeSelection(); tinyMCEPopup.storeSelection();
} else { } else {
if (!w.find(s, ca, b, false, false, false, false)) if (!w.find(s, ca, b, false, false, false, false))
tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound')); tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound'));
else else
fix(); fix();
} }
} }
}; };
tinyMCEPopup.onInit.add(SearchReplaceDialog.init, SearchReplaceDialog); tinyMCEPopup.onInit.add(SearchReplaceDialog.init, SearchReplaceDialog);

View File

@ -1,16 +1,16 @@
tinyMCE.addI18n('en.searchreplace_dlg',{ tinyMCE.addI18n('en.searchreplace_dlg',{
searchnext_desc:"Find again", searchnext_desc:"Find again",
notfound:"The search has been completed. The search string could not be found.", notfound:"The search has been completed. The search string could not be found.",
search_title:"Find", search_title:"Find",
replace_title:"Find/Replace", replace_title:"Find/Replace",
allreplaced:"All occurrences of the search string were replaced.", allreplaced:"All occurrences of the search string were replaced.",
findwhat:"Find what", findwhat:"Find what",
replacewith:"Replace with", replacewith:"Replace with",
direction:"Direction", direction:"Direction",
up:"Up", up:"Up",
down:"Down", down:"Down",
mcase:"Match case", mcase:"Match case",
findnext:"Find next", findnext:"Find next",
replace:"Replace", replace:"Replace",
replaceall:"Replace all" replaceall:"Replace all"
}); });

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