/** * 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 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); } } }
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 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); }
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()); }
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 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 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); } }
/** * 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); } }
/** * Displays the list of orphan phrases in the specified language. * * @return XenForo_ControllerResponse_Abstract */ public function actionOrphanPhrases() { $languageId = $this->_input->filterSingle('language_id', XenForo_Input::UINT); $language = $this->_getLanguageOrError($languageId, true); $languageModel = $this->_getLanguageModel(); $phraseModel = $this->_getPhraseModel(); if (!$phraseModel->canModifyPhraseInLanguage($languageId)) { return $this->responseError(new XenForo_Phrase('phrases_in_this_language_can_not_be_modified')); } $addOns = $this->_getAddOnModel()->getAllAddOns(); $addOnId = $this->_input->filterSingle('addon_id', XenForo_Input::STRING); if (!empty($GLOBALS['XenForo_Route_PrefixAdmin_Languages']) && !$addOnId) { $addOnId = XenForo_Helper_Cookie::getCookie('edit_addon_id'); } else { XenForo_Helper_Cookie::setCookie('edit_addon_id', $addOnId); } if ($addOnId) { $addOn = $addOns[$addOnId]; } else { $addOn = array('addon_id' => ''); } $this->canonicalizeRequestUrl(XenForo_Link::buildAdminLink('add-ons/languages/orphan-phrases', $addOn, $language)); // set an edit_language_id cookie so we can switch to another area and // maintain the current style selection XenForo_Helper_Cookie::setCookie('edit_language_id', $languageId); $page = $this->_input->filterSingle('page', XenForo_Input::UINT); $perPage = 100; $conditions = array('addon_id' => $addOnId); $filter = $this->_input->filterSingle('_filter', XenForo_Input::ARRAY_SIMPLE); if ($filter && isset($filter['value'])) { $conditions['title'] = array($filter['value'], empty($filter['prefix']) ? 'lr' : 'r'); $filterView = true; } else { $filterView = false; } $fetchOptions = array('page' => $page, 'perPage' => $perPage); $totalPhrases = $phraseModel->countOrphanPhrasesInLanguage($languageId, $conditions, $fetchOptions); $viewParams = array('addOns' => $addOns, 'addOnSelected' => $addOnId, 'phrases' => $phraseModel->getOrphanPhraseListForLanguage($languageId, $conditions, $fetchOptions), 'languages' => $languageModel->getAllLanguagesAsFlattenedTree($languageModel->showMasterLanguage() ? 1 : 0), 'masterLanguage' => $languageModel->showMasterLanguage() ? $languageModel->getLanguageById(0, true) : array(), 'language' => $languageModel->getLanguageById($languageId, true), 'page' => $page, 'perPage' => $perPage, 'totalPhrases' => $totalPhrases, 'filterView' => $filterView, 'filterMore' => $filterView && $totalPhrases > $perPage); return $this->responseView('ThemeHouse_Phrases_ViewAdmin_Phrase_OrphanList', 'th_orphan_phrase_list_phrases', $viewParams); }
/** * Sets the fbUid cookie that is used by the JavaScript. * * @param integer $fbUid 64-bit int of FB user ID */ public static function setUidCookie($fbUid) { XenForo_Helper_Cookie::setCookie('fbUid', $fbUid, 14 * 86400); }
/** * Displays the list of phrases in the specified language. * * @return XenForo_ControllerResponse_Abstract */ public function actionPhrases() { $languageId = $this->_input->filterSingle('language_id', XenForo_Input::UINT); $language = $this->_getLanguageOrError($languageId, true); $languageModel = $this->_getLanguageModel(); $phraseModel = $this->_getPhraseModel(); if (!$phraseModel->canModifyPhraseInLanguage($languageId)) { return $this->responseError(new XenForo_Phrase('phrases_in_this_language_can_not_be_modified')); } // set an edit_language_id cookie so we can switch to another area and maintain the current style selection XenForo_Helper_Cookie::setCookie('edit_language_id', $languageId); $page = $this->_input->filterSingle('page', XenForo_Input::UINT); $perPage = 100; $conditions = array(); $filter = $this->_input->filterSingle('_filter', XenForo_Input::ARRAY_SIMPLE); if ($filter && isset($filter['value'])) { $conditions['title'] = array($filter['value'], empty($filter['prefix']) ? 'lr' : 'r'); $filterView = true; } else { $filterView = false; } $fetchOptions = array('page' => $page, 'perPage' => $perPage); $totalPhrases = $phraseModel->countEffectivePhrasesInLanguage($languageId, $conditions, $fetchOptions); $viewParams = array('phrases' => $phraseModel->getEffectivePhraseListForLanguage($languageId, $conditions, $fetchOptions), 'languages' => $languageModel->getAllLanguagesAsFlattenedTree($languageModel->showMasterLanguage() ? 1 : 0), 'masterLanguage' => $languageModel->showMasterLanguage() ? $languageModel->getLanguageById(0, true) : array(), 'language' => $languageModel->getLanguageById($languageId, true), 'page' => $page, 'perPage' => $perPage, 'totalPhrases' => $totalPhrases, 'filterView' => $filterView, 'filterMore' => $filterView && $totalPhrases > $perPage); return $this->responseView('XenForo_ViewAdmin_Phrase_List', 'phrase_list', $viewParams); }
/** * Sets the user remember cookie for the specified user ID. * * @param integer $userId * @param array|false|null $auth User's auth record (retrieved if null) * * @return boolean */ public function setUserRememberCookie($userId, $auth = null) { $value = $this->getUserRememberKeyForCookie($userId, $auth); if (!$value) { return false; } XenForo_Helper_Cookie::setCookie('user', $value, 30 * 86400, true); return true; }
/** * Saves the current session. If a session is being created, the session cookie will be created. */ public function save() { if (!$this->_sessionId || $this->_saved) { return; } if (!$this->_sessionExists) { $this->_db->insert($this->_config['table'], array('session_id' => $this->_sessionId, 'session_data' => serialize($this->_session), 'expiry_date' => XenForo_Application::$time + $this->_config['lifetime'])); if (!headers_sent()) { XenForo_Helper_Cookie::setCookie($this->_config['cookie'], $this->_sessionId, 0, true); } } else { $data = array('expiry_date' => XenForo_Application::$time + $this->_config['lifetime']); if ($this->_dataChanged) { $data['session_data'] = serialize($this->_session); } $this->_db->update($this->_config['table'], $data, 'session_id = ' . $this->_db->quote($this->_sessionId)); } $this->_sessionExists = true; $this->_saved = true; $this->_dataChanged = false; }
/** * Saves the current session. If a session is being created, the session cookie will be created. */ public function save() { if (!$this->_sessionId || $this->_saved) { return; } if (!$this->_sessionExists) { $this->saveSessionToSource($this->_sessionId, false); if (!headers_sent()) { XenForo_Helper_Cookie::setCookie($this->_config['cookie'], $this->_sessionId, 0, true); } } else { $this->saveSessionToSource($this->_sessionId, true); } $this->_sessionExists = true; $this->_saved = true; $this->_dataChanged = false; }
public function actionPrefix() { $threadIds = $this->getInlineModIds(!$this->isConfirmedPost()); $redirect = $this->getDynamicRedirect(); if (!$threadIds) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect); } if ($this->isConfirmedPost()) { $prefixId = $this->_input->filterSingle('prefix_id', XenForo_Input::UINT); if (!$this->_getInlineModThreadModel()->applyThreadPrefix($threadIds, $prefixId, $unchangedThreadIds, array(), $errorKey)) { return $this->responseError(new XenForo_Phrase($errorKey)); } if ($unchangedThreadIds) { XenForo_Helper_Cookie::setCookie('inlinemod_' . $this->inlineModKey, implode(',', $unchangedThreadIds)); } else { $this->clearCookie(); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect); } else { $handler = $this->_getInlineModThreadModel(); if (!$handler->canEditThreads($threadIds, $errorPhraseKey)) { throw $this->getErrorOrNoPermissionResponseException($errorPhraseKey); } $threadModel = $this->_getThreadModel(); $prefixModel = $this->_getPrefixModel(); $threads = $threadModel->getThreadsByIds($threadIds); $nodeIds = $threadModel->getNodeIdsFromThreads($threads); $prefixes = $prefixModel->getUsablePrefixesInForums($nodeIds); if (empty($prefixes)) { return $this->responseError(new XenForo_Phrase('no_thread_prefixes_available_for_selected_forums')); } $selectedPrefix = 0; $prefixCounts = array(0 => 0); foreach ($threads as $thread) { $threadPrefixId = $thread['prefix_id']; if (!isset($prefixCounts[$threadPrefixId])) { $prefixCounts[$threadPrefixId] = 1; } else { $prefixCounts[$threadPrefixId]++; } if ($prefixCounts[$threadPrefixId] > $prefixCounts[$selectedPrefix]) { $selectedPrefix = $threadPrefixId; } } $viewParams = array('threadIds' => $threadIds, 'threadCount' => count($threadIds), 'threads' => $threads, 'nodeIds' => $nodeIds, 'forumCount' => count($nodeIds), 'prefixes' => $prefixes, 'selectedPrefix' => $selectedPrefix, 'redirect' => $redirect); return $this->responseView('XenForo_ViewPublic_InlineMod_Thread_Prefix', 'inline_mod_thread_prefix', $viewParams); } }
/** * Phrase index. This is a list of phrases, so redirect this to a * language-specific list. * * @return XenForo_ControllerResponse_Redirect */ public function actionPhrases() { $languageModel = $this->_getLanguageModel(); $addOnModel = $this->_getAddOnModel(); $languageId = $this->_input->filterSingle('language_id', XenForo_Input::STRING); $addOnId = $this->_input->filterSingle('addon_id', XenForo_Input::STRING); $phraseFilter = $this->_input->filterSingle('phrase_filter', XenForo_Input::STRING); if ($addOnId == '') { $addOnId = XenForo_Helper_Cookie::getCookie('edit_addon_id') ? XenForo_Helper_Cookie::getCookie('edit_addon_id') : 'All'; } if ($languageId == '') { $languageId = $languageModel->getLanguageIdFromCookie(); } if ($phraseFilter == '') { $phraseFilter = XenForo_Helper_Cookie::getCookie('phrase_filter') ? XenForo_Helper_Cookie::getCookie('phrase_filter') : 'existing'; } if ($languageId && in_array($phraseFilter, array('found', 'undefined')) || !$languageId && in_array($phraseFilter, array('untranslated'))) { $phraseFilter = 'existing'; } $phraseModel = $this->_getPhraseModel(); if (!$phraseModel->canModifyPhraseInLanguage($languageId)) { return $this->responseError(new XenForo_Phrase('phrases_in_this_language_can_not_be_modified')); } $page = $this->_input->filterSingle('page', XenForo_Input::UINT); $perPage = 100; $conditions = array(); if ($addOnId != 'All') { $conditions['addon_id'] = $addOnId; } $conditions['phrase_filter'] = $phraseFilter; $filter = $this->_input->filterSingle('_filter', XenForo_Input::ARRAY_SIMPLE); if ($filter && isset($filter['value'])) { $conditions['title'] = array($filter['value'], empty($filter['prefix']) ? 'lr' : 'r'); $filterView = true; } else { $filterView = false; } $fetchOptions = array('page' => $page, 'perPage' => $perPage); if ($phraseFilter == 'undefined' or $phraseFilter == 'found') { $allPhrases = $phraseModel->getAllPhrasesInMasterLanguage(); //$limitOptions = $phraseModel->prepareLimitFetchOptions($fetchOptions); $phrases = array(); $foundPhrases = $this->_getUndefinedPhrases($addOnId); $foundPhrases = array_unique($foundPhrases); sort($foundPhrases); //$limitedFoundPhrases = $foundPhrases; foreach ($foundPhrases as $phraseTitle) { $phrase = isset($allPhrases[$phraseTitle]) ? $allPhrases[$phraseTitle] : array('title' => $phraseTitle, 'phrase_state' => 'custom'); if ($phraseFilter == 'found' || $phraseFilter == 'undefined' && !isset($allPhrases[$phraseTitle])) { $phrases[] = $phrase; } } $totalPhrases = count($phrases); $page = null; $perPage = null; //die(Zend_Debug::dump($phrases)); } else { $phrases = $phraseModel->getEffectivePhraseListForLanguage($languageId, $conditions, $fetchOptions); $totalPhrases = $phraseModel->countEffectivePhrasesInLanguage($languageId, $conditions, $fetchOptions); } if (is_array($phrases)) { // set an edit_language_id cookie so we can switch to another area and maintain the current style selection XenForo_Helper_Cookie::setCookie('edit_language_id', $languageId); XenForo_Helper_Cookie::setCookie('edit_addon_id', $addOnId); XenForo_Helper_Cookie::setCookie('phrase_filter', $phraseFilter); } else { XenForo_Helper_Cookie::setCookie('edit_language_id', 0); XenForo_Helper_Cookie::setCookie('edit_addon_id', 'All'); XenForo_Helper_Cookie::setCookie('phrase_filter', 'existing'); } $viewParams = array('phrases' => $phrases, 'languages' => $languageModel->getAllLanguagesAsFlattenedTree($languageModel->showMasterLanguage() ? 1 : 0), 'masterLanguage' => $languageModel->showMasterLanguage() ? $languageModel->getLanguageById(0, true) : array(), 'language' => $languageModel->getLanguageById($languageId, true), 'addOns' => $addOnModel->getAllAddOns(), 'addOn' => $addOnId == 'XenForo' ? array('addon_id' => 'XenForo', 'title' => 'XenForo') : $addOnModel->getAddOnById($addOnId), 'addOnId' => $addOnId, 'phraseFilter' => $phraseFilter, 'phraseFilterTitle' => new XenForo_Phrase('devkit_' . $phraseFilter), 'page' => $page, 'perPage' => $perPage, 'totalPhrases' => $totalPhrases, 'filterView' => $filterView, 'filterMore' => $filterView && $totalPhrases > $perPage); return $this->responseView('XenForo_ViewAdmin_Phrase_List', 'phrase_list', $viewParams); }
public function setDeviceTrusted($userId) { $key = $this->_getTfaModel()->createTrustedKey($userId); XenForo_Helper_Cookie::setCookie('tfa_trust', $key, 86400 * 31, true); return $key; }
public function actionSave() { $input = $this->_input->filter(array('class' => XenForo_Input::STRING, 'addon_id' => XenForo_Input::STRING)); $phpFile = new ThemeHouse_PhpFile($input['addon_id'] . '_Model_' . $input['class']); $phpFile->setExtends('XenForo_Model'); $phpFile->export(); $model = array('class' => $input['addon_id'] . '_Model_' . $input['class']); XenForo_Helper_Cookie::setCookie('edit_addon_id', $input['addon_id']); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CREATED, XenForo_Link::buildAdminLink('models', $model)); }
/** * Sets the user remember cookie for the specified user ID. * * @param integer $userId * @param array|false|null $auth User's auth record (retrieved if null) * * @return boolean */ public function setUserRememberCookie($userId, $auth = null) { if ($auth === null) { $auth = $this->getUserAuthenticationRecordByUserId($userId); } if (!$auth) { return false; } $value = intval($userId) . ',' . $this->prepareRememberKeyForCookie($auth['remember_key']); XenForo_Helper_Cookie::setCookie('user', $value, 7 * 86400, true); return true; }
public function setUpgradeCookie($userId) { /** @var $userModel XenForo_Model_User */ $userModel = $this->getModelFromCache('XenForo_Model_User'); $value = $userModel->getUserRememberKeyForCookie($userId); if (!$value) { return false; } return XenForo_Helper_Cookie::setCookie('upgrade', $value, 0, true); }
public function updateViews($page) { if (!XenForo_Helper_Cookie::getCookie('EWRcarta_' . $page['page_id'])) { $this->_getDb()->query("\n\t\t\t\tUPDATE EWRcarta_pages\n\t\t\t\tSET page_views = page_views+1\n\t\t\t\tWHERE page_id = ?\n\t\t\t", $page['page_id']); $page['page_views']++; } XenForo_Helper_Cookie::setCookie('EWRcarta_' . $page['page_id'], '1', 86400); $this->standardizeViewingUserReference($viewingUser); $userID = $viewingUser['user_id']; if ($userID) { $this->_getDb()->query(' INSERT INTO EWRcarta_read (user_id, page_id, page_read_date) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE page_read_date = VALUES(page_read_date) ', array($userID, $page['page_id'], XenForo_Application::$time)); } return $page; }
public function updateViews($media) { if (!XenForo_Helper_Cookie::getCookie('EWRmedio_' . $media['media_id'])) { $this->_getDb()->query("\n\t\t\t\tUPDATE EWRmedio_media\n\t\t\t\tSET media_views = media_views+1\n\t\t\t\tWHERE media_id = ?\n\t\t\t", $media['media_id']); $media['media_views']++; } XenForo_Helper_Cookie::setCookie('EWRmedio_' . $media['media_id'], '1', 86400); $this->standardizeViewingUserReference($viewingUser); $userID = $viewingUser['user_id']; if ($userID) { $this->_getDb()->query(' INSERT INTO EWRmedio_read (user_id, media_id, media_read_date) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE media_read_date = VALUES(media_read_date) ', array($userID, $media['media_id'], XenForo_Application::$time)); } return $media; }