openAdmDBSrv($arrTemplate['STEP3_TEXT_02'],$strErrorMessage);
if ($intError == 0) $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_02'],$strErrorMessage);
// Check NagiosQL version
if ($intError == 0) {
$arrTemplate['STEP3_TEXT_03'] = 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'] = translate("Upgrading from version")." ".$setQLVersion." ".translate("to")." ".$preNagiosQL_ver;
$arrTemplate['STEP3_TEXT_05_SHOW'] = "showfield";
$intError = $myInstClass->updateQLDB($arrTemplate['STEP3_TEXT_06'],$strErrorMessage,$arrUpdate);
}
// Converting database to UTF8
if ($intError == 0) {
$arrTemplate['STEP3_TEXT_07'] = 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'] = 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'] = 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'] = translate("Create new NagiosQL database");
// Check database connection
$intOldDBStatus = 0;
if ($intError == 0) $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_02'],$strErrorMessage);
if ($intError == 0) {
$intOldDBStatus = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_02'],$strErrorMessage);
if (($intOldDBStatus == 0) && ($_SESSION['install']['dbdrop'] == 0)) {
$strErrorMessage .= translate("Database already exists and drop database was not selected, please correct or manage manually")."
";
$arrTemplate['STEP3_TEXT_02'] = "".translate("failed")."";
$intError = 1;
} else {
$arrTemplate['STEP3_TEXT_02'] = "".translate("passed")."";
}
}
// 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'] = "".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);
}
// Grant NagiosQL database user
if ($intError == 0) {
$arrTemplate['STEP3_TEXT_11_SHOW'] = "showfield";
$intError = $myInstClass->grantDBUser($arrTemplate['STEP3_TEXT_12'],$strErrorMessage);
}
// Write initial SQL data to database
if ($intError == 0) $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_02'],$strErrorMessage);
if ($intError == 0) {
$arrTemplate['STEP3_TEXT_13_SHOW'] = "showfield";
$arrInsert[] = $preSqlNewInstall;
$intError = $myInstClass->updateQLDB($arrTemplate['STEP3_TEXT_14'],$strErrorMessage,$arrInsert);
}
// 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) {
$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'] = "