function initializeLicenseObjectArray()
{
$fs = get_bloginfo("name");
$uM = site_url();
if (!empty(get_option("mo_saml_environment_objects"))) {
goto EO;
}
$SA = array($fs => LicenseHelper::getNewEnvironmentObject($uM));
update_option("mo_saml_environment_objects", $SA);
EO:
update_option("mo_saml_selected_environment", $fs);
}
function updateLicenseObjects($ek)
{
$My = array();
$tt = array();
if (!checkIssetAndEmpty($ek, "mo_saml_environment_names")) {
goto RU;
}
$My = $ek["mo_saml_environment_names"];
RU:
if (!checkIssetAndEmpty($ek, "mo_saml_environment_urls")) {
goto PP;
}
$tt = $ek["mo_saml_environment_urls"];
PP:
if (!(isArrayWithDuplicateEntries($My) || isArrayWithDuplicateEntries($tt) || isCurrentEnvironmentRemoved($tt))) {
goto Y6;
}
return false;
Y6:
$TW = array_combine($My, $tt);
$TW = array_filter($TW);
$KY = createEnvironmentObjectsForEnvironments($TW);
update_option("mo_saml_environment_objects", $KY);
return true;
}
function checkIssetAndEmpty($IN, $Iq)
{
if (!(isset($IN[$Iq]) and !empty($IN[$Iq]))) {
goto Ob;
}
return true;
Ob:
return false;
}
function mo_saml_filter_environmentObjects($KY, $TW)
{
foreach ($KY as $bM => $OY) {
if (!(empty($bM) || empty($OY->getWpSiteUrl()) || !array_key_exists($bM, $TW))) {
goto JM;
}
unset($KY[$bM]);
JM:
vW:
}
tD:
return $KY;
}
function isArrayWithDuplicateEntries($TW)
{
$Oo = array_unique($TW);
if (count($TW) != count($Oo)) {
goto Sw;
}
return false;
goto C4;
Sw:
return true;
C4:
}
function createEnvironmentObjectsForEnvironments($TW)
{
$KY = get_option("mo_saml_environment_objects");
$Je = LicenseHelper::getCurrentEnvironment();
$eZ = isset($KY[$Je]) ? $KY[$Je]->getPluginSettings() : null;
foreach ($TW as $GH => $cI) {
$G3 = $cI;
if (!(substr($G3, -1) == "/")) {
goto D1;
}
$G3 = substr($G3, 0, -1);
D1:
$j1 = LicenseHelper::fetchExistingEnvironmentName($GH, $cI);
if (!empty($j1)) {
goto af;
}
$zP = new LicenseObject($G3);
$KY[$GH] = $zP;
$zP->setPluginSettings($eZ);
goto N1;
af:
$Y1 = $KY[$j1];
$Y1->setWpSiteUrl($G3);
unset($KY[$j1]);
$KY[$GH] = $Y1;
N1:
St:
}
EL:
$KY = mo_saml_filter_environmentObjects($KY, $TW);
return $KY;
}
function isCurrentEnvironmentRemoved($tt)
{
$HF = LicenseHelper::parseEnvironmentUrl(site_url());
foreach ($tt as $yb) {
if (!($HF == LicenseHelper::parseEnvironmentUrl($yb))) {
goto Cn;
}
return false;
Cn:
sS:
}
xq:
return true;
}
© 2023 Quttera Ltd. All rights reserved.