当前位置: 首页>>代码示例>>PHP>>正文


PHP Input::cookie方法代码示例

本文整理汇总了PHP中Contao\Input::cookie方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::cookie方法的具体用法?PHP Input::cookie怎么用?PHP Input::cookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contao\Input的用法示例。


在下文中一共展示了Input::cookie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Initialize the object
  */
 protected function __construct()
 {
     parent::__construct();
     $this->strIp = \Environment::get('ip');
     $this->strHash = \Input::cookie($this->strCookie);
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:9,代码来源:BackendUser.php

示例2: getDebugBar

 /**
  * Return the debug bar string
  *
  * @return string The debug bar markup
  */
 protected function getDebugBar()
 {
     $intReturned = 0;
     $intAffected = 0;
     // Count the totals (see #3884)
     if (is_array($GLOBALS['TL_DEBUG']['database_queries'])) {
         foreach ($GLOBALS['TL_DEBUG']['database_queries'] as $k => $v) {
             $intReturned += $v['return_count'];
             $intAffected += $v['affected_count'];
             unset($GLOBALS['TL_DEBUG']['database_queries'][$k]['return_count']);
             unset($GLOBALS['TL_DEBUG']['database_queries'][$k]['affected_count']);
         }
     }
     $intElapsed = microtime(true) - TL_START;
     $strDebug = sprintf("<!-- indexer::stop -->\n" . '<div id="contao-debug">' . '<p>' . '<span class="debug-time">Execution time: %s ms</span>' . '<span class="debug-memory">Memory usage: %s</span>' . '<span class="debug-db">Database queries: %d</span>' . '<span class="debug-rows">Rows: %d returned, %s affected</span>' . '<span class="debug-models">Registered models: %d</span>' . '<span id="debug-tog">&nbsp;</span>' . '</p>' . '<div><pre>', $this->getFormattedNumber($intElapsed * 1000, 0), $this->getReadableSize(memory_get_peak_usage()), count($GLOBALS['TL_DEBUG']['database_queries']), $intReturned, $intAffected, \Model\Registry::getInstance()->count());
     ksort($GLOBALS['TL_DEBUG']);
     ob_start();
     print_r($GLOBALS['TL_DEBUG']);
     $strDebug .= ob_get_contents();
     ob_end_clean();
     unset($GLOBALS['TL_DEBUG']);
     $strDebug .= '</pre></div></div>' . $this->generateInlineScript("(function(\$) {" . "\$(document.body).addClass('debug-enabled " . \Input::cookie('CONTAO_CONSOLE') . "');" . "\$('debug-tog').addEvent('click',function(e) {" . "\$(document.body).toggleClass('debug-closed');" . "Cookie.write('CONTAO_CONSOLE',\$(document.body).hasClass('debug-closed')?'debug-closed':'',{path:'" . (TL_PATH ?: '/') . "'});" . "});" . "})(document.id);", $this->strFormat == 'xhtml') . "\n<!-- indexer::continue -->\n\n";
     return $strDebug;
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:29,代码来源:Template.php

示例3: addToCache

 /**
  * Add the template output to the cache and add the cache headers
  */
 protected function addToCache()
 {
     /** @var PageModel $objPage */
     global $objPage;
     $intCache = 0;
     // Decide whether the page shall be cached
     if (!isset($_GET['file']) && !isset($_GET['token']) && empty($_POST) && !BE_USER_LOGGED_IN && !FE_USER_LOGGED_IN && !$_SESSION['DISABLE_CACHE'] && !isset($_SESSION['LOGIN_ERROR']) && !\Message::hasMessages() && intval($objPage->cache) > 0 && !$objPage->protected) {
         $intCache = time() + intval($objPage->cache);
     }
     // Server-side cache
     if ($intCache > 0 && (\Config::get('cacheMode') == 'both' || \Config::get('cacheMode') == 'server')) {
         // If the request string is empty, use a special cache tag which considers the page language
         if (\Environment::get('relativeRequest') == '') {
             $strCacheKey = \Environment::get('host') . '/empty.' . $objPage->language;
         } else {
             $strCacheKey = \Environment::get('host') . '/' . \Environment::get('relativeRequest');
         }
         // 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);
             }
         }
         // Add a suffix if there is a mobile layout (see #7826)
         if ($objPage->mobileLayout > 0) {
             if (\Input::cookie('TL_VIEW') == 'mobile' || \Environment::get('agent')->mobile && \Input::cookie('TL_VIEW') != 'desktop') {
                 $strCacheKey .= '.mobile';
             } else {
                 $strCacheKey .= '.desktop';
             }
         }
         // Replace insert tags for caching
         $strBuffer = $this->replaceInsertTags($this->strBuffer);
         $strBuffer = $this->replaceDynamicScriptTags($strBuffer);
         // see #4203
         // Add the cache file header
         $strHeader = sprintf("<?php /* %s */ \$expire = %d; \$content = %s; \$type = %s; \$files = %s; \$assets = %s; ?>\n", $strCacheKey, (int) $intCache, var_export($this->strContentType, true), var_export($objPage->type, true), var_export(TL_FILES_URL, true), var_export(TL_ASSETS_URL, true));
         $strCachePath = str_replace(TL_ROOT . '/', '', \System::getContainer()->getParameter('kernel.cache_dir'));
         // Create the cache file
         $strMd5CacheKey = md5($strCacheKey);
         $objFile = new \File($strCachePath . '/contao/html/' . substr($strMd5CacheKey, 0, 1) . '/' . $strMd5CacheKey . '.html');
         $objFile->write($strHeader);
         $objFile->append($this->minifyHtml($strBuffer), '');
         $objFile->close();
     }
     // Client-side cache
     if (!headers_sent()) {
         if ($intCache > 0 && (\Config::get('cacheMode') == 'both' || \Config::get('cacheMode') == 'browser')) {
             header('Cache-Control: private, max-age=' . ($intCache - time()));
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
             header('Expires: ' . gmdate('D, d M Y H:i:s', $intCache) . ' GMT');
         } else {
             header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
             header('Expires: Fri, 06 Jun 1975 15:10:00 GMT');
         }
     }
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:62,代码来源:FrontendTemplate.php

示例4: getResponseFromCache

 /**
  * Check whether there is a cached version of the page and return a response object
  *
  * @return Response|null
  */
 public static function getResponseFromCache()
 {
     // Build the page if a user is (potentially) logged in or there is POST data
     if (!empty($_POST) || \Input::cookie('BE_USER_AUTH') || \Input::cookie('FE_USER_AUTH') || \Input::cookie('FE_AUTO_LOGIN') || $_SESSION['DISABLE_CACHE'] || isset($_SESSION['LOGIN_ERROR']) || \Message::hasMessages() || \Config::get('debugMode')) {
         return null;
     }
     $strCacheDir = \System::getContainer()->getParameter('kernel.cache_dir');
     // Try to map the empty request
     if (\Environment::get('relativeRequest') == '') {
         // Return if the language is added to the URL and the empty domain will be redirected
         if (\Config::get('addLanguageToUrl') && !\Config::get('doNotRedirectEmpty')) {
             return null;
         }
         $strCacheKey = null;
         $arrLanguage = \Environment::get('httpAcceptLanguage');
         $strMappingFile = $strCacheDir . '/contao/config/mapping.php';
         // Try to get the cache key from the mapper array
         if (file_exists($strMappingFile)) {
             $arrMapper = (include $strMappingFile);
             $arrPaths = array(\Environment::get('host'), '*');
             // Try the language specific keys
             foreach ($arrLanguage as $strLanguage) {
                 foreach ($arrPaths as $strPath) {
                     $strKey = $strPath . '/empty.' . $strLanguage;
                     if (isset($arrMapper[$strKey])) {
                         $strCacheKey = $arrMapper[$strKey];
                         break;
                     }
                 }
             }
             // Try the fallback key
             if ($strCacheKey === null) {
                 foreach ($arrPaths as $strPath) {
                     $strKey = $strPath . '/empty.fallback';
                     if (isset($arrMapper[$strKey])) {
                         $strCacheKey = $arrMapper[$strKey];
                         break;
                     }
                 }
             }
         }
         // Fall back to the first accepted language
         if ($strCacheKey === null) {
             $strCacheKey = \Environment::get('host') . '/empty.' . $arrLanguage[0];
         }
     } else {
         $strCacheKey = \Environment::get('host') . '/' . \Environment::get('relativeRequest');
     }
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['getCacheKey']) && is_array($GLOBALS['TL_HOOKS']['getCacheKey'])) {
         foreach ($GLOBALS['TL_HOOKS']['getCacheKey'] as $callback) {
             $strCacheKey = \System::importStatic($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') {
         $strMd5CacheKey = md5($strCacheKey . '.mobile');
         $strCacheFile = $strCacheDir . '/contao/html/' . substr($strMd5CacheKey, 0, 1) . '/' . $strMd5CacheKey . '.html';
         if (file_exists($strCacheFile)) {
             $blnFound = true;
         }
     } else {
         $strMd5CacheKey = md5($strCacheKey . '.desktop');
         $strCacheFile = $strCacheDir . '/contao/html/' . substr($strMd5CacheKey, 0, 1) . '/' . $strMd5CacheKey . '.html';
         if (file_exists($strCacheFile)) {
             $blnFound = true;
         }
     }
     // Check for a regular layout
     if (!$blnFound) {
         $strMd5CacheKey = md5($strCacheKey);
         $strCacheFile = $strCacheDir . '/contao/html/' . substr($strMd5CacheKey, 0, 1) . '/' . $strMd5CacheKey . '.html';
         if (file_exists($strCacheFile)) {
             $blnFound = true;
         }
     }
     // Return if the file does not exist
     if (!$blnFound) {
         return null;
     }
     $expire = null;
     $content = null;
     $type = null;
     $files = null;
     $assets = null;
     // Include the file
     ob_start();
     require_once $strCacheFile;
     // The file has expired
     if ($expire < time()) {
         ob_end_clean();
         return null;
     }
//.........这里部分代码省略.........
开发者ID:bytehead,项目名称:core-bundle,代码行数:101,代码来源:Frontend.php

示例5: run

 /**
  * Run the controller and parse the template
  *
  * @return Response
  */
 public function run()
 {
     $this->disableProfiler();
     if (\Environment::get('isAjaxRequest')) {
         $this->getDatalistOptions();
     }
     $strUser = '';
     $strHash = $this->getSessionHash('FE_USER_AUTH');
     // Get the front end user
     if (FE_USER_LOGGED_IN) {
         $objUser = $this->Database->prepare("SELECT username FROM tl_member WHERE id=(SELECT pid FROM tl_session WHERE hash=?)")->limit(1)->execute($strHash);
         if ($objUser->numRows) {
             $strUser = $objUser->username;
         }
     }
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_switch');
     $objTemplate->user = $strUser;
     $objTemplate->show = \Input::cookie('FE_PREVIEW');
     $objTemplate->update = false;
     // Switch
     if (\Input::post('FORM_SUBMIT') == 'tl_switch') {
         $time = time();
         // Hide unpublished elements
         if (\Input::post('unpublished') == 'hide') {
             $this->setCookie('FE_PREVIEW', 0, $time - 86400);
             $objTemplate->show = 0;
         } else {
             $this->setCookie('FE_PREVIEW', 1, $time + \Config::get('sessionTimeout'));
             $objTemplate->show = 1;
         }
         // Allow admins to switch user accounts
         if ($this->User->isAdmin) {
             // Remove old sessions
             $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute($time - \Config::get('sessionTimeout'), $strHash);
             // Log in the front end user
             if (\Input::post('user')) {
                 $objUser = \MemberModel::findByUsername(\Input::post('user'));
                 if ($objUser !== null) {
                     // Insert the new session
                     $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute($objUser->id, $time, 'FE_USER_AUTH', \System::getContainer()->get('session')->getId(), \Environment::get('ip'), $strHash);
                     // Set the cookie
                     $this->setCookie('FE_USER_AUTH', $strHash, $time + \Config::get('sessionTimeout'), null, null, false, true);
                     $objTemplate->user = \Input::post('user');
                 }
             } else {
                 // Remove cookie
                 $this->setCookie('FE_USER_AUTH', $strHash, $time - 86400, null, null, false, true);
                 $objTemplate->user = '';
             }
         }
         $objTemplate->update = true;
     }
     // Default variables
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->apply = $GLOBALS['TL_LANG']['MSC']['apply'];
     $objTemplate->reload = $GLOBALS['TL_LANG']['MSC']['reload'];
     $objTemplate->feUser = $GLOBALS['TL_LANG']['MSC']['feUser'];
     $objTemplate->username = $GLOBALS['TL_LANG']['MSC']['username'];
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->lblHide = $GLOBALS['TL_LANG']['MSC']['hiddenHide'];
     $objTemplate->lblShow = $GLOBALS['TL_LANG']['MSC']['hiddenShow'];
     $objTemplate->fePreview = $GLOBALS['TL_LANG']['MSC']['fePreview'];
     $objTemplate->hiddenElements = $GLOBALS['TL_LANG']['MSC']['hiddenElements'];
     $objTemplate->closeSrc = TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/close.gif';
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->isAdmin = $this->User->isAdmin;
     return $objTemplate->getResponse();
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:76,代码来源:BackendSwitch.php

示例6: getPageLayout

 /**
  * Get a page layout and return it as database result object
  *
  * @param \PageModel $objPage
  *
  * @return \LayoutModel
  */
 protected function getPageLayout($objPage)
 {
     $blnMobile = $objPage->mobileLayout && \Environment::get('agent')->mobile;
     // Override the autodetected value
     if (\Input::cookie('TL_VIEW') == 'mobile') {
         $blnMobile = true;
     } elseif (\Input::cookie('TL_VIEW') == 'desktop') {
         $blnMobile = false;
     }
     $intId = $blnMobile && $objPage->mobileLayout ? $objPage->mobileLayout : $objPage->layout;
     $objLayout = \LayoutModel::findByPk($intId);
     // Die if there is no layout
     if (null === $objLayout) {
         $this->log('Could not find layout ID "' . $intId . '"', __METHOD__, TL_ERROR);
         throw new NoLayoutSpecifiedException('No layout specified');
     }
     $objPage->hasJQuery = $objLayout->addJQuery;
     $objPage->hasMooTools = $objLayout->addMooTools;
     $objPage->isMobile = $blnMobile;
     return $objLayout;
 }
开发者ID:jamesdevine,项目名称:core-bundle,代码行数:28,代码来源:PageRegular.php

示例7: logout

 /**
  * Logout from phpbb
  */
 public function logout()
 {
     if ($this->debug) {
         System::log("phpbb_bridge: " . __METHOD__, __METHOD__, TL_ACCESS);
     }
     $cookie_prefix = $this->getDbConfig('cookie_name');
     $sid = Input::cookie($cookie_prefix . '_sid');
     System::getContainer()->get('session')->remove('phpbb_user');
     if ($sid) {
         $logoutUrl = Environment::get('url') . '/' . $this->getForumPath() . '/contao_connect/logout';
         $headers = $this->initForumRequestHeaders();
         $browser = $this->initForumRequest();
         $browser->get($logoutUrl, $headers);
         // Parse cookies and send them to the client
         foreach ($browser->getListener()->getCookies() as $cookie) {
             /* @var $cookie Cookie */
             // Stream cookies through to the client
             System::setCookie($cookie->getName(), $cookie->getValue(), strtotime($cookie->getAttribute('expires')), $cookie->getAttribute('path'), $cookie->getAttribute('domain'));
         }
     }
 }
开发者ID:ctsmedia,项目名称:contao-phpbb-bridge-bundle,代码行数:24,代码来源:Connector.php

示例8: run

 /**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     if (!\Config::get('enableSearch')) {
         return '';
     }
     $time = time();
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_rebuild_index');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->indexHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['searchIndex'];
     $objTemplate->isActive = $this->isActive();
     // Add the error message
     if ($_SESSION['REBUILD_INDEX_ERROR'] != '') {
         $objTemplate->indexMessage = $_SESSION['REBUILD_INDEX_ERROR'];
         $_SESSION['REBUILD_INDEX_ERROR'] = '';
     }
     // Rebuild the index
     if (\Input::get('act') == 'index') {
         // Check the request token (see #4007)
         if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) {
             /** @var SessionInterface $objSession */
             $objSession = \System::getContainer()->get('session');
             $objSession->set('INVALID_TOKEN_URL', \Environment::get('request'));
             $this->redirect('contao/confirm.php');
         }
         $arrPages = $this->findSearchablePages();
         // HOOK: take additional pages
         if (isset($GLOBALS['TL_HOOKS']['getSearchablePages']) && is_array($GLOBALS['TL_HOOKS']['getSearchablePages'])) {
             foreach ($GLOBALS['TL_HOOKS']['getSearchablePages'] as $callback) {
                 $this->import($callback[0]);
                 $arrPages = $this->{$callback[0]}->{$callback[1]}($arrPages);
             }
         }
         // Return if there are no pages
         if (empty($arrPages)) {
             $_SESSION['REBUILD_INDEX_ERROR'] = $GLOBALS['TL_LANG']['tl_maintenance']['noSearchable'];
             $this->redirect($this->getReferer());
         }
         // Truncate the search tables
         $this->import('Automator');
         $this->Automator->purgeSearchTables();
         // Hide unpublished elements
         $this->setCookie('FE_PREVIEW', 0, $time - 86400);
         // Calculate the hash
         $strHash = $this->getSessionHash('FE_USER_AUTH');
         // Remove old sessions
         $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute($time - \Config::get('sessionTimeout'), $strHash);
         // Log in the front end user
         if (is_numeric(\Input::get('user')) && \Input::get('user') > 0) {
             // Insert a new session
             $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute(\Input::get('user'), $time, 'FE_USER_AUTH', \System::getContainer()->get('session')->getId(), \Environment::get('ip'), $strHash);
             // Set the cookie
             $this->setCookie('FE_USER_AUTH', $strHash, $time + \Config::get('sessionTimeout'), null, null, false, true);
         } else {
             // Unset the cookies
             $this->setCookie('FE_USER_AUTH', $strHash, $time - 86400, null, null, false, true);
             $this->setCookie('FE_AUTO_LOGIN', \Input::cookie('FE_AUTO_LOGIN'), $time - 86400, null, null, false, true);
         }
         $strBuffer = '';
         $rand = rand();
         // Display the pages
         for ($i = 0, $c = count($arrPages); $i < $c; $i++) {
             $strBuffer .= '<span class="page_url" data-url="' . $arrPages[$i] . '#' . $rand . $i . '">' . \StringUtil::substr($arrPages[$i], 100) . '</span><br>';
             unset($arrPages[$i]);
             // see #5681
         }
         $objTemplate->content = $strBuffer;
         $objTemplate->note = $GLOBALS['TL_LANG']['tl_maintenance']['indexNote'];
         $objTemplate->loading = $GLOBALS['TL_LANG']['tl_maintenance']['indexLoading'];
         $objTemplate->complete = $GLOBALS['TL_LANG']['tl_maintenance']['indexComplete'];
         $objTemplate->indexContinue = $GLOBALS['TL_LANG']['MSC']['continue'];
         $objTemplate->theme = \Backend::getTheme();
         $objTemplate->isRunning = true;
         return $objTemplate->parse();
     }
     $arrUser = array('' => '-');
     // Get active front end users
     $objUser = $this->Database->execute("SELECT id, username FROM tl_member WHERE disable!='1' AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "') ORDER BY username");
     while ($objUser->next()) {
         $arrUser[$objUser->id] = $objUser->username . ' (' . $objUser->id . ')';
     }
     // Default variables
     $objTemplate->user = $arrUser;
     $objTemplate->indexLabel = $GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][0];
     $objTemplate->indexHelp = \Config::get('showHelp') && strlen($GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][1]) ? $GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][1] : '';
     $objTemplate->indexSubmit = $GLOBALS['TL_LANG']['tl_maintenance']['indexSubmit'];
     return $objTemplate->parse();
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:93,代码来源:RebuildIndex.php

