function CheckFields(&$arFields, $ID) { global $DB, $APPLICATION; $aMsg = array(); if (array_key_exists("NAME", $arFields)) { $arFields["NAME"] = trim($arFields["NAME"]); } if (array_key_exists("ACTIVE", $arFields)) { $arFields["ACTIVE"] = $arFields["ACTIVE"] === "Y" ? "Y" : "N"; } if (array_key_exists("SELECTABLE", $arFields)) { $arFields["SELECTABLE"] = $arFields["SELECTABLE"] == "N" ? "N" : "Y"; } if (array_key_exists("WEIGHT", $arFields)) { $weight = intval($arFields["WEIGHT"]); if ($weight < 0) { $weight = 0; } elseif ($weight > 100) { $weight = 100; } $arFields["WEIGHT"] = $weight; } if ($arFields["ACTIVE"] == "Y" && $arFields["ROLE_ID"] != "SLAVE") { $obCheck = new CClusterDBNodeCheck(); $nodeDB = $obCheck->SlaveNodeConnection($arFields["DB_HOST"], $arFields["DB_NAME"], $arFields["DB_LOGIN"], $arFields["DB_PASSWORD"], $arFields["ROLE_ID"] == "MASTER" ? $arFields["MASTER_HOST"] : false, $arFields["ROLE_ID"] == "MASTER" ? $arFields["MASTER_PORT"] : false); if (is_object($nodeDB)) { $arFields["SERVER_ID"] = intval($obCheck->GetServerVariable($nodeDB, "server_id")); } else { if (!array_key_exists("STATUS", $arFields)) { $arFields["STATUS"] = "OFFLINE"; } $aMsg[] = array("id" => "", "text" => $nodeDB); } } if (!empty($aMsg)) { $e = new CAdminException($aMsg); $APPLICATION->ThrowException($e); return false; } return true; }
function ShowStepNoError() { $wizard = $this->GetWizard(); $wizard->SetVar('status', ''); $obCheck = new CClusterDBNodeCheck(); $IsReplicationRunning = $obCheck->SlaveNodeIsReplicationRunning($wizard->GetVar("db_host"), $GLOBALS["DB"]->DBName, $wizard->GetVar("db_login"), $wizard->GetVar("db_password"), $wizard->GetVar("master_host", true), $wizard->GetVar("master_port", true)); if (is_object($IsReplicationRunning)) { $this->content .= '<p>' . GetMessage("CLUWIZ_STEP4_SLAVE_IS_RUNNING") . '</p>'; $arCheckList = array_merge($obCheck->SlaveNodeCommon($IsReplicationRunning), $obCheck->SlaveNodeForReplication($IsReplicationRunning)); $this->ShowCheckList($arCheckList); $bNextStep = $this->CheckListHasNoError($arCheckList); if ($bNextStep) { $wizard->SetVar('status', 'online'); } } elseif ($IsReplicationRunning === false) { $DB = $obCheck->SlaveNodeConnection($wizard->GetVar("db_host"), $GLOBALS["DB"]->DBName, $wizard->GetVar("db_login"), $wizard->GetVar("db_password"), $wizard->GetVar("master_host", true), $wizard->GetVar("master_port", true)); if (is_object($DB)) { $arCheckList = array_merge($obCheck->SlaveNodeCommon($DB), $obCheck->SlaveNodeForReplication($DB), $obCheck->SlaveNodeForMaster($DB)); $this->ShowCheckList($arCheckList); $bNextStep = $this->CheckListHasNoError($arCheckList); } else { $this->content .= '<p class="cluwiz_err">' . $DB . '</p><p>' . GetMessage("CLUWIZ_STEP4_CONN_ERROR") . '</p>'; $bNextStep = false; } } else { $this->content .= '<p class="cluwiz_err">' . $IsReplicationRunning . '</p><p>' . GetMessage("CLUWIZ_STEP4_CONN_ERROR") . '</p>'; $bNextStep = false; } if ($bNextStep) { $this->SetNextStep("final"); } else { $this->SetNextStep("step4"); } }
function ShowStepNoError() { $wizard = $this->GetWizard(); $obCheck = new CClusterDBNodeCheck(); $DB = $obCheck->SlaveNodeConnection($wizard->GetVar("db_host"), $wizard->GetVar("db_name"), $wizard->GetVar("db_login"), $wizard->GetVar("db_password")); if (is_object($DB)) { $arCheckList = $obCheck->SlaveNodeCommon($DB); $this->ShowCheckList($arCheckList); $bNextStep = $this->CheckListHasNoError($arCheckList); } else { $this->content .= '<p class="cluwiz_err">' . $DB . '</p><p>' . GetMessage("CLUWIZ_STEP4_CONN_ERROR") . '</p>'; $bNextStep = false; } if ($bNextStep) { $this->SetNextStep("final"); } else { $this->SetNextStep("step4"); } }