Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2007 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00213 class tslib_fe { 00214 00215 // CURRENT PAGE: 00216 var $id=''; // The page id (int) 00217 var $type=''; // RO The type (int) 00218 var $idParts=array(); // Loaded with the id, exploded by ',' 00219 var $cHash=''; // The submitted cHash 00220 var $no_cache=''; // Page will not be cached. Write only true. Never clear value (some other code might have reasons to set it true) 00221 var $rootLine=''; // The rootLine (all the way to tree root, not only the current site!) (array) 00222 var $page=''; // The pagerecord (array) 00223 var $contentPid=0; // This will normally point to the same value as id, but can be changed to point to another page from which content will then be displayed instead. 00224 var $sys_page=''; // The object with pagefunctions (object) 00225 var $jumpurl=''; 00226 var $pageNotFound=0; // Is set to 1 if a pageNotFound handler could have been called. 00227 var $domainStartPage=0; // Domain start page 00228 var $pageAccessFailureHistory=array(); // Array containing a history of why a requested page was not accessible. 00229 var $MP=''; 00230 var $RDCT=''; 00231 var $page_cache_reg1=0; // This can be set from applications as a way to tag cached versions of a page and later perform some external cache management, like clearing only a part of the cache of a page... 00232 var $siteScript=''; // Contains the value of the current script path that activated the frontend. Typically "index.php" but by rewrite rules it could be something else! Used for Speaking Urls / Simulate Static Documents. 00233 00234 // USER 00235 var $fe_user=''; // The user (object) 00236 var $loginUser=''; // Global flag indicating that a front-end user is logged in. This is set only if a user really IS logged in. The group-list may show other groups (like added by IP filter or so) even though there is no user. 00237 var $gr_list=''; // (RO=readonly) The group list, sorted numerically. Group '0,-1' is the default group, but other groups may be added by other means than a user being logged in though... 00238 var $beUserLogin=''; // Flag that indicates if a Backend user is logged in! 00239 var $workspacePreview=''; // Integer, that indicates which workspace is being previewed. 00240 var $loginAllowedInBranch = TRUE; // Shows whether logins are allowed in branch 00241 var $ADMCMD_preview_BEUSER_uid = 0; // Integer, set to backend user ID to initialize when keyword-based preview is used. 00242 00243 // PREVIEW 00244 var $fePreview=''; // Flag indication that preview is active. This is based on the login of a backend user and whether the backend user has read access to the current page. A value of 1 means ordinary preview, 2 means preview of a non-live workspace 00245 var $showHiddenPage=''; // Flag indicating that hidden pages should be shown, selected and so on. This goes for almost all selection of pages! 00246 var $showHiddenRecords=''; // Flag indicating that hidden records should be shown. This includes sys_template, pages_language_overlay and even fe_groups in addition to all other regular content. So in effect, this includes everything except pages. 00247 var $simUserGroup='0'; // Value that contains the simulated usergroup if any 00248 00249 // CONFIGURATION 00250 var $TYPO3_CONF_VARS=array(); // The configuration array as set up in t3lib/config_default.php. Should be an EXACT copy of the global array. 00251 var $config=''; // 'CONFIG' object from TypoScript. Array generated based on the TypoScript configuration of the current page. Saved with the cached pages. 00252 var $TCAcachedExtras=array(); // Array of cached information from TCA. This is NOT TCA itself! 00253 00254 // TEMPLATE / CACHE 00255 var $tmpl=''; // The TypoScript template object. Used to parse the TypoScript template 00256 var $cacheTimeOutDefault=''; // Is set to the time-to-live time of cached pages. If false, default is 60*60*24, which is 24 hours. 00257 var $cacheContentFlag=''; // Set internally if cached content is fetched from the database 00258 var $cacheExpires=0; // Set to the expire time of cached content 00259 var $isClientCachable=FALSE; // Set if cache headers allowing caching are sent. 00260 var $all=''; // $all used by template fetching system. This array is an identification of the template. If $this->all is empty it's because the template-data is not cached, which it must be. 00261 var $sPre=''; // toplevel - objArrayName, eg 'page' 00262 var $pSetup=''; // TypoScript configuration of the page-object pointed to by sPre. $this->tmpl->setup[$this->sPre.'.'] 00263 var $newHash=''; // This hash is unique to the template, the $this->id and $this->type vars and the gr_list (list of groups). Used to get and later store the cached data 00264 var $getMethodUrlIdToken=''; // If config.ftu (Frontend Track User) is set in TypoScript for the current page, the string value of this var is substituted in the rendered source-code with the string, '&ftu=[token...]' which enables GET-method usertracking as opposed to cookie based 00265 var $no_CacheBeforePageGen=''; // This flag is set before inclusion of pagegen.php IF no_cache is set. If this flag is set after the inclusion of pagegen.php, no_cache is forced to be set. This is done in order to make sure that php-code from pagegen does not falsely clear the no_cache flag. 00266 var $tempContent = FALSE; // This flag indicates if temporary content went into the cache during page-generation. 00267 var $forceTemplateParsing=''; // Boolean, passed to TypoScript template class and tells it to render the template forcibly 00268 var $cHash_array=array(); // The array which cHash_calc is based on, see ->makeCacheHash(). 00269 var $hash_base=''; // Loaded with the serialized array that is used for generating a hashstring for the cache 00270 var $pagesTSconfig=''; // May be set to the pagesTSconfig 00271 // PAGE-GENERATION / cOBJ 00272 /* 00273 Eg. insert JS-functions in this array ($additionalHeaderData) to include them once. Use associative keys. 00274 Keys in use: 00275 JSFormValidate : <script type="text/javascript" src="'.$GLOBALS["TSFE"]->absRefPrefix.'t3lib/jsfunc.validateform.js"></script> 00276 JSincludeFormupdate : <script type="text/javascript" src="t3lib/jsfunc.updateform.js"></script> 00277 JSMenuCode, JSMenuCode_menu : JavaScript for the JavaScript menu 00278 JSCode : reserved 00279 JSImgCode : reserved 00280 */ 00281 var $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[] = '...') 00282 var $additionalJavaScript=array(); // used to accumulate additional JavaScript-code. Works like additionalHeaderData. Reserved keys at 'openPic' and 'mouseOver' 00283 var $additionalCSS=array(); // used to accumulate additional Style code. Works like additionalHeaderData. 00284 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 00285 'onmousemove' => array(), 00286 'onmouseup' => array(), 00287 'onmousemove' => array(), 00288 'onkeydown' => array(), 00289 'onkeyup' => array(), 00290 'onkeypress' => array(), 00291 'onload' => array(), 00292 'onunload' => array(), 00293 ); 00294 var $JSCode=''; // Deprecated, use additionalJavaScript instead. 00295 var $JSImgCode=''; // Used to accumulate JavaScript loaded images (by menus) 00296 var $divSection=''; // Used to accumulate DHTML-layers. 00297 var $defaultBodyTag='<body>'; // Default bodytag, if nothing else is set. This can be overridden by applications like TemplaVoila. 00298 00299 // RENDERING configuration, settings from TypoScript is loaded into these vars. See pagegen.php 00300 var $debug=''; // Debug flag, may output special debug html-code. 00301 var $intTarget=''; // Default internal target 00302 var $extTarget=''; // Default external target 00303 var $MP_defaults=array(); // Keys are page ids and values are default &MP (mount point) values to set when using the linking features...) 00304 var $spamProtectEmailAddresses=0; // If set, typolink() function encrypts email addresses. Is set in pagegen-class. 00305 var $absRefPrefix=''; // Absolute Reference prefix 00306 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 '/' 00307 var $compensateFieldWidth=''; // Factor for form-field widths compensation 00308 var $lockFilePath=''; // Lock file path 00309 var $ATagParams=''; // <A>-tag parameters 00310 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. 00311 var $sWordList=''; // Is set to the incoming array sword_list in case of a page-view jumped to from a search-result. 00312 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. 00313 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. 00314 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. 00315 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. 00316 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) 00317 var $sys_language_mode=''; // Site language mode for content fall back. 00318 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) 00319 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...] 00320 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") 00321 00322 // RENDERING data 00323 var $applicationData=Array(); // 'Global' Storage for various applications. Keys should be 'tx_'.extKey for extensions. 00324 var $register=Array(); 00325 var $registerStack=Array(); // Stack used for storing array and retrieving register arrays (see LOAD_REGISTER and CLEAR_REGISTER) 00326 var $cObjectDepthCounter = 50; // Checking that the function is not called eternally. This is done by interrupting at a depth of 50 00327 var $recordRegister = Array(); // used by cObj->RECORDS and cObj->CONTENT to ensure the a records is NOT rendered twice through it! 00328 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 00329 var $accessKey =array(); // Used by class tslib_menu to keep track of access-keys. 00330 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. 00331 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 00332 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() 00333 var $uniqueString=''; 00334 var $indexedDocTitle=''; // This value will be used as the title for the page in the indexer (if indexing happens) 00335 var $altPageTitle=''; // Alternative page title (normally the title of the page record). Can be set from applications you make. 00336 var $pEncAllowedParamNames=array(); // An array that holds parameter names (keys) of GET parameters which MAY be MD5/base64 encoded with simulate_static_documents method. 00337 var $baseUrl=''; // The base URL set for the page header. 00338 var $anchorPrefix=''; // The proper anchor prefix needed when using speaking urls. (only set if baseUrl is set) 00339 00340 // Page content render object 00341 var $cObj =''; // is instantiated object of tslib_cObj 00342 00343 // CONTENT accumulation 00344 var $content=''; // All page content is accumulated in this variable. See pagegen.php 00345 00346 // GENERAL 00347 var $clientInfo=''; // Set to the browser: net / msie if 4+ browsers 00348 var $scriptParseTime=0; 00349 var $TCAloaded = 0; // Set ONLY if the full TCA is loaded 00350 00351 // Character set (charset) conversion object: 00352 var $csConvObj; // An instance of the "t3lib_cs" class. May be used by any application. 00353 var $defaultCharSet = 'iso-8859-1'; // The default charset used in the frontend if nothing else is set. 00354 var $renderCharset=''; // Internal charset of the frontend during rendering: Defaults to "forceCharset" and if that is not set, to ->defaultCharSet 00355 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. 00356 var $localeCharset=''; // Assumed charset of locale strings. 00357 00358 // LANG: 00359 var $lang=''; // Set to the system language key (used on the site) 00360 var $langSplitIndex=0; // Set to the index number of the language key 00361 var $labelsCharset=''; // Charset of the labels from locallang (based on $this->lang) 00362 var $convCharsetToFrom=''; // Set to the charsets to convert from/to IF there are any difference. Otherwise this stays a string 00363 var $LL_labels_cache=array(); 00364 var $LL_files_cache=array(); 00365 00366 00367 00368 00369 00387 function tslib_fe($TYPO3_CONF_VARS, $id, $type, $no_cache='', $cHash='', $jumpurl='',$MP='',$RDCT='') { 00388 00389 // Setting some variables: 00390 $this->TYPO3_CONF_VARS = $TYPO3_CONF_VARS; 00391 $this->id = $id; 00392 $this->type = $type; 00393 $this->no_cache = $no_cache ? 1 : 0; 00394 $this->cHash = $cHash; 00395 $this->jumpurl = $jumpurl; 00396 $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? (string)$MP : ''; 00397 $this->RDCT = $RDCT; 00398 $this->clientInfo = t3lib_div::clientInfo(); 00399 $this->uniqueString=md5(microtime()); 00400 00401 $this->csConvObj = t3lib_div::makeInstance('t3lib_cs'); 00402 00403 // Call post processing function for constructor: 00404 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'])) { 00405 $_params = array('pObj' => &$this); 00406 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef) { 00407 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00408 } 00409 } 00410 } 00411 00420 function connectToMySQL() { 00421 $this->connectToDB(); 00422 } 00423 00430 function connectToDB() { 00431 if ($GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { 00432 if (!TYPO3_db) { 00433 $this->printError('No database selected','Database Error'); 00434 // Redirects to the Install Tool: 00435 echo '<script type="text/javascript"> 00436 /*<![CDATA[*/ 00437 window.location.href = "'.TYPO3_mainDir.'install/index.php?mode=123&step=1&password=joh316"; 00438 /*]]>*/ 00439 </script>'; 00440 exit; 00441 } elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) { 00442 $this->printError('Cannot connect to the current database, "'.TYPO3_db.'"','Database Error'); 00443 exit; 00444 } 00445 } else { 00446 if (!TYPO3_db) { 00447 // Redirects to the Install Tool: 00448 echo '<script type="text/javascript"> 00449 /*<![CDATA[*/ 00450 window.location.href = "'.TYPO3_mainDir.'install/index.php?mode=123&step=1&password=joh316"; 00451 /*]]>*/ 00452 </script>'; 00453 exit; 00454 } 00455 $this->printError('The current username, password or host was not accepted when the connection to the database was attempted to be established!','Database Error'); 00456 exit; 00457 } 00458 00459 00460 // Call post processing function for DB connection: 00461 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'])) { 00462 $_params = array('pObj' => &$this); 00463 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'] as $_funcRef) { 00464 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00465 } 00466 } 00467 } 00468 00475 function sendRedirect() { 00476 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->RDCT, 'cache_md5params')); 00477 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00478 $this->updateMD5paramsRecord($this->RDCT); 00479 header('Location: '.$row['params']); 00480 exit; 00481 } 00482 } 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 /******************************************** 00502 * 00503 * Initializing, resolving page id 00504 * 00505 ********************************************/ 00506 00507 00513 function initFEuser() { 00514 $this->fe_user = t3lib_div::makeInstance('tslib_feUserAuth'); 00515 00516 $this->fe_user->lockIP = $this->TYPO3_CONF_VARS['FE']['lockIP']; 00517 $this->fe_user->lockHashKeyWords = $this->TYPO3_CONF_VARS['FE']['lockHashKeyWords']; 00518 $this->fe_user->checkPid = $this->TYPO3_CONF_VARS['FE']['checkFeUserPid']; 00519 $this->fe_user->lifetime = intval($this->TYPO3_CONF_VARS['FE']['lifetime']); 00520 $this->fe_user->checkPid_value = $GLOBALS['TYPO3_DB']->cleanIntList(t3lib_div::_GP('pid')); // List of pid's acceptable 00521 00522 // Check if a session is transferred: 00523 if (t3lib_div::_GP('FE_SESSION_KEY')) { 00524 $fe_sParts = explode('-',t3lib_div::_GP('FE_SESSION_KEY')); 00525 if (!strcmp(md5($fe_sParts[0].'/'.$this->TYPO3_CONF_VARS['SYS']['encryptionKey']), $fe_sParts[1])) { // If the session key hash check is OK: 00526 $_COOKIE[$this->fe_user->name] = $fe_sParts[0]; 00527 $this->fe_user->forceSetCookie = 1; 00528 } 00529 } 00530 00531 if ($this->TYPO3_CONF_VARS['FE']['dontSetCookie']) { 00532 $this->fe_user->dontSetCookie=1; 00533 } 00534 00535 $this->fe_user->start(); 00536 $this->fe_user->unpack_uc(''); 00537 $this->fe_user->fetchSessionData(); // Gets session data 00538 $recs = t3lib_div::_GP('recs'); 00539 if (is_array($recs)) { // If any record registration is submitted, register the record. 00540 $this->fe_user->record_registration($recs, $this->TYPO3_CONF_VARS['FE']['maxSessionDataSize']); 00541 } 00542 00543 // Call hook for possible manipulation of frontend user object 00544 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'])) { 00545 $_params = array('pObj' => &$this); 00546 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] as $_funcRef) { 00547 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00548 } 00549 } 00550 00551 // For every 60 seconds the is_online timestamp is updated. 00552 if (is_array($this->fe_user->user) && $this->fe_user->user['uid'] && $this->fe_user->user['is_online']<($GLOBALS['EXEC_TIME']-60)) { 00553 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid='.intval($this->fe_user->user['uid']), array('is_online' => $GLOBALS['EXEC_TIME'])); 00554 } 00555 } 00556 00563 function initUserGroups() { 00564 00565 $this->fe_user->showHiddenRecords = $this->showHiddenRecords; // This affects the hidden-flag selecting the fe_groups for the user! 00566 $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!) 00567 00568 if (is_array($this->fe_user->user) && count($this->fe_user->groupData['uid'])) { 00569 $this->loginUser=1; // global flag! 00570 $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! 00571 $gr_array = $this->fe_user->groupData['uid']; 00572 } else { 00573 $this->loginUser=0; 00574 $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! 00575 00576 if ($this->loginAllowedInBranch) { 00577 $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. 00578 } else { 00579 $gr_array = array(); // Set to blank since we will NOT risk any groups being set when no logins are allowed! 00580 } 00581 } 00582 00583 // Clean up. 00584 $gr_array = array_unique($gr_array); // Make unique... 00585 sort($gr_array); // sort 00586 if (count($gr_array)) { 00587 $this->gr_list.=','.implode(',',$gr_array); 00588 } 00589 00590 if ($this->fe_user->writeDevLog) t3lib_div::devLog('Valid usergroups for TSFE: '.$this->gr_list, 'tslib_fe'); 00591 } 00592 00598 function isUserOrGroupSet() { 00599 return is_array($this->fe_user->user) || $this->gr_list!=='0,-1'; 00600 } 00601 00623 function checkAlternativeIdMethods() { 00624 00625 $this->siteScript = t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT'); 00626 00627 // Resolving of "simulateStaticDocuments" URLs: 00628 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 00629 $uParts = parse_url($this->siteScript); // Parse the path: 00630 $fI = t3lib_div::split_fileref($uParts['path']); 00631 00632 if (!$fI['path'] && $fI['file'] && substr($fI['file'],-5)=='.html') { 00633 $parts = explode('.',$fI['file']); 00634 $pCount = count($parts); 00635 if ($pCount>2) { 00636 $this->type = intval($parts[$pCount-2]); 00637 $this->id = $parts[$pCount-3]; 00638 } else { 00639 $this->type = 0; 00640 $this->id = $parts[0]; 00641 } 00642 } 00643 } 00644 00645 // If PATH_INFO 00646 if (t3lib_div::getIndpEnv('PATH_INFO')) { // If pathinfo contains stuff... 00647 $parts=t3lib_div::trimExplode('/',t3lib_div::getIndpEnv('PATH_INFO'),1); 00648 $parts[]='html'; 00649 $pCount = count($parts); 00650 if ($pCount>2) { 00651 $this->type = intval($parts[$pCount-2]); 00652 $this->id = $parts[$pCount-3]; 00653 } else { 00654 $this->type = 0; 00655 $this->id = $parts[0]; 00656 } 00657 $this->absRefPrefix_force=1; 00658 } 00659 00660 // Call post processing function for custom URL methods. 00661 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'])) { 00662 $_params = array('pObj' => &$this); 00663 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef) { 00664 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00665 } 00666 } 00667 } 00668 00675 function clear_preview() { 00676 $this->showHiddenPage = 0; 00677 $this->showHiddenRecords = 0; 00678 $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME']; 00679 $this->fePreview = 0; 00680 } 00681 00688 function determineId() { 00689 00690 // Getting ARG-v values if some 00691 $this->setIDfromArgV(); 00692 00693 // If there is a Backend login we are going to check for any preview settings: 00694 $GLOBALS['TT']->push('beUserLogin',''); 00695 if ($this->beUserLogin || $this->doWorkspacePreview()) { 00696 00697 // Backend user preview features: 00698 if ($this->beUserLogin) { 00699 $this->fePreview = $GLOBALS['BE_USER']->extGetFeAdminValue('preview') ? 1 : 0; 00700 00701 // If admin panel preview is enabled... 00702 if ($this->fePreview) { 00703 $fe_user_OLD_USERGROUP = $this->fe_user->user['usergroup']; 00704 00705 $this->showHiddenPage = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenPages'); 00706 $this->showHiddenRecords = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenRecords'); 00707 // simulate date 00708 $simTime = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateDate'); 00709 if ($simTime) $GLOBALS['SIM_EXEC_TIME']=$simTime; 00710 // simulate user 00711 $simUserGroup = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateUserGroup'); 00712 $this->simUserGroup = $simUserGroup; 00713 if ($simUserGroup) $this->fe_user->user['usergroup']=$simUserGroup; 00714 if (!$simUserGroup && !$simTime && !$this->showHiddenPage && !$this->showHiddenRecords) { 00715 $this->fePreview=0; 00716 } 00717 } 00718 } 00719 00720 if ($this->id) { 00721 00722 // Now it's investigated if the raw page-id points to a hidden page and if so, the flag is set. 00723 // This does not require the preview flag to be set in the admin panel 00724 $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... 00725 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('hidden', 'pages', $idQ.' AND hidden!=0 AND deleted=0'); 00726 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 00727 $this->fePreview = 1; // The preview flag is set only if the current page turns out to actually be hidden! 00728 $this->showHiddenPage = 1; 00729 } 00730 00731 // For Live workspace: Check root line for proper connection to tree root (done because of possible preview of page / branch versions) 00732 if (!$this->fePreview && $this->whichWorkspace()===0) { 00733 00734 // Initialize the page-select functions to check rootline: 00735 $temp_sys_page = t3lib_div::makeInstance('t3lib_pageSelect'); 00736 $temp_sys_page->init($this->showHiddenPage); 00737 00738 // If root line contained NO records and ->error_getRootLine_failPid tells us that it was because of a pid=-1 (indicating a "version" record)...: 00739 if (!count($temp_sys_page->getRootLine($this->id,$this->MP)) && $temp_sys_page->error_getRootLine_failPid==-1) { 00740 00741 // Setting versioningPreview flag and try again: 00742 $temp_sys_page->versioningPreview = TRUE; 00743 if (count($temp_sys_page->getRootLine($this->id,$this->MP))) { 00744 // 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. 00745 $this->fePreview = 1; 00746 } 00747 } 00748 } 00749 } 00750 00751 // The preview flag will be set if a backend user is in an offline workspace 00752 if (($GLOBALS['BE_USER']->user['workspace_preview'] || t3lib_div::_GP('ADMCMD_view') || $this->doWorkspacePreview()) && ($this->whichWorkspace()===-1 || $this->whichWorkspace()>0)) { 00753 $this->fePreview = 2; // Will show special preview message. 00754 } 00755 00756 // If the front-end is showing a preview, caching MUST be disabled. 00757 if ($this->fePreview) { 00758 $this->set_no_cache(); 00759 } 00760 } 00761 $GLOBALS['TT']->pull(); 00762 00763 // Now, get the id, validate access etc: 00764 $this->fetch_the_id(); 00765 00766 // Check if backend user has read access to this page. If not, recalculate the id. 00767 if ($this->beUserLogin && $this->fePreview) { 00768 if (!$GLOBALS['BE_USER']->doesUserHaveAccess($this->page,1)) { 00769 00770 // Resetting 00771 $this->clear_preview(); 00772 $this->fe_user->user['usergroup'] = $fe_user_OLD_USERGROUP; 00773 00774 // Fetching the id again, now with the preview settings reset. 00775 $this->fetch_the_id(); 00776 } 00777 } 00778 00779 // Checks if user logins are blocked for a certain branch and if so, will unset user login and re-fetch ID. 00780 $this->loginAllowedInBranch = $this->checkIfLoginAllowedInBranch(); 00781 if (!$this->loginAllowedInBranch) { // Logins are not allowed: 00782 if ($this->isUserOrGroupSet()) { // Only if there is a login will we run this... 00783 00784 // Clear out user and group: 00785 unset($this->fe_user->user); 00786 $this->gr_list = '0,-1'; 00787 00788 // Fetching the id again, now with the preview settings reset. 00789 $this->fetch_the_id(); 00790 } 00791 } 00792 00793 // Final cleaning. 00794 $this->id = $this->contentPid = intval($this->id); // Make sure it's an integer 00795 $this->type = intval($this->type); // Make sure it's an integer 00796 00797 // Look for alternative content PID if page is under version preview: 00798 if ($this->fePreview) { 00799 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: 00800 // 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! 00801 $this->contentPid = $this->page['_ORIG_uid']; 00802 } 00803 } 00804 00805 // Call post processing function for id determination: 00806 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) { 00807 $_params = array('pObj' => &$this); 00808 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef) { 00809 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00810 } 00811 } 00812 } 00813 00822 function fetch_the_id() { 00823 $GLOBALS['TT']->push('fetch_the_id initialize/',''); 00824 00825 // Initialize the page-select functions. 00826 $this->sys_page = t3lib_div::makeInstance('t3lib_pageSelect'); 00827 $this->sys_page->versioningPreview = $this->fePreview ? TRUE : FALSE; 00828 $this->sys_page->versioningWorkspaceId = $this->whichWorkspace(); 00829 $this->sys_page->init($this->showHiddenPage); 00830 00831 // Set the valid usergroups for FE 00832 $this->initUserGroups(); 00833 00834 // Sets sys_page where-clause 00835 $this->setSysPageWhereClause(); 00836 00837 // Splitting $this->id by a period (.). First part is 'id' and second part - if exists - will overrule the &type param if given 00838 $pParts = explode('.',$this->id); 00839 $this->id = $pParts[0]; // Set it. 00840 if (isset($pParts[1])) {$this->type=$pParts[1];} 00841 00842 // Splitting $this->id by a comma (,). First part is 'id' and other parts are just stored for use in scripts. 00843 $this->idParts = explode(',',$this->id); 00844 00845 // Splitting by a '+' sign - used for base64/md5 methods of parameter encryption for simulate static documents. 00846 list($pgID,$SSD_p)=explode('+',$this->idParts[0],2); 00847 if ($SSD_p) { $this->idPartsAnalyze($SSD_p); } 00848 $this->id = $pgID; // Set id 00849 00850 // If $this->id is a string, it's an alias 00851 $this->checkAndSetAlias(); 00852 00853 // The id and type is set to the integer-value - just to be sure... 00854 $this->id = intval($this->id); 00855 $this->type = intval($this->type); 00856 $GLOBALS['TT']->pull(); 00857 00858 // We find the first page belonging to the current domain 00859 $GLOBALS['TT']->push('fetch_the_id domain/',''); 00860 $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']); // the page_id of the current domain 00861 if (!$this->id) { 00862 if ($this->domainStartPage) { 00863 $this->id = $this->domainStartPage; // If the id was not previously set, set it to the id of the domain. 00864 } else { 00865 $theFirstPage = $this->sys_page->getFirstWebPage($this->id); // Find the first 'visible' page in that domain 00866 if ($theFirstPage) { 00867 $this->id = $theFirstPage['uid']; 00868 } else { 00869 $this->printError('No pages are found on the rootlevel!'); 00870 exit; 00871 } 00872 } 00873 } 00874 $GLOBALS['TT']->pull(); 00875 00876 $GLOBALS['TT']->push('fetch_the_id rootLine/',''); 00877 $requestedId = $this->id; // We store the originally requested id 00878 $this->getPageAndRootlineWithDomain($this->domainStartPage); 00879 $GLOBALS['TT']->pull(); 00880 00881 if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) { 00882 $pNotFoundMsg = array( 00883 1 => 'ID was not an accessible page', 00884 2 => 'Subsection was found and not accessible', 00885 3 => 'ID was outside the domain', 00886 4 => 'The requested page alias does not exist' 00887 ); 00888 $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]); 00889 } 00890 00891 // set no_cache if set 00892 if ($this->page['no_cache']) { 00893 $this->set_no_cache(); 00894 } 00895 00896 // Init SYS_LASTCHANGED 00897 $this->register['SYS_LASTCHANGED'] = intval($this->page['tstamp']); 00898 if ($this->register['SYS_LASTCHANGED'] < intval($this->page['SYS_LASTCHANGED'])) { 00899 $this->register['SYS_LASTCHANGED'] = intval($this->page['SYS_LASTCHANGED']); 00900 } 00901 } 00902 00916 function getPageAndRootline() { 00917 $this->page = $this->sys_page->getPage($this->id); 00918 if (!count($this->page)) { 00919 // If no page, we try to find the page before in the rootLine. 00920 $this->pageNotFound=1; // Page is 'not found' in case the id itself was not an accessible page. code 1 00921 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP); 00922 if (count($this->rootLine)) { 00923 $c=count($this->rootLine)-1; 00924 while($c>0) { 00925 00926 // Add to page access failure history: 00927 $this->pageAccessFailureHistory['direct_access'][] = $this->rootLine[$c]; 00928 00929 // Decrease to next page in rootline and check the access to that, if OK, set as page record and ID value. 00930 $c--; 00931 $this->id = $this->rootLine[$c]['uid']; 00932 $this->page = $this->sys_page->getPage($this->id); 00933 if (count($this->page)){ break; } 00934 } 00935 } 00936 // If still no page... 00937 if (!count($this->page)) { 00938 if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) { 00939 $this->pageNotFoundAndExit('The requested page does not exist!'); 00940 } else { 00941 $this->printError('The requested page does not exist!'); 00942 exit; 00943 } 00944 } 00945 } 00946 00947 // Spacer is not accessible in frontend 00948 if ($this->page['doktype'] == 199) { 00949 if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) { 00950 $this->pageNotFoundAndExit('The requested page does not exist!'); 00951 } else { 00952 $this->printError('The requested page does not exist!'); 00953 exit; 00954 } 00955 } 00956 00957 // Is the ID a link to another page?? 00958 if ($this->page['doktype']==4) { 00959 $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. 00960 $this->page = $this->getPageShortcut($this->page['shortcut'],$this->page['shortcut_mode'],$this->page['uid']); 00961 $this->id = $this->page['uid']; 00962 } 00963 00964 // Gets the rootLine 00965 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP); 00966 00967 // If not rootline we're off... 00968 if (!count($this->rootLine)) { 00969 $this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')'); 00970 exit; 00971 } 00972 00973 // Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!) 00974 if ($this->checkRootlineForIncludeSection()) { 00975 if (!count($this->rootLine)) { 00976 $this->printError('The requested page was not accessible!'); 00977 exit; 00978 } else { 00979 $el = reset($this->rootLine); 00980 $this->id = $el['uid']; 00981 $this->page = $this->sys_page->getPage($this->id); 00982 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP); 00983 } 00984 } 00985 } 00986 00999 function getPageShortcut($SC,$mode,$thisUid,$itera=20,$pageLog=array()) { 01000 $idArray = t3lib_div::intExplode(',',$SC); 01001 01002 // Find $page record depending on shortcut mode: 01003 switch($mode) { 01004 case 1: 01005 case 2: 01006 $pageArray = $this->sys_page->getMenu($idArray[0]?$idArray[0]:$thisUid,'*','sorting','AND pages.doktype<199 AND pages.doktype!=6'); 01007 $pO = 0; 01008 if ($mode==2 && count($pageArray)) { // random 01009 $this->make_seed(); 01010 $randval = intval(rand(0,count($pageArray)-1)); 01011 $pO = $randval; 01012 } 01013 $c = 0; 01014 reset($pageArray); 01015 while(list(,$pV)=each($pageArray)) { 01016 if ($c==$pO) { 01017 $page = $pV; 01018 break; 01019 } 01020 $c++; 01021 } 01022 break; 01023 default: 01024 $page = $this->sys_page->getPage($idArray[0]); 01025 break; 01026 } 01027 01028 // Check if short cut page was a shortcut itself, if so look up recursively: 01029 if ($page['doktype']==4) { 01030 if (!in_array($page['uid'],$pageLog) && $itera>0) { 01031 $pageLog[] = $page['uid']; 01032 $page = $this->getPageShortcut($page['shortcut'],$page['shortcut_mode'],$page['uid'],$itera-1,$pageLog); 01033 } else { 01034 $pageLog[] = $page['uid']; 01035 $this->printError('Page shortcuts were looping in uids '.implode(',',$pageLog).'...!'); 01036 exit; 01037 } 01038 } 01039 // Return resulting page: 01040 return $page; 01041 } 01042 01049 function checkRootlineForIncludeSection() { 01050 $c=count($this->rootLine); 01051 $removeTheRestFlag=0; 01052 01053 for ($a=0;$a<$c;$a++) { 01054 if (!$this->checkPagerecordForIncludeSection($this->rootLine[$a])) { 01055 // Add to page access failure history: 01056 $this->pageAccessFailureHistory['sub_section'][] = $this->rootLine[$a]; 01057 $removeTheRestFlag=1; 01058 } 01059 if ($this->rootLine[$a]['doktype']==6) { 01060 if ($this->beUserLogin) { // If there is a backend user logged in, check if he has read access to the page: 01061 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($this->id).' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1)); // versionOL()? 01062 list($isPage) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 01063 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... 01064 } else { // Dont go here, if there is no backend user logged in. 01065 $removeTheRestFlag=1; 01066 } 01067 } 01068 if ($removeTheRestFlag) { 01069 $this->pageNotFound=2; // Page is 'not found' in case a subsection was found and not accessible, code 2 01070 unset($this->rootLine[$a]); 01071 } 01072 } 01073 return $removeTheRestFlag; 01074 } 01075 01086 function checkEnableFields($row,$bypassGroupCheck=FALSE) { 01087 if ((!$row['hidden'] || $this->showHiddenPage) 01088 && $row['starttime']<=$GLOBALS['SIM_EXEC_TIME'] 01089 && ($row['endtime']==0 || $row['endtime']>$GLOBALS['SIM_EXEC_TIME']) 01090 && ($bypassGroupCheck || $this->checkPageGroupAccess($row)) 01091 ) { return TRUE; } 01092 } 01093 01102 function checkPageGroupAccess($row, $groupList=NULL) { 01103 if(is_null($groupList)) { 01104 $groupList = $this->gr_list; 01105 } 01106 if(!is_array($groupList)) { 01107 $groupList = explode(',', $groupList); 01108 } 01109 $pageGroupList = explode(',', $row['fe_group'] ? $row['fe_group'] : 0); 01110 return count(array_intersect($groupList, $pageGroupList)) > 0; 01111 } 01112 01121 function checkPagerecordForIncludeSection($row) { 01122 return (!$row['extendToSubpages'] || $this->checkEnableFields($row)) ? 1 : 0; 01123 } 01124 01130 function checkIfLoginAllowedInBranch() { 01131 01132 // Initialize: 01133 $c = count($this->rootLine); 01134 $disable = FALSE; 01135 01136 // Traverse root line from root and outwards: 01137 for ($a=0; $a<$c; $a++) { 01138 01139 // If a value is set for login state: 01140 if ($this->rootLine[$a]['fe_login_mode'] > 0) { 01141 01142 // Determine state from value: 01143 $disable = (int)$this->rootLine[$a]['fe_login_mode'] === 1 ? TRUE : FALSE; 01144 } 01145 } 01146 01147 return !$disable; 01148 } 01149 01155 function getPageAccessFailureReasons() { 01156 $output = array(); 01157 01158 $combinedRecords = array_merge( 01159 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! 01160 is_array($this->pageAccessFailureHistory['sub_section']) ? $this->pageAccessFailureHistory['sub_section'] : array() 01161 ); 01162 01163 if (count($combinedRecords)) { 01164 foreach($combinedRecords as $k => $pagerec) { 01165 // 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 01166 // 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! 01167 if (!$k || $pagerec['extendToSubpages']) { 01168 if ($pagerec['hidden']) $output['hidden'][$pagerec['uid']] = TRUE; 01169 if ($pagerec['starttime'] > $GLOBALS['SIM_EXEC_TIME']) $output['starttime'][$pagerec['uid']] = $pagerec['starttime']; 01170 if ($pagerec['endtime']!=0 && $pagerec['endtime'] <= $GLOBALS['SIM_EXEC_TIME']) $output['endtime'][$pagerec['uid']] = $pagerec['endtime']; 01171 if (!$this->checkPageGroupAccess($pagerec)) $output['fe_group'][$pagerec['uid']] = $pagerec['fe_group']; 01172 } 01173 } 01174 } 01175 01176 return $output; 01177 } 01178 01187 function setIDfromArgV() { 01188 if (!$this->id) { 01189 list($theAlias) = explode('&',t3lib_div::getIndpEnv('QUERY_STRING')); 01190 $theAlias = trim($theAlias); 01191 $this->id = ($theAlias != '' && strpos($theAlias, '=') === false) ? $theAlias : 0; 01192 } 01193 } 01194 01203 function getPageAndRootlineWithDomain($domainStartPage) { 01204 $this->getPageAndRootline(); 01205 01206 // 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. 01207 if ($domainStartPage && is_array($this->rootLine)) { 01208 reset ($this->rootLine); 01209 $idFound = 0; 01210 while(list($key,$val)=each($this->rootLine)) { 01211 if ($val['uid']==$domainStartPage) { 01212 $idFound=1; 01213 break; 01214 } 01215 } 01216 if (!$idFound) { 01217 $this->pageNotFound=3; // Page is 'not found' in case the id was outside the domain, code 3 01218 $this->id = $domainStartPage; 01219 $this->getPageAndRootline(); //re-get the page and rootline if the id was not found. 01220 } 01221 } 01222 } 01223 01230 function setSysPageWhereClause() { 01231 $this->sys_page->where_hid_del.=' AND pages.doktype<200'; 01232 $this->sys_page->where_groupAccess = $this->sys_page->getMultipleGroupsWhereClause('pages.fe_group', 'pages'); 01233 } 01234 01242 function findDomainRecord($recursive=0) { 01243 if ($recursive) { 01244 $host = explode('.',t3lib_div::getIndpEnv('HTTP_HOST')); 01245 while(count($host)) { 01246 $pageUid = $this->sys_page->getDomainStartPage(implode('.',$host),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI')); 01247 if ($pageUid) return $pageUid; else array_shift($host); 01248 } 01249 return $pageUid; 01250 } else { 01251 return $this->sys_page->getDomainStartPage(t3lib_div::getIndpEnv('HTTP_HOST'),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI')); 01252 } 01253 } 01254 01262 function pageNotFoundAndExit($reason='', $header='') { 01263 $header = $header ? $header : $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader']; 01264 $this->pageNotFoundHandler($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'], $header, $reason); 01265 exit; 01266 } 01267 01277 function pageNotFoundHandler($code, $header='', $reason='') { 01278 01279 // Issue header in any case: 01280 if ($header) { 01281 $headerArr = preg_split('/\r|\n/',$header,-1,PREG_SPLIT_NO_EMPTY); 01282 foreach ($headerArr as $header) { 01283 header ($header); 01284 } 01285 } 01286 01287 // Convert $code in case it was written as a string (e.g. if edited in Install Tool) 01288 // TODO: Once the Install Tool handles such data types correctly, this workaround should be removed again... 01289 if (!strcasecmp($code,'TRUE')) { $code=TRUE; } 01290 01291 // Create response: 01292 if (gettype($code)=='boolean' || !strcmp($code,1)) { // Simply boolean; Just shows TYPO3 error page with reason: 01293 $this->printError('The page did not exist or was inaccessible.'.($reason ? ' Reason: '.htmlspecialchars($reason) : '')); 01294 } elseif (t3lib_div::isFirstPartOfStr($code,'USER_FUNCTION:')) { 01295 $funcRef = trim(substr($code,14)); 01296 $params = array( 01297 'currentUrl' => t3lib_div::getIndpEnv('REQUEST_URI'), 01298 'reasonText' => $reason, 01299 'pageAccessFailureReasons' => $this->getPageAccessFailureReasons() 01300 ); 01301 echo t3lib_div::callUserFunction($funcRef,$params,$this); 01302 } elseif (t3lib_div::isFirstPartOfStr($code,'READFILE:')) { 01303 $readFile = t3lib_div::getFileAbsFileName(trim(substr($code,9))); 01304 if (@is_file($readFile)) { 01305 $fileContent = t3lib_div::getUrl($readFile); 01306 $fileContent = str_replace('###CURRENT_URL###', t3lib_div::getIndpEnv('REQUEST_URI'), $fileContent); 01307 $fileContent = str_replace('###REASON###', htmlspecialchars($reason), $fileContent); 01308 echo $fileContent; 01309 } else { 01310 $this->printError('Configuration Error: 404 page "'.$readFile.'" could not be found.'); 01311 } 01312 } elseif (t3lib_div::isFirstPartOfStr($code,'REDIRECT:')) { 01313 header('Location: '.t3lib_div::locationHeaderUrl(substr($code,9))); 01314 exit; 01315 } elseif (strlen($code)) { 01316 // Check if URL is relative 01317 $url_parts = parse_url($code); 01318 if ($url_parts['host'] == '') { 01319 $url_parts['host'] = t3lib_div::getIndpEnv('HTTP_HOST'); 01320 $code = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . $code; 01321 $checkBaseTag = false; 01322 } else { 01323 $checkBaseTag = true; 01324 } 01325 01326 // Check recursion 01327 if ($code == t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) { 01328 if ($reason == '') { 01329 $reason = 'Page cannot be found.'; 01330 } 01331 $reason.= chr(10) . chr(10) . 'Additionally, ' . $code . ' was not found while trying to retrieve the error document.'; 01332 $this->printError('Reason: '.nl2br(htmlspecialchars($reason))); 01333 exit(); 01334 } 01335 01336 // Prepare headers 01337 $headerArr = array( 01338 'User-agent: ' . t3lib_div::getIndpEnv('HTTP_USER_AGENT'), 01339 'Referer: ' . t3lib_div::getIndpEnv('TYPO3_REQUEST_URL') 01340 ); 01341 $res = t3lib_div::getURL($code, 1, $headerArr); 01342 01343 // Header and content are separated by an empty line 01344 list($header,$content) = split("\r\n\r\n", $res, 2); 01345 $content.= "\r\n"; 01346 01347 if (false === $content) { 01348 // Last chance -- redirect 01349 header('Location: '.t3lib_div::locationHeaderUrl($code)); 01350 } else { 01351 01352 $forwardHeaders = array( // Forward these response headers to the client 01353 'Content-Type:', 01354 ); 01355 $headerArr = preg_split('/\r|\n/',$header,-1,PREG_SPLIT_NO_EMPTY); 01356 foreach ($headerArr as $header) { 01357 foreach ($forwardHeaders as $h) { 01358 if (preg_match('/^'.$h.'/', $header)) { 01359 header ($header); 01360 } 01361 } 01362 } 01363 // Put <base> if necesary 01364 if ($checkBaseTag) { 01365 01366 // If content already has <base> tag, we do not need to do anything 01367 if (false === stristr($content, '<base ')) { 01368 01369 // Generate href for base tag 01370 $base = $url_parts['scheme'] . '://'; 01371 if ($url_parts['user'] != '') { 01372 $base.= $url_parts['user']; 01373 if ($url_parts['pass'] != '') { 01374 $base.= ':' . $url_parts['pass']; 01375 } 01376 $base.= '@'; 01377 } 01378 $base.= $url_parts['host']; 01379 01380 // Add path portion skipping possible file name 01381 $base.= preg_replace('/(.*\/)[^\/]*/', '\1', $url_parts['path']); 01382 01383 // Put it into content (generate also <head> if necessary) 01384 $replacement = chr(10) . '<base href="' . htmlentities($base) . '" />' . chr(10); 01385 if (stristr($content, '<head>')) { 01386 $content = preg_replace('/(<head>)/i', '\1' . $replacement, $content); 01387 } else { 01388 $content = preg_replace('/(<html[^>]*>)/i', '\1<head>' . $replacement . '</head>', $content); 01389 } 01390 } 01391 } 01392 echo $content; // Output the content 01393 } 01394 } else { 01395 $this->printError($reason ? 'Reason: '.htmlspecialchars($reason) : 'Page cannot be found.'); 01396 } 01397 exit(); 01398 } 01399 01407 function checkAndSetAlias() { 01408 if ($this->id && !t3lib_div::testInt($this->id)) { 01409 $aid = $this->sys_page->getPageIdFromAlias($this->id); 01410 if ($aid) { 01411 $this->id = $aid; 01412 } else { 01413 $this->pageNotFound = 4; 01414 } 01415 } 01416 } 01417 01426 function idPartsAnalyze($str) { 01427 $GET_VARS = ''; 01428 switch(substr($str,0,2)) { 01429 case 'B6': 01430 $addParams = base64_decode(str_replace('_','=',str_replace('-','/',substr($str,2)))); 01431 parse_str($addParams,$GET_VARS); 01432 break; 01433 case 'M5': 01434 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr(substr($str,2), 'cache_md5params')); 01435 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 01436 01437 $this->updateMD5paramsRecord(substr($str,2)); 01438 parse_str($row['params'],$GET_VARS); 01439 break; 01440 } 01441 01442 $this->mergingWithGetVars($GET_VARS); 01443 } 01444 01451 function mergingWithGetVars($GET_VARS) { 01452 if (is_array($GET_VARS)) { 01453 $realGet = t3lib_div::_GET(); // Getting $_GET var, unescaped. 01454 if (!is_array($realGet)) $realGet = array(); 01455 01456 // Merge new values on top: 01457 $realGet = t3lib_div::array_merge_recursive_overrule($realGet,$GET_VARS); 01458 01459 // Write values back to $_GET: 01460 t3lib_div::_GETset($realGet); 01461 01462 // Setting these specifically (like in the init-function): 01463 if (isset($GET_VARS['type'])) $this->type = intval($GET_VARS['type']); 01464 if (isset($GET_VARS['cHash'])) $this->cHash = $GET_VARS['cHash']; 01465 if (isset($GET_VARS['jumpurl'])) $this->jumpurl = $GET_VARS['jumpurl']; 01466 if (isset($GET_VARS['MP'])) $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? $GET_VARS['MP'] : ''; 01467 01468 if (isset($GET_VARS['no_cache']) && $GET_VARS['no_cache']) $this->set_no_cache(); 01469 } 01470 } 01471 01481 function ADMCMD_preview(){ 01482 $inputCode = t3lib_div::_GP('ADMCMD_prev'); 01483 01484 if ($inputCode) { 01485 01486 // Look for keyword configuration record: 01487 list($previewData) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 01488 '*', 01489 'sys_preview', 01490 'keyword='.$GLOBALS['TYPO3_DB']->fullQuoteStr($inputCode, 'sys_preview'). 01491 ' AND endtime>'.time() 01492 ); 01493 01494 // Get: Backend login status, Frontend login status 01495 // - Make sure to remove fe/be cookies (temporarily); BE already done in ADMCMD_preview_postInit() 01496 if (is_array($previewData)) { 01497 if (!count(t3lib_div::_POST())) { 01498 if (t3lib_div::getIndpEnv('TYPO3_SITE_URL').'index.php?ADMCMD_prev='.$inputCode === t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) { 01499 01500 // Unserialize configuration: 01501 $previewConfig = unserialize($previewData['config']); 01502 01503 // Set GET variables: 01504 $GET_VARS = ''; 01505 parse_str($previewConfig['getVars'], $GET_VARS); 01506 t3lib_div::_GETset($GET_VARS); 01507 01508 // Return preview keyword configuration: 01509 return $previewConfig; 01510 } 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. 01511 } else die('POST requests are incompatible with keyword preview.'); 01512 } else die('ADMCMD command could not be executed! (No keyword configuration found)'); 01513 } 01514 } 01515 01524 function ADMCMD_preview_postInit($previewConfig){ 01525 if (is_array($previewConfig)) { 01526 01527 // Clear cookies: 01528 unset($_COOKIE['be_typo_user']); 01529 $this->ADMCMD_preview_BEUSER_uid = $previewConfig['BEUSER_uid']; 01530 01531 } else die('Error in preview configuration.'); 01532 } 01533 01534 01535 01536 01537 01538 01539 01540 01541 01542 01543 01544 /******************************************** 01545 * 01546 * Template and caching related functions. 01547 * 01548 *******************************************/ 01549 01556 function makeCacheHash() { 01557 $GET = t3lib_div::_GET(); 01558 if ($this->cHash && is_array($GET)) { 01559 $this->cHash_array = t3lib_div::cHashParams(t3lib_div::implodeArrayForUrl('',$GET)); 01560 $cHash_calc = t3lib_div::shortMD5(serialize($this->cHash_array)); 01561 01562 if ($cHash_calc!=$this->cHash) { 01563 if ($this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) { 01564 $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash comparison failed)'); 01565 } else { 01566 $this->set_no_cache(); 01567 $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); 01568 } 01569 } 01570 } 01571 } 01572 01580 function reqCHash() { 01581 if (!$this->cHash) { 01582 if ($this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) { 01583 if ($this->tempContent) { $this->clearPageCacheContent(); } 01584 $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash empty)'); 01585 } else { 01586 $this->set_no_cache(); 01587 $GLOBALS['TT']->setTSlogMessage('TSFE->reqCHash(): No &cHash parameter was sent for GET vars though required so caching is disabled ',2); 01588 } 01589 } 01590 } 01591 01602 function cHashParams($addQueryParams) { 01603 return t3lib_div::cHashParams($addQueryParams); 01604 } 01605 01611 function initTemplate() { 01612 $this->tmpl = t3lib_div::makeInstance('t3lib_TStemplate'); 01613 $this->tmpl->init(); 01614 $this->tmpl->tt_track= $this->beUserLogin ? 1 : 0; 01615 } 01616 01623 function getFromCache() { 01624 if (!$this->no_cache) { 01625 $this->tmpl->getCurrentPageData(); 01626 01627 $cc = Array(); 01628 if (is_array($this->tmpl->currentPageData)) { 01629 // BE CAREFULL 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. 01630 // If this hash is not the same in here in this section and after page-generation the page will not be properly cached! 01631 01632 $cc['all'] = $this->tmpl->currentPageData['all']; 01633 $cc['rowSum'] = $this->tmpl->currentPageData['rowSum']; 01634 $cc['rootLine'] = $this->tmpl->currentPageData['rootLine']; // This rootline is used with templates only (matching()-function) 01635 $this->all = $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. 01636 ksort($this->all); 01637 } 01638 } 01639 01640 $this->content=''; // clearing the content-variable, which will hold the pagecontent 01641 unset($this->config); // Unsetting the lowlevel config 01642 $this->cacheContentFlag = 0; 01643 01644 // Look for page in cache only if caching is not disabled and if a shift-reload is not sent to the server. 01645 if ($this->all && !$this->no_cache && !$this->headerNoCache()) { 01646 01647 $this->newHash = $this->getHash(); 01648 01649 $GLOBALS['TT']->push('Cache Row',''); 01650 if ($row = $this->getFromCache_queryRow()) { 01651 01652 $this->config = (array)unserialize($row['cache_data']); // Fetches the lowlevel config stored with the cached data 01653 $this->content = $row['HTML']; // Getting the content 01654 $this->tempContent = $row['temp_content']; // Flag for temp content 01655 $this->cacheContentFlag = 1; // Setting flag, so we know, that some cached content is gotten. 01656 $this->cacheExpires = $row['expires']; 01657 01658 if ($this->TYPO3_CONF_VARS['FE']['debug'] || $this->config['config']['debug']) { 01659 $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']; 01660 $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm']; 01661 01662 $this->content.=chr(10).'<!-- Cached page generated '.date($dateFormat.' '.$timeFormat, $row['tstamp']).'. Expires '.Date($dateFormat.' '.$timeFormat, $row['expires']).' -->'; 01663 } 01664 01665 } 01666 $GLOBALS['TT']->pull(); 01667 } 01668 } 01669 01675 function getFromCache_queryRow() { 01676 01677 $GLOBALS['TT']->push('Cache Query',''); 01678 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 01679 'S.*', 01680 'cache_pages S,pages P', 01681 'S.hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->newHash, 'cache_pages').' 01682 AND S.page_id=P.uid 01683 AND S.expires > '.intval($GLOBALS['EXEC_TIME']).' 01684 AND P.deleted=0 01685 AND P.hidden=0 01686 AND P.starttime<='.intval($GLOBALS['EXEC_TIME']).' 01687 AND (P.endtime=0 OR P.endtime>'.intval($GLOBALS['EXEC_TIME']).')' 01688 ); 01689 $GLOBALS['TT']->pull(); 01690 01691 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01692 $this->pageCachePostProcess($row,'get'); 01693 } 01694 $GLOBALS['TYPO3_DB']->sql_free_result($res); 01695 return $row; 01696 } 01697 01705 function headerNoCache() { 01706 $disableAcquireCacheData = FALSE; 01707 01708 if ($this->beUserLogin) { 01709 if (strtolower($_SERVER['HTTP_CACHE_CONTROL'])==='no-cache' || strtolower($_SERVER['HTTP_PRAGMA'])==='no-cache') { 01710 $disableAcquireCacheData = TRUE; 01711 } 01712 } 01713 01714 // Call hook for possible by-pass of requiring of page cache (for recaching purpose) 01715 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'])) { 01716 $_params = array('pObj' => &$this, 'disableAcquireCacheData' => &$disableAcquireCacheData); 01717 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'] as $_funcRef) { 01718 t3lib_div::callUserFunction($_funcRef,$_params,$this); 01719 } 01720 } 01721 01722 return $disableAcquireCacheData; 01723 } 01724 01734 function getHash() { 01735 $this->hash_base = serialize( 01736 array( 01737 'all' => $this->all, 01738 'id' => intval($this->id), 01739 'type' => intval($this->type), 01740 'gr_list' => (string)$this->gr_list, 01741 'MP' => (string)$this->MP, 01742 'cHash' => $this->cHash_array 01743 ) 01744 ); 01745 01746 return md5($this->hash_base); 01747 } 01748 01754 function getConfigArray() { 01755 $setStatPageName = false; 01756 01757 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 01758 $GLOBALS['TT']->push('Parse template',''); 01759 01760 // Force parsing, if set?: 01761 $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing; 01762 01763 // Start parsing the TS template. Might return cached version. 01764 $this->tmpl->start($this->rootLine); 01765 $GLOBALS['TT']->pull(); 01766 01767 if ($this->tmpl->loaded) { 01768 $GLOBALS['TT']->push('Setting the config-array',''); 01769 // t3lib_div::print_array($this->tmpl->setup); 01770 $this->sPre = $this->tmpl->setup['types.'][$this->type]; // toplevel - objArrayName 01771 $this->pSetup = $this->tmpl->setup[$this->sPre.'.']; 01772 01773 if (!is_array($this->pSetup)) { 01774 $this->printError('The page is not configured! [type= '.$this->type.']['.$this->sPre.']'); 01775 exit; 01776 } else { 01777 $this->config['config']=Array(); 01778 01779 // Filling the config-array. 01780 if (is_array($this->tmpl->setup['config.'])) { 01781 $this->config['config'] = $this->tmpl->setup['config.']; 01782 } 01783 if (is_array($this->pSetup['config.'])) { 01784 reset($this->pSetup['config.']); 01785 while(list($theK,$theV)=each($this->pSetup['config.'])) { 01786 $this->config['config'][$theK] = $theV; 01787 } 01788 } 01789 // if .simulateStaticDocuments was not present, the default value will rule. 01790 if (!isset($this->config['config']['simulateStaticDocuments'])) { 01791 $this->config['config']['simulateStaticDocuments'] = trim($this->TYPO3_CONF_VARS['FE']['simulateStaticDocuments']); 01792 } 01793 if ($this->config['config']['simulateStaticDocuments']) { 01794 // Set replacement char only if it is needed 01795 $this->setSimulReplacementChar(); 01796 } 01797 01798 // Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0 01799 if (!isset($this->config['config']['removeDefaultJS']) && t3lib_div::compat_version('4.0')) { 01800 $this->config['config']['removeDefaultJS'] = 'external'; 01801 } 01802 if (!isset($this->config['config']['inlineStyle2TempFile']) && t3lib_div::compat_version('4.0')) { 01803 $this->config['config']['inlineStyle2TempFile'] = 1; 01804 } 01805 01806 // Processing for the config_array: 01807 $this->config['rootLine'] = $this->tmpl->rootLine; 01808 $this->config['mainScript'] = trim($this->config['config']['mainScript']) ? trim($this->config['config']['mainScript']) : 'index.php'; 01809 01810 // STAT: 01811 $theLogFile = $this->TYPO3_CONF_VARS['FE']['logfile_dir'].strftime($this->config['config']['stat_apache_logfile']); 01812 // Add PATH_site left to $theLogFile if the path is not absolute yet 01813 if (!t3lib_div::isAbsPath($theLogFile)) $theLogFile = PATH_site.$theLogFile; 01814 01815 if ($this->config['config']['stat_apache'] && $this->config['config']['stat_apache_logfile'] && !strstr($this->config['config']['stat_apache_logfile'],'/')) { 01816 if (t3lib_div::isAllowedAbsPath($theLogFile)) { 01817 if (!@is_file($theLogFile)) { 01818 touch($theLogFile); // Try to create the logfile 01819 t3lib_div::fixPermissions($theLogFile); 01820 } 01821 01822 if (@is_file($theLogFile) && @is_writable($theLogFile)) { 01823 $this->config['stat_vars']['logFile'] = $theLogFile; 01824 $setStatPageName = true; // Set page name later on 01825 } else { 01826 $GLOBALS['TT']->setTSlogMessage('Could not set logfile path. Check filepath and permissions.',3); 01827 } 01828 } 01829 } 01830 01831 $this->config['FEData'] = $this->tmpl->setup['FEData']; 01832 $this->config['FEData.'] = $this->tmpl->setup['FEData.']; 01833 } 01834 $GLOBALS['TT']->pull(); 01835 } else { 01836 $this->printError('No template found!'); 01837 exit; 01838 } 01839 } 01840 01841 // Initialize charset settings etc. 01842 $this->initLLvars(); 01843 01844 // We want nice names, so we need to handle the charset 01845 if ($setStatPageName) { 01846 // Make life easier and accept variants for utf-8 01847 if (preg_match('/utf-?8/i', $this->config['config']['stat_apache_niceTitle'])) { 01848 $this->config['config']['stat_apache_niceTitle'] = 'utf-8'; 01849 } 01850 if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8') { 01851 $shortTitle = $this->csConvObj->utf8_encode($this->page['title'],$this->renderCharset); 01852 } elseif ($this->config['config']['stat_apache_niceTitle']) { 01853 $shortTitle = $this->csConvObj->specCharsToASCII($this->renderCharset,$this->page['title']); 01854 } else { 01855 $shortTitle = $this->page['title']; 01856 } 01857 $len = t3lib_div::intInRange($this->config['config']['stat_apache_pageLen'],1,100,30); 01858 if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8') { 01859 $shortTitle = rawurlencode($this->csConvObj->substr('utf-8',$shortTitle,0,$len)); 01860 } else { 01861 $shortTitle = substr(preg_replace('/[^.[:alnum:]_-]/','_',$shortTitle),0,$len); 01862 } 01863 $pageName = $this->config['config']['stat_apache_pagenames'] ? $this->config['config']['stat_apache_pagenames'] : '[path][title]--[uid].html'; 01864 $pageName = str_replace('[title]', $shortTitle ,$pageName); 01865 $pageName = str_replace('[uid]',$this->page['uid'],$pageName); 01866 $pageName = str_replace('[alias]',$this->page['alias'],$pageName); 01867 $pageName = str_replace('[type]',$this->type,$pageName); 01868 $temp = $this->config['rootLine']; 01869 array_pop($temp); 01870 if ($this->config['config']['stat_apache_noRoot']) { 01871 array_shift($temp); 01872 } 01873 $len = t3lib_div::intInRange($this->config['config']['stat_titleLen'],1,100,20); 01874 if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8') { 01875 $path = ''; 01876 $c = count($temp); 01877 for ($i=0; $i<$c; $i++) { 01878 if ($temp[$i]['uid']) { 01879 $p = $this->csConvObj->crop('utf-8',$this->csConvObj->utf8_encode($temp[$i]['title'],$this->renderCharset),$len,"\xE2\x80\xA6"); // U+2026; HORIZONTAL ELLIPSIS 01880 $path .= '/' . rawurlencode($p); 01881 } 01882 } 01883 } elseif ($this->config['config']['stat_apache_niceTitle']) { 01884 $path = $this->csConvObj->specCharsToASCII($this->renderCharset,$this->sys_page->getPathFromRootline($temp,$len)); 01885 } else { 01886 $path = $this->sys_page->getPathFromRootline($temp,$len); 01887 } 01888 if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8') { 01889 $this->config['stat_vars']['pageName'] = str_replace('[path]', $path.'/', $pageName); 01890 } else { 01891 $this->config['stat_vars']['pageName'] = str_replace('[path]', preg_replace('/[^.[:alnum:]\/_-]/','_',$path.'/'), $pageName); 01892 } 01893 } 01894 01895 // No cache 01896 if ($this->config['config']['no_cache']) { $this->set_no_cache(); } // Set $this->no_cache true if the config.no_cache value is set! 01897 01898 // Check PATH_INFO url 01899 if ($this->absRefPrefix_force && strcmp($this->config['config']['simulateStaticDocuments'],'PATH_INFO')) { 01900 $redirectUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php?id='.$this->id.'&type='.$this->type; 01901 if ($this->config['config']['simulateStaticDocuments_dontRedirectPathInfoError']) { 01902 $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'); 01903 } else { 01904 header('Location: '.t3lib_div::locationHeaderUrl($redirectUrl)); 01905 } 01906 exit; 01907 // $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. 01908 } 01909 } 01910 01911 01912 01913 01914 01915 01916 01917 01918 01919 01920 01921 01922 01923 01924 /******************************************** 01925 * 01926 * Further initialization and data processing 01927 * (jumpurl/submission of forms) 01928 * 01929 *******************************************/ 01930 01939 function getCompressedTCarray() { 01940 global $TCA; 01941 01942 $GLOBALS['TT']->push('Get Compressed TC array'); 01943 if (!$this->TCAloaded) { 01944 // Create hash string for storage / retrieval of cached content: 01945 $tempHash = md5('tables.php:'. 01946 filemtime(TYPO3_extTableDef_script ? PATH_typo3conf.TYPO3_extTableDef_script : PATH_t3lib.'stddb/tables.php'). 01947 (TYPO3_extTableDef_script?filemtime(PATH_typo3conf.TYPO3_extTableDef_script):''). 01948 ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] ? filemtime(PATH_typo3conf.$GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'].'_ext_tables.php') : '') 01949 ); 01950 // Try to fetch if: 01951 list($TCA,$this->TCAcachedExtras) = unserialize($this->sys_page->getHash($tempHash, 0)); 01952 // If no result, create it: 01953 if (!is_array($TCA)) { 01954 $this->includeTCA(0); 01955 $newTc = Array(); 01956 $this->TCAcachedExtras = array(); // Collects other information 01957 01958 foreach($TCA as $key => $val) { 01959 $newTc[$key]['ctrl'] = $val['ctrl']; 01960 $newTc[$key]['feInterface'] = $val['feInterface']; 01961 01962 // Collect information about localization exclusion of fields: 01963 t3lib_div::loadTCA($key); 01964 if (is_array($TCA[$key]['columns'])) { 01965 $this->TCAcachedExtras[$key]['l10n_mode'] = array(); 01966 foreach($TCA[$key]['columns'] as $fN => $fV) { 01967 if ($fV['l10n_mode']) { 01968 $this->TCAcachedExtras[$key]['l10n_mode'][$fN] = $fV['l10n_mode']; 01969 } 01970 } 01971 } 01972 } 01973 01974 // Store it in cache: 01975 $TCA = $newTc; 01976 $this->sys_page->storeHash($tempHash, serialize(array($newTc,$this->TCAcachedExtras)), 'SHORT TC'); 01977 } 01978 } 01979 $GLOBALS['TT']->pull(); 01980 } 01981 01993 function includeTCA($TCAloaded=1) { 01994 global $TCA, $PAGES_TYPES, $LANG_GENERAL_LABELS, $TBE_MODULES; 01995 if (!$this->TCAloaded) { 01996 $TCA = Array(); 01997 include (TYPO3_tables_script ? PATH_typo3conf.TYPO3_tables_script : PATH_t3lib.'stddb/tables.php'); 01998 // Extension additions 01999 if ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE']) { 02000 include(PATH_typo3conf.$GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'].'_ext_tables.php'); 02001 } else { 02002 include(PATH_t3lib.'stddb/load_ext_tables.php'); 02003 } 02004 // ext-script 02005 if (TYPO3_extTableDef_script) { 02006 include (PATH_typo3conf.TYPO3_extTableDef_script); 02007 } 02008 02009 $this->TCAloaded = $TCAloaded; 02010 } 02011 } 02012 02020 function settingLanguage() { 02021 02022 // Get values from TypoScript: 02023 $this->sys_language_uid = $this->sys_language_content = intval($this->config['config']['sys_language_uid']); 02024 list($this->sys_language_mode,$sys_language_content) = t3lib_div::trimExplode(';', $this->config['config']['sys_language_mode']); 02025 $this->sys_language_contentOL = $this->config['config']['sys_language_overlay']; 02026 02027 // If sys_language_uid is set to another language than default: 02028 if ($this->sys_language_uid>0) { 02029 // Request the overlay record for the sys_language_uid: 02030 $olRec = $this->sys_page->getPageOverlay($this->id, $this->sys_language_uid); 02031 if (!count($olRec)) { 02032 02033 // If no OL record exists and a foreign language is asked for... 02034 if ($this->sys_language_uid) { 02035 02036 // If requested translation is not available: 02037 if (t3lib_div::hideIfNotTranslated($this->page['l18n_cfg'])) { 02038 $this->pageNotFoundAndExit('Page is not available in the requested language.'); 02039 } else { 02040 switch((string)$this->sys_language_mode) { 02041 case 'strict': 02042 $this->pageNotFoundAndExit('Page is not available in the requested language (strict).'); 02043 break; 02044 case 'content_fallback': 02045 $fallBackOrder = t3lib_div::intExplode(',', $sys_language_content); 02046 foreach($fallBackOrder as $orderValue) { 02047 if (!strcmp($orderValue,'0') || count($this->sys_page->getPageOverlay($this->id, $orderValue))) { 02048 $this->sys_language_content = $orderValue; // Setting content uid (but leaving the sys_language_uid) 02049 break; 02050 } 02051 } 02052 break; 02053 case 'ignore': 02054 $this->sys_language_content = $this->sys_language_uid; 02055 break; 02056 default: 02057 // Default is that everything defaults to the default language... 02058 $this->sys_language_uid = $this->sys_language_content = 0; 02059 break; 02060 } 02061 } 02062 } 02063 } else { 02064 // Setting sys_language if an overlay record was found (which it is only if a language is used) 02065 $this->page = $this->sys_page->getPageOverlay($this->page, $this->sys_language_uid); 02066 } 02067 } 02068 02069 // Setting sys_language_uid inside sys-page: 02070 $this->sys_page->sys_language_uid = $this->sys_language_uid; 02071 02072 // If default translation is not available: 02073 if ((!$this->sys_language_uid || !$this->sys_language_content) && $this->page['l18n_cfg']&1) { 02074 $this->pageNotFoundAndExit('Page is not available in default language.'); 02075 } 02076 02077 // Updating content of the two rootLines IF the language key is set! 02078 if ($this->sys_language_uid && is_array($this->tmpl->rootLine)) { 02079 reset($this->tmpl->rootLine); 02080 while(list($rLk)=each($this->tmpl->rootLine)) { 02081 $this->tmpl->rootLine[$rLk] = $this->sys_page->getPageOverlay($this->tmpl->rootLine[$rLk]); 02082 } 02083 } 02084 if ($this->sys_language_uid && is_array($this->rootLine)) { 02085 reset($this->rootLine); 02086 while(list($rLk)=each($this->rootLine)) { 02087 $this->rootLine[$rLk] = $this->sys_page->getPageOverlay($this->rootLine[$rLk]); 02088 } 02089 } 02090 02091 // Finding the ISO code: 02092 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" 02093 $sys_language_row = $this->sys_page->getRawRecord('sys_language',$this->sys_language_content,'static_lang_isocode'); 02094 if (is_array($sys_language_row) && $sys_language_row['static_lang_isocode']) { 02095 $stLrow = $this->sys_page->getRawRecord('static_languages',$sys_language_row['static_lang_isocode'],'lg_iso_2'); 02096 $this->sys_language_isocode = $stLrow['lg_iso_2']; 02097 } 02098 } 02099 02100 // Setting softMergeIfNotBlank: 02101 $table_fields = t3lib_div::trimExplode(',', $this->config['config']['sys_language_softMergeIfNotBlank'],1); 02102 foreach($table_fields as $TF) { 02103 list($tN,$fN) = explode(':',$TF); 02104 $this->TCAcachedExtras[$tN]['l10n_mode'][$fN] = 'mergeIfNotBlank'; 02105 } 02106 02107 // Setting softExclude: 02108 $table_fields = t3lib_div::trimExplode(',', $this->config['config']['sys_language_softExclude'],1); 02109 foreach($table_fields as $TF) { 02110 list($tN,$fN) = explode(':',$TF); 02111 $this->TCAcachedExtras[$tN]['l10n_mode'][$fN] = 'exclude'; 02112 } 02113 } 02114 02120 function settingLocale() { 02121 02122 // Setting locale 02123 if ($this->config['config']['locale_all']) { 02124 # Change by Rene Fritz, 22/10 2002 02125 # 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 02126 # this does not work in php 4.2.3 02127 #setlocale('LC_ALL',$this->config['config']['locale_all']); 02128 #setlocale('LC_NUMERIC','en_US'); 02129 02130 # so we set all except LC_NUMERIC 02131 setlocale(LC_COLLATE,$this->config['config']['locale_all']); 02132 setlocale(LC_CTYPE,$this->config['config']['locale_all']); 02133 setlocale(LC_MONETARY,$this->config['config']['locale_all']); 02134 setlocale(LC_TIME,$this->config['config']['locale_all']); 02135 02136 $this->localeCharset = $this->csConvObj->get_locale_charset($this->config['config']['locale_all']); 02137 } 02138 } 02139 02145 function checkDataSubmission() { 02146 $ret = ''; 02147 $formtype_db = isset($_POST['formtype_db']) || isset($_POST['formtype_db_x']); 02148 $formtype_mail = isset($_POST['formtype_mail']) || isset($_POST['formtype_mail_x']); 02149 if ($formtype_db || $formtype_mail) { 02150 $refInfo = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER')); 02151 if (t3lib_div::getIndpEnv('TYPO3_HOST_ONLY')==$refInfo['host'] || $this->TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) { 02152 if ($this->locDataCheck($_POST['locationData'])) { 02153 if ($formtype_mail) { 02154 $ret = 'email'; 02155 } elseif ($formtype_db && is_array($_POST['data'])) { 02156 $ret = 'fe_tce'; 02157 } 02158 $GLOBALS['TT']->setTSlogMessage('"Check Data Submission": Return value: '.$ret,0); 02159 return $ret; 02160 } 02161 } else $GLOBALS['TT']->setTSlogMessage('"Check Data Submission": HTTP_HOST and REFERER HOST did not match when processing submitted formdata!',3); 02162 } 02163 02164 // Hook for processing data submission to extensions: 02165 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkDataSubmission'])) { 02166 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkDataSubmission'] as $_classRef) { 02167 $_procObj = &t3lib_div::getUserObj($_classRef); 02168 $_procObj->checkDataSubmission($this); 02169 } 02170 } 02171 return $ret; 02172 } 02173 02181 function fe_tce() { 02182 $fe_tce = t3lib_div::makeInstance('tslib_feTCE'); 02183 $fe_tce->start(t3lib_div::_POST('data'),$this->config['FEData.']); 02184 $fe_tce->includeScripts(); 02185 } 02186 02195 function locDataCheck($locationData) { 02196 $locData = explode(':',$locationData); 02197 if (!$locData[1] || $this->sys_page->checkRecord($locData[1],$locData[2],1)) { 02198 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. 02199 return 1; 02200 } else $GLOBALS['TT']->setTSlogMessage('LocationData Error: The page pointed to by location data ('.$locationData.') was not accessible.',2); 02201 } else $GLOBALS['TT']->setTSlogMessage('LocationData Error: Location data ('.$locationData.') record pointed to was not accessible.',2); 02202 } 02203 02211 function sendFormmail() { 02212 $formmail = t3lib_div::makeInstance('t3lib_formmail'); 02213 02214 $EMAIL_VARS = t3lib_div::_POST(); 02215 $locationData = $EMAIL_VARS['locationData']; 02216 unset($EMAIL_VARS['locationData']); 02217 unset($EMAIL_VARS['formtype_mail'], $EMAIL_VARS['formtype_mail_x'], $EMAIL_VARS['formtype_mail_y']); 02218 02219 $integrityCheck = $this->TYPO3_CONF_VARS['FE']['strictFormmail']; 02220 02221 if (!$this->TYPO3_CONF_VARS['FE']['secureFormmail']) { 02222 // Check recipient field: 02223 $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. 02224 foreach ($encodedFields as $fieldKey) { 02225 if (strlen($EMAIL_VARS[$fieldKey])) { 02226 if ($res = $this->codeString($EMAIL_VARS[$fieldKey], TRUE)) { // Decode... 02227 $EMAIL_VARS[$fieldKey] = $res; // Set value if OK 02228 } elseif ($integrityCheck) { // Otherwise abort: 02229 $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); 02230 return false; 02231 } else { 02232 $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); 02233 } 02234 } 02235 } 02236 } else { 02237 $locData = explode(':',$locationData); 02238 $record = $this->sys_page->checkRecord($locData[1],$locData[2],1); 02239 $EMAIL_VARS['recipient'] = $record['subheader']; 02240 $EMAIL_VARS['recipient_copy'] = $this->extractRecipientCopy($record['bodytext']); 02241 } 02242 02243 // Hook for preprocessing of the content for formmails: 02244 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass'])) { 02245 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass'] as $_classRef) { 02246 $_procObj = &t3lib_div::getUserObj($_classRef); 02247 $EMAIL_VARS = $_procObj->sendFormmail_preProcessVariables($EMAIL_VARS,$this); 02248 } 02249 } 02250 02251 $formmail->start($EMAIL_VARS); 02252 $formmail->sendtheMail(); 02253 $GLOBALS['TT']->setTSlogMessage('"Formmail" invoked, sending mail to '.$EMAIL_VARS['recipient'],0); 02254 } 02255 02262 function extractRecipientCopy($bodytext) { 02263 $recipient_copy = ''; 02264 $fdef = array(); 02265 //|recipient_copy=hidden|karsten@localhost.localdomain 02266 preg_match('/^[\s]*\|[\s]*recipient_copy[\s]*=[\s]*hidden[\s]*\|(.*)$/m', $bodytext, $fdef); 02267 $recipient_copy = (!empty($fdef[1])) ? $fdef[1] : ''; 02268 return $recipient_copy; 02269 } 02270 02276 function setExternalJumpUrl() { 02277 if ($extUrl = $this->sys_page->getExtURL($this->page, $this->config['config']['disablePageExternalUrl'])) { 02278 $this->jumpurl = $extUrl; 02279 } 02280 } 02281 02287 function checkJumpUrlReferer() { 02288 if (strcmp($this->jumpurl,'') && !$this->TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) { 02289 $referer = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER')); 02290 if (isset($referer['host']) && !($referer['host'] == t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'))) { 02291 unset($this->jumpurl); 02292 } 02293 } 02294 } 02295 02302 function jumpUrl() { 02303 if ($this->jumpurl) { 02304 if (t3lib_div::_GP('juSecure')) { 02305 $hArr = array( 02306 $this->jumpurl, 02307 t3lib_div::_GP('locationData'), 02308 $this->TYPO3_CONF_VARS['SYS']['encryptionKey'] 02309 ); 02310 $calcJuHash=t3lib_div::shortMD5(serialize($hArr)); 02311 $locationData = t3lib_div::_GP('locationData'); 02312 $juHash = t3lib_div::_GP('juHash'); 02313 if ($juHash == $calcJuHash) { 02314 if ($this->locDataCheck($locationData)) { 02315 $this->jumpurl = rawurldecode($this->jumpurl); // 211002 - goes with cObj->filelink() rawurlencode() of filenames so spaces can be allowed. 02316 if (@is_file($this->jumpurl)) { 02317 $mimeType = t3lib_div::_GP('mimeType'); 02318 $mimeType = $mimeType ? $mimeType : 'application/octet-stream'; 02319 header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 02320 header('Content-Type: '.$mimeType); 02321 header('Content-Disposition: attachment; filename='.basename($this->jumpurl)); 02322 readfile($this->jumpurl); 02323 exit; 02324 } else die('jumpurl Secure: "'.$this->jumpurl.'" was not a valid file!'); 02325 } else die('jumpurl Secure: locationData, '.$locationData.', was not accessible.'); 02326 } else die('jumpurl Secure: Calculated juHash, '.$calcJuHash.', did not match the submitted juHash.'); 02327 } else { 02328 $TSConf = $this->getPagesTSconfig(); 02329 if ($TSConf['TSFE.']['jumpUrl_transferSession']) { 02330 $uParts = parse_url($this->jumpurl); 02331 $params = '&FE_SESSION_KEY='.rawurlencode($this->fe_user->id.'-'.md5($this->fe_user->id.'/'.$this->TYPO3_CONF_VARS['SYS']['encryptionKey'])); 02332 $this->jumpurl.= ($uParts['query']?'':'?').$params; // Add the session parameter ... 02333 } 02334 header('Location: '.$this->jumpurl); 02335 exit; 02336 } 02337 } 02338 } 02339 02346 function setUrlIdToken() { 02347 if ($this->config['config']['ftu']) { 02348 $this->getMethodUrlIdToken = $this->TYPO3_CONF_VARS['FE']['get_url_id_token']; 02349 } else { 02350 $this->getMethodUrlIdToken = ''; 02351 } 02352 } 02353 02354 02355 02356 02357 02358 02359 02360 02361 02362 02363 02364 02365 02366 02367 02368 02369 02370 02371 02372 02373 02374 02375 02376 02377 /******************************************** 02378 * 02379 * Page generation; cache handling 02380 * 02381 *******************************************/ 02382 02389 function isGeneratePage() { 02390 return (!$this->cacheContentFlag && !$this->jumpurl); 02391 } 02392 02399 function tempPageCacheContent() { 02400 $this->tempContent = false; 02401 02402 if (!$this->no_cache) { 02403 $seconds = 30; 02404 $title = htmlspecialchars($this->tmpl->printTitle($this->page['title'])); 02405 $request_uri = htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')); 02406 02407 $stdMsg = ' 02408 <strong>Page is being generated.</strong><br /> 02409 If this message does not disappear within '.$seconds.' seconds, please reload.'; 02410 02411 $message = $this->config['config']['message_page_is_being_generated']; 02412 if (strcmp('', $message)) { 02413 $message = $this->csConvObj->utf8_encode($message,$this->renderCharset); // This page is always encoded as UTF-8 02414 $message = str_replace('###TITLE###', $title, $message); 02415 $message = str_replace('###REQUEST_URI###', $request_uri, $message); 02416 } else $message = $stdMsg; 02417 02418 $temp_content = '<?xml version="1.0" encoding="UTF-8"?> 02419 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 02420 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 02421 <html xmlns="http://www.w3.org/1999/xhtml"> 02422 <head> 02423 <title>'.$title.'</title> 02424 <meta http-equiv="refresh" content="10" /> 02425 </head> 02426 <body style="background-color:white; font-family:Verdana,Arial,Helvetica,sans-serif; color:#cccccc; text-align:center;">'. 02427 $message.' 02428 </body> 02429 </html>'; 02430 02431 // Fix 'nice errors' feature in modern browsers 02432 $padSuffix = '<!--pad-->'; // prevent any trims 02433 $padSize = 768 - strlen($padSuffix) - strlen($temp_content); 02434 if ($padSize > 0) { 02435 $temp_content = str_pad($temp_content, $padSize, "\n") . $padSuffix; 02436 } 02437 02438 if (!$this->headerNoCache() && $cachedRow = $this->getFromCache_queryRow()) { 02439 // 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. 02440 // This is either the "Page is being generated" screen or it can be the final result. 02441 // In any case we should not begin another rendering process also, so we silently disable caching and render the page ourselves and thats it. 02442 // 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... 02443 $this->set_no_cache(); 02444 } else { 02445 $this->tempContent = TRUE; // This flag shows that temporary content is put in the cache 02446 $this->setPageCacheContent($temp_content, $this->config, $GLOBALS['EXEC_TIME']+$seconds); 02447 } 02448 } 02449 } 02450 02456 function realPageCacheContent() { 02457 $cache_timeout = $this->page['cache_timeout'] ? $this->page['cache_timeout'] : ($this->cacheTimeOutDefault ? $this->cacheTimeOutDefault : 60*60*24); // seconds until a cached page is too old 02458 $timeOutTime = $GLOBALS['EXEC_TIME']+$cache_timeout; 02459 if ($this->config['config']['cache_clearAtMidnight']) { 02460 $midnightTime = mktime (0,0,0,date('m',$timeOutTime),date('d',$timeOutTime),date('Y',$timeOutTime)); 02461 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. 02462 $timeOutTime = $midnightTime; 02463 } 02464 } 02465 $this->tempContent = false; 02466 $this->setPageCacheContent($this->content, $this->config, $timeOutTime); 02467 02468 // Hook for cache post processing (eg. writing static files!) 02469 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'])) { 02470 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'] as $_classRef) { 02471 $_procObj = &t3lib_div::getUserObj($_classRef); 02472 $_procObj->insertPageIncache($this,$timeOutTime); 02473 } 02474 } 02475 } 02476 02486 function setPageCacheContent($content,$data,$tstamp) { 02487 $this->clearPageCacheContent(); 02488 $insertFields = array( 02489 'hash' => $this->newHash, 02490 'page_id' => $this->id, 02491 'HTML' => $content, 02492 'temp_content' => $this->tempContent, 02493 'cache_data' => serialize($data), 02494 'expires' => $tstamp, 02495 'tstamp' => $GLOBALS['EXEC_TIME'] 02496 ); 02497 02498 $this->cacheExpires = $tstamp; 02499 02500 if ($this->page_cache_reg1) { 02501 $insertFields['reg1'] = intval($this->page_cache_reg1); 02502 } 02503 $this->pageCachePostProcess($insertFields,'set'); 02504 02505 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pages', $insertFields); 02506 } 02507 02513 function clearPageCacheContent() { 02514 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->newHash, 'cache_pages')); 02515 } 02516 02523 function clearPageCacheContent_pidList($pidList) { 02524 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'page_id IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($pidList).')'); 02525 } 02526 02534 function pageCachePostProcess(&$row,$type) { 02535 02536 if ($this->TYPO3_CONF_VARS['FE']['pageCacheToExternalFiles']) { 02537 $cacheFileName = PATH_site.'typo3temp/cache_pages/'.$row['hash']{0}.$row['hash']{1}.'/'.$row['hash'].'.html'; 02538 switch((string)$type) { 02539 case 'get': 02540 $row['HTML'] = @is_file($cacheFileName) ? t3lib_div::getUrl($cacheFileName) : '<!-- CACHING ERROR, sorry -->'; 02541 break; 02542 case 'set': 02543 t3lib_div::writeFileToTypo3tempDir($cacheFileName,$row['HTML']); 02544 $row['HTML'] = ''; 02545 break; 02546 } 02547 } 02548 } 02549 02557 function setSysLastChanged() { 02558 if ($this->page['SYS_LASTCHANGED'] < intval($this->register['SYS_LASTCHANGED'])) { 02559 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid='.intval($this->id), array('SYS_LASTCHANGED' => intval($this->register['SYS_LASTCHANGED']))); 02560 } 02561 } 02562 02563 02564 02565 02566 02567 02568 02569 02570 02571 02572 02573 02574 02575 02576 02577 02578 02579 02580 02581 02582 /******************************************** 02583 * 02584 * Page generation; rendering and inclusion 02585 * 02586 *******************************************/ 02587 02593 function generatePage_preProcessing() { 02594 ksort($this->all); 02595 // Same codeline as in getFromCache(). BUT $this->all has been set in the meantime, so we can't just skip this line and let it be set above! Keep this line! 02596 $this->newHash = $this->getHash(); 02597 $this->config['hash_base'] = $this->hash_base; // For cache management informational purposes. 02598 02599 // 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. 02600 $this->tempPageCacheContent(); 02601 02602 // Setting cache_timeout_default. May be overridden by PHP include scritps. 02603 $this->cacheTimeOutDefault = intval($this->config['config']['cache_period']); 02604 02605 // page is generated 02606 $this->no_cacheBeforePageGen = $this->no_cache; 02607 } 02608 02615 function generatePage_whichScript() { 02616 if (!$this->TYPO3_CONF_VARS['FE']['noPHPscriptInclude'] && $this->config['config']['pageGenScript']) { 02617 return $this->tmpl->getFileName($this->config['config']['pageGenScript']); 02618 } 02619 } 02620 02627 function generatePage_postProcessing() { 02628 // 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. 02629 if ($this->no_cacheBeforePageGen) $this->set_no_cache(); 02630 02631 // Tidy up the code, if flag... 02632 if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'all') { 02633 $GLOBALS['TT']->push('Tidy, all',''); 02634 $this->content = $this->tidyHTML($this->content); 02635 $GLOBALS['TT']->pull(); 02636 } 02637 02638 // XHTML-clean the code, if flag set 02639 if ($this->doXHTML_cleaning() == 'all') { 02640 $GLOBALS['TT']->push('XHTML clean, all',''); 02641 $XHTML_clean = t3lib_div::makeInstance('t3lib_parsehtml'); 02642 $this->content = $XHTML_clean->XHTML_clean($this->content); 02643 $GLOBALS['TT']->pull(); 02644 } 02645 02646 // Fix local anchors in links, if flag set 02647 if ($this->doLocalAnchorFix() == 'all') { 02648 $GLOBALS['TT']->push('Local anchor fix, all',''); 02649 $this->prefixLocalAnchorsWithScript(); 02650 $GLOBALS['TT']->pull(); 02651 } 02652 02653 // Hook for post-processing of page content cached/non-cached: 02654 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'])) { 02655 $_params = array('pObj' => &$this); 02656 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'] as $_funcRef) { 02657 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02658 } 02659 } 02660 02661 // Processing if caching is enabled: 02662 if (!$this->no_cache) { 02663 // Tidy up the code, if flag... 02664 if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'cached') { 02665 $GLOBALS['TT']->push('Tidy, cached',''); 02666 $this->content = $this->tidyHTML($this->content); 02667 $GLOBALS['TT']->pull(); 02668 } 02669 // XHTML-clean the code, if flag set 02670 if ($this->doXHTML_cleaning() == 'cached') { 02671 $GLOBALS['TT']->push('XHTML clean, cached',''); 02672 $XHTML_clean = t3lib_div::makeInstance('t3lib_parsehtml'); 02673 $this->content = $XHTML_clean->XHTML_clean($this->content); 02674 $GLOBALS['TT']->pull(); 02675 } 02676 // Fix local anchors in links, if flag set 02677 if ($this->doLocalAnchorFix() == 'cached') { 02678 $GLOBALS['TT']->push('Local anchor fix, cached',''); 02679 $this->prefixLocalAnchorsWithScript(); 02680 $GLOBALS['TT']->pull(); 02681 } 02682 02683 // Hook for post-processing of page content before being cached: 02684 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'])) { 02685 $_params = array('pObj' => &$this); 02686 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'] as $_funcRef) { 02687 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02688 } 02689 } 02690 } 02691 02692 // Convert char-set for output: (should be BEFORE indexing of the content (changed 22/4 2005)), because otherwise indexed search might convert from the wrong charset! One thing is that the charset mentioned in the HTML header would be wrong since the output charset (metaCharset) has not been converted to from renderCharset. And indexed search will internally convert from metaCharset to renderCharset so the content MUST be in metaCharset already! 02693 $this->content = $this->convOutputCharset($this->content,'mainpage'); 02694 02695 // Hook for indexing pages 02696 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageIndexing'])) { 02697 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageIndexing'] as $_classRef) { 02698 $_procObj = &t3lib_div::getUserObj($_classRef); 02699 $_procObj->hook_indexContent($this); 02700 } 02701 } 02702 02703 // Storing for cache: 02704 if (!$this->no_cache) { 02705 $this->realPageCacheContent(); 02706 } elseif ($this->tempContent) { // If there happens to be temporary content in the cache and the cache was not cleared due to new content put in it... ($this->no_cache=0) 02707 $this->clearPageCacheContent(); 02708 $this->tempContent = false; 02709 } 02710 02711 // Sets sys-last-change: 02712 $this->setSysLastChanged(); 02713 } 02714 02720 function INTincScript() { 02721 $GLOBALS['TT']->push('Split content'); 02722 $INTiS_splitC = explode('<!--INT_SCRIPT.',$this->content); // Splits content with the key. 02723 $this->content=''; 02724 $GLOBALS['TT']->setTSlogMessage('Parts: '.count($INTiS_splitC)); 02725 $GLOBALS['TT']->pull(); 02726 02727 // Deprecated stuff: 02728 $this->additionalHeaderData = is_array($this->config['INTincScript_ext']['additionalHeaderData']) ? $this->config['INTincScript_ext']['additionalHeaderData'] : array(); 02729 $this->additionalJavaScript = $this->config['INTincScript_ext']['additionalJavaScript']; 02730 $this->additionalCSS = $this->config['INTincScript_ext']['additionalCSS']; 02731 $this->JSCode = $this->additionalHeaderData['JSCode']; 02732 $this->JSImgCode = $this->additionalHeaderData['JSImgCode']; 02733 $this->divSection=''; 02734 02735 $INTiS_config = $GLOBALS['TSFE']->config['INTincScript']; 02736 foreach($INTiS_splitC as $INTiS_c => $INTiS_cPart) { 02737 if (substr($INTiS_cPart,32,3)=='-->') { // If the split had a comment-end after 32 characters it's probably a split-string 02738 $INTiS_key = 'INT_SCRIPT.'.substr($INTiS_cPart,0,32); 02739 $GLOBALS['TT']->push('Include '.$INTiS_config[$INTiS_key]['file'],''); 02740 $incContent=''; 02741 if (is_array($INTiS_config[$INTiS_key])) { 02742 $INTiS_cObj = unserialize($INTiS_config[$INTiS_key]['cObj']); 02743 $INTiS_cObj->INT_include=1; 02744 switch($INTiS_config[$INTiS_key]['type']) { 02745 case 'SCRIPT': 02746 $incContent = $INTiS_cObj->PHP_SCRIPT($INTiS_config[$INTiS_key]['conf']); 02747 break; 02748 case 'COA': 02749 $incContent = $INTiS_cObj->COBJ_ARRAY($INTiS_config[$INTiS_key]['conf']); 02750 break; 02751 case 'FUNC': 02752 $incContent = $INTiS_cObj->USER($INTiS_config[$INTiS_key]['conf']); 02753 break; 02754 case 'POSTUSERFUNC': 02755 $incContent = $INTiS_cObj->callUserFunction($INTiS_config[$INTiS_key]['postUserFunc'], $INTiS_config[$INTiS_key]['conf'], $INTiS_config[$INTiS_key]['content']); 02756 break; 02757 } 02758 } 02759 $this->content.= $this->convOutputCharset($incContent,'INC-'.$INTiS_c); 02760 $this->content.= substr($INTiS_cPart,35); 02761 $GLOBALS['TT']->pull($incContent); 02762 } else { 02763 $this->content.= ($INTiS_c?'<!--INT_SCRIPT.':'').$INTiS_cPart; 02764 } 02765 } 02766 $GLOBALS['TT']->push('Substitute header section'); 02767 $this->INTincScript_loadJSCode(); 02768 $this->content = str_replace('<!--HD_'.$this->config['INTincScript_ext']['divKey'].'-->', $this->convOutputCharset(implode(chr(10),$this->additionalHeaderData),'HD'), $this->content); 02769 $this->content = str_replace('<!--TDS_'.$this->config['INTincScript_ext']['divKey'].'-->', $this->convOutputCharset($this->divSection,'TDS'), $this->content); 02770 $this->setAbsRefPrefix(); 02771 $GLOBALS['TT']->pull(); 02772 } 02773 02780 function INTincScript_loadJSCode() { 02781 if ($this->JSImgCode) { // If any images added, then add them to the javascript section 02782 $this->additionalHeaderData['JSImgCode']=' 02783 <script type="text/javascript"> 02784 /*<![CDATA[*/ 02785 <!-- 02786 if (version == "n3") { 02787 '.trim($this->JSImgCode).' 02788 } 02789 // --> 02790 /*]]>*/ 02791 </script>'; 02792 } 02793 if ($this->JSCode || count($this->additionalJavaScript)) { // Add javascript 02794 $this->additionalHeaderData['JSCode']=' 02795 <script type="text/javascript"> 02796 /*<![CDATA[*/ 02797 <!-- 02798 '.implode(chr(10),$this->additionalJavaScript).' 02799 '.trim($this->JSCode).' 02800 // --> 02801 /*]]>*/ 02802 </script>'; 02803 } 02804 if (count($this->additionalCSS)) { // Add javascript 02805 $this->additionalHeaderData['_CSS']=' 02806 <style type="text/css"> 02807 /*<![CDATA[*/ 02808 <!-- 02809 '.implode(chr(10),$this->additionalCSS).' 02810 // --> 02811 /*]]>*/ 02812 </style>'; 02813 } 02814 } 02815 02821 function isINTincScript() { 02822 return (is_array($this->config['INTincScript']) && !$this->jumpurl); 02823 } 02824 02830 function doXHTML_cleaning() { 02831 return $this->config['config']['xhtml_cleaning']; 02832 } 02833 02839 function doLocalAnchorFix() { 02840 return $this->config['config']['prefixLocalAnchors']; 02841 } 02842 02843 02844 02845 02846 02847 02848 02849 02850 02851 02852 02853 02854 02855 02856 02857 02858 /******************************************** 02859 * 02860 * Finished off; outputting, storing session data, statistics... 02861 * 02862 *******************************************/ 02863 02870 function isOutputting() { 02871 02872 // Initialize by status of jumpUrl: 02873 $enableOutput = (!$this->jumpurl); 02874 02875 // Call hook for possible disabling of output: 02876 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['isOutputting'])) { 02877 $_params = array('pObj' => &$this, 'enableOutput' => &$enableOutput); 02878 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['isOutputting'] as $_funcRef) { 02879 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02880 } 02881 } 02882 02883 return $enableOutput; 02884 } 02885 02893 function processOutput() { 02894 02895 // Set header for charset-encoding unless disabled 02896 if (!$this->config['config']['disableCharsetHeader']) { 02897 $headLine = 'Content-Type:text/html;charset='.trim($this->metaCharset); 02898 header($headLine); 02899 } 02900 02901 // Set cache related headers to client (used to enable proxy / client caching!) 02902 if ($this->config['config']['sendCacheHeaders']) { 02903 $this->sendCacheHeaders(); 02904 } 02905 02906 // Set headers, if any 02907 if ($this->config['config']['additionalHeaders']) { 02908 $headerArray = explode('|', $this->config['config']['additionalHeaders']); 02909 while(list(,$headLine)=each($headerArray)) { 02910 $headLine = trim($headLine); 02911 header($headLine); 02912 } 02913 } 02914 02915 // Send appropriate status code in case of temporary content 02916 if ($this->tempContent) { 02917 $this->addTempContentHttpHeaders(); 02918 } 02919 02920 // Make substitution of eg. username/uid in content only if cache-headers for client/proxy caching is NOT sent! 02921 if (!$this->isClientCachable) { 02922 $this->contentStrReplace(); 02923 } 02924 02925 // Tidy up the code, if flag... 02926 if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'output') { 02927 $GLOBALS['TT']->push('Tidy, output',''); 02928 $this->content = $this->tidyHTML($this->content); 02929 $GLOBALS['TT']->pull(); 02930 } 02931 // XHTML-clean the code, if flag set 02932 if ($this->doXHTML_cleaning() == 'output') { 02933 $GLOBALS['TT']->push('XHTML clean, output',''); 02934 $XHTML_clean = t3lib_div::makeInstance('t3lib_parsehtml'); 02935 $this->content = $XHTML_clean->XHTML_clean($this->content); 02936 $GLOBALS['TT']->pull(); 02937 } 02938 // Fix local anchors in links, if flag set 02939 if ($this->doLocalAnchorFix() == 'output') { 02940 $GLOBALS['TT']->push('Local anchor fix, output',''); 02941 $this->prefixLocalAnchorsWithScript(); 02942 $GLOBALS['TT']->pull(); 02943 } 02944 02945 // Hook for post-processing of page content before output: 02946 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'])) { 02947 $_params = array('pObj' => &$this); 02948 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'] as $_funcRef) { 02949 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02950 } 02951 } 02952 02953 // Send content-lenght header. Notice that all HTML content outside the length of the content-length header will be cut off! Therefore content of unknown length from included PHP-scripts and if admin users are logged in (admin panel might show...) we disable it! 02954 if ($this->config['config']['enableContentLengthHeader'] && !$this->isEXTincScript() && !$this->beUserLogin && !$this->doWorkspacePreview()) { 02955 header('Content-Length: '.strlen($this->content)); 02956 } 02957 } 02958 02966 function sendCacheHeaders() { 02967 02968 // Getting status whether we can send cache control headers for proxy caching: 02969 $doCache = $this->isStaticCacheble(); 02970 02971 // This variable will be TRUE unless cache headers are configured to be sent ONLY if a branch does not allow logins and logins turns out to be allowed anyway... 02972 $loginsDeniedCfg = !$this->config['config']['sendCacheHeaders_onlyWhenLoginDeniedInBranch'] || !$this->loginAllowedInBranch; 02973 02974 // Finally, when backend users are logged in, do not send cache headers at all (Admin Panel might be displayed for instance). 02975 if ($doCache 02976 && !$this->beUserLogin 02977 && !$this->doWorkspacePreview() 02978 && $loginsDeniedCfg) { 02979 02980 // Build headers: 02981 $headers = array( 02982 'Last-Modified: '.gmdate('D, d M Y H:i:s T', $this->register['SYS_LASTCHANGED']), 02983 'Expires: '.gmdate('D, d M Y H:i:s T', $this->cacheExpires), 02984 'ETag: '.md5($this->content), 02985 'Cache-Control: max-age='.($this->cacheExpires - $GLOBALS['EXEC_TIME']), // no-cache 02986 'Pragma: public', 02987 ); 02988 02989 $this->isClientCachable = TRUE; 02990 } else { 02991 // Build headers: 02992 $headers = array( 02993 #'Last-Modified: '.gmdate('D, d M Y H:i:s T', $this->register['SYS_LASTCHANGED']), 02994 #'ETag: '.md5($this->content), 02995 02996 #'Cache-Control: no-cache', 02997 #'Pragma: no-cache', 02998 'Cache-Control: private', // Changed to this according to Ole Tange, FI.dk 02999 ); 03000 03001 $this->isClientCachable = FALSE; 03002 03003 // Now, if a backend user is logged in, tell him in the Admin Panel log what the caching status would have been: 03004 if ($this->beUserLogin) { 03005 if ($doCache) { 03006 $GLOBALS['TT']->setTSlogMessage('Cache-headers with max-age "'.($this->cacheExpires - $GLOBALS['EXEC_TIME']).'" would have been sent'); 03007 } else { 03008 $reasonMsg = ''; 03009 $reasonMsg.= !$this->no_cache ? '' : 'Caching disabled (no_cache). '; 03010 $reasonMsg.= !$this->isINTincScript() ? '' : '*_INT object(s) on page. '; 03011 $reasonMsg.= !$this->isEXTincScript() ? '' : '*_EXT object(s) on page. '; 03012 $reasonMsg.= !is_array($this->fe_user->user) ? '' : 'Frontend user logged in. '; 03013 $GLOBALS['TT']->setTSlogMessage('Cache-headers would disable proxy caching! Reason(s): "'.$reasonMsg.'"',1); 03014 } 03015 } 03016 } 03017 03018 // Send headers: 03019 foreach($headers as $hL) { 03020 header($hL); 03021 } 03022 } 03023 03034 function isStaticCacheble() { 03035 $doCache = !$this->no_cache 03036 && !$this->isINTincScript() 03037 && !$this->isEXTincScript() 03038 && !$this->isUserOrGroupSet(); 03039 return $doCache; 03040 } 03041 03047 function contentStrReplace() { 03048 // Substitutes username mark with the username 03049 if ($this->fe_user->user['uid']) { 03050 03051 // User name: 03052 $token = trim($this->config['config']['USERNAME_substToken']); 03053 $this->content = str_replace($token ? $token : '<!--###USERNAME###-->',$this->fe_user->user['username'],$this->content); 03054 03055 // User uid (if configured): 03056 $token = trim($this->config['config']['USERUID_substToken']); 03057 if ($token) { 03058 $this->content = str_replace($token, $this->fe_user->user['uid'], $this->content); 03059 } 03060 } 03061 // Substitutes get_URL_ID in case of GET-fallback 03062 if ($this->getMethodUrlIdToken) { 03063 $this->content = str_replace($this->getMethodUrlIdToken, $this->fe_user->get_URL_ID, $this->content); 03064 } 03065 } 03066 03073 function isEXTincScript() { 03074 return is_array($this->config['EXTincScript']); 03075 } 03076 03082 function storeSessionData() { 03083 $this->fe_user->storeSessionData(); 03084 } 03085 03092 function setParseTime() { 03093 // Compensates for the time consumed with Back end user initialization. 03094 $this->scriptParseTime = $GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_end']) 03095 - $GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_start']) 03096 - ($GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'])-$GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'])); 03097 } 03098 03104 function statistics() { 03105 if ($this->config['config']['stat'] && 03106 (!strcmp('',$this->config['config']['stat_typeNumList']) || t3lib_div::inList(str_replace(' ','',$this->config['config']['stat_typeNumList']), $this->type)) && 03107 (!$this->config['config']['stat_excludeBEuserHits'] || !$this->beUserLogin) && 03108 (!$this->config['config']['stat_excludeIPList'] || !t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'),str_replace(' ','',$this->config['config']['stat_excludeIPList'])))) { 03109 03110 $GLOBALS['TT']->push('Stat'); 03111 if (t3lib_extMgm::isLoaded('sys_stat') && $this->config['config']['stat_mysql']) { 03112 03113 // Jumpurl: 03114 $sword = t3lib_div::_GP('sword'); 03115 if ($sword) { 03116 $jumpurl_msg = 'sword:'.$sword; 03117 } elseif ($this->jumpurl) { 03118 $jumpurl_msg = 'jumpurl:'.$this->jumpurl; 03119 } else { 03120 $jumpurl_msg = ''; 03121 } 03122 03123 // Flags: bits: 0 = BE_user, 1=Cached page? 03124 $flags=0; 03125 if ($this->beUserLogin) {$flags|=1;} 03126 if ($this->cacheContentFlag) {$flags|=2;} 03127 03128 // Ref url: 03129 $refUrl = t3lib_div::getIndpEnv('HTTP_REFERER'); 03130 $thisUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR'); 03131 if (t3lib_div::isFirstPartOfStr($refUrl,$thisUrl)) { 03132 $refUrl='[LOCAL]'; 03133 } 03134 03135 $insertFields = array( 03136 'page_id' => intval($this->id), // id 03137 'page_type' => intval($this->type), // type 03138 'jumpurl' => $jumpurl_msg, // jumpurl message 03139 'feuser_id' => $this->fe_user->user['uid'], // fe_user id, integer 03140 'cookie' => $this->fe_user->id, // cookie as set or retrieve. If people has cookies disabled this will vary all the time... 03141 'sureCookie' => hexdec(substr($this->fe_user->cookieId,0,8)), // This is the cookie value IF the cookie WAS actually set. However the first hit where the cookie is set will thus NOT be logged here. So this lets you select for a session of at least two clicks... 03142 'rl0' => $this->config['rootLine'][0]['uid'], // RootLevel 0 uid 03143 'rl1' => $this->config['rootLine'][1]['uid'], // RootLevel 1 uid 03144 'client_browser' => $GLOBALS['CLIENT']['BROWSER'], // Client browser (net, msie, opera) 03145 'client_version' => $GLOBALS['CLIENT']['VERSION'], // Client version (double value) 03146 'client_os' => $GLOBALS['CLIENT']['SYSTEM'], // Client Operating system (win, mac, unix) 03147 'parsetime' => intval($this->scriptParseTime), // Parsetime for the page. 03148 'flags' => $flags, // Flags: Is be user logged in? Is page cached? 03149 'IP' => t3lib_div::getIndpEnv('REMOTE_ADDR'), // Remote IP address 03150 'host' => t3lib_div::getIndpEnv('REMOTE_HOST'), // Remote Host Address 03151 'referer' => $refUrl, // Referer URL 03152 'browser' => t3lib_div::getIndpEnv('HTTP_USER_AGENT'), // User Agent Info. 03153 'tstamp' => $GLOBALS['EXEC_TIME'] // Time stamp 03154 ); 03155 03156 // Hook for preprocessing the list of fields to insert into sys_stat: 03157 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sys_stat-PreProcClass'])) { 03158 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sys_stat-PreProcClass'] as $_classRef) { 03159 $_procObj = &t3lib_div::getUserObj($_classRef); 03160 $insertFields = $_procObj->sysstat_preProcessFields($insertFields,$this); 03161 } 03162 } 03163 03164 03165 $GLOBALS['TT']->push('Store SQL'); 03166 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_stat', $insertFields); 03167 $GLOBALS['TT']->pull(); 03168 } 03169 03170 // Apache: 03171 if ($this->config['config']['stat_apache'] && $this->config['stat_vars']['pageName']) { 03172 if (@is_file($this->config['stat_vars']['logFile'])) { 03173 $LogLine = ((t3lib_div::getIndpEnv('REMOTE_HOST') && !$this->config['config']['stat_apache_noHost']) ? t3lib_div::getIndpEnv('REMOTE_HOST') : t3lib_div::getIndpEnv('REMOTE_ADDR')).' - - '.Date('[d/M/Y:H:i:s +0000]',$GLOBALS['EXEC_TIME']).' "GET '.$this->config['stat_vars']['pageName'].' HTTP/1.1" 200 '.strlen($this->content); 03174 if (!$this->config['config']['stat_apache_notExtended']) { 03175 $LogLine.= ' "'.t3lib_div::getIndpEnv('HTTP_REFERER').'" "'.t3lib_div::getIndpEnv('HTTP_USER_AGENT').'"'; 03176 } 03177 03178 $GLOBALS['TT']->push('Write to log file (fputs)'); 03179 $logfilehandle = fopen($this->config['stat_vars']['logFile'], 'a'); 03180 fputs($logfilehandle, $LogLine.chr(10)); 03181 @fclose($logfilehandle); 03182 $GLOBALS['TT']->pull(); 03183 03184 $GLOBALS['TT']->setTSlogMessage('Writing to logfile: OK',0); 03185 } else { 03186 $GLOBALS['TT']->setTSlogMessage('Writing to logfile: Error - logFile did not exist!',3); 03187 } 03188 } 03189 $GLOBALS['TT']->pull(); 03190 } 03191 } 03192 03198 function previewInfo() { 03199 if ($this->fePreview) { 03200 03201 if ($this->fePreview==2) { 03202 $text = 'Preview of workspace "'.$this->whichWorkspace(TRUE).'" ('.$this->whichWorkspace().')'; 03203 } else { 03204 $text = 'PREVIEW!'; 03205 } 03206 03207 $stdMsg = ' 03208 <br /> 03209 <div align="center"> 03210 <table border="3" bordercolor="black" cellpadding="2" bgcolor="red"> 03211 <tr> 03212 <td> <font face="Verdana" size="1"><b>'.htmlspecialchars($text).'</b></font> </td> 03213 </tr> 03214 </table> 03215 </div>'; 03216 03217 if ($this->fePreview==2) { 03218 $temp_content = $this->config['config']['message_preview_workspace'] ? 03219 @sprintf($this->config['config']['message_preview_workspace'], $this->whichWorkspace(TRUE),$this->whichWorkspace()) : 03220 $stdMsg; 03221 } else { 03222 $temp_content = $this->config['config']['message_preview'] ? $this->config['config']['message_preview'] : $stdMsg; 03223 } 03224 echo $temp_content; 03225 } 03226 } 03227 03233 function hook_eofe() { 03234 03235 // Call hook for end-of-frontend processing: 03236 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe'])) { 03237 $_params = array('pObj' => &$this); 03238 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe'] as $_funcRef) { 03239 t3lib_div::callUserFunction($_funcRef,$_params,$this); 03240 } 03241 } 03242 } 03243 03249 function beLoginLinkIPList() { 03250 if ($this->config['config']['beLoginLinkIPList']) { 03251 if (t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $this->config['config']['beLoginLinkIPList'])) { 03252 $label = !$this->beUserLogin ? $this->config['config']['beLoginLinkIPList_login'] : $this->config['config']['beLoginLinkIPList_logout']; 03253 if ($label) { 03254 if (!$this->beUserLogin) { 03255 $link = '<a href="'.htmlspecialchars(TYPO3_mainDir.'index.php?redirect_url='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.$label.'</a>'; 03256 } else { 03257 $link = '<a href="'.htmlspecialchars(TYPO3_mainDir.'index.php?L=OUT&redirect_url='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.$label.'</a>'; 03258 } 03259 return $link; 03260 } 03261 } 03262 } 03263 } 03264 03270 function addTempContentHttpHeaders() { 03271 header('HTTP/1.0 503 Service unavailable'); 03272 header('Retry-after: 3600'); 03273 header('Pragma: no-cache'); 03274 header('Cache-control: no-cache'); 03275 header('Expire: 0'); 03276 } 03277 03278 03279 03280 03281 03282 03283 03284 03285 03286 03287 03288 03289 03290 03291 03292 03293 03294 03295 03296 03297 03298 /******************************************** 03299 * 03300 * Various internal API functions 03301 * 03302 *******************************************/ 03303 03304 03316 function makeSimulFileName($inTitle,$page,$type,$addParams='',$no_cache=false) { 03317 $titleChars = intval($this->config['config']['simulateStaticDocuments_addTitle']); 03318 // Default value is 30 but values > 1 will be override this 03319 if($titleChars==1) { $titleChars = 30; } 03320 03321 $out = ''; 03322 if ($titleChars) { 03323 $out = $this->fileNameASCIIPrefix($inTitle, $titleChars); 03324 } 03325 $enc = ''; 03326 03327 if (strcmp($addParams,'') && !$no_cache) { 03328 switch ((string)$this->config['config']['simulateStaticDocuments_pEnc']) { 03329 case 'md5': 03330 $md5 = substr(md5($addParams),0,10); 03331 $enc = '+M5'.$md5; 03332 03333 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('md5hash', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($md5, 'cache_md5params')); 03334 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 03335 $insertFields = array( 03336 'md5hash' => $md5, 03337 'tstamp' => time(), 03338 'type' => 1, 03339 'params' => $addParams 03340 ); 03341 03342 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_md5params', $insertFields); 03343 } 03344 break; 03345 case 'base64': 03346 $enc = '+B6'.str_replace('=','_',str_replace('/','-',base64_encode($addParams))); 03347 break; 03348 } 03349 } 03350 // Setting page and type number: 03351 $url = $out.$page.$enc; 03352 $url.= ($type || $out || !$this->config['config']['simulateStaticDocuments_noTypeIfNoTitle']) ? '.'.$type : ''; 03353 return $url; 03354 } 03355 03363 function simulateStaticDocuments_pEnc_onlyP_proc($linkVars) { 03364 $remainLinkVars = ''; 03365 if (strcmp($linkVars,'')) { 03366 $p = explode('&',$linkVars); 03367 sort($p); // This sorts the parameters - and may not be needed and further it will generate new MD5 hashes in many cases. Maybe not so smart. Hmm? 03368 $rem = array(); 03369 foreach($p as $k => $v) { 03370 if (strlen($v)) { 03371 list($pName) = explode('=',$v,2); 03372 $pName = rawurldecode($pName); 03373 if (!$this->pEncAllowedParamNames[$pName]) { 03374 unset($p[$k]); 03375 $rem[] = $v; 03376 } 03377 } else unset($p[$k]); 03378 } 03379 03380 $linkVars = count($p) ? '&'.implode('&',$p) : ''; 03381 $remainLinkVars = count($rem) ? '&'.implode('&',$rem) : ''; 03382 } 03383 return array($linkVars, $remainLinkVars); 03384 } 03385 03392 function getSimulFileName() { 03393 $url = ''; 03394 $url.= $this->makeSimulFileName($this->page['title'], $this->page['alias']?$this->page['alias']:$this->id, $this->type).'.html'; 03395 return $url; 03396 } 03397 03403 function setSimulReplacementChar() { 03404 $replacement = $defChar = t3lib_div::compat_version('4.0') ? '-' : '_'; 03405 if (isset($this->config['config']['simulateStaticDocuments_replacementChar'])) { 03406 $replacement = trim($this->config['config']['simulateStaticDocuments_replacementChar']); 03407 if (urlencode($replacement) != $replacement) { 03408 // Invalid character 03409 $replacement = $defChar; 03410 } 03411 } 03412 $this->config['config']['simulateStaticDocuments_replacementChar'] = $replacement; 03413 } 03414 03423 function fileNameASCIIPrefix($inTitle,$titleChars,$mergeChar='.') { 03424 $out = $this->csConvObj->specCharsToASCII($this->renderCharset, $inTitle); 03425 // Get replacement character 03426 $replacementChar = $this->config['config']['simulateStaticDocuments_replacementChar']; 03427 $replacementChars = '_\-' . ($replacementChar != '_' && $replacementChar != '-' ? $replacementChar : ''); 03428 $out = preg_replace('/[^A-Za-z0-9_-]/', $replacementChar, trim(substr($out, 0, $titleChars))); 03429 $out = preg_replace('/([' . $replacementChars . ']){2,}/', '\1', $out); 03430 $out = preg_replace('/[' . $replacementChars . ']?$/', '', $out); 03431 $out = preg_replace('/^[' . $replacementChars . ']?/', '', $out); 03432 if (strlen($out)) { 03433 $out.= $mergeChar; 03434 } 03435 03436 return $out; 03437 } 03438 03449 function encryptCharcode($n,$start,$end,$offset) { 03450 $n = $n + $offset; 03451 if ($offset > 0 && $n > $end) { 03452 $n = $start + ($n - $end - 1); 03453 } else if ($offset < 0 && $n < $start) { 03454 $n = $end - ($start - $n - 1); 03455 } 03456 return chr($n); 03457 } 03458 03466 function encryptEmail($string,$back=0) { 03467 $out = ''; 03468 03469 if ($this->spamProtectEmailAddresses === 'ascii') { 03470 for ($a=0; $a<strlen($string); $a++) { 03471 $out .= '&#'.ord(substr($string, $a, 1)).';'; 03472 } 03473 } else { 03474 // like str_rot13() but with a variable offset and a wider character range 03475 $len = strlen($string); 03476 $offset = intval($this->spamProtectEmailAddresses)*($back?-1:1); 03477 for ($i=0; $i<$len; $i++) { 03478 $charValue = ord($string{$i}); 03479 if ($charValue >= 0x2B && $charValue <= 0x3A) { // 0-9 . , - + / : 03480 $out .= $this->encryptCharcode($charValue,0x2B,0x3A,$offset); 03481 } elseif ($charValue >= 0x40 && $charValue <= 0x5A) { // A-Z @ 03482 $out .= $this->encryptCharcode($charValue,0x40,0x5A,$offset); 03483 } else if ($charValue >= 0x61 && $charValue <= 0x7A) { // a-z 03484 $out .= $this->encryptCharcode($charValue,0x61,0x7A,$offset); 03485 } else { 03486 $out .= $string{$i}; 03487 } 03488 } 03489 } 03490 return $out; 03491 } 03492 03502 function codeString($string, $decode=FALSE) { 03503 03504 if ($decode) { 03505 list($md5Hash, $str) = explode(':',$string,2); 03506 $newHash = substr(md5($this->TYPO3_CONF_VARS['SYS']['encryptionKey'].':'.$str),0,10); 03507 if (!strcmp($md5Hash, $newHash)) { 03508 $str = base64_decode($str); 03509 $str = $this->roundTripCryptString($str); 03510 return $str; 03511 } else return FALSE; // Decoding check failed! Original string not produced by this server! 03512 } else { 03513 $str = $string; 03514 $str = $this->roundTripCryptString($str); 03515 $str = base64_encode($str); 03516 $newHash = substr(md5($this->TYPO3_CONF_VARS['SYS']['encryptionKey'].':'.$str),0,10); 03517 return $newHash.':'.$str; 03518 } 03519 } 03520 03528 function roundTripCryptString($string) { 03529 $out = ''; 03530 $strLen = strlen($string); 03531 $cryptLen = strlen($this->TYPO3_CONF_VARS['SYS']['encryptionKey']); 03532 03533 for ($a=0; $a < $strLen; $a++) { 03534 $xorVal = $cryptLen>0 ? ord($this->TYPO3_CONF_VARS['SYS']['encryptionKey']{($a%$cryptLen)}) : 255; 03535 $out.= chr(ord($string{$a}) ^ $xorVal); 03536 } 03537 03538 return $out; 03539 } 03540 03548 function checkFileInclude($incFile) { 03549 return !$this->TYPO3_CONF_VARS['FE']['noPHPscriptInclude'] 03550 || substr($incFile,0,14)=='media/scripts/' 03551 || substr($incFile,0,4+strlen(TYPO3_mainDir))==TYPO3_mainDir.'ext/' 03552 || substr($incFile,0,7+strlen(TYPO3_mainDir))==TYPO3_mainDir.'sysext/' 03553 || substr($incFile,0,14)=='typo3conf/ext/'; 03554 } 03555 03563 function newCObj() { 03564 $this->cObj =t3lib_div::makeInstance('tslib_cObj'); 03565 $this->cObj->start($this->page,'pages'); 03566 } 03567 03576 function setAbsRefPrefix() { 03577 if ($this->absRefPrefix) { 03578 $this->content = str_replace('"media/', '"'.t3lib_extMgm::siteRelPath('cms').'tslib/media/', $this->content); 03579 $this->content = str_replace('"fileadmin/', '"'.$this->absRefPrefix.'fileadmin/', $this->content); 03580 } 03581 } 03582 03590 function baseUrlWrap($url) { 03591 if ($this->baseUrl) { 03592 $urlParts = parse_url($url); 03593 if (!strlen($urlParts['scheme']) && $url{0}!=='/') { 03594 $url = $this->baseUrl.$url; 03595 } 03596 } 03597 return $url; 03598 } 03599 03609 function printError($label,$header='Error!') { 03610 t3lib_timeTrack::debug_typo3PrintError($header,$label,0,t3lib_div::getIndpEnv('TYPO3_SITE_URL')); 03611 } 03612 03620 function updateMD5paramsRecord($hash) { 03621 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_md5params'), array('tstamp' => time())); 03622 } 03623 03631 function tidyHTML($content) { 03632 if ($this->TYPO3_CONF_VARS['FE']['tidy'] && $this->TYPO3_CONF_VARS['FE']['tidy_path']) { 03633 $oldContent = $content; 03634 $fname = t3lib_div::tempnam('typo3_tidydoc_'); // Create temporary name 03635 @unlink ($fname); // Delete if exists, just to be safe. 03636 $fp = fopen ($fname,'wb'); // Open for writing 03637 fputs ($fp, $content); // Put $content 03638 @fclose ($fp); // Close 03639 03640 exec ($this->TYPO3_CONF_VARS['FE']['tidy_path'].' '.$fname, $output); // run the $content through 'tidy', which formats the HTML to nice code. 03641 @unlink ($fname); // Delete the tempfile again 03642 $content = implode(chr(10),$output); 03643 if (!trim($content)) { 03644 $content = $oldContent; // Restore old content due empty return value. 03645 $GLOBALS['TT']->setTSlogMessage('"tidy" returned an empty value!',2); 03646 } 03647 $GLOBALS['TT']->setTSlogMessage('"tidy" content lenght: '.strlen($content),0); 03648 } 03649 return $content; 03650 } 03651 03657 function prefixLocalAnchorsWithScript() { 03658 $scriptPath = substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL'))); 03659 $this->content = preg_replace('/(<(a|area).*?href=")(#[^"]*")/i','$1' . htmlspecialchars($scriptPath) . '$3',$this->content); 03660 } 03661 03667 function workspacePreviewInit() { 03668 $previewWS = t3lib_div::_GP('ADMCMD_previewWS'); 03669 if ($this->beUserLogin && is_object($GLOBALS['BE_USER']) && t3lib_div::testInt($previewWS)) { 03670 if ($previewWS>=-1 && ($previewWS==0 || $GLOBALS['BE_USER']->checkWorkspace($previewWS))) { // Check Access to workspace. Live (0) is OK to preview for all. 03671 $this->workspacePreview = intval($previewWS); 03672 } else { 03673 $this->workspacePreview = -99; // No preview, will default to "Live" at the moment 03674 } 03675 } 03676 } 03677 03683 function doWorkspacePreview() { 03684 return (string)$this->workspacePreview!==''; 03685 } 03686 03693 function whichWorkspace($returnTitle = FALSE) { 03694 if ($this->doWorkspacePreview()) { 03695 $ws = intval($this->workspacePreview); 03696 } elseif ($this->beUserLogin) { 03697 $ws = $GLOBALS['BE_USER']->workspace; 03698 } else return FALSE; 03699 03700 if ($returnTitle) { 03701 if ($ws===-1) { 03702 return 'Default Draft Workspace'; 03703 } else { 03704 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('title', 'sys_workspace', 'uid='.intval($ws)); 03705 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 03706 return $row['title']; 03707 } 03708 } 03709 } else { 03710 return $ws; 03711 } 03712 } 03713 03714 03715 03716 03717 03718 03719 03720 03721 03722 03723 03724 03725 03726 03727 03728 03729 03730 03731 03732 03733 03734 03735 03736 03737 03738 03739 /******************************************** 03740 * 03741 * Various external API functions - for use in plugins etc. 03742 * 03743 *******************************************/ 03744 03745 03751 function getStorageSiterootPids() { 03752 $res=array(); 03753 reset($this->rootLine); 03754 while(list(,$rC)=each($this->rootLine)) { 03755 if (!$res['_STORAGE_PID']) $res['_STORAGE_PID']=intval($rC['storage_pid']); 03756 if (!$res['_SITEROOT']) $res['_SITEROOT']=$rC['is_siteroot']?intval($rC['uid']):0; 03757 } 03758 return $res; 03759 } 03760 03766 function getPagesTSconfig() { 03767 if (!is_array($this->pagesTSconfig)) { 03768 reset($this->rootLine); 03769 $TSdataArray = array(); 03770 $TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig']; // Setting default configuration: 03771 while(list($k,$v)=each($this->rootLine)) { 03772 $TSdataArray[]=$v['TSconfig']; 03773 } 03774 // Parsing the user TS (or getting from cache) 03775 $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray); 03776 $userTS = implode(chr(10).'[GLOBAL]'.chr(10),$TSdataArray); 03777 $hash = md5('pageTS:'.$userTS); 03778 $cachedContent = $this->sys_page->getHash($hash,0); 03779 if (isset($cachedContent)) { 03780 $this->pagesTSconfig = unserialize($cachedContent); 03781 } else { 03782 $parseObj = t3lib_div::makeInstance('t3lib_TSparser'); 03783 $parseObj->parse($userTS); 03784 $this->pagesTSconfig = $parseObj->setup; 03785 $this->sys_page->storeHash($hash,serialize($this->pagesTSconfig),'PAGES_TSconfig'); 03786 } 03787 } 03788 return $this->pagesTSconfig; 03789 } 03790 03799 function setJS($key,$content='') { 03800 if ($key) { 03801 switch($key) { 03802 case 'mouseOver': 03803 $this->additionalJavaScript[$key]= 03804 ' // JS function for mouse-over 03805 function over(name,imgObj) { // 03806 if (version == "n3" && document[name]) {document[name].src = eval(name+"_h.src");} 03807 else if (typeof(document.getElementById)=="function" && document.getElementById(name)) {document.getElementById(name).src = eval(name+"_h.src");} 03808 else if (imgObj) {imgObj.src = eval(name+"_h.src");} 03809 } 03810 // JS function for mouse-out 03811 function out(name,imgObj) { // 03812 if (version == "n3" && document[name]) {document[name].src = eval(name+"_n.src");} 03813 else if (typeof(document.getElementById)=="function" && document.getElementById(name)) {document.getElementById(name).src = eval(name+"_n.src");} 03814 else if (imgObj) {imgObj.src = eval(name+"_n.src");} 03815 }'; 03816 break; 03817 case 'openPic': 03818 $this->additionalJavaScript[$key]= 03819 ' function openPic(url,winName,winParams) { // 03820 var theWindow = window.open(url,winName,winParams); 03821 if (theWindow) {theWindow.focus();} 03822 }'; 03823 break; 03824 default: 03825 $this->additionalJavaScript[$key]=$content; 03826 break; 03827 } 03828 } 03829 } 03830 03839 function setCSS($key,$content) { 03840 if ($key) { 03841 switch($key) { 03842 default: 03843 $this->additionalCSS[$key]=$content; 03844 break; 03845 } 03846 } 03847 } 03848 03854 function make_seed() { 03855 list($usec, $sec) = explode(' ', microtime()); 03856 $seedV = (float)$sec + ((float)$usec * 100000); 03857 srand($seedV); 03858 } 03859 03867 function uniqueHash($str='') { 03868 return md5($this->uniqueString.'_'.$str.$this->uniqueCounter++); 03869 } 03870 03876 function set_no_cache() { 03877 $this->no_cache = 1; 03878 } 03879 03886 function set_cache_timeout_default($seconds) { 03887 $this->cacheTimeOutDefault = intval($seconds); 03888 } 03889 03902 function plainMailEncoded($email,$subject,$message,$headers='') { 03903 $urlmode = $this->config['config']['notification_email_urlmode']; // '76', 'all', '' 03904 03905 if ($urlmode) { 03906 $message = t3lib_div::substUrlsInPlainText($message,$urlmode); 03907 } 03908 03909 $encoding = $this->config['config']['notification_email_encoding'] ? $this->config['config']['notification_email_encoding'] : ''; 03910 $charset = $this->renderCharset; 03911 03912 $convCharset = FALSE; // do we need to convert mail data? 03913 if ($this->config['config']['notification_email_charset']) { // Respect config.notification_email_charset if it was set 03914 $charset = $this->csConvObj->parse_charset($this->config['config']['notification_email_charset']); 03915 if ($charset != $this->renderCharset) { 03916 $convCharset = TRUE; 03917 } 03918 03919 } elseif ($this->metaCharset != $this->renderCharset) { // Use metaCharset for mail if different from renderCharset 03920 $charset = $this->metaCharset; 03921 $convCharset = TRUE; 03922 } 03923 03924 if ($convCharset) { 03925 $email = $this->csConvObj->conv($email,$this->renderCharset,$charset); 03926 $subject = $this->csConvObj->conv($subject,$this->renderCharset,$charset); 03927 $message = $this->csConvObj->conv($message,$this->renderCharset,$charset); 03928 $headers = $this->csConvObj->conv($headers,$this->renderCharset,$charset); 03929 } 03930 03931 t3lib_div::plainMailEncoded( 03932 $email, 03933 $subject, 03934 $message, 03935 $headers, 03936 $encoding, 03937 $charset 03938 ); 03939 } 03940 03941 03942 03943 03944 03945 03946 03947 03948 03949 03950 03951 03952 03953 /********************************************* 03954 * 03955 * Localization and character set conversion 03956 * 03957 *********************************************/ 03958 03965 function sL($input) { 03966 if (strcmp(substr($input,0,4),'LLL:')) { 03967 $t = explode('|',$input); 03968 return $t[$this->langSplitIndex] ? $t[$this->langSplitIndex] : $t[0]; 03969 } else { 03970 if (!isset($this->LL_labels_cache[$this->lang][$input])) { // If cached label 03971 $restStr = trim(substr($input,4)); 03972 $extPrfx=''; 03973 if (!strcmp(substr($restStr,0,4),'EXT:')) { 03974 $restStr = trim(substr($restStr,4)); 03975 $extPrfx='EXT:'; 03976 } 03977 $parts = explode(':',$restStr); 03978 $parts[0]=$extPrfx.$parts[0]; 03979 if (!isset($this->LL_files_cache[$parts[0]])) { // Getting data if not cached 03980 $this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]); 03981 } 03982 $this->LL_labels_cache[$this->lang][$input] = $this->csConv($this->getLLL($parts[1],$this->LL_files_cache[$parts[0]])); 03983 } 03984 return $this->LL_labels_cache[$this->lang][$input]; 03985 } 03986 } 03987 03994 function readLLfile($fileRef) { 03995 return t3lib_div::readLLfile($fileRef,$this->lang); 03996 } 03997 04005 function getLLL($index,$LOCAL_LANG) { 04006 if (strcmp($LOCAL_LANG[$this->lang][$index],'')) { 04007 return $LOCAL_LANG[$this->lang][$index]; 04008 } else { 04009 return $LOCAL_LANG['default'][$index]; 04010 } 04011 } 04012 04019 function initLLvars() { 04020 04021 // Setting language key and split index: 04022 $this->lang = $this->config['config']['language'] ? $this->config['config']['language'] : 'default'; 04023 04024 $ls = explode('|',TYPO3_languages); 04025 while(list($i,$v)=each($ls)) { 04026 if ($v==$this->lang) {$this->langSplitIndex=$i; break;} 04027 } 04028 04029 // Setting charsets: 04030 $this->renderCharset = $this->csConvObj->parse_charset($this->config['config']['renderCharset'] ? $this->config['config']['renderCharset'] : ($this->TYPO3_CONF_VARS['BE']['forceCharset'] ? $this->TYPO3_CONF_VARS['BE']['forceCharset'] : $this->defaultCharSet)); // Rendering charset of HTML page. 04031 $this->metaCharset = $this->csConvObj->parse_charset($this->config['config']['metaCharset'] ? $this->config['config']['metaCharset'] : $this->renderCharset); // Output charset of HTML page. 04032 $this->labelsCharset = $this->csConvObj->parse_charset($this->csConvObj->charSetArray[$this->lang] ? $this->csConvObj->charSetArray[$this->lang] : 'iso-8859-1'); 04033 if ($this->renderCharset != $this->labelsCharset) { 04034 $this->convCharsetToFrom = array( 04035 'from' => $this->labelsCharset, 04036 'to' => $this->renderCharset 04037 ); 04038 } 04039 } 04040 04053 function csConv($str,$from='') { 04054 if ($from) { 04055 $output = $this->csConvObj->conv($str,$this->csConvObj->parse_charset($from),$this->renderCharset,1); 04056 return $output ? $output : $str; 04057 } elseif (is_array($this->convCharsetToFrom)) { 04058 return $this->csConvObj->conv($str,$this->convCharsetToFrom['from'],$this->convCharsetToFrom['to'],1); 04059 } else { 04060 return $str; 04061 } 04062 } 04063 04071 function convOutputCharset($content,$label='') { 04072 if ($this->renderCharset != $this->metaCharset) { 04073 $content = $this->csConvObj->conv($content,$this->renderCharset,$this->metaCharset,TRUE); 04074 } 04075 04076 return $content; 04077 } 04078 04084 function convPOSTCharset() { 04085 if ($this->renderCharset != $this->metaCharset && is_array($_POST) && count($_POST)) { 04086 $this->csConvObj->convArray($_POST,$this->metaCharset,$this->renderCharset); 04087 $GLOBALS['HTTP_POST_VARS'] = $_POST; 04088 } 04089 } 04090 } 04091 04092 04093 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']) { 04094 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']); 04095 } 04096 ?>