示例9: output

 /**
  * Output the template file
  *
  * @return Response
  */
 protected function output()
 {
     // Default headline
     if ($this->Template->headline == '') {
         $this->Template->headline = \Config::get('websiteTitle');
     }
     // Default title
     if ($this->Template->title == '') {
         $this->Template->title = $this->Template->headline;
     }
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     // File picker reference
     if (\Input::get('popup') && \Input::get('act') != 'show' && (\Input::get('do') == 'page' || \Input::get('do') == 'files') && $objSession->get('filePickerRef')) {
         $this->Template->managerHref = ampersand($objSession->get('filePickerRef'));
         $this->Template->manager = strpos($objSession->get('filePickerRef'), 'contao/page?') !== false ? $GLOBALS['TL_LANG']['MSC']['pagePickerHome'] : $GLOBALS['TL_LANG']['MSC']['filePickerHome'];
     }
     // Website title
     if (\Config::get('websiteTitle') != 'Contao Open Source CMS') {
         $this->Template->websiteTitle = \Config::get('websiteTitle');
     }
     $this->Template->theme = \Backend::getTheme();
     $this->Template->base = \Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->title = \StringUtil::specialchars($this->Template->title);
     $this->Template->charset = \Config::get('characterSet');
     $this->Template->account = $GLOBALS['TL_LANG']['MOD']['login'][1];
     $this->Template->preview = $GLOBALS['TL_LANG']['MSC']['fePreview'];
     $this->Template->previewTitle = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['fePreviewTitle']);
     $this->Template->pageOffset = \Input::cookie('BE_PAGE_OFFSET');
     $this->Template->logout = $GLOBALS['TL_LANG']['MSC']['logoutBT'];
     $this->Template->logoutTitle = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['logoutBTTitle']);
     $this->Template->backendModules = $GLOBALS['TL_LANG']['MSC']['backendModules'];
     $this->Template->username = $GLOBALS['TL_LANG']['MSC']['user'] . ' ' . $GLOBALS['TL_USERNAME'];
     $this->Template->skipNavigation = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']);
     $this->Template->request = ampersand(\Environment::get('request'));
     $this->Template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
     $this->Template->modules = $this->User->navigation();
     $this->Template->home = $GLOBALS['TL_LANG']['MSC']['home'];
     $this->Template->homeTitle = $GLOBALS['TL_LANG']['MSC']['homeTitle'];
     $this->Template->backToTop = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['backToTopTitle']);
     $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->isPopup = \Input::get('popup');
     $this->Template->systemMessages = $GLOBALS['TL_LANG']['MSC']['systemMessages'];
     $strSystemMessages = \Backend::getSystemMessages();
     $this->Template->systemMessagesCount = substr_count($strSystemMessages, 'class="tl_');
     $this->Template->systemErrorMessagesCount = substr_count($strSystemMessages, 'class="tl_error"');
     // Front end preview links
     if (defined('CURRENT_ID') && CURRENT_ID != '') {
         if (\Input::get('do') == 'page') {
             $this->Template->frontendFile = '?page=' . CURRENT_ID;
         } elseif (\Input::get('do') == 'article' && ($objArticle = \ArticleModel::findByPk(CURRENT_ID)) !== null) {
             $this->Template->frontendFile = '?page=' . $objArticle->pid;
         } elseif (\Input::get('do') != '') {
             $event = new PreviewUrlCreateEvent(\Input::get('do'), CURRENT_ID);
             \System::getContainer()->get('event_dispatcher')->dispatch(ContaoCoreEvents::PREVIEW_URL_CREATE, $event);
             if (($strQuery = $event->getQuery()) !== null) {
                 $this->Template->frontendFile = '?' . $strQuery;
             }
         }
     }
     return $this->Template->getResponse();
 }
