function BB_InitLangmap($path, $default = "") { global $bb_admin_lang, $bb_admin_def_lang, $bb_langmap; $bb_langmap = array(); BB_SetLanguage($path, ""); if ($default != "") { BB_SetLanguage($path, $default); } $bb_admin_def_lang = $bb_admin_lang; if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) { $langs = explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]); foreach ($langs as $lang) { $lang = trim($lang); $pos = strpos($lang, ";"); if ($pos !== false) { $lang = substr($lang, 0, $pos); } if ($lang != "") { $result = BB_SetLanguage($path, $lang); if ($result["success"]) { break; } } } } }
} require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/random.php"; Str::ProcessAllInput(); // Initialize the global CSPRNG instance. $sso_rng = new CSPRNG(); // Timing attack defense. SSO_RandomSleep(); // Calculate the remote IP address. $sso_ipaddr = SSO_GetRemoteIP(); // Initialize language settings. BB_InitLangmap(SSO_ROOT_PATH . "/" . SSO_LANG_PATH . "/", SSO_DEFAULT_LANG); if (isset($_REQUEST["lang"]) && $_REQUEST["lang"] == "") { unset($_REQUEST["lang"]); } if (isset($_REQUEST["lang"])) { BB_SetLanguage(SSO_ROOT_PATH . "/" . SSO_LANG_PATH . "/", $_REQUEST["lang"]); } function SSO_DisplayError($msg, $htmlmsg = "") { global $sso_header, $sso_footer; if (isset($_REQUEST["sso_ajax"])) { echo htmlspecialchars(BB_Translate($msg)) . $htmlmsg; } else { echo $sso_header; echo "<div class=\"sso_server_message_wrap" . ($htmlmsg == "" ? " sso_server_message_wrap_nosplit" : "") . "\"><div class=\"sso_server_error\">" . htmlspecialchars(BB_Translate($msg)) . "</div></div>"; echo $htmlmsg; if (isset($_COOKIE["sso_server_lastapp"]) && $_COOKIE["sso_server_lastapp"] !== "") { $url = @base64_decode($_COOKIE["sso_server_lastapp"]); if ($url !== false) { echo "<div class=\"sso_main_info\"><a href=\"" . htmlspecialchars($url) . "\">" . htmlspecialchars(BB_Translate("Return to the application")) . "</a></div>"; }
require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/phpseclib/AES.php"; } require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/random.php"; SetDebugLevel(); Str::ProcessAllInput(); // Don't proceed any further if this is an acciental re-upload of this file to the root path. if (SSO_STO_ADMIN && SSO_ROOT_PATH == str_replace("\\", "/", dirname(__FILE__))) { exit; } if (SSO_USE_HTTPS && !BB_IsSSLRequest()) { header("Location: " . BB_GetFullRequestURLBase("https")); exit; } // Initialize language settings. BB_InitLangmap(SSO_ROOT_PATH . "/" . SSO_LANG_PATH . "/", SSO_DEFAULT_LANG); BB_SetLanguage(SSO_ROOT_PATH . "/" . SSO_LANG_PATH . "/", SSO_ADMIN_LANG); // Initialize the global CSPRNG instance. $sso_rng = new CSPRNG(); // Calculate the remote IP address. $sso_ipaddr = SSO_GetRemoteIP(); $bb_randpage = SSO_BASE_RAND_SEED; $bb_rootname = "SSO Server Admin"; $bb_usertoken = ""; $sso_site_admin = false; $sso_user_id = "0"; // Require developers to inject code here. For example, integration with a specific login system or IP address restrictions. if (file_exists("admin_hook.php")) { require_once "admin_hook.php"; } if (!is_string($bb_usertoken) || $bb_usertoken === "") { echo "Invalid user token.\n";
if (isset($bb_accounts["sessions"][$_REQUEST["bbl"]])) { $bb_session = $bb_accounts["sessions"][$_REQUEST["bbl"]]; if ($bb_session["expire"] < time()) { BB_DeleteExpiredUserSessions(); } else { $bb_account = $bb_accounts["users"][$bb_session["username"]]; } } } if ($bb_account === false) { BB_RunPluginAction("access_denied"); echo htmlspecialchars(BB_Translate("Invalid credentials.")); exit; } if (isset($bb_account["lang"]) && $bb_account["lang"] != "") { BB_SetLanguage(ROOT_PATH . "/" . LANG_PATH . "/", $bb_account["lang"]); } BB_RunPluginAction("account_valid"); // Load in a revision, if required. $bb_revision_num = -1; $bb_revision = false; $bb_revision_writeable = true; BB_RunPluginAction("pre_revision_load"); if (isset($_REQUEST["bb_revnum"]) && (int) $_REQUEST["bb_revnum"] > -1) { require_once $bb_dir . "/" . $bb_file . "_" . $bb_pref_lang . "_rev.php"; $bb_revision_num = (int) $_REQUEST["bb_revnum"]; if (!isset($bb_langpagerevisions["revisions"][$bb_revision_num])) { $bb_revision_num = -1; } else { $bb_revision = $bb_langpagerevisions["revisions"][$bb_revision_num]; $bb_langpage = unserialize($bb_revision[1]);
function BB_SetUserLanguage($username, $lang) { global $bb_accounts, $bb_admin_pref_lang; if (!isset($bb_accounts["users"][$username])) { return false; } $result = BB_SetLanguage($lang); if (!$result["success"]) { return false; } BB_RunPluginActionInfo("pre_bb_setuserlanguage", $bb_accounts["users"][$username]); $bb_accounts["users"][$username]["lang"] = $bb_admin_pref_lang; BB_RunPluginActionInfo("post_bb_setuserlanguage", $bb_accounts["users"][$username]); return BB_SaveUserAccounts(); }