2 /***************************************************************
5 * (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Class for the built TypoScript based Front End
30 * This class has a lot of functions and internal variable which are use from index_ts.php.
31 * The class is instantiated as $GLOBALS['TSFE'] in index_ts.php.
32 * The use of this class should be inspired by the order of function calls as found in index_ts.php.
35 * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
38 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
41 * [CLASS/FUNCTION INDEX of SCRIPT]
46 * 382: function tslib_fe($TYPO3_CONF_VARS, $id, $type, $no_cache='', $cHash='', $jumpurl='',$MP='',$RDCT='')
47 * 415: function connectToMySQL()
48 * 425: function connectToDB()
49 * 470: function sendRedirect()
51 * SECTION: Initializing, resolving page id
52 * 508: function initFEuser()
53 * 558: function initUserGroups()
54 * 593: function isUserOrGroupSet()
55 * 618: function checkAlternativeIdMethods()
56 * 670: function clear_preview()
57 * 683: function determineId()
58 * 817: function fetch_the_id()
59 * 911: function getPageAndRootline()
60 * 994: function getPageShortcut($SC,$mode,$thisUid,$itera=20,$pageLog=array())
61 * 1044: function checkRootlineForIncludeSection()
62 * 1081: function checkEnableFields($row,$bypassGroupCheck=FALSE)
63 * 1097: function checkPageGroupAccess($row, $groupList=NULL)
64 * 1116: function checkPagerecordForIncludeSection($row)
65 * 1125: function checkIfLoginAllowedInBranch()
66 * 1150: function getPageAccessFailureReasons()
67 * 1182: function setIDfromArgV()
68 * 1198: function getPageAndRootlineWithDomain($domainStartPage)
69 * 1225: function setSysPageWhereClause()
70 * 1237: function findDomainRecord($recursive=0)
71 * 1257: function pageNotFoundAndExit($reason='', $header='')
72 * 1272: function pageNotFoundHandler($code, $header='', $reason='')
73 * 1316: function checkAndSetAlias()
74 * 1335: function idPartsAnalyze($str)
75 * 1360: function mergingWithGetVars($GET_VARS)
76 * 1390: function ADMCMD_preview()
77 * 1433: function ADMCMD_preview_postInit($previewConfig)
79 * SECTION: Template and caching related functions.
80 * 1465: function makeCacheHash()
81 * 1489: function reqCHash()
82 * 1511: function cHashParams($addQueryParams)
83 * 1520: function initTemplate()
84 * 1532: function getFromCache()
85 * 1578: function getFromCache_queryRow()
86 * 1608: function headerNoCache()
87 * 1637: function getHash()
88 * 1657: function getConfigArray()
90 * SECTION: Further initialization and data processing
91 * 1818: function getCompressedTCarray()
92 * 1872: function includeTCA($TCAloaded=1)
93 * 1899: function settingLanguage()
94 * 1992: function settingLocale()
95 * 2017: function checkDataSubmission()
96 * 2050: function fe_tce()
97 * 2064: function locDataCheck($locationData)
98 * 2080: function sendFormmail()
99 * 2131: function extractRecipientCopy($bodytext)
100 * 2145: function setExternalJumpUrl()
101 * 2156: function checkJumpUrlReferer()
102 * 2171: function jumpUrl()
103 * 2215: function setUrlIdToken()
105 * SECTION: Page generation; cache handling
106 * 2258: function isGeneratePage()
107 * 2268: function tempPageCacheContent()
108 * 2325: function realPageCacheContent()
109 * 2355: function setPageCacheContent($content,$data,$tstamp)
110 * 2382: function clearPageCacheContent()
111 * 2392: function clearPageCacheContent_pidList($pidList)
112 * 2403: function pageCachePostProcess(&$row,$type)
113 * 2426: function setSysLastChanged()
115 * SECTION: Page generation; rendering and inclusion
116 * 2462: function generatePage_preProcessing()
117 * 2484: function generatePage_whichScript()
118 * 2496: function generatePage_postProcessing()
119 * 2588: function INTincScript()
120 * 2648: function INTincScript_loadJSCode()
121 * 2689: function isINTincScript()
122 * 2698: function doXHTML_cleaning()
123 * 2707: function doLocalAnchorFix()
125 * SECTION: Finished off; outputting, storing session data, statistics...
126 * 2738: function isOutputting()
127 * 2761: function processOutput()
128 * 2834: function sendCacheHeaders()
129 * 2902: function isStaticCacheble()
130 * 2915: function contentStrReplace()
131 * 2941: function isEXTincScript()
132 * 2950: function storeSessionData()
133 * 2960: function setParseTime()
134 * 2972: function statistics()
135 * 3066: function previewInfo()
136 * 3101: function hook_eofe()
137 * 3117: function beLoginLinkIPList()
138 * 3138: function addTempContentHttpHeaders()
140 * SECTION: Various internal API functions
141 * 3184: function makeSimulFileName($inTitle,$page,$type,$addParams='',$no_cache='')
142 * 3231: function simulateStaticDocuments_pEnc_onlyP_proc($linkVars)
143 * 3260: function getSimulFileName()
144 * 3271: function setSimulReplacementChar()
145 * 3291: function fileNameASCIIPrefix($inTitle,$titleChars,$mergeChar='.')
146 * 3314: function encryptEmail($string,$back=0)
147 * 3340: function codeString($string, $decode=FALSE)
148 * 3366: function roundTripCryptString($string)
149 * 3386: function checkFileInclude($incFile)
150 * 3401: function newCObj()
151 * 3414: function setAbsRefPrefix()
152 * 3428: function baseUrlWrap($url)
153 * 3447: function printError($label,$header='Error!')
154 * 3458: function updateMD5paramsRecord($hash)
155 * 3469: function tidyHTML($content)
156 * 3495: function prefixLocalAnchorsWithScript()
157 * 3505: function workspacePreviewInit()
158 * 3521: function doWorkspacePreview()
159 * 3531: function whichWorkspace($returnTitle = FALSE)
161 * SECTION: Various external API functions - for use in plugins etc.
162 * 3589: function getStorageSiterootPids()
163 * 3604: function getPagesTSconfig()
164 * 3637: function setJS($key,$content='')
165 * 3677: function setCSS($key,$content)
166 * 3692: function make_seed()
167 * 3705: function uniqueHash($str='')
168 * 3714: function set_no_cache()
169 * 3724: function set_cache_timeout_default($seconds)
170 * 3740: function plainMailEncoded($email,$subject,$message,$headers='')
172 * SECTION: Localization and character set conversion
173 * 3784: function sL($input)
174 * 3813: function readLLfile($fileRef)
175 * 3824: function getLLL($index,$LOCAL_LANG)
176 * 3838: function initLLvars()
177 * 3872: function csConv($str,$from='')
178 * 3890: function convOutputCharset($content,$label='')
179 * 3903: function convPOSTCharset()
181 * TOTAL FUNCTIONS: 116
182 * (This index is automatically created/updated by the extension "extdeveval")
186 require_once (PATH_t3lib
.'class.t3lib_lock.php');
208 * Main frontend class, instantiated in the index_ts.php script as the global object TSFE
210 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
217 var $id=''; // The page id (int)
218 var $type=''; // RO The type (int)
219 var $idParts=array(); // Loaded with the id, exploded by ','
220 var $cHash=''; // The submitted cHash
221 var $no_cache=''; // Page will not be cached. Write only true. Never clear value (some other code might have reasons to set it true)
222 var $rootLine=''; // The rootLine (all the way to tree root, not only the current site!) (array)
223 var $page=''; // The pagerecord (array)
224 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.
227 * sys_page-object, pagefunctions
229 * @var t3lib_pageSelect
233 var $pageNotFound=0; // Is set to 1 if a pageNotFound handler could have been called.
234 var $domainStartPage=0; // Domain start page
235 var $pageAccessFailureHistory=array(); // Array containing a history of why a requested page was not accessible.
238 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...
239 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.
246 * @var tslib_feUserAuth
249 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.
250 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...
251 var $beUserLogin=''; // Flag that indicates if a Backend user is logged in!
252 var $workspacePreview=''; // Integer, that indicates which workspace is being previewed.
253 var $loginAllowedInBranch = TRUE; // Shows whether logins are allowed in branch
254 var $ADMCMD_preview_BEUSER_uid = 0; // Integer, set to backend user ID to initialize when keyword-based preview is used.
257 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
258 var $showHiddenPage=''; // Flag indicating that hidden pages should be shown, selected and so on. This goes for almost all selection of pages!
259 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.
260 var $simUserGroup='0'; // Value that contains the simulated usergroup if any
263 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.
264 var $config=''; // 'CONFIG' object from TypoScript. Array generated based on the TypoScript configuration of the current page. Saved with the cached pages.
265 var $TCAcachedExtras=array(); // Array of cached information from TCA. This is NOT TCA itself!
270 * The TypoScript template object. Used to parse the TypoScript template
272 * @var t3lib_TStemplate
275 var $cacheTimeOutDefault=''; // Is set to the time-to-live time of cached pages. If false, default is 60*60*24, which is 24 hours.
276 var $cacheContentFlag = 0; // Set internally if cached content is fetched from the database
277 var $cacheExpires=0; // Set to the expire time of cached content
278 var $isClientCachable=FALSE; // Set if cache headers allowing caching are sent.
279 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.
280 var $sPre=''; // toplevel - objArrayName, eg 'page'
281 var $pSetup=''; // TypoScript configuration of the page-object pointed to by sPre. $this->tmpl->setup[$this->sPre.'.']
282 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
283 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
284 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.
285 var $tempContent = FALSE; // This flag indicates if temporary content went into the cache during page-generation.
286 var $forceTemplateParsing=''; // Boolean, passed to TypoScript template class and tells it to render the template forcibly
287 var $cHash_array=array(); // The array which cHash_calc is based on, see ->makeCacheHash().
288 var $hash_base=''; // Loaded with the serialized array that is used for generating a hashstring for the cache
289 var $pagesTSconfig=''; // May be set to the pagesTSconfig
290 // PAGE-GENERATION / cOBJ
292 Eg. insert JS-functions in this array ($additionalHeaderData) to include them once. Use associative keys.
294 JSFormValidate : <script type="text/javascript" src="'.$GLOBALS["TSFE"]->absRefPrefix.'t3lib/jsfunc.validateform.js"></script>
295 JSincludeFormupdate : <script type="text/javascript" src="t3lib/jsfunc.updateform.js"></script>
296 JSMenuCode, JSMenuCode_menu : JavaScript for the JavaScript menu
300 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[] = '...')
301 var $additionalJavaScript=array(); // used to accumulate additional JavaScript-code. Works like additionalHeaderData. Reserved keys at 'openPic' and 'mouseOver'
302 var $additionalCSS=array(); // used to accumulate additional Style code. Works like additionalHeaderData.
303 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
304 'onmousemove' => array(),
305 'onmouseup' => array(),
306 'onmousemove' => array(),
307 'onkeydown' => array(),
308 'onkeyup' => array(),
309 'onkeypress' => array(),
311 'onunload' => array(),
313 var $JSCode=''; // Deprecated, use additionalJavaScript instead.
314 var $JSImgCode=''; // Used to accumulate JavaScript loaded images (by menus)
315 var $divSection=''; // Used to accumulate DHTML-layers.
316 var $defaultBodyTag='<body>'; // Default bodytag, if nothing else is set. This can be overridden by applications like TemplaVoila.
318 // RENDERING configuration, settings from TypoScript is loaded into these vars. See pagegen.php
319 var $debug=''; // Debug flag, may output special debug html-code.
320 var $intTarget=''; // Default internal target
321 var $extTarget=''; // Default external target
322 var $MP_defaults=array(); // Keys are page ids and values are default &MP (mount point) values to set when using the linking features...)
323 var $spamProtectEmailAddresses=0; // If set, typolink() function encrypts email addresses. Is set in pagegen-class.
324 var $absRefPrefix=''; // Absolute Reference prefix
325 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 '/'
326 var $compensateFieldWidth=''; // Factor for form-field widths compensation
327 var $lockFilePath=''; // Lock file path
328 var $ATagParams=''; // <A>-tag parameters
329 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.
330 var $sWordList=''; // Is set to the incoming array sword_list in case of a page-view jumped to from a search-result.
331 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.
332 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.
333 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.
334 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.
335 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)
336 var $sys_language_mode=''; // Site language mode for content fall back.
337 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)
338 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...]
339 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")
342 var $applicationData=Array(); // 'Global' Storage for various applications. Keys should be 'tx_'.extKey for extensions.
343 var $register=Array();
344 var $registerStack=Array(); // Stack used for storing array and retrieving register arrays (see LOAD_REGISTER and CLEAR_REGISTER)
345 var $cObjectDepthCounter = 50; // Checking that the function is not called eternally. This is done by interrupting at a depth of 50
346 var $recordRegister = Array(); // used by cObj->RECORDS and cObj->CONTENT to ensure the a records is NOT rendered twice through it!
347 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
348 var $accessKey =array(); // Used by class tslib_menu to keep track of access-keys.
349 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.
350 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
351 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()
352 var $uniqueString='';
353 var $indexedDocTitle=''; // This value will be used as the title for the page in the indexer (if indexing happens)
354 var $altPageTitle=''; // Alternative page title (normally the title of the page record). Can be set from applications you make.
355 var $pEncAllowedParamNames=array(); // An array that holds parameter names (keys) of GET parameters which MAY be MD5/base64 encoded with simulate_static_documents method.
356 var $baseUrl=''; // The base URL set for the page header.
357 var $anchorPrefix=''; // The proper anchor prefix needed when using speaking urls. (only set if baseUrl is set)
360 * Page content render object
366 // CONTENT accumulation
367 var $content=''; // All page content is accumulated in this variable. See pagegen.php
370 var $clientInfo=''; // Set to the browser: net / msie if 4+ browsers
371 var $scriptParseTime=0;
372 var $TCAloaded = 0; // Set ONLY if the full TCA is loaded
374 // Character set (charset) conversion object:
377 * charset conversion class. May be used by any application.
382 var $defaultCharSet = 'iso-8859-1'; // The default charset used in the frontend if nothing else is set.
383 var $renderCharset=''; // Internal charset of the frontend during rendering: Defaults to "forceCharset" and if that is not set, to ->defaultCharSet
384 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.
385 var $localeCharset=''; // Assumed charset of locale strings.
388 var $lang=''; // Set to the system language key (used on the site)
389 var $langSplitIndex=0; // Set to the index number of the language key
390 var $LL_labels_cache=array();
391 var $LL_files_cache=array();
398 var $pagesection_lockObj; // Locking object for accessing "cache_pagesection"
405 var $pages_lockObj; // Locking object for accessing "cache_pages"
413 * Takes a number of GET/POST input variable as arguments and stores them internally.
414 * The processing of these variables goes on later in this class.
415 * Also sets internal clientInfo array (browser information) and a unique string (->uniqueString) for this script instance; A md5 hash of the microtime()
417 * @param array The global $TYPO3_CONF_VARS array. Will be set internally in ->TYPO3_CONF_VARS
418 * @param mixed The value of t3lib_div::_GP('id')
419 * @param integer The value of t3lib_div::_GP('type')
420 * @param boolean The value of t3lib_div::_GP('no_cache'), evaluated to 1/0
421 * @param string The value of t3lib_div::_GP('cHash')
422 * @param string The value of t3lib_div::_GP('jumpurl')
423 * @param string The value of t3lib_div::_GP('MP')
424 * @param string The value of t3lib_div::_GP('RDCT')
428 function tslib_fe($TYPO3_CONF_VARS, $id, $type, $no_cache='', $cHash='', $jumpurl='',$MP='',$RDCT='') {
430 // Setting some variables:
431 $this->TYPO3_CONF_VARS
= $TYPO3_CONF_VARS;
434 $this->no_cache
= $no_cache ?
1 : 0;
435 $this->cHash
= $cHash;
436 $this->jumpurl
= $jumpurl;
437 $this->MP
= $this->TYPO3_CONF_VARS
['FE']['enable_mount_pids'] ?
(string)$MP : '';
439 $this->clientInfo
= t3lib_div
::clientInfo();
440 $this->uniqueString
=md5(microtime());
442 $this->csConvObj
= t3lib_div
::makeInstance('t3lib_cs');
444 // Call post processing function for constructor:
445 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'])) {
446 $_params = array('pObj' => &$this);
447 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef) {
448 t3lib_div
::callUserFunction($_funcRef,$_params,$this);
454 * Connect to MySQL database
455 * May exit after outputting an error message or some JavaScript redirecting to the install tool.
456 * Use connectToDB() instead!
461 function connectToMySQL() {
462 $this->connectToDB();
466 * Connect to SQL database
467 * May exit after outputting an error message or some JavaScript redirecting to the install tool.
471 function connectToDB() {
472 if ($GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host
, TYPO3_db_username
, TYPO3_db_password
)) {
474 $this->printError('No database selected','Database Error');
475 // Redirects to the Install Tool:
476 echo '<script type="text/javascript">
478 window.location.href = "'.TYPO3_mainDir
.'install/index.php?mode=123&step=1&password=joh316";
482 } elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db
)) {
483 header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
484 $this->printError('Cannot connect to the current database, "'.TYPO3_db
.'"','Database Error');
489 // Redirects to the Install Tool:
490 echo '<script type="text/javascript">
492 window.location.href = "'.TYPO3_mainDir
.'install/index.php?mode=123&step=1&password=joh316";
497 header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
498 $this->printError('The current username, password or host was not accepted when the connection to the database was attempted to be established!','Database Error');
503 // Call post processing function for DB connection:
504 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'])) {
505 $_params = array('pObj' => &$this);
506 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'] as $_funcRef) {
507 t3lib_div
::callUserFunction($_funcRef,$_params,$this);
513 * Looks up the value of $this->RDCT in the database and if it is found to be associated with a redirect URL then the redirection is carried out with a 'Location:' header
514 * May exit after sending a location-header.
518 function sendRedirect() {
519 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->RDCT
, 'cache_md5params'));
520 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
521 $this->updateMD5paramsRecord($this->RDCT
);
522 header('Location: '.$row['params']);
544 /********************************************
546 * Initializing, resolving page id
548 ********************************************/
552 * Initializes the front-end login user.
556 function initFEuser() {
557 $this->fe_user
= t3lib_div
::makeInstance('tslib_feUserAuth');
559 $this->fe_user
->lockIP
= $this->TYPO3_CONF_VARS
['FE']['lockIP'];
560 $this->fe_user
->lockHashKeyWords
= $this->TYPO3_CONF_VARS
['FE']['lockHashKeyWords'];
561 $this->fe_user
->checkPid
= $this->TYPO3_CONF_VARS
['FE']['checkFeUserPid'];
562 $this->fe_user
->lifetime
= intval($this->TYPO3_CONF_VARS
['FE']['lifetime']);
563 $this->fe_user
->checkPid_value
= $GLOBALS['TYPO3_DB']->cleanIntList(t3lib_div
::_GP('pid')); // List of pid's acceptable
565 // Check if a session is transferred:
566 if (t3lib_div
::_GP('FE_SESSION_KEY')) {
567 $fe_sParts = explode('-',t3lib_div
::_GP('FE_SESSION_KEY'));
568 if (!strcmp(md5($fe_sParts[0].'/'.$this->TYPO3_CONF_VARS
['SYS']['encryptionKey']), $fe_sParts[1])) { // If the session key hash check is OK:
569 $_COOKIE[$this->fe_user
->name
] = $fe_sParts[0];
570 $this->fe_user
->forceSetCookie
= 1;
574 if ($this->TYPO3_CONF_VARS
['FE']['dontSetCookie']) {
575 $this->fe_user
->dontSetCookie
=1;
578 $this->fe_user
->start();
579 $this->fe_user
->unpack_uc('');
580 $this->fe_user
->fetchSessionData(); // Gets session data
581 $recs = t3lib_div
::_GP('recs');
582 if (is_array($recs)) { // If any record registration is submitted, register the record.
583 $this->fe_user
->record_registration($recs, $this->TYPO3_CONF_VARS
['FE']['maxSessionDataSize']);
586 // Call hook for possible manipulation of frontend user object
587 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'])) {
588 $_params = array('pObj' => &$this);
589 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] as $_funcRef) {
590 t3lib_div
::callUserFunction($_funcRef,$_params,$this);
594 // For every 60 seconds the is_online timestamp is updated.
595 if (is_array($this->fe_user
->user
) && $this->fe_user
->user
['uid'] && $this->fe_user
->user
['is_online']<($GLOBALS['EXEC_TIME']-60)) {
596 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid='.intval($this->fe_user
->user
['uid']), array('is_online' => $GLOBALS['EXEC_TIME']));
601 * Initializes the front-end user groups.
602 * Sets ->loginUser and ->gr_list based on front-end user status.
606 function initUserGroups() {
608 $this->fe_user
->showHiddenRecords
= $this->showHiddenRecords
; // This affects the hidden-flag selecting the fe_groups for the user!
609 $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!)
611 if (is_array($this->fe_user
->user
) && count($this->fe_user
->groupData
['uid'])) {
612 $this->loginUser
=1; // global flag!
613 $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!
614 $gr_array = $this->fe_user
->groupData
['uid'];
617 $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!
619 if ($this->loginAllowedInBranch
) {
620 $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.
622 $gr_array = array(); // Set to blank since we will NOT risk any groups being set when no logins are allowed!
627 $gr_array = array_unique($gr_array); // Make unique...
628 sort($gr_array); // sort
629 if (count($gr_array)) {
630 $this->gr_list
.=','.implode(',',$gr_array);
633 if ($this->fe_user
->writeDevLog
) t3lib_div
::devLog('Valid usergroups for TSFE: '.$this->gr_list
, 'tslib_fe');
637 * Checking if a user is logged in or a group constellation different from "0,-1"
639 * @return boolean TRUE if either a login user is found (array fe_user->user) OR if the gr_list is set to something else than '0,-1' (could be done even without a user being logged in!)
641 function isUserOrGroupSet() {
642 return is_array($this->fe_user
->user
) ||
$this->gr_list
!=='0,-1';
646 * Provides ways to bypass the '?id=[xxx]&type=[xx]' format, using either PATH_INFO or virtual HTML-documents (using Apache mod_rewrite)
649 * 1) Apache mod_rewrite: Here a .htaccess file maps all .html-files to index.php and then we extract the id and type from the name of that HTML-file. (AKA "simulateStaticDocuments")
650 * 2) Use PATH_INFO (also Apache) to extract id and type from that var. Does not require any special modules compiled with apache. (less typical)
651 * 3) Using hook which enables features like those provided from "realurl" extension (AKA "Speaking URLs")
653 * Support for RewriteRule to generate (simulateStaticDocuments)
654 * With the mod_rewrite compiled into apache, put these lines into a .htaccess in this directory:
656 * RewriteRule ^[^/]*\.html$ index.php
657 * The url must end with '.html' and the format must comply with either of these:
658 * 1: '[title].[id].[type].html' - title is just for easy recognition in the logfile!; no practical use of the title for TYPO3.
659 * 2: '[id].[type].html' - above, but title is omitted; no practical use of the title for TYPO3.
660 * 3: '[id].html' - only id, type is set to the default, zero!
661 * NOTE: In all case 'id' may be the uid-number OR the page alias (if any)
664 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&cHash=4ad9d7acb4
666 function checkAlternativeIdMethods() {
668 $this->siteScript
= t3lib_div
::getIndpEnv('TYPO3_SITE_SCRIPT');
670 // Resolving of "simulateStaticDocuments" URLs:
671 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
672 $uParts = parse_url($this->siteScript
); // Parse the path:
673 $fI = t3lib_div
::split_fileref($uParts['path']);
675 if (!$fI['path'] && $fI['file'] && substr($fI['file'],-5)=='.html') {
676 $parts = explode('.',$fI['file']);
677 $pCount = count($parts);
679 $this->type
= intval($parts[$pCount-2]);
680 $this->id
= $parts[$pCount-3];
683 $this->id
= $parts[0];
689 if (t3lib_div
::getIndpEnv('PATH_INFO')) { // If pathinfo contains stuff...
690 $parts=t3lib_div
::trimExplode('/',t3lib_div
::getIndpEnv('PATH_INFO'),1);
692 $pCount = count($parts);
694 $this->type
= intval($parts[$pCount-2]);
695 $this->id
= $parts[$pCount-3];
698 $this->id
= $parts[0];
700 $this->absRefPrefix_force
=1;
703 // Call post processing function for custom URL methods.
704 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'])) {
705 $_params = array('pObj' => &$this);
706 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef) {
707 t3lib_div
::callUserFunction($_funcRef,$_params,$this);
713 * Clears the preview-flags, sets sim_exec_time to current time.
714 * Hidden pages must be hidden as default, $GLOBALS['SIM_EXEC_TIME'] is set to $GLOBALS['EXEC_TIME'] in t3lib/config_default.inc. Alter it by adding or subtracting seconds.
718 function clear_preview() {
719 $this->showHiddenPage
= 0;
720 $this->showHiddenRecords
= 0;
721 $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME'];
722 $GLOBALS['SIM_ACCESS_TIME'] = $GLOBALS['ACCESS_TIME'];
723 $this->fePreview
= 0;
727 * Determines the id and evaluates any preview settings
728 * Basically this function is about determining whether a backend user is logged in, if he has read access to the page and if he's previewing the page. That all determines which id to show and how to initialize the id.
732 function determineId() {
734 // Getting ARG-v values if some
735 $this->setIDfromArgV();
737 // If there is a Backend login we are going to check for any preview settings:
738 $GLOBALS['TT']->push('beUserLogin','');
739 if ($this->beUserLogin ||
$this->doWorkspacePreview()) {
741 // Backend user preview features:
742 if ($this->beUserLogin
) {
743 $this->fePreview
= $GLOBALS['BE_USER']->extGetFeAdminValue('preview') ?
1 : 0;
745 // If admin panel preview is enabled...
746 if ($this->fePreview
) {
747 $fe_user_OLD_USERGROUP = $this->fe_user
->user
['usergroup'];
749 $this->showHiddenPage
= $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenPages');
750 $this->showHiddenRecords
= $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenRecords');
752 $simTime = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateDate');
754 $GLOBALS['SIM_EXEC_TIME'] = $simTime;
755 $GLOBALS['SIM_ACCESS_TIME'] = $simTime - ($simTime %
60);
758 $simUserGroup = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateUserGroup');
759 $this->simUserGroup
= $simUserGroup;
760 if ($simUserGroup) $this->fe_user
->user
['usergroup']=$simUserGroup;
761 if (!$simUserGroup && !$simTime && !$this->showHiddenPage
&& !$this->showHiddenRecords
) {
769 // Now it's investigated if the raw page-id points to a hidden page and if so, the flag is set.
770 // This does not require the preview flag to be set in the admin panel
771 $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...
772 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('hidden', 'pages', $idQ.' AND hidden!=0 AND deleted=0');
773 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
774 $this->fePreview
= 1; // The preview flag is set only if the current page turns out to actually be hidden!
775 $this->showHiddenPage
= 1;
778 // For Live workspace: Check root line for proper connection to tree root (done because of possible preview of page / branch versions)
779 if (!$this->fePreview
&& $this->whichWorkspace()===0) {
781 // Initialize the page-select functions to check rootline:
782 $temp_sys_page = t3lib_div
::makeInstance('t3lib_pageSelect');
783 $temp_sys_page->init($this->showHiddenPage
);
784 // If root line contained NO records and ->error_getRootLine_failPid tells us that it was because of a pid=-1 (indicating a "version" record)...:
785 if (!count($temp_sys_page->getRootLine($this->id
,$this->MP
)) && $temp_sys_page->error_getRootLine_failPid
==-1) {
787 // Setting versioningPreview flag and try again:
788 $temp_sys_page->versioningPreview
= TRUE;
789 if (count($temp_sys_page->getRootLine($this->id
,$this->MP
))) {
790 // 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.
791 $this->fePreview
= 1;
797 // The preview flag will be set if a backend user is in an offline workspace
798 if (($GLOBALS['BE_USER']->user
['workspace_preview'] || t3lib_div
::_GP('ADMCMD_view') ||
$this->doWorkspacePreview()) && ($this->whichWorkspace()===-1 ||
$this->whichWorkspace()>0)) {
799 $this->fePreview
= 2; // Will show special preview message.
802 // If the front-end is showing a preview, caching MUST be disabled.
803 if ($this->fePreview
) {
804 $this->set_no_cache();
807 $GLOBALS['TT']->pull();
809 // Now, get the id, validate access etc:
810 $this->fetch_the_id();
812 // Check if backend user has read access to this page. If not, recalculate the id.
813 if ($this->beUserLogin
&& $this->fePreview
) {
814 if (!$GLOBALS['BE_USER']->doesUserHaveAccess($this->page
,1)) {
817 $this->clear_preview();
818 $this->fe_user
->user
['usergroup'] = $fe_user_OLD_USERGROUP;
820 // Fetching the id again, now with the preview settings reset.
821 $this->fetch_the_id();
825 // Checks if user logins are blocked for a certain branch and if so, will unset user login and re-fetch ID.
826 $this->loginAllowedInBranch
= $this->checkIfLoginAllowedInBranch();
827 if (!$this->loginAllowedInBranch
) { // Logins are not allowed:
828 if ($this->isUserOrGroupSet()) { // Only if there is a login will we run this...
830 // Clear out user and group:
831 unset($this->fe_user
->user
);
832 $this->gr_list
= '0,-1';
834 // Fetching the id again, now with the preview settings reset.
835 $this->fetch_the_id();
840 $this->id
= $this->contentPid
= intval($this->id
); // Make sure it's an integer
841 $this->type
= intval($this->type
); // Make sure it's an integer
843 // Look for alternative content PID if page is under version preview:
844 if ($this->fePreview
) {
845 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:
846 // 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!
847 $this->contentPid
= $this->page
['_ORIG_uid'];
851 // Call post processing function for id determination:
852 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) {
853 $_params = array('pObj' => &$this);
854 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef) {
855 t3lib_div
::callUserFunction($_funcRef,$_params,$this);
862 * This gets the id of the page, checks if the page is in the domain and if the page is accessible
863 * Sets variables such as $this->sys_page, $this->loginUser, $this->gr_list, $this->id, $this->type, $this->domainStartPage, $this->idParts
868 function fetch_the_id() {
869 $GLOBALS['TT']->push('fetch_the_id initialize/','');
871 // Initialize the page-select functions.
872 $this->sys_page
= t3lib_div
::makeInstance('t3lib_pageSelect');
873 $this->sys_page
->versioningPreview
= $this->fePreview ?
TRUE : FALSE;
874 $this->sys_page
->versioningWorkspaceId
= $this->whichWorkspace();
875 $this->sys_page
->init($this->showHiddenPage
);
877 // Set the valid usergroups for FE
878 $this->initUserGroups();
880 // Sets sys_page where-clause
881 $this->setSysPageWhereClause();
883 // Splitting $this->id by a period (.). First part is 'id' and second part - if exists - will overrule the &type param if given
884 $pParts = explode('.',$this->id
);
885 $this->id
= $pParts[0]; // Set it.
886 if (isset($pParts[1])) {$this->type
=$pParts[1];}
888 // Splitting $this->id by a comma (,). First part is 'id' and other parts are just stored for use in scripts.
889 $this->idParts
= explode(',',$this->id
);
891 // Splitting by a '+' sign - used for base64/md5 methods of parameter encryption for simulate static documents.
892 list($pgID,$SSD_p)=explode('+',$this->idParts
[0],2);
893 if ($SSD_p) { $this->idPartsAnalyze($SSD_p); }
894 $this->id
= $pgID; // Set id
896 // If $this->id is a string, it's an alias
897 $this->checkAndSetAlias();
899 // The id and type is set to the integer-value - just to be sure...
900 $this->id
= intval($this->id
);
901 $this->type
= intval($this->type
);
902 $GLOBALS['TT']->pull();
904 // We find the first page belonging to the current domain
905 $GLOBALS['TT']->push('fetch_the_id domain/','');
906 $this->domainStartPage
= $this->findDomainRecord($this->TYPO3_CONF_VARS
['SYS']['recursiveDomainSearch']); // the page_id of the current domain
908 if ($this->domainStartPage
) {
909 $this->id
= $this->domainStartPage
; // If the id was not previously set, set it to the id of the domain.
911 $theFirstPage = $this->sys_page
->getFirstWebPage($this->id
); // Find the first 'visible' page in that domain
913 $this->id
= $theFirstPage['uid'];
915 header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
916 t3lib_div
::sysLog('No pages are found on the rootlevel!', 'cms', 3);
917 $this->printError('No pages are found on the rootlevel!');
922 $GLOBALS['TT']->pull();
924 $GLOBALS['TT']->push('fetch_the_id rootLine/','');
925 $requestedId = $this->id
; // We store the originally requested id
926 $this->getPageAndRootlineWithDomain($this->domainStartPage
);
927 $GLOBALS['TT']->pull();
929 if ($this->pageNotFound
&& $this->TYPO3_CONF_VARS
['FE']['pageNotFound_handling']) {
930 $pNotFoundMsg = array(
931 1 => 'ID was not an accessible page',
932 2 => 'Subsection was found and not accessible',
933 3 => 'ID was outside the domain',
934 4 => 'The requested page alias does not exist'
936 $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound
]);
939 // set no_cache if set
940 if ($this->page
['no_cache']) {
941 $this->set_no_cache();
944 // Init SYS_LASTCHANGED
945 $this->register
['SYS_LASTCHANGED'] = intval($this->page
['tstamp']);
946 if ($this->register
['SYS_LASTCHANGED'] < intval($this->page
['SYS_LASTCHANGED'])) {
947 $this->register
['SYS_LASTCHANGED'] = intval($this->page
['SYS_LASTCHANGED']);
952 * Gets the page and rootline arrays based on the id, $this->id
954 * If the id does not correspond to a proper page, the 'previous' valid page in the rootline is found
955 * If the page is a shortcut (doktype=4), the ->id is loaded with that id
957 * Whether or not the ->id is changed to the shortcut id or the previous id in rootline (eg if a page is hidden), the ->page-array and ->rootline is found and must also be valid.
959 * Sets or manipulates internal variables such as: $this->id, $this->page, $this->rootLine, $this->MP, $this->pageNotFound
964 function getPageAndRootline() {
965 $this->page
= $this->sys_page
->getPage($this->id
);
966 if (!count($this->page
)) {
967 // If no page, we try to find the page before in the rootLine.
968 $this->pageNotFound
=1; // Page is 'not found' in case the id itself was not an accessible page. code 1
969 $this->rootLine
= $this->sys_page
->getRootLine($this->id
,$this->MP
);
970 if (count($this->rootLine
)) {
971 $c=count($this->rootLine
)-1;
974 // Add to page access failure history:
975 $this->pageAccessFailureHistory
['direct_access'][] = $this->rootLine
[$c];
977 // Decrease to next page in rootline and check the access to that, if OK, set as page record and ID value.
979 $this->id
= $this->rootLine
[$c]['uid'];
980 $this->page
= $this->sys_page
->getPage($this->id
);
981 if (count($this->page
)) { break; }
984 // If still no page...
985 if (!count($this->page
)) {
986 if ($this->TYPO3_CONF_VARS
['FE']['pageNotFound_handling']) {
987 $this->pageNotFoundAndExit('The requested page does not exist!');
989 header( 'HTTP/1.0 404 Page Not Found' );
990 t3lib_div
::sysLog('The requested page does not exist!', 'cms', 3);
991 $this->printError('The requested page does not exist!');
997 // Spacer is not accessible in frontend
998 if ($this->page
['doktype'] == 199) {
999 if ($this->TYPO3_CONF_VARS
['FE']['pageNotFound_handling']) {
1000 $this->pageNotFoundAndExit('The requested page does not exist!');
1002 header( 'HTTP/1.0 404 Page Not Found' );
1003 t3lib_div
::sysLog('The requested page does not exist!', 'cms', 3);
1004 $this->printError('The requested page does not exist!');
1009 // Is the ID a link to another page??
1010 if ($this->page
['doktype']==4) {
1011 $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.
1012 $this->page
= $this->getPageShortcut($this->page
['shortcut'],$this->page
['shortcut_mode'],$this->page
['uid']);
1013 $this->id
= $this->page
['uid'];
1016 // Gets the rootLine
1017 $this->rootLine
= $this->sys_page
->getRootLine($this->id
,$this->MP
);
1019 // If not rootline we're off...
1020 if (!count($this->rootLine
)) {
1021 $ws = $this->whichWorkspace();
1022 if ($this->sys_page
->error_getRootLine_failPid
==-1 && $ws) {
1023 $this->sys_page
->versioningPreview
= TRUE;
1024 $this->versioningWorkspaceId
= $ws;
1025 $this->rootLine
= $this->sys_page
->getRootLine($this->id
,$this->MP
);
1027 if (!count($this->rootLine
)) {
1028 header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1029 t3lib_div
::sysLog('The requested page didn\'t have a proper connection to the tree-root! ('.$this->sys_page
->error_getRootLine
.')', 'cms', 3);
1030 $this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page
->error_getRootLine
.')');
1033 $this->fePreview
= 1;
1036 // Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!)
1037 if ($this->checkRootlineForIncludeSection()) {
1038 if (!count($this->rootLine
)) {
1039 header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1040 t3lib_div
::sysLog('The requested page was not accessible!', 'cms', 3);
1041 $this->printError('The requested page was not accessible!');
1044 $el = reset($this->rootLine
);
1045 $this->id
= $el['uid'];
1046 $this->page
= $this->sys_page
->getPage($this->id
);
1047 $this->rootLine
= $this->sys_page
->getRootLine($this->id
,$this->MP
);
1053 * Get page shortcut; Finds the records pointed to by input value $SC (the shortcut value)
1055 * @param integer The value of the "shortcut" field from the pages record
1056 * @param integer The shortcut mode: 1 and 2 will select either first subpage or random subpage; the default is the page pointed to by $SC
1057 * @param integer The current page UID of the page which is a shortcut
1058 * @param integer Safety feature which makes sure that the function is calling itself recursively max 20 times (since this function can find shortcuts to other shortcuts to other shortcuts...)
1059 * @param array An array filled with previous page uids tested by the function - new page uids are evaluated against this to avoid going in circles.
1060 * @return mixed Returns the page record of the page that the shortcut pointed to.
1062 * @see getPageAndRootline()
1064 function getPageShortcut($SC,$mode,$thisUid,$itera=20,$pageLog=array()) {
1065 $idArray = t3lib_div
::intExplode(',',$SC);
1067 // Find $page record depending on shortcut mode:
1071 $pageArray = $this->sys_page
->getMenu($idArray[0]?
$idArray[0]:$thisUid,'*','sorting','AND pages.doktype<199 AND pages.doktype!=6');
1073 if ($mode==2 && count($pageArray)) { // random
1075 $randval = intval(rand(0,count($pageArray)-1));
1080 while(list(,$pV)=each($pageArray)) {
1089 $page = $this->sys_page
->getPage($idArray[0]);
1093 // Check if short cut page was a shortcut itself, if so look up recursively:
1094 if ($page['doktype']==4) {
1095 if (!in_array($page['uid'],$pageLog) && $itera>0) {
1096 $pageLog[] = $page['uid'];
1097 $page = $this->getPageShortcut($page['shortcut'],$page['shortcut_mode'],$page['uid'],$itera-1,$pageLog);
1099 $pageLog[] = $page['uid'];
1100 header( 'HTTP/1.0 500 Internal Server Error' );
1101 t3lib_div
::sysLog('Page shortcuts were looping in uids '.implode(',',$pageLog).'...!', 'cms', 3);
1102 $this->printError('Page shortcuts were looping in uids '.implode(',',$pageLog).'...!');
1106 // Return resulting page:
1111 * Checks the current rootline for defined sections.
1116 function checkRootlineForIncludeSection() {
1117 $c=count($this->rootLine
);
1118 $removeTheRestFlag=0;
1120 for ($a=0;$a<$c;$a++
) {
1121 if (!$this->checkPagerecordForIncludeSection($this->rootLine
[$a])) {
1122 // Add to page access failure history:
1123 $this->pageAccessFailureHistory
['sub_section'][] = $this->rootLine
[$a];
1124 $removeTheRestFlag=1;
1126 if ($this->rootLine
[$a]['doktype']==6) {
1127 if ($this->beUserLogin
) { // If there is a backend user logged in, check if he has read access to the page:
1128 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($this->id
).' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1)); // versionOL()?
1129 list($isPage) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
1130 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...
1131 } else { // Dont go here, if there is no backend user logged in.
1132 $removeTheRestFlag=1;
1135 if ($removeTheRestFlag) {
1136 $this->pageNotFound
=2; // Page is 'not found' in case a subsection was found and not accessible, code 2
1137 unset($this->rootLine
[$a]);
1140 return $removeTheRestFlag;
1144 * Checks page record for enableFields
1145 * Returns true if enableFields does not disable the page record.
1146 * Takes notice of the ->showHiddenPage flag and uses SIM_ACCESS_TIME for start/endtime evaluation
1148 * @param array The page record to evaluate (needs fields: hidden, starttime, endtime, fe_group)
1149 * @param boolean Bypass group-check
1150 * @return boolean True, if record is viewable.
1151 * @see tslib_cObj::getTreeList(), checkPagerecordForIncludeSection()
1153 function checkEnableFields($row,$bypassGroupCheck=FALSE) {
1154 if ((!$row['hidden'] ||
$this->showHiddenPage
)
1155 && $row['starttime']<=$GLOBALS['SIM_ACCESS_TIME']
1156 && ($row['endtime']==0 ||
$row['endtime']>$GLOBALS['SIM_ACCESS_TIME'])
1157 && ($bypassGroupCheck ||
$this->checkPageGroupAccess($row))
1162 * Check group access against a page record
1164 * @param array The page record to evaluate (needs field: fe_group)
1165 * @param mixed List of group id's (comma list or array). Default is $this->gr_list
1166 * @return boolean True, if group access is granted.
1169 function checkPageGroupAccess($row, $groupList=NULL) {
1170 if(is_null($groupList)) {
1171 $groupList = $this->gr_list
;
1173 if(!is_array($groupList)) {
1174 $groupList = explode(',', $groupList);
1176 $pageGroupList = explode(',', $row['fe_group'] ?
$row['fe_group'] : 0);
1177 return count(array_intersect($groupList, $pageGroupList)) > 0;
1181 * Checks page record for include section
1183 * @param array The page record to evaluate (needs fields: extendToSubpages + hidden, starttime, endtime, fe_group)
1184 * @return boolean Returns true if either extendToSubpages is not checked or if the enableFields does not disable the page record.
1186 * @see checkEnableFields(), tslib_cObj::getTreeList(), checkRootlineForIncludeSection()
1188 function checkPagerecordForIncludeSection($row) {
1189 return (!$row['extendToSubpages'] ||
$this->checkEnableFields($row)) ?
1 : 0;
1193 * Checks if logins are allowed in the current branch of the page tree. Traverses the full root line and returns TRUE if logins are OK, otherwise false (and then the login user must be unset!)
1195 * @return boolean returns TRUE if logins are OK, otherwise false (and then the login user must be unset!)
1197 function checkIfLoginAllowedInBranch() {
1200 $c = count($this->rootLine
);
1203 // Traverse root line from root and outwards:
1204 for ($a=0; $a<$c; $a++
) {
1206 // If a value is set for login state:
1207 if ($this->rootLine
[$a]['fe_login_mode'] > 0) {
1209 // Determine state from value:
1210 $disable = (int)$this->rootLine
[$a]['fe_login_mode'] === 1 ?
TRUE : FALSE;
1218 * Analysing $this->pageAccessFailureHistory into a summary array telling which features disabled display and on which pages and conditions. That data can be used inside a page-not-found handler
1220 * @return array Summary of why page access was not allowed.
1222 function getPageAccessFailureReasons() {
1225 $combinedRecords = array_merge(
1226 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!
1227 is_array($this->pageAccessFailureHistory
['sub_section']) ?
$this->pageAccessFailureHistory
['sub_section'] : array()
1230 if (count($combinedRecords)) {
1231 foreach($combinedRecords as $k => $pagerec) {
1232 // 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
1233 // 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!
1234 if (!$k ||
$pagerec['extendToSubpages']) {
1235 if ($pagerec['hidden']) $output['hidden'][$pagerec['uid']] = TRUE;
1236 if ($pagerec['starttime'] > $GLOBALS['SIM_ACCESS_TIME']) $output['starttime'][$pagerec['uid']] = $pagerec['starttime'];
1237 if ($pagerec['endtime']!=0 && $pagerec['endtime'] <= $GLOBALS['SIM_ACCESS_TIME']) $output['endtime'][$pagerec['uid']] = $pagerec['endtime'];
1238 if (!$this->checkPageGroupAccess($pagerec)) $output['fe_group'][$pagerec['uid']] = $pagerec['fe_group'];
1247 * This checks if there are ARGV-parameters in the QUERY_STRING and if so, those are used for the id
1248 * $this->id must be 'false' in order for any processing to happen in here
1249 * If an id/alias value is extracted from the QUERY_STRING it is set in $this->id
1254 function setIDfromArgV() {
1256 list($theAlias) = explode('&',t3lib_div
::getIndpEnv('QUERY_STRING'));
1257 $theAlias = trim($theAlias);
1258 $this->id
= ($theAlias != '' && strpos($theAlias, '=') === false) ?
$theAlias : 0;
1263 * Gets ->page and ->rootline information based on ->id. ->id may change during this operation.
1264 * If not inside domain, then default to first page in domain.
1266 * @param integer Page uid of the page where the found domain record is (pid of the domain record)
1270 function getPageAndRootlineWithDomain($domainStartPage) {
1271 $this->getPageAndRootline();
1273 // 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.
1274 if ($domainStartPage && is_array($this->rootLine
)) {
1275 reset ($this->rootLine
);
1277 while(list($key,$val)=each($this->rootLine
)) {
1278 if ($val['uid']==$domainStartPage) {
1284 $this->pageNotFound
=3; // Page is 'not found' in case the id was outside the domain, code 3
1285 $this->id
= $domainStartPage;
1286 $this->getPageAndRootline(); //re-get the page and rootline if the id was not found.
1292 * Sets sys_page where-clause
1297 function setSysPageWhereClause() {
1298 $this->sys_page
->where_hid_del
.=' AND pages.doktype<200';
1299 $this->sys_page
->where_groupAccess
= $this->sys_page
->getMultipleGroupsWhereClause('pages.fe_group', 'pages');
1303 * Looking up a domain record based on HTTP_HOST
1305 * @param boolean If set, it looks "recursively" meaning that a domain like "123.456.typo3.com" would find a domain record like "typo3.com" if "123.456.typo3.com" or "456.typo3.com" did not exist.
1306 * @return integer Returns the page id of the page where the domain record was found.
1309 function findDomainRecord($recursive=0) {
1311 $host = explode('.',t3lib_div
::getIndpEnv('HTTP_HOST'));
1312 while(count($host)) {
1313 $pageUid = $this->sys_page
->getDomainStartPage(implode('.',$host),t3lib_div
::getIndpEnv('SCRIPT_NAME'),t3lib_div
::getIndpEnv('REQUEST_URI'));
1314 if ($pageUid) return $pageUid; else array_shift($host);
1318 return $this->sys_page
->getDomainStartPage(t3lib_div
::getIndpEnv('HTTP_HOST'),t3lib_div
::getIndpEnv('SCRIPT_NAME'),t3lib_div
::getIndpEnv('REQUEST_URI'));
1323 * Page-not-found handler for use in frontend plugins from extensions.
1325 * @param string Reason text
1326 * @param string HTTP header to send
1327 * @return void Function exits.
1329 function pageNotFoundAndExit($reason='', $header='') {
1330 $header = $header ?
$header : $this->TYPO3_CONF_VARS
['FE']['pageNotFound_handling_statheader'];
1331 $this->pageNotFoundHandler($this->TYPO3_CONF_VARS
['FE']['pageNotFound_handling'], $header, $reason);
1336 * Page not found handler.
1339 * @param mixed Which type of handling; If a true PHP-boolean or TRUE then a ->printError message is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
1340 * @param string If set, this is passed directly to the PHP function, header()
1341 * @param string If set, error messages will also mention this as the reason for the page-not-found.
1342 * @return void (The function exits!)
1344 function pageNotFoundHandler($code, $header='', $reason='') {
1346 // Issue header in any case:
1348 $headerArr = preg_split('/\r|\n/',$header,-1,PREG_SPLIT_NO_EMPTY
);
1349 foreach ($headerArr as $header) {
1355 if (gettype($code)=='boolean' ||
!strcmp($code,1)) { // Simply boolean; Just shows TYPO3 error page with reason:
1356 $this->printError('The page did not exist or was inaccessible.'.($reason ?
' Reason: '.htmlspecialchars($reason) : ''));
1357 } elseif (t3lib_div
::isFirstPartOfStr($code,'USER_FUNCTION:')) {
1358 $funcRef = trim(substr($code,14));
1360 'currentUrl' => t3lib_div
::getIndpEnv('REQUEST_URI'),
1361 'reasonText' => $reason,
1362 'pageAccessFailureReasons' => $this->getPageAccessFailureReasons()
1364 echo t3lib_div
::callUserFunction($funcRef,$params,$this);
1365 } elseif (t3lib_div
::isFirstPartOfStr($code,'READFILE:')) {
1366 $readFile = t3lib_div
::getFileAbsFileName(trim(substr($code,9)));
1367 if (@is_file
($readFile)) {
1368 $fileContent = t3lib_div
::getUrl($readFile);
1369 $fileContent = str_replace('###CURRENT_URL###', t3lib_div
::getIndpEnv('REQUEST_URI'), $fileContent);
1370 $fileContent = str_replace('###REASON###', htmlspecialchars($reason), $fileContent);
1373 $this->printError('Configuration Error: 404 page "'.$readFile.'" could not be found.');
1375 } elseif (t3lib_div
::isFirstPartOfStr($code,'REDIRECT:')) {
1376 header('Location: '.t3lib_div
::locationHeaderUrl(substr($code,9)));
1378 } elseif (strlen($code)) {
1379 // Check if URL is relative
1380 $url_parts = parse_url($code);
1381 if ($url_parts['host'] == '') {
1382 $url_parts['host'] = t3lib_div
::getIndpEnv('HTTP_HOST');
1383 $code = t3lib_div
::getIndpEnv('TYPO3_REQUEST_HOST') . $code;
1384 $checkBaseTag = false;
1386 $checkBaseTag = true;
1390 if ($code == t3lib_div
::getIndpEnv('TYPO3_REQUEST_URL')) {
1391 if ($reason == '') {
1392 $reason = 'Page cannot be found.';
1394 $reason.= chr(10) . chr(10) . 'Additionally, ' . $code . ' was not found while trying to retrieve the error document.';
1395 $this->printError('Reason: '.nl2br(htmlspecialchars($reason)));
1401 'User-agent: ' . t3lib_div
::getIndpEnv('HTTP_USER_AGENT'),
1402 'Referer: ' . t3lib_div
::getIndpEnv('TYPO3_REQUEST_URL')
1404 $res = t3lib_div
::getURL($code, 1, $headerArr);
1406 // Header and content are separated by an empty line
1407 list($header,$content) = split("\r\n\r\n", $res, 2);
1410 if (false === $res) {
1411 // Last chance -- redirect
1412 header('Location: '.t3lib_div
::locationHeaderUrl($code));
1415 $forwardHeaders = array( // Forward these response headers to the client
1418 $headerArr = preg_split('/\r|\n/',$header,-1,PREG_SPLIT_NO_EMPTY
);
1419 foreach ($headerArr as $header) {
1420 foreach ($forwardHeaders as $h) {
1421 if (preg_match('/^'.$h.'/', $header)) {
1426 // Put <base> if necesary
1427 if ($checkBaseTag) {
1429 // If content already has <base> tag, we do not need to do anything
1430 if (false === stristr($content, '<base ')) {
1432 // Generate href for base tag
1433 $base = $url_parts['scheme'] . '://';
1434 if ($url_parts['user'] != '') {
1435 $base.= $url_parts['user'];
1436 if ($url_parts['pass'] != '') {
1437 $base.= ':' . $url_parts['pass'];
1441 $base.= $url_parts['host'];
1443 // Add path portion skipping possible file name
1444 $base.= preg_replace('/(.*\/)[^\/]*/', '${1}', $url_parts['path']);
1446 // Put it into content (generate also <head> if necessary)
1447 $replacement = chr(10) . '<base href="' . htmlentities($base) . '" />' . chr(10);
1448 if (stristr($content, '<head>')) {
1449 $content = preg_replace('/(<head>)/i', '\1' . $replacement, $content);
1451 $content = preg_replace('/(<html[^>]*>)/i', '\1<head>' . $replacement . '</head>', $content);
1455 echo $content; // Output the content
1458 $this->printError($reason ?
'Reason: '.htmlspecialchars($reason) : 'Page cannot be found.');
1464 * Fetches the integer page id for a page alias.
1465 * Looks if ->id is not an integer and if so it will search for a page alias and if found the page uid of that page is stored in $this->id
1470 function checkAndSetAlias() {
1471 if ($this->id
&& !t3lib_div
::testInt($this->id
)) {
1472 $aid = $this->sys_page
->getPageIdFromAlias($this->id
);
1476 $this->pageNotFound
= 4;
1482 * Analyzes the second part of a id-string (after the "+"), looking for B6 or M5 encoding and if found it will resolve it and restore the variables in global $_GET
1483 * If values for ->cHash, ->no_cache, ->jumpurl and ->MP is found, they are also loaded into the internal vars of this class.
1485 * @param string String to analyze
1489 function idPartsAnalyze($str) {
1491 switch(substr($str,0,2)) {
1493 $addParams = base64_decode(str_replace('_','=',str_replace('-','/',substr($str,2))));
1494 parse_str($addParams,$GET_VARS);
1497 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr(substr($str,2), 'cache_md5params'));
1498 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
1500 $this->updateMD5paramsRecord(substr($str,2));
1501 parse_str($row['params'],$GET_VARS);
1505 $this->mergingWithGetVars($GET_VARS);
1509 * Merging values into the global $_GET
1511 * @param array Array of key/value pairs that will be merged into the current GET-vars. (Non-escaped values)
1514 function mergingWithGetVars($GET_VARS) {
1515 if (is_array($GET_VARS)) {
1516 $realGet = t3lib_div
::_GET(); // Getting $_GET var, unescaped.
1517 if (!is_array($realGet)) $realGet = array();
1519 // Merge new values on top:
1520 $realGet = t3lib_div
::array_merge_recursive_overrule($realGet,$GET_VARS);
1522 // Write values back to $_GET:
1523 t3lib_div
::_GETset($realGet);
1525 // Setting these specifically (like in the init-function):
1526 if (isset($GET_VARS['type'])) $this->type
= intval($GET_VARS['type']);
1527 if (isset($GET_VARS['cHash'])) $this->cHash
= $GET_VARS['cHash'];
1528 if (isset($GET_VARS['jumpurl'])) $this->jumpurl
= $GET_VARS['jumpurl'];
1529 if (isset($GET_VARS['MP'])) $this->MP
= $this->TYPO3_CONF_VARS
['FE']['enable_mount_pids'] ?
$GET_VARS['MP'] : '';
1531 if (isset($GET_VARS['no_cache']) && $GET_VARS['no_cache']) $this->set_no_cache();
1536 * Looking for a ADMCMD_prev code, looks it up if found and returns configuration data.
1537 * Background: From the backend a request to the frontend to show a page, possibly with workspace preview can be "recorded" and associated with a keyword. When the frontend is requested with this keyword the associated request parameters are restored from the database AND the backend user is loaded - only for that request.
1538 * The main point is that a special URL valid for a limited time, eg. http://localhost/typo3site/index.php?ADMCMD_prev=035d9bf938bd23cb657735f68a8cedbf will open up for a preview that doesn't require login. Thus it's useful for sending in an email to someone without backend account.
1539 * This can also be used to generate previews of hidden pages, start/endtimes, usergroups and those other settings from the Admin Panel - just not implemented yet.
1541 * @return array Preview configuration array from sys_preview record.
1542 * @see t3lib_BEfunc::compilePreviewKeyword()
1544 function ADMCMD_preview(){
1545 $inputCode = t3lib_div
::_GP('ADMCMD_prev');
1547 // If no inputcode and a cookie is set, load input code from cookie:
1548 if (!$inputCode && $_COOKIE['ADMCMD_prev']) {
1549 $inputCode = $_COOKIE['ADMCMD_prev'];
1552 // If inputcode now, look up the settings:
1555 if ($inputCode=='LOGOUT') { // "log out":
1556 SetCookie('ADMCMD_prev', '', 0);
1557 if ($this->TYPO3_CONF_VARS
['FE']['workspacePreviewLogoutTemplate']) {
1558 if (@is_file
(PATH_site
.$this->TYPO3_CONF_VARS
['FE']['workspacePreviewLogoutTemplate'])) {
1559 $message = t3lib_div
::getUrl(PATH_site
.$this->TYPO3_CONF_VARS
['FE']['workspacePreviewLogoutTemplate']);
1561 $message = '<b>ERROR!</b><br>Template File "'.$this->TYPO3_CONF_VARS
['FE']['workspacePreviewLogoutTemplate'].'" configured with $TYPO3_CONF_VARS["FE"]["workspacePreviewLogoutTemplate"] not found. Please contact webmaster about this problem.';
1564 $message = 'You logged out from Workspace preview mode. Click this link to <a href="%1$s">go back to the website</a>';
1566 die(sprintf($message,
1567 htmlspecialchars(ereg_replace('\&?ADMCMD_prev=[[:alnum:]]+','',t3lib_div
::_GET('returnUrl')))
1571 // Look for keyword configuration record:
1572 list($previewData) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
1575 'keyword='.$GLOBALS['TYPO3_DB']->fullQuoteStr($inputCode, 'sys_preview').
1576 ' AND endtime>'.time()
1579 // Get: Backend login status, Frontend login status
1580 // - Make sure to remove fe/be cookies (temporarily); BE already done in ADMCMD_preview_postInit()
1581 if (is_array($previewData)) {
1582 if (!count(t3lib_div
::_POST())) {
1583 // Unserialize configuration:
1584 $previewConfig = unserialize($previewData['config']);
1586 if ($previewConfig['fullWorkspace']) { // For full workspace preview we only ADD a get variable to set the preview of the workspace - so all other Get vars are accepted. Hope this is not a security problem. Still posting is not allowed and even if a backend user get initialized it shouldn't lead to situations where users can use those credentials.
1588 // Set the workspace preview value:
1589 t3lib_div
::_GETset($previewConfig['fullWorkspace'],'ADMCMD_previewWS');
1591 // If ADMCMD_prev is set the $inputCode value cannot come from a cookie and we set that cookie here. Next time it will be found from the cookie if ADMCMD_prev is not set again...
1592 if (t3lib_div
::_GP('ADMCMD_prev')) {
1593 SetCookie('ADMCMD_prev', t3lib_div
::_GP('ADMCMD_prev'), 0); // Lifetime is 1 hour, does it matter much? Requires the user to click the link from their email again if it expires.
1595 return $previewConfig;
1596 } elseif (t3lib_div
::getIndpEnv('TYPO3_SITE_URL').'index.php?ADMCMD_prev='.$inputCode === t3lib_div
::getIndpEnv('TYPO3_REQUEST_URL')) {
1598 // Set GET variables:
1600 parse_str($previewConfig['getVars'], $GET_VARS);
1601 t3lib_div
::_GETset($GET_VARS);
1603 // Return preview keyword configuration:
1604 return $previewConfig;
1605 } else die(htmlspecialchars('Request URL did not match "'.t3lib_div
::getIndpEnv('TYPO3_SITE_URL').'index.php?ADMCMD_prev='.$inputCode.'"')); // This check is to prevent people from setting additional GET vars via realurl or other URL path based ways of passing parameters.
1606 } else die('POST requests are incompatible with keyword preview.');
1607 } else die('ADMCMD command could not be executed! (No keyword configuration found)');
1612 * Configuration after initialization of TSFE object.
1613 * Basically this unsets the BE cookie if any and forces the BE user set according to the preview configuration.
1615 * @param array Preview configuration, see ADMCMD_preview()
1617 * @see ADMCMD_preview(), index_ts.php
1619 function ADMCMD_preview_postInit($previewConfig){
1620 if (is_array($previewConfig)) {
1623 unset($_COOKIE['be_typo_user']);
1624 $this->ADMCMD_preview_BEUSER_uid
= $previewConfig['BEUSER_uid'];
1626 } else die('Error in preview configuration.');
1639 /********************************************
1641 * Template and caching related functions.
1643 *******************************************/
1646 * Calculates a hash string based on additional parameters in the url. This is used to cache pages with more parameters than just id and type
1651 function makeCacheHash() {
1652 $GET = t3lib_div
::_GET();
1653 if ($this->cHash
&& is_array($GET)) {
1654 $this->cHash_array
= t3lib_div
::cHashParams(t3lib_div
::implodeArrayForUrl('',$GET));
1655 $cHash_calc = t3lib_div
::shortMD5(serialize($this->cHash_array
));
1657 if ($cHash_calc!=$this->cHash
) {
1658 if ($this->TYPO3_CONF_VARS
['FE']['pageNotFoundOnCHashError']) {
1659 $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash comparison failed)');
1661 $this->set_no_cache();
1662 $GLOBALS['TT']->setTSlogMessage('The incoming cHash "'.$this->cHash
.'" and calculated cHash "'.$cHash_calc.'" did not match, so caching was disabled. The fieldlist used was "'.implode(',',array_keys($this->cHash_array
)).'"',2);
1669 * Will disable caching if the cHash value was not set.
1670 * This function should be called to check the _existence_ of "&cHash" whenever a plugin generating cachable output is using extra GET variables. If there _is_ a cHash value the validation of it automatically takes place in makeCacheHash() (see above)
1673 * @see makeCacheHash(), tslib_pibase::pi_cHashCheck()
1675 function reqCHash() {
1676 if (!$this->cHash
) {
1677 if ($this->TYPO3_CONF_VARS
['FE']['pageNotFoundOnCHashError']) {
1678 if ($this->tempContent
) { $this->clearPageCacheContent(); }
1679 $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash empty)');
1681 $this->set_no_cache();
1682 $GLOBALS['TT']->setTSlogMessage('TSFE->reqCHash(): No &cHash parameter was sent for GET vars though required so caching is disabled ',2);
1688 * Splits the input query-parameters into an array with certain parameters filtered out.
1689 * Used to create the cHash value
1691 * @param string Query-parameters: "&xxx=yyy&zzz=uuu"
1692 * @return array Array with key/value pairs of query-parameters WITHOUT a certain list of variable names (like id, type, no_cache etc) and WITH a variable, encryptionKey, specific for this server/installation
1694 * @see makeCacheHash(), tslib_cObj::typoLink()
1697 function cHashParams($addQueryParams) {
1698 return t3lib_div
::cHashParams($addQueryParams);
1702 * Initialize the TypoScript template parser
1706 function initTemplate() {
1707 $this->tmpl
= t3lib_div
::makeInstance('t3lib_TStemplate');
1708 $this->tmpl
->init();
1709 $this->tmpl
->tt_track
= $this->beUserLogin ?
1 : 0;
1713 * See if page is in cache and get it if so
1714 * Stores the page content in $this->content if something is found.
1718 function getFromCache() {
1719 if (!$this->no_cache
) {
1720 $cc = $this->tmpl
->getCurrentPageData();
1722 if (!is_array($cc)) {
1723 $key = $this->id
.'::'.$this->MP
;
1724 $isLocked = $this->acquirePageGenerationLock($this->pagesection_lockObj
, $key); // Returns true if the lock is active now
1725 if (!$isLocked) { // Lock is no longer active, the data in "cache_pagesection" is now ready
1726 $cc = $this->tmpl
->getCurrentPageData();
1727 if (is_array($cc)) {
1728 $this->releasePageGenerationLock($this->pagesection_lockObj
); // Release the lock
1733 if (is_array($cc)) {
1734 // BE CAREFUL to change the content of the cc-array. This array is serialized and an md5-hash based on this is used for caching the page.
1735 // If this hash is not the same in here in this section and after page-generation, then the page will not be properly cached!
1736 $cc = $this->tmpl
->matching($cc); // 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.
1744 $this->content
= ''; // clearing the content-variable, which will hold the pagecontent
1745 unset($this->config
); // Unsetting the lowlevel config
1746 $this->cacheContentFlag
= 0;
1748 // Look for page in cache only if caching is not disabled and if a shift-reload is not sent to the server.
1749 if (!$this->no_cache
&& !$this->headerNoCache()) {
1750 $lockHash = $this->getLockHash();
1753 $this->newHash
= $this->getHash();
1755 $GLOBALS['TT']->push('Cache Row','');
1756 $row = $this->getFromCache_queryRow();
1758 if (!is_array($row)) {
1759 $isLocked = $this->acquirePageGenerationLock($this->pages_lockObj
, $lockHash);
1760 if (!$isLocked) { // Lock is no longer active, the data in "cache_pages" is now ready
1761 $row = $this->getFromCache_queryRow();
1762 if (is_array($row)) {
1763 $this->releasePageGenerationLock($this->pages_lockObj
); // Release the lock
1768 if (is_array($row)) {
1769 // Release this lock
1770 $this->releasePageGenerationLock($this->pages_lockObj
);
1772 $this->config
= (array)unserialize($row['cache_data']); // Fetches the lowlevel config stored with the cached data
1773 $this->content
= $row['HTML']; // Getting the content
1774 $this->tempContent
= $row['temp_content']; // Flag for temp content
1775 $this->cacheContentFlag
= 1; // Setting flag, so we know, that some cached content has been loaded
1776 $this->cacheExpires
= $row['expires'];
1778 if ($this->TYPO3_CONF_VARS
['FE']['debug'] ||
$this->config
['config']['debug']) {
1779 $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
1780 $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
1782 $this->content
.= chr(10).'<!-- Cached page generated '.date($dateFormat.' '.$timeFormat, $row['tstamp']).'. Expires '.Date($dateFormat.' '.$timeFormat, $row['expires']).' -->';
1785 $GLOBALS['TT']->pull();
1788 $this->acquirePageGenerationLock($this->pages_lockObj
, $lockHash);
1794 * Returning the cached version of page with hash = newHash
1796 * @return array Cached row, if any. Otherwise void.
1798 function getFromCache_queryRow() {
1800 $GLOBALS['TT']->push('Cache Query','');
1801 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1803 'cache_pages S,pages P',
1804 'S.hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->newHash
, 'cache_pages').'
1806 AND S.expires > '.intval($GLOBALS['EXEC_TIME']).'
1809 AND P.starttime<='.intval($GLOBALS['EXEC_TIME']).'
1810 AND (P.endtime=0 OR P.endtime>'.intval($GLOBALS['EXEC_TIME']).')'
1812 $GLOBALS['TT']->pull();
1814 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1815 $this->pageCachePostProcess($row,'get');
1817 $GLOBALS['TYPO3_DB']->sql_free_result($res);
1822 * Detecting if shift-reload has been clicked
1823 * Will not be called if re-generation of page happens by other reasons (for instance that the page is not in cache yet!)
1824 * Also, a backend user MUST be logged in for the shift-reload to be detected due to DoS-attack-security reasons.
1826 * @return boolean If shift-reload in client browser has been clicked, disable getting cached page (and regenerate it).
1828 function headerNoCache() {
1829 $disableAcquireCacheData = FALSE;
1831 if ($this->beUserLogin
) {
1832 if (strtolower($_SERVER['HTTP_CACHE_CONTROL'])==='no-cache' ||
strtolower($_SERVER['HTTP_PRAGMA'])==='no-cache') {
1833 $disableAcquireCacheData = TRUE;
1837 // Call hook for possible by-pass of requiring of page cache (for recaching purpose)
1838 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'])) {
1839 $_params = array('pObj' => &$this, 'disableAcquireCacheData' => &$disableAcquireCacheData);
1840 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'] as $_funcRef) {
1841 t3lib_div
::callUserFunction($_funcRef,$_params,$this);
1845 return $disableAcquireCacheData;
1849 * Calculates the cache-hash
1850 * This hash is unique to the template, the variables ->id, ->type, ->gr_list (list of groups), ->MP (Mount Points) and cHash array
1851 * Used to get and later store the cached data.
1853 * @return string MD5 hash of $this->hash_base which is a serialized version of there variables.
1855 * @see getFromCache(), getLockHash()
1857 function getHash() {
1858 $this->hash_base
= serialize(
1860 'all' => $this->all
,
1861 'id' => intval($this->id
),
1862 'type' => intval($this->type
),
1863 'gr_list' => (string)$this->gr_list
,
1864 'MP' => (string)$this->MP
,
1865 'cHash' => $this->cHash_array
1869 return md5($this->hash_base
);
1873 * Calculates the lock-hash
1874 * This hash is unique to the above hash, except that it doesn't contain the template information in $this->all.
1876 * @return string MD5 hash
1878 * @see getFromCache(), getHash()
1880 function getLockHash() {
1881 $lockHash = serialize(
1883 'id' => intval($this->id
),
1884 'type' => intval($this->type
),
1885 'gr_list' => (string)$this->gr_list
,
1886 'MP' => (string)$this->MP
,
1887 'cHash' => $this->cHash_array
1891 return md5($lockHash);
1895 * Checks if config-array exists already but if not, gets it
1899 function getConfigArray() {
1900 $setStatPageName = false;
1902 if (!is_array($this->config
) ||
is_array($this->config
['INTincScript']) ||
$this->forceTemplateParsing
) { // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
1903 $GLOBALS['TT']->push('Parse template','');
1905 // Force parsing, if set?:
1906 $this->tmpl
->forceTemplateParsing
= $this->forceTemplateParsing
;
1908 // Start parsing the TS template. Might return cached version.
1909 $this->tmpl
->start($this->rootLine
);
1910 $GLOBALS['TT']->pull();
1912 if ($this->tmpl
->loaded
) {
1913 $GLOBALS['TT']->push('Setting the config-array','');
1914 // t3lib_div::print_array($this->tmpl->setup);
1915 $this->sPre
= $this->tmpl
->setup
['types.'][$this->type
]; // toplevel - objArrayName
1916 $this->pSetup
= $this->tmpl
->setup
[$this->sPre
.'.'];
1918 if (!is_array($this->pSetup
)) {
1919 header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1920 t3lib_div
::sysLog('The page is not configured! [type= '.$this->type
.']['.$this->sPre
.']', 'cms', 3);
1921 $this->printError('The page is not configured! [type= '.$this->type
.']['.$this->sPre
.']');
1924 $this->config
['config']=Array();
1926 // Filling the config-array.
1927 if (is_array($this->tmpl
->setup
['config.'])) {
1928 $this->config
['config'] = $this->tmpl
->setup
['config.'];
1930 if (is_array($this->pSetup
['config.'])) {
1931 reset($this->pSetup
['config.']);
1932 while(list($theK,$theV)=each($this->pSetup
['config.'])) {
1933 $this->config
['config'][$theK] = $theV;
1936 // if .simulateStaticDocuments was not present, the default value will rule.
1937 if (!isset($this->config
['config']['simulateStaticDocuments'])) {
1938 $this->config
['config']['simulateStaticDocuments'] = trim($this->TYPO3_CONF_VARS
['FE']['simulateStaticDocuments']);
1940 if ($this->config
['config']['simulateStaticDocuments']) {
1941 // Set replacement char only if it is needed
1942 $this->setSimulReplacementChar();
1945 if ($this->config
['config']['typolinkEnableLinksAcrossDomains']) {
1946 $this->config
['config']['typolinkCheckRootline'] = true;
1949 // Set default values for removeDefaultJS, inlineStyle2TempFile and minifyJS so CSS and JS are externalized/minified if compatversion is higher than 4.0
1950 if (t3lib_div
::compat_version('4.0')) {
1951 if (!isset($this->config
['config']['removeDefaultJS'])) {
1952 $this->config
['config']['removeDefaultJS'] = 'external';
1954 if (!isset($this->config
['config']['inlineStyle2TempFile'])) {
1955 $this->config
['config']['inlineStyle2TempFile'] = 1;
1957 if (!isset($this->config
['config']['minifyJS'])) {
1958 $this->config
['config']['minifyJS'] = 1;
1962 // Processing for the config_array:
1963 $this->config
['rootLine'] = $this->tmpl
->rootLine
;
1964 $this->config
['mainScript'] = trim($this->config
['config']['mainScript']) ?
trim($this->config
['config']['mainScript']) : 'index.php';
1967 $theLogFile = $this->TYPO3_CONF_VARS
['FE']['logfile_dir'].strftime($this->config
['config']['stat_apache_logfile']);
1968 // Add PATH_site left to $theLogFile if the path is not absolute yet
1969 if (!t3lib_div
::isAbsPath($theLogFile)) $theLogFile = PATH_site
.$theLogFile;
1971 if ($this->config
['config']['stat_apache'] && $this->config
['config']['stat_apache_logfile'] && !strstr($this->config
['config']['stat_apache_logfile'],'/')) {
1972 if (t3lib_div
::isAllowedAbsPath($theLogFile)) {
1973 if (!@is_file
($theLogFile)) {
1974 touch($theLogFile); // Try to create the logfile
1975 t3lib_div
::fixPermissions($theLogFile);
1978 if (@is_file
($theLogFile) && @is_writable
($theLogFile)) {
1979 $this->config
['stat_vars']['logFile'] = $theLogFile;
1980 $setStatPageName = true; // Set page name later on
1982 $GLOBALS['TT']->setTSlogMessage('Could not set logfile path. Check filepath and permissions.',3);
1987 $this->config
['FEData'] = $this->tmpl
->setup
['FEData'];
1988 $this->config
['FEData.'] = $this->tmpl
->setup
['FEData.'];
1990 $GLOBALS['TT']->pull();
1992 header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1993 t3lib_div
::sysLog('No template found!', 'cms', 3);
1994 $this->printError('No template found!');
1999 // Initialize charset settings etc.
2000 $this->initLLvars();
2002 // We want nice names, so we need to handle the charset
2003 if ($setStatPageName) {
2004 // Make life easier and accept variants for utf-8
2005 if (preg_match('/utf-?8/i', $this->config
['config']['stat_apache_niceTitle'])) {
2006 $this->config
['config']['stat_apache_niceTitle'] = 'utf-8';
2008 if ($this->config
['config']['stat_apache_niceTitle'] == 'utf-8') {
2009 $shortTitle = $this->csConvObj
->utf8_encode($this->page
['title'],$this->renderCharset
);
2010 } elseif ($this->config
['config']['stat_apache_niceTitle']) {
2011 $shortTitle = $this->csConvObj
->specCharsToASCII($this->renderCharset
,$this->page
['title']);
2013 $shortTitle = $this->page
['title'];
2015 $len = t3lib_div
::intInRange($this->config
['config']['stat_apache_pageLen'],1,100,30);
2016 if ($this->config
['config']['stat_apache_niceTitle'] == 'utf-8') {
2017 $shortTitle = rawurlencode($this->csConvObj
->substr('utf-8',$shortTitle,0,$len));
2019 $shortTitle = substr(preg_replace('/[^.[:alnum:]_-]/','_',$shortTitle),0,$len);
2021 $pageName = $this->config
['config']['stat_apache_pagenames'] ?
$this->config
['config']['stat_apache_pagenames'] : '[path][title]--[uid].html';
2022 $pageName = str_replace('[title]', $shortTitle ,$pageName);
2023 $pageName = str_replace('[uid]',$this->page
['uid'],$pageName);
2024 $pageName = str_replace('[alias]',$this->page
['alias'],$pageName);
2025 $pageName = str_replace('[type]',$this->type
,$pageName);
2026 $temp = $this->config
['rootLine'];
2028 if ($this->config
['config']['stat_apache_noRoot']) {
2031 $len = t3lib_div
::intInRange($this->config
['config']['stat_titleLen'],1,100,20);
2032 if ($this->config
['config']['stat_apache_niceTitle'] == 'utf-8') {
2035 for ($i=0; $i<$c; $i++
) {
2036 if ($temp[$i]['uid']) {
2037 $p = $this->csConvObj
->crop('utf-8',$this->csConvObj
->utf8_encode($temp[$i]['title'],$this->renderCharset
),$len,"\xE2\x80\xA6"); // U+2026; HORIZONTAL ELLIPSIS
2038 $path .= '/' . rawurlencode($p);
2041 } elseif ($this->config
['config']['stat_apache_niceTitle']) {
2042 $path = $this->csConvObj
->specCharsToASCII($this->renderCharset
,$this->sys_page
->getPathFromRootline($temp,$len));
2044 $path = $this->sys_page
->getPathFromRootline($temp,$len);
2046 if ($this->config
['config']['stat_apache_niceTitle'] == 'utf-8') {
2047 $this->config
['stat_vars']['pageName'] = str_replace('[path]', $path.'/', $pageName);
2049 $this->config
['stat_vars']['pageName'] = str_replace('[path]', preg_replace('/[^.[:alnum:]\/_-]/','_',$path.'/'), $pageName);
2054 if ($this->config
['config']['no_cache']) { $this->set_no_cache(); } // Set $this->no_cache true if the config.no_cache value is set!
2056 // Check PATH_INFO url
2057 if ($this->absRefPrefix_force
&& strcmp($this->config
['config']['simulateStaticDocuments'],'PATH_INFO')) {
2058 $redirectUrl = t3lib_div
::getIndpEnv('TYPO3_REQUEST_DIR').'index.php?id='.$this->id
.'&type='.$this->type
;
2059 if ($this->config
['config']['simulateStaticDocuments_dontRedirectPathInfoError']) {
2060 header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
2061 t3lib_div
::sysLog('PATH_INFO was not configured for this website, and the URL tries to find the page by PATH_INFO!', 'cms', 3);
2062 $this->printError('PATH_INFO was not configured for this website, and the URL tries to find the page by PATH_INFO!<br /><br /><a href="'.htmlspecialchars($redirectUrl).'">Click here to get to the right page.</a>','Error: PATH_INFO not configured');
2064 header('Location: '.t3lib_div
::locationHeaderUrl($redirectUrl));
2067 // $this->set_no_cache(); // Set no_cache if PATH_INFO is NOT used as simulateStaticDoc. and if absRefPrefix_force shows that such an URL has been passed along.
2084 /********************************************
2086 * Further initialization and data processing
2087 * (jumpurl/submission of forms)
2089 *******************************************/
2092 * Get the compressed $TCA array for use in the front-end
2093 * A compressed $TCA array holds only the ctrl- and feInterface-part for each table. But the column-definitions are omitted in order to save some memory and be more efficient.
2094 * Operates on the global variable, $TCA
2099 function getCompressedTCarray() {
2102 $GLOBALS['TT']->push('Get Compressed TC array');
2103 if (!$this->TCAloaded
) {
2104 // Create hash string for storage / retrieval of cached content:
2105 $tempHash = md5('tables.php:'.
2106 filemtime(TYPO3_extTableDef_script ? PATH_typo3conf
.TYPO3_extTableDef_script
: PATH_t3lib
.'stddb/tables.php').
2107 (TYPO3_extTableDef_script?
filemtime(PATH_typo3conf
.TYPO3_extTableDef_script
):'').
2108 ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] ?
filemtime(PATH_typo3conf
.$GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'].'_ext_tables.php') : '')
2111 list($TCA,$this->TCAcachedExtras
) = unserialize($this->sys_page
->getHash($tempHash, 0));
2112 // If no result, create it:
2113 if (!is_array($TCA)) {
2114 $this->includeTCA(0);
2116 $this->TCAcachedExtras
= array(); // Collects other information
2118 foreach($TCA as $key => $val) {
2119 $newTc[$key]['ctrl'] = $val['ctrl'];
2120 $newTc[$key]['feInterface'] = $val['feInterface'];
2122 // Collect information about localization exclusion of fields:
2123 t3lib_div
::loadTCA($key);
2124 if (is_array($TCA[$key]['columns'])) {
2125 $this->TCAcachedExtras
[$key]['l10n_mode'] = array();
2126 foreach($TCA[$key]['columns'] as $fN => $fV) {
2127 if ($fV['l10n_mode']) {
2128 $this->TCAcachedExtras
[$key]['l10n_mode'][$fN] = $fV['l10n_mode'];
2134 // Store it in cache:
2136 $this->sys_page
->storeHash($tempHash, serialize(array($newTc,$this->TCAcachedExtras
)), 'SHORT TC');
2139 $GLOBALS['TT']->pull();
2143 * Includes full TCA.
2144 * Normally in the frontend only a part of the global $TCA array is loaded, for instance the "ctrl" part. Thus it doesn't take up too much memory.
2145 * If you need the FULL TCA available for some reason (like plugins using it) you should call this function which will include the FULL TCA.
2146 * Global vars $TCA, $PAGES_TYPES, $LANG_GENERAL_LABELS can/will be affected.
2147 * The flag $this->TCAloaded will make sure that such an inclusion happens only once since; If $this->TCAloaded is set, nothing is included.
2149 * @param boolean Probably, keep hands of this value. Just don't set it. (This may affect the first-ever time this function is called since if you set it to zero/false any subsequent call will still trigger the inclusion; In other words, this value will be set in $this->TCAloaded after inclusion and therefore if its false, another inclusion will be possible on the next call. See ->getCompressedTCarray())
2151 * @see getCompressedTCarray()
2153 function includeTCA($TCAloaded=1) {
2154 global $TCA, $PAGES_TYPES, $LANG_GENERAL_LABELS, $TBE_MODULES;
2155 if (!$this->TCAloaded
) {
2157 include (TYPO3_tables_script ? PATH_typo3conf
.TYPO3_tables_script
: PATH_t3lib
.'stddb/tables.php');
2158 // Extension additions
2159 if ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE']) {
2160 include(PATH_typo3conf
.$GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'].'_ext_tables.php');
2162 include(PATH_t3lib
.'stddb/load_ext_tables.php');
2165 if (TYPO3_extTableDef_script
) {
2166 include (PATH_typo3conf
.TYPO3_extTableDef_script
);
2169 $this->TCAloaded
= $TCAloaded;
2174 * Setting the language key that'll be used by the current page.
2175 * In this function it should be checked, 1) that this language exists, 2) that a page_overlay_record exists, .. and if not the default language, 0 (zero), should be set.
2180 function settingLanguage() {
2182 // Get values from TypoScript:
2183 $this->sys_language_uid
= $this->sys_language_content
= intval($this->config
['config']['sys_language_uid']);
2184 list($this->sys_language_mode
,$sys_language_content) = t3lib_div
::trimExplode(';', $this->config
['config']['sys_language_mode']);
2185 $this->sys_language_contentOL
= $this->config
['config']['sys_language_overlay'];
2187 // If sys_language_uid is set to another language than default:
2188 if ($this->sys_language_uid
>0) {
2189 // Request the overlay record for the sys_language_uid:
2190 $olRec = $this->sys_page
->getPageOverlay($this->id
, $this->sys_language_uid
);
2191 if (!count($olRec)) {
2193 // If no OL record exists and a foreign language is asked for...
2194 if ($this->sys_language_uid
) {
2196 // If requested translation is not available:
2197 if (t3lib_div
::hideIfNotTranslated($this->page
['l18n_cfg'])) {
2198 $this->pageNotFoundAndExit('Page is not available in the requested language.');
2200 switch((string)$this->sys_language_mode
) {
2202 $this->pageNotFoundAndExit('Page is not available in the requested language (strict).');
2204 case 'content_fallback':
2205 $fallBackOrder = t3lib_div
::intExplode(',', $sys_language_content);
2206 foreach($fallBackOrder as $orderValue) {
2207 if (!strcmp($orderValue,'0') ||
count($this->sys_page
->getPageOverlay($this->id
, $orderValue))) {
2208 $this->sys_language_content
= $orderValue; // Setting content uid (but leaving the sys_language_uid)
2214 $this->sys_language_content
= $this->sys_language_uid
;
2217 // Default is that everything defaults to the default language...
2218 $this->sys_language_uid
= $this->sys_language_content
= 0;
2224 // Setting sys_language if an overlay record was found (which it is only if a language is used)
2225 $this->page
= $this->sys_page
->getPageOverlay($this->page
, $this->sys_language_uid
);
2229 // Setting sys_language_uid inside sys-page:
2230 $this->sys_page
->sys_language_uid
= $this->sys_language_uid
;
2232 // If default translation is not available:
2233 if ((!$this->sys_language_uid ||
!$this->sys_language_content
) && $this->page
['l18n_cfg']&1) {
2234 $this->pageNotFoundAndExit('Page is not available in default language.');
2237 // Updating content of the two rootLines IF the language key is set!
2238 if ($this->sys_language_uid
&& is_array($this->tmpl
->rootLine
)) {
2239 reset($this->tmpl
->rootLine
);
2240 while(list($rLk)=each($this->tmpl
->rootLine
)) {
2241 $this->tmpl
->rootLine
[$rLk] = $this->sys_page
->getPageOverlay($this->tmpl
->rootLine
[$rLk]);
2244 if ($this->sys_language_uid
&& is_array($this->rootLine
)) {
2245 reset($this->rootLine
);
2246 while(list($rLk)=each($this->rootLine
)) {
2247 $this->rootLine
[$rLk] = $this->sys_page
->getPageOverlay($this->rootLine
[$rLk]);
2251 // Finding the ISO code:
2252 if (t3lib_extMgm
::isLoaded('static_info_tables') && $this->sys_language_content
) { // using sys_language_content because the ISO code only (currently) affect content selection from FlexForms - which should follow "sys_language_content"
2253 $sys_language_row = $this->sys_page
->getRawRecord('sys_language',$this->sys_language_content
,'static_lang_isocode');
2254 if (is_array($sys_language_row) && $sys_language_row['static_lang_isocode']) {
2255 $stLrow = $this->sys_page
->getRawRecord('static_languages',$sys_language_row['static_lang_isocode'],'lg_iso_2');
2256 $this->sys_language_isocode
= $stLrow['lg_iso_2'];
2260 // Setting softMergeIfNotBlank:
2261 $table_fields = t3lib_div
::trimExplode(',', $this->config
['config']['sys_language_softMergeIfNotBlank'],1);
2262 foreach($table_fields as $TF) {
2263 list($tN,$fN) = explode(':',$TF);
2264 $this->TCAcachedExtras
[$tN]['l10n_mode'][$fN] = 'mergeIfNotBlank';
2267 // Setting softExclude:
2268 $table_fields = t3lib_div
::trimExplode(',', $this->config
['config']['sys_language_softExclude'],1);
2269 foreach($table_fields as $TF) {
2270 list($tN,$fN) = explode(':',$TF);
2271 $this->TCAcachedExtras
[$tN]['l10n_mode'][$fN] = 'exclude';
2276 * Setting locale for frontend rendering
2280 function settingLocale() {
2283 if ($this->config
['config']['locale_all']) {
2284 # Change by Rene Fritz, 22/10 2002
2285 # there's a problem that PHP parses float values in scripts wrong if the locale LC_NUMERIC is set to something with a comma as decimal point
2286 # this does not work in php 4.2.3
2287 #setlocale('LC_ALL',$this->config['config']['locale_all']);
2288 #setlocale('LC_NUMERIC','en_US');
2290 # so we set all except LC_NUMERIC
2291 setlocale(LC_COLLATE
,$this->config
['config']['locale_all']);
2292 setlocale(LC_CTYPE
,$this->config
['config']['locale_all']);
2293 setlocale(LC_MONETARY
,$this->config
['config']['locale_all']);
2294 setlocale(LC_TIME
,$this->config
['config']['locale_all']);
2296 $this->localeCharset
= $this->csConvObj
->get_locale_charset($this->config
['config']['locale_all']);
2301 * Checks if any email-submissions or submission via the fe_tce
2303 * @return string "email" if a formmail has been sent, "fe_tce" if front-end data submission (like forums, guestbooks) is sent. "" if none.
2305 function checkDataSubmission() {
2307 $formtype_db = isset($_POST['formtype_db']) ||
isset($_POST['formtype_db_x']);
2308 $formtype_mail = isset($_POST['formtype_mail']) ||
isset($_POST['formtype_mail_x']);
2309 if ($formtype_db ||
$formtype_mail) {
2310 $refInfo = parse_url(t3lib_div
::getIndpEnv('HTTP_REFERER'));
2311 if (t3lib_div
::getIndpEnv('TYPO3_HOST_ONLY')==$refInfo['host'] ||
$this->TYPO3_CONF_VARS
['SYS']['doNotCheckReferer']) {
2312 if ($this->locDataCheck($_POST['locationData'])) {
2313 if ($formtype_mail) {
2315 } elseif ($formtype_db && is_array($_POST['data'])) {
2318 $GLOBALS['TT']->setTSlogMessage('"Check Data Submission": Return value: '.$ret,0);
2321 } else $GLOBALS['TT']->setTSlogMessage('"Check Data Submission": HTTP_HOST and REFERER HOST did not match when processing submitted formdata!',3);
2324 // Hook for processing data submission to extensions:
2325 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkDataSubmission'])) {
2326 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkDataSubmission'] as $_classRef) {
2327 $_procObj = &t3lib_div
::getUserObj($_classRef);
2328 $_procObj->checkDataSubmission($this);
2335 * Processes submitted user data (obsolete "Frontend TCE")
2339 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=342&cHash=fdf55adb3b
2342 $fe_tce = t3lib_div
::makeInstance('tslib_feTCE');
2343 $fe_tce->start(t3lib_div
::_POST('data'),$this->config
['FEData.']);
2344 $fe_tce->includeScripts();
2348 * Checks if a formmail submission can be sent as email
2350 * @param string The input from $_POST['locationData']
2353 * @see checkDataSubmission()
2355 function locDataCheck($locationData) {
2356 $locData = explode(':',$locationData);
2357 if (!$locData[1] ||
$this->sys_page
->checkRecord($locData[1],$locData[2],1)) {
2358 if (count($this->sys_page
->getPage($locData[0]))) { // $locData[1] -check means that a record is checked only if the locationData has a value for a record else than the page.
2360 } else $GLOBALS['TT']->setTSlogMessage('LocationData Error: The page pointed to by location data ('.$locationData.') was not accessible.',2);
2361 } else $GLOBALS['TT']->setTSlogMessage('LocationData Error: Location data ('.$locationData.') record pointed to was not accessible.',2);
2365 * Sends the emails from the formmail content object.
2369 * @see checkDataSubmission()
2371 function sendFormmail() {
2372 $formmail = t3lib_div
::makeInstance('t3lib_formmail');
2374 $EMAIL_VARS = t3lib_div
::_POST();
2375 $locationData = $EMAIL_VARS['locationData'];
2376 unset($EMAIL_VARS['locationData']);
2377 unset($EMAIL_VARS['formtype_mail'], $EMAIL_VARS['formtype_mail_x'], $EMAIL_VARS['formtype_mail_y']);
2379 $integrityCheck = $this->TYPO3_CONF_VARS
['FE']['strictFormmail'];
2381 if (!$this->TYPO3_CONF_VARS
['FE']['secureFormmail']) {
2382 // Check recipient field:
2383 $encodedFields = explode(',','recipient,recipient_copy'); // These two fields are the ones which contain recipient addresses that can be misused to send mail from foreign servers.
2384 foreach ($encodedFields as $fieldKey) {
2385 if (strlen($EMAIL_VARS[$fieldKey])) {
2386 if ($res = $this->codeString($EMAIL_VARS[$fieldKey], TRUE)) { // Decode...
2387 $EMAIL_VARS[$fieldKey] = $res; // Set value if OK
2388 } elseif ($integrityCheck) { // Otherwise abort:
2389 $GLOBALS['TT']->setTSlogMessage('"Formmail" discovered a field ('.$fieldKey.') which could not be decoded to a valid string. Sending formmail aborted due to security reasons!',3);
2392 $GLOBALS['TT']->setTSlogMessage('"Formmail" discovered a field ('.$fieldKey.') which could not be decoded to a valid string. The security level accepts this, but you should consider a correct coding though!',2);
2397 $locData = explode(':',$locationData);
2398 $record = $this->sys_page
->checkRecord($locData[1],$locData[2],1);
2399 $EMAIL_VARS['recipient'] = $record['subheader'];
2400 $EMAIL_VARS['recipient_copy'] = $this->extractRecipientCopy($record['bodytext']);
2403 // Hook for preprocessing of the content for formmails:
2404 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass'])) {
2405 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass'] as $_classRef) {
2406 $_procObj = &t3lib_div
::getUserObj($_classRef);
2407 $EMAIL_VARS = $_procObj->sendFormmail_preProcessVariables($EMAIL_VARS,$this);
2411 $formmail->start($EMAIL_VARS);
2412 $formmail->sendtheMail();
2413 $GLOBALS['TT']->setTSlogMessage('"Formmail" invoked, sending mail to '.$EMAIL_VARS['recipient'],0);
2417 * Extracts the value of recipient copy field from a formmail CE bodytext
2419 * @param string $bodytext The content of the related bodytext field
2420 * @return string The value of the recipient_copy field, or an empty string
2422 function extractRecipientCopy($bodytext) {
2423 $recipient_copy = '';
2425 //|recipient_copy=hidden|karsten@localhost.localdomain
2426 preg_match('/^[\s]*\|[\s]*recipient_copy[\s]*=[\s]*hidden[\s]*\|(.*)$/m', $bodytext, $fdef);
2427 $recipient_copy = (!empty($fdef[1])) ?
$fdef[1] : '';
2428 return $recipient_copy;
2432 * Sets the jumpurl for page type "External URL"
2436 function setExternalJumpUrl() {
2437 if ($extUrl = $this->sys_page
->getExtURL($this->page
, $this->config
['config']['disablePageExternalUrl'])) {
2438 $this->jumpurl
= $extUrl;
2443 * Checks the jumpurl referer if required
2447 function checkJumpUrlReferer() {
2448 if (strcmp($this->jumpurl
,'') && !$this->TYPO3_CONF_VARS
['SYS']['doNotCheckReferer']) {
2449 $referer = parse_url(t3lib_div
::getIndpEnv('HTTP_REFERER'));
2450 if (isset($referer['host']) && !($referer['host'] == t3lib_div
::getIndpEnv('TYPO3_HOST_ONLY'))) {
2451 unset($this->jumpurl
);
2457 * Sends a header 'Location' to jumpurl, if jumpurl is set.
2458 * Will exit if a location header is sent (for instance if JumpUrl was triggered)
2462 function jumpUrl() {
2463 if ($this->jumpurl
) {
2464 if (t3lib_div
::_GP('juSecure')) {
2467 t3lib_div
::_GP('locationData'),
2468 $this->TYPO3_CONF_VARS
['SYS']['encryptionKey']
2470 $calcJuHash=t3lib_div
::shortMD5(serialize($hArr));
2471 $locationData = t3lib_div
::_GP('locationData');
2472 $juHash = t3lib_div
::_GP('juHash');
2473 if ($juHash == $calcJuHash) {
2474 if ($this->locDataCheck($locationData)) {
2475 $this->jumpurl
= rawurldecode($this->jumpurl
); // 211002 - goes with cObj->filelink() rawurlencode() of filenames so spaces can be allowed.
2476 if (@is_file
($this->jumpurl
)) {
2477 $mimeType = t3lib_div
::_GP('mimeType');
2478 $mimeType = $mimeType ?
$mimeType : 'application/octet-stream';
2479 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
2480 header('Content-Type: '.$mimeType);
2481 header('Content-Disposition: attachment; filename='.basename($this->jumpurl
));
2482 readfile($this->jumpurl
);
2484 } else die('jumpurl Secure: "'.$this->jumpurl
.'" was not a valid file!');
2485 } else die('jumpurl Secure: locationData, '.$locationData.', was not accessible.');
2486 } else die('jumpurl Secure: Calculated juHash, '.$calcJuHash.', did not match the submitted juHash.');
2488 $TSConf = $this->getPagesTSconfig();
2489 if ($TSConf['TSFE.']['jumpUrl_transferSession']) {
2490 $uParts = parse_url($this->jumpurl
);
2491 $params = '&FE_SESSION_KEY='.rawurlencode($this->fe_user
->id
.'-'.md5($this->fe_user
->id
.'/'.$this->TYPO3_CONF_VARS
['SYS']['encryptionKey']));
2492 $this->jumpurl
.= ($uParts['query']?
'':'?').$params; // Add the session parameter ...
2494 header('Location: '.$this->jumpurl
);
2501 * Sets the URL_ID_TOKEN in the internal var, $this->getMethodUrlIdToken
2506 function setUrlIdToken() {
2507 if ($this->config
['config']['ftu']) {
2508 $this->getMethodUrlIdToken
= $this->TYPO3_CONF_VARS
['FE']['get_url_id_token'];
2510 $this->getMethodUrlIdToken
= '';
2536 /********************************************
2538 * Page generation; cache handling
2540 *******************************************/
2543 * Returns true if the page should be generated
2544 * That is if jumpurl is not set and the cacheContentFlag is not set.
2548 function isGeneratePage() {
2549 return (!$this->cacheContentFlag
&& !$this->jumpurl
);
2553 * Temp cache content
2554 * The temporary cache will expire after a few seconds (typ. 30) or will be cleared by the rendered page, which will also clear and rewrite the cache.
2558 function tempPageCacheContent() {
2559 $this->tempContent
= false;
2561 if (!$this->no_cache
) {
2563 $title = htmlspecialchars($this->tmpl
->printTitle($this->page
['title']));
2564 $request_uri = htmlspecialchars(t3lib_div
::getIndpEnv('REQUEST_URI'));
2567 <strong>Page is being generated.</strong><br />
2568 If this message does not disappear within '.$seconds.' seconds, please reload.';
2570 $message = $this->config
['config']['message_page_is_being_generated'];
2571 if (strcmp('', $message)) {
2572 $message = $this->csConvObj
->utf8_encode($message,$this->renderCharset
); // This page is always encoded as UTF-8
2573 $message = str_replace('###TITLE###', $title, $message);
2574 $message = str_replace('###REQUEST_URI###', $request_uri, $message);
2575 } else $message = $stdMsg;
2577 $temp_content = '<?xml version="1.0" encoding="UTF-8"?>
2578 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2579 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2580 <html xmlns="http://www.w3.org/1999/xhtml">
2582 <title>'.$title.'</title>
2583 <meta http-equiv="refresh" content="10" />
2585 <body style="background-color:white; font-family:Verdana,Arial,Helvetica,sans-serif; color:#cccccc; text-align:center;">'.
2590 // Fix 'nice errors' feature in modern browsers
2591 $padSuffix = '<!--pad-->'; // prevent any trims
2592 $padSize = 768 - strlen($padSuffix) - strlen($temp_content);
2594 $temp_content = str_pad($temp_content, $padSize, "\n") . $padSuffix;
2597 if (!$this->headerNoCache() && $cachedRow = $this->getFromCache_queryRow()) {
2598 // We are here because between checking for cached content earlier and now some other HTTP-process managed to store something in cache AND it was not due to a shift-reload by-pass.
2599 // This is either the "Page is being generated" screen or it can be the final result.
2600 // In any case we should not begin another rendering process also, so we silently disable caching and render the page ourselves and thats it.
2601 // Actually $cachedRow contains content that we could show instead of rendering. Maybe we should do that to gain more performance but then we should set all the stuff done in $this->getFromCache()... For now we stick to this...
2602 $this->set_no_cache();
2604 $this->tempContent
= TRUE; // This flag shows that temporary content is put in the cache
2605 $this->setPageCacheContent($temp_content, $this->config
, $GLOBALS['EXEC_TIME']+
$seconds);
2611 * Set cache content to $this->content
2615 function realPageCacheContent() {
2616 $cache_timeout = $this->get_cache_timeout(); // seconds until a cached page is too old
2617 $timeOutTime = $GLOBALS['EXEC_TIME']+
$cache_timeout;
2618 if ($this->config
['config']['cache_clearAtMidnight']) {
2619 $midnightTime = mktime (0,0,0,date('m',$timeOutTime),date('d',$timeOutTime),date('Y',$timeOutTime));
2620 if ($midnightTime > $GLOBALS['EXEC_TIME']) { // If the midnight time of the expire-day is greater than the current time, we may set the timeOutTime to the new midnighttime.
2621 $timeOutTime = $midnightTime;
2624 $this->tempContent
= false;
2625 $this->setPageCacheContent($this->content
, $this->config
, $timeOutTime);
2627 // Hook for cache post processing (eg. writing static files!)
2628 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'])) {
2629 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'] as $_classRef) {
2630 $_procObj = &t3lib_div
::getUserObj($_classRef);
2631 $_procObj->insertPageIncache($this,$timeOutTime);
2637 * Sets cache content; Inserts the content string into the cache_pages table.
2639 * @param string The content to store in the HTML field of the cache table
2640 * @param mixed The additional cache_data array, fx. $this->config
2641 * @param integer Timestamp
2643 * @see realPageCacheContent(), tempPageCacheContent()
2645 function setPageCacheContent($content,$data,$tstamp) {
2646 $this->clearPageCacheContent();
2647 $insertFields = array(
2648 'hash' => $this->newHash
,
2649 'page_id' => $this->id
,
2651 'temp_content' => $this->tempContent
,
2652 'cache_data' => serialize($data),
2653 'expires' => $tstamp,
2654 'tstamp' => $GLOBALS['EXEC_TIME']
2657 $this->cacheExpires
= $tstamp;
2659 if ($this->page_cache_reg1
) {
2660 $insertFields['reg1'] = intval($this->page_cache_reg1
);
2662 $this->pageCachePostProcess($insertFields,'set');
2664 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pages', $insertFields);
2668 * Clears cache content (for $this->newHash)
2672 function clearPageCacheContent() {
2673 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->newHash
, 'cache_pages'));
2677 * Clears cache content for a list of page ids
2679 * @param string A list of INTEGER numbers which points to page uids for which to clear entries in the cache_pages table (page content cache)
2682 function clearPageCacheContent_pidList($pidList) {
2683 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'page_id IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($pidList).')');
2687 * Post processing page cache rows for both get and set.
2689 * @param array Input "cache_pages" row, passed by reference!
2690 * @param string Type of operation, either "get" or "set"
2693 function pageCachePostProcess(&$row,$type) {
2695 if ($this->TYPO3_CONF_VARS
['FE']['pageCacheToExternalFiles']) {
2696 $cacheFileName = PATH_site
.'typo3temp/cache_pages/'.$row['hash']{0}.$row['hash']{1}.'/'.$row['hash'].'.html';
2697 switch((string)$type) {
2699 $row['HTML'] = @is_file
($cacheFileName) ? t3lib_div
::getUrl($cacheFileName) : '<!-- CACHING ERROR, sorry -->';
2702 t3lib_div
::writeFileToTypo3tempDir($cacheFileName,$row['HTML']);
2710 * Sets sys last changed
2711 * Setting the SYS_LASTCHANGED value in the pagerecord: This value will thus be set to the highest tstamp of records rendered on the page. This includes all records with no regard to hidden records, userprotection and so on.
2714 * @see tslib_cObj::lastChanged()
2716 function setSysLastChanged() {
2717 if ($this->page
['SYS_LASTCHANGED'] < intval($this->register
['SYS_LASTCHANGED'])) {
2718 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid='.intval($this->id
), array('SYS_LASTCHANGED' => intval($this->register
['SYS_LASTCHANGED'])));
2723 * Lock the page generation process
2724 * The lock is used to queue page requests until this page is successfully stored in the cache.
2726 * @param object Reference to a locking object
2727 * @param string String to identify the lock in the system
2728 * @return boolean Returns true if the lock could be obtained, false otherwise (= process had to wait for existing lock to be released)
2729 * @see releasePageGenerationLock()
2731 function acquirePageGenerationLock(&$lockObj, $key) {
2732 if ($this->no_cache ||
$this->headerNoCache()) {
2733 return true; // No locking is needed if caching is disabled
2737 if (!is_object($lockObj)) {
2738 $className = t3lib_div
::makeInstanceClassName('t3lib_lock');
2739 $lockObj = new $className($key, $this->TYPO3_CONF_VARS
['SYS']['lockingMode']);
2744 // true = Page could get locked without blocking
2745 // false = Page could get locked but process was blocked before
2746 $success = $lockObj->acquire();
2748 } catch (Exception
$e) {
2749 t3lib_div
::sysLog('Locking failed: '.$e->getMessage(), 'cms', 3);
2750 $success = false; // If locking fails, return with false and continue without locking
2757 * Release the page generation lock
2759 * @param object Reference to a locking object
2760 * @return boolean Returns true on success, false otherwise
2761 * @see acquirePageGenerationLock()
2763 function releasePageGenerationLock(&$lockObj) {
2764 if ($this->no_cache ||
$this->headerNoCache()) {
2765 return true; // No locking is needed if caching is disabled
2769 if (is_object($lockObj)) {
2770 $success = $lockObj->release();
2796 /********************************************
2798 * Page generation; rendering and inclusion
2800 *******************************************/
2803 * Does some processing BEFORE the pagegen script is included.
2807 function generatePage_preProcessing() {
2808 $this->newHash
= $this->getHash(); // Same codeline as in getFromCache(). But $this->all has been changed by t3lib_TStemplate::start() in the meantime, so this must be called again!
2809 $this->config
['hash_base'] = $this->hash_base
; // For cache management informational purposes.
2811 if (!is_object($this->pages_lockObj
) ||
$this->pages_lockObj
->getLockStatus()==false) {
2812 // Here we put some temporary stuff in the cache in order to let the first hit generate the page. The temporary cache will expire after a few seconds (typ. 30) or will be cleared by the rendered page, which will also clear and rewrite the cache.
2813 $this->tempPageCacheContent();
2816 // Setting cache_timeout_default. May be overridden by PHP include scritps.
2817 $this->cacheTimeOutDefault
= intval($this->config
['config']['cache_period']);
2819 // page is generated
2820 $this->no_cacheBeforePageGen
= $this->no_cache
;
2824 * Determines to include custom or pagegen.php script
2825 * returns script-filename if a TypoScript (config) script is defined and should be include instead of pagegen.php
2827 * @return string The relative filepath of "config.pageGenScript" if found and allowed
2829 function generatePage_whichScript() {
2830 if (!$this->TYPO3_CONF_VARS
['FE']['noPHPscriptInclude'] && $this->config
['config']['pageGenScript']) {
2831 return $this->tmpl
->getFileName($this->config
['config']['pageGenScript']);
2836 * Does some processing AFTER the pagegen script is included.
2837 * This includes calling tidy (if configured), XHTML cleaning (if configured), caching the page, indexing the page (if configured) and setting sysLastChanged
2841 function generatePage_postProcessing() {
2842 // This is to ensure, that the page is NOT cached if the no_cache parameter was set before the page was generated. This is a safety precaution, as it could have been unset by some script.
2843 if ($this->no_cacheBeforePageGen
) $this->set_no_cache();
2845 // Tidy up the code, if flag...
2846 if ($this->TYPO3_CONF_VARS
['FE']['tidy_option'] == 'all') {
2847 $GLOBALS['TT']->push('Tidy, all','');
2848 $this->content
= $this->tidyHTML($this->content
);
2849 $GLOBALS['TT']->pull();
2852 // XHTML-clean the code, if flag set
2853 if ($this->doXHTML_cleaning() == 'all') {
2854 $GLOBALS['TT']->push('XHTML clean, all','');
2855 $XHTML_clean = t3lib_div
::makeInstance('t3lib_parsehtml');
2856 $this->content
= $XHTML_clean->XHTML_clean($this->content
);
2857 $GLOBALS['TT']->pull();
2860 // Fix local anchors in links, if flag set
2861 if ($this->doLocalAnchorFix() == 'all') {
2862 $GLOBALS['TT']->push('Local anchor fix, all','');
2863 $this->prefixLocalAnchorsWithScript();
2864 $GLOBALS['TT']->pull();
2867 // Hook for post-processing of page content cached/non-cached:
2868 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'])) {
2869 $_params = array('pObj' => &$this);
2870 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'] as $_funcRef) {
2871 t3lib_div
::callUserFunction($_funcRef,$_params,$this);
2875 // Processing if caching is enabled:
2876 if (!$this->no_cache
) {
2877 // Tidy up the code, if flag...
2878 if ($this->TYPO3_CONF_VARS
['FE']['tidy_option'] == 'cached') {
2879 $GLOBALS['TT']->push('Tidy, cached','');
2880 $this->content
= $this->tidyHTML($this->content
);
2881 $GLOBALS['TT']->pull();
2883 // XHTML-clean the code, if flag set
2884 if ($this->doXHTML_cleaning() == 'cached') {
2885 $GLOBALS['TT']->push('XHTML clean, cached','');
2886 $XHTML_clean = t3lib_div
::makeInstance('t3lib_parsehtml');
2887 $this->content
= $XHTML_clean->XHTML_clean($this->content
);
2888 $GLOBALS['TT']->pull();
2890 // Fix local anchors in links, if flag set
2891 if ($this->doLocalAnchorFix() == 'cached') {
2892 $GLOBALS['TT']->push('Local anchor fix, cached','');
2893 $this->prefixLocalAnchorsWithScript();
2894 $GLOBALS['TT']->pull();
2897 // Hook for post-processing of page content before being cached:
2898 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'])) {
2899 $_params = array('pObj' => &$this);
2900 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'] as $_funcRef) {
2901 t3lib_div
::callUserFunction($_funcRef,$_params,$this);