Fixed bug #14021: Simplify the code to get nested GET Parameters with TS
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / index_ts.php
index 11a5c32..0770b00 100644 (file)
@@ -46,17 +46,21 @@ if (version_compare(phpversion(), '5.2', '<'))      die ('TYPO3 requires PHP 5.2.0 or
 // *******************************
 // Set error reporting
 // *******************************
-error_reporting (E_ALL ^ E_NOTICE);
+if (defined('E_DEPRECATED')) {
+       error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
+} else {
+       error_reporting(E_ALL ^ E_NOTICE);
+}
 
 
 // ******************
 // Constants defined
 // ******************
-$TYPO3_MISC['microtime_start'] = microtime();
+$TYPO3_MISC['microtime_start'] = microtime(true);
 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_thisScript'))       define('PATH_thisScript',str_replace('//','/', str_replace('\\','/', (PHP_SAPI=='cgi'||PHP_SAPI=='isapi' ||PHP_SAPI=='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/');
 
@@ -75,6 +79,11 @@ if (!defined('PATH_tslib')) {
 if (!@is_dir(PATH_typo3conf))  die('Cannot find configuration. This file is probably executed from the wrong location.');
 
 // *********************
+// Unset variable(s) in global scope (fixes #13959)
+// *********************
+unset($error);
+
+// *********************
 // Prevent any output until AJAX/compression is initialized to stop
 // AJAX/compression data corruption
 // *********************
@@ -83,8 +92,14 @@ ob_start();
 // *********************
 // Timetracking started
 // *********************
-require_once(PATH_t3lib.'class.t3lib_timetrack.php');
-$TT = new t3lib_timeTrack;
+if ($_COOKIE['be_typo_user']) {
+       require_once(PATH_t3lib.'class.t3lib_timetrack.php');
+       $TT = new t3lib_timeTrack;
+} else {
+       require_once(PATH_t3lib.'class.t3lib_timetracknull.php');
+       $TT = new t3lib_timeTrackNull;
+}
+
 $TT->start();
 $TT->push('','Script start');
 
@@ -112,14 +127,22 @@ if (!defined('PATH_tslib')) {
 }
 
 
+
+
 // *********************
-// Autoloader
+// Error & Exception handling
 // *********************
-$TT->push('Register Autoloader', '');
-       require_once(PATH_t3lib . 'class.t3lib_autoloader.php');
-       t3lib_autoloader::registerAutoloader();
-$TT->pull();
-
+if ($TYPO3_CONF_VARS['SC_OPTIONS']['errors']['exceptionHandler'] !== '') {
+       $TT->push('Register Exceptionhandler', '');
+       if ($TYPO3_CONF_VARS['SYS']['errorHandler'] !== '') {
+                       // register an error handler for the given errorHandlerErrors
+               $errorHandler = t3lib_div::makeInstance($TYPO3_CONF_VARS['SYS']['errorHandler'], $TYPO3_CONF_VARS['SYS']['errorHandlerErrors']);
+                       // set errors which will be converted in an exception
+               $errorHandler->setExceptionalErrors($TYPO3_CONF_VARS['SC_OPTIONS']['errors']['exceptionalErrors']);
+       }
+       $exceptionHandler = t3lib_div::makeInstance($TYPO3_CONF_VARS['SC_OPTIONS']['errors']['exceptionHandler']);
+       $TT->pull();
+}
 
 $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
 $TYPO3_DB->debugOutput = $TYPO3_CONF_VARS['SYS']['sqlDebug'];
@@ -161,23 +184,11 @@ if ($temp_extId = t3lib_div::_GP('eID'))  {
                // Remove any output produced until now
                ob_clean();
 
-               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)
@@ -231,7 +242,6 @@ if ($TYPO3_CONF_VARS['FE']['compressionLevel'] && extension_loaded('zlib')) {
                // Prevent errors if ini_set() is unavailable (safe mode)
                @ini_set('zlib.output_compression_level', $TYPO3_CONF_VARS['FE']['compressionLevel']);
        }
-       require_once(PATH_tslib . 'class.tslib_fecompression.php');
        ob_start(array(t3lib_div::makeInstance('tslib_fecompression'), 'compressionOutputHandler'));
 }
 
@@ -257,14 +267,10 @@ if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preBeUser']))
 // *********
 // BE_USER
 // *********
-$BE_USER='';
+$BE_USER = NULL;
 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();
+       $TYPO3_MISC['microtime_BE_USER_start'] = microtime(true);
        $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
@@ -278,16 +284,12 @@ if ($_COOKIE['be_typo_user']) {           // If the backend cookie is set, we proceed and
                }
                        // Unset the user initialization.
                if (!$BE_USER->checkLockToIP() || !$BE_USER->checkBackendAccessSettingsFromInitPhp() || !$BE_USER->user['uid']) {
-                       $BE_USER='';
+                       $BE_USER = NULL;
                        $TSFE->beUserLogin=0;
                }
        $TT->pull();
-       $TYPO3_MISC['microtime_BE_USER_end'] = microtime();
+       $TYPO3_MISC['microtime_BE_USER_end'] = microtime(true);
 } 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
