/* Decoded by unphp.net */ getQuery(true); $f6->select("*"); $f6->from($PT->quoteName("#__miniorange_dirsync_config")); $f6->where($PT->quoteName("id") . " = 1"); $PT->setQuery($f6); $sB = $PT->loadAssoc(); $aO = $sB["allow_login"]; $O9 = JURI::root(); $vx = $G6["username"]; $C_ = $G6["password"]; if (!($C_ == '' || $C_ == " ")) { goto vr; } $bE->status = JAuthentication::STATUS_FAILURE; $tC->enqueueMessage("Kindly please enter the password.", "warning"); return; vr: $PT = JFactory::getDbo(); $f6 = $PT->getQuery(true); $f6->select("*"); $f6->from($PT->quoteName("#__miniorange_dirsync_config")); $f6->where($PT->quoteName("id") . " = 1"); $PT->setQuery($f6); $sB = $PT->loadAssoc(); if ($sB["ldap_login"] == "ch") { goto eW; } $bE->status = JAuthentication::STATUS_FAILURE; $tC->enqueueMessage("You are not enabled LDAP login. Please contact administrator.", "error"); goto mz; eW: $Aj = $sB["ldap_server_url"]; $Aj = MoDirsyncUtility::decrypt($Aj); $JJ = Self::getConnection($Aj); if (!$JJ) { goto Ha; } $jy = $sB["service_account_dn"]; $jy = MoDirsyncUtility::decrypt($jy); $Tr = $sB["service_account_password"]; $Tr = MoDirsyncUtility::decrypt($Tr); $f1 = $sB["search_base"]; $f1 = MoDirsyncUtility::decrypt($f1); $vm = explode(",", $f1); $su = $sB["search_filter"]; $Rj = str_replace("?", $vx, $su); $af = null; $lJ = null; $LF = null; $Fi = @ldap_bind($JJ, $jy, $Tr); $sX = ldap_error($JJ); if (!(strtolower($sX) == "success")) { goto JB; } if (!ldap_search($JJ, $f1, $Rj)) { goto KJ; } $af = ldap_search($JJ, $f1, $Rj); $LF = ldap_first_entry($JJ, $af); $lJ = ldap_get_entries($JJ, $af); if (!$LF) { goto rk; } $Gt = @ldap_bind($JJ, $lJ[0]["dn"], $C_); rk: if (!isset($lJ[0][$sB["email"]][0])) { goto mb; } $dD = self::get_user_from_joomla($lJ[0][$sB["email"]][0]); mb: if (!(isset($dD) && $dD)) { goto oM; } $PT = JFactory::getDbo(); $f6 = $PT->getQuery(true); $vs = array($PT->quoteName("user_already_exist") . " = " . $PT->quote(1)); $Zn = array($PT->quoteName("id") . " = " . $PT->quote($dD->id)); $f6->update($PT->quoteName("#__users"))->set($vs)->where($Zn); $PT->setQuery($f6); $PT->execute(); oM: if (isset($Gt) && $Gt) { goto S9; } if (!isset($lJ[0]["mail"][0])) { goto Ts; } $bE->email = $lJ[0]["mail"][0]; Ts: $bE->status = JAuthentication::STATUS_FAILURE; return; goto KV; S9: $bE->type = "Ldap"; $bE->error_message = ''; $bE->fullname = $lJ[0]["givenname"][0] . " " . $lJ[0]["sn"][0]; $bE->username = $lJ[0][$sB["username"]][0]; if (!isset($lJ[0][$sB["email"]][0])) { goto ir; } $bE->email = $lJ[0][$sB["email"]][0]; ir: $bE->status = JAuthentication::STATUS_SUCCESS; KV: KJ: JB: Ha: mz: } public static function getConnection($Aj) { $JJ = ldap_connect($Aj); if (!(version_compare(PHP_VERSION, "5.3.0") >= 0)) { goto gE; } ldap_set_option($JJ, LDAP_OPT_NETWORK_TIMEOUT, 5); gE: ldap_set_option($JJ, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($JJ, LDAP_OPT_REFERRALS, 0); return $JJ; } public static function selectMaxOrdering($df) { $PT = JFactory::getDbo(); $f6 = $PT->getQuery(true); $f6->select("MAX(ordering)"); $f6->from($PT->quoteName("#__user_profiles")); $f6->where($PT->quoteName("user_id") . " = " . $PT->quote($df)); $PT->setQuery($f6); $UX = $PT->loadResult(); return isset($UX) && !empty($UX) ? $UX : "0"; } public static function get_user_from_joomla($uj) { $PT = JFactory::getDBO(); $f6 = $PT->getQuery(true)->select("id")->from("#__users")->where("email=" . $PT->quote($uj)); $PT->setQuery($f6); $sB = $PT->loadObject(); return $sB; } public static function onUserAfterLogin() { $post = JFactory::getApplication()->input->post->getArray(); $PT = JFactory::getDbo(); $f6 = $PT->getQuery(true); $f6->select("*"); $f6->from($PT->quoteName("#__miniorange_dirsync_config")); $f6->where($PT->quoteName("id") . " = 1"); $PT->setQuery($f6); $sB = $PT->loadAssoc(); $user = $post["username"]; $R0 = JFactory::getUser(); $vx = $user; $Aj = $sB["ldap_server_url"]; $Aj = MoDirsyncUtility::decrypt($Aj); $JJ = Self::getConnection($Aj); $jy = $sB["service_account_dn"]; $jy = MoDirsyncUtility::decrypt($jy); $Tr = $sB["service_account_password"]; $Tr = MoDirsyncUtility::decrypt($Tr); $f1 = $sB["search_base"]; $f1 = MoDirsyncUtility::decrypt($f1); $vm = explode(",", $f1); $su = $sB["search_filter"]; $Rj = str_replace("?", $vx, $su); $af = null; $lJ = null; $LF = null; $Fi = @ldap_bind($JJ, $jy, $Tr); $af = ldap_search($JJ, $f1, $Rj); if (!$af) { goto x4; } $LF = ldap_first_entry($JJ, $af); $lJ = ldap_get_entries($JJ, $af); x4: if (!$LF) { goto CE; } if (!($lJ[0][$sB["username"]][0] && $lJ[0][$sB["email"]][0])) { goto Id; } $vx = $lJ[0][$sB["username"]][0]; $VS = $lJ[0][$sB["email"]][0]; $PT = JFactory::getDbo(); $f6 = $PT->getQuery(true); $vs = array($PT->quoteName("email") . " = " . $PT->quote($VS)); $Zn = array($PT->quoteName("id") . " = " . $PT->quote($R0->id)); $f6->update($PT->quoteName("#__users"))->set($vs)->where($Zn); $PT->setQuery($f6); $g0 = $PT->execute(); Id: $PT = JFactory::getDbo(); $f6 = $PT->getQuery(true); $f6->select(array("profile_key", "profile_value", "ordering")); $f6->from($PT->quoteName("#__user_profiles")); $f6->where($PT->quoteName("user_id") . " =" . $PT->quote($R0->id)); $PT->setQuery($f6); $Yt = $PT->loadRowList(); if (!$Yt) { goto El; } $PT = JFactory::getDbo(); $f6 = $PT->getQuery(true); $f6->delete($PT->quoteName("#__user_profiles")); $f6->where($PT->quoteName("user_id") . " =" . $PT->quote($R0->id)); $PT->setQuery($f6); $Yt = $PT->execute(); El: if (!1) { goto Km; } $sa = $sB["user_profile_attributes"]; $df = $R0->id; $C6 = 0; if (!(isset($sa) && !empty($sa))) { goto io; } $sa = json_decode($sa, true); $Fr = Self::selectMaxOrdering($df); foreach ($sa as $Be) { $X2 = strtolower($Be["attr_name"]); $Ju = strtolower($Be["attr_value"]); if (!isset($lJ[0][$Ju][0])) { goto Wh; } if (is_array($lJ[0][$Ju])) { goto qX; } $Ju = isset($lJ[0][$Ju]) ? $lJ[0][$Ju] : ''; goto Gc; qX: $Ju = isset($lJ[0][$Ju][0]) ? $lJ[0][$Ju][0] : ''; Gc: $PT = JFactory::getDbo(); $f6 = $PT->getQuery(true); $ze = array("user_id", "profile_key", "profile_value", "ordering"); $Lj = array($df, $PT->quote("profile." . $X2), $PT->quote($Ju), ++$Fr); $f6->insert($PT->quoteName("#__user_profiles"))->columns($PT->quoteName($ze))->values(implode(",", $Lj)); $PT->setQuery($f6); $PT->execute(); Wh: aa: } pL: io: Km: $PT = JFactory::getDbo(); $f6 = $PT->getQuery(true); $f6->select("*"); $f6->from($PT->quoteName("#__miniorange_ldap_role_mapping")); $f6->where($PT->quoteName("id") . " = 1"); $PT->setQuery($f6); $sB = $PT->loadAssoc(); $PT = JFactory::getDbo(); $f6 = $PT->getQuery(true); $f6->select("user_already_exist"); $f6->from($PT->quoteName("#__users")); $f6->where($PT->quoteName("id") . " = " . $PT->quote($R0->id)); $PT->setQuery($f6); $Zf = $PT->loadAssoc(); if (!($Zf["user_already_exist"] != 1 || $sB["disable_update_existing_users_role"] != 1)) { goto k2; } $TV = $sB["mapping_value_default"]; if (isset($R0->groups[8])) { goto yt; } $ku = 1; goto ok; yt: $ku = 0; ok: if (!($sB["enable_ldap_role_mapping"] && $ku)) { goto zp; } JUserHelper::addUserToGroup($R0->id, $TV); if (!($Zf["user_already_exist"] != 1 || $sB["disable_update_existing_users_role"] != 1)) { goto DL; } foreach ($R0->groups as $TD) { if (!($TD != $TV && $TD != "8")) { goto zX; } JUserHelper::removeUserFromGroup($R0->id, $TD); zX: K9: } J3: DL: zp: k2: if (!(($Zf["user_already_exist"] != 1 || $sB["disable_update_existing_users_role"] != 1) && $sB["enable_ldap_role_mapping"])) { goto cp; } $Fi = @ldap_bind($JJ, $jy, $Tr); $nw = array("memberof"); if (!isset($sB["mapping_memberof_attribute"])) { goto pR; } $nw = array($sB["mapping_memberof_attribute"]); pR: $af = ldap_search($JJ, $f1, $Rj, $nw); if (!$af) { goto FC; } $LF = ldap_first_entry($JJ, $af); $lJ = ldap_get_entries($JJ, $af); FC: $YU = $sB["role_mapping_key_value"]; $YU = json_decode($YU, true); $cv = $sB["role_mapping_groupvalue"]; $cv = json_decode($cv, true); $C6 = 1; foreach ($YU as $KJ) { if (empty($lJ[0]["memberof"])) { goto bT; } if (!in_array($KJ, $lJ[0]["memberof"])) { goto Xh; } JUserHelper::addUserToGroup($R0->id, $cv[$C6]); Xh: bT: $C6++; kj: } Sk: cp: CE: } } T_: ?>