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 fc23f00..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'];
@@ -244,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
@@ -265,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
@@ -286,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;
        }
 }
@@ -498,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 '
@@ -522,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');
        }
@@ -550,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) {