Documentation TYPO3 par Ameos

class.tslib_fe.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00213  class tslib_fe {
00214 
00215                 // CURRENT PAGE:
00216         var $id='';                                                     // The page id (int)
00217         var $type='';                                           // RO The type (int)
00218         var $idParts=array();                           // Loaded with the id, exploded by ','
00219         var $cHash='';                                          // The submitted cHash
00220         var $no_cache='';                                       // Page will not be cached. Write only true. Never clear value (some other code might have reasons to set it true)
00221         var $rootLine='';                                       // The rootLine (all the way to tree root, not only the current site!) (array)
00222         var $page='';                                           // The pagerecord (array)
00223         var $contentPid=0;                                      // This will normally point to the same value as id, but can be changed to point to another page from which content will then be displayed instead.
00224         var $sys_page='';                                       // The object with pagefunctions (object)
00225         var $jumpurl='';
00226         var $pageNotFound=0;                            // Is set to 1 if a pageNotFound handler could have been called.
00227         var $domainStartPage=0;                         // Domain start page
00228         var $pageAccessFailureHistory=array();  // Array containing a history of why a requested page was not accessible.
00229         var $MP='';
00230         var $RDCT='';
00231         var $page_cache_reg1=0;                         // This can be set from applications as a way to tag cached versions of a page and later perform some external cache management, like clearing only a part of the cache of a page...
00232         var $siteScript='';                                     // Contains the value of the current script path that activated the frontend. Typically "index.php" but by rewrite rules it could be something else! Used for Speaking Urls / Simulate Static Documents.
00233 
00234                 // USER
00235         var $fe_user='';                                        // The user (object)
00236         var $loginUser='';                                      // Global flag indicating that a front-end user is logged in. This is set only if a user really IS logged in. The group-list may show other groups (like added by IP filter or so) even though there is no user.
00237         var $gr_list='';                                        // (RO=readonly) The group list, sorted numerically. Group '0,-1' is the default group, but other groups may be added by other means than a user being logged in though...
00238         var $beUserLogin='';                            // Flag that indicates if a Backend user is logged in!
00239         var $workspacePreview='';                       // Integer, that indicates which workspace is being previewed.
00240         var $loginAllowedInBranch = TRUE;       // Shows whether logins are allowed in branch
00241         var $ADMCMD_preview_BEUSER_uid = 0;     // Integer, set to backend user ID to initialize when keyword-based preview is used.
00242 
00243                 // PREVIEW
00244         var $fePreview='';                                      // Flag indication that preview is active. This is based on the login of a backend user and whether the backend user has read access to the current page. A value of 1 means ordinary preview, 2 means preview of a non-live workspace
00245         var $showHiddenPage='';                         // Flag indicating that hidden pages should be shown, selected and so on. This goes for almost all selection of pages!
00246         var $showHiddenRecords='';                      // Flag indicating that hidden records should be shown. This includes sys_template, pages_language_overlay and even fe_groups in addition to all other regular content. So in effect, this includes everything except pages.
00247         var $simUserGroup='0';                          // Value that contains the simulated usergroup if any
00248 
00249                 // CONFIGURATION
00250         var $TYPO3_CONF_VARS=array();           // The configuration array as set up in t3lib/config_default.php. Should be an EXACT copy of the global array.
00251         var $config='';                                         // 'CONFIG' object from TypoScript. Array generated based on the TypoScript configuration of the current page. Saved with the cached pages.
00252         var $TCAcachedExtras=array();           // Array of cached information from TCA. This is NOT TCA itself!
00253 
00254                 // TEMPLATE / CACHE
00255         var $tmpl='';                                           // The TypoScript template object. Used to parse the TypoScript template
00256         var $cacheTimeOutDefault='';            // Is set to the time-to-live time of cached pages. If false, default is 60*60*24, which is 24 hours.
00257         var $cacheContentFlag='';                       // Set internally if cached content is fetched from the database
00258         var $cacheExpires=0;                            // Set to the expire time of cached content
00259         var $isClientCachable=FALSE;            // Set if cache headers allowing caching are sent.
00260         var $all='';                                            // $all used by template fetching system. This array is an identification of the template. If $this->all is empty it's because the template-data is not cached, which it must be.
00261         var $sPre='';                                           // toplevel - objArrayName, eg 'page'
00262         var $pSetup='';                                         // TypoScript configuration of the page-object pointed to by sPre. $this->tmpl->setup[$this->sPre.'.']
00263         var $newHash='';                                        // This hash is unique to the template, the $this->id and $this->type vars and the gr_list (list of groups). Used to get and later store the cached data
00264         var $getMethodUrlIdToken='';            // If config.ftu (Frontend Track User) is set in TypoScript for the current page, the string value of this var is substituted in the rendered source-code with the string, '&ftu=[token...]' which enables GET-method usertracking as opposed to cookie based
00265         var $no_CacheBeforePageGen='';          // This flag is set before inclusion of pagegen.php IF no_cache is set. If this flag is set after the inclusion of pagegen.php, no_cache is forced to be set. This is done in order to make sure that php-code from pagegen does not falsely clear the no_cache flag.
00266         var $tempContent = FALSE;                       // This flag indicates if temporary content went into the cache during page-generation.
00267         var $forceTemplateParsing='';                           // Boolean, passed to TypoScript template class and tells it to render the template forcibly
00268         var $cHash_array=array();                       // The array which cHash_calc is based on, see ->makeCacheHash().
00269         var $hash_base='';                                      // Loaded with the serialized array that is used for generating a hashstring for the cache
00270         var $pagesTSconfig='';                          // May be set to the pagesTSconfig
00271                 // PAGE-GENERATION / cOBJ
00272         /*
00273                 Eg. insert JS-functions in this array ($additionalHeaderData) to include them once. Use associative keys.
00274                 Keys in use:
00275                         JSFormValidate  :               <script type="text/javascript" src="'.$GLOBALS["TSFE"]->absRefPrefix.'t3lib/jsfunc.validateform.js"></script>
00276                         JSincludeFormupdate :   <script type="text/javascript" src="t3lib/jsfunc.updateform.js"></script>
00277                         JSMenuCode, JSMenuCode_menu :                   JavaScript for the JavaScript menu
00278                         JSCode : reserved
00279                         JSImgCode : reserved
00280         */
00281         var $defaultBodyTag='<body>';           // Default bodytag, if nothing else is set. This can be overridden by applications like TemplaVoila.
00282         var $additionalHeaderData=array();      // used to accumulate additional HTML-code for the header-section, <head>...</head>. Insert either associative keys (like additionalHeaderData['myStyleSheet'], see reserved keys above) or num-keys (like additionalHeaderData[] = '...')
00283         var $additionalJavaScript=array();      // used to accumulate additional JavaScript-code. Works like additionalHeaderData. Reserved keys at 'openPic' and 'mouseOver'
00284         var $additionalCSS=array();                     // used to accumulate additional Style code. Works like additionalHeaderData.
00285         var $JSeventFuncCalls = array(          // you can add JavaScript functions to each entry in these arrays. Please see how this is done in the GMENU_LAYERS script. The point is that many applications on a page can set handlers for onload, onmouseover and onmouseup
00286                 'onmousemove' => array(),
00287                 'onmouseup' => array(),
00288                 'onload' => array(),
00289         );
00290         var $JSCode='';                                         // Deprecated, use additionalJavaScript instead.
00291         var $JSImgCode='';                                      // Used to accumulate JavaScript loaded images (by menus)
00292         var $divSection='';                                     // Used to accumulate DHTML-layers.
00293 
00294                 // RENDERING configuration, settings from TypoScript is loaded into these vars. See pagegen.php
00295         var $debug='';                                          // Debug flag, may output special debug html-code.
00296         var $intTarget='';                                      // Default internal target
00297         var $extTarget='';                                      // Default external target
00298         var $MP_defaults=array();                       // Keys are page ids and values are default &MP (mount point) values to set when using the linking features...)
00299         var $spamProtectEmailAddresses=0;       // If set, typolink() function encrypts email addresses. Is set in pagegen-class.
00300         var $absRefPrefix='';                           // Absolute Reference prefix
00301         var $absRefPrefix_force=0;                      // Absolute Reference prefix force flag. This is set, if the type and id is retrieve from PATH_INFO and thus we NEED to prefix urls with at least '/'
00302         var $compensateFieldWidth='';           // Factor for form-field widths compensation
00303         var $lockFilePath='';                           // Lock file path
00304         var $ATagParams='';                                     // <A>-tag parameters
00305         var $sWordRegEx='';                                     // Search word regex, calculated if there has been search-words send. This is used to mark up the found search words on a page when jumped to from a link in a search-result.
00306         var $sWordList='';                                      // Is set to the incoming array sword_list in case of a page-view jumped to from a search-result.
00307         var $linkVars='';                                       // A string prepared for insertion in all links on the page as url-parameters. Based on configuration in TypoScript where you defined which GET_VARS you would like to pass on.
00308         var $excludeCHashVars='';                       // A string set with a comma list of additional GET vars which should NOT be included in the cHash calculation. These vars should otherwise be detected and involved in caching, eg. through a condition in TypoScript.
00309         var $displayEditIcons='';                       // If set, edit icons are rendered aside content records. Must be set only if the ->beUserLogin flag is set and set_no_cache() must be called as well.
00310         var $displayFieldEditIcons='';          // If set, edit icons are rendered aside individual fields of content. Must be set only if the ->beUserLogin flag is set and set_no_cache() must be called as well.
00311         var $sys_language_uid=0;                        // Site language, 0 (zero) is default, int+ is uid pointing to a sys_language record. Should reflect which language menus, templates etc is displayed in (master language) - but not necessarily the content which could be falling back to default (see sys_language_content)
00312         var $sys_language_mode='';                      // Site language mode for content fall back.
00313         var $sys_language_content=0;            // Site content selection uid (can be different from sys_language_uid if content is to be selected from a fall-back language. Depends on sys_language_mode)
00314         var $sys_language_contentOL=0;          // Site content overlay flag; If set - and sys_language_content is > 0 - , records selected will try to look for a translation pointing to their uid. (If configured in [ctrl][languageField] / [ctrl][transOrigP...]
00315         var $sys_language_isocode = '';         // Is set to the iso code of the sys_language_content if that is properly defined by the sys_language record representing the sys_language_uid. (Requires the extension "static_info_tables")
00316 
00317                 // RENDERING data
00318         var $applicationData=Array();           //       'Global' Storage for various applications. Keys should be 'tx_'.extKey for extensions.
00319         var $register=Array();
00320         var $registerStack=Array();                     // Stack used for storing array and retrieving register arrays (see LOAD_REGISTER and CLEAR_REGISTER)
00321         var $cObjectDepthCounter = 50;          // Checking that the function is not called eternally. This is done by interrupting at a depth of 50
00322         var $recordRegister = Array();          // used by cObj->RECORDS and cObj->CONTENT to ensure the a records is NOT rendered twice through it!
00323         var $currentRecord = '';                        // This is set to the [table]:[uid] of the latest record rendered. Note that class tslib_cObj has an equal value, but that is pointing to the record delivered in the $data-array of the tslib_cObj instance, if the cObjects CONTENT or RECORD created that instance
00324         var $accessKey =array();                        // Used by class tslib_menu to keep track of access-keys.
00325         var $imagesOnPage=array();                      // Numerical array where image filenames are added if they are referenced in the rendered document. This includes only TYPO3 generated/inserted images.
00326         var $lastImageInfo=array();                     // Is set in tslib_cObj->cImage() function to the info-array of the most recent rendered image. The information is used in tslib_cObj->IMGTEXT
00327         var $uniqueCounter=0;                           // Used to generate page-unique keys. Point is that uniqid() functions is very slow, so a unikey key is made based on this, see function uniqueHash()
00328         var $uniqueString='';
00329         var $indexedDocTitle='';                        // This value will be used as the title for the page in the indexer (if indexing happens)
00330         var $altPageTitle='';                           // Alternative page title (normally the title of the page record). Can be set from applications you make.
00331         var $pEncAllowedParamNames=array();     // An array that holds parameter names (keys) of GET parameters which MAY be MD5/base64 encoded with simulate_static_documents method.
00332         var $baseUrl='';                                        // The Base url set for the page header.
00333         var $anchorPrefix='';                           // The proper anchor prefix needed when using speaking urls. (only set if baseUrl is set)
00334 
00335                 // Page content render object
00336         var $cObj ='';                                          // is instantiated object of tslib_cObj
00337 
00338                 // CONTENT accumulation
00339         var $content='';                                        // All page content is accumulated in this variable. See pagegen.php
00340 
00341                 // GENERAL
00342         var $clientInfo='';                                     // Set to the browser: net / msie if 4+ browsers
00343         var $scriptParseTime=0;
00344         var $TCAloaded = 0;                                     // Set ONLY if the full TCA is loaded
00345 
00346                 // Character set (charset) conversion object:
00347         var $csConvObj;                                         // An instance of the "t3lib_cs" class. May be used by any application.
00348         var $defaultCharSet = 'iso-8859-1';     // The default charset used in the frontend if nothing else is set.
00349         var $renderCharset='';                          // Internal charset of the frontend during rendering: Defaults to "forceCharset" and if that is not set, to ->defaultCharSet
00350         var $metaCharset='';                            // Output charset of the websites content. This is the charset found in the header, meta tag etc. If different from $renderCharset a conversion happens before output to browser. Defaults to ->renderCharset if not set.
00351         var $localeCharset='';                          // Assumed charset of locale strings.
00352 
00353                 // LANG:
00354         var $lang='';                                           // Set to the system language key (used on the site)
00355         var $langSplitIndex=0;                          // Set to the index number of the language key
00356         var $labelsCharset='';                          // Charset of the labels from locallang (based on $this->lang)
00357         var $convCharsetToFrom='';                      // Set to the charsets to convert from/to IF there are any difference. Otherwise this stays a string
00358         var $LL_labels_cache=array();
00359         var $LL_files_cache=array();
00360 
00361 
00362 
00363 
00364 
00382         function tslib_fe($TYPO3_CONF_VARS, $id, $type, $no_cache='', $cHash='', $jumpurl='',$MP='',$RDCT='')   {
00383 
00384                         // Setting some variables:
00385                 $this->TYPO3_CONF_VARS = $TYPO3_CONF_VARS;
00386                 $this->id = $id;
00387                 $this->type = $type;
00388                 $this->no_cache = $no_cache ? 1 : 0;
00389                 $this->cHash = $cHash;
00390                 $this->jumpurl = $jumpurl;
00391                 $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? (string)$MP : '';
00392                 $this->RDCT = $RDCT;
00393                 $this->clientInfo = t3lib_div::clientInfo();
00394                 $this->uniqueString=md5(microtime());
00395 
00396                 $this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
00397 
00398                         // Call post processing function for constructor:
00399                 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc']))    {
00400                         $_params = array('pObj' => &$this);
00401                         foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef)     {
00402                                 t3lib_div::callUserFunction($_funcRef,$_params,$this);
00403                         }
00404                 }
00405         }
00406 
00415         function connectToMySQL()       {
00416                 $this->connectToDB();
00417         }
00418 
00425         function connectToDB()  {
00426                 if ($GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))    {
00427                         if (!TYPO3_db)  {
00428                                 $this->printError('No database selected','Database Error');
00429                                         // Redirects to the Install Tool:
00430                                 echo '<script type="text/javascript">
00431                                                 /*<![CDATA[*/
00432                                         window.location.href = "'.TYPO3_mainDir.'install/index.php?mode=123&step=1&password=joh316";
00433                                                 /*]]>*/
00434                                         </script>';
00435                                 exit;
00436                         } elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db))       {
00437                                 $this->printError('Cannot connect to the current database, "'.TYPO3_db.'"','Database Error');
00438                                 exit;
00439                         }
00440                 } else {
00441                         if (!TYPO3_db)  {
00442                                         // Redirects to the Install Tool:
00443                                 echo '<script type="text/javascript">
00444                                                 /*<![CDATA[*/
00445                                         window.location.href = "'.TYPO3_mainDir.'install/index.php?mode=123&step=1&password=joh316";
00446                                                 /*]]>*/
00447                                         </script>';
00448                                 exit;
00449                         }
00450                         $this->printError('The current username, password or host was not accepted when the connection to the database was attempted to be established!','Database Error');
00451                         exit;
00452                 }
00453 
00454 
00455                         // Call post processing function for DB connection:
00456                 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB']))  {
00457                         $_params = array('pObj' => &$this);
00458                         foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'] as $_funcRef)   {
00459                                 t3lib_div::callUserFunction($_funcRef,$_params,$this);
00460                         }
00461                 }
00462         }
00463 
00470         function sendRedirect() {
00471                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->RDCT, 'cache_md5params'));
00472                 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00473                         $this->updateMD5paramsRecord($this->RDCT);
00474                         header('Location: '.$row['params']);
00475                         exit;
00476                 }
00477         }
00478 
00479 
00480 
00481 
00482 
00483 
00484 
00485 
00486 
00487 
00488 
00489 
00490 
00491 
00492 
00493 
00494 
00495 
00496         /********************************************
00497          *
00498          * Initializing, resolving page id
00499          *
00500          ********************************************/
00501 
00502 
00508         function initFEuser()   {
00509                 $this->fe_user = t3lib_div::makeInstance('tslib_feUserAuth');
00510 
00511                 $this->fe_user->lockIP = $this->TYPO3_CONF_VARS['FE']['lockIP'];
00512                 $this->fe_user->lockHashKeyWords = $this->TYPO3_CONF_VARS['FE']['lockHashKeyWords'];
00513                 $this->fe_user->checkPid = $this->TYPO3_CONF_VARS['FE']['checkFeUserPid'];
00514                 $this->fe_user->lifetime = intval($this->TYPO3_CONF_VARS['FE']['lifetime']);
00515                 $this->fe_user->checkPid_value = $GLOBALS['TYPO3_DB']->cleanIntList(t3lib_div::_GP('pid'));     // List of pid's acceptable
00516 
00517                         // Check if a session is transferred:
00518                 if (t3lib_div::_GP('FE_SESSION_KEY'))   {
00519                         $fe_sParts = explode('-',t3lib_div::_GP('FE_SESSION_KEY'));
00520                         if (!strcmp(md5($fe_sParts[0].'/'.$this->TYPO3_CONF_VARS['SYS']['encryptionKey']), $fe_sParts[1]))      {       // If the session key hash check is OK:
00521                                 $_COOKIE[$this->fe_user->name] = $fe_sParts[0];
00522                                 $this->fe_user->forceSetCookie = 1;
00523                         }
00524                 }
00525 
00526                 if ($this->TYPO3_CONF_VARS['FE']['dontSetCookie'])      {
00527                         $this->fe_user->dontSetCookie=1;
00528                 }
00529 
00530                 $this->fe_user->start();
00531                 $this->fe_user->unpack_uc('');
00532                 $this->fe_user->fetchSessionData();     // Gets session data
00533                 $recs = t3lib_div::_GP('recs');
00534                 if (is_array($recs))    {       // If any record registration is submitted, register the record.
00535                         $this->fe_user->record_registration($recs, $this->TYPO3_CONF_VARS['FE']['maxSessionDataSize']);
00536                 }
00537 
00538                         // Call hook for possible manipulation of frontend user object
00539                 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser']))   {
00540                         $_params = array('pObj' => &$this);
00541                         foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] as $_funcRef)    {
00542                                 t3lib_div::callUserFunction($_funcRef,$_params,$this);
00543                         }
00544                 }
00545 
00546                         // For every 60 seconds the is_online timestamp is updated.
00547                 if (is_array($this->fe_user->user) && $this->fe_user->user['uid'] && $this->fe_user->user['is_online']<($GLOBALS['EXEC_TIME']-60))      {
00548                         $GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid='.intval($this->fe_user->user['uid']), array('is_online' => $GLOBALS['EXEC_TIME']));
00549                 }
00550         }
00551 
00558         function initUserGroups() {
00559 
00560                 $this->fe_user->showHiddenRecords = $this->showHiddenRecords;           // This affects the hidden-flag selecting the fe_groups for the user!
00561                 $this->fe_user->fetchGroupData();       // no matter if we have an active user we try to fetch matching groups which can be set without an user (simulation for instance!)
00562 
00563                 if (is_array($this->fe_user->user) && count($this->fe_user->groupData['uid']))  {
00564                         $this->loginUser=1;     // global flag!
00565                         $this->gr_list = '0,-2';        // group -2 is not an existing group, but denotes a 'default' group when a user IS logged in. This is used to let elements be shown for all logged in users!
00566                         $gr_array = $this->fe_user->groupData['uid'];
00567                 } else {
00568                         $this->loginUser=0;
00569                         $this->gr_list = '0,-1';        // group -1 is not an existing group, but denotes a 'default' group when not logged in. This is used to let elements be hidden, when a user is logged in!
00570 
00571                         if ($this->loginAllowedInBranch)        {
00572                                 $gr_array = $this->fe_user->groupData['uid'];   // For cases where logins are not banned from a branch usergroups can be set based on IP masks so we should add the usergroups uids.
00573                         } else {
00574                                 $gr_array = array();            // Set to blank since we will NOT risk any groups being set when no logins are allowed!
00575                         }
00576                 }
00577 
00578                         // Clean up.
00579                 $gr_array = array_unique($gr_array);    // Make unique...
00580                 sort($gr_array);        // sort
00581                 if (count($gr_array))   {
00582                         $this->gr_list.=','.implode(',',$gr_array);
00583                 }
00584 
00585                 if ($this->fe_user->writeDevLog)        t3lib_div::devLog('Valid usergroups for TSFE: '.$this->gr_list, 'tslib_fe');
00586         }
00587 
00593         function isUserOrGroupSet()     {
00594                 return is_array($this->fe_user->user) || $this->gr_list!=='0,-1';
00595         }
00596 
00618         function checkAlternativeIdMethods()    {
00619 
00620                 $this->siteScript = t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT');
00621 
00622                         // Resolving of "simulateStaticDocuments" URLs:
00623                 if ($this->siteScript && substr($this->siteScript,0,9)!='index.php')    {               // If there has been a redirect (basically; we arrived here otherwise than via "index.php" in the URL) this can happend either due to a CGI-script or because of reWrite rule. Earlier we used $_SERVER['REDIRECT_URL'] to check but
00624                         $uParts = parse_url($this->siteScript); // Parse the path:
00625                         $fI = t3lib_div::split_fileref($uParts['path']);
00626 
00627                         if (!$fI['path'] && $fI['file'] && substr($fI['file'],-5)=='.html')     {
00628                                 $parts = explode('.',$fI['file']);
00629                                 $pCount = count($parts);
00630                                 if ($pCount>2)  {
00631                                         $this->type = intval($parts[$pCount-2]);
00632                                         $this->id = $parts[$pCount-3];
00633                                 } else {
00634                                         $this->type = 0;
00635                                         $this->id = $parts[0];
00636                                 }
00637                         }
00638                 }
00639 
00640                         // If PATH_INFO
00641                 if (t3lib_div::getIndpEnv('PATH_INFO')) {               // If pathinfo contains stuff...
00642                         $parts=t3lib_div::trimExplode('/',t3lib_div::getIndpEnv('PATH_INFO'),1);
00643                         $parts[]='html';
00644                         $pCount = count($parts);
00645                         if ($pCount>2)  {
00646                                 $this->type = intval($parts[$pCount-2]);
00647                                 $this->id = $parts[$pCount-3];
00648                         } else {
00649                                 $this->type = 0;
00650                                 $this->id = $parts[0];
00651                         }
00652                         $this->absRefPrefix_force=1;
00653                 }
00654 
00655                         // Call post processing function for custom URL methods.
00656                 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc']))   {
00657                         $_params = array('pObj' => &$this);
00658                         foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef)    {
00659                                 t3lib_div::callUserFunction($_funcRef,$_params,$this);
00660                         }
00661                 }
00662         }
00663 
00670         function clear_preview()        {
00671                 $this->showHiddenPage = 0;
00672                 $this->showHiddenRecords = 0;
00673                 $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME'];
00674                 $this->fePreview = 0;
00675         }
00676 
00683         function determineId()  {
00684 
00685                         // Getting ARG-v values if some
00686                 $this->setIDfromArgV();
00687 
00688                         // If there is a Backend login we are going to check for any preview settings:
00689                 $GLOBALS['TT']->push('beUserLogin','');
00690                 if ($this->beUserLogin || $this->doWorkspacePreview())  {
00691 
00692                                 // Backend user preview features:
00693                         if ($this->beUserLogin) {
00694                                 $this->fePreview = $GLOBALS['BE_USER']->extGetFeAdminValue('preview') ? 1 : 0;
00695 
00696                                         // If admin panel preview is enabled...
00697                                 if ($this->fePreview)   {
00698                                         $fe_user_OLD_USERGROUP = $this->fe_user->user['usergroup'];
00699 
00700                                         $this->showHiddenPage = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenPages');
00701                                         $this->showHiddenRecords = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenRecords');
00702                                                 // simulate date
00703                                         $simTime = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateDate');
00704                                         if ($simTime)   $GLOBALS['SIM_EXEC_TIME']=$simTime;
00705                                                 // simulate user
00706                                         $simUserGroup = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateUserGroup');
00707                                         $this->simUserGroup = $simUserGroup;
00708                                         if ($simUserGroup)      $this->fe_user->user['usergroup']=$simUserGroup;
00709                                         if (!$simUserGroup && !$simTime && !$this->showHiddenPage && !$this->showHiddenRecords) {
00710                                                 $this->fePreview=0;
00711                                         }
00712                                 }
00713                         }
00714 
00715                         if ($this->id)  {
00716 
00717                                         // Now it's investigated if the raw page-id points to a hidden page and if so, the flag is set.
00718                                         // This does not require the preview flag to be set in the admin panel
00719                                 $idQ = t3lib_div::testInt($this->id) ? 'uid='.intval($this->id) : 'alias='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->id, 'pages').' AND pid>=0';        // pid>=0 added for the sake of versioning...
00720                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('hidden', 'pages', $idQ.' AND hidden!=0 AND deleted=0');
00721                                 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
00722                                         $this->fePreview = 1;   // The preview flag is set only if the current page turns out to actually be hidden!
00723                                         $this->showHiddenPage = 1;
00724                                 }
00725 
00726                                         // For Live workspace: Check root line for proper connection to tree root (done because of possible preview of page / branch versions)
00727                                 if (!$this->fePreview && $this->whichWorkspace()===0)   {
00728 
00729                                                 // Initialize the page-select functions to check rootline:
00730                                         $temp_sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
00731                                         $temp_sys_page->init($this->showHiddenPage);
00732 
00733                                                 // If root line contained NO records and ->error_getRootLine_failPid tells us that it was because of a pid=-1 (indicating a "version" record)...:
00734                                         if (!count($temp_sys_page->getRootLine($this->id,$this->MP)) && $temp_sys_page->error_getRootLine_failPid==-1)  {
00735 
00736                                                         // Setting versioningPreview flag and try again:
00737                                                 $temp_sys_page->versioningPreview = TRUE;
00738                                                 if (count($temp_sys_page->getRootLine($this->id,$this->MP)))    {
00739                                                                 // Finally, we got a root line (meaning that it WAS due to versioning preview of a page somewhere) and we set the fePreview flag which in itself will allow sys_page class to display previews of versionized records.
00740                                                         $this->fePreview = 1;
00741                                                 }
00742                                         }
00743                                 }
00744                         }
00745 
00746                                 // The preview flag will be set if a backend user is in an offline workspace
00747                         if (($GLOBALS['BE_USER']->user['workspace_preview'] || t3lib_div::_GP('ADMCMD_view') || $this->doWorkspacePreview()) && ($this->whichWorkspace()===-1 || $this->whichWorkspace()>0))    {
00748                                 $this->fePreview = 2;   // Will show special preview message.
00749                         }
00750 
00751                                 // If the front-end is showing a preview, caching MUST be disabled.
00752                         if ($this->fePreview)   {
00753                                 $this->set_no_cache();
00754                         }
00755                 }
00756                 $GLOBALS['TT']->pull();
00757 
00758                         // Now, get the id, validate access etc:
00759                 $this->fetch_the_id();
00760 
00761                         // Check if backend user has read access to this page. If not, recalculate the id.
00762                 if ($this->beUserLogin && $this->fePreview)     {
00763                         if (!$GLOBALS['BE_USER']->doesUserHaveAccess($this->page,1))    {
00764 
00765                                         // Resetting
00766                                 $this->clear_preview();
00767                                 $this->fe_user->user['usergroup'] = $fe_user_OLD_USERGROUP;
00768 
00769                                         // Fetching the id again, now with the preview settings reset.
00770                                 $this->fetch_the_id();
00771                         }
00772                 }
00773 
00774                         // Checks if user logins are blocked for a certain branch and if so, will unset user login and re-fetch ID.
00775                 $this->loginAllowedInBranch = $this->checkIfLoginAllowedInBranch();
00776                 if (!$this->loginAllowedInBranch)       {       // Logins are not allowed:
00777                         if ($this->isUserOrGroupSet())  {       // Only if there is a login will we run this...
00778 
00779                                         // Clear out user and group:
00780                                 unset($this->fe_user->user);
00781                                 $this->gr_list = '0,-1';
00782 
00783                                         // Fetching the id again, now with the preview settings reset.
00784                                 $this->fetch_the_id();
00785                         }
00786                 }
00787 
00788                         // Final cleaning.
00789                 $this->id = $this->contentPid = intval($this->id);      // Make sure it's an integer
00790                 $this->type = intval($this->type);      // Make sure it's an integer
00791 
00792                         // Look for alternative content PID if page is under version preview:
00793                 if ($this->fePreview)   {
00794                         if ($this->page['_ORIG_pid']==-1 && $this->page['t3ver_swapmode']==0)   {       // Current page must have been an offline version and have swapmode set to 0:
00795                                         // Setting contentPid here for preview might not be completely correct to do. Strictly the "_ORIG_uid" value should be used for tables where "versioning_followPages" is set and for others not. However this is a working quick-fix to display content elements at least!
00796                                 $this->contentPid = $this->page['_ORIG_uid'];
00797                         }
00798                 }
00799 
00800                         // Call post processing function for id determination:
00801                 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) {
00802                         $_params = array('pObj' => &$this);
00803                         foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef)  {
00804                                 t3lib_div::callUserFunction($_funcRef,$_params,$this);
00805                         }
00806                 }
00807         }
00808 
00817         function fetch_the_id() {
00818                 $GLOBALS['TT']->push('fetch_the_id initialize/','');
00819 
00820                         // Initialize the page-select functions.
00821                 $this->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
00822                 $this->sys_page->versioningPreview = $this->fePreview ? TRUE : FALSE;
00823                 $this->sys_page->versioningWorkspaceId = $this->whichWorkspace();
00824                 $this->sys_page->init($this->showHiddenPage);
00825 
00826                         // Set the valid usergroups for FE
00827                 $this->initUserGroups();
00828 
00829                         // Sets sys_page where-clause
00830                 $this->setSysPageWhereClause();
00831 
00832                         // Splitting $this->id by a period (.). First part is 'id' and second part - if exists - will overrule the &type param if given
00833                 $pParts = explode('.',$this->id);
00834                 $this->id = $pParts[0]; // Set it.
00835                 if (isset($pParts[1]))  {$this->type=$pParts[1];}
00836 
00837                         // Splitting $this->id by a comma (,). First part is 'id' and other parts are just stored for use in scripts.
00838                 $this->idParts = explode(',',$this->id);
00839 
00840                         // Splitting by a '+' sign - used for base64/md5 methods of parameter encryption for simulate static documents.
00841                 list($pgID,$SSD_p)=explode('+',$this->idParts[0],2);
00842                 if ($SSD_p)     {       $this->idPartsAnalyze($SSD_p);  }
00843                 $this->id = $pgID;      // Set id
00844 
00845                         // If $this->id is a string, it's an alias
00846                 $this->checkAndSetAlias();
00847 
00848                         // The id and type is set to the integer-value - just to be sure...
00849                 $this->id = intval($this->id);
00850                 $this->type = intval($this->type);
00851                 $GLOBALS['TT']->pull();
00852 
00853                         // We find the first page belonging to the current domain
00854                 $GLOBALS['TT']->push('fetch_the_id domain/','');
00855                 $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']);       // the page_id of the current domain
00856                 if (!$this->id) {
00857                         if ($this->domainStartPage)     {
00858                                 $this->id = $this->domainStartPage;     // If the id was not previously set, set it to the id of the domain.
00859                         } else {
00860                                 $theFirstPage = $this->sys_page->getFirstWebPage($this->id);    // Find the first 'visible' page in that domain
00861                                 if ($theFirstPage)      {
00862                                         $this->id = $theFirstPage['uid'];
00863                                 } else {
00864                                         $this->printError('No pages are found on the rootlevel!');
00865                                         exit;
00866                                 }
00867                         }
00868                 }
00869                 $GLOBALS['TT']->pull();
00870 
00871                 $GLOBALS['TT']->push('fetch_the_id rootLine/','');
00872                 $requestedId = $this->id;               // We store the originally requested id
00873                 $this->getPageAndRootlineWithDomain($this->domainStartPage);
00874                 $GLOBALS['TT']->pull();
00875 
00876                 if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'])       {
00877                         $pNotFoundMsg = array(
00878                                 1 => 'ID was not an accessible page',
00879                                 2 => 'Subsection was found and not accessible',
00880                                 3 => 'ID was outside the domain',
00881                                 4 => 'The requested page alias does not exist'
00882                         );
00883                         $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]);
00884                 }
00885 
00886                         // set no_cache if set
00887                 if ($this->page['no_cache'])    {
00888                         $this->set_no_cache();
00889                 }
00890 
00891                         // Init SYS_LASTCHANGED
00892                 $this->register['SYS_LASTCHANGED'] = intval($this->page['tstamp']);
00893                 if ($this->register['SYS_LASTCHANGED'] < intval($this->page['SYS_LASTCHANGED']))        {
00894                         $this->register['SYS_LASTCHANGED'] = intval($this->page['SYS_LASTCHANGED']);
00895                 }
00896         }
00897 
00911         function getPageAndRootline() {
00912                 $this->page = $this->sys_page->getPage($this->id);
00913                 if (!count($this->page))        {
00914                                 // If no page, we try to find the page before in the rootLine.
00915                         $this->pageNotFound=1;                  // Page is 'not found' in case the id itself was not an accessible page. code 1
00916                         $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);
00917                         if (count($this->rootLine))     {
00918                                 $c=count($this->rootLine)-1;
00919                                 while($c>0)     {
00920 
00921                                                 // Add to page access failure history:
00922                                         $this->pageAccessFailureHistory['direct_access'][] = $this->rootLine[$c];
00923 
00924                                                 // Decrease to next page in rootline and check the access to that, if OK, set as page record and ID value.
00925                                         $c--;
00926                                         $this->id = $this->rootLine[$c]['uid'];
00927                                         $this->page = $this->sys_page->getPage($this->id);
00928                                         if (count($this->page)){ break; }
00929                                 }
00930                         }
00931                                 // If still no page...
00932                         if (!count($this->page))        {
00933                                 if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'])      {
00934                                         $this->pageNotFoundAndExit('The requested page does not exist!');
00935                                 } else {
00936                                         $this->printError('The requested page does not exist!');
00937                                         exit;
00938                                 }
00939                         }
00940                 }
00941 
00942                 // spacer is not accessible in frontend
00943                 if ($this->page['doktype'] == 199)      {
00944                         if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'])      {
00945                                 $this->pageNotFoundAndExit('The requested page does not exist!');
00946                         } else {
00947                                 $this->printError('The requested page does not exist!');
00948                                 exit;
00949                         }
00950                 }
00951 
00952                         // Is the ID a link to another page??
00953                 if ($this->page['doktype']==4)  {
00954                         $this->MP = '';         // We need to clear MP if the page is a shortcut. Reason is if the short cut goes to another page, then we LEAVE the rootline which the MP expects.
00955                         $this->page = $this->getPageShortcut($this->page['shortcut'],$this->page['shortcut_mode'],$this->page['uid']);
00956                         $this->id = $this->page['uid'];
00957                 }
00958 
00959                         // Gets the rootLine
00960                 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);
00961 
00962                         // If not rootline we're off...
00963                 if (!count($this->rootLine))    {
00964                         $this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')');
00965                         exit;
00966                 }
00967 
00968                         // Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!)
00969                 if ($this->checkRootlineForIncludeSection())    {
00970                         if (!count($this->rootLine))    {
00971                                 $this->printError('The requested page was not accessible!');
00972                                 exit;
00973                         } else {
00974                                 $el = reset($this->rootLine);
00975                                 $this->id = $el['uid'];
00976                                 $this->page = $this->sys_page->getPage($this->id);
00977                                 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);
00978                         }
00979                 }
00980         }
00981 
00994         function getPageShortcut($SC,$mode,$thisUid,$itera=20,$pageLog=array()) {
00995                 $idArray = t3lib_div::intExplode(',',$SC);
00996 
00997                         // Find $page record depending on shortcut mode:
00998                 switch($mode)   {
00999                         case 1:
01000                         case 2:
01001                                 $pageArray = $this->sys_page->getMenu($idArray[0]?$idArray[0]:$thisUid,'*','sorting','AND pages.doktype<199 AND pages.doktype!=6');
01002                                 $pO = 0;
01003                                 if ($mode==2 && count($pageArray))      {       // random
01004                                         $this->make_seed();
01005                                         $randval = intval(rand(0,count($pageArray)-1));
01006                                         $pO = $randval;
01007                                 }
01008                                 $c = 0;
01009                                 reset($pageArray);
01010                                 while(list(,$pV)=each($pageArray))      {
01011                                         if ($c==$pO)    {
01012                                                 $page = $pV;
01013                                                 break;
01014                                         }
01015                                         $c++;
01016                                 }
01017                         break;
01018                         default:
01019                                 $page = $this->sys_page->getPage($idArray[0]);
01020                         break;
01021                 }
01022 
01023                         // Check if short cut page was a shortcut itself, if so look up recursively:
01024                 if ($page['doktype']==4)        {
01025                         if (!in_array($page['uid'],$pageLog) && $itera>0)       {
01026                                 $pageLog[] = $page['uid'];
01027                                 $page = $this->getPageShortcut($page['shortcut'],$page['shortcut_mode'],$page['uid'],$itera-1,$pageLog);
01028                         } else {
01029                                 $pageLog[] = $page['uid'];
01030                                 $this->printError('Page shortcuts were looping in uids '.implode(',',$pageLog).'...!');
01031                                 exit;
01032                         }
01033                 }
01034                         // Return resulting page:
01035                 return $page;
01036         }
01037 
01044         function checkRootlineForIncludeSection()       {
01045                 $c=count($this->rootLine);
01046                 $removeTheRestFlag=0;
01047 
01048                 for ($a=0;$a<$c;$a++)   {
01049                         if (!$this->checkPagerecordForIncludeSection($this->rootLine[$a]))      {
01050                                         // Add to page access failure history:
01051                                 $this->pageAccessFailureHistory['sub_section'][] = $this->rootLine[$a];
01052                                 $removeTheRestFlag=1;
01053                         }
01054                         if ($this->rootLine[$a]['doktype']==6)  {
01055                                 if ($this->beUserLogin) {       // If there is a backend user logged in, check if he has read access to the page:
01056                                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($this->id).' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1));     // versionOL()?
01057                                         list($isPage) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
01058                                         if (!$isPage)   $removeTheRestFlag=1;   // If there was no page selected, the user apparently did not have read access to the current PAGE (not position in rootline) and we set the remove-flag...
01059                                 } else {        // Dont go here, if there is no backend user logged in.
01060                                         $removeTheRestFlag=1;
01061                                 }
01062                         }
01063                         if ($removeTheRestFlag) {
01064                                 $this->pageNotFound=2;                  // Page is 'not found' in case a subsection was found and not accessible, code 2
01065                                 unset($this->rootLine[$a]);
01066                         }
01067                 }
01068                 return $removeTheRestFlag;
01069         }
01070 
01081         function checkEnableFields($row,$bypassGroupCheck=FALSE)        {
01082                 if ((!$row['hidden'] || $this->showHiddenPage)
01083                         && $row['starttime']<=$GLOBALS['SIM_EXEC_TIME']
01084                         && ($row['endtime']==0 || $row['endtime']>$GLOBALS['SIM_EXEC_TIME'])
01085                         && ($bypassGroupCheck || $this->checkPageGroupAccess($row))
01086                 ) { return TRUE; }
01087         }
01088 
01097         function checkPageGroupAccess($row, $groupList=NULL) {
01098                 if(is_null($groupList)) {
01099                         $groupList = $this->gr_list;
01100                 }
01101                 if(!is_array($groupList)) {
01102                         $groupList = explode(',', $groupList);
01103                 }
01104                 $pageGroupList = explode(',', $row['fe_group'] ? $row['fe_group'] : 0);
01105                 return count(array_intersect($groupList, $pageGroupList)) > 0;
01106         }
01107 
01116         function checkPagerecordForIncludeSection($row) {
01117                 return (!$row['extendToSubpages'] || $this->checkEnableFields($row)) ? 1 : 0;
01118         }
01119 
01125         function checkIfLoginAllowedInBranch()  {
01126 
01127                         // Initialize:
01128                 $c = count($this->rootLine);
01129                 $disable = FALSE;
01130 
01131                         // Traverse root line from root and outwards:
01132                 for ($a=0; $a<$c; $a++) {
01133 
01134                                 // If a value is set for login state:
01135                         if ($this->rootLine[$a]['fe_login_mode'] > 0)   {
01136 
01137                                         // Determine state from value:
01138                                 $disable = (int)$this->rootLine[$a]['fe_login_mode'] === 1 ? TRUE : FALSE;
01139                         }
01140                 }
01141 
01142                 return !$disable;
01143         }
01144 
01150         function getPageAccessFailureReasons()  {
01151                 $output = array();
01152 
01153                 $combinedRecords = array_merge(
01154                         is_array($this->pageAccessFailureHistory['direct_access']) ? $this->pageAccessFailureHistory['direct_access'] : array(array('fe_group'=>0)),    // Adding fake first record for direct access if none, otherwise $k==0 below will be indicating a sub-section record to be first direct_access record which is of course false!
01155                         is_array($this->pageAccessFailureHistory['sub_section']) ? $this->pageAccessFailureHistory['sub_section'] : array()
01156                 );
01157 
01158                 if (count($combinedRecords))    {
01159                         foreach($combinedRecords as $k => $pagerec)     {
01160                                 // If $k=0 then it is the very first page the original ID was pointing at and that will get a full check of course
01161                                 // If $k>0 it is parent pages being tested. They are only significant for the access to the first page IF they had the extendToSubpages flag set, hence checked only then!
01162                                 if (!$k || $pagerec['extendToSubpages'])        {
01163                                         if ($pagerec['hidden']) $output['hidden'][$pagerec['uid']] = TRUE;
01164                                         if ($pagerec['starttime'] > $GLOBALS['SIM_EXEC_TIME'])  $output['starttime'][$pagerec['uid']] = $pagerec['starttime'];
01165                                         if ($pagerec['endtime']!=0 && $pagerec['endtime'] <= $GLOBALS['SIM_EXEC_TIME']) $output['endtime'][$pagerec['uid']] = $pagerec['endtime'];
01166                                         if (!$this->checkPageGroupAccess($pagerec))     $output['fe_group'][$pagerec['uid']] = $pagerec['fe_group'];
01167                                 }
01168                         }
01169                 }
01170 
01171                 return $output;
01172         }
01173 
01182         function setIDfromArgV()        {
01183                 if (!$this->id) {
01184                         list($theAlias) = explode('&',t3lib_div::getIndpEnv('QUERY_STRING'));
01185                         $theAlias = trim($theAlias);
01186                         $this->id = $theAlias ? $theAlias : 0;
01187                 }
01188         }
01189 
01198         function getPageAndRootlineWithDomain($domainStartPage) {
01199                 $this->getPageAndRootline();
01200 
01201                 // Checks if the $domain-startpage is in the rootLine. This is necessary so that references to page-id's from other domains are not possible.
01202                 if ($domainStartPage && is_array($this->rootLine)) {
01203                         reset ($this->rootLine);
01204                         $idFound = 0;
01205                         while(list($key,$val)=each($this->rootLine)) {
01206                                 if ($val['uid']==$domainStartPage)      {
01207                                         $idFound=1;
01208                                         break;
01209                                 }
01210                         }
01211                         if (!$idFound)  {
01212                                 $this->pageNotFound=3;                  // Page is 'not found' in case the id was outside the domain, code 3
01213                                 $this->id = $domainStartPage;
01214                                 $this->getPageAndRootline();            //re-get the page and rootline if the id was not found.
01215                         }
01216                 }
01217         }
01218 
01225         function setSysPageWhereClause()        {
01226                 $this->sys_page->where_hid_del.=' AND pages.doktype<200';
01227                 $this->sys_page->where_groupAccess = $this->sys_page->getMultipleGroupsWhereClause('pages.fe_group', 'pages');
01228         }
01229 
01237         function findDomainRecord($recursive=0) {
01238                 if ($recursive) {
01239                         $host = explode('.',t3lib_div::getIndpEnv('HTTP_HOST'));
01240                         while(count($host))     {
01241                                 $pageUid = $this->sys_page->getDomainStartPage(implode('.',$host),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI'));
01242                                 if ($pageUid)   return $pageUid; else array_shift($host);
01243                         }
01244                         return $pageUid;
01245                 } else {
01246                         return $this->sys_page->getDomainStartPage(t3lib_div::getIndpEnv('HTTP_HOST'),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI'));
01247                 }
01248         }
01249 
01257         function pageNotFoundAndExit($reason='', $header='')    {
01258                 $header = $header ? $header : $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'];
01259                 $this->pageNotFoundHandler($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'], $header, $reason);
01260                 exit;
01261         }
01262 
01272         function pageNotFoundHandler($code, $header='', $reason='')     {
01273                         // Issue header in any case:
01274                 if ($header)    {header($header);}
01275 
01276                         // Create response:
01277                 if (gettype($code)=='boolean' || !strcmp($code,1))