📄 index_ts.php
字号:
<?php/**************************************************************** Copyright notice** (c) 1999-2007 Kasper Skaarhoj (kasperYYYY@typo3.com)* All rights reserved** This script is part of the TYPO3 project. The TYPO3 project is* free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** The GNU General Public License can be found at* http://www.gnu.org/copyleft/gpl.html.* A copy is found in the textfile GPL.txt and important notices to the license* from the author is found in LICENSE.txt distributed with these scripts.*** This script is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.** This copyright notice MUST APPEAR in all copies of the script!***************************************************************//** * This is the MAIN DOCUMENT of the TypoScript driven standard front-end (from the "cms" extension) * Basically put this is the "index.php" script which all requests for TYPO3 delivered pages goes to in the frontend (the website) * The script configures constants, includes libraries and does a little logic here and there in order to instantiate the right classes to create the webpage. * All the real data processing goes on in the "tslib/" classes which this script will include and use as needed. * * $Id: index_ts.php 2488 2007-09-05 09:49:51Z tkahler $ * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj * * @author Kasper Skaarhoj <kasperYYYY@typo3.com> * @package TYPO3 * @subpackage tslib */// *******************************// Set error reporting// *******************************error_reporting (E_ALL ^ E_NOTICE);// ******************// Constants defined// ******************$TYPO3_MISC['microtime_start'] = microtime();define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');define('TYPO3_MODE','FE');if (!defined('PATH_thisScript')) define('PATH_thisScript',str_replace('//','/', str_replace('\\','/', (php_sapi_name()=='cgi'||php_sapi_name()=='isapi' ||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED'])? ($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED']):($_SERVER['ORIG_SCRIPT_FILENAME']?$_SERVER['ORIG_SCRIPT_FILENAME']:$_SERVER['SCRIPT_FILENAME']))));if (!defined('PATH_site')) define('PATH_site', dirname(PATH_thisScript).'/');if (!defined('PATH_t3lib')) define('PATH_t3lib', PATH_site.'t3lib/');define('TYPO3_mainDir', 'typo3/'); // This is the directory of the backend administration for the sites of this TYPO3 installation.define('PATH_typo3', PATH_site.TYPO3_mainDir);define('PATH_typo3conf', PATH_site.'typo3conf/');if (!defined('PATH_tslib')) { if (@is_dir(PATH_site.TYPO3_mainDir.'sysext/cms/tslib/')) { define('PATH_tslib', PATH_site.TYPO3_mainDir.'sysext/cms/tslib/'); } elseif (@is_dir(PATH_site.'tslib/')) { define('PATH_tslib', PATH_site.'tslib/'); }}if (!@is_dir(PATH_typo3conf)) die('Cannot find configuration. This file is probably executed from the wrong location.');// *********************// Timetracking started// *********************require_once(PATH_t3lib.'class.t3lib_timetrack.php');$TT = new t3lib_timeTrack;$TT->start();$TT->push('','Script start');// *********************// Mandatory libraries included// *********************$TT->push('Include class t3lib_db, t3lib_div, t3lib_extmgm',''); require_once(PATH_t3lib.'class.t3lib_div.php'); require_once(PATH_t3lib.'class.t3lib_extmgm.php');$TT->pull();// **********************// Include configuration// **********************$TT->push('Include config files','');require(PATH_t3lib.'config_default.php');if (!defined ('TYPO3_db')) die ('The configuration file was not included.'); // the name of the TYPO3 database is stored in this constant. Here the inclusion of the config-file is verified by checking if this var is set.if (!t3lib_extMgm::isLoaded('cms')) die('<strong>Error:</strong> The main frontend extension "cms" was not loaded. Enable it in the extension manager in the backend.');if (!defined('PATH_tslib')) { define('PATH_tslib', t3lib_extMgm::extPath('cms').'tslib/');}require_once(PATH_t3lib.'class.t3lib_db.php');$TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');$TYPO3_DB->debugOutput = $TYPO3_CONF_VARS['SYS']['sqlDebug'];$CLIENT = t3lib_div::clientInfo(); // Set to the browser: net / msie if 4+ browsers$TT->pull();// *******************************// Checking environment// *******************************if (t3lib_div::int_from_ver(phpversion())<4003000) die ('TYPO3 requires PHP 4.3.0 or higher.');if (isset($_POST['GLOBALS']) || isset($_GET['GLOBALS'])) die('You cannot set the GLOBALS-array from outside the script.');if (!get_magic_quotes_gpc()) { $TT->push('Add slashes to GET/POST arrays',''); t3lib_div::addSlashesOnArray($_GET); t3lib_div::addSlashesOnArray($_POST); $HTTP_GET_VARS = $_GET; $HTTP_POST_VARS = $_POST; $TT->pull();}// *********************// Look for extension ID which will launch alternative output engine// *********************if ($temp_extId = t3lib_div::_GP('eID')) { if ($classPath = t3lib_div::getFileAbsFileName($TYPO3_CONF_VARS['FE']['eID_include'][$temp_extId])) { require_once(PATH_tslib.'class.tslib_eidtools.php'); require($classPath); } exit;}// *********************// Libraries included// *********************$TT->push('Include Frontend libraries',''); require_once(PATH_tslib.'class.tslib_fe.php'); require_once(PATH_t3lib.'class.t3lib_page.php'); require_once(PATH_t3lib.'class.t3lib_userauth.php'); require_once(PATH_tslib.'class.tslib_feuserauth.php'); require_once(PATH_t3lib.'class.t3lib_tstemplate.php'); require_once(PATH_t3lib.'class.t3lib_cs.php');$TT->pull();// ***********************************// Create $TSFE object (TSFE = TypoScript Front End)// Connecting to database// ***********************************$temp_TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');$TSFE = new $temp_TSFEclassName( $TYPO3_CONF_VARS, t3lib_div::_GP('id'), t3lib_div::_GP('type'), t3lib_div::_GP('no_cache'), t3lib_div::_GP('cHash'), t3lib_div::_GP('jumpurl'), t3lib_div::_GP('MP'), t3lib_div::_GP('RDCT') );$TSFE->connectToDB(); // In case of a keyword-authenticated preview, re-initialize the TSFE object:if ($temp_previewConfig = $TSFE->ADMCMD_preview()) { $TSFE = new $temp_TSFEclassName( $TYPO3_CONF_VARS, t3lib_div::_GP('id'), t3lib_div::_GP('type'), t3lib_div::_GP('no_cache'), t3lib_div::_GP('cHash'), t3lib_div::_GP('jumpurl'), t3lib_div::_GP('MP'), t3lib_div::_GP('RDCT') ); $TSFE->ADMCMD_preview_postInit($temp_previewConfig);}if ($TSFE->RDCT) {$TSFE->sendRedirect();}// *******************// output compression// *******************if ($TYPO3_CONF_VARS['FE']['compressionLevel']) { ob_start(); require_once(PATH_t3lib.'class.gzip_encode.php');}// *********// FE_USER// *********$TT->push('Front End user initialized',''); $TSFE->initFEuser();$TT->pull();// ****************// PRE BE_USER HOOK// ****************if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preBeUser'])) { foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preBeUser'] as $_funcRef) { $_params = array(); t3lib_div::callUserFunction($_funcRef, $_params , $_params); }}// *********// BE_USER// *********$BE_USER='';if ($_COOKIE['be_typo_user']) { // If the backend cookie is set, we proceed and checks if a backend user is logged in. $TYPO3_MISC['microtime_BE_USER_start'] = microtime(); $TT->push('Back End user initialized',''); require_once (PATH_t3lib.'class.t3lib_befunc.php'); require_once (PATH_t3lib.'class.t3lib_userauthgroup.php'); require_once (PATH_t3lib.'class.t3lib_beuserauth.php'); require_once (PATH_t3lib.'class.t3lib_tsfebeuserauth.php'); // the value this->formfield_status is set to empty in order to disable login-attempts to the backend account through this script $BE_USER = t3lib_div::makeInstance('t3lib_tsfeBeUserAuth'); // New backend user object $BE_USER->OS = TYPO3_OS; $BE_USER->lockIP = $TYPO3_CONF_VARS['BE']['lockIP']; $BE_USER->start(); // Object is initialized $BE_USER->unpack_uc(''); if ($BE_USER->user['uid']) { $BE_USER->fetchGroupData(); $TSFE->beUserLogin = 1; } if ($BE_USER->checkLockToIP() && $BE_USER->checkBackendAccessSettingsFromInitPhp()) { $BE_USER->extInitFeAdmin(); } else { // Unset the user initialization. $BE_USER=''; $TSFE->beUserLogin=0; } $TT->pull(); $TYPO3_MISC['microtime_BE_USER_end'] = microtime();} elseif ($TSFE->ADMCMD_preview_BEUSER_uid) { require_once (PATH_t3lib.'class.t3lib_befunc.php'); require_once (PATH_t3lib.'class.t3lib_userauthgroup.php'); require_once (PATH_t3lib.'class.t3lib_beuserauth.php'); require_once (PATH_t3lib.'class.t3lib_tsfebeuserauth.php'); // the value this->formfield_status is set to empty in order to disable login-attempts to the backend account through this script $BE_USER = t3lib_div::makeInstance('t3lib_tsfeBeUserAuth'); // New backend user object $BE_USER->userTS_dontGetCached = 1; $BE_USER->OS = TYPO3_OS; $BE_USER->setBeUserByUid($TSFE->ADMCMD_preview_BEUSER_uid); $BE_USER->unpack_uc(''); if ($BE_USER->user['uid']) { $BE_USER->fetchGroupData(); $TSFE->beUserLogin = 1; } else { $BE_USER = ''; $TSFE->beUserLogin = 0; }}// ********************// Workspace preview:// ********************$TSFE->workspacePreviewInit();// *****************************************// Process the ID, type and other parameters// After this point we have an array, $page in TSFE, which is the page-record of the current page, $id// *****************************************$TT->push('Process ID',''); $TSFE->checkAlternativeIdMethods(); $TSFE->clear_preview(); $TSFE->determineId(); // Now, if there is a backend user logged in and he has NO access to this page, then re-evaluate the id shown! if ($TSFE->beUserLogin && (!$BE_USER->extPageReadAccess($TSFE->page) || t3lib_div::_GP('ADMCMD_noBeUser'))) { // t3lib_div::_GP('ADMCMD_noBeUser') is placed here because workspacePreviewInit() might need to know if a backend user is logged in! // Remove user unset($BE_USER); $TSFE->beUserLogin = 0; // Re-evaluate the page-id. $TSFE->checkAlternativeIdMethods(); $TSFE->clear_preview(); $TSFE->determineId(); } $TSFE->makeCacheHash();$TT->pull();// *****************************************// Frontend editing// *****************************************if ($TSFE->beUserLogin && $BE_USER->extAdmEnabled) { require_once(t3lib_extMgm::extPath('lang').'lang.php'); $LANG = t3lib_div::makeInstance('language'); $LANG->init($BE_USER->uc['lang']); $BE_USER->extSaveFeAdminConfig(); // Setting some values based on the admin panel $TSFE->forceTemplateParsing = $BE_USER->extGetFeAdminValue('tsdebug', 'forceTemplateParsing'); $TSFE->displayEditIcons = $BE_USER->extGetFeAdminValue('edit', 'displayIcons');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -