/** * * @see XenForo_ControllerAdmin_Option::actionIndex() */ public function actionIndex() { $response = parent::actionIndex(); if ($response instanceof XenForo_ControllerResponse_View) { $addOns = $this->_getAddOnModel()->getAllAddOns(); $addOnId = $this->_input->filterSingle('addon_id', XenForo_Input::STRING); if (!empty($GLOBALS['XenForo_Route_PrefixAdmin_Options']) && !$addOnId) { $addOnId = XenForo_Helper_Cookie::getCookie('edit_addon_id'); } if ($addOnId) { XenForo_Helper_Cookie::setCookie('edit_addon_id', $addOnId); } else { XenForo_Helper_Cookie::deleteCookie('edit_addon_id'); } $groupCount = count($response->params['groups']); if ($addOnId && !empty($addOns[$addOnId])) { XenForo_Helper_Cookie::setCookie('edit_addon_id', $addOnId); $addOn = $addOns[$addOnId]; $response->params['addOnSelected'] = $addOnId; if ($addOnId) { foreach ($response->params['groups'] as $groupKey => $group) { if ($addOnId != $group['addon_id']) { unset($response->params['groups'][$groupKey]); } } } $this->canonicalizeRequestUrl(XenForo_Link::buildAdminLink('add-ons/options', $addOn)); } else { $this->canonicalizeRequestUrl(XenForo_Link::buildAdminLink('add-ons/options', array('addon_id' => ''))); } $response->params['addOns'] = $addOns; $response->params['groupCount'] = $groupCount; } return $response; }
/** * Displays a form to change the visitor's language, or changes it if a language_id is present. * * @return XenForo_ControllerResponse_Abstract */ public function actionLanguage() { $visitor = XenForo_Visitor::getInstance(); if ($this->_input->inRequest('language_id')) { $this->_checkCsrfFromToken($this->_input->filterSingle('_xfToken', XenForo_Input::STRING)); $languageId = $this->_input->filterSingle('language_id', XenForo_Input::UINT); if ($languageId) { $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache(); if (!isset($languages[$languageId])) { $languageId = 0; } } if ($visitor['user_id']) { $dw = XenForo_DataWriter::create('XenForo_DataWriter_User'); $dw->setExistingData($visitor['user_id']); $dw->set('language_id', $languageId); $dw->save(); XenForo_Helper_Cookie::deleteCookie('language_id'); } else { XenForo_Helper_Cookie::setCookie('language_id', $languageId, 86400 * 365); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false)); } else { $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache(); $viewParams = array('languages' => $this->getModelFromCache('XenForo_Model_Language')->getAllLanguages(), 'redirect' => $this->getDynamicRedirect(false, false)); return $this->responseView('XenForo_ViewPublic_Misc_Language', 'language_chooser', $viewParams); } }
public static function getVisitor(XenForo_Visitor &$visitor) { if (class_exists('Sedo_DetectBrowser_Listener_Visitor') && isset($visitor->getBrowser['isMobile'])) { //External Addon $isMobile = $visitor->getBrowser['isMobile']; $isTablet = $visitor->getBrowser['isTablet']; } else { //XenForo $isMobile = XenForo_Visitor::isBrowsingWith('mobile'); $isTablet = ''; } if (!empty($isMobile)) { $options = XenForo_Application::get('options'); $mobileStyle = $options->sedoDefaultMobileStyle; if (!empty($isTablet)) { $mobileStyle = $options->sedoDefaultTabletStyle; } if (!empty($visitor['user_id'])) { //Only for members => guests use the default style option (unless they have choosen to use another style =>cookie: style_id) XenForo_Helper_Cookie::deleteCookie('style_id'); //case: visitor changed the default style, then log $getCookie = XenForo_Helper_Cookie::getCookie('mobile_style_id'); // the mobile_style_id is set here: Sedo_MobileStyleSelector_ControllerPublic_Misc if ($getCookie == false) { //No cookie => continue to force mobile style $visitor['style_id'] = $mobileStyle; } } //Force style if ($options->sedoForceMobileStyle && $visitor->style_id != $mobileStyle) { $visitor['style_id'] = $mobileStyle; } } }
public function actionRevert() { if ($cookies = XenForo_Helper_Cookie::getCookie('EWRporta')) { foreach ($cookies as $key => $cookie) { XenForo_Helper_Cookie::deleteCookie('EWRporta[' . $key . '][order]'); XenForo_Helper_Cookie::deleteCookie('EWRporta[' . $key . '][position]'); } } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('portal/blocks')); }
public function actionIndex() { $class = $this->_input->filterSingle('class', XenForo_Input::STRING); if ($class) { return $this->responseReroute(__CLASS__, 'view'); } $addOns = $this->_getAddOnModel()->getAllAddOns(); $xenOptions = XenForo_Application::get('options'); $addOnSelected = ''; if ($xenOptions->th_dataWriters_enableAddOnChooser) { $addOnId = $this->_input->filterSingle('addon_id', XenForo_Input::STRING); if (!empty($GLOBALS['ThemeHouse_DataWriters_Route_PrefixAdmin_DataWriters']) && !$addOnId) { $addOnId = XenForo_Helper_Cookie::getCookie('edit_addon_id'); } if ($addOnId && !empty($addOns[$addOnId])) { XenForo_Helper_Cookie::setCookie('edit_addon_id', $addOnId); $addOn = $addOns[$addOnId]; $addOnSelected = $addOnId; $this->canonicalizeRequestUrl(XenForo_Link::buildAdminLink('add-ons/data-writers', $addOn)); } else { $this->canonicalizeRequestUrl(XenForo_Link::buildAdminLink('add-ons/data-writers')); XenForo_Helper_Cookie::deleteCookie('edit_addon_id'); } } $addOns['XenForo'] = array('addon_id' => 'XenForo', 'active' => true, 'title' => 'XenForo'); $rootPath = XenForo_Autoloader::getInstance()->getRootDir(); $dataWriters = array(); $dataWriterCount = 0; $totalDataWriters = 0; foreach ($addOns as $addOnId => $addOn) { $dataWriterPath = $rootPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $addOnId) . DIRECTORY_SEPARATOR . 'DataWriter'; if (!file_exists($dataWriterPath)) { continue; } $directory = new RecursiveDirectoryIterator($dataWriterPath); $iterator = new RecursiveIteratorIterator($directory); $regex = new RegexIterator($iterator, '/^.+\\.php$/i', RecursiveRegexIterator::GET_MATCH); foreach ($regex as $fileinfo) { $classPath = str_replace($rootPath, '', $fileinfo[0]); $classPath = pathinfo($classPath, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . pathinfo($classPath, PATHINFO_FILENAME); $dirs = explode(DIRECTORY_SEPARATOR, $classPath); $dirs = array_filter($dirs); $className = implode('_', $dirs); if (!$xenOptions->th_dataWriters_enableAddOnChooser || !$addOnSelected || $addOnId == $addOnSelected) { $dataWriters[$addOnId][$className] = array('class' => $className, 'filename' => pathinfo($classPath, PATHINFO_FILENAME)); $dataWriterCount++; } $totalDataWriters++; } } unset($addOns['XenForo']); $viewParams = array('addOns' => $addOns, 'addOnSelected' => $addOnSelected, 'dataWriters' => $dataWriters, 'dataWriterCount' => $dataWriterCount, 'totalDataWriters' => $totalDataWriters); return $this->responseView('ThemeHouse_DataWriters_ViewAdmin_DataWriter_List', 'th_datawriter_list_datawriters', $viewParams); }
/** * Displays a form to change the visitor's location, or changes it if a location_id is present. * * @return XenForo_ControllerResponse_Abstract */ public function actionLocation() { $visitor = XenForo_Visitor::getInstance(); if ($this->_input->inRequest('location')) { $this->_checkCsrfFromToken($this->_input->filterSingle('_xfToken', XenForo_Input::STRING)); $localtion = $this->_input->filterSingle('location', XenForo_Input::STRING); if ($localtion) { $locations = array(); $options = XenForo_Application::get('options'); if (!empty($options->BRTC_locations) && is_array($options->BRTC_locations)) { $locations = $options->BRTC_locations; } if (!isset($locations[$localtion])) { $localtion = ''; } } if ($visitor['user_id']) { $dw = XenForo_DataWriter::create('XenForo_DataWriter_User'); $dw->setExistingData($visitor['user_id']); $dw->set('location', $localtion); $dw->save(); XenForo_Helper_Cookie::deleteCookie('location'); } else { if ($localtion) { XenForo_Helper_Cookie::setCookie('location', $localtion, 86400 * 365); } else { XenForo_Helper_Cookie::deleteCookie('location'); } } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false)); } else { $locations = array(); $options = XenForo_Application::get('options'); if (!empty($options->BRTC_locations) && is_array($options->BRTC_locations)) { $locations = $options->BRTC_locations; } $viewParams = array('locations' => $locations, 'redirect' => $this->_input->filterSingle('redirect', XenForo_Input::STRING)); return $this->responseView('XenForo_ViewPublic_Misc_Location', 'BRTC_location_chooser', $viewParams); } }
public function actionRunDeferred() { $redirect = $this->getDynamicRedirectIfNot(XenForo_Link::buildAdminLink('tools/run-deferred')); $input = $this->_input->filter(array('execute' => XenForo_Input::UINT)); /* @var $deferModel XenForo_Model_Deferred */ $deferModel = $this->getModelFromCache('XenForo_Model_Deferred'); $status = ''; $canCancel = false; if (XenForo_Helper_Cookie::getCookie('cancel_defer')) { $deferModel->cancelFirstRunnableDeferred(); XenForo_Helper_Cookie::deleteCookie('cancel_defer'); } if ($input['execute'] && $this->_request->isPost()) { $continued = $deferModel->run(true, null, $status, $canCancel); if (!$continued) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect); } } $viewParams = array('status' => $status, 'canCancel' => $canCancel, 'redirect' => $redirect); $containerParams = array('containerTemplate' => 'PAGE_CONTAINER_SIMPLE', 'allowManualDeferredRun' => false); return $this->responseView('XenForo_ViewAdmin_Tools_RunDeferred', 'tools_run_deferred', $viewParams, $containerParams); }
public function actionMultiQuote() { $input = $this->_input->filter(array('formId' => XenForo_Input::STRING, 'quoteSelections' => array(XenForo_Input::STRING, 'array' => true))); if ($this->_request->has('postIds')) { $mode = 'quote'; $quoteIds = $this->_input->filterSingle('postIds', array(XenForo_Input::STRING, 'array' => true)); $postIds = array(); foreach ($quoteIds as $quoteId) { $postId = preg_replace('/^(\\d+)(-\\d+)?$/', '$1', $quoteId); $postIds[$postId] = $postId; } } else { $mode = 'overlay'; $cookieValue = XenForo_Helper_Cookie::getCookie('MultiQuote'); $postIds = explode(',', $cookieValue); } if (empty($postIds)) { return $this->responseError(new XenForo_Phrase('no_messages_selected')); } $visitor = XenForo_Visitor::getInstance(); $threadModel = $this->_getThreadModel(); $postModel = $this->_getPostModel(); $posts = $postModel->getPostsByIds($postIds, array('join' => XenForo_Model_Post::FETCH_USER | XenForo_Model_Post::FETCH_THREAD | XenForo_Model_Post::FETCH_FORUM, 'permissionCombinationId' => $visitor['permission_combination_id'])); // permission filter foreach ($posts as $postId => $post) { $post['permissions'] = XenForo_Permission::unserializePermissions($post['node_permission_cache']); if (!$postModel->canViewPostAndContainer($post, $post, $post, $null, $post['permissions'])) { unset($posts[$postId]); } } $viewParams = array('formId' => $input['formId']); $bbCodeModel = $this->getModelFromCache('XenForo_Model_BbCode'); if ($mode == 'overlay') { $datedPosts = array(); foreach ($posts as $postId => $post) { $i = 1; $quoteId = $postId . '-1'; if (array_key_exists($quoteId, $input['quoteSelections'])) { do { $message = $bbCodeModel->getBbCodeFromSelectionHtml($input['quoteSelections'][$quoteId]); $datedPosts[$post['post_date']][$quoteId] = $post; $datedPosts[$post['post_date']][$quoteId]['message'] = $message; $quoteId = $postId . '-' . ++$i; } while (array_key_exists($quoteId, $input['quoteSelections'])); } else { $datedPosts[$post['post_date']][$postId] = $post; } } ksort($datedPosts); $posts = array(); foreach ($datedPosts as $postDate => $postIds) { foreach ($postIds as $postId => $post) { $posts[$postId] = $post; } } if (empty($posts)) { // clear the cookie, as its value is invalid or unusable XenForo_Helper_Cookie::deleteCookie('MultiQuote'); return $this->responseError(new XenForo_Phrase('selected_messages_not_found')); } $viewParams['posts'] = $posts; return $this->responseView('XenForo_ViewPublic_Thread_MultiQuoteOverlay', 'thread_multi_quote_overlay', $viewParams); } else { $orderedPosts = array(); foreach ($quoteIds as $quoteId) { $postId = $this->_getPostIdFromQuoteId($quoteId); if (isset($posts[$postId])) { $orderedPosts[$quoteId] = $posts[$postId]; if (array_key_exists($quoteId, $input['quoteSelections'])) { $message = $bbCodeModel->getBbCodeFromSelectionHtml($input['quoteSelections'][$quoteId]); $orderedPosts[$quoteId]['message'] = $message; } } } $viewParams['posts'] = $orderedPosts; $quotes = ''; foreach ($orderedPosts as $post) { $quotes .= trim($postModel->getQuoteTextForPost($post)) . "\n\n"; } $viewParams['quote'] = trim($quotes); return $this->responseView('XenForo_ViewPublic_Thread_MultiQuote', '', $viewParams); } }
/** * Deletes the current session. The session cookie will be removed as well. */ public function delete() { if ($this->_sessionExists) { $this->deleteSessionFromSource($this->_sessionId); if (!headers_sent()) { XenForo_Helper_Cookie::deleteCookie($this->_config['cookie'], true); } } $this->_session = array(); $this->_dataChanged = false; $this->_sessionId = ''; $this->_sessionExists = false; $this->_saved = false; }
/** * Clears the inline mod cookie for the given type. */ public function clearCookie() { XenForo_Helper_Cookie::deleteCookie('inlinemod_' . $this->inlineModKey); }
public function actionChangeStyle() { $visitor = XenForo_Visitor::getInstance()->toArray(); $styleModel = $this->_getStyleModel(); $styleModel->setAdminStyles(true); if ($this->_input->inRequest('style_id')) { $styleId = $this->_input->filterSingle('style_id', XenForo_Input::UINT); if ($styleId) { $styles = XenForo_Application::isRegistered('adminStyles') ? XenForo_Application::get('adminStyles') : $styleModel->getAllStyles(); if (!isset($styles[$styleId]) || !$styles[$styleId]['brass_user_selectable'] && !$visitor['is_admin']) { $styleId = 0; } } if ($visitor['user_id']) { $dw = XenForo_DataWriter::create('XenForo_DataWriter_User'); $dw->setExistingData($visitor['user_id']); $dw->set('brass_admin_style_id', $styleId); $dw->save(); XenForo_Helper_Cookie::deleteCookie('brass_admin_style_id'); } else { XenForo_Helper_Cookie::setCookie('brass_admin_style_id', $styleId, 86400 * 365); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false)); } else { $styles = $styleModel->getAllStylesAsFlattenedTree(); $styleId = $this->_input->filterSingle('style_id', XenForo_Input::UINT); if ($styleId && !empty($styles[$styleId]['brass_user_selectable'])) { $style = $styles[$styleId]; } else { $style = false; } $viewParams = array('styles' => $styles, 'targetStyle' => $style, 'redirect' => $this->_input->filterSingle('redirect', XenForo_Input::STRING), 'isManagerAdminStyle' => XenForo_Visitor::getInstance()->hasAdminPermission('BRASS_adminStyle')); return $this->responseView('Brivium_AdminStyleSystem_ViewAdmin_Style', 'BRASS_style_chooser', $viewParams); } }