static function saveToSession() { if (array_key_exists('flashMessage', $GLOBALS)) { session_setVariable('flashMessage', $GLOBALS['flashMessage']); session_setVariable('flashMessageType', $GLOBALS['flashMessageType']); } }
static function set($user, $detailsVisible, $userPrefs, $skin, $widgetMask) { if ($user) { $user->detailsVisible = $detailsVisible; $user->preferences = $userPrefs; if (session_isValidSkin($skin)) { $user->skin = $skin; } $user->widgetMask = $widgetMask; $user->widgetCount = Widget::WIDGET_COUNT; $user->save(); session_setVariable('user', $user); } else { session_setAnonymousPrefs($userPrefs); if (session_isValidSkin($skin)) { session_setSkin($skin); } // Set the widgetMask / widgetCount cookies. This is a bit complex because we want to delete the cookie when the settings are all default. if ($widgetMask == Widget::getDefaultWidgetMask()) { session_setWidgetMask(null); session_setWidgetCount(null); } else { session_setWidgetMask($widgetMask); session_setWidgetCount(Widget::WIDGET_COUNT); } } }
function session_loadUserFromCookie() { if (!isset($_COOKIE['prefs']) || !isset($_COOKIE['prefs']['lll'])) { return; } $cookie = Cookie::get_by_cookieString($_COOKIE['prefs']['lll']); $user = $cookie ? User::get_by_id($cookie->userId) : null; if ($user && $user->identity) { session_setVariable('user', $user); } else { // The cookie is invalid or this account doesn't have an OpenID identity yet. setcookie("prefs[lll]", NULL, time() - 3600, '/'); unset($_COOKIE['prefs']['lll']); if ($cookie) { $cookie->delete(); } } }
function authenticate($clientId, $secret) { $this->fetchWellKnownConfig(); if (!$clientId || !$secret) { throw new OpenIDException('Autentificare eșuată.'); } $url = $this->wellKnownConfig['authorization_endpoint']; $nonce = util_randomCapitalLetterString(32); $state = util_randomCapitalLetterString(32); session_setVariable('openid_connect_nonce', $nonce); session_setVariable('openid_connect_state', $state); session_setVariable('openid_connect_provider', $this->provider); session_setVariable('openid_connect_client', $clientId); session_setVariable('openid_connect_secret', $secret); $params = array('client_id' => $clientId, 'openid.realm' => util_getFullServerUrl(), 'nonce' => $nonce, 'redirect_uri' => $this->getReturnTo(), 'response_type' => 'code', 'scope' => 'openid email', 'state' => $state); $url .= '?' . http_build_query($params, null, '&'); util_redirect($url); }
if (count($lexems) == 0 && empty($definitions)) { $searchType = SEARCH_APPROXIMATE; $lexems = Lexem::searchApproximate($cuv, $hasDiacritics, true); if (count($lexems) == 1) { FlashMessage::add("Ați fost redirecționat automat la forma „{$lexems[0]->formNoAccent}”."); } else { if (!count($lexems)) { FlashMessage::add("Niciun rezultat relevant pentru „{$cuv}”."); } } } if (count($lexems) == 1 && $cuv != $lexems[0]->formNoAccent) { // Convenience redirect when there is only one correct form. We want all pages to be canonical $sourcePart = $source ? "-{$source->urlName}" : ''; session_setVariable('redirect', true); session_setVariable('init_word', $cuv); util_redirect(util_getWwwRoot() . "definitie{$sourcePart}/{$lexems[0]->formNoAccent}" . ($xml ? '/xml' : '')); } smarty_assign('lexems', $lexems); if ($searchType == SEARCH_INFLECTED) { // For successful searches, load the definitions, inflections and linguistic articles $definitions = Definition::loadForLexems($lexems, $sourceId, $cuv, $exclude_unofficial); smarty_assign('wikiArticles', WikiArticle::loadForLexems($lexems)); } if (isset($definitions)) { $searchResults = SearchResult::mapDefinitionArray($definitions); } } $conjugations = NULL; $declensions = NULL; if ($searchType == SEARCH_INFLECTED || $searchType == SEARCH_LEXEM_ID || $searchType == SEARCH_FULL_TEXT || $searchType == SEARCH_MULTIWORD) {
$sendButton = util_getRequestParameter('send'); $detailsVisible = util_getRequestParameter('detailsVisible'); $userPrefs = util_getRequestCheckboxArray('userPrefs', ','); $skin = util_getRequestParameter('skin'); $user = session_getUser(); if (!$user) { util_redirect('auth/login'); } if ($sendButton) { $user->detailsVisible = $detailsVisible ? 1 : 0; $user->preferences = $userPrefs; if (session_isValidSkin($skin)) { $user->skin = $skin; } $user->save(); session_setVariable('user', $user); FlashMessage::add('Informațiile au fost salvate.', 'info'); } else { $detailsVisible = $user->detailsVisible; $skin = session_getSkin(); $userPrefs = $user->preferences; } foreach (preg_split('/,/', $userPrefs) as $pref) { if (isset($userPreferencesSet[$pref])) { $userPreferencesSet[$pref]['checked'] = true; } } smarty_assign('detailsVisible', $detailsVisible); smarty_assign('userPrefs', $userPreferencesSet); smarty_assign('skin', $skin); smarty_assign('availableSkins', pref_getServerPreference('skins'));