开发者ID:bytehead,项目名称:core-bundle,代码行数:70,代码来源:BackendMain.php

示例10: getUserID

 /**
  * @return string
  */
 protected function getUserID()
 {
     $hash = Input::cookie('BE_USER_AUTH');
     $id = '0';
     if (isset($hash) && $hash != '') {
         $sessionDB = $this->Database->prepare('SELECT * FROM tl_session WHERE hash = ?')->execute($hash);
         if ($sessionDB->count() > 0) {
             $id = $sessionDB->row()['pid'];
         }
     }
     return $id;
 }
开发者ID:alnv,项目名称:fmodul,代码行数:15,代码来源:ViewContainer.php

示例11: getLoginStatus

 /**
  * Check whether a back end or front end user is logged in
  *
  * @param string $strCookie
  *
  * @return boolean
  */
 protected function getLoginStatus($strCookie)
 {
     $cookie = \Input::cookie($strCookie);
     if ($cookie === null) {
         return false;
     }
     $hash = $this->getSessionHash($strCookie);
     // Validate the cookie hash
     if ($cookie == $hash) {
         // Try to find the session
         $objSession = \SessionModel::findByHashAndName($hash, $strCookie);
         // Validate the session ID and timeout
         if ($objSession !== null && $objSession->sessionID == \System::getContainer()->get('session')->getId() && (\System::getContainer()->getParameter('contao.security.disable_ip_check') || $objSession->ip == \Environment::get('ip')) && $objSession->tstamp + \Config::get('sessionTimeout') > time()) {
             // Disable the cache if a back end user is logged in
             if (TL_MODE == 'FE' && $strCookie == 'BE_USER_AUTH') {
                 $_SESSION['DISABLE_CACHE'] = true;
                 // Always return false if we are not in preview mode (show hidden elements)
                 if (!\Input::cookie('FE_PREVIEW')) {
                     return false;
                 }
             }
             // The session could be verified
             return true;
         }
     }
     // Reset the cache settings
     if (TL_MODE == 'FE' && $strCookie == 'BE_USER_AUTH') {
         $_SESSION['DISABLE_CACHE'] = false;
     }
     // Remove the cookie if it is invalid to enable loading cached pages
     $this->setCookie($strCookie, $hash, time() - 86400, null, null, \Environment::get('ssl'), true);
     return false;
 }
