本文整理汇总了PHP中XenForo_Helper_Cookie::getCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Helper_Cookie::getCookie方法的具体用法?PHP XenForo_Helper_Cookie::getCookie怎么用?PHP XenForo_Helper_Cookie::getCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Helper_Cookie
的用法示例。
在下文中一共展示了XenForo_Helper_Cookie::getCookie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _preSave
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']);
}
}
}
}
}
示例2: getBlocks
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;
}
示例3: getVisitor
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;
}
}
}
示例4: loadInput
public function loadInput($input)
{
$prefs = ['pref_location' => $input->filterSingle('pref_location', XenForo_Input::STRING, ['default' => '']), 'pref_distance' => $input->filterSingle('pref_distance', XenForo_Input::UINT, ['default' => 0]), 'pref_city' => $input->filterSingle('pref_city', XenForo_Input::STRING, ['default' => '']), 'pref_country' => $input->filterSingle('pref_country', XenForo_Input::STRING, ['default' => '']), 'pref_lat' => $input->filterSingle('pref_lat', XenForo_Input::FLOAT, ['default' => '0']), 'pref_lng' => $input->filterSingle('pref_lng', XenForo_Input::FLOAT, ['default' => '0']), 'pref_cats' => $input->filterSingle('pref_cats', XenForo_Input::ARRAY_SIMPLE, ['default' => [7]]), 'pref_subcats' => $input->filterSingle('pref_subcats', XenForo_Input::ARRAY_SIMPLE, ['default' => [31]]), 'pref_alert_on_new' => $input->filterSingle('pref_alert_on_new', XenForo_Input::INT, ['default' => 1]), 'pref_email_on_new' => $input->filterSingle('pref_email_on_new', XenForo_Input::INT, ['default' => 1]), 'pref_cat' => 0, 'pref_subcat' => 0];
$subcat = $cat = 0;
foreach (array_keys($prefs['pref_cats']) as $val) {
$cat += (int) $val;
}
foreach (array_keys($prefs['pref_subcats']) as $val) {
$subcat += (int) $val;
}
$saved_prefs = ['pref_location' => '', 'pref_distance' => 0, 'pref_city' => '', 'pref_country' => '', 'pref_lat' => 0, 'pref_lng' => 0, 'pref_cats' => 7, 'pref_subcats' => 31, 'pref_alert_on_new' => 1, 'pref_email_on_new' => 1, 'pref_cat' => 0, 'pref_subcat' => 0];
if ($this->userId > 0) {
//use data
$_db = $_db = XenForo_Application::getDb();
$saved_prefs = $_db->fetchRow("SELECT * FROM geek_listings_prefs WHERE pref_user_id=? AND pref_type_id=? ", [$this->userId, $this->typeId]);
} else {
//use cookies?
$test = XenForo_Helper_Cookie::getCookie('GeekListing_prefs_' . $this->type['pref_type_id']);
if ($test) {
$saved_prefs = unserialize($test);
}
}
$save = $prefs['pref_cat'] != $cat || $prefs['pref_subcat'] != $subcat || $prefs['pref_location'] != $saved_prefs['pref_location'] || $prefs['pref_lat'] != $saved_prefs['pref_lat'] || $prefs['pref_lng'] != $saved_prefs['pref_lng'] || $prefs['pref_alert_on_new'] != $saved_prefs['pref_alert_on_new'] || $prefs['pref_email_on_new'] != $saved_prefs['pref_email_on_new'] || $prefs['pref_city'] != $saved_prefs['pref_city'] || $prefs['pref_country'] != $saved_prefs['pref_country'];
$prefs['pref_cat'] = $cat;
$prefs['pref_subcat'] = $subcat;
if ($save) {
$this->save($prefs);
}
}
示例5: actionRevert
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'));
}
示例6: getStyleIdFromCookie
/**
* 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;
}
示例7: actionIndex
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);
}
示例8: _getStyleIdFromCookie
/**
* 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;
}
示例9: getInlineModIds
/**
* Gets the selected inline mod IDs.
*
* @param boolean $fromCookie True to read from the cookie input
*
* @return array
*/
public function getInlineModIds($fromCookie = true)
{
$ids = $this->_input->filterSingle($this->inlineModKey, XenForo_Input::UINT, array('array' => true));
if ($fromCookie) {
$cookie = XenForo_Helper_Cookie::getCookie('inlinemod_' . $this->inlineModKey);
if (is_string($cookie)) {
$ids = array_merge($ids, explode(',', $cookie));
$ids = array_map('intval', $ids);
$ids = array_unique($ids);
}
}
return $ids;
}
示例10: setupVisitorFromUpgradeCookie
public function setupVisitorFromUpgradeCookie()
{
$cookie = XenForo_Helper_Cookie::getCookie('upgrade');
if (!$cookie) {
return false;
}
/** @var $userModel XenForo_Model_User */
$userModel = $this->getModelFromCache('XenForo_Model_User');
$userId = $userModel->loginUserByRememberCookie($cookie);
if ($userId) {
XenForo_Visitor::setup($userId);
}
return $userId;
}
示例11: getContentSort
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;
}
}
示例12: actionRunDeferred
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);
}
示例13: _getPhraseAddEditResponse
/**
*
* @see XenForo_ControllerAdmin_Phrase::_getPhraseAddEditResponse()
*/
protected function _getPhraseAddEditResponse(array $phrase, $inputLanguageId, $inputPhraseId = 0)
{
$response = parent::_getPhraseAddEditResponse($phrase, $inputLanguageId, $inputPhraseId = 0);
if ($response instanceof XenForo_ControllerResponse_View) {
$addOnId = $this->_input->filterSingle('addon_id', XenForo_Input::STRING);
if (!empty($GLOBALS['XenForo_Route_PrefixAdmin_Phrases']) && !$addOnId) {
$addOnId = XenForo_Helper_Cookie::getCookie('edit_addon_id');
}
if ($addOnId && empty($phrase['addon_id'])) {
$template['addon_id'] = $addOnId;
$response->params['addOnSelected'] = $addOnId;
}
$phrase = $response->params['phrase'];
if (empty($phrase['title'])) {
$title = $this->_input->filterSingle('title', XenForo_Input::STRING);
$response->params['phrase']['title'] = $title;
}
if (empty($response->params['redirect'])) {
$response->params['redirect'] = $this->getDynamicRedirect();
}
}
return $response;
}
示例14: _preDispatch
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;
}
}
示例15: actionMultiQuote
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);
}
}