本文整理汇总了PHP中XenForo_Helper_Cookie::setCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Helper_Cookie::setCookie方法的具体用法?PHP XenForo_Helper_Cookie::setCookie怎么用?PHP XenForo_Helper_Cookie::setCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Helper_Cookie
的用法示例。
在下文中一共展示了XenForo_Helper_Cookie::setCookie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionLanguage
/**
* 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);
}
}
示例2: Diktat
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);
}
}
}
示例3: save
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));
}
示例4: 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);
}
示例5: actionAdsenseAuth
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;
}
示例6: actionSave
/**
*
* @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;
}
示例7: 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;
}
}
示例8: actionBlocks
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);
}
示例9: actionSaveMethod
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());
}
示例10: front_controller_pre_route
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
}
}
}
示例11: actionFilter
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);
}
}
示例12: actionStyle
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;
}
示例13: actionLocation
/**
* 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);
}
}
示例14: actionIndex
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();
}
示例15: actionChangeStyle
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);
}
}