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 static function Diktat(XenForo_Controller $controller, $action) { $visitor = XenForo_Visitor::getInstance(); 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; //$visitor->style_id = $mobileStyle; if (!empty($isTablet)) { $mobileStyle = $options->sedoDefaultTabletStyle; } $options->defaultStyleId = $mobileStyle; if ($options->sedoForceMobileStyle && $visitor->style_id != $mobileStyle) { //Should not be needed XenForo_Helper_Cookie::setCookie('style_id', $mobileStyle, 86400 * 365); } } }
/** * 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); } }
/** * Single-stage logout procedure */ public function actionIndex() { $csrfToken = $this->_input->filterSingle('_xfToken', XenForo_Input::STRING); $redirectResponse = $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false)); $userId = XenForo_Visitor::getUserId(); if (!$userId) { return $redirectResponse; } if ($this->_noRedirect() || !$csrfToken) { // request is likely from JSON, probably XenForo.OverlayTrigger, so show a confirmation dialog return $this->responseView('XenForo_ViewPublic_LogOut', 'log_out'); } else { $this->_checkCsrfFromToken($csrfToken); // remove an admin session if we're logged in as the same person if (XenForo_Visitor::getInstance()->get('is_admin')) { $class = XenForo_Application::resolveDynamicClass('XenForo_Session'); $adminSession = new $class(array('admin' => true)); $adminSession->start(); if ($adminSession->get('user_id') == $userId) { $adminSession->delete(); } } $this->getModelFromCache('XenForo_Model_Session')->processLastActivityUpdateForLogOut(XenForo_Visitor::getUserId()); XenForo_Application::get('session')->delete(); XenForo_Helper_Cookie::deleteAllCookies($this->_getRetainedCookies(), array('user' => array('httpOnly' => false))); XenForo_Visitor::setup(0); return $redirectResponse; } }
protected function _preSave() { parent::_preSave(); $code = $this->get('affiliate_code'); if (empty($code)) { $this->setAffiliateCode(); } if ($this->isInsert()) { $invitationModel = $this->_getInvitationModel(); $cookieVal = XenForo_Helper_Cookie::getCookie('ref'); if ($cookieVal) { $cookieParts = explode('_', $cookieVal); if (isset($cookieParts[1])) { $ref = $cookieParts[1]; $invitation = false; if ($cookieParts[0] == 'u') { $invitation = $invitationModel->getUserByCode($ref); } else { if ($cookieParts[0] == 'i') { $invitation = $invitationModel->getInvitationByCode($ref); } } if ($invitation) { if ($cookieParts[0] == 'i') { self::$_invitationId = $invitation['invite_id']; } $this->set('ref_user_id', $invitation['user_id']); } } } } }
public function getBlocks($getCookies = false, $layout1 = false, $layout2 = false, $layout3 = false) { if ($layout1) { if ($layout1 && ($layout = $this->getModelFromCache('EWRporta_Model_Layouts')->getLayoutById($layout1)) || $layout2 && ($layout = $this->getModelFromCache('EWRporta_Model_Layouts')->getLayoutById($layout2)) || $layout3 && ($layout = $this->getModelFromCache('EWRporta_Model_Layouts')->getLayoutById($layout3))) { $layout = unserialize($layout['blocks']); } elseif ($layout1 != 'portal') { return array(); } } $blocks = $this->fetchAllKeyed("\n\t\t\tSELECT *, 'disabled' AS position\n\t\t\t\tFROM EWRporta_blocks\n\t\t\tWHERE active = 1\n\t\t\tORDER BY block_id ASC\n\t\t", 'block_id'); if (!empty($layout)) { $_blocks = array(); foreach ($layout as $key => $position) { if (!empty($blocks[$key])) { $_blocks[$key] = array('position' => $position) + $blocks[$key]; } } $blocks = $_blocks + $blocks; } if ($getCookies && ($cookies = XenForo_Helper_Cookie::getCookie('EWRporta'))) { $_blocks = array(); foreach ($cookies as $key => $cookie) { if (!empty($blocks[$key]) && !empty($cookie['position'])) { $position = $blocks[$key]['locked'] ? $blocks[$key]['position'] : $cookie['position']; $_blocks[$key] = array('position' => $position) + $blocks[$key]; } } $blocks = $_blocks + $blocks; } return $blocks; }
protected function save($prefs) { if ($this->userId > 0) { $_db = $_db = XenForo_Application::getDb(); $_db->query("INSERT INTO geek_listings_prefs ( pref_user_id, pref_type_id, pref_cat, pref_subcat, pref_location, pref_lat, pref_lng, pref_alert_on_new, pref_email_on_new, pref_last_check, pref_last_alert, pref_last_email, pref_city, pref_country)\n VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, 0, ?, ? ) ON DUPLICATE KEY UPDATE\n pref_type_id=VALUES(pref_type_id),pref_cat=VALUES(pref_cat), pref_subcat=VALUES(pref_subcat), pref_location=VALUES(pref_location), pref_lat=VALUES(pref_lat), pref_lng=VALUES(pref_lng), pref_alert_on_new=VALUES(pref_alert_on_new), pref_email_on_new=VALUES(pref_email_on_new), pref_city=VALUES(pref_city), pref_country=VALUES(pref_country) ", [$this->userId, $this->typeId, $this->cat, $this->subcat, $this->location, $this->lat, $this->lng, $this->alert_on_new, $this->email_on_new, $this->city, $this->country]); } XenForo_Helper_Cookie::setCookie('GeekListing_prefs_' . $this->typeId, serialize($prefs)); }
public function deletePost($postID) { if (!($post = $this->getModelFromCache('XenForo_Model_Post')->getPostById($postID))) { return false; } $this->getModelFromCache('XenForo_Model_Post')->deletePost($post['post_id'], 'hard'); XenForo_Helper_Cookie::clearIdFromCookie($post['post_id'], 'inlinemod_posts'); return true; }
/** * Fetches $styleId from cookie if it's available, or returns the default style ID. * * @param int $allowMaster If true, allow the master style to be returned * * @return integer */ public function getStyleIdFromCookie($allowMaster = true) { $styleId = XenForo_Helper_Cookie::getCookie('edit_style_id'); if ($styleId === false) { $styleId = XenForo_Application::debugMode() ? 0 : XenForo_Application::get('options')->defaultStyleId; } if ((!$allowMaster || !XenForo_Application::debugMode()) && !$styleId) { $styleId = XenForo_Application::get('options')->defaultStyleId; } return $styleId; }
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); }
protected function _deleteContent(array $content, $reason, array $viewingUser) { $dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_ProfilePost', XenForo_DataWriter::ERROR_SILENT); if ($dw->setExistingData($content)) { $dw->setExtraData(XenForo_DataWriter_DiscussionMessage::DATA_DELETE_REASON, $reason); $dw->set('message_state', 'deleted'); $dw->save(); } XenForo_Model_Log::logModeratorAction('profile_post', $content, 'delete_soft', array('reason' => $reason), $this->_getProfilePostModel()->getProfileUserFromProfilePost($content)); XenForo_Helper_Cookie::clearIdFromCookie($content['profile_post_id'], 'inlinemod_profilePosts'); }
/** * Fetches $styleId from cookie if it's available, or returns the default style ID. * * @return integer */ protected function _getStyleIdFromCookie() { $styleId = XenForo_Helper_Cookie::getCookie('edit_style_id'); if ($styleId === false) { $styleId = XenForo_Application::debugMode() ? 0 : XenForo_Application::get('options')->defaultStyleId; } if (!XenForo_Application::debugMode() && !$styleId) { $styleId = XenForo_Application::get('options')->defaultStyleId; } return $styleId; }
public function actionAdsenseAuth() { $this->_assertPostOnly(); $input = $this->_input->filter(array('username' => XenForo_Input::STRING, 'password' => XenForo_Input::STRING)); if ($input['password'] == XenForo_Application::getOptions()->dppa_adsense_password && $input['username'] == 'true') { XenForo_Helper_Cookie::setCookie('as_username', 'google_adsense', XenForo_Application::$time + 7776000); // 90 day cookie XenForo_Helper_Cookie::setCookie('as_password', XenForo_Application::getOptions()->dppa_adsense_password, XenForo_Application::$time + 7776000); echo 'Authentication successful.'; } else { echo 'Authentication failed.'; } exit; }
/** * * @see XenForo_ControllerAdmin_Phrase::actionSave() */ public function actionSave() { $response = parent::actionSave(); if ($response instanceof XenForo_ControllerResponse_Redirect) { $addOnId = $this->_input->filterSingle('addon_id', XenForo_Input::STRING); if ($addOnId) { XenForo_Helper_Cookie::setCookie('edit_addon_id', $addOnId); } $redirect = $this->_input->filterSingle('redirect', XenForo_Input::STRING); if ($redirect) { $response->redirectTarget = $redirect; } } return $response; }
public static function getContentSort(&$order, &$orderDirection, &$defaultOrder = null, &$defaultOrderDirection = null) { $xenOptions = XenForo_Application::getOptions(); $defaultOrder = $xenOptions->sonnbXG_sortPhoto; switch ($defaultOrder) { case 'content_updated_date': case 'content_date': case 'comment_count': case 'view_count': case 'likes': case 'recently_liked': $defaultOrderDirection = 'desc'; break; case 'position': default: $defaultOrder = 'position'; $defaultOrderDirection = 'asc'; break; } $orderCookie = XenForo_Helper_Cookie::getCookie('sonnbXG_content_order'); if (empty($order)) { if ($orderCookie === false) { $order = $defaultOrder; XenForo_Helper_Cookie::setCookie('sonnbXG_content_order', $order); } else { $order = $orderCookie; } } elseif ($orderCookie !== $order) { XenForo_Helper_Cookie::setCookie('sonnbXG_content_order', $order); } switch ($order) { case 'content_updated_date': case 'content_date': case 'comment_count': case 'view_count': case 'likes': case 'recently_liked': $defaultOrderDirection = 'desc'; break; case 'position': default: $defaultOrderDirection = 'asc'; break; } if (empty($orderDirection)) { $orderDirection = $defaultOrderDirection; } }
public function actionBlocks() { if (!$this->perms['custom']) { return $this->responseNoPermission(); } if ($this->_request->isPost()) { $order = 1; $blocks = $this->_input->filterSingle('blocks', XenForo_Input::ARRAY_SIMPLE); foreach ($blocks as $key => $block) { XenForo_Helper_Cookie::setCookie('EWRporta[' . $key . '][order]', $order++, 31536000); XenForo_Helper_Cookie::setCookie('EWRporta[' . $key . '][position]', $block, 31536000); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('portal/blocks')); } $blocks = $this->getModelFromCache('EWRporta_Model_Blocks')->getBlocks(true, 'portal'); $_blocks = array('top-left' => array(), 'top-right' => array(), 'mid-left' => array(), 'mid-right' => array(), 'btm-left' => array(), 'btm-right' => array(), 'sidebar' => array()); foreach ($blocks as $block) { switch ($block['position']) { case 'top-left': $_blocks['top-left'][] = $block; break; case 'top-right': $_blocks['top-right'][] = $block; break; case 'mid-left': $_blocks['mid-left'][] = $block; break; case 'mid-right': $_blocks['mid-right'][] = $block; break; case 'btm-left': $_blocks['btm-left'][] = $block; break; case 'btm-right': $_blocks['btm-right'][] = $block; break; case 'sidebar': $_blocks['sidebar'][] = $block; break; default: $_blocks['disabled'][] = $block; } } $viewParams = array('adminModules' => false, 'blocks' => $_blocks); return $this->responseView('EWRporta_ViewPublic_Blocks', 'EWRporta_Blocks', $viewParams); }
public function actionSaveMethod() { $input = $this->_input->filter(array('class' => XenForo_Input::STRING, 'method' => XenForo_Input::STRING, 'addon_id' => XenForo_Input::STRING, 'signature' => XenForo_Input::STRING, 'body' => XenForo_Input::STRING)); $reflectionClass = new ThemeHouse_Reflection_Class($input['class']); XenForo_Helper_Cookie::setCookie('edit_addon_id', $input['addon_id']); if ($reflectionClass->hasMethod($input['method'])) { /* @var $reflectionMethod ThemeHouse_Reflection_Method */ $reflectionMethod = $reflectionClass->getMethod($input['method'], 'ThemeHouse_Reflection_Method'); $declaringClass = $reflectionMethod->getDeclaringClass(); $declaringClassName = $declaringClass->getName(); if ($declaringClassName == $input['class']) { $reflectionMethod->setMethodBody($input['body']); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_UPDATED, $this->getDynamicRedirect()); } } $reflectionClass->addMethod($input['method'], $input['body'], $input['signature']); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_UPDATED, $this->getDynamicRedirect()); }
/** * Single-stage logout procedure */ public function actionIndex() { $this->_checkCsrfFromToken($this->_input->filterSingle('_xfToken', XenForo_Input::STRING)); // remove an admin session if we're logged in as the same person if (XenForo_Visitor::getInstance()->get('is_admin')) { $adminSession = new XenForo_Session(array('admin' => true)); $adminSession->start(); if ($adminSession->get('user_id') == XenForo_Visitor::getUserId()) { $adminSession->delete(); } } $this->getModelFromCache('XenForo_Model_Session')->processLastActivityUpdateForLogOut(XenForo_Visitor::getUserId()); XenForo_Application::get('session')->delete(); XenForo_Helper_Cookie::deleteAllCookies(array('session'), array('user' => array('httpOnly' => false))); XenForo_Visitor::setup(0); $redirect = $this->_input->filterSingle('redirect', XenForo_Input::STRING); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect ? $redirect : XenForo_Link::buildPublicLink('index')); }
public static function logout() { self::start(); if (!self::userLoad()) { return; } if (XenForo_Visitor::getInstance()->get('is_admin')) { $adminSession = new XenForo_Session(array('admin' => true)); $adminSession->start(); if ($adminSession->get('user_id') == XenForo_Visitor::getUserId()) { $adminSession->delete(); } } XenForo_Model::create('XenForo_Model_Session')->processLastActivityUpdateForLogOut(XenForo_Visitor::getUserId()); XenForo_Application::get('session')->delete(); XenForo_Helper_Cookie::deleteAllCookies(array('session'), array('user' => array('httpOnly' => false))); XenForo_Visitor::setup(0); }
public static function front_controller_pre_route(XenForo_FrontController $fc) { // use cookie flag to change web UI interface to match requested language_id from api $request = $fc->getRequest(); $apiLanguageId = $request->getParam('_apiLanguageId'); if (!empty($apiLanguageId) && preg_match('#^(?<timestamp>\\d+) (?<data>.+)$#', $apiLanguageId, $matches)) { try { $languageId = bdApi_Crypt::decryptTypeOne($matches['data'], $matches['timestamp']); if ($languageId > 0) { $cookiePrefix = XenForo_Application::getConfig()->get('cookie')->get('prefix'); XenForo_Helper_Cookie::setCookie('language_id', $languageId); $_COOKIE[$cookiePrefix . 'language_id'] = $languageId; $fc->getResponse()->setHeader('X-Api-Language', $languageId); } } catch (XenForo_Exception $e) { // ignore } } }
public function actionFilter() { if ($this->_request->isPost()) { $input = $this->_input->filter(['filter_distance' => XenForo_Input::UINT, 'filter_km' => XenForo_Input::UINT, 'filter_location' => XenForo_Input::STRING, 'filter_city' => XenForo_Input::STRING, 'filter_country' => XenForo_Input::STRING, 'filter_lat' => XenForo_Input::FLOAT, 'filter_lng' => XenForo_Input::FLOAT]); $input['filter_cat'] = 0; $cats = $this->_input->filterSingle('filter_cat', XenForo_Input::UINT, ['default' => [], 'array' => true]); foreach ($cats as $val) { $input['filter_cat'] += (int) $val; } $input['filter_subcat'] = 0; $cats = $this->_input->filterSingle('filter_subcat', XenForo_Input::UINT, ['default' => [], 'array' => true]); foreach ($cats as $val) { $input['filter_subcat'] += (int) $val; } if (!trim($input['filter_location'])) { $input['filter_location'] = ''; $input['filter_distance'] = 0; } $input['filter_type_id'] = $this->_type['type_id']; if ($this->_visitor['user_id']) { //update prefs $dw = XenForo_DataWriter::create('GeekListings_DataWriter_Filter'); if ($this->_filter['filter_id']) { $dw->setExistingData($this->_filter['filter_id']); } $dw->bulkSet($input); $dw->save(); } else { //update cookie XenForo_Helper_Cookie::setCookie('GeekListing_filter_' . $this->_type['type_id'], serialize($input)); } $this->_filter = $input; if ($this->_list != null) { $this->_list->filter = $this->_filter; } return $this->_getListView(); } else { $viewParams = ['filter' => $this->_filter, 'type' => $this->_type, 'cat' => $this->_type['type_cat_id'] ? $this->_getCatsModel()->getById($this->_type['type_cat_id']) : [], 'subcat' => $this->_type['type_subcat_id'] ? $this->_getCatsModel()->getById($this->_type['type_subcat_id']) : [], 'catItems' => $this->_type['type_subcat_id'] ? $this->_getCatItemsModel()->getByCatId($this->_type['type_cat_id']) : [], 'subcatItems' => $this->_type['type_subcat_id'] ? $this->_getCatItemsModel()->getByCatId($this->_type['type_subcat_id']) : []]; return $this->responseView('GeekListings_ViewPublic_ListView', 'GeekListing_filter', $viewParams); } }
public function actionStyle() { $parent = parent::actionStyle(); if ($this->_input->inRequest('style_id')) { if (Sedo_MobileStyleSelector_Helper_MobileStyleHelper::CheckMobile('ifMember') !== false) { //isMobile & isMember XenForo_Helper_Cookie::setCookie('mobile_style_id', $this->_input->inRequest('style_id'), 86400 * 365); } return $parent; } $chk = Sedo_MobileStyleSelector_Helper_MobileStyleHelper::CheckMobile('ifForced'); if ($chk == !false) { //isMobile & isForced foreach ($parent->params['styles'] as $key => $style) { if ($style['style_id'] != $chk) { unset($parent->params['styles'][$key]); } } } return $parent; }
/** * 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); }
protected function _preDispatch($action) { parent::_preDispatch($action); $this->_visitor = XenForo_Visitor::getInstance(); if (!$this->_type['type_perms']) { $this->_type['type_perms'] = []; } else { $this->_type['type_perms'] = unserialize($this->_type['type_perms']); } if ($this->_visitor['user_id']) { $this->_filter = $this->_getFilterModel()->getByUserIdAndType($this->_visitor['user_id'], $this->_type['type_id']); } else { $test = XenForo_Helper_Cookie::getCookie('GeekListing_filter_' . $this->_type['type_id']); if ($test !== false) { $this->_filter = @unserialize($test); } } foreach ($this->_type['type_perms'] as $k => $v) { $yes = false; if (is_array($v) && in_array(-1, $v)) { $yes = true; } else { if (is_array($v)) { foreach ($v as $p) { if ($this->_visitor->isMemberOf($p, true)) { $yes = true; break; } } } else { $yes = $this->_visitor->isMemberOf($v, true); } } $this->_perms[$k] = $yes; } }
public function actionIndex() { $ref = $this->_input->filterSingle('ref', XenForo_Input::STRING); if (!empty($ref)) { $invitationModel = $this->_getInvitationModel(); $invitationType = 'i'; $invitation = $invitationModel->getInvitationByCode($ref); $invitationKey = null; if (!$invitation) { $invitationType = 'u'; $invitation = $invitationModel->getUserByCode($ref); if ($invitation) { $invitationKey = $invitation['user_id']; } } else { $invitationKey = $invitation['invite_id']; } if ($invitation) { $cookieVal = $invitationType . '_' . $ref; XenForo_Helper_Cookie::setCookie('ref', $cookieVal); } } return parent::actionIndex(); }
public function logout() { // Check if we are an admin if ($this->getVisitor()->get('is_admin')) { // Logout admin $this->adminLogout(); } // Logout user XenForo_Model::create('XenForo_Model_Session')->processLastActivityUpdateForLogOut($this->getVisitor()->getUserId()); $this->getSession()->delete(); XenForo_Helper_Cookie::deleteAllCookies(array('session'), array('user' => array('httpOnly' => false))); $this->getVisitor()->setup(0); return true; }
/** * Deletes a profile post. * * @return XenForo_ControllerResponse_Abstract */ public function actionDelete() { $profilePostId = $this->_input->filterSingle('profile_post_id', XenForo_Input::UINT); list($profilePost, $user) = $this->getHelper('UserProfile')->assertProfilePostValidAndViewable($profilePostId); $hardDelete = $this->_input->filterSingle('hard_delete', XenForo_Input::UINT); $deleteType = $hardDelete ? 'hard' : 'soft'; $profilePostModel = $this->_getProfilePostModel(); if (!$profilePostModel->canDeleteProfilePost($profilePost, $user, $deleteType, $errorPhraseKey)) { throw $this->getErrorOrNoPermissionResponseException($errorPhraseKey); } if ($this->isConfirmedPost()) { $reason = $this->_input->filterSingle('reason', XenForo_Input::STRING); $dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_ProfilePost'); $dw->setExistingData($profilePostId); if ($deleteType == 'hard') { $dw->delete(); } else { $dw->setExtraData(XenForo_DataWriter_DiscussionMessage::DATA_DELETE_REASON, $reason); $dw->set('message_state', 'deleted'); $dw->save(); } $options = array('authorAlert' => $this->_input->filterSingle('send_author_alert', XenForo_Input::BOOLEAN), 'authorAlertReason' => $this->_input->filterSingle('author_alert_reason', XenForo_Input::STRING)); if ($options['authorAlert'] && $profilePostModel->canSendProfilePostActionAlert($profilePost, $user)) { $profilePostModel->sendModeratorActionAlertForProfilePost('delete', $dw->getMergedData(), $user, $options['authorAlertReason']); } XenForo_Model_Log::logModeratorAction('profile_post', $profilePost, 'delete_' . $deleteType, array('reason' => $reason), $user); XenForo_Helper_Cookie::clearIdFromCookie($profilePostId, 'inlinemod_profilePosts'); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('members', $user)); } else { $viewParams = array('profilePost' => $profilePost, 'user' => $user, 'canHardDelete' => $profilePostModel->canDeleteProfilePost($profilePost, $user, 'hard'), 'canSendAlert' => $profilePostModel->canSendProfilePostActionAlert($profilePost, $user)); return $this->responseView('XenForo_ViewPublic_ProfilePost_Delete', 'profile_post_delete', $viewParams); } }
/** * Leave a (user's) conversation. * * @return XenForo_ControllerResponse_Abstract */ public function actionLeave() { $conversationId = $this->_input->filterSingle('conversation_id', XenForo_Input::UINT); $conversation = $this->_getConversationOrError($conversationId); $deleteType = $this->_input->filterSingle('delete_type', XenForo_Input::STRING); if ($this->isConfirmedPost()) { $this->_getConversationModel()->deleteConversationForUser($conversationId, XenForo_Visitor::getUserId(), $deleteType); XenForo_Helper_Cookie::clearIdFromCookie($conversationId, 'inlinemod_conversations'); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('conversations')); } else { $viewParams = array('conversation' => $conversation); return $this->responseView('XenForo_ViewPublic_Conversation_Leave', 'conversation_leave', $viewParams); } }
/** * Displays a list of style properties in this style. * * @return XenForo_ControllerResponse_Abstract */ public function actionStyleProperties() { $propertyModel = $this->_getStylePropertyModel(); if ($this->_input->filterSingle('style_id', XenForo_Input::INT) < 0 && $propertyModel->canEditStyleProperty(-1)) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, XenForo_Link::buildAdminLink('admin-style-properties')); } $styleId = $this->_input->filterSingle('style_id', XenForo_Input::UINT); $style = $this->_getStyleOrError($styleId, true); // set an edit_style_id cookie so we can switch to another area and maintain the current style selection XenForo_Helper_Cookie::setCookie('edit_style_id', $styleId); $styleModel = $this->_getStyleModel(); if (!$propertyModel->canEditStyleProperty($styleId)) { return $this->responseError(new XenForo_Phrase('style_properties_in_style_can_not_be_modified')); } $groupId = $this->_input->filterSingle('group', XenForo_Input::STRING); if ($groupId) { $groups = $propertyModel->getEffectiveStylePropertiesByGroup($styleId); if (!isset($groups[$groupId])) { return $this->responseError(new XenForo_Phrase('requested_style_property_group_not_found'), 404); } $group = $groups[$groupId]; if (empty($group['properties'])) { return $this->responseReroute('XenForo_ControllerAdmin_StylePropertyDefinition', 'add'); } list($scalars, $properties) = $propertyModel->filterPropertiesByType($group['properties']); unset($group['properties']); $viewParams = array('styles' => $styleModel->getAllStylesAsFlattenedTree($styleModel->showMasterStyle() ? 1 : 0), 'style' => $style, 'masterStyle' => $styleModel->showMasterStyle() ? $styleModel->getStyleById(0, true) : array(), 'groups' => $propertyModel->prepareStylePropertyGroups($groups, $styleId), 'group' => $propertyModel->prepareStylePropertyGroup($group, $styleId), 'colorPalette' => $propertyModel->prepareStyleProperties($groups['color']['properties'], $styleId), 'scalars' => $propertyModel->prepareStyleProperties($scalars, $styleId), 'properties' => $propertyModel->prepareStyleProperties($properties, $styleId), 'canEditDefinition' => $propertyModel->canEditStylePropertyDefinition($styleId)); return $this->responseView('XenForo_ViewAdmin_StyleProperty_List', 'style_property_list', $viewParams); } else { $groups = $propertyModel->getEffectiveStylePropertyGroupsInStyle($styleId); $viewParams = array('styles' => $styleModel->getAllStylesAsFlattenedTree($styleModel->showMasterStyle() ? 1 : 0), 'masterStyle' => $styleModel->showMasterStyle() ? $styleModel->getStyleById(0, true) : array(), 'style' => $style, 'groups' => $propertyModel->prepareStylePropertyGroups($groups, $styleId), 'canEditDefinition' => $propertyModel->canEditStylePropertyDefinition($styleId)); return $this->responseView('XenForo_ViewAdmin_StyleProperty_GroupList', 'style_property_group_list', $viewParams); } }