开发者ID:contao,项目名称:core-bundle,代码行数:40,代码来源:Frontend.php

示例12: logout

 /**
  * Remove the authentication cookie and destroy the current session
  *
  * @return boolean True if the user could be logged out
  */
 public function logout()
 {
     // Return if the user has been logged out already
     if (!\Input::cookie($this->strCookie)) {
         return false;
     }
     $intUserid = null;
     // Find the session
     $objSession = $this->Database->prepare("SELECT * FROM tl_session WHERE hash=?")->limit(1)->execute($this->strHash);
     if ($objSession->numRows) {
         $this->strIp = $objSession->ip;
         $this->strHash = $objSession->hash;
         $intUserid = $objSession->pid;
     }
     $time = time();
     // Remove the session from the database
     $this->Database->prepare("DELETE FROM tl_session WHERE hash=?")->execute($this->strHash);
     // Remove cookie and hash
     $this->setCookie($this->strCookie, $this->strHash, $time - 86400, null, null, false, true);
     $this->strHash = '';
     \System::getContainer()->get('session')->invalidate();
     \System::getContainer()->get('security.token_storage')->setToken(null);
     // Add a log entry
     if ($this->findBy('id', $intUserid) != false) {
         $GLOBALS['TL_USERNAME'] = $this->username;
         $this->log('User "' . $this->username . '" has logged out', __METHOD__, TL_ACCESS);
     }
     // HOOK: post logout callback
     if (isset($GLOBALS['TL_HOOKS']['postLogout']) && is_array($GLOBALS['TL_HOOKS']['postLogout'])) {
         foreach ($GLOBALS['TL_HOOKS']['postLogout'] as $callback) {
             $this->import($callback[0], 'objLogout', true);
             $this->objLogout->{$callback[1]}($this);
         }
     }
     return true;
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:41,代码来源:User.php

示例13: output

 /**
  * Output the template file
  *
  * @return Response
  */
 protected function output()
 {
     // Default headline
     if ($this->Template->headline == '') {
         $this->Template->headline = \Config::get('websiteTitle');
     }
     // Default title
     if ($this->Template->title == '') {
         $this->Template->title = $this->Template->headline;
     }
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     // File picker reference
     if (\Input::get('popup') && \Input::get('act') != 'show' && (\Input::get('do') == 'page' || \Input::get('do') == 'files') && $objSession->get('filePickerRef')) {
         $this->Template->managerHref = ampersand($this->Session->get('filePickerRef'));
         $this->Template->manager = strpos($objSession->get('filePickerRef'), 'contao/page?') !== false ? $GLOBALS['TL_LANG']['MSC']['pagePickerHome'] : $GLOBALS['TL_LANG']['MSC']['filePickerHome'];
     }
     $this->Template->theme = \Backend::getTheme();
     $this->Template->base = \Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->title = specialchars($this->Template->title);
     $this->Template->charset = \Config::get('characterSet');
     $this->Template->account = $GLOBALS['TL_LANG']['MOD']['login'][1];
     $this->Template->preview = $GLOBALS['TL_LANG']['MSC']['fePreview'];
     $this->Template->previewTitle = specialchars($GLOBALS['TL_LANG']['MSC']['fePreviewTitle']);
     $this->Template->pageOffset = \Input::cookie('BE_PAGE_OFFSET');
     $this->Template->logout = $GLOBALS['TL_LANG']['MSC']['logoutBT'];
     $this->Template->logoutTitle = specialchars($GLOBALS['TL_LANG']['MSC']['logoutBTTitle']);
     $this->Template->backendModules = $GLOBALS['TL_LANG']['MSC']['backendModules'];
     $this->Template->username = $GLOBALS['TL_LANG']['MSC']['user'] . ' ' . $GLOBALS['TL_USERNAME'];
     $this->Template->skipNavigation = specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']);
     $this->Template->request = ampersand(\Environment::get('request'));
     $this->Template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
     $this->Template->modules = $this->User->navigation();
     $this->Template->home = $GLOBALS['TL_LANG']['MSC']['home'];
     $this->Template->homeTitle = $GLOBALS['TL_LANG']['MSC']['homeTitle'];
     $this->Template->backToTop = specialchars($GLOBALS['TL_LANG']['MSC']['backToTopTitle']);
     $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 = \Config::get('loadGoogleFonts');
     $this->Template->isAdmin = $this->User->isAdmin;
     $this->Template->isMaintenanceMode = \Config::get('maintenanceMode');
     $this->Template->maintenanceMode = $GLOBALS['TL_LANG']['MSC']['maintenanceMode'];
     $this->Template->maintenanceOff = specialchars($GLOBALS['TL_LANG']['MSC']['maintenanceOff']);
     $this->Template->maintenanceHref = $this->addToUrl('mmo=1');
     $this->Template->buildCacheLink = $GLOBALS['TL_LANG']['MSC']['buildCacheLink'];
     $this->Template->buildCacheText = sprintf($GLOBALS['TL_LANG']['MSC']['buildCacheText'], \System::getContainer()->getParameter('kernel.environment'));
     $this->Template->buildCacheHref = $this->addToUrl('bic=1');
     $this->Template->needsCacheBuild = !is_dir(\System::getContainer()->getParameter('kernel.cache_dir') . '/contao/sql');
     $this->Template->isPopup = \Input::get('popup');
     // Front end preview links
     if (defined('CURRENT_ID') && CURRENT_ID != '') {
         // Pages
         if (\Input::get('do') == 'page') {
             $this->Template->frontendFile = '?page=' . CURRENT_ID;
         } elseif (\Input::get('do') == 'article') {
             if (($objArticle = \ArticleModel::findByPk(CURRENT_ID)) !== null) {
                 $this->Template->frontendFile = '?page=' . $objArticle->pid;
             }
         }
     }
     return $this->Template->getResponse();
 }
开发者ID:jamesdevine,项目名称:core-bundle,代码行数:69,代码来源:BackendMain.php

示例14: doReplace


//.........这里部分代码省略.........
                 $bundles = \System::getContainer()->getParameter('kernel.bundles');
                 if (isset($bundles['ContaoNewsBundle'])) {
                     $strQuery .= ", (SELECT MAX(tstamp) FROM tl_news) AS tn";
                 }
                 if (isset($bundles['ContaoCalendarBundle'])) {
                     $strQuery .= ", (SELECT MAX(tstamp) FROM tl_calendar_events) AS te";
                 }
                 $strQuery .= " FROM tl_content";
                 $objUpdate = \Database::getInstance()->query($strQuery);
                 if ($objUpdate->numRows) {
                     $arrCache[$strTag] = \Date::parse($elements[1] ?: \Config::get('datimFormat'), max($objUpdate->tc, $objUpdate->tn, $objUpdate->te));
                 }
                 break;
                 // Version
             // Version
             case 'version':
                 $arrCache[$strTag] = VERSION . '.' . BUILD;
                 break;
                 // Request token
             // Request token
             case 'request_token':
                 $arrCache[$strTag] = REQUEST_TOKEN;
                 break;
                 // POST data
             // POST data
             case 'post':
                 $arrCache[$strTag] = \Input::post($elements[1]);
                 break;
                 // Mobile/desktop toggle (see #6469)
             // Mobile/desktop toggle (see #6469)
             case 'toggle_view':
                 $strUrl = ampersand(\Environment::get('request'));
                 $strGlue = strpos($strUrl, '?') === false ? '?' : '&amp;';
                 if (\Input::cookie('TL_VIEW') == 'mobile' || \Environment::get('agent')->mobile && \Input::cookie('TL_VIEW') != 'desktop') {
                     $arrCache[$strTag] = '<a href="' . $strUrl . $strGlue . 'toggle_view=desktop" class="toggle_desktop" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['toggleDesktop'][1]) . '">' . $GLOBALS['TL_LANG']['MSC']['toggleDesktop'][0] . '</a>';
                 } else {
                     $arrCache[$strTag] = '<a href="' . $strUrl . $strGlue . 'toggle_view=mobile" class="toggle_mobile" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['toggleMobile'][1]) . '">' . $GLOBALS['TL_LANG']['MSC']['toggleMobile'][0] . '</a>';
                 }
                 break;
                 // Conditional tags (if)
             // Conditional tags (if)
             case 'iflng':
                 if ($elements[1] != '' && $elements[1] != $objPage->language) {
                     for (; $_rit < $_cnt; $_rit += 2) {
                         if ($tags[$_rit + 1] == 'iflng' || $tags[$_rit + 1] == 'iflng::' . $objPage->language) {
                             break;
                         }
                     }
                 }
                 unset($arrCache[$strTag]);
                 break;
                 // Conditional tags (if not)
             // Conditional tags (if not)
             case 'ifnlng':
                 if ($elements[1] != '') {
                     $langs = \StringUtil::trimsplit(',', $elements[1]);
                     if (in_array($objPage->language, $langs)) {
                         for (; $_rit < $_cnt; $_rit += 2) {
                             if ($tags[$_rit + 1] == 'ifnlng') {
                                 break;
                             }
                         }
                     }
                 }
                 unset($arrCache[$strTag]);
                 break;
开发者ID:contao,项目名称:core-bundle,代码行数:67,代码来源:InsertTags.php

示例15: hasAuthenticatedBackendUser

 /**
  * Check whether there is an authenticated back end user
  *
  * @return boolean True if there is an authenticated back end user
  */
 public function hasAuthenticatedBackendUser()
 {
     if (!isset($_COOKIE['BE_USER_AUTH'])) {
         return false;
     }
     return Input::cookie('BE_USER_AUTH') == $this->getSessionHash('BE_USER_AUTH');
 }
开发者ID:contao,项目名称:core-bundle,代码行数:12,代码来源:FrontendTemplate.php


注:本文中的Contao\Input::cookie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。