1<?php 2/////////////////////////////////////////////////////////////////////////////// 3// 4// NagiosQL 5// 6/////////////////////////////////////////////////////////////////////////////// 7// 8// (c) 2005-2020 by Martin Willisegger 9// 10// Project : NagiosQL 11// Component : Preprocessing script for content pages 12// Website : https://sourceforge.net/projects/nagiosql/ 13// Version : 3.4.1 14// GIT Repo : https://gitlab.com/wizonet/NagiosQL 15// 16/////////////////////////////////////////////////////////////////////////////// 17// 18// Define common variables 19// ======================= 20$intLineCount = 0; // Database line count 21$intWriteAccessId = 0; // Write access to data id ($chkDataId) 22$intReadAccessId = 0; // Read access to data id ($chkListId) 23$intDataWarning = 0; // Missing data indicator 24$intNoTime = 0; // Show modified time list (0=show) 25$strSearchWhere = ''; // SQL WHERE addon for searching 26$strSearchWhere2 = ''; // SQL WHERE addon for configuration selection list 27$chkTfValue3 = ''; 28$chkTfValue5 = ''; 29// 30// Define missing variables used in this prepend file 31// ================================================== 32if (!isset($preTableName)) { 33 $preTableName = ''; 34} // Predefined variable table name 35if (!isset($preSearchSession)) { 36 $preSearchSession = ''; 37} // Predefined variable search session 38// 39// Store some variables to content class 40// ===================================== 41$myContentClass->intLimit = $chkLimit; 42/** @var int $intVersion - defined in prepend_adm.php */ 43$myContentClass->intVersion = $intVersion; 44$myContentClass->strBrowser = $preBrowser; 45$myContentClass->intGroupAdm = $chkGroupAdm; 46$myContentClass->strTableName = $preTableName; 47$myContentClass->strSearchSession = $preSearchSession; 48$myContentClass->intSortBy = $hidSortBy; 49$myContentClass->strSortDir = $hidSortDir; 50// 51// Process get parameters 52// ====================== 53$chkFromLine = filter_input(INPUT_GET, 'from_line', FILTER_VALIDATE_INT, array('options' => array('default' => 0))); 54// 55// Process post parameters 56// ======================= 57$chkTfSearchRaw = filter_input(INPUT_POST, 'txtSearch', FILTER_SANITIZE_STRING); 58$chkSelAccGr = filter_input(INPUT_POST, 'selAccGr', FILTER_VALIDATE_INT, array('options' => array('default' => 0))); 59$chkSelCnfName = filter_input(INPUT_POST, 'selCnfName', FILTER_SANITIZE_STRING); 60$chkSelRegFilter = filter_input(INPUT_POST, 'selRegFilter', FILTER_VALIDATE_INT, array('options' => array('default' => 0))); 61$chkSelActiveFilter = filter_input(INPUT_POST, 'selActiveFilter', FILTER_VALIDATE_INT, array('options' => array('default' => 0))); 62// 63// Common text field value 64for ($i = 1; $i <= 23; $i++) { 65 $tmpVar = 'chkTfValue'.$i; 66 $$tmpVar = filter_input(INPUT_POST, 'tfValue'.$i, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES); 67 if (get_magic_quotes_gpc() == 0) { 68 $$tmpVar = addslashes($$tmpVar); 69 } 70 if (isset($$tmpVar)) { 71 $$tmpVar = $myVisClass->tfSecure($$tmpVar); 72 } 73} 74// Common argument text field value 75for ($i = 1; $i <= 8; $i++) { 76 $tmpVar = 'chkTfArg'.$i; 77 $$tmpVar = filter_input(INPUT_POST, 'tfArg'.$i, FILTER_UNSAFE_RAW); 78 if (get_magic_quotes_gpc() == 0) { 79 $$tmpVar = addslashes($$tmpVar); 80 } 81 if (isset($$tmpVar)) { 82 $$tmpVar = $myVisClass->tfSecure($$tmpVar); 83 } 84} 85// Common argument info field value 86for ($i = 1; $i <= 8; $i++) { 87 $tmpVar = 'chkTaArg'.$i.'Info'; 88 $$tmpVar = filter_input(INPUT_POST, 'taArg'.$i.'Info', FILTER_UNSAFE_RAW); 89 if (get_magic_quotes_gpc() == 0) { 90 $$tmpVar = addslashes($$tmpVar); 91 } 92 if (isset($$tmpVar)) { 93 $$tmpVar = $myVisClass->tfSecure($$tmpVar); 94 } 95} 96// Common multi select field value 97for ($i = 1; $i <= 8; $i++) { 98 $tmpVar = 'chkMselValue'.$i; 99 $tmpVar2 = 'intMselValue'.$i; 100 $$tmpVar = filter_input(INPUT_POST, 'mselValue'.$i, FILTER_SANITIZE_STRING, FILTER_FORCE_ARRAY); 101 // Multiselect data processing 102 if ((${$tmpVar}[0] == '') || (${$tmpVar}[0] == '0')) { 103 $$tmpVar2 = 0; 104 } elseif (${$tmpVar}[0] == '*') { 105 $$tmpVar2 = 2; 106 } else { 107 $$tmpVar2 = 1; 108 } 109} 110// Common select field value 111for ($i = 1; $i <= 5; $i++) { 112 $tmpVar = 'chkSelValue'.$i; 113 $$tmpVar = filter_input(INPUT_POST, 'selValue'.$i, FILTER_VALIDATE_INT, array('options' => array('default' => 0))); 114} 115//Common radio field value 116for ($i = 1; $i <= 18; $i++) { 117 $tmpVar = 'chkRadValue'.$i; 118 $$tmpVar = filter_input(INPUT_POST, 'radValue'.$i, FILTER_VALIDATE_INT, array('options' => array('default' => 2))); 119} 120// Common checkbox group 121$arrChar = explode(';', 'a;b;c;d;e;f;g;h'); 122for ($i = 1; $i <= 4; $i++) { 123 foreach ($arrChar as $elem) { 124 $tmpVar = 'chkChbGr'.$i.$elem; 125 $$tmpVar = filter_input(INPUT_POST, 'chbGr'.$i.$elem, FILTER_SANITIZE_STRING); 126 if ($$tmpVar != '') { 127 $$tmpVar .= ','; 128 } 129 } 130} 131// Common button value 132for ($i = 1; $i <= 5; $i++) { 133 $tmpVar = 'chkButValue'.$i; 134 $$tmpVar = filter_input(INPUT_POST, 'butValue'.$i, FILTER_SANITIZE_STRING); 135} 136// Common text NULL field value 137for ($i = 1; $i <= 9; $i++) { 138 $tmpVar = 'chkTfNullVal'.$i; 139 $$tmpVar = filter_input(INPUT_POST, 'tfNullVal'.$i, FILTER_SANITIZE_STRING); 140 if (isset($$tmpVar) && ($$tmpVar != '')) { 141 $myVisClass->checkNull($$tmpVar); 142 } else { 143 $$tmpVar = 'NULL'; 144 } 145} 146// Common checkbox field value 147$chkChbValue1 = filter_input(INPUT_POST, 'chbValue1', FILTER_VALIDATE_INT, array('options' => array('default' => 0))); 148$chkChbValue2 = filter_input(INPUT_POST, 'chbValue2', FILTER_VALIDATE_INT, array('options' => array('default' => 0))); 149// Common file selection field 150$chkDatValue1 = filter_input(INPUT_POST, 'datValue1', FILTER_SANITIZE_STRING); 151// Common text area value 152$chkTaValue1Raw = filter_input(INPUT_POST, 'taValue1', FILTER_SANITIZE_FULL_SPECIAL_CHARS); 153// Common text area value for file import (not SQL) 154$chkTaFileTextRaw = filter_input(INPUT_POST, 'taFileText', FILTER_UNSAFE_RAW); 155// Common text field with special chars 156$chkTfSpValue1 = filter_input(INPUT_POST, 'tfSpValue1', FILTER_UNSAFE_RAW); 157// 158// Quote special characters 159// ========================== 160if (get_magic_quotes_gpc() == 0) { 161 $chkTfSearchRaw = addslashes($chkTfSearchRaw); 162 $chkTaValue1Raw = addslashes($chkTaValue1Raw); 163 $chkTaFileTextRaw = addslashes($chkTaFileTextRaw); 164 $chkTfSpValue1 = addslashes($chkTfSpValue1); 165} 166// 167// Security function for text fields 168// ================================= 169$chkTfSearch = $myVisClass->tfSecure($chkTfSearchRaw); 170$chkTaValue1 = $myVisClass->tfSecure($chkTaValue1Raw); 171$chkTfSpValue1 = $myVisClass->tfSecure($chkTfSpValue1); 172$chkTaFileText = stripslashes($chkTaFileTextRaw); 173// 174// Search/sort/filter - session data 175// ================================= 176if (!isset($_SESSION['search'][$preSearchSession])) { 177 $_SESSION['search'][$preSearchSession] = ''; 178} 179if (!isset($_SESSION['filter'][$preSearchSession]['registered'])) { 180 $_SESSION['filter'][$preSearchSession]['registered'] = ''; 181} 182if (!isset($_SESSION['filter'][$preSearchSession]['active'])) { 183 $_SESSION['filter'][$preSearchSession]['active'] = ''; 184} 185if (!isset($_SESSION['search']['config_selection'])) { 186 $_SESSION['search']['config_selection'] = ''; 187} 188if (($chkModus == 'checkform') || ($chkModus == 'filter')) { 189 $_SESSION['search'][$preSearchSession] = $chkTfSearch; 190 $_SESSION['search']['config_selection'] = $chkSelCnfName; 191 $_SESSION['filter'][$preSearchSession]['registered'] = $chkSelRegFilter; 192 $_SESSION['filter'][$preSearchSession]['active'] = $chkSelActiveFilter; 193 $myContentClass->arrSession = $_SESSION; 194} 195// 196// Process additional templates/variables 197// ====================================== 198if (isset($_SESSION['templatedefinition']) && is_array($_SESSION['templatedefinition']) && 199 (count($_SESSION['templatedefinition']) != 0)) { 200 $intTemplates = 1; 201} else { 202 $intTemplates = 0; 203} 204if (isset($_SESSION['variabledefinition']) && is_array($_SESSION['variabledefinition']) && 205 (count($_SESSION['variabledefinition']) != 0)) { 206 $intVariables = 1; 207} else { 208 $intVariables = 0; 209} 210// 211// Common SQL parts 212// ================ 213if ($hidActive == 1) { 214 $chkActive = 1; 215} 216if ($chkGroupAdm == 1) { 217 $strGroupSQL = "`access_group`=$chkSelAccGr, "; 218} else { 219 $strGroupSQL = ''; 220} 221$preSQLCommon1 = "$strGroupSQL `active`='$chkActive', `register`='$chkRegister', `config_id`=$chkDomainId, " 222 . '`last_modified`=NOW()'; 223$preSQLCommon2 = "$strGroupSQL `active`='$chkActive', `register`='0', `config_id`=$chkDomainId, `last_modified`=NOW()"; 224$intRet1 = 0; 225$intRet2 = 0; 226$intRet3 = 0; 227$intRet4 = 0; 228$intRet5 = 0; 229$intRet6 = 0; 230$intRet7 = 0; 231$intRet8 = 0; 232// 233// Check read and write access 234// =========================== 235if (isset($prePageKey)) { 236 // Global read access (0 = access granted) 237 $intGlobalReadAccess = $myVisClass->checkAccountGroup($prePageKey, 'read'); 238 // Global write access (0 = access granted) 239 $intGlobalWriteAccess = $myVisClass->checkAccountGroup($prePageKey, 'write'); 240 $myContentClass->intGlobalWriteAccess = $intGlobalWriteAccess; 241} 242if (!isset($preNoAccessGrp) || ($preNoAccessGrp == 0)) { 243 if ($chkDataId != 0) { 244 $strSQLWrite = "SELECT `access_group` FROM `$preTableName` WHERE `id`=".$chkDataId; 245 $intWriteAccessId = $myVisClass->checkAccountGroup((int)$myDBClass->getFieldData($strSQLWrite), 'write'); 246 $myContentClass->intWriteAccessId = $intWriteAccessId; 247 } 248 if ($chkListId != 0) { 249 $strSQLWrite = "SELECT `access_group` FROM `$preTableName` WHERE `id`=".$chkListId; 250 $intReadAccessId = $myVisClass->checkAccountGroup((int)$myDBClass->getFieldData($strSQLWrite), 'read'); 251 $intWriteAccessId = $myVisClass->checkAccountGroup((int)$myDBClass->getFieldData($strSQLWrite), 'write'); 252 $myContentClass->intWriteAccessId = $intWriteAccessId; 253 } 254} 255// 256// Data processing 257// =============== 258if (($chkModus == 'make') && ($intGlobalWriteAccess == 0)) { 259 $intError = 0; 260 $intSuccess = 0; 261 // Get write access groups 262 $strAccess = $myVisClass->getAccessGroups('write'); 263 // Write configuration file 264 if ($preTableName == 'tbl_host') { 265 /** @var string $strDomainWhere - defined in prepend_adm.php */ 266 $strSQL = "SELECT `id` FROM `$preTableName` " 267 . "WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1'"; 268 $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount); 269 if ($booReturn == false) { 270 $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage); 271 } 272 if ($booReturn && ($intDataCount != 0)) { 273 foreach ($arrData as $data) { 274 $intReturn = $myConfigClass->createConfigSingle($preTableName, $data['id']); 275 if ($intReturn == 1) { 276 $intError++; 277 $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage); 278 } else { 279 $intSuccess++; 280 } 281 } 282 } else { 283 $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, ' 284 . 'not found or you do not have write permission!'), $strErrorMessage); 285 } 286 if ($intSuccess != 0) { 287 $myVisClass->processMessage(translate('Configuration files successfully written!'), $strInfoMessage); 288 } 289 if ($intError != 0) { 290 $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, ' 291 . 'not found or you do not have write permission!'), $strErrorMessage); 292 } 293 } elseif ($preTableName == 'tbl_service') { 294 /** @var string $strDomainWhere - defined in prepend_adm.php */ 295 $strSQL = "SELECT `id`, `$preKeyField` FROM `$preTableName` " 296 . "WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1' " 297 . "GROUP BY `$preKeyField`, `id`"; 298 $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount); 299 if ($booReturn == false) { 300 $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage); 301 } 302 if ($booReturn && ($intDataCount != 0)) { 303 foreach ($arrData as $data) { 304 $intReturn = $myConfigClass->createConfigSingle($preTableName, $data['id']); 305 if ($intReturn == 1) { 306 $intError++; 307 $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage); 308 } else { 309 $intSuccess++; 310 } 311 } 312 } else { 313 $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, ' 314 . 'not found or you do not have write permission!'), $strErrorMessage); 315 } 316 if ($intSuccess != 0) { 317 $myVisClass->processMessage(translate('Configuration files successfully written!'), $strInfoMessage); 318 } 319 if ($intError != 0) { 320 $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, ' 321 . 'not found or you do not have write permission!'), $strErrorMessage); 322 } 323 } else { 324 $intReturn = $myConfigClass->createConfig($preTableName, 0); 325 if ($intReturn == 1) { 326 $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage); 327 } 328 if ($intReturn == 0) { 329 $myVisClass->processMessage($myConfigClass->strInfoMessage, $strInfoMessage); 330 } 331 } 332 $chkModus = 'display'; 333} elseif (($chkModus == 'checkform') && ($chkSelModify == 'info')) { 334 // Display additional relation information 335 if ($preTableName == 'tbl_service') { 336 $intReturn = $myDataClass->infoRelation($preTableName, $chkListId, "$preKeyField,service_description"); 337 } else { 338 $intReturn = $myDataClass->infoRelation($preTableName, $chkListId, $preKeyField); 339 } 340 $myVisClass->processMessage($myDataClass->strInfoMessage, $strConsistMessage); 341 $chkModus = 'display'; 342} elseif (($chkModus == 'checkform') && ($chkSelModify == 'delete') && ($intGlobalWriteAccess == 0)) { 343 $intReturn = 1; 344 // Delete selected datasets 345 if (($preTableName == 'tbl_user') && ($chkTfValue5 == 'Admin')) { 346 $myVisClass->processMessage(translate('Admin cannot be deleted'), $strErrorMessage); 347 $intReturn = 0; 348 } elseif ((($preTableName == 'tbl_datadomain') || ($preTableName == 'tbl_configtarget')) && 349 ($chkTfValue3 == 'localhost')) { 350 $myVisClass->processMessage(translate("Localhost can't be deleted"), $strErrorMessage); 351 $intReturn = 0; 352 } elseif (($preTableName == 'tbl_user') || ($preTableName == 'tbl_datadomain') || 353 ($preTableName == 'tbl_configtarget')) { 354 $intReturn = $myDataClass->dataDeleteEasy($preTableName, $chkListId); 355 } else { 356 $strInfoMessageTmp = $strInfoMessage; 357 if ($preTableName == 'tbl_service') { 358 $intRetVal = $myDataClass->infoRelation($preTableName, $chkListId, "$preKeyField,service_description"); 359 } else { 360 $intRetVal = $myDataClass->infoRelation($preTableName, $chkListId, $preKeyField); 361 } 362 if ($intRetVal == 0) { 363 $strInfoMessage = $strInfoMessageTmp; 364 $intReturn = $myDataClass->dataDeleteFull($preTableName, $chkListId); 365 } 366 } 367 $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage); 368 $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage); 369 $chkModus = 'display'; 370} elseif (($chkModus == 'checkform') && ($chkSelModify == 'copy') && ($intGlobalWriteAccess == 0)) { 371 // Copy selected datasets 372 $intReturn = $myDataClass->dataCopyEasy($preTableName, $preKeyField, $chkListId, $chkSelTarDom); 373 if ($intReturn == 1) { 374 $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage); 375 } 376 if ($intReturn == 0) { 377 $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage); 378 } 379 $chkModus = 'display'; 380} elseif (($chkModus == 'checkform') && ($chkSelModify == 'activate') && ($intGlobalWriteAccess == 0)) { 381 // Activate selected datasets 382 $intReturn = $myDataClass->dataActivate($preTableName, $chkListId); 383 if ($intReturn == 1) { 384 $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage); 385 } 386 if ($intReturn == 0) { 387 $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage); 388 } 389 $chkModus = 'display'; 390} elseif (($chkModus == 'checkform') && ($chkSelModify == 'deactivate') && ($intGlobalWriteAccess == 0)) { 391 // Deactivate selected datasets 392 $intReturn = $myDataClass->dataDeactivate($preTableName, $chkListId); 393 if ($intReturn == 1) { 394 $myVisClass->processMessage($myDataClass->strErrorMessage, $strErrorMessage); 395 } 396 if ($intReturn == 0) { 397 $myVisClass->processMessage($myDataClass->strInfoMessage, $strInfoMessage); 398 } 399 // Remove deactivated files 400 if ($preTableName == 'tbl_host') { 401 if ($chkListId != 0) { 402 $strChbName = 'chbId_' .$chkListId; 403 $_POST[$strChbName] = 'on'; 404 } 405 // Get write access groups 406 $strAccess = $myVisClass->getAccessGroups('write'); 407 // Getting data sets 408 $strSQL = 'SELECT `id`, `host_name` FROM `' .$preTableName. '` ' 409 . "WHERE `active`='0' AND `access_group` IN ($strAccess) AND `config_id`=".$chkDomainId; 410 $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount); 411 if ($booReturn && ($intDataCount != 0) && ($chkDomainId != 0)) { 412 $intReturn = $myConfigClass->getConfigTargets($arrConfigID); 413 $intError = 0; 414 $intSuccess = 0; 415 if (($arrConfigID != 1) && is_array($arrConfigID)) { 416 foreach ($arrData as $elem) { 417 $strChbName = 'chbId_' .$elem['id']; 418 // was the current record is marked for deactivate? 419 if ((filter_input(INPUT_POST, $strChbName) != null) && 420 (filter_input(INPUT_POST, $strChbName, FILTER_SANITIZE_STRING) == 'on')) { 421 $intCount = 0; 422 $intReturn = 0; 423 foreach ($arrConfigID as $intConfigID) { 424 $intReturn += $myConfigClass->moveFile('host', $elem['host_name']. '.cfg', $intConfigID); 425 if ($intReturn == 0) { 426 $myDataClass->writeLog(translate('Host file deleted:'). ' ' .$elem['host_name'] 427 . '.cfg'); 428 $intCount++; 429 } 430 } 431 if ($intReturn == 0) { 432 $intSuccess++; 433 } 434 if ($intReturn != 0) { 435 $intError++; 436 } 437 } 438 } 439 if (($intSuccess != 0) && ($intCount != 0)) { 440 $myVisClass->processMessage(translate('The assigned, no longer used configuration files were ' 441 . 'deleted successfully!').$intCount, $strInfoMessage); 442 } 443 if ($intError != 0) { 444 $myVisClass->processMessage(translate('Errors while deleting the old configuration file - please ' 445 . 'check!:'), $strErrorMessage); 446 } 447 } 448 } elseif ($chkDomainId == 0) { 449 $myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check ' 450 . 'manually'), $strErrorMessage); 451 } 452 } elseif ($preTableName == 'tbl_service') { 453 if ($chkListId != 0) { 454 $strChbName = 'chbId_' .$chkListId; 455 $_POST[$strChbName] = 'on'; 456 } 457 // Get write access groups 458 $strAccess = $myVisClass->getAccessGroups('write'); 459 // Getting data sets 460 $strSQL = 'SELECT `id`, `config_name` FROM `' .$preTableName. '` ' 461 . "WHERE `active`='0' AND `access_group` IN ($strAccess) AND `config_id`=".$chkDomainId; 462 $booReturn = $myDBClass->hasDataArray($strSQL, $arrData, $intDataCount); 463 if ($booReturn && ($intDataCount != 0) && ($chkDomainId != 0)) { 464 $intReturn = $myConfigClass->getConfigTargets($arrConfigID); 465 $intError = 0; 466 $intSuccess = 0; 467 if (($arrConfigID != 1) && is_array($arrConfigID)) { 468 $intCount = 0; 469 foreach ($arrData as $elem) { 470 $strChbName = 'chbId_' .$elem['id']; 471 // was the current record is marked for deactivate? 472 if (filter_input(INPUT_POST, $strChbName) && (filter_input(INPUT_POST, $strChbName) == 'on')) { 473 $intServiceCount = $myDBClass->countRows("SELECT * FROM `$preTableName` " 474 . "WHERE `$preKeyField`='".$elem['config_name']."' " 475 . "AND `config_id`=$chkDomainId AND `active`='1'"); 476 if ($intServiceCount == 0) { 477 $intReturn = 0; 478 foreach ($arrConfigID as $intConfigID) { 479 $intReturn += $myConfigClass->moveFile( 480 'service', 481 $elem['config_name']. '.cfg', 482 $intConfigID 483 ); 484 if ($intReturn == 0) { 485 $myDataClass->writeLog(translate('Service file deleted:'). ' ' . 486 $elem['config_name']. '.cfg'); 487 } 488 $intCount++; 489 } 490 if ($intReturn == 0) { 491 $intSuccess++; 492 } 493 if ($intReturn != 0) { 494 $intError++; 495 } 496 } 497 } 498 } 499 if (($intSuccess != 0) && ($intCount != 0)) { 500 $myVisClass->processMessage(translate('The assigned, no longer used configuration files were ' 501 . 'deleted successfully!'), $strInfoMessage); 502 } 503 if ($intError != 0) { 504 $myVisClass->processMessage(translate('Errors while deleting the old configuration file - please ' 505 . 'check!:'), $strErrorMessage); 506 } 507 } 508 } elseif ($chkDomainId == 0) { 509 $myVisClass->processMessage(translate('Common files cannot be removed from target systems - please check ' 510 . 'manually'), $strErrorMessage); 511 } 512 } 513 $chkModus = 'display'; 514} elseif (($chkModus == 'checkform') && ($chkSelModify == 'modify')) { 515 // Open the dataset to modify 516 if ($intReadAccessId == 0) { 517 $booReturn = $myDBClass->hasSingleDataset("SELECT * FROM `$preTableName` " 518 . 'WHERE `id`=' .$chkListId, $arrModifyData); 519 if ($booReturn == false) { 520 $myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage); 521 $myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage); 522 $chkModus = 'display'; 523 } else { 524 $chkModus = 'add'; 525 } 526 } else { 527 $myVisClass->processMessage(translate('No permission to open configuration!'), $strErrorMessage); 528 $chkModus = 'display'; 529 } 530} elseif (($chkModus == 'checkform') && ($chkSelModify == 'config') && ($intGlobalWriteAccess == 0)) { 531 // Write configuration file (hosts and services) 532 $intDSId = (int)substr(array_search('on', filter_input_array(INPUT_POST), true), 6); 533 if (isset($chkListId) && ($chkListId != 0)) { 534 $intDSId = $chkListId; 535 } 536 $intValCount = 0; 537 foreach (filter_input_array(INPUT_POST) as $key => $elem) { 538 if ($elem == 'on') { 539 $intValCount++; 540 } 541 } 542 if ($intValCount > 1) { 543 $intDSId = 0; 544 } 545 $intReturn = $myConfigClass->createConfigSingle($preTableName, $intDSId); 546 if ($intReturn == 1) { 547 $myVisClass->processMessage($myConfigClass->strErrorMessage, $strErrorMessage); 548 } 549 if ($intReturn == 0) { 550 $myVisClass->processMessage($myConfigClass->strInfoMessage, $strInfoMessage); 551 } 552 $chkModus = 'display'; 553} 554// 555// Some common list view functions 556// =============================== 557if ($chkModus != 'add') { 558 // Get Group id's with READ 559 $strAccess = $myVisClass->getAccessGroups('read'); 560 // Include domain list 561 /** @var HTML_Template_IT $mastertp */ 562 $myVisClass->insertDomainList($mastertp); 563 // Process filter string 564} 565