This commit was manufactured by cvs2svn to create tag
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / index_ts.php
index bf28b91..e1801a2 100755 (executable)
@@ -1,22 +1,22 @@
 <?php
 /***************************************************************
 *  Copyright notice
-*  
-*  (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
+*
+*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  All rights reserved
 *
-*  This script is part of the TYPO3 project. The TYPO3 project is 
+*  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 
+*  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
@@ -24,7 +24,7 @@
 *
 *  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.
  *
  * On Windows this file should copied to "index.php" in your website root (which is ../)
  *
- * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
+ * $Id$
+ * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
  *
- * @author     Kasper Skårhøj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage tslib
  */
+
 // *******************************
-// Set error reporting 
+// Set error reporting
 // *******************************
-error_reporting (E_ALL ^ E_NOTICE); 
+error_reporting (E_ALL ^ E_NOTICE);
 
 
 // ******************
@@ -52,13 +55,13 @@ error_reporting (E_ALL ^ E_NOTICE);
 $TYPO3_MISC['microtime_start'] = microtime();
 define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
 define('TYPO3_MODE','FE');
-define('PATH_thisScript',str_replace('//','/', str_replace('\\','/', php_sapi_name()=='cgi'||php_sapi_name()=='isapi' ? $HTTP_SERVER_VARS['PATH_TRANSLATED']:$HTTP_SERVER_VARS['SCRIPT_FILENAME'])));
+define('PATH_thisScript',str_replace('//','/', str_replace('\\','/', php_sapi_name()=='cgi'||php_sapi_name()=='isapi'||php_sapi_name()=='cgi-fcgi' ? $HTTP_SERVER_VARS['PATH_TRANSLATED']:$HTTP_SERVER_VARS['SCRIPT_FILENAME'])));
 
 define('PATH_site', dirname(PATH_thisScript).'/');
 define('PATH_t3lib', PATH_site.'t3lib/');
 define('PATH_tslib', PATH_site.'tslib/');
 define('PATH_typo3conf', PATH_site.'typo3conf/');
-define('TYPO3_mainDir', 'typo3/');             // This is the directory of the backend administration for the sites of this TYPO3 installation. 
+define('TYPO3_mainDir', 'typo3/');             // This is the directory of the backend administration for the sites of this TYPO3 installation.
 
 if (!@is_dir(PATH_typo3conf))  die('Cannot find configuration. This file is probably executed from the wrong location.');
 
@@ -74,7 +77,7 @@ $TT->push('','Script start');
 // *********************
 // DIV Library included
 // *********************
-$TT->push('Include class t3lib_div','');
+$TT->push('Include class t3lib_db, t3lib_div, t3lib_extmgm','');
        require(PATH_t3lib.'class.t3lib_div.php');
        require(PATH_t3lib.'class.t3lib_extmgm.php');
 $TT->pull();
@@ -89,6 +92,9 @@ 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.');
 
+require(PATH_t3lib.'class.t3lib_db.php');
+$TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
+
 $CLIENT=t3lib_div::clientInfo();                               // Set to the browser: net / msie if 4+ browsers
 $TT->pull();
 
@@ -116,6 +122,8 @@ if (!get_magic_quotes_gpc())        {
        $TT->push('Add slashes to GET/POST arrays','');
        t3lib_div::addSlashesOnArray($HTTP_GET_VARS);
        t3lib_div::addSlashesOnArray($HTTP_POST_VARS);
+       $_GET = $HTTP_GET_VARS;
+       $_POST = $HTTP_POST_VARS;
        $TT->pull();
 }
 
@@ -125,14 +133,14 @@ if (!get_magic_quotes_gpc())      {
 // ***********************************
 $temp_TSFEclassName=t3lib_div::makeInstanceClassName('tslib_fe');
 $TSFE = new $temp_TSFEclassName(
-               $TYPO3_CONF_VARS, 
-               t3lib_div::GPvar('id'), 
-               t3lib_div::GPvar('type'), 
-               t3lib_div::GPvar('no_cache'), 
-               t3lib_div::GPvar('cHash'), 
-               t3lib_div::GPvar('jumpurl'),
-               t3lib_div::GPvar('MP'),
-               t3lib_div::GPvar('RDCT')
+               $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->connectToMySQL();
 if ($TSFE->RDCT)       {$TSFE->sendRedirect();}
@@ -164,7 +172,7 @@ if ($HTTP_COOKIE_VARS['be_typo_user']) {            // If the backend cookie is set, we pr
                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;
@@ -172,9 +180,9 @@ if ($HTTP_COOKIE_VARS['be_typo_user']) {            // If the backend cookie is set, we pr
                $BE_USER->unpack_uc('');
                if ($BE_USER->user['uid'])      {
                        $BE_USER->fetchGroupData();
-                       $TSFE->beUserLogin=1; 
+                       $TSFE->beUserLogin = 1;
                }
-               if ($BE_USER->checkLockToIP())  {
+               if ($BE_USER->checkLockToIP() && $BE_USER->checkBackendAccessSettingsFromInitPhp())     {
                        $BE_USER->extInitFeAdmin();
                        if ($BE_USER->extAdmEnabled)    {
                                require_once(t3lib_extMgm::extPath('lang').'lang.php');
@@ -186,46 +194,46 @@ if ($HTTP_COOKIE_VARS['be_typo_user']) {          // If the backend cookie is set, we pr
                                $TSFE->forceTemplateParsing = $BE_USER->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
                                $TSFE->displayEditIcons = $BE_USER->extGetFeAdminValue('edit', 'displayIcons');
                                $TSFE->displayFieldEditIcons = $BE_USER->extGetFeAdminValue('edit', 'displayFieldIcons');
-       
-                               if (t3lib_div::GPvar('ADMCMD_editIcons'))       {
+
+                               if (t3lib_div::_GP('ADMCMD_editIcons')) {
                                        $TSFE->displayFieldEditIcons=1;
                                        $BE_USER->uc['TSFE_adminConfig']['edit_editNoPopup']=1;
                                }
-                               if (t3lib_div::GPvar('ADMCMD_simUser')) {
-                                       $BE_USER->uc['TSFE_adminConfig']['preview_simulateUserGroup']=intval(t3lib_div::GPvar('ADMCMD_simUser'));
+                               if (t3lib_div::_GP('ADMCMD_simUser'))   {
+                                       $BE_USER->uc['TSFE_adminConfig']['preview_simulateUserGroup']=intval(t3lib_div::_GP('ADMCMD_simUser'));
                                        $BE_USER->ext_forcePreview=1;
                                }
-                               if (t3lib_div::GPvar('ADMCMD_simTime')) {
-                                       $BE_USER->uc['TSFE_adminConfig']['preview_simulateDate']=intval(t3lib_div::GPvar('ADMCMD_simTime'));
+                               if (t3lib_div::_GP('ADMCMD_simTime'))   {
+                                       $BE_USER->uc['TSFE_adminConfig']['preview_simulateDate']=intval(t3lib_div::_GP('ADMCMD_simTime'));
                                        $BE_USER->ext_forcePreview=1;
                                }
-       
-                               if ($BE_USER->extAdmModuleEnabled('edit'))      {
+
+                                       // Include classes for editing IF editing module in Admin Panel is open (it is assumed that $TSFE->displayEditIcons is set only if the Edit module is open in the Admin Panel)
+                               if ($BE_USER->extAdmModuleEnabled('edit') && $BE_USER->extIsAdmMenuOpen('edit'))        {
+                                       $TSFE->includeTCA();
                                        if ($BE_USER->extIsEditAction())        {
-                                               $TSFE->includeTCA();
                                                require_once (PATH_t3lib.'class.t3lib_tcemain.php');
                                                $BE_USER->extEditAction();
                                        }
                                        if ($BE_USER->extIsFormShown()) {
-                                               $TSFE->includeTCA();
                                                require_once(PATH_t3lib.'class.t3lib_tceforms.php');
                                                require_once(PATH_t3lib.'class.t3lib_iconworks.php');
                                                require_once(PATH_t3lib.'class.t3lib_loaddbgroup.php');
                                                require_once(PATH_t3lib.'class.t3lib_transferdata.php');
                                        }
                                }
-       
-                               if ($TSFE->forceTemplateParsing || $TSFE->displayEditIcons || $TSFE->displayFieldEditIcons)     {$TSFE->set_no_cache();}
+
+                               if ($TSFE->forceTemplateParsing || $TSFE->displayEditIcons || $TSFE->displayFieldEditIcons)     { $TSFE->set_no_cache(); }
                        }
-       
+
        //              $WEBMOUNTS = (string)($BE_USER->groupData['webmounts'])!='' ? explode(',',$BE_USER->groupData['webmounts']) : Array();
        //              $FILEMOUNTS = $BE_USER->groupData['filemounts'];
                } else {        // Unset the user initialization.
                        $BE_USER='';
-                       $TSFE->beUserLogin=0; 
+                       $TSFE->beUserLogin=0;
                }
        $TT->pull();
-       $TYPO3_MISC['microtime_BE_USER_end'] = microtime();     
+       $TYPO3_MISC['microtime_BE_USER_end'] = microtime();
 }
 
 
@@ -239,16 +247,18 @@ $TT->push('Process ID','');
        $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 (is_object($BE_USER) && !$BE_USER->extPageReadAccess($TSFE->page))   {
+       if ($TSFE->beUserLogin && !$BE_USER->extPageReadAccess($TSFE->page))    {
+
                        // Remove user
-               $BE_USER='';
-               $TSFE->beUserLogin=0; 
+               unset($BE_USER);
+               $TSFE->beUserLogin = 0;
+
                        // Re-evaluate the page-id.
                $TSFE->checkAlternativeIdMethods();
                $TSFE->clear_preview();
                $TSFE->determineId();
        }
-       $TSFE->makeCacheHash(); // This was originally placed in the init- function. But moved to here because of the pEnc of simulateStaticDocuments. (200902)
+       $TSFE->makeCacheHash();
 $TT->pull();
 
 
@@ -283,13 +293,13 @@ $TSFE->getCompressedTCarray();
 
 
 // *******************************************
-// Setting the internal var, sys_language_uid 
+// Setting the internal var, sys_language_uid
 // *******************************************
 $TSFE->settingLanguage();
 
 
 // ********************************
-// Check Submission of data. 
+// Check Submission of data.
 // This is done at this point, because we need the config values
 // *******************************
 switch($TSFE->checkDataSubmission())   {
@@ -338,18 +348,18 @@ if ($TSFE->isGeneratePage())      {
                $TSFE->generatePage_postProcessing();
 } elseif ($TSFE->isINTincScript())     {
        require_once(PATH_tslib.'class.tslib_pagegen.php');
-       include(PATH_tslib.'pagegen.php');      
+       include(PATH_tslib.'pagegen.php');
 }
 $TT->pull();
 
 
 // ********************************
-// $GLOBALS['TSFE']->config['INTincScript'] 
+// $GLOBALS['TSFE']->config['INTincScript']
 // *******************************
 if ($TSFE->isINTincScript())           {
        $TT->push('Non-cached objects','');
                $INTiS_config = $GLOBALS['TSFE']->config['INTincScript'];
-                       
+
                        // Special feature: Include libraries
                $TT->push('Include libraries');
                reset($INTiS_config);
@@ -371,7 +381,7 @@ if ($TSFE->isINTincScript())                {
                $TT->pull();
                $TSFE->INTincScript();
        $TT->pull();
-}  
+}
 
 // ***************
 // Output content
@@ -423,7 +433,7 @@ if ($TSFE->isOutputting())  {
                                        echo ($c?'<!--EXT_SCRIPT.':'').$EXTiS_cPart;
                                }
                        }
-                       
+
                $TT->pull();
        } else {
                echo $GLOBALS['TSFE']->content;
@@ -487,10 +497,10 @@ echo $GLOBALS['TSFE']->beLoginLinkIPList();
 // *************
 // Admin panel
 // *************
-if (is_object($BE_USER) 
-       && $GLOBALS['TSFE']->beUserLogin 
-       && $GLOBALS['TSFE']->config['config']['admPanel'] 
-       && $BE_USER->extAdmEnabled 
+if (is_object($BE_USER)
+       && $GLOBALS['TSFE']->beUserLogin
+       && $GLOBALS['TSFE']->config['config']['admPanel']
+       && $BE_USER->extAdmEnabled
 //     && $BE_USER->extPageReadAccess($GLOBALS['TSFE']->page)  // This is already done, if there is a BE_USER object at this point!
        && !$BE_USER->extAdminConfig['hide'])   {
                echo $BE_USER->extPrintFeAdminDialog();
@@ -503,6 +513,7 @@ if (is_object($BE_USER)
 if(@is_callable(array($error,'debugOutput'))) {
        $error->debugOutput();
 }
+if (TYPO3_DLOG)        t3lib_div::devLog('END of FRONTEND session','',0,array('_FLUSH'=>TRUE));
 
 
 // *************
@@ -512,4 +523,4 @@ if ($TYPO3_CONF_VARS['FE']['compressionLevel'])     {
        new gzip_encode($TYPO3_CONF_VARS['FE']['compressionLevel'], false, $GLOBALS['TYPO3_CONF_VARS']['FE']['compressionDebugInfo']);
 }
 
-?>
\ No newline at end of file
+?>