@@ -299,7 +301,7 @@ if ($_COOKIE['be_typo_user']) {             // If the backend cookie is set, we proceed and
                $BE_USER->fetchGroupData();
                $TSFE->beUserLogin = 1;
        } else {
-               $BE_USER = '';
+               $BE_USER = NULL;
                $TSFE->beUserLogin = 0;
        }
 }
@@ -315,6 +317,11 @@ $TSFE->workspacePreviewInit();
 // After this point we have an array, $page in TSFE, which is the page-record of the current page, $id
 // *****************************************
 $TT->push('Process ID','');
+               // Initialize admin panel since simulation settings are required here:
+       if ($TSFE->beUserLogin) {
+               $BE_USER->initializeAdminPanel();
+       }
+
        $TSFE->checkAlternativeIdMethods();
        $TSFE->clear_preview();
        $TSFE->determineId();
@@ -338,7 +345,6 @@ $TT->pull();
 // Admin Panel & Frontend editing
 // *****************************************
 if ($TSFE->beUserLogin) {
-       $BE_USER->initializeAdminPanel();
        $BE_USER->initializeFrontendEdit();
        if ($BE_USER->adminPanel instanceof tslib_AdminPanel) {
                $LANG = t3lib_div::makeInstance('language');
@@ -406,12 +412,9 @@ $TSFE->checkJumpUrlReferer();
 // *******************************
 switch($TSFE->checkDataSubmission())   {
        case 'email':
-               require_once(PATH_t3lib.'class.t3lib_htmlmail.php');
-               require_once(PATH_t3lib.'class.t3lib_formmail.php');
                $TSFE->sendFormmail();
        break;
        case 'fe_tce':
-               require_once(PATH_tslib.'class.tslib_fetce.php');
                $TSFE->includeTCA();
                $TT->push('fe_tce','');
                $TSFE->fe_tce();
@@ -426,9 +429,6 @@ switch($TSFE->checkDataSubmission())        {
 $TSFE->setUrlIdToken();
 
 $TT->push('Page generation','');
-       if ($TSFE->doXHTML_cleaning()) {
-               require_once(PATH_t3lib.'class.t3lib_parsehtml.php');
-       }
        if ($TSFE->isGeneratePage()) {
                $TSFE->generatePage_preProcessing();
                $temp_theScript=$TSFE->generatePage_whichScript();
@@ -436,12 +436,10 @@ $TT->push('Page generation','');
                if ($temp_theScript) {
                        include($temp_theScript);
                } else {
-                       require_once(PATH_tslib.'class.tslib_pagegen.php');
                        include(PATH_tslib.'pagegen.php');
                }
                $TSFE->generatePage_postProcessing();
        } elseif ($TSFE->isINTincScript()) {
-               require_once(PATH_tslib.'class.tslib_pagegen.php');
                include(PATH_tslib.'pagegen.php');
        }
 $TT->pull();
@@ -515,7 +513,7 @@ $TSFE->storeSessionData();
 // ***********
 // Statistics
 // ***********
-$TYPO3_MISC['microtime_end'] = microtime();
+$TYPO3_MISC['microtime_end'] = microtime(true);
 $TSFE->setParseTime();
 if ($TSFE->isOutputting() && ($TSFE->TYPO3_CONF_VARS['FE']['debug'] || $TSFE->config['config']['debug']))      {
        echo '
@@ -539,7 +537,7 @@ $TSFE->previewInfo();
 // ******************
 // Publishing static
 // ******************
-if (is_object($BE_USER) && ($BE_USER->adminPabel instanceof tslib_AdminPanel)) {
+if (is_object($BE_USER) && ($BE_USER->adminPanel instanceof tslib_AdminPanel)) {
        if ($BE_USER->adminPanel->isAdminModuleEnabled('publish') && $BE_USER->adminPanel->getExtPublishList()) {
                include_once(PATH_tslib.'publish.php');
        }
@@ -567,14 +565,14 @@ echo $TSFE->beLoginLinkIPList();
 // *************
 // Admin panel
 // *************
-if (is_object($BE_USER) && $TSFE->beUserLogin) {
+if (is_object($BE_USER) && $BE_USER->isAdminPanelVisible() && $TSFE->beUserLogin) {
        echo $BE_USER->displayAdminPanel();
 }
 
 // *************
 // Debugging Output
 // *************
-if(@is_callable(array($error,'debugOutput'))) {
+if(is_object($error) && @is_callable(array($error,'debugOutput'))) {
        $error->debugOutput();
 }
 if (TYPO3_DLOG) {