translate('Requirements'); $arrTemplate['STEP2_BOX'] = $myInstClass->translate($_SESSION['install']['mode']); $arrTemplate['STEP3_BOX'] = $myInstClass->translate('Finish'); $arrTemplate['STEP3_TITLE'] = "NagiosQL ".$myInstClass->translate($_SESSION['install']['mode']).": ".$myInstClass->translate("Finishing Setup"); $arrTemplate['INST_VISIBLE'] = "showfield"; $arrTemplate['STEP4_SUB_TITLE'] = $myInstClass->translate("Deploy NagiosQL settings"); $arrTemplate['STEP3_TEXT_01'] = $myInstClass->translate("Database server connection (privileged user)"); $arrTemplate['STEP3_TEXT_03'] = $myInstClass->translate("Database server version"); $arrTemplate['STEP3_TEXT_05'] = $myInstClass->translate("Database server support"); $arrTemplate['STEP3_TEXT_07'] = $myInstClass->translate("Delete existing NagiosQL database"); $arrTemplate['STEP3_TEXT_09'] = $myInstClass->translate("Creating new database"); $arrTemplate['STEP3_TEXT_11'] = $myInstClass->translate("Installing NagiosQL database tables"); $arrTemplate['STEP3_TEXT_13'] = $myInstClass->translate("Create NagiosQL database user"); $arrTemplate['STEP3_TEXT_15'] = $myInstClass->translate("Set initial NagiosQL Administrator"); $arrTemplate['STEP3_TEXT_17'] = $myInstClass->translate("Database server connection (NagiosQL user)"); $arrTemplate['STEP4_TEXT_01'] = $myInstClass->translate("Writing global settings to database"); $arrTemplate['STEP4_TEXT_03'] = $myInstClass->translate("Writing database configuration to settings.php"); $arrTemplate['STEP4_TEXT_05'] = $myInstClass->translate("Import Nagios sample data"); $arrTemplate['STEP4_TEXT_07'] = $myInstClass->translate("Create and/or store NagiosQL path settings"); $arrTemplate['STEP4_VISIBLE'] = "hidefield"; $arrTemplate['STEP3_TEXT_02_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_03_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_05_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_07_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_09_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_11_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_13_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_15_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_17_SHOW'] = "hidefield"; $arrTemplate['STEP4_TEXT_03_SHOW'] = "hidefield"; $arrTemplate['STEP4_TEXT_05_SHOW'] = "hidefield"; $arrTemplate['STEP4_TEXT_07_SHOW'] = "hidefield"; // // Check any data before installation // ================================== $intInstError = 0; // // Doing installation/upgrade // ========================== if ($_SESSION['install']['mode'] == "Update") { $arrTemplate['STEP3_SUB_TITLE'] = $myInstClass->translate("Updating existing NagiosQL database"); // // Include database class // ====================== if ($_SESSION['install']['dbtype'] == "mysqli") { // Include and initialize mysqli class include("../functions/mysqli_class.php"); $myDBClass = new mysqlidb; } else if ($_SESSION['install']['dbtype'] == "pgsql") { // Include and initialize pgsql class include("../functions/pgsql_class.php"); $myDBClass = new pgsqldb; } else { $strErrorMessage .= $myInstClass->translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; $strStatusMessage = "".$myInstClass->translate("failed").""; $intError = 1; } // Set DB parameters $myDBClass->arrParams['server'] = $_SESSION['install']['dbserver']; $myDBClass->arrParams['port'] = $_SESSION['install']['dbport']; $myDBClass->arrParams['username'] = $_SESSION['install']['admuser']; $myDBClass->arrParams['password'] = $_SESSION['install']['admpass']; $myDBClass->arrParams['database'] = $_SESSION['install']['dbname']; // Include classes if ($intError == 0) $myInstClass->myDBClass =& $myDBClass; // Check database connection if ($intError == 0) $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); if ($intError == 0) $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); $arrTemplate['STEP3_TEXT_02_SHOW'] = "showfield"; // Check NagiosQL version if ($intError == 0) { $arrTemplate['STEP3_TEXT_03'] = $myInstClass->translate("Installed NagiosQL version"); $arrTemplate['STEP3_TEXT_03_SHOW'] = "showfield"; $intError = $myInstClass->checkQLVersion($arrTemplate['STEP3_TEXT_04'],$strErrorMessage,$arrUpdate,$setQLVersion); } // Upgrade NagiosQL DB if ($intError == 0) { $arrTemplate['STEP3_TEXT_05'] = $myInstClass->translate("Upgrading from version")." ".$setQLVersion." ".$myInstClass->translate("to")." ".$preNagiosQL_ver; $arrTemplate['STEP3_TEXT_05_SHOW'] = "showfield"; $intError = $myInstClass->updateQLDB($arrTemplate['STEP3_TEXT_06'],$strErrorMessage,$arrUpdate); } if (($_SESSION['install']['dbtype'] == "mysql") && (version_compare($setQLVersion,"3.2.0") == -1)) { // Converting database to UTF8 if ($intError == 0) { $arrTemplate['STEP3_TEXT_07'] = $myInstClass->translate("Converting database to utf8 character set"); $arrTemplate['STEP3_TEXT_07_SHOW'] = "showfield"; $intError = $myInstClass->convQLDB($arrTemplate['STEP3_TEXT_08'],$strErrorMessage); } // Converting database tables to UTF8 if ($intError == 0) { $arrTemplate['STEP3_TEXT_09'] = $myInstClass->translate("Converting database tables to utf8 character set"); $arrTemplate['STEP3_TEXT_09_SHOW'] = "showfield"; $intError = $myInstClass->convQLDBTables($arrTemplate['STEP3_TEXT_10'],$strErrorMessage); } // Converting database fields to UTF8 if ($intError == 0) { $arrTemplate['STEP3_TEXT_11'] = $myInstClass->translate("Converting database fields to utf8 character set"); $arrTemplate['STEP3_TEXT_11_SHOW'] = "showfield"; $intError = $myInstClass->convQLDBFields($arrTemplate['STEP3_TEXT_12'],$strErrorMessage); } } // Reconnect Database with new user if ($intError == 0) { $arrTemplate['STEP3_TEXT_17_SHOW'] = "showfield"; $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_18'],$strErrorMessage,1); $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_18'],$strErrorMessage,1); } // Deploy NagiosQL database settings if ($intError == 0) { $arrTemplate['STEP4_VISIBLE'] = "showfield"; $intError = $myInstClass->updateSettingsDB($arrTemplate['STEP4_TEXT_02'],$strErrorMessage); } // Write database settings to file if ($intError == 0) { $arrTemplate['STEP4_TEXT_03_SHOW'] = "showfield"; $intError = $myInstClass->updateSettingsFile($arrTemplate['STEP4_TEXT_04'],$strErrorMessage); } } else { $arrTemplate['STEP3_SUB_TITLE'] = $myInstClass->translate("Create new NagiosQL database"); // // Include database class // ====================== if ($_SESSION['install']['dbtype'] == "mysqli") { // Include and initialize mysqli class include("../functions/mysqli_class.php"); $myDBClass = new mysqlidb; } else if ($_SESSION['install']['dbtype'] == "pgsql") { // Include and initialize pgsql class include("../functions/pgsql_class.php"); $myDBClass = new pgsqldb; //} else if ($_SESSION['install']['dbtype'] == "sqlite3") { // // Include sqlite3 and initialize class // include("../functions/sqlite3_class.php"); // $myDBClass = new sqlite3db; } else { $strErrorMessage .= $myInstClass->translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; $strStatusMessage = "".$myInstClass->translate("failed").""; $intError = 1; } // Set DB parameters $myDBClass->arrParams['server'] = $_SESSION['install']['dbserver']; $myDBClass->arrParams['port'] = $_SESSION['install']['dbport']; $myDBClass->arrParams['username'] = $_SESSION['install']['admuser']; $myDBClass->arrParams['password'] = $_SESSION['install']['admpass']; $myDBClass->arrParams['database'] = $_SESSION['install']['dbname']; // Include classes if ($intError == 0) $myInstClass->myDBClass =& $myDBClass; // Check database connection $intOldDBStatus = 0; if ($intError == 0) $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); // Does the database already exist? if ($intError == 0) { $intOldDBStatus = $myInstClass->openDatabase($strTmpMessage,$strTmpError); $myDBClass->strErrorMessage = ""; if (($intOldDBStatus == 0) && ($_SESSION['install']['dbdrop'] == 0)) { $strErrorMessage .= $myInstClass->translate("Database already exists and drop database was not selected, please correct or manage manually")."
"; $arrTemplate['STEP3_TEXT_02'] = "".$myInstClass->translate("failed").""; $intError = 1; } else { $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); } } $arrTemplate['STEP3_TEXT_02_SHOW'] = "showfield"; $arrTemplate['STEP3_TEXT_02'] .= " (".$_SESSION['install']['dbtype'].")"; // Check database version if ($intError == 0) { $arrTemplate['STEP3_TEXT_03_SHOW'] = "showfield"; $arrTemplate['STEP3_TEXT_05_SHOW'] = "showfield"; $intError = $myInstClass->checkDBVersion($arrTemplate['STEP3_TEXT_06'],$strErrorMessage,$strVersion); if ($strVersion == "unknown") { $arrTemplate['STEP3_TEXT_04'] = "".$myInstClass->translate("unknown").""; } else { $arrTemplate['STEP3_TEXT_04'] = "".$strVersion.""; } } // Drop existing database if (($intError == 0) && ($_SESSION['install']['dbdrop'] == 1) && ($intOldDBStatus == 0)) { $arrTemplate['STEP3_TEXT_07_SHOW'] = "showfield"; $intError = $myInstClass->dropDB($arrTemplate['STEP3_TEXT_08'],$strErrorMessage); } // Create new database if ($intError == 0) { $arrTemplate['STEP3_TEXT_09_SHOW'] = "showfield"; $intError = $myInstClass->createDB($arrTemplate['STEP3_TEXT_10'],$strErrorMessage); echo $strErrorMessage; } // Write initial SQL data to database if ($intError == 0) $intError = $myInstClass->openDatabase($strTmp,$strErrorMessage); if ($intError == 0) { $arrTemplate['STEP3_TEXT_11_SHOW'] = "showfield"; $arrInsert[] = $preSqlNewInstall; $intError = $myInstClass->updateQLDB($arrTemplate['STEP3_TEXT_12'],$strErrorMessage,$arrInsert); } // Grant NagiosQL database user if ($intError == 0) { $arrTemplate['STEP3_TEXT_13_SHOW'] = "showfield"; $intError = $myInstClass->grantDBUser($arrTemplate['STEP3_TEXT_14'],$strErrorMessage); } // Create NagiosQL admin user if ($intError == 0) { $arrTemplate['STEP3_TEXT_15_SHOW'] = "showfield"; $intError = $myInstClass->createNQLAdmin($arrTemplate['STEP3_TEXT_16'],$strErrorMessage); } // Reconnect Database with new user if ($intError == 0) { $myDBClass->arrParams['username'] = $_SESSION['install']['dbuser']; $myDBClass->arrParams['password'] = $_SESSION['install']['dbpass']; $arrTemplate['STEP3_TEXT_17_SHOW'] = "showfield"; if ($intError == 0) $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_18'],$strErrorMessage,1); if ($intError == 0) $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_18'],$strErrorMessage,1); } // Deploy NagiosQL settings if ($intError == 0) { $arrTemplate['STEP4_VISIBLE'] = "showfield"; $intError = $myInstClass->updateSettingsDB($arrTemplate['STEP4_TEXT_02'],$strErrorMessage); } // Write database settings to file if ($intError == 0) { $arrTemplate['STEP4_TEXT_03_SHOW'] = "showfield"; $intError = $myInstClass->updateSettingsFile($arrTemplate['STEP4_TEXT_04'],$strErrorMessage); } // Write sample data to database if (($intError == 0) && ($_SESSION['install']['sample'] == 1)) { $arrTemplate['STEP4_TEXT_05_SHOW'] = "showfield"; $arrSample[] = "sql/import_nagios_sample.sql"; $intError = $myInstClass->updateQLDB($arrTemplate['STEP4_TEXT_06'],$strErrorMessage,$arrSample); } // Create NagiosQL path and write path settings to the database if ($intError == 0) { $arrTemplate['STEP4_TEXT_07_SHOW'] = "showfield"; $intError = $myInstClass->updateQLpath($arrTemplate['STEP4_TEXT_08'],$strErrorMessage); } } if ($intError != 0) { $arrTemplate['ERRORMESSAGE'] = "

".$strErrorMessage."

\n"; $arrTemplate['INFO_TEXT'] = ""; $arrTemplate['BUTTON'] = "
\n"; $arrTemplate['BUTTON'] .= "\n"; $arrTemplate['BUTTON'] .= "
".$myInstClass->translate("Back")."\n"; $arrTemplate['BUTTON'] .= "
\n"; } else { $arrTemplate['ERRORMESSAGE'] = ""; $arrTemplate['INST_VISIBLE'] = "showfield"; $arrTemplate['INFO_TEXT'] = $myInstClass->translate("Please delete the install directory to continue!"); $arrTemplate['BUTTON'] = "
\n"; $arrTemplate['BUTTON'] .= "finish
".$myInstClass->translate("Finish")."\n"; $arrTemplate['BUTTON'] .= "
\n"; } // // Write content // ============= $strContent = $myInstClass->parseTemplate($arrTemplate,$preIncludeContent); echo $strContent; ?>