本文整理汇总了PHP中Input::cookie方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::cookie方法的具体用法?PHP Input::cookie怎么用?PHP Input::cookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::cookie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the controller and parse the login template
*/
public function run()
{
$this->Template = new BackendTemplate('be_files');
$this->Template->main = '';
// Ajax request
if (Environment::get('isAjaxRequest')) {
$this->objAjax = new Ajax(Input::post('action'));
$this->objAjax->executePreActions();
}
$this->Template->main .= $this->getBackendModule('files');
// Default headline
if ($this->Template->headline == '') {
$this->Template->headline = $GLOBALS['TL_CONFIG']['websiteTitle'];
}
$this->Template->theme = $this->getTheme();
$this->Template->base = Environment::get('base');
$this->Template->language = $GLOBALS['TL_LANGUAGE'];
$this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['filetree']);
$this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$this->Template->pageOffset = Input::cookie('BE_PAGE_OFFSET');
$this->Template->error = Input::get('act') == 'error' ? $GLOBALS['TL_LANG']['ERR']['general'] : '';
$this->Template->skipNavigation = $GLOBALS['TL_LANG']['MSC']['skipNavigation'];
$this->Template->request = ampersand(Environment::get('request'));
$this->Template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
$this->Template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode'];
$this->Template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode'];
$this->Template->loadingData = $GLOBALS['TL_LANG']['MSC']['loadingData'];
$this->Template->loadFonts = $GLOBALS['TL_CONFIG']['loadGoogleFonts'];
$GLOBALS['TL_CONFIG']['debugMode'] = false;
$this->Template->output();
}
示例2: compile
/**
* Generate the content element
*/
protected function compile()
{
$rows = deserialize($this->tableitems);
$this->Template->id = 'table_' . $this->id;
$this->Template->summary = specialchars($this->summary);
$this->Template->useHeader = $this->thead ? true : false;
$this->Template->useFooter = $this->tfoot ? true : false;
$this->Template->useLeftTh = $this->tleft ? true : false;
$this->Template->sortable = $this->sortable ? true : false;
$arrHeader = array();
$arrBody = array();
$arrFooter = array();
// Table header
if ($this->thead) {
foreach ($rows[0] as $i => $v) {
// Set table sort cookie
if ($this->sortable && $i == $this->sortIndex) {
$co = 'TS_TABLE_' . $this->id;
$so = $this->sortOrder == 'descending' ? 'desc' : 'asc';
if (\Input::cookie($co) == '') {
\System::setCookie($co, $i . '|' . $so, 0);
}
}
// Add cell
$arrHeader[] = array('class' => 'head_' . $i . ($i == 0 ? ' col_first' : '') . ($i == count($rows[0]) - 1 ? ' col_last' : '') . ($i == 0 && $this->tleft ? ' unsortable' : ''), 'content' => $v != '' ? nl2br_html5($v) : ' ');
}
array_shift($rows);
}
$this->Template->header = $arrHeader;
$limit = $this->tfoot ? count($rows) - 1 : count($rows);
// Table body
for ($j = 0; $j < $limit; $j++) {
$class_tr = '';
if ($j == 0) {
$class_tr .= ' row_first';
}
if ($j == $limit - 1) {
$class_tr .= ' row_last';
}
$class_eo = $j % 2 == 0 ? ' odd' : ' even';
foreach ($rows[$j] as $i => $v) {
$class_td = '';
if ($i == 0) {
$class_td .= ' col_first';
}
if ($i == count($rows[$j]) - 1) {
$class_td .= ' col_last';
}
$arrBody['row_' . $j . $class_tr . $class_eo][] = array('class' => 'col_' . $i . $class_td, 'content' => $v != '' ? nl2br_html5($v) : ' ');
}
}
$this->Template->body = $arrBody;
// Table footer
if ($this->tfoot) {
foreach ($rows[count($rows) - 1] as $i => $v) {
$arrFooter[] = array('class' => 'foot_' . $i . ($i == 0 ? ' col_first' : '') . ($i == count($rows[count($rows) - 1]) - 1 ? ' col_last' : ''), 'content' => $v != '' ? nl2br_html5($v) : ' ');
}
}
$this->Template->footer = $arrFooter;
}
示例3: _init
/**
* Class init
*
* Fetches CSRF settings and current token
*/
public static function _init()
{
static::$csrf_token_key = \Config::get('security.csrf_token_key', 'fuel_csrf_token');
static::$csrf_old_token = \Input::cookie(static::$csrf_token_key, false);
if (\Config::get('security.csrf_autoload', true)) {
static::check_token();
}
}
示例4: resolveBackendUser
/**
* Resolve the user from the session.
*
* @return \UserModel
*
* @internal
*/
public function resolveBackendUser()
{
if (TL_MODE == 'FE') {
// request the BE_USER_AUTH login status
$hash = $this->input->cookie(self::COOKIE_NAME);
// Check the cookie hash
if ($this->validateHash($hash)) {
$session = $this->database->prepare("SELECT * FROM tl_session WHERE hash=? AND name=?")->execute($hash, self::COOKIE_NAME);
// Try to find the session in the database
if ($session->next() && $this->validateUserSession($hash, $session)) {
$userId = $session->pid;
$user = \UserModel::findByPk($userId);
return $user;
}
}
}
return null;
}
示例5: _init
/**
* Class init
*
* Fetches CSRF settings and current token
*/
public static function _init()
{
static::$csrf_token_key = \Config::get('security.csrf_token_key', 'fuel_csrf_token');
static::$csrf_old_token = \Input::cookie(static::$csrf_token_key, false);
if (\Config::get('security.csrf_autoload', true)) {
static::check_token();
}
// throw an exception if no the output filter setting is missing from the app config
if (\Config::get('security.output_filter', null) === null) {
throw new \FuelException('There is no security.output_filter defined in your application config file');
}
}
示例6: _init
/**
* Class init
*
* Fetches CSRF settings and current token
*/
public static function _init()
{
static::$csrf_token_key = \Config::get('security.csrf_token_key', 'fuel_csrf_token');
static::$csrf_old_token = \Input::cookie(static::$csrf_token_key, false);
if (\Config::get('security.csrf_autoload', true)) {
static::check_token();
}
// set a default output filter if none is defined in the config
// this code is deprecated and will be removed in v1.2
if (\Config::get('security.output_filter', null) === null) {
\Config::set('security.output_filter', '\\Security::htmlentities');
logger(\Fuel::L_WARNING, 'There is no security.output_filter defined in your application config file.', __METHOD__);
}
}
示例7: fakeLogin
public function fakeLogin()
{
if (TL_MODE == 'FE') {
$rootPage = $this->getRootPageFromUrl();
if ($rootPage && is_array($GLOBALS['BROWSER_AUTH_MODULES'])) {
foreach ($GLOBALS['BROWSER_AUTH_MODULES'] as $authModuleClass) {
$authModule = new $authModuleClass();
$member = $authModule->authenticate($rootPage);
if ($member) {
$database = \Database::getInstance();
$cookieName = 'FE_USER_AUTH';
$ip = \Environment::get('ip');
$time = time();
// Generate the cookie hash
$hash = sha1(session_id() . (!$GLOBALS['TL_CONFIG']['disableIpCheck'] ? $ip : '') . $cookieName);
if ($hash == \Input::cookie($cookieName)) {
$session = $database->prepare('SELECT * FROM tl_session WHERE hash=? AND name=?')->executeUncached($hash, $cookieName);
$update = array();
if ($session->numRows) {
// Validate the session
if ($session->sessionID != session_id()) {
$update['sessionID'] = session_id();
}
if (!$GLOBALS['TL_CONFIG']['disableIpCheck'] && $session->ip != $ip) {
$update['ip'] = $ip;
}
if ($session->hash != $hash) {
$update['hash'] = $hash;
}
if ($session->tstamp + $GLOBALS['TL_CONFIG']['sessionTimeout'] < $time) {
$update['tstamp'] = $time;
}
if (count($update)) {
$database->prepare('UPDATE tl_session %s WHERE hash=? AND name=?')->set($update)->execute($hash, $cookieName);
}
break;
}
}
// fake a new session
$database->prepare('INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash)
VALUES (?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE tstamp=?, name=?, sessionID=?, ip=?')->execute($member->id, $time, $cookieName, session_id(), $ip, $hash, $time, $cookieName, session_id(), $ip);
// fake authentication cookie
$this->setCookie($cookieName, $hash, $time + $GLOBALS['TL_CONFIG']['sessionTimeout'], null, null, false, true);
break;
}
}
}
}
}
示例8: getInstance
/**
* Get the singleton instance.
*
* @return \ExtCSS\ExtCSS
*/
public static function getInstance()
{
if (self::$instance == null) {
self::$instance = new ExtCss();
// remember cookie FE_PREVIEW state
$fePreview = \Input::cookie('FE_PREVIEW');
// set into preview mode
\Input::setCookie('FE_PREVIEW', true);
// request the BE_USER_AUTH login status
static::setDesignerMode(self::$instance->getLoginStatus('BE_USER_AUTH'));
// restore previous FE_PREVIEW state
\Input::setCookie('FE_PREVIEW', $fePreview);
}
return self::$instance;
}
示例9: addServersToLoginPage
/**
* Display option field in backend login
*
* @param $strContent
* @param $strTemplate
* @return mixed
*/
public function addServersToLoginPage($strContent, $strTemplate)
{
if ($strTemplate == 'be_login') {
$template = new \BackendTemplate('mod_authclient_serverlist');
$template->loginServers = \AuthClientServerModel::findAll();
// TODO: Check if certificate is still valid
// Preferred login provider
$preferredServer = intval(\Input::cookie('cto_preferred_login_provider'));
if ($preferredServer > 0) {
$template->preferredServer = $preferredServer;
} else {
$template->preferredServer = false;
}
$searchString = '<table class="tl_login_table">';
$strContent = str_replace($searchString, $searchString . $template->parse(), $strContent);
}
return $strContent;
}
示例10: _init
/**
* Class init
*
* Fetches CSRF settings and current token
*/
public static function _init()
{
static::$csrf_token_key = \Config::get('security.csrf_token_key', 'fuel_csrf_token');
static::$csrf_old_token = \Input::cookie(static::$csrf_token_key, false);
// if csrf automatic checking is enabled, and it fails validation, bail out!
if (\Config::get('security.csrf_autoload', true)) {
static::check_token();
}
// throw an exception if the output filter setting is missing from the app config
if (\Config::get('security.output_filter', null) === null) {
throw new \FuelException('There is no security.output_filter defined in your application config file');
}
// deal with duplicate filters, no need to slow the framework down
foreach (array('output_filter', 'uri_filter', 'input_filter') as $setting) {
$config = \Config::get('security.' . $setting, array());
is_array($config) and \Config::set('security.' . $setting, array_keys(array_flip($config)));
}
}
示例11: registerPageCacheKey
/**
* Register a page cache key.
*
* @param string $cacheKey The cache key.
*
* @return string
*/
public function registerPageCacheKey($cacheKey)
{
global $objPage;
// $objPage is only available when the hook is triggered by the FrontendTemplate::addToCache method.
// If it's triggered by outputFromCache it's not available. Make use of this knowledge.
if ($objPage) {
$preparedKey = $cacheKey;
if ($objPage->mobileLayout > 0) {
if (\Input::cookie('TL_VIEW') == 'mobile' || \Environment::get('agent')->mobile && \Input::cookie('TL_VIEW') != 'desktop') {
// Mobile key is usually added after the hook. So add it here. See. contao/core#7826.
$preparedKey .= '.mobile';
} elseif (version_compare(VERSION, '3.5', '>=')) {
// Contao 3.5 uses desktop suffix if mobile layout is enabled.
$preparedKey .= '.desktop';
}
}
$this->service()->registerCacheKey($objPage->id, md5($preparedKey));
}
return $cacheKey;
}
示例12: _init
/**
* Class init
*
* Fetches CSRF settings and current token
*
* @throws SecurityException it the CSRF token validation failed
* @throws FuelException if no security output filter is defined
*/
public static function _init()
{
static::$csrf_token_key = \Config::get('security.csrf_token_key', 'fuel_csrf_token');
static::$csrf_old_token = \Input::cookie(static::$csrf_token_key, false);
// if csrf automatic checking is enabled, and it fails validation, bail out!
if (\Config::get('security.csrf_autoload', true)) {
$check_token_methods = \Config::get('security.csrf_autoload_methods', array('post', 'put', 'delete'));
if (in_array(strtolower(\Input::method()), $check_token_methods) and !static::check_token()) {
throw new \SecurityException('CSRF validation failed, Possible hacking attempt detected!');
}
}
// throw an exception if the output filter setting is missing from the app config
if (\Config::get('security.output_filter', null) === null) {
throw new \FuelException('There is no security.output_filter defined in your application config file');
}
// deal with duplicate filters, no need to slow the framework down
foreach (array('output_filter', 'uri_filter', 'input_filter') as $setting) {
$config = \Config::get('security.' . $setting, array());
is_array($config) and \Config::set('security.' . $setting, \Arr::unique($config));
}
}
示例13: showTags
//.........这里部分代码省略.........
}
if (strlen($strParams)) {
if (strpos($strUrl, '?') !== false) {
$strUrl .= '&' . $strParams;
} else {
$strUrl .= '?' . $strParams;
}
}
}
$this->arrTags[$idx]['tag_url'] = $strUrl;
if ($tag['tag_name'] == \Input::get('tag') || $tag['tag_name'] == str_replace('|slash|', '/', \Input::get('tag'))) {
$this->arrTags[$idx]['tag_class'] .= ' active';
}
if ($this->checkForArticleOnPage) {
global $objPage;
// get articles on page
$arrArticles = $this->Database->prepare("SELECT id FROM tl_article WHERE pid = ?")->execute($objPage->id)->fetchEach('id');
$arrTagIds = $this->Database->prepare("SELECT tid FROM " . $this->tag_tagtable . " WHERE from_table = ? AND tag = ?")->execute('tl_article', $tag['tag_name'])->fetchEach('tid');
if (count(array_intersect($arrArticles, $arrTagIds))) {
$this->arrTags[$idx]['tag_class'] .= ' here';
}
}
if ($this->checkForContentElementOnPage) {
global $objPage;
// get articles on page
$arrArticles = $this->Database->prepare("SELECT id FROM tl_article WHERE pid = ?")->execute($objPage->id)->fetchEach('id');
if (count($arrArticles)) {
$arrCE = $this->Database->prepare("SELECT id FROM tl_content WHERE pid IN (" . implode(",", $arrArticles) . ")")->execute()->fetchEach('id');
$arrTagIds = $this->Database->prepare("SELECT tid FROM " . $this->tag_tagtable . " WHERE from_table = ? AND tag = ?")->execute('tl_content', $tag['tag_name'])->fetchEach('tid');
if (count(array_intersect($arrCE, $arrTagIds))) {
$this->arrTags[$idx]['tag_class'] .= ' here';
}
}
}
}
$relatedlist = strlen(\Input::get('related')) ? preg_split("/,/", \Input::get('related')) : array();
foreach ($this->arrRelated as $idx => $tag) {
if (count($pageArr)) {
if ($tag['tag_name'] != \Input::get('tag')) {
$strUrl = ampersand($this->generateFrontendUrl($pageArr, '/tag/' . str_replace('/', '|slash|', \System::urlencode(\Input::get('tag'))) . '/related/' . str_replace('/', '|slash|', \System::urlencode(join(array_merge($relatedlist, array($tag['tag_name'])), ',')))));
} else {
$strUrl = ampersand($this->generateFrontendUrl($pageArr));
}
}
$this->arrRelated[$idx]['tag_url'] = $strUrl;
}
$this->Template->pageID = $this->id;
$this->Template->tags = $this->arrTags;
$this->Template->jumpTo = $this->jumpTo;
$this->Template->relatedtags = $this->arrRelated;
$this->Template->strRelatedTags = $GLOBALS['TL_LANG']['tl_module']['tag_relatedtags'];
$this->Template->strAllTags = $GLOBALS['TL_LANG']['tl_module']['tag_alltags'];
$this->Template->strTopTenTags = sprintf($GLOBALS['TL_LANG']['tl_module']['top_tags'], $this->tag_topten_number);
$this->Template->tagcount = count($this->arrTags);
$this->Template->selectedtags = strlen(\Input::get('tag')) ? count($this->arrRelated) + 1 : 0;
if ($this->tag_show_reset) {
$strEmptyUrl = ampersand($this->generateFrontendUrl($pageArr, ''));
if (strlen($strParams)) {
if (strpos($strUrl, '?') !== false) {
$strEmptyUrl .= '&' . $strParams;
} else {
$strEmptyUrl .= '?' . $strParams;
}
}
$this->Template->empty_url = $strEmptyUrl;
$this->Template->lngEmpty = $GLOBALS['TL_LANG']['tl_module']['tag_clear_tags'];
}
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/tags/assets/tagcloud.js';
if (count($pageArr)) {
$this->Template->topten = $this->tag_topten;
if ($this->tag_topten) {
foreach ($this->arrTopTenTags as $idx => $tag) {
if (count($pageArr)) {
if ($tag['tag_name'] != \Input::get('tag')) {
$strUrl = ampersand($this->generateFrontendUrl($pageArr, '/tag/' . str_replace('/', '|slash|', \System::urlencode($tag['tag_name']))));
} else {
$strUrl = ampersand($this->generateFrontendUrl($pageArr));
}
if (strlen($strParams)) {
if (strpos($strUrl, '?') !== false) {
$strUrl .= '&' . $strParams;
} else {
$strUrl .= '?' . $strParams;
}
}
}
if ($this->arrTopTenTags[$idx]['tag_name'] == str_replace('|slash|', '/', \Input::get('tag'))) {
$this->arrTopTenTags[$idx]['tag_class'] .= ' active';
}
$this->arrTopTenTags[$idx]['tag_url'] = $strUrl;
}
$ts = deserialize(\Input::cookie('tagcloud_states'), true);
// $ts = $this->Session->get('tagcloud_states');
$this->Template->expandedTopTen = strlen($ts[$this->id]['topten']) ? strcmp($ts[$this->id]['topten'], 'none') == 0 ? 0 : 1 : $this->tag_topten_expanded;
$this->Template->expandedAll = strlen($ts[$this->id]['alltags']) ? strcmp($ts[$this->id]['alltags'], 'none') == 0 ? 0 : 1 : $this->tag_all_expanded;
$this->Template->expandedRelated = strlen($ts[$this->id]['related']) ? strcmp($ts[$this->id]['related'], 'none') == 0 ? 0 : 1 : 1;
$this->Template->toptentags = $this->arrTopTenTags;
}
}
}
示例14: outputFromCache
/**
* Try to load the page from the cache
*/
protected function outputFromCache()
{
// Build the page if a user is (potentially) logged in or there is POST data
if (!empty($_POST) || Input::cookie('FE_USER_AUTH') || Input::cookie('FE_AUTO_LOGIN') || $_SESSION['DISABLE_CACHE'] || isset($_SESSION['LOGIN_ERROR']) || Config::get('debugMode')) {
return;
}
/**
* If the request string is empty, look for a cached page matching the
* primary browser language. This is a compromise between not caching
* empty requests at all and considering all browser languages, which
* is not possible for various reasons.
*/
if (Environment::get('request') == '' || Environment::get('request') == 'index.php') {
// Return if the language is added to the URL and the empty domain will be redirected
if (Config::get('addLanguageToUrl') && !Config::get('doNotRedirectEmpty')) {
return;
}
$arrLanguage = Environment::get('httpAcceptLanguage');
$strCacheKey = Environment::get('base') . 'empty.' . $arrLanguage[0];
} else {
$strCacheKey = Environment::get('base') . Environment::get('request');
}
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['getCacheKey']) && is_array($GLOBALS['TL_HOOKS']['getCacheKey'])) {
foreach ($GLOBALS['TL_HOOKS']['getCacheKey'] as $callback) {
$this->import($callback[0]);
$strCacheKey = $this->{$callback}[0]->{$callback}[1]($strCacheKey);
}
}
$blnFound = false;
$strCacheFile = null;
// Check for a mobile layout
if (Input::cookie('TL_VIEW') == 'mobile' || Environment::get('agent')->mobile && Input::cookie('TL_VIEW') != 'desktop') {
$strCacheKey = md5($strCacheKey . '.mobile');
$strCacheFile = TL_ROOT . '/system/cache/html/' . substr($strCacheKey, 0, 1) . '/' . $strCacheKey . '.html';
if (file_exists($strCacheFile)) {
$blnFound = true;
}
}
// Check for a regular layout
if (!$blnFound) {
$strCacheKey = md5($strCacheKey);
$strCacheFile = TL_ROOT . '/system/cache/html/' . substr($strCacheKey, 0, 1) . '/' . $strCacheKey . '.html';
if (file_exists($strCacheFile)) {
$blnFound = true;
}
}
// Return if the file does not exist
if (!$blnFound) {
return;
}
$expire = null;
$content = null;
$type = null;
// Include the file
ob_start();
require_once $strCacheFile;
// The file has expired
if ($expire < time()) {
ob_end_clean();
return;
}
// Read the buffer
$strBuffer = ob_get_contents();
ob_end_clean();
// Session required to determine the referer
$this->import('Session');
$session = $this->Session->getData();
// Set the new referer
if (!isset($_GET['pdf']) && !isset($_GET['file']) && !isset($_GET['id']) && $session['referer']['current'] != Environment::get('requestUri')) {
$session['referer']['last'] = $session['referer']['current'];
$session['referer']['current'] = substr(Environment::get('requestUri'), strlen(TL_PATH) + 1);
}
// Store the session data
$this->Session->setData($session);
// Load the default language file (see #2644)
$this->import('Config');
System::loadLanguageFile('default');
// Replace the insert tags and then re-replace the request_token
// tag in case a form element has been loaded via insert tag
$strBuffer = $this->replaceInsertTags($strBuffer, false);
$strBuffer = str_replace(array('{{request_token}}', '[{]', '[}]'), array(REQUEST_TOKEN, '{{', '}}'), $strBuffer);
// Content type
if (!$content) {
$content = 'text/html';
}
// Send the status header (see #6585)
if ($type == 'error_403') {
header('HTTP/1.1 403 Forbidden');
} elseif ($type == 'error_404') {
header('HTTP/1.1 404 Not Found');
} else {
header('HTTP/1.1 200 Ok');
}
header('Vary: User-Agent', false);
header('Content-Type: ' . $content . '; charset=' . Config::get('characterSet'));
// Send the cache headers
//.........这里部分代码省略.........
示例15: get
/**
* Gets the value of a signed cookie. Cookies without signatures will not
* be returned. If the cookie signature is present, but invalid, the cookie
* will be deleted.
*
* // Get the "theme" cookie, or use "blue" if the cookie does not exist
* $theme = Cookie::get('theme', 'blue');
*
* @param string cookie name
* @param mixed default value to return
* @return string
*/
public static function get($name = null, $default = null)
{
return \Input::cookie($name, $default);
}