New upstream version 3.5.0
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
<?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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/* ----------------------------------------------------------------------------
|
||||
NagiosQL
|
||||
-------------------------------------------------------------------------------
|
||||
(c) 2005-2022 by Martin Willisegger
|
||||
|
||||
Project : NagiosQL
|
||||
Component : Autoloader Class
|
||||
Website : https://sourceforge.net/projects/nagiosql/
|
||||
Version : 3.5.0
|
||||
GIT Repo : https://gitlab.com/wizonet/NagiosQL
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
namespace functions;
|
||||
|
||||
class Autoloader
|
||||
@@ -29,9 +27,10 @@ class Autoloader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $strBasePath Base path of project
|
||||
* @param string $strBasePath Base path of project
|
||||
* @noinspection PhpObjectFieldsAreOnlyWrittenInspection
|
||||
*/
|
||||
public static function register($strBasePath)
|
||||
public static function register(string $strBasePath): void
|
||||
{
|
||||
$object = new Autoloader();
|
||||
$object->preBasePath = $strBasePath;
|
||||
@@ -39,21 +38,21 @@ class Autoloader
|
||||
|
||||
/**
|
||||
* Load class from path
|
||||
* @param string $strClassName Class name
|
||||
* @param string $strClassName Class name
|
||||
*/
|
||||
public function loadClass($strClassName)
|
||||
public function loadClass(string $strClassName): void
|
||||
{
|
||||
$className = ltrim($strClassName, '\\');
|
||||
$fileName = '';
|
||||
$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;
|
||||
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;
|
||||
$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;
|
||||
}
|
||||
@@ -61,4 +60,4 @@ class Autoloader
|
||||
require_once $strFilePath2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +1,60 @@
|
||||
<?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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
NagiosQL
|
||||
-------------------------------------------------------------------------------
|
||||
(c) 2005-2022 by Martin Willisegger
|
||||
|
||||
Project : NagiosQL
|
||||
Component : MySQLi data processing class
|
||||
Website : https://sourceforge.net/projects/nagiosql/
|
||||
Version : 3.5.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
|
||||
/* 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'] = '';
|
||||
$this->arrParams['server'] = '';
|
||||
$this->arrParams['port'] = 0;
|
||||
$this->arrParams['username'] = '';
|
||||
$this->arrParams['password'] = '';
|
||||
$this->arrParams['database'] = '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,21 +66,162 @@ class MysqliDbClass
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Close database server connectuon
|
||||
* @return bool true = successful / false = error
|
||||
* @noinspection PhpReturnValueOfMethodIsNeverUsedInspection
|
||||
*/
|
||||
public function hasDBConnection($intMode = 0)
|
||||
private function dbDisconnect(): bool
|
||||
{
|
||||
return mysqli_close($this->strDBId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(int $intMode = 0): bool
|
||||
{
|
||||
$booReturn = true;
|
||||
$this->dbconnect();
|
||||
if ($this->error == true) {
|
||||
if ($this->error === true) {
|
||||
$booReturn = false;
|
||||
}
|
||||
if (($booReturn == true) && ($intMode == 0)) {
|
||||
if (($booReturn === true) && ($intMode === 0)) {
|
||||
$this->dbselect();
|
||||
if ($this->error == true) {
|
||||
if ($this->error === true) {
|
||||
$booReturn = false;
|
||||
}
|
||||
}
|
||||
return $booReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 void true = successful / false = error
|
||||
* Status messages are stored in class variable
|
||||
* @noinspection PhpMissingParamTypeInspection
|
||||
* @noinspection PhpSameParameterValueInspection
|
||||
*/
|
||||
private function dbconnect($dbserver = null, int $dbport = 0, $dbuser = null, $dbpasswd = null): void
|
||||
{
|
||||
/* Reset error variables */
|
||||
$this->strErrorMessage = '';
|
||||
$this->error = false;
|
||||
$booReturn = true;
|
||||
/* Get parameters */
|
||||
if ($dbserver === null) {
|
||||
$dbserver = $this->arrParams['server'];
|
||||
}
|
||||
if ($dbport === 0) {
|
||||
$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) {
|
||||
TODO: 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;
|
||||
}
|
||||
/** PHP8 exception handling */
|
||||
mysqli_report(MYSQLI_REPORT_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a mysql database connection
|
||||
* @return bool true = successful / false = error
|
||||
* @noinspection PhpReturnValueOfMethodIsNeverUsedInspection
|
||||
*/
|
||||
private function dbinit(): bool
|
||||
{
|
||||
$this->strDBId = mysqli_init();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a database
|
||||
* @param string $database Database name
|
||||
* @return bool true = successful / false = error
|
||||
* Status messages are stored in class variable
|
||||
* @noinspection PhpReturnValueOfMethodIsNeverUsedInspection
|
||||
* @noinspection PhpMissingParamTypeInspection
|
||||
* @noinspection PhpSameParameterValueInspection
|
||||
*/
|
||||
private function dbselect($database = null): bool
|
||||
{
|
||||
/* 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) {
|
||||
$intErrorReporting = error_reporting();
|
||||
error_reporting(0);
|
||||
$bolConnect = mysqli_select_db($this->strDBId, $database);
|
||||
error_reporting($intErrorReporting);
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
@@ -97,112 +230,115 @@ class MysqliDbClass
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param string $strSQL SQL Statement
|
||||
* @return string <data> = successful / <empty> = error
|
||||
* Status messages are stored in class variable
|
||||
*/
|
||||
public function getFieldData($strSQL)
|
||||
public function getFieldData(string $strSQL): string
|
||||
{
|
||||
// Reset error variables
|
||||
/* Reset error variables */
|
||||
$this->strErrorMessage = '';
|
||||
$this->error = false;
|
||||
$strReturn = '';
|
||||
// Send the SQL statement to the server
|
||||
$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
|
||||
/* 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;
|
||||
if ($strReturn === null) {
|
||||
$strReturn = '';
|
||||
}
|
||||
} 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
|
||||
* @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)
|
||||
public function hasSingleDataset(string $strSQL, ?array &$arrDataset): bool
|
||||
{
|
||||
//$arrDataset = array();
|
||||
$booReturn = true;
|
||||
// Reset error variables
|
||||
$arrDataset = array();
|
||||
$booReturn = true;
|
||||
/* Reset error variables */
|
||||
$this->strErrorMessage = '';
|
||||
$this->error = false;
|
||||
// Send the SQL statement to the server
|
||||
$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
|
||||
/* 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;
|
||||
} 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
|
||||
* @param string $strSQL SQL Statement
|
||||
* @param array|null $arrDataset Result array (by reference)
|
||||
* @param int|null $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)
|
||||
public function hasDataArray(string $strSQL, array &$arrDataset = null, int &$intDataCount = null): bool
|
||||
{
|
||||
$arrDataset = array();
|
||||
$arrDataset = array();
|
||||
$intDataCount = 0;
|
||||
$booReturn = true;
|
||||
// Reset error variables
|
||||
$booReturn = true;
|
||||
/* Reset error variables */
|
||||
$this->strErrorMessage = '';
|
||||
$this->error = false;
|
||||
// Send the SQL statement to the server
|
||||
$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);
|
||||
/* Error processing */
|
||||
if ($resQuery && (mysqli_num_rows($resQuery) !== 0) && (mysqli_error($this->strDBId) === '')) {
|
||||
$intDataCount = (int)mysqli_num_rows($resQuery);
|
||||
$intCount = 0;
|
||||
// Put the values into the array
|
||||
/* 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;
|
||||
} 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
|
||||
* @param string $strSQL SQL Statement
|
||||
* @return bool true = successful / false = error
|
||||
* Status messages are stored in class variable
|
||||
*/
|
||||
public function insertData($strSQL)
|
||||
public function insertData(string $strSQL): bool
|
||||
{
|
||||
// Reset error variables
|
||||
/* Reset error variables */
|
||||
$this->strErrorMessage = '';
|
||||
$this->error = false;
|
||||
$booReturn = false;
|
||||
// Send the SQL statement to the server
|
||||
if ($strSQL != '') {
|
||||
$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) == '') {
|
||||
/* Error processing */
|
||||
if (mysqli_error($this->strDBId) === '') {
|
||||
$this->intLastId = mysqli_insert_id($this->strDBId);
|
||||
$this->intAffectedRows = mysqli_affected_rows($this->strDBId);
|
||||
$booReturn = true;
|
||||
@@ -216,197 +352,65 @@ class MysqliDbClass
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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)
|
||||
public function countRows(string $strSQL): int
|
||||
{
|
||||
// Reset error variables
|
||||
/* Reset error variables */
|
||||
$this->strErrorMessage = '';
|
||||
$this->error = false;
|
||||
$intReturn = 0;
|
||||
// Send the SQL statement to the server
|
||||
$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) == '')) {
|
||||
/* Error processing */
|
||||
if ($resQuery && (mysqli_error($this->strDBId) === '')) {
|
||||
$intReturn = mysqli_num_rows($resQuery);
|
||||
} else {
|
||||
$this->strErrorMessage .= mysqli_error($this->strDBId);
|
||||
$this->error = true;
|
||||
$this->error = true;
|
||||
}
|
||||
return $intReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a safe insert string for database manipulations
|
||||
* @param string $strInput Input String
|
||||
* @return string Output String
|
||||
* @param string $strInput Input String
|
||||
* @return string Output String
|
||||
*/
|
||||
public function realEscape($strInput)
|
||||
public function realEscape(string $strInput): string
|
||||
{
|
||||
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
|
||||
* @param string $sslkey SSL key
|
||||
* @param string $sslcert SSL certificate
|
||||
* @param string|null $sslca SSL CA file (optional)
|
||||
* @param string|null $sslpath SSL certificate path (optional)
|
||||
* @param string|null $sslcypher SSL cypher (optional)
|
||||
* @return bool true = successful
|
||||
* Status messages are stored in class variable
|
||||
* @noinspection PhpSameParameterValueInspection
|
||||
* @noinspection PhpUnusedPrivateMethodInspection
|
||||
*/
|
||||
/*
|
||||
private function dbsetssl($sslkey, $sslcert, $sslca = null, $sslpath = null, $sslcypher = null)
|
||||
private function dbsetssl(string $sslkey, string $sslcert, string $sslca = null, string $sslpath = null, string $sslcypher = null): bool
|
||||
{
|
||||
// Reset error variables
|
||||
/* 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;
|
||||
$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) {
|
||||
if ($booReturn === true) {
|
||||
mysqli_ssl_set($this->strDBId, $sslkey, $sslcert, $sslca, $sslpath, $sslcypher);
|
||||
}
|
||||
return($booReturn);
|
||||
return ($booReturn);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Close database server connectuon
|
||||
* @return bool true = successful / false = error
|
||||
*/
|
||||
private function dbDisconnect()
|
||||
{
|
||||
mysqli_close($this->strDBId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,90 +1,84 @@
|
||||
<?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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* ----------------------------------------------------------------------------
|
||||
NagiosQL
|
||||
-------------------------------------------------------------------------------
|
||||
(c) 2005-2022 by Martin Willisegger
|
||||
|
||||
Project : NagiosQL
|
||||
Component : Content Class
|
||||
Website : https://sourceforge.net/projects/nagiosql/
|
||||
Version : 3.5.0
|
||||
GIT Repo : https://gitlab.com/wizonet/NagiosQL
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
Class: Common content functions
|
||||
-------------------------------------------------------------------------------
|
||||
Includes all functions used to display the application data
|
||||
Name: NagContentClass
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
namespace functions;
|
||||
|
||||
use HTML_Template_IT;
|
||||
use function strlen;
|
||||
|
||||
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
|
||||
/* Define class variables */
|
||||
public $arrSession = array(); /* Array includes all global settings */
|
||||
public $arrDescription = array(); /* Session content */
|
||||
public $intLimit = 15; /* Text values from fieldvars.php */
|
||||
public $intDomainId = 0; /* Data limit value */
|
||||
public $intSortBy = -1; /* Configuration domain ID */
|
||||
public $intGlobalWriteAccess = -1; /* Sort by field id */
|
||||
public $intVersion = 0; /* Global write access id */
|
||||
public $intGroupAdm = 0; /* Nagios version id */
|
||||
public $intWriteAccessId = 0; /* Group admin enabled/disabled */
|
||||
public $strTableName = ''; /* Write access id */
|
||||
public $strSearchSession = ''; /* Data table name */
|
||||
public $strErrorMessage = ''; /* Search session name */
|
||||
public $strSortDir = 'ASC'; /* String including error messages */
|
||||
public $strBrowser = ''; /* SQL sort direction (ASC/DESC) */
|
||||
/** @var MysqliDbClass */
|
||||
public $myDBClass; // Database class reference
|
||||
public $myDBClass; /* Browser string */
|
||||
|
||||
/* Class includes */
|
||||
/** @var NagConfigClass */
|
||||
public $myConfigClass; // NagiosQL configuration class object
|
||||
public $myConfigClass; /* Database class reference */
|
||||
/** @var NagVisualClass */
|
||||
public $myVisClass; // NagiosQL visual class object
|
||||
public $myVisClass; /* NagiosQL configuration class object */
|
||||
private $arrSettings = array(); /* NagiosQL visual class object */
|
||||
|
||||
/**
|
||||
* NagContentClass constructor.
|
||||
* @param array $arrSession PHP Session array
|
||||
* @param array $arrSession PHP Session array
|
||||
*/
|
||||
public function __construct($arrSession)
|
||||
public function __construct(array $arrSession)
|
||||
{
|
||||
if (isset($arrSession['SETS'])) {
|
||||
// Read global settings
|
||||
/* Read global settings */
|
||||
$this->arrSettings = $arrSession['SETS'];
|
||||
}
|
||||
if (isset($arrSession['domain'])) {
|
||||
$this->intDomainId = $arrSession['domain'];
|
||||
$this->intDomainId = (int)$arrSession['domain'];
|
||||
}
|
||||
$this->arrSession = $arrSession;
|
||||
$this->arrSession = $arrSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data list view - form initialization
|
||||
* @param \HTML_Template_IT $objTemplate Form template object
|
||||
* @param HTML_Template_IT $objTemplate Form template object
|
||||
*/
|
||||
public function listViewInit($objTemplate)
|
||||
public function listViewInit(HTML_Template_IT $objTemplate): void
|
||||
{
|
||||
// Language text replacements from fieldvars.php file
|
||||
/* Language text replacements from fieldvars.php file */
|
||||
foreach ($this->arrDescription as $elem) {
|
||||
$objTemplate->setVariable($elem['name'], $elem['string']);
|
||||
}
|
||||
// Some single replacements
|
||||
/* Some single replacements */
|
||||
$objTemplate->setVariable('LIMIT', $this->intLimit);
|
||||
$objTemplate->setVariable('ACTION_MODIFY', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
|
||||
$objTemplate->setVariable('ACTION_MODIFY', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_UNSAFE_RAW));
|
||||
$objTemplate->setVariable('TABLE_NAME', $this->strTableName);
|
||||
if (isset($this->arrSession['search'][$this->strSearchSession])) {
|
||||
$objTemplate->setVariable('DAT_SEARCH', $this->arrSession['search'][$this->strSearchSession]);
|
||||
@@ -95,41 +89,42 @@ class NagContentClass
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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 Fieldname for data field 1
|
||||
* @param string $strField2 Fieldname 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
|
||||
HTML_Template_IT $objTemplate,
|
||||
array $arrData,
|
||||
int $intDLCount1,
|
||||
int $intDLCount2,
|
||||
string $strField1,
|
||||
string $strField2,
|
||||
int $intLimit = 0
|
||||
): void
|
||||
{
|
||||
/* Template block names */
|
||||
$strTplPart = 'datatable';
|
||||
$strTplRow = 'datarow';
|
||||
if ($this->strTableName == 'tbl_host') {
|
||||
$strTplRow = 'datarow';
|
||||
if ($this->strTableName === 'tbl_host') {
|
||||
$strTplPart = 'datatablehost';
|
||||
$strTplRow = 'datarowhost';
|
||||
$strTplRow = 'datarowhost';
|
||||
}
|
||||
if ($this->strTableName == 'tbl_service') {
|
||||
if ($this->strTableName === 'tbl_service') {
|
||||
$strTplPart = 'datatableservice';
|
||||
$strTplRow = 'datarowservice';
|
||||
$strTplRow = 'datarowservice';
|
||||
}
|
||||
if (($this->strTableName == 'tbl_user') || ($this->strTableName == 'tbl_group') ||
|
||||
($this->strTableName == 'tbl_datadomain') || ($this->strTableName == 'tbl_configtarget')) {
|
||||
if (($this->strTableName === 'tbl_user') || ($this->strTableName === 'tbl_group') ||
|
||||
($this->strTableName === 'tbl_datadomain') || ($this->strTableName === 'tbl_configtarget')) {
|
||||
$strTplPart = 'datatablecommon';
|
||||
$strTplRow = 'datarowcommon';
|
||||
$strTplRow = 'datarowcommon';
|
||||
}
|
||||
// Some single replacements
|
||||
$objTemplate->setVariable('IMAGE_PATH_HEAD', $this->arrSettings['path']['base_url']. 'images/');
|
||||
/* 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');
|
||||
@@ -141,13 +136,13 @@ class NagContentClass
|
||||
$objTemplate->setVariable('PICTURE_CLASS', 'elementHide');
|
||||
$objTemplate->setVariable('DOMAIN_SPECIAL', ' ');
|
||||
$objTemplate->setVariable('SORT_BY', $this->intSortBy);
|
||||
// Inserting data values
|
||||
if ($intDLCount1 != 0) {
|
||||
/* Inserting data values */
|
||||
if ($intDLCount1 !== 0) {
|
||||
$intMinID = 0;
|
||||
$intMaxID = 0;
|
||||
for ($i=0; $i<$intDLCount1; $i++) {
|
||||
// Get biggest and smalest value
|
||||
if ($i == 0) {
|
||||
for ($i = 0; $i < $intDLCount1; $i++) {
|
||||
/* Get biggest and smalest value */
|
||||
if ($i === 0) {
|
||||
$intMinID = $arrData[$i]['id'];
|
||||
$intMaxID = $arrData[$i]['id'];
|
||||
}
|
||||
@@ -159,27 +154,27 @@ class NagContentClass
|
||||
}
|
||||
$objTemplate->setVariable('MAX_ID', $intMaxID);
|
||||
$objTemplate->setVariable('MIN_ID', $intMinID);
|
||||
// Line colours
|
||||
/* Line colours */
|
||||
$strClassL = 'tdld';
|
||||
$strClassM = 'tdmd';
|
||||
if ($i%2 == 1) {
|
||||
if ($i % 2 === 1) {
|
||||
$strClassL = 'tdlb';
|
||||
$strClassM = 'tdmb';
|
||||
}
|
||||
if (isset($arrData[$i]['register']) && ($arrData[$i]['register'] == 0)) {
|
||||
if (isset($arrData[$i]['register']) && ((int)$arrData[$i]['register'] === 0)) {
|
||||
$strRegister = translate('No');
|
||||
} else {
|
||||
$strRegister = translate('Yes');
|
||||
}
|
||||
if ($arrData[$i]['active'] == 0) {
|
||||
$strActive = translate('No');
|
||||
if ((int)$arrData[$i]['active'] === 0) {
|
||||
$strActive = translate('No');
|
||||
} else {
|
||||
$strActive = translate('Yes');
|
||||
$strActive = translate('Yes');
|
||||
}
|
||||
// Get file date for hosts and services
|
||||
/* Get file date for hosts and services */
|
||||
$intTimeInfo = 0;
|
||||
$arrTimeData = array();
|
||||
if ($this->strTableName == 'tbl_host') {
|
||||
if ($this->strTableName === 'tbl_host') {
|
||||
$intReturn = $this->myConfigClass->lastModifiedDir(
|
||||
$this->strTableName,
|
||||
$arrData[$i]['host_name'],
|
||||
@@ -187,11 +182,11 @@ class NagContentClass
|
||||
$arrTimeData,
|
||||
$intTimeInfo
|
||||
);
|
||||
if ($intReturn == 1) {
|
||||
if ($intReturn === 1) {
|
||||
$this->strErrorMessage = $this->myConfigClass->strErrorMessage;
|
||||
}
|
||||
}
|
||||
if ($this->strTableName == 'tbl_service') {
|
||||
if ($this->strTableName === 'tbl_service') {
|
||||
$intReturn = $this->myConfigClass->lastModifiedDir(
|
||||
$this->strTableName,
|
||||
$arrData[$i]['config_name'],
|
||||
@@ -199,16 +194,16 @@ class NagContentClass
|
||||
$arrTimeData,
|
||||
$intTimeInfo
|
||||
);
|
||||
if ($intReturn == 1) {
|
||||
if ($intReturn === 1) {
|
||||
$this->strErrorMessage = $this->myConfigClass->strErrorMessage;
|
||||
}
|
||||
}
|
||||
// Set datafields
|
||||
/* 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'];
|
||||
if ((string)$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(
|
||||
@@ -216,7 +211,7 @@ class NagContentClass
|
||||
ENT_COMPAT,
|
||||
'UTF-8'
|
||||
)));
|
||||
if ($strField2 == 'process_field') {
|
||||
if ($strField2 === 'process_field') {
|
||||
$arrData[$i]['process_field'] = $this->processField($arrData[$i], $this->strTableName);
|
||||
} else {
|
||||
$objTemplate->setVariable('DATA_FIELD_2S', addslashes(htmlentities(
|
||||
@@ -225,8 +220,8 @@ class NagContentClass
|
||||
'UTF-8'
|
||||
)));
|
||||
}
|
||||
if ($intLimit != 0) {
|
||||
if (\strlen($arrData[$i][$strField2]) > $intLimit) {
|
||||
if ($intLimit !== 0) {
|
||||
if (strlen($arrData[$i][$strField2]) > $intLimit) {
|
||||
$strAdd = ' ...';
|
||||
} else {
|
||||
$strAdd = '';
|
||||
@@ -235,7 +230,7 @@ class NagContentClass
|
||||
$arrData[$i][$strField2],
|
||||
0,
|
||||
$intLimit
|
||||
), ENT_COMPAT, 'UTF-8').$strAdd);
|
||||
), ENT_COMPAT, 'UTF-8') . $strAdd);
|
||||
} else {
|
||||
$objTemplate->setVariable('DATA_FIELD_2', htmlentities(
|
||||
$arrData[$i][$strField2],
|
||||
@@ -244,130 +239,256 @@ class NagContentClass
|
||||
));
|
||||
}
|
||||
$objTemplate->setVariable('DATA_REGISTERED', $strRegister);
|
||||
if (substr_count($this->strTableName, 'template') != 0) {
|
||||
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', '<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 === 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 === 2) {
|
||||
$objTemplate->setVariable('DATA_FILE', '<span class="redmessage">' . translate('missed') . '</span>');
|
||||
}
|
||||
if ($intTimeInfo == 0) {
|
||||
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('IMAGE_PATH', $this->arrSettings['path']['base_url'] . 'images/');
|
||||
$objTemplate->setVariable('PICTURE_CLASS', 'elementShow');
|
||||
$objTemplate->setVariable('DOMAIN_SPECIAL', '');
|
||||
$objTemplate->setVariable('DISABLED', '');
|
||||
// Disable common domain objects
|
||||
$objTemplate->setVariable('DOMAIN_SPECIAL');
|
||||
$objTemplate->setVariable('DISABLED');
|
||||
/* Disable common domain objects */
|
||||
if (isset($arrData[$i]['config_id'])) {
|
||||
if ($arrData[$i]['config_id'] != $this->intDomainId) {
|
||||
if ((int)$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');
|
||||
}
|
||||
} else if ((int)$arrData[$i]['active'] === 0) {
|
||||
$objTemplate->setVariable('ACTIVE_CONTROL', 'elementHide');
|
||||
}
|
||||
}
|
||||
// Check access rights for list objects
|
||||
/* 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) {
|
||||
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) {
|
||||
/* 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->setVariable('IMAGE_PATH', $this->arrSettings['path']['base_url'] . 'images/');
|
||||
$objTemplate->parse($strTplRow);
|
||||
}
|
||||
$objTemplate->setVariable('BUTTON_CLASS', 'elementShow');
|
||||
if ($this->intDomainId == 0) {
|
||||
if ($this->intDomainId === 0) {
|
||||
$objTemplate->setVariable('BUTTON_CLASS', 'elementHide');
|
||||
}
|
||||
// Check access rights for adding new objects
|
||||
if ($this->intGlobalWriteAccess != 0) {
|
||||
/* Check access rights for adding new objects */
|
||||
if ($this->intGlobalWriteAccess !== 0) {
|
||||
$objTemplate->setVariable('ADD_CONTROL', 'disabled="disabled"');
|
||||
}
|
||||
// Show page numbers
|
||||
/* Show page numbers */
|
||||
$objTemplate->setVariable('PAGES', $this->myVisClass->buildPageLinks(filter_input(
|
||||
INPUT_SERVER,
|
||||
'PHP_SELF',
|
||||
FILTER_SANITIZE_STRING
|
||||
FILTER_UNSAFE_RAW
|
||||
), $intDLCount2, $this->intLimit, $this->intSortBy, $this->strSortDir));
|
||||
$objTemplate->parse($strTplPart);
|
||||
$objTemplate->show($strTplPart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process field view
|
||||
* @param array $arrData Data array
|
||||
* @param string $strTableName Table name
|
||||
* @return string String includung field data
|
||||
*/
|
||||
public function processField(array $arrData, string $strTableName): string
|
||||
{
|
||||
$strField = '';
|
||||
$arrDataHosts = array();
|
||||
$arrDataHostgroups = array();
|
||||
$arrDataService = array();
|
||||
$arrDataServices = array();
|
||||
/* Hostdependency table */
|
||||
if ($strTableName === 'tbl_hostdependency') {
|
||||
if ((int)$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 ((int)$elem['exclude'] === 1) {
|
||||
$strField .= 'H:!' . $elem['host_name'] . ',';
|
||||
} else {
|
||||
$strField .= 'H:' . $elem['host_name'] . ',';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((int)$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 ((int)$elem['exclude'] === 1) {
|
||||
$strField .= 'HG:!' . $elem['hostgroup_name'] . ',';
|
||||
} else {
|
||||
$strField .= 'HG:' . $elem['hostgroup_name'] . ',';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Hostescalation table */
|
||||
if ($strTableName === 'tbl_hostescalation') {
|
||||
if ((int)$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 ((int)$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 ((int)$arrData['dependent_service_description'] === 2) {
|
||||
$strField .= '*';
|
||||
} elseif ((int)$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 ((int)$arrData['service_description'] === 2) {
|
||||
$strField .= '*';
|
||||
} elseif ((int)$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 at line end */
|
||||
if (substr($strField, -1) === ',') {
|
||||
$strField = substr($strField, 0, -1);
|
||||
}
|
||||
return $strField;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @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 != '') {
|
||||
HTML_Template_IT $objTemplate,
|
||||
string $strErrorMessage,
|
||||
string $strInfoMessage,
|
||||
string $strConsistMessage,
|
||||
array $arrTimeData,
|
||||
string $strTimeInfoString,
|
||||
int $intNoTime = 0
|
||||
): void
|
||||
{
|
||||
/* Display info messages */
|
||||
if ($strInfoMessage !== '') {
|
||||
$objTemplate->setVariable('INFOMESSAGE', $strInfoMessage);
|
||||
$objTemplate->parse('infomessage');
|
||||
}
|
||||
// Display error messages
|
||||
if ($strErrorMessage != '') {
|
||||
/* Display error messages */
|
||||
if ($strErrorMessage !== '') {
|
||||
$objTemplate->setVariable('ERRORMESSAGE', $strErrorMessage);
|
||||
$objTemplate->parse('errormessage');
|
||||
}
|
||||
// Display time informations
|
||||
if (($this->intDomainId != 0) && ($intNoTime == 0)) {
|
||||
/* Display time information */
|
||||
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>');
|
||||
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->setVariable('LAST_MODIFIED_FILE', translate('Last file change of the configuration ' .
|
||||
'target ') . ' <i>' . $key . '</i>: <b>' . $elem . '</b>');
|
||||
$objTemplate->parse('file_time');
|
||||
}
|
||||
}
|
||||
if ($strTimeInfoString != '') {
|
||||
if ($strTimeInfoString !== '') {
|
||||
$objTemplate->setVariable('MODIFICATION_STATUS', $strTimeInfoString);
|
||||
$objTemplate->parse('modification_status');
|
||||
}
|
||||
}
|
||||
// Display consistency messages
|
||||
if ($strConsistMessage != '') {
|
||||
/* Display consistency messages */
|
||||
if ($strConsistMessage !== '') {
|
||||
$objTemplate->setVariable('CONSIST_USAGE', $strConsistMessage);
|
||||
$objTemplate->parse('consistency');
|
||||
}
|
||||
@@ -377,12 +498,12 @@ class NagContentClass
|
||||
|
||||
/**
|
||||
* Display page footer
|
||||
* @param \HTML_Template_IT $objTemplate Form template object
|
||||
* @param string $setFileVersion NagiosQL version
|
||||
* @param HTML_Template_IT $objTemplate Form template object
|
||||
* @param string $setFileVersion NagiosQL version
|
||||
*/
|
||||
public function showFooter($objTemplate, $setFileVersion)
|
||||
public function showFooter(HTML_Template_IT $objTemplate, string $setFileVersion): void
|
||||
{
|
||||
$objTemplate->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' ".
|
||||
$objTemplate->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' " .
|
||||
"target='_blank'>NagiosQL</a> $setFileVersion");
|
||||
$objTemplate->parse('footer');
|
||||
$objTemplate->show('footer');
|
||||
@@ -390,18 +511,18 @@ class NagContentClass
|
||||
|
||||
/**
|
||||
* Single data form initialization
|
||||
* @param \HTML_Template_IT $objTemplate Form template object
|
||||
* @param string $strChbFields Comma separated string of checkbox value names
|
||||
* @param HTML_Template_IT $objTemplate Form template object
|
||||
* @param string $strChbFields Comma separated string of checkbox value names
|
||||
*/
|
||||
public function addFormInit($objTemplate, $strChbFields = '')
|
||||
public function addFormInit(HTML_Template_IT $objTemplate, string $strChbFields = ''): void
|
||||
{
|
||||
// Language text replacements from fieldvars.php file
|
||||
/* 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/');
|
||||
/* Some single replacements */
|
||||
$objTemplate->setVariable('ACTION_INSERT', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_UNSAFE_RAW));
|
||||
$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');
|
||||
@@ -409,31 +530,31 @@ class NagContentClass
|
||||
$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('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) {
|
||||
if ($this->intGroupAdm === 0) {
|
||||
$objTemplate->setVariable('RESTRICT_GROUP_ADMIN', 'class="elementHide"');
|
||||
}
|
||||
if ($this->arrSettings['common']['seldisable'] == 0) {
|
||||
$objTemplate->setVariable('MSIE_DISABLED', '');
|
||||
if ((int)$this->arrSettings['common']['seldisable'] === 0) {
|
||||
$objTemplate->setVariable('MSIE_DISABLED');
|
||||
}
|
||||
if ($this->arrSettings['common']['tplcheck'] == 0) {
|
||||
if ((int)$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
|
||||
/* 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_30_MUST');
|
||||
$objTemplate->setVariable('VERSION_40_MUST');
|
||||
$objTemplate->setVariable('VERSION_20_STAR', '*');
|
||||
$objTemplate->setVariable('NAGIOS_VERSION', '2');
|
||||
}
|
||||
@@ -441,10 +562,10 @@ class NagContentClass
|
||||
$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_20_MUST');
|
||||
$objTemplate->setVariable('VERSION_30_MUST', 'inpmust');
|
||||
$objTemplate->setVariable('VERSION_40_MUST', '');
|
||||
$objTemplate->setVariable('VERSION_20_STAR', '');
|
||||
$objTemplate->setVariable('VERSION_40_MUST');
|
||||
$objTemplate->setVariable('VERSION_20_STAR');
|
||||
$objTemplate->setVariable('NAGIOS_VERSION', '3');
|
||||
}
|
||||
if ($this->intVersion >= 4) {
|
||||
@@ -452,194 +573,64 @@ class NagContentClass
|
||||
$objTemplate->setVariable('VERSION_40_MUST', 'inpmust');
|
||||
$objTemplate->setVariable('NAGIOS_VERSION', '4');
|
||||
}
|
||||
// Checkbox and radio field value replacements
|
||||
if ($strChbFields != '') {
|
||||
/* 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');
|
||||
$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
|
||||
* @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 = '')
|
||||
public function addInsertData(HTML_Template_IT $objTemplate, array $arrModifyData, int $intLocked, string $strInfo, string $strChbFields = ''): void
|
||||
{
|
||||
// Insert text data values
|
||||
/* Insert text data values */
|
||||
foreach ($arrModifyData as $key => $value) {
|
||||
if (($key == 'active') || ($key == 'register') || ($key == 'last_modified') || ($key == 'access_rights')) {
|
||||
if (($key === 'active') || ($key === 'register') || ($key === 'last_modified') || ($key === 'access_rights')) {
|
||||
continue;
|
||||
}
|
||||
$objTemplate->setVariable('DAT_' .strtoupper($key), htmlentities($value, ENT_QUOTES, 'UTF-8'));
|
||||
$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', '');
|
||||
/* Insert checkbox data values */
|
||||
if (isset($arrModifyData['active']) && ((int)$arrModifyData['active'] !== 1)) {
|
||||
$objTemplate->setVariable('ACT_CHECKED');
|
||||
}
|
||||
if (isset($arrModifyData['register']) && ($arrModifyData['register'] != 1)) {
|
||||
$objTemplate->setVariable('REG_CHECKED', '');
|
||||
if (isset($arrModifyData['register']) && ((int)$arrModifyData['register'] !== 1)) {
|
||||
$objTemplate->setVariable('REG_CHECKED');
|
||||
}
|
||||
// Deselect any checkboxes
|
||||
if ($strChbFields != '') {
|
||||
/* 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', '');
|
||||
$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) {
|
||||
/* 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
|
||||
/* Change mode to modify */
|
||||
$objTemplate->setVariable('MODUS', 'modify');
|
||||
// Check write permission
|
||||
if ($this->intWriteAccessId == 1) {
|
||||
/* Check write permission */
|
||||
if ($this->intWriteAccessId === 1) {
|
||||
$objTemplate->setVariable('DISABLE_SAVE', 'disabled="disabled"');
|
||||
}
|
||||
if ($this->intGlobalWriteAccess == 1) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,15 @@
|
||||
/*
|
||||
(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
|
||||
/**
|
||||
* (c) 2005-2022 by Martin Willisegger
|
||||
* Project : NagiosQL
|
||||
* Component : common JavaScript functions
|
||||
* Website : https://sourceforge.net/projects/nagiosql/
|
||||
* Version : 3.5.0
|
||||
* GIT Repo : https://gitlab.com/wizonet/NagiosQL
|
||||
*/
|
||||
let popup = false;
|
||||
function info(key1,key2,ver) {
|
||||
if(popup && popup.closed === false) popup.close();
|
||||
|
||||
function info(key1, key2, ver) {
|
||||
if (popup && popup.closed === false) popup.close();
|
||||
const top = (screen.availHeight - 240) / 2;
|
||||
const left = (screen.availWidth - 320) / 2;
|
||||
popup = window.open("info.php?key1=" + key1 + "&key2=" + key2 + "&version=" + ver,
|
||||
@@ -19,9 +20,9 @@ function info(key1,key2,ver) {
|
||||
|
||||
const myFocusObject = {};
|
||||
|
||||
function checkfields(fields,frm,object) {
|
||||
function checkfields(fields, frm, object) {
|
||||
const ar_field = fields.split(",");
|
||||
for (let i=0;i<ar_field.length;i++){
|
||||
for (let i = 0; i < ar_field.length; i++) {
|
||||
if (frm[ar_field[i]].value === "") {
|
||||
//frm[ar_field[i]].focus();
|
||||
object.myValue = frm[ar_field[i]];
|
||||
@@ -30,9 +31,10 @@ function checkfields(fields,frm,object) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function checkfields2(fields,frm,object) {
|
||||
|
||||
function checkfields2(fields, frm, object) {
|
||||
const ar_field = fields.split(",");
|
||||
for (let i=0;i<ar_field.length;i++){
|
||||
for (let i = 0; i < ar_field.length; i++) {
|
||||
if ((frm[ar_field[i]].value === "") || (frm[ar_field[i]].value === "0")) {
|
||||
//frm[ar_field[i]].focus();
|
||||
object.myValue = frm[ar_field[i]];
|
||||
@@ -41,10 +43,11 @@ function checkfields2(fields,frm,object) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function checkboxes(fields,frm) {
|
||||
|
||||
function checkboxes(fields, frm) {
|
||||
let retval = false;
|
||||
const ar_field = fields.split(",");
|
||||
for (let i=0;i<ar_field.length;i++){
|
||||
for (let i = 0; i < ar_field.length; i++) {
|
||||
if (frm[ar_field[i]].checked === true) {
|
||||
retval = true;
|
||||
}
|
||||
@@ -53,7 +56,7 @@ function checkboxes(fields,frm) {
|
||||
}
|
||||
|
||||
<!-- YUI message box -->
|
||||
function msginit(msg,header,type) {
|
||||
function msginit(msg, header, type) {
|
||||
let iconobj;
|
||||
YAHOO.namespace("msg.container");
|
||||
const handleOK = function () {
|
||||
@@ -67,7 +70,8 @@ function msginit(msg,header,type) {
|
||||
iconobj = YAHOO.widget.SimpleDialog.ICON_HELP;
|
||||
}
|
||||
YAHOO.msg.container.domainmsg = new YAHOO.widget.SimpleDialog("domainmsg",
|
||||
{ width: "300px",
|
||||
{
|
||||
width: "300px",
|
||||
fixedcenter: true,
|
||||
visible: false,
|
||||
draggable: false,
|
||||
@@ -76,15 +80,15 @@ function msginit(msg,header,type) {
|
||||
modal: true,
|
||||
icon: iconobj,
|
||||
constraintoviewport: true,
|
||||
buttons: [ { text:"Ok", handler:handleOK, isDefault:true } ]
|
||||
} );
|
||||
buttons: [{text: "Ok", handler: handleOK, isDefault: true}]
|
||||
});
|
||||
YAHOO.msg.container.domainmsg.setHeader(header);
|
||||
YAHOO.msg.container.domainmsg.render("msgcontainer");
|
||||
YAHOO.msg.container.domainmsg.show();
|
||||
}
|
||||
|
||||
<!-- YUI confirm box -->
|
||||
function confirminit(msg,header,type,yes,no,key) {
|
||||
function confirminit(msg, header, type, yes, no, key) {
|
||||
let iconobj;
|
||||
YAHOO.namespace("question.container");
|
||||
const handleYes = function () {
|
||||
@@ -99,7 +103,8 @@ function confirminit(msg,header,type,yes,no,key) {
|
||||
iconobj = YAHOO.widget.SimpleDialog.ICON_WARN;
|
||||
}
|
||||
YAHOO.question.container.domainmsg = new YAHOO.widget.SimpleDialog("confirm1",
|
||||
{ width: "400px",
|
||||
{
|
||||
width: "400px",
|
||||
fixedcenter: true,
|
||||
visible: false,
|
||||
draggable: false,
|
||||
@@ -108,9 +113,9 @@ function confirminit(msg,header,type,yes,no,key) {
|
||||
modal: true,
|
||||
icon: iconobj,
|
||||
constraintoviewport: true,
|
||||
buttons: [ { text:yes, handler:handleYes, isDefault:true },
|
||||
{ text:no, handler:handleNo }]
|
||||
} );
|
||||
buttons: [{text: yes, handler: handleYes, isDefault: true},
|
||||
{text: no, handler: handleNo}]
|
||||
});
|
||||
YAHOO.question.container.domainmsg.setHeader(header);
|
||||
YAHOO.question.container.domainmsg.render("confirmcontainer");
|
||||
YAHOO.question.container.domainmsg.show();
|
||||
@@ -118,7 +123,7 @@ function confirminit(msg,header,type,yes,no,key) {
|
||||
|
||||
|
||||
<!-- YUI dialog box -->
|
||||
function dialoginit(key1,key2,ver,header) {
|
||||
function dialoginit(key1, key2, ver, header) {
|
||||
YAHOO.namespace("dialog.container");
|
||||
|
||||
const handleCancel = function () {
|
||||
@@ -149,12 +154,13 @@ function dialoginit(key1,key2,ver,header) {
|
||||
|
||||
if (typeof YAHOO.dialog.container.infodialog === "undefined") {
|
||||
YAHOO.dialog.container.infodialog = new YAHOO.widget.Dialog("infodialog",
|
||||
{ width : "50em",
|
||||
visible : false,
|
||||
{
|
||||
width: "50em",
|
||||
visible: false,
|
||||
draggable: true,
|
||||
fixedcenter: true,
|
||||
constraintoviewport : true,
|
||||
buttons : [ { text:"Ok", handler:handleCancel, isDefault:true } ]
|
||||
constraintoviewport: true,
|
||||
buttons: [{text: "Ok", handler: handleCancel, isDefault: true}]
|
||||
});
|
||||
|
||||
}
|
||||
@@ -165,18 +171,18 @@ function dialoginit(key1,key2,ver,header) {
|
||||
}
|
||||
|
||||
<!-- YUI calendar -->
|
||||
function calendarinit(lang,start,field,key,cont,obj) {
|
||||
YAHOO.util.Event.onDOMReady(function(){
|
||||
function calendarinit(lang, start, field, key, cont, obj) {
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
|
||||
let dialog, calendar;
|
||||
|
||||
calendar = new YAHOO.widget.Calendar(obj, {
|
||||
iframe:false,
|
||||
hide_blank_weeks:true,
|
||||
START_WEEKDAY:start
|
||||
iframe: false,
|
||||
hide_blank_weeks: true,
|
||||
START_WEEKDAY: start
|
||||
});
|
||||
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"]);
|
||||
}
|
||||
|
||||
@@ -185,31 +191,35 @@ function calendarinit(lang,start,field,key,cont,obj) {
|
||||
//}
|
||||
|
||||
//function handleSelect(type,args,obj) {
|
||||
function handleSelect(type,args) {
|
||||
function handleSelect(type, args) {
|
||||
const dates = args[0];
|
||||
const date = dates[0];
|
||||
const year = date[0];
|
||||
let month = date[1], day = date[2];
|
||||
|
||||
const txtDate1 = document.getElementById(field);
|
||||
if (month < 10) { month = "0" + month;}
|
||||
if (day < 10) { day = "0" + day;}
|
||||
if (month < 10) {
|
||||
month = "0" + month;
|
||||
}
|
||||
if (day < 10) {
|
||||
day = "0" + day;
|
||||
}
|
||||
// noinspection JSUndefinedPropertyAssignment
|
||||
txtDate1.value = year + "-" + month + "-" + day;
|
||||
dialog.hide();
|
||||
}
|
||||
|
||||
dialog = new YAHOO.widget.Dialog(cont, {
|
||||
context:[field, "tl", "bl"],
|
||||
width:"16em",
|
||||
draggable:true,
|
||||
close:true
|
||||
context: [field, "tl", "bl"],
|
||||
width: "16em",
|
||||
draggable: true,
|
||||
close: true
|
||||
});
|
||||
calendar.render();
|
||||
dialog.render();
|
||||
dialog.hide();
|
||||
|
||||
calendar.renderEvent.subscribe(function() {
|
||||
calendar.renderEvent.subscribe(function () {
|
||||
dialog.fireEvent("changeContent");
|
||||
});
|
||||
// noinspection JSUnresolvedVariable
|
||||
@@ -220,9 +230,9 @@ function calendarinit(lang,start,field,key,cont,obj) {
|
||||
}
|
||||
|
||||
// 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(){
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
|
||||
let mutdialog;
|
||||
|
||||
@@ -269,7 +279,7 @@ function openMutDlgInit(field,divbox,header,key,langkey1,langkey2,exclude) {
|
||||
}
|
||||
this.cancel();
|
||||
// noinspection JSUnresolvedVariable
|
||||
if ((typeof(update) === 'number') && (update === 1)) {
|
||||
if ((typeof (update) === 'number') && (update === 1)) {
|
||||
// noinspection JSUnresolvedFunction
|
||||
updateForm(field);
|
||||
}
|
||||
@@ -278,20 +288,21 @@ function openMutDlgInit(field,divbox,header,key,langkey1,langkey2,exclude) {
|
||||
this.cancel();
|
||||
};
|
||||
mutdialog = new YAHOO.widget.Dialog(divbox,
|
||||
{ width : "60em",
|
||||
fixedcenter : true,
|
||||
visible : false,
|
||||
{
|
||||
width: "60em",
|
||||
fixedcenter: true,
|
||||
visible: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
constraintoviewport : true,
|
||||
buttons : [ { text:langkey1, handler:handleSave, isDefault:true },
|
||||
{ text:langkey2, handler:handleCancel } ]
|
||||
constraintoviewport: true,
|
||||
buttons: [{text: langkey1, handler: handleSave, isDefault: true},
|
||||
{text: langkey2, handler: handleCancel}]
|
||||
});
|
||||
|
||||
mutdialog.setHeader(header);
|
||||
mutdialog.render();
|
||||
mutdialog.hide();
|
||||
mutdialog.beforeShowEvent.subscribe(function() {
|
||||
mutdialog.beforeShowEvent.subscribe(function () {
|
||||
getData(field);
|
||||
});
|
||||
|
||||
@@ -304,12 +315,12 @@ function getData(field) {
|
||||
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++) {
|
||||
for (let i = 0; i < targetSelect.length; i++) {
|
||||
targetSelect.options[i] = null;
|
||||
}
|
||||
// noinspection JSUndefinedPropertyAssignment
|
||||
targetSelect.length = 0;
|
||||
for (let i=0; i < targetAvail.length; i++) {
|
||||
for (let i = 0; i < targetAvail.length; i++) {
|
||||
targetAvail.options[i] = null;
|
||||
}
|
||||
// noinspection JSUndefinedPropertyAssignment
|
||||
@@ -333,6 +344,7 @@ function getData(field) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert selection
|
||||
function selValue(field) {
|
||||
const targetSelect = document.getElementById(field + 'Selected');
|
||||
@@ -350,11 +362,12 @@ function selValue(field) {
|
||||
}
|
||||
sort(targetSelect);
|
||||
DelOptions.reverse();
|
||||
for (let i=0; i<DelOptions.length; ++i) {
|
||||
for (let i = 0; i < DelOptions.length; ++i) {
|
||||
targetAvail.options[DelOptions[i]] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert selection (exclude variant)
|
||||
function selValueEx(field) {
|
||||
const targetSelect = document.getElementById(field + 'Selected');
|
||||
@@ -381,6 +394,7 @@ function selValueEx(field) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove selection
|
||||
function desValue(field) {
|
||||
const targetSelect = document.getElementById(field + 'Selected');
|
||||
@@ -405,14 +419,15 @@ function desValue(field) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort entries
|
||||
function sort(obj){
|
||||
function sort(obj) {
|
||||
const sortieren = [];
|
||||
const list = [];
|
||||
let i;
|
||||
|
||||
// Insert list to array
|
||||
for (i=0; i < obj.options.length; i++) {
|
||||
for (i = 0; i < obj.options.length; i++) {
|
||||
list[i] = [];
|
||||
list[i]["text"] = obj.options[i].text;
|
||||
list[i]["value"] = obj.options[i].value;
|
||||
@@ -420,15 +435,15 @@ function sort(obj){
|
||||
}
|
||||
|
||||
// Sort into a single dimension array
|
||||
for (i=0; i < obj.length; i++){
|
||||
sortieren[i]=list[i]["text"]+";"+list[i]["value"]+";"+list[i]["className"];
|
||||
for (i = 0; i < obj.length; i++) {
|
||||
sortieren[i] = list[i]["text"] + ";" + list[i]["value"] + ";" + list[i]["className"];
|
||||
}
|
||||
|
||||
// Real sort
|
||||
sortieren.sort();
|
||||
|
||||
// Make array to list
|
||||
for (i=0; i < sortieren.length; i++) {
|
||||
for (i = 0; i < sortieren.length; i++) {
|
||||
const felder = sortieren[i].split(";");
|
||||
list[i]["text"] = felder[0];
|
||||
list[i]["value"] = felder[1];
|
||||
@@ -436,7 +451,7 @@ function sort(obj){
|
||||
}
|
||||
|
||||
// Remove list field
|
||||
for (i=0; i < obj.options.length; i++) {
|
||||
for (i = 0; i < obj.options.length; i++) {
|
||||
obj.options[i] = null;
|
||||
}
|
||||
|
||||
@@ -448,6 +463,7 @@ function sort(obj){
|
||||
obj.options[i] = NeuerEintrag;
|
||||
}
|
||||
}
|
||||
|
||||
// Show relation data
|
||||
function showRelationData(option) {
|
||||
if (option === 1) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,201 +1,241 @@
|
||||
<?php
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NagiosQL
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (c) 2005-2018 by Martin Willisegger
|
||||
//
|
||||
// Project : NagiosQL
|
||||
// Component : Preprocessing script for content pages
|
||||
// Website : https://sourceforge.net/projects/nagiosql/
|
||||
// Version : 3.4.0
|
||||
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Define common variables
|
||||
// =======================
|
||||
$intLineCount = 0; // Database line count
|
||||
$intWriteAccessId = 0; // Write access to data id ($chkDataId)
|
||||
$intReadAccessId = 0; // Read access to data id ($chkListId)
|
||||
$intDataWarning = 0; // Missing data indicator
|
||||
$intNoTime = 0; // Show modified time list (0=show)
|
||||
$strSearchWhere = ''; // SQL WHERE addon for searching
|
||||
$strSearchWhere2 = ''; // SQL WHERE addon for configuration selection list
|
||||
$chkTfValue3 = '';
|
||||
$chkTfValue5 = '';
|
||||
//
|
||||
// Define missing variables used in this prepend file
|
||||
// ==================================================
|
||||
if (!isset($preTableName)) {
|
||||
$preTableName = '';
|
||||
} // Predefined variable table name
|
||||
if (!isset($preSearchSession)) {
|
||||
$preSearchSession = '';
|
||||
} // Predefined variable search session
|
||||
//
|
||||
// Store some variables to content class
|
||||
// =====================================
|
||||
$myContentClass->intLimit = $chkLimit;
|
||||
/** @var int $intVersion - defined in prepend_adm.php */
|
||||
$myContentClass->intVersion = $intVersion;
|
||||
$myContentClass->strBrowser = $preBrowser;
|
||||
$myContentClass->intGroupAdm = $chkGroupAdm;
|
||||
$myContentClass->strTableName = $preTableName;
|
||||
$myContentClass->strSearchSession = $preSearchSession;
|
||||
$myContentClass->intSortBy = $hidSortBy;
|
||||
$myContentClass->strSortDir = $hidSortDir;
|
||||
//
|
||||
// Process get parameters
|
||||
// ======================
|
||||
$chkFromLine = filter_input(INPUT_GET, 'from_line', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
||||
//
|
||||
// Process post parameters
|
||||
// =======================
|
||||
$chkTfSearchRaw = filter_input(INPUT_POST, 'txtSearch', FILTER_SANITIZE_STRING);
|
||||
$chkSelAccGr = filter_input(INPUT_POST, 'selAccGr', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
||||
$chkSelCnfName = filter_input(INPUT_POST, 'selCnfName', FILTER_SANITIZE_STRING);
|
||||
//
|
||||
// Common text field value
|
||||
for ($i = 1; $i <= 22; $i++) {
|
||||
$tmpVar = 'chkTfValue'.$i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'tfValue'.$i, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
|
||||
if (get_magic_quotes_gpc() == 0) {
|
||||
$$tmpVar = addslashes($$tmpVar);
|
||||
}
|
||||
if (isset($$tmpVar)) {
|
||||
$$tmpVar = $myVisClass->tfSecure($$tmpVar);
|
||||
}
|
||||
}
|
||||
// Common argument text field value
|
||||
for ($i = 1; $i <= 8; $i++) {
|
||||
$tmpVar = 'chkTfArg'.$i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'tfArg'.$i, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
|
||||
if (get_magic_quotes_gpc() == 0) {
|
||||
$$tmpVar = addslashes($$tmpVar);
|
||||
}
|
||||
if (isset($$tmpVar)) {
|
||||
$$tmpVar = $myVisClass->tfSecure($$tmpVar);
|
||||
}
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
NagiosQL
|
||||
-------------------------------------------------------------------------------
|
||||
(c) 2005-2022 by Martin Willisegger
|
||||
|
||||
// Common multi select field value
|
||||
Project : NagiosQL
|
||||
Component : Preprocessing script for content pages
|
||||
Website : https://sourceforge.net/projects/nagiosql/
|
||||
Version : 3.5.0
|
||||
GIT Repo : https://gitlab.com/wizonet/NagiosQL
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
use functions\MysqliDbClass;
|
||||
use functions\NagConfigClass;
|
||||
use functions\NagContentClass;
|
||||
use functions\NagDataClass;
|
||||
use functions\NagVisualClass;
|
||||
|
||||
/**
|
||||
* Class and variable includes
|
||||
* @var NagContentClass $myContentClass NagiosQL content class
|
||||
* @var NagVisualClass $myVisClass Visual content class
|
||||
* @var MysqliDbClass $myDBClass MySQL database class
|
||||
* @var NagConfigClass $myConfigClass NagiosQL configuration class
|
||||
* @var NagDataClass $myDataClass NagiosQL data class
|
||||
* @var HTML_Template_IT $mastertp Master template (list view)
|
||||
* @var string $chkLimit from prepend_adm.php / settings -> Data set count per page
|
||||
* @var string $preBrowser from prepend_adm.php -> Browser version
|
||||
* @var string $chkGroupAdm from prepend_adm.php -> Session value group admin
|
||||
* @var string $hidSortBy from prepend_adm.php -> Sort data by
|
||||
* @var string $hidSortDir from prepend_adm.php -> Sort data direction (ASC, DESC)
|
||||
* @var string $chkModus from prepend_adm.php -> Form work mode
|
||||
* @var string $chkRegister from prepend_adm.php -> Register checkbox
|
||||
* @var string $preKeyField from content file -> Table key field
|
||||
* @var string $strDomainWhere from prepend_adm.php -> Domain selection SQL part with table name
|
||||
* @var string $chkSelModify from prepend_adm.php -> Modification selection value
|
||||
* @var string $strInfoMessage from prepend_adm.php -> Information messages
|
||||
* @var string $chkSelTarDom from prepend_adm.php -> Target domain
|
||||
* @var int $intVersion from prepend_adm.php -> Nagios version
|
||||
* @var int $hidActive from prepend_adm.php -> (hidden) active checkbox
|
||||
* @var int $chkActive from prepend_adm.php -> Active checkbox
|
||||
* @var int $chkDomainId from prepend_adm.php -> Configuration domain id
|
||||
* @var int $chkDataId from prepend_adm.php -> Actual dataset id
|
||||
* @var int $chkListId from prepend_adm.php -> Actual dataset id (list view)
|
||||
* @var int $intGlobalWriteAccess from prepend_content.php -> Global admin write access
|
||||
*/
|
||||
/*
|
||||
Define common variables
|
||||
*/
|
||||
$intLineCount = 0; /* Database line count */
|
||||
$intWriteAccessId = 0; /* Write access to data id ($chkDataId) */
|
||||
$intReadAccessId = 0; /* Read access to data id ($chkListId) */
|
||||
$intDataWarning = 0; /* Missing data indicator */
|
||||
$intNoTime = 0; /* Show modified time list (0=show) */
|
||||
$strSearchWhere = ''; /* SQL WHERE addon for searching */
|
||||
$strSearchWhere2 = ''; /* SQL WHERE addon for configuration selection list */
|
||||
$chkTfValue3 = '';
|
||||
$chkTfValue5 = '';
|
||||
/*
|
||||
Define missing variables used in this prepend file
|
||||
*/
|
||||
if (!isset($preTableName)) {
|
||||
/* Predefined variable table name */
|
||||
$preTableName = '';
|
||||
}
|
||||
if (!isset($preSearchSession)) {
|
||||
/* Predefined variable search session */
|
||||
$preSearchSession = '';
|
||||
}
|
||||
/*
|
||||
Store some variables to content class
|
||||
*/
|
||||
$myContentClass->intLimit = $chkLimit;
|
||||
$myContentClass->intVersion = $intVersion;
|
||||
$myContentClass->strBrowser = $preBrowser;
|
||||
$myContentClass->intGroupAdm = $chkGroupAdm;
|
||||
$myContentClass->strTableName = $preTableName;
|
||||
$myContentClass->strSearchSession = $preSearchSession;
|
||||
$myContentClass->intSortBy = $hidSortBy;
|
||||
$myContentClass->strSortDir = $hidSortDir;
|
||||
/*
|
||||
Process get parameters
|
||||
*/
|
||||
$chkFromLine = filter_input(INPUT_GET, 'from_line', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
||||
/*
|
||||
Process post parameters
|
||||
*/
|
||||
$chkTfSearchRaw = filter_input(INPUT_POST, 'txtSearch');
|
||||
$chkSelAccGr = filter_input(INPUT_POST, 'selAccGr', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
||||
$chkSelCnfName = filter_input(INPUT_POST, 'selCnfName');
|
||||
$chkSelRegFilter = filter_input(INPUT_POST, 'selRegFilter', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
||||
$chkSelActiveFilter = filter_input(INPUT_POST, 'selActiveFilter', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
||||
/* Common text field value */
|
||||
for ($i = 1; $i <= 23; $i++) {
|
||||
$tmpVar = 'chkTfValue' . $i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'tfValue' . $i, FILTER_DEFAULT, FILTER_FLAG_NO_ENCODE_QUOTES);
|
||||
$$tmpVar = $myVisClass->tfSecure(addslashes($$tmpVar));
|
||||
}
|
||||
/* Common argument text field value */
|
||||
for ($i = 1; $i <= 8; $i++) {
|
||||
$tmpVar = 'chkMselValue'.$i;
|
||||
$tmpVar2 = 'intMselValue'.$i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'mselValue'.$i, FILTER_SANITIZE_STRING, FILTER_FORCE_ARRAY);
|
||||
// Multiselect data processing
|
||||
if ((${$tmpVar}[0] == '') || (${$tmpVar}[0] == '0')) {
|
||||
$$tmpVar2 = 0;
|
||||
} elseif (${$tmpVar}[0] == '*') {
|
||||
$$tmpVar2 = 2;
|
||||
} else {
|
||||
$$tmpVar2 = 1;
|
||||
$tmpVar = 'chkTfArg' . $i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'tfArg' . $i, FILTER_UNSAFE_RAW);
|
||||
$$tmpVar = $myVisClass->tfSecure(addslashes($$tmpVar));
|
||||
}
|
||||
/* Common argument info field value */
|
||||
for ($i = 1; $i <= 8; $i++) {
|
||||
$tmpVar = 'chkTaArg' . $i . 'Info';
|
||||
$$tmpVar = filter_input(INPUT_POST, 'taArg' . $i . 'Info', FILTER_UNSAFE_RAW);
|
||||
$$tmpVar = $myVisClass->tfSecure(addslashes($$tmpVar));
|
||||
}
|
||||
/* Common multi select field value */
|
||||
for ($i = 1; $i <= 8; $i++) {
|
||||
$tmpVar = 'chkMselValue' . $i;
|
||||
$tmpVar2 = 'intMselValue' . $i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'mselValue' . $i, FILTER_DEFAULT, FILTER_FORCE_ARRAY);
|
||||
/* Multiselect-data processing */
|
||||
if (isset(${$tmpVar}[0])) {
|
||||
if ((${$tmpVar}[0] === '') || (${$tmpVar}[0] === '0')) {
|
||||
$$tmpVar2 = 0;
|
||||
} elseif (${$tmpVar}[0] === '*') {
|
||||
$$tmpVar2 = 2;
|
||||
} else {
|
||||
$$tmpVar2 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Common select field value
|
||||
/* Common select field value */
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$tmpVar = 'chkSelValue'.$i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'selValue'.$i, FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
||||
$tmpVar = 'chkSelValue' . $i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'selValue' . $i, FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
||||
}
|
||||
//Common radio field value
|
||||
/* Common radio field value */
|
||||
for ($i = 1; $i <= 18; $i++) {
|
||||
$tmpVar = 'chkRadValue'.$i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'radValue'.$i, FILTER_VALIDATE_INT, array('options' => array('default' => 2)));
|
||||
$tmpVar = 'chkRadValue' . $i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'radValue' . $i, FILTER_VALIDATE_INT, array('options' => array('default' => 2)));
|
||||
}
|
||||
// Common checkbox group
|
||||
/* Common checkbox group */
|
||||
$arrChar = explode(';', 'a;b;c;d;e;f;g;h');
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
foreach ($arrChar as $elem) {
|
||||
$tmpVar = 'chkChbGr'.$i.$elem;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'chbGr'.$i.$elem, FILTER_SANITIZE_STRING);
|
||||
if ($$tmpVar != '') {
|
||||
$tmpVar = 'chkChbGr' . $i . $elem;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'chbGr' . $i . $elem);
|
||||
if (isset($$tmpVar) && ($$tmpVar !== '')) {
|
||||
$$tmpVar .= ',';
|
||||
}
|
||||
}
|
||||
}
|
||||
// Common button value
|
||||
/* Common button value */
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$tmpVar = 'chkButValue'.$i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'butValue'.$i, FILTER_SANITIZE_STRING);
|
||||
$tmpVar = 'chkButValue' . $i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'butValue' . $i);
|
||||
}
|
||||
// Common text NULL field value
|
||||
/* Common text NULL field value */
|
||||
for ($i = 1; $i <= 9; $i++) {
|
||||
$tmpVar = 'chkTfNullVal'.$i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'tfNullVal'.$i, FILTER_SANITIZE_STRING);
|
||||
if (isset($$tmpVar) && ($$tmpVar != '')) {
|
||||
$myVisClass->checkNull($$tmpVar);
|
||||
$tmpVar = 'chkTfNullVal' . $i;
|
||||
$$tmpVar = filter_input(INPUT_POST, 'tfNullVal' . $i);
|
||||
if (isset($$tmpVar) && ($$tmpVar !== '')) {
|
||||
$$tmpVar = $myVisClass->checkNull($$tmpVar);
|
||||
} else {
|
||||
$$tmpVar = 'NULL';
|
||||
}
|
||||
}
|
||||
// Common checkbox field value
|
||||
/* Common checkbox field value */
|
||||
$chkChbValue1 = filter_input(INPUT_POST, 'chbValue1', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
||||
$chkChbValue2 = filter_input(INPUT_POST, 'chbValue2', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
||||
// Common file selection field
|
||||
$chkDatValue1 = filter_input(INPUT_POST, 'datValue1', FILTER_SANITIZE_STRING);
|
||||
// Common text area value
|
||||
/* Common file selection field */
|
||||
$chkDatValue1 = filter_input(INPUT_POST, 'datValue1');
|
||||
/* Common text area value */
|
||||
$chkTaValue1Raw = filter_input(INPUT_POST, 'taValue1', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
// Common text area value for file import (not SQL)
|
||||
$chkTaFileTextRaw = filter_input(INPUT_POST, 'taFileText', FILTER_UNSAFE_RAW);
|
||||
//
|
||||
// Quote special characters
|
||||
// ==========================
|
||||
if (get_magic_quotes_gpc() == 0) {
|
||||
$chkTfSearchRaw = addslashes($chkTfSearchRaw);
|
||||
$chkTaValue1Raw = addslashes($chkTaValue1Raw);
|
||||
$chkTaFileTextRaw = addslashes($chkTaFileTextRaw);
|
||||
/* Common text area value for file import (not SQL) */
|
||||
$chkTaFileTextRaw = filter_input(INPUT_POST, 'taFileText');
|
||||
/* Common text field with special chars */
|
||||
$chkTfSpValue1 = filter_input(INPUT_POST, 'tfSpValue1');
|
||||
/*
|
||||
Quote special characters
|
||||
*/
|
||||
$chkTfSearchRaw = addslashes($chkTfSearchRaw);
|
||||
$chkTaValue1Raw = addslashes($chkTaValue1Raw);
|
||||
$chkTaFileTextRaw = addslashes($chkTaFileTextRaw);
|
||||
$chkTfSpValue1 = addslashes($chkTfSpValue1);
|
||||
/*
|
||||
Security function for text fields
|
||||
*/
|
||||
$chkTfSearch = $myVisClass->tfSecure($chkTfSearchRaw);
|
||||
$chkTaValue1 = $myVisClass->tfSecure($chkTaValue1Raw);
|
||||
$chkTfSpValue1 = $myVisClass->tfSecure($chkTfSpValue1);
|
||||
$chkTaFileText = stripslashes($chkTaFileTextRaw);
|
||||
/*
|
||||
Search/sort/filter - session data
|
||||
*/
|
||||
if (!isset($_SESSION['search'][$preSearchSession])) {
|
||||
$_SESSION['search'][$preSearchSession] = '';
|
||||
}
|
||||
//
|
||||
// Security function for text fields
|
||||
// =================================
|
||||
$chkTfSearch = $myVisClass->tfSecure($chkTfSearchRaw);
|
||||
$chkTaValue1 = $myVisClass->tfSecure($chkTaValue1Raw);
|
||||
$chkTaFileText = stripslashes($chkTaFileTextRaw);
|
||||
//
|
||||
// Search/sort/filter - session data
|
||||
// =================================
|
||||
if (!isset($_SESSION['search']) || !isset($_SESSION['search'][$preSearchSession])) {
|
||||
$_SESSION['search'][$preSearchSession] = '';
|
||||
if (!isset($_SESSION['filter'][$preSearchSession]['registered'])) {
|
||||
$_SESSION['filter'][$preSearchSession]['registered'] = '';
|
||||
}
|
||||
if (!isset($_SESSION['search']) || !isset($_SESSION['search']['config_selection'])) {
|
||||
if (!isset($_SESSION['filter'][$preSearchSession]['active'])) {
|
||||
$_SESSION['filter'][$preSearchSession]['active'] = '';
|
||||
}
|
||||
if (!isset($_SESSION['search']['config_selection'])) {
|
||||
$_SESSION['search']['config_selection'] = '';
|
||||
}
|
||||
if (($chkModus == 'checkform') || ($chkModus == 'filter')) {
|
||||
$_SESSION['search'][$preSearchSession] = $chkTfSearch;
|
||||
if (($chkModus === 'checkform') || ($chkModus === 'filter')) {
|
||||
$_SESSION['search'][$preSearchSession] = $chkTfSearch;
|
||||
$_SESSION['search']['config_selection'] = $chkSelCnfName;
|
||||
$_SESSION['filter'][$preSearchSession]['registered'] = $chkSelRegFilter;
|
||||
$_SESSION['filter'][$preSearchSession]['active'] = $chkSelActiveFilter;
|
||||
$myContentClass->arrSession = $_SESSION;
|
||||
}
|
||||
//
|
||||
// Process additional templates/variables
|
||||
// ======================================
|
||||
/*
|
||||
Process additional templates/variables
|
||||
*/
|
||||
if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) &&
|
||||
(count($_SESSION['templatedefinition']) != 0)) {
|
||||
(count($_SESSION['templatedefinition']) !== 0)) {
|
||||
$intTemplates = 1;
|
||||
} else {
|
||||
$intTemplates = 0;
|
||||
}
|
||||
if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) &&
|
||||
(count($_SESSION['variabledefinition']) != 0)) {
|
||||
(count($_SESSION['variabledefinition']) !== 0)) {
|
||||
$intVariables = 1;
|
||||
} else {
|
||||
$intVariables = 0;
|
||||
}
|
||||
//
|
||||
// Common SQL parts
|
||||
// ================
|
||||
if ($hidActive == 1) {
|
||||
/*
|
||||
Common SQL parts
|
||||
*/
|
||||
if ($hidActive === 1) {
|
||||
$chkActive = 1;
|
||||
}
|
||||
if ($chkGroupAdm == 1) {
|
||||
if ((int)$chkGroupAdm === 1) {
|
||||
$strGroupSQL = "`access_group`=$chkSelAccGr, ";
|
||||
} else {
|
||||
$strGroupSQL = '';
|
||||
}
|
||||
$preSQLCommon1 = "$strGroupSQL `active`='$chkActive', `register`='$chkRegister', `config_id`=$chkDomainId, "
|
||||
. '`last_modified`=NOW()';
|
||||
. '`last_modified`=NOW()';
|
||||
$preSQLCommon2 = "$strGroupSQL `active`='$chkActive', `register`='0', `config_id`=$chkDomainId, `last_modified`=NOW()";
|
||||
$intRet1 = 0;
|
||||
$intRet2 = 0;
|
||||
@@ -205,50 +245,52 @@ $intRet5 = 0;
|
||||
$intRet6 = 0;
|
||||
$intRet7 = 0;
|
||||
$intRet8 = 0;
|
||||
//
|
||||
// Check read and write access
|
||||
// ===========================
|
||||
/*
|
||||
Check read and write access
|
||||
*/
|
||||
if (isset($prePageKey)) {
|
||||
// Global read access (0 = access granted)
|
||||
$intGlobalReadAccess = $myVisClass->checkAccountGroup($prePageKey, 'read');
|
||||
// Global write access (0 = access granted)
|
||||
/* Global read access (0 = access granted) */
|
||||
$intGlobalReadAccess = $myVisClass->checkAccountGroup($prePageKey, 'read');
|
||||
/* Global write access (0 = access granted) */
|
||||
$intGlobalWriteAccess = $myVisClass->checkAccountGroup($prePageKey, 'write');
|
||||
$myContentClass->intGlobalWriteAccess = $intGlobalWriteAccess;
|
||||
}
|
||||
if (!isset($preNoAccessGrp) || ($preNoAccessGrp == 0)) {
|
||||
if ($chkDataId != 0) {
|
||||
$strSQLWrite = "SELECT `access_group` FROM `$preTableName` WHERE `id`=".$chkDataId;
|
||||
if (!isset($preNoAccessGrp) || ($preNoAccessGrp === 0)) {
|
||||
if ($chkDataId !== 0) {
|
||||
/** @noinspection SqlResolve */
|
||||
$strSQLWrite = "SELECT `access_group` FROM `$preTableName` WHERE `id`=" . $chkDataId;
|
||||
$intWriteAccessId = $myVisClass->checkAccountGroup((int)$myDBClass->getFieldData($strSQLWrite), 'write');
|
||||
$myContentClass->intWriteAccessId = $intWriteAccessId;
|
||||
}
|
||||
if ($chkListId != 0) {
|
||||
$strSQLWrite = "SELECT `access_group` FROM `$preTableName` WHERE `id`=".$chkListId;
|
||||
$intReadAccessId = $myVisClass->checkAccountGroup((int)$myDBClass->getFieldData($strSQLWrite), 'read');
|
||||
if ($chkListId !== 0) {
|
||||
/** @noinspection SqlResolve */
|
||||
$strSQLWrite = "SELECT `access_group` FROM `$preTableName` WHERE `id`=" . $chkListId;
|
||||
$intReadAccessId = $myVisClass->checkAccountGroup((int)$myDBClass->getFieldData($strSQLWrite), 'read');
|
||||
$intWriteAccessId = $myVisClass->checkAccountGroup((int)$myDBClass->getFieldData($strSQLWrite), 'write');
|
||||
$myContentClass->intWriteAccessId = $intWriteAccessId;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Data processing
|
||||
// ===============
|
||||
if (($chkModus == 'make') && ($intGlobalWriteAccess == 0)) {
|
||||
$intError = 0;
|
||||
/*
|
||||
Data processing
|
||||
*/
|
||||
if (($chkModus === 'make') && ($intGlobalWriteAccess === 0)) {
|
||||
$intError = 0;
|
||||
$intSuccess = 0;
|
||||
// Get write access groups
|
||||
/* Get write access groups */
|
||||
$strAccess = $myVisClass->getAccessGroups('write');
|
||||
// Write configuration file
|
||||
if ($preTableName == 'tbl_host') {
|
||||
/** @var string $strDomainWhere - defined in prepend_adm.php */
|
||||
$strSQL = "SELECT `id` FROM `$preTableName` "
|
||||
. "WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1'";
|
||||
/* Write configuration file */
|
||||
if ($preTableName === 'tbl_host') {
|
||||
/** @noinspection SqlResolve */
|
||||
$strSQL = "SELECT `id` FROM `$preTableName` "
|
||||
. "WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1'";
|
||||
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
|
||||
if ($booReturn == false) {
|
||||
if ($booReturn === false) {
|
||||
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
|
||||
}
|
||||
if ($booReturn && ($intDataCount != 0)) {
|
||||
if ($booReturn && ($intDataCount !== 0)) {
|
||||
foreach ($arrData as $data) {
|
||||
$intReturn = $myConfigClass->createConfigSingle($preTableName, $data['id']);
|
||||
if ($intReturn == 1) {
|
||||
if ($intReturn === 1) {
|
||||
$intError++;
|
||||
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
|
||||
} else {
|
||||
@@ -257,28 +299,28 @@ if (($chkModus == 'make') && ($intGlobalWriteAccess == 0)) {
|
||||
}
|
||||
} else {
|
||||
$myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, '
|
||||
. 'not found or you do not have write permission!'), $strErrorMessage);
|
||||
. 'not found or you do not have write permission!'), $strErrorMessage);
|
||||
}
|
||||
if ($intSuccess != 0) {
|
||||
if ($intSuccess !== 0) {
|
||||
$myVisClass->processMessage(translate('Configuration files successfully written!'), $strInfoMessage);
|
||||
}
|
||||
if ($intError != 0) {
|
||||
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);
|
||||
. 'not found or you do not have write permission!'), $strErrorMessage);
|
||||
}
|
||||
} elseif ($preTableName == 'tbl_service') {
|
||||
/** @var string $strDomainWhere - defined in prepend_adm.php */
|
||||
$strSQL = "SELECT `id`, `$preKeyField` FROM `$preTableName` "
|
||||
. "WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1' "
|
||||
. "GROUP BY `$preKeyField`, `id`";
|
||||
$myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
|
||||
if ($booReturn == false) {
|
||||
} elseif ($preTableName === 'tbl_service') {
|
||||
/** @noinspection SqlResolve */
|
||||
$strSQL = "SELECT `id`, `$preKeyField` FROM `$preTableName` "
|
||||
. "WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1' "
|
||||
. "GROUP BY `$preKeyField`, `id`";
|
||||
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
|
||||
if ($booReturn === false) {
|
||||
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
|
||||
}
|
||||
if ($booReturn && ($intDataCount != 0)) {
|
||||
if ($booReturn && ($intDataCount !== 0)) {
|
||||
foreach ($arrData as $data) {
|
||||
$intReturn = $myConfigClass->createConfigSingle($preTableName, $data['id']);
|
||||
if ($intReturn == 1) {
|
||||
if ($intReturn === 1) {
|
||||
$intError++;
|
||||
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
|
||||
} else {
|
||||
@@ -287,212 +329,215 @@ if (($chkModus == 'make') && ($intGlobalWriteAccess == 0)) {
|
||||
}
|
||||
} else {
|
||||
$myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, '
|
||||
. 'not found or you do not have write permission!'), $strErrorMessage);
|
||||
. 'not found or you do not have write permission!'), $strErrorMessage);
|
||||
}
|
||||
if ($intSuccess != 0) {
|
||||
if ($intSuccess !== 0) {
|
||||
$myVisClass->processMessage(translate('Configuration files successfully written!'), $strInfoMessage);
|
||||
}
|
||||
if ($intError != 0) {
|
||||
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);
|
||||
. 'not found or you do not have write permission!'), $strErrorMessage);
|
||||
}
|
||||
} else {
|
||||
$intReturn = $myConfigClass->createConfig($preTableName, 0);
|
||||
if ($intReturn == 1) {
|
||||
$intReturn = $myConfigClass->createConfig($preTableName);
|
||||
if ($intReturn === 1) {
|
||||
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
|
||||
}
|
||||
if ($intReturn == 0) {
|
||||
if ($intReturn === 0) {
|
||||
$myVisClass->processMessage($myConfigClass->strInfoMessage, $strInfoMessage);
|
||||
}
|
||||
}
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus == 'checkform') && ($chkSelModify == 'info')) {
|
||||
// Display additional relation information
|
||||
if ($preTableName == 'tbl_service') {
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus === 'checkform') && ($chkSelModify === 'info')) {
|
||||
/* Display additional relation information */
|
||||
if ($preTableName === 'tbl_service') {
|
||||
$intReturn = $myDataClass->infoRelation($preTableName, $chkListId, "$preKeyField,service_description");
|
||||
} else {
|
||||
$intReturn = $myDataClass->infoRelation($preTableName, $chkListId, $preKeyField);
|
||||
}
|
||||
$myVisClass->processMessage($myDataClass->strInfoMessage, $strConsistMessage);
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus == 'checkform') && ($chkSelModify == 'delete') && ($intGlobalWriteAccess == 0)) {
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus === 'checkform') && ($chkSelModify === 'delete') && ($intGlobalWriteAccess === 0)) {
|
||||
$intReturn = 1;
|
||||
// Delete selected datasets
|
||||
if (($preTableName == 'tbl_user') && ($chkTfValue5 == 'Admin')) {
|
||||
/* Delete selected datasets */
|
||||
if (($preTableName === 'tbl_user') && ($chkTfValue5 === 'Admin')) {
|
||||
$myVisClass->processMessage(translate('Admin cannot be deleted'), $strErrorMessage);
|
||||
$intReturn = 0;
|
||||
} elseif ((($preTableName == 'tbl_datadomain') || ($preTableName == 'tbl_configtarget')) &&
|
||||
($chkTfValue3 == 'localhost')) {
|
||||
} elseif ((($preTableName === 'tbl_datadomain') || ($preTableName === 'tbl_configtarget')) &&
|
||||
($chkTfValue3 === 'localhost')) {
|
||||
$myVisClass->processMessage(translate("Localhost can't be deleted"), $strErrorMessage);
|
||||
$intReturn = 0;
|
||||
} elseif (($preTableName == 'tbl_user') || ($preTableName == 'tbl_datadomain') ||
|
||||
($preTableName == 'tbl_configtarget')) {
|
||||
} elseif (($preTableName === 'tbl_user') || ($preTableName === 'tbl_datadomain') ||
|
||||
($preTableName === 'tbl_configtarget')) {
|
||||
$intReturn = $myDataClass->dataDeleteEasy($preTableName, $chkListId);
|
||||
} else {
|
||||
$strInfoMessageTmp = $strInfoMessage;
|
||||
if ($preTableName == 'tbl_service') {
|
||||
if ($preTableName === 'tbl_service') {
|
||||
$intRetVal = $myDataClass->infoRelation($preTableName, $chkListId, "$preKeyField,service_description");
|
||||
} else {
|
||||
$intRetVal = $myDataClass->infoRelation($preTableName, $chkListId, $preKeyField);
|
||||
}
|
||||
if ($intRetVal == 0) {
|
||||
if ($intRetVal === 0) {
|
||||
$strInfoMessage = $strInfoMessageTmp;
|
||||
$intReturn = $myDataClass->dataDeleteFull($preTableName, $chkListId);
|
||||
}
|
||||
}
|
||||
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
|
||||
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus == 'checkform') && ($chkSelModify == 'copy') && ($intGlobalWriteAccess == 0)) {
|
||||
// Copy selected datasets
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus === 'checkform') && ($chkSelModify === 'copy') && ($intGlobalWriteAccess === 0)) {
|
||||
/* Copy selected datasets */
|
||||
$intReturn = $myDataClass->dataCopyEasy($preTableName, $preKeyField, $chkListId, $chkSelTarDom);
|
||||
if ($intReturn == 1) {
|
||||
if ($intReturn === 1) {
|
||||
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
|
||||
}
|
||||
if ($intReturn == 0) {
|
||||
if ($intReturn === 0) {
|
||||
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
|
||||
}
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus == 'checkform') && ($chkSelModify == 'activate') && ($intGlobalWriteAccess == 0)) {
|
||||
// Activate selected datasets
|
||||
} elseif (($chkModus === 'checkform') && ($chkSelModify === 'activate') && ($intGlobalWriteAccess === 0)) {
|
||||
/* Activate selected datasets */
|
||||
$intReturn = $myDataClass->dataActivate($preTableName, $chkListId);
|
||||
if ($intReturn == 1) {
|
||||
if ($intReturn === 1) {
|
||||
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
|
||||
}
|
||||
if ($intReturn == 0) {
|
||||
if ($intReturn === 0) {
|
||||
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
|
||||
}
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus == 'checkform') && ($chkSelModify == 'deactivate') && ($intGlobalWriteAccess == 0)) {
|
||||
// Deactivate selected datasets
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus === 'checkform') && ($chkSelModify === 'deactivate') && ($intGlobalWriteAccess === 0)) {
|
||||
/* Deactivate selected datasets */
|
||||
$intReturn = $myDataClass->dataDeactivate($preTableName, $chkListId);
|
||||
if ($intReturn == 1) {
|
||||
if ($intReturn === 1) {
|
||||
$myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage);
|
||||
}
|
||||
if ($intReturn == 0) {
|
||||
if ($intReturn === 0) {
|
||||
$myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage);
|
||||
}
|
||||
// Remove deactivated files
|
||||
if ($preTableName == 'tbl_host') {
|
||||
if ($chkListId != 0) {
|
||||
$strChbName = 'chbId_' .$chkListId;
|
||||
/* Remove deactivated files */
|
||||
if ($preTableName === 'tbl_host') {
|
||||
if ($chkListId !== 0) {
|
||||
$strChbName = 'chbId_' . $chkListId;
|
||||
$_POST[$strChbName] = 'on';
|
||||
}
|
||||
// Get write access groups
|
||||
/* Get write access groups */
|
||||
$strAccess = $myVisClass->getAccessGroups('write');
|
||||
// Getting data sets
|
||||
$strSQL = 'SELECT `id`, `host_name` FROM `' .$preTableName. '` '
|
||||
. "WHERE `active`='0' AND `access_group` IN ($strAccess) AND `config_id`=".$chkDomainId;
|
||||
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
|
||||
if ($booReturn && ($intDataCount != 0) && ($chkDomainId != 0)) {
|
||||
$intReturn = $myConfigClass->getConfigTargets($arrConfigID);
|
||||
$intError = 0;
|
||||
/* Getting data sets */
|
||||
/** @noinspection SqlResolve */
|
||||
$strSQL = 'SELECT `id`, `host_name` FROM `' . $preTableName . '` '
|
||||
. "WHERE `active`='0' AND `access_group` IN ($strAccess) AND `config_id`=" . $chkDomainId;
|
||||
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
|
||||
if ($booReturn && ($intDataCount !== 0) && ($chkDomainId !== 0)) {
|
||||
$intReturn = $myConfigClass->getConfigTargets($arrConfigID);
|
||||
$intError = 0;
|
||||
$intSuccess = 0;
|
||||
if (($arrConfigID != 1) && is_array($arrConfigID)) {
|
||||
$intCount = 0;
|
||||
if (is_array($arrConfigID) && ((int)$arrConfigID[0] !== 0)) {
|
||||
foreach ($arrData as $elem) {
|
||||
$strChbName = 'chbId_' .$elem['id'];
|
||||
// was the current record is marked for deactivate?
|
||||
if ((filter_input(INPUT_POST, $strChbName) != null) &&
|
||||
(filter_input(INPUT_POST, $strChbName, FILTER_SANITIZE_STRING) == 'on')) {
|
||||
$intCount = 0;
|
||||
$strChbName = 'chbId_' . $elem['id'];
|
||||
/* was the current record is marked for deactivate? */
|
||||
if ((filter_input(INPUT_POST, $strChbName) === 'on')) {
|
||||
$intReturn = 0;
|
||||
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']
|
||||
$intReturn += $myConfigClass->moveFile('host', $elem['host_name'] . '.cfg', $intConfigID);
|
||||
if ($intReturn === 0) {
|
||||
$myDataClass->writeLog(translate('Host file deleted:') . ' ' . $elem['host_name']
|
||||
. '.cfg');
|
||||
$intCount++;
|
||||
}
|
||||
}
|
||||
if ($intReturn == 0) {
|
||||
if ($intReturn === 0) {
|
||||
$intSuccess++;
|
||||
}
|
||||
if ($intReturn != 0) {
|
||||
if ($intReturn !== 0) {
|
||||
$intError++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (($intSuccess != 0) && ($intCount != 0)) {
|
||||
if (($intSuccess !== 0) && ($intCount !== 0)) {
|
||||
$myVisClass->processMessage(translate('The assigned, no longer used configuration files were '
|
||||
. 'deleted successfully!').$intCount, $strInfoMessage);
|
||||
. 'deleted successfully!') . $intCount, $strInfoMessage);
|
||||
}
|
||||
if ($intError != 0) {
|
||||
if ($intError !== 0) {
|
||||
$myVisClass->processMessage(translate('Errors while deleting the old configuration file - please '
|
||||
. 'check!:'), $strErrorMessage);
|
||||
. 'check!:'), $strErrorMessage);
|
||||
}
|
||||
}
|
||||
} elseif ($chkDomainId == 0) {
|
||||
} elseif ($chkDomainId === 0) {
|
||||
$myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check '
|
||||
. 'manually'), $strErrorMessage);
|
||||
. 'manually'), $strErrorMessage);
|
||||
}
|
||||
} elseif ($preTableName == 'tbl_service') {
|
||||
if ($chkListId != 0) {
|
||||
$strChbName = 'chbId_' .$chkListId;
|
||||
} elseif ($preTableName === 'tbl_service') {
|
||||
if ($chkListId !== 0) {
|
||||
$strChbName = 'chbId_' . $chkListId;
|
||||
$_POST[$strChbName] = 'on';
|
||||
}
|
||||
// Get write access groups
|
||||
/* Get write access groups */
|
||||
$strAccess = $myVisClass->getAccessGroups('write');
|
||||
// Getting data sets
|
||||
$strSQL = 'SELECT `id`, `config_name` FROM `' .$preTableName. '` '
|
||||
. "WHERE `active`='0' AND `access_group` IN ($strAccess) AND `config_id`=".$chkDomainId;
|
||||
/* Getting data sets */
|
||||
/** @noinspection SqlResolve */
|
||||
$strSQL = 'SELECT `id`, `config_name` FROM `' . $preTableName . '` '
|
||||
. "WHERE `active`='0' AND `access_group` IN ($strAccess) AND `config_id`=" . $chkDomainId;
|
||||
$booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount);
|
||||
if ($booReturn && ($intDataCount != 0) && ($chkDomainId != 0)) {
|
||||
$intReturn = $myConfigClass->getConfigTargets($arrConfigID);
|
||||
$intError = 0;
|
||||
if ($booReturn && ($intDataCount !== 0) && ($chkDomainId !== 0)) {
|
||||
$intReturn = $myConfigClass->getConfigTargets($arrConfigID);
|
||||
$intError = 0;
|
||||
$intSuccess = 0;
|
||||
if (($arrConfigID != 1) && is_array($arrConfigID)) {
|
||||
$intCount = 0;
|
||||
if (is_array($arrConfigID) && ((int)$arrConfigID[0] !== 0)) {
|
||||
$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')) {
|
||||
$strChbName = 'chbId_' . $elem['id'];
|
||||
/* was the current record is marked for deactivate? */
|
||||
if (filter_input(INPUT_POST, $strChbName) === 'on') {
|
||||
/** @noinspection SqlResolve */
|
||||
$intServiceCount = $myDBClass->countRows("SELECT * FROM `$preTableName` "
|
||||
. "WHERE `$preKeyField`='".$elem['config_name']."' "
|
||||
. "AND `config_id`=$chkDomainId AND `active`='1'");
|
||||
if ($intServiceCount == 0) {
|
||||
. "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',
|
||||
$elem['config_name'] . '.cfg',
|
||||
$intConfigID
|
||||
);
|
||||
if ($intReturn == 0) {
|
||||
$myDataClass->writeLog(translate('Service file deleted:'). ' ' .
|
||||
$elem['config_name']. '.cfg');
|
||||
if ($intReturn === 0) {
|
||||
$myDataClass->writeLog(translate('Service file deleted:') . ' ' .
|
||||
$elem['config_name'] . '.cfg');
|
||||
}
|
||||
$intCount++;
|
||||
}
|
||||
if ($intReturn == 0) {
|
||||
if ($intReturn === 0) {
|
||||
$intSuccess++;
|
||||
}
|
||||
if ($intReturn != 0) {
|
||||
if ($intReturn !== 0) {
|
||||
$intError++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (($intSuccess != 0) && ($intCount != 0)) {
|
||||
if (($intSuccess !== 0) && ($intCount !== 0)) {
|
||||
$myVisClass->processMessage(translate('The assigned, no longer used configuration files were '
|
||||
. 'deleted successfully!'), $strInfoMessage);
|
||||
. 'deleted successfully!'), $strInfoMessage);
|
||||
}
|
||||
if ($intError != 0) {
|
||||
if ($intError !== 0) {
|
||||
$myVisClass->processMessage(translate('Errors while deleting the old configuration file - please '
|
||||
. 'check!:'), $strErrorMessage);
|
||||
. 'check!:'), $strErrorMessage);
|
||||
}
|
||||
}
|
||||
} elseif ($chkDomainId == 0) {
|
||||
} elseif ($chkDomainId === 0) {
|
||||
$myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check '
|
||||
. 'manually'), $strErrorMessage);
|
||||
. 'manually'), $strErrorMessage);
|
||||
}
|
||||
}
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus == 'checkform') && ($chkSelModify == 'modify')) {
|
||||
// Open the dataset to modify
|
||||
if ($intReadAccessId == 0) {
|
||||
$chkModus = 'display';
|
||||
} elseif (($chkModus === 'checkform') && ($chkSelModify === 'modify')) {
|
||||
/* Open the dataset to modify */
|
||||
if ($intReadAccessId === 0) {
|
||||
/** @noinspection SqlResolve */
|
||||
$booReturn = $myDBClass->hasSingleDataset("SELECT * FROM `$preTableName` "
|
||||
. 'WHERE `id`=' .$chkListId, $arrModifyData);
|
||||
if ($booReturn == false) {
|
||||
. 'WHERE `id`=' . $chkListId, $arrModifyData);
|
||||
if ($booReturn === false) {
|
||||
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
|
||||
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
|
||||
$chkModus = 'display';
|
||||
@@ -503,15 +548,15 @@ if (($chkModus == 'make') && ($intGlobalWriteAccess == 0)) {
|
||||
$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)) {
|
||||
} 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') {
|
||||
if ($elem === 'on') {
|
||||
$intValCount++;
|
||||
}
|
||||
}
|
||||
@@ -519,22 +564,21 @@ if (($chkModus == 'make') && ($intGlobalWriteAccess == 0)) {
|
||||
$intDSId = 0;
|
||||
}
|
||||
$intReturn = $myConfigClass->createConfigSingle($preTableName, $intDSId);
|
||||
if ($intReturn == 1) {
|
||||
if ($intReturn === 1) {
|
||||
$myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage);
|
||||
}
|
||||
if ($intReturn == 0) {
|
||||
if ($intReturn === 0) {
|
||||
$myVisClass->processMessage($myConfigClass->strInfoMessage, $strInfoMessage);
|
||||
}
|
||||
$chkModus = 'display';
|
||||
$chkModus = 'display';
|
||||
}
|
||||
//
|
||||
// Some common list view functions
|
||||
// ===============================
|
||||
if ($chkModus != 'add') {
|
||||
// Get Group id's with READ
|
||||
/*
|
||||
Some common list view functions
|
||||
*/
|
||||
if ($chkModus !== 'add') {
|
||||
/* Get Group id's with READ */
|
||||
$strAccess = $myVisClass->getAccessGroups('read');
|
||||
// Include domain list
|
||||
/** @var HTML_Template_IT $mastertp */
|
||||
/* Include domain list */
|
||||
$myVisClass->insertDomainList($mastertp);
|
||||
// Process filter string
|
||||
}
|
||||
/* Process filter string */
|
||||
}
|
||||
@@ -1,77 +1,76 @@
|
||||
<?php
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NagiosQL
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (c) 2005-2018 by Martin Willisegger
|
||||
//
|
||||
// Project : NagiosQL
|
||||
// Component : Preprocessing script for scripting files
|
||||
// Website : https://sourceforge.net/projects/nagiosql/
|
||||
// Version : 3.4.0
|
||||
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//error_reporting(E_ALL);
|
||||
//error_reporting(E_ERROR);
|
||||
//
|
||||
// Security Protection
|
||||
// ===================
|
||||
/* ----------------------------------------------------------------------------
|
||||
NagiosQL
|
||||
-------------------------------------------------------------------------------
|
||||
(c) 2005-2022 by Martin Willisegger
|
||||
|
||||
Project : NagiosQL
|
||||
Component : Preprocessing script for scripting files
|
||||
Website : https://sourceforge.net/projects/nagiosql/
|
||||
Version : 3.5.0
|
||||
GIT Repo : https://gitlab.com/wizonet/NagiosQL
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Security Protection
|
||||
*/
|
||||
if (isset($_GET['SETS']) || isset($_POST['SETS'])) {
|
||||
$SETS = '';
|
||||
}
|
||||
//
|
||||
// Timezone settings (>=PHP5.1)
|
||||
// ============================
|
||||
|
||||
/*
|
||||
Timezone settings
|
||||
*/
|
||||
if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
|
||||
@date_default_timezone_set(@date_default_timezone_get());
|
||||
}
|
||||
//
|
||||
// Define common variables
|
||||
// =======================
|
||||
$chkDomainId = 0;
|
||||
$intError = 0;
|
||||
//
|
||||
// Define path constants
|
||||
//
|
||||
//define('BASE_PATH', str_replace("functions", "", dirname(__FILE__)));
|
||||
//
|
||||
// Read settings file
|
||||
// ==================
|
||||
|
||||
/*
|
||||
Define common variables
|
||||
*/
|
||||
$chkDomainId = 0;
|
||||
$intError = 0;
|
||||
|
||||
/*
|
||||
Read settings file
|
||||
*/
|
||||
$preBasePath = str_replace('functions', '', __DIR__);
|
||||
$preIniFile = $preBasePath.'config/settings.php';
|
||||
//
|
||||
// Read file settings
|
||||
// ==================
|
||||
$preIniFile = $preBasePath . 'config/settings.php';
|
||||
|
||||
/*
|
||||
Read file settings
|
||||
*/
|
||||
$SETS = parse_ini_file($preIniFile, true);
|
||||
//
|
||||
// Include external function/class files - part 1
|
||||
// ==============================================
|
||||
require $preBasePath.'functions/Autoloader.php';
|
||||
|
||||
/*
|
||||
Include external function/class files - part 1
|
||||
*/
|
||||
require_once $preBasePath . 'libraries/pear/HTML/Template/IT.php';
|
||||
require $preBasePath . 'functions/Autoloader.php';
|
||||
functions\Autoloader::register($preBasePath);
|
||||
//
|
||||
// Initialize classes - part 1
|
||||
// ===========================
|
||||
$myDBClass = new functions\MysqliDbClass();
|
||||
|
||||
/*
|
||||
Initialize classes - part 1
|
||||
*/
|
||||
$myDBClass = new functions\MysqliDbClass();
|
||||
$myDBClass->arrParams = $SETS['db'];
|
||||
$myDBClass->hasDBConnection();
|
||||
if ($myDBClass->error == true) {
|
||||
if ($myDBClass->error === true) {
|
||||
$strDBMessage = $myDBClass->strErrorMessage;
|
||||
$booError = $myDBClass->error;
|
||||
$booError = $myDBClass->error;
|
||||
}
|
||||
//
|
||||
// Get additional configuration from the table tbl_settings
|
||||
// ========================================================
|
||||
if ($intError == 0) {
|
||||
$strSQL = 'SELECT `category`,`name`,`value` FROM `tbl_settings`';
|
||||
|
||||
/*
|
||||
Get additional configuration from the table tbl_settings
|
||||
*/
|
||||
if ($intError === 0) {
|
||||
$strSQL = 'SELECT `category`,`name`,`value` FROM `tbl_settings`';
|
||||
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
|
||||
if ($booReturn == false) {
|
||||
echo str_replace('::', "\n", 'Error while selecting data from database: ' .$myDBClass->strErrorMessage);
|
||||
$intError = 1;
|
||||
} elseif ($intDataCount != 0) {
|
||||
for ($i=0; $i<$intDataCount; $i++) {
|
||||
if ($booReturn === false) {
|
||||
echo str_replace('::', "\n", 'Error while selecting data from database: ' . $myDBClass->strErrorMessage);
|
||||
$intError = 1;
|
||||
} elseif ($intDataCount !== 0) {
|
||||
for ($i = 0; $i < $intDataCount; $i++) {
|
||||
$SETS[$arrDataLines[$i]['category']][$arrDataLines[$i]['name']] = $arrDataLines[$i]['value'];
|
||||
}
|
||||
}
|
||||
@@ -79,25 +78,29 @@ if ($intError == 0) {
|
||||
echo "Could not load configuration settings from database - abort\n";
|
||||
exit;
|
||||
}
|
||||
//
|
||||
// Include external function/class files
|
||||
// =====================================
|
||||
|
||||
/*
|
||||
Include translator strings
|
||||
*/
|
||||
include 'translator.php';
|
||||
//
|
||||
// Initialize classes
|
||||
// ==================
|
||||
$arrSession = array();
|
||||
|
||||
/*
|
||||
Initialize classes
|
||||
*/
|
||||
$arrSession = array();
|
||||
$arrSession['SETS'] = $SETS;
|
||||
$myDataClass = new functions\NagDataClass($arrSession);
|
||||
$myConfigClass = new functions\NagConfigClass($arrSession);
|
||||
$myImportClass = new functions\NagImportClass($arrSession);
|
||||
//
|
||||
// Propagating the classes themselves
|
||||
// ==================================
|
||||
$myDataClass->myDBClass =& $myDBClass;
|
||||
$myDataClass->myConfigClass =& $myConfigClass;
|
||||
$myConfigClass->myDBClass =& $myDBClass;
|
||||
$myConfigClass->myDataClass =& $myDataClass;
|
||||
$myImportClass->myDataClass =& $myDataClass;
|
||||
$myImportClass->myDBClass =& $myDBClass;
|
||||
$myImportClass->myConfigClass =& $myConfigClass;
|
||||
$myDataClass = new functions\NagDataClass($arrSession);
|
||||
$myConfigClass = new functions\NagConfigClass($arrSession);
|
||||
/** @noinspection PhpObjectFieldsAreOnlyWrittenInspection */
|
||||
$myImportClass = new functions\NagImportClass($arrSession);
|
||||
|
||||
/*
|
||||
Propagating the classes themselves
|
||||
*/
|
||||
$myDataClass->myDBClass =& $myDBClass;
|
||||
$myDataClass->myConfigClass =& $myConfigClass;
|
||||
$myConfigClass->myDBClass =& $myDBClass;
|
||||
$myConfigClass->myDataClass =& $myDataClass;
|
||||
$myImportClass->myDataClass =& $myDataClass;
|
||||
$myImportClass->myDBClass =& $myDBClass;
|
||||
$myImportClass->myConfigClass =& $myConfigClass;
|
||||
@@ -1,42 +1,35 @@
|
||||
<?php
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NagiosQL
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (c) 2005-2018 by Martin Willisegger
|
||||
//
|
||||
// Project : NagiosQL
|
||||
// Component : Translation Functions
|
||||
// Website : https://sourceforge.net/projects/nagiosql/
|
||||
// Version : 3.4.0
|
||||
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Translate given text
|
||||
//
|
||||
function translate($translation)
|
||||
/* ----------------------------------------------------------------------------
|
||||
NagiosQL
|
||||
-------------------------------------------------------------------------------
|
||||
(c) 2005-2022 by Martin Willisegger
|
||||
|
||||
Project : NagiosQL
|
||||
Component : Translation Functions
|
||||
Website : https://sourceforge.net/projects/nagiosql/
|
||||
Version : 3.5.0
|
||||
GIT Repo : https://gitlab.com/wizonet/NagiosQL
|
||||
-----------------------------------------------------------------------------*/
|
||||
/*
|
||||
Translate given text
|
||||
*/
|
||||
function translate($strTranslation): string
|
||||
{
|
||||
$translation = str_replace('"', '"', gettext($translation));
|
||||
$translation = str_replace("'", ''', gettext($translation));
|
||||
return $translation;
|
||||
return str_replace("'", ''', gettext(str_replace('"', '"', gettext($strTranslation))));
|
||||
}
|
||||
///
|
||||
/// Internationalization and Localization utilities
|
||||
///
|
||||
function getLanguageCodefromLanguage($languagetosearch)
|
||||
|
||||
/*
|
||||
Internationalization and Localization utilities
|
||||
*/
|
||||
function getLanguageCodefromLanguage($strLangSearch): string
|
||||
{
|
||||
$strReturn = 'en_GB';
|
||||
$detaillanguages = getLanguageData();
|
||||
/** @noinspection ForeachSourceInspection */
|
||||
foreach ($detaillanguages as $key2 => $languagename) {
|
||||
if ($languagetosearch == $languagename['description']) {
|
||||
$strReturn = $key2;
|
||||
$arrLangDetail = getLanguageData();
|
||||
foreach ($arrLangDetail as $key => $elem) {
|
||||
if ($strLangSearch === $elem['description']) {
|
||||
$strReturn = $key;
|
||||
}
|
||||
}
|
||||
// else return default en code
|
||||
return $strReturn;
|
||||
}
|
||||
|
||||
@@ -46,7 +39,7 @@ function getLanguageNameFromCode($codetosearch, $withnative = true)
|
||||
$detaillanguages = getLanguageData();
|
||||
if (isset($detaillanguages[$codetosearch]['description'])) {
|
||||
if ($withnative) {
|
||||
$strReturn = $detaillanguages[$codetosearch]['description'].' - '.
|
||||
$strReturn = $detaillanguages[$codetosearch]['description'] . ' - ' .
|
||||
$detaillanguages[$codetosearch]['nativedescription'];
|
||||
} else {
|
||||
$strReturn = $detaillanguages[$codetosearch]['description'];
|
||||
@@ -58,206 +51,56 @@ function getLanguageNameFromCode($codetosearch, $withnative = true)
|
||||
|
||||
function getLanguageData()
|
||||
{
|
||||
unset($supportedLanguages);
|
||||
// English
|
||||
$supportedLanguages['en_GB']['description'] = translate('English');
|
||||
$supportedLanguages['en_GB']['nativedescription'] = 'English';
|
||||
unset($arrLangSupported);
|
||||
/* English */
|
||||
$arrLangSupported['en_GB']['description'] = translate('English');
|
||||
$arrLangSupported['en_GB']['nativedescription'] = 'English';
|
||||
|
||||
// German
|
||||
$supportedLanguages['de_DE']['description'] = translate('German');
|
||||
$supportedLanguages['de_DE']['nativedescription'] = 'Deutsch';
|
||||
/* German */
|
||||
$arrLangSupported['de_DE']['description'] = translate('German');
|
||||
$arrLangSupported['de_DE']['nativedescription'] = 'Deutsch';
|
||||
|
||||
// Chinese (Simplified)
|
||||
$supportedLanguages['zh_CN']['description'] = translate('Chinese (Simplified)');
|
||||
$supportedLanguages['zh_CN']['nativedescription'] = '简体中文';
|
||||
/* Chinese (Simplified) */
|
||||
$arrLangSupported['zh_CN']['description'] = translate('Chinese (Simplified)');
|
||||
$arrLangSupported['zh_CN']['nativedescription'] = '简体中文';
|
||||
|
||||
// Italian
|
||||
$supportedLanguages['it_IT']['description'] = translate('Italian');
|
||||
$supportedLanguages['it_IT']['nativedescription'] = 'Italiano';
|
||||
/* Italian */
|
||||
$arrLangSupported['it_IT']['description'] = translate('Italian');
|
||||
$arrLangSupported['it_IT']['nativedescription'] = 'Italiano';
|
||||
|
||||
// French
|
||||
$supportedLanguages['fr_FR']['description'] = translate('French');
|
||||
$supportedLanguages['fr_FR']['nativedescription'] = 'Français';
|
||||
/* French */
|
||||
$arrLangSupported['fr_FR']['description'] = translate('French');
|
||||
$arrLangSupported['fr_FR']['nativedescription'] = 'Français';
|
||||
|
||||
// Russian
|
||||
$supportedLanguages['ru_RU']['description'] = translate('Russian');
|
||||
$supportedLanguages['ru_RU']['nativedescription'] = 'Русский';
|
||||
/* Russian */
|
||||
$arrLangSupported['ru_RU']['description'] = translate('Russian');
|
||||
$arrLangSupported['ru_RU']['nativedescription'] = 'Русский';
|
||||
|
||||
// Spanish
|
||||
$supportedLanguages['es_ES']['description'] = translate('Spanish');
|
||||
$supportedLanguages['es_ES']['nativedescription'] = 'Español';
|
||||
/* Spanish */
|
||||
$arrLangSupported['es_ES']['description'] = translate('Spanish');
|
||||
$arrLangSupported['es_ES']['nativedescription'] = 'Español';
|
||||
|
||||
// Brazilian Portuguese
|
||||
$supportedLanguages['pt_BR']['description'] = translate('Portuguese (Brazilian)');
|
||||
$supportedLanguages['pt_BR']['nativedescription'] = 'Português do Brasil';
|
||||
/* Brazilian Portuguese */
|
||||
$arrLangSupported['pt_BR']['description'] = translate('Portuguese (Brazilian)');
|
||||
$arrLangSupported['pt_BR']['nativedescription'] = 'Português do Brasil';
|
||||
|
||||
// Dutch
|
||||
$supportedLanguages['nl_NL']['description'] = translate('Dutch');
|
||||
$supportedLanguages['nl_NL']['nativedescription'] = 'Nederlands';
|
||||
/* Dutch */
|
||||
$arrLangSupported['nl_NL']['description'] = translate('Dutch');
|
||||
$arrLangSupported['nl_NL']['nativedescription'] = 'Nederlands';
|
||||
|
||||
// Danish
|
||||
$supportedLanguages['da_DK']['description'] = translate('Danish');
|
||||
$supportedLanguages['da_DK']['nativedescription'] = 'Dansk';
|
||||
|
||||
// No longer supported language because of missing translators
|
||||
//
|
||||
// // Japanese
|
||||
// $supportedLanguages['ja_JP']['description'] = translate('Japanese');
|
||||
// $supportedLanguages['ja_JP']['nativedescription'] = '日本語';
|
||||
//
|
||||
// // Polish
|
||||
// $supportedLanguages['pl_PL']['description'] = translate('Polish');
|
||||
// $supportedLanguages['pl_PL']['nativedescription'] = 'Polski';
|
||||
//
|
||||
// // Spanish (Argentina)
|
||||
// $supportedLanguages['es_AR']['description'] = translate('Spanish (Argentina)');
|
||||
// $supportedLanguages['es_AR']['nativedescription'] = 'Español Argentina';
|
||||
///
|
||||
/// Currently not supported languages
|
||||
//
|
||||
// // Albanian
|
||||
// $supportedLanguages['sq']['description'] = $clang->translate('Albanian');
|
||||
// $supportedLanguages['sq']['nativedescription'] = 'Shqipe';
|
||||
//
|
||||
// // Basque
|
||||
// $supportedLanguages['eu']['description'] = translate('Basque');
|
||||
// $supportedLanguages['eu']['nativedescription'] = 'Euskara';
|
||||
//
|
||||
// // Bosnian
|
||||
// $supportedLanguages['bs']['description'] = translate('Bosnian');
|
||||
// $supportedLanguages['bs']['nativedescription'] =
|
||||
// 'Български';
|
||||
//
|
||||
// // Bulgarian
|
||||
// $supportedLanguages['bg']['description'] = translate('Bulgarian');
|
||||
// $supportedLanguages['bg']['nativedescription'] =
|
||||
// 'Български';
|
||||
//
|
||||
// // Catalan
|
||||
// $supportedLanguages['ca']['description'] = translate('Catalan');
|
||||
// $supportedLanguages['ca']['nativedescription'] = 'Catalά';
|
||||
//
|
||||
// // Welsh
|
||||
// $supportedLanguages['cy']['description'] = translate('Welsh');
|
||||
// $supportedLanguages['cy']['nativedescription'] = 'Cymraeg';
|
||||
//
|
||||
// // Chinese (Traditional - Hong Kong)
|
||||
// $supportedLanguages['zh-Hant-HK']['description'] = translate('Chinese (Traditional - Hong Kong)');
|
||||
// $supportedLanguages['zh-Hant-HK']['nativedescription'] = '繁體中文語系';
|
||||
//
|
||||
// // Chinese (Traditional - Taiwan)
|
||||
// $supportedLanguages['zh-Hant-TW']['description'] = translate('Chinese (Traditional - Taiwan)');
|
||||
// $supportedLanguages['zh-Hant-TW']['nativedescription'] = 'Chinese (Traditional - Taiwan)';
|
||||
//
|
||||
// // Croatian
|
||||
// $supportedLanguages['hr']['description'] = translate('Croatian');
|
||||
// $supportedLanguages['hr']['nativedescription'] = 'Hrvatski';
|
||||
//
|
||||
// // Czech
|
||||
// $supportedLanguages['cs']['description'] = translate('Czech');
|
||||
// $supportedLanguages['cs']['nativedescription'] = 'Česky';
|
||||
//
|
||||
//
|
||||
// // Estonian
|
||||
// $supportedLanguages['et']['description'] = translate('Estonian');
|
||||
// $supportedLanguages['et']['nativedescription'] = 'Eesti';
|
||||
//
|
||||
// // Finnish
|
||||
// $supportedLanguages['fi']['description'] = translate('Finnish');
|
||||
// $supportedLanguages['fi']['nativedescription'] = 'Suomi';
|
||||
//
|
||||
// // Galician
|
||||
// $supportedLanguages['gl']['description'] = translate('Galician');
|
||||
// $supportedLanguages['gl']['nativedescription'] = 'Galego';
|
||||
//
|
||||
// // German informal
|
||||
// $supportedLanguages['de-informal']['description'] = translate('German informal');
|
||||
// $supportedLanguages['de-informal']['nativedescription'] = 'Deutsch (Du)';
|
||||
//
|
||||
// // Greek
|
||||
// $supportedLanguages['el']['description'] = translate('Greek');
|
||||
// $supportedLanguages['el']['nativedescription'] = 'ελληνικά';
|
||||
//
|
||||
// // Hebrew
|
||||
// $supportedLanguages['he']['description'] = translate('Hebrew');
|
||||
// $supportedLanguages['he']['nativedescription'] = ' עברית';
|
||||
//
|
||||
// // Hungarian
|
||||
// $supportedLanguages['hu']['description'] = translate('Hungarian');
|
||||
// $supportedLanguages['hu']['nativedescription'] = 'Magyar';
|
||||
//
|
||||
// // Indonesian
|
||||
// $supportedLanguages['id']['description'] = translate('Indonesian');
|
||||
// $supportedLanguages['id']['nativedescription'] = 'Bahasa Indonesia';
|
||||
//
|
||||
//
|
||||
// // Lithuanian
|
||||
// $supportedLanguages['lt']['description'] = translate('Lithuanian');
|
||||
// $supportedLanguages['lt']['nativedescription'] = 'Lietuvių';
|
||||
//
|
||||
// // Macedonian
|
||||
// $supportedLanguages['mk']['description'] = translate('Macedonian');
|
||||
// $supportedLanguages['mk']['nativedescription'] =
|
||||
// 'Македонски';
|
||||
//
|
||||
// // Norwegian Bokml
|
||||
// $supportedLanguages['nb']['description'] = translate('Norwegian (Bokmal)');
|
||||
// $supportedLanguages['nb']['nativedescription'] = 'Norsk Bokmål';
|
||||
//
|
||||
// // Norwegian Nynorsk
|
||||
// $supportedLanguages['nn']['description'] = translate('Norwegian (Nynorsk)');
|
||||
// $supportedLanguages['nn']['nativedescription'] = 'Norsk Nynorsk';
|
||||
//
|
||||
// // Portuguese
|
||||
// $supportedLanguages['pt']['description'] = translate('Portuguese');
|
||||
// $supportedLanguages['pt']['nativedescription'] = 'Português';
|
||||
//
|
||||
// // Romanian
|
||||
// $supportedLanguages['ro']['description'] = translate('Romanian');
|
||||
// $supportedLanguages['ro']['nativedescription'] = 'Românesc';
|
||||
//
|
||||
// // Slovak
|
||||
// $supportedLanguages['sk']['description'] = translate('Slovak');
|
||||
// $supportedLanguages['sk']['nativedescription'] = 'Slovák';
|
||||
//
|
||||
// // Slovenian
|
||||
// $supportedLanguages['sl']['description'] = translate('Slovenian');
|
||||
// $supportedLanguages['sl']['nativedescription'] = 'Slovenščina';
|
||||
//
|
||||
// // Serbian
|
||||
// $supportedLanguages['sr']['description'] = translate('Serbian');
|
||||
// $supportedLanguages['sr']['nativedescription'] = 'Srpski';
|
||||
//
|
||||
// // Spanish (Mexico)
|
||||
// $supportedLanguages['es-MX']['description'] = translate('Spanish (Mexico)');
|
||||
// $supportedLanguages['es-MX']['nativedescription'] = 'Español Mejicano';
|
||||
//
|
||||
// // Swedish
|
||||
// $supportedLanguages['sv']['description'] = translate('Swedish');
|
||||
// $supportedLanguages['sv']['nativedescription'] = 'Svenska';
|
||||
//
|
||||
// // Turkish
|
||||
// $supportedLanguages['tr']['description'] = translate('Turkish');
|
||||
// $supportedLanguages['tr']['nativedescription'] = 'Türkçe';
|
||||
//
|
||||
// // Thai
|
||||
// $supportedLanguages['th']['description'] = translate('Thai');
|
||||
// $supportedLanguages['th']['nativedescription'] = 'ภาษาไทย';
|
||||
//
|
||||
// // Vietnamese
|
||||
// $supportedLanguages['vi']['description'] = translate('Vietnamese');
|
||||
// $supportedLanguages['vi']['nativedescription'] = 'Tiếng Việt';
|
||||
/* Danish */
|
||||
$arrLangSupported['da_DK']['description'] = translate('Danish');
|
||||
$arrLangSupported['da_DK']['nativedescription'] = 'Dansk';
|
||||
|
||||
uasort($supportedLanguages, 'user_sort');
|
||||
return $supportedLanguages;
|
||||
uasort($arrLangSupported, 'user_sort');
|
||||
return $arrLangSupported;
|
||||
}
|
||||
|
||||
function user_sort($intValue1, $intValue2)
|
||||
function user_sort($intValue1, $intValue2): int
|
||||
{
|
||||
$intReturn = -1;
|
||||
// smarts is all-important, so sort it first
|
||||
if ($intValue1['description'] > $intValue2['description']) {
|
||||
$intReturn = 1;
|
||||
}
|
||||
return $intReturn;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user