Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00201 class tslib_fe { 00202 00203 // CURRENT PAGE: 00204 var $id=''; // The page id (int) 00205 var $type=''; // RO The type (int) 00206 var $idParts=array(); // Loaded with the id, exploded by ',' 00207 var $cHash=''; // The submitted cHash 00208 var $no_cache=''; // Page will not be cached. Write only true. Never clear value (some other code might have reasons to set it true) 00209 var $rootLine=''; // The rootLine (all the way to tree root, not only the current site!) (array) 00210 var $page=''; // The pagerecord (array) 00211 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. 00212 var $sys_page=''; // The object with pagefunctions (object) 00213 var $jumpurl=''; 00214 var $pageNotFound=0; // Is set to 1 if a pageNotFound handler could have been called. 00215 var $domainStartPage=0; // Domain start page 00216 var $pageAccessFailureHistory=array(); // Array containing a history of why a requested page was not accessible. 00217 var $MP=''; 00218 var $RDCT=''; 00219 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... 00220 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. 00221 00222 // USER 00223 var $fe_user=''; // The user (object) 00224 var $loginUser=''; // Global falg 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. 00225 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... 00226 var $beUserLogin=''; // Flag that indicates if a Backend user is logged in! 00227 var $loginAllowedInBranch = TRUE; // Shows whether logins are allowed in branch 00228 00229 // PREVIEW 00230 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. 00231 var $showHiddenPage=''; // Flag indicating that hidden pages should be shown, selected and so on. This goes for almost all selection of pages! 00232 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. 00233 var $simUserGroup='0'; // Value that contains the simulated usergroup if any 00234 var $versionPreviewMap=array(); // Versioning Preview record map (temporary, for sys_page) 00235 00236 // CONFIGURATION 00237 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. 00238 var $config=''; // 'CONFIG' object from TypoScript. Array generated based on the TypoScript configuration of the current page. Saved with the cached pages. 00239 var $TCAcachedExtras=array(); // Array of cached information from TCA. This is NOT TCA itself! 00240 00241 // TEMPLATE / CACHE 00242 var $tmpl=''; // The TypoScript template object. Used to parse the TypoScript template 00243 var $cacheTimeOutDefault=''; // Is set to the time-to-live time of cached pages. If false, default is 60*60*24, which is 24 hours. 00244 var $cacheContentFlag=''; // Set internally if cached content is fetched from the database 00245 var $cacheExpires=0; // Set to the expire time of cached content 00246 var $isClientCachable=FALSE; // Set if cache headers allowing caching are sent. 00247 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. 00248 var $sPre=''; // toplevel - objArrayName, eg 'page' 00249 var $pSetup=''; // TypoScript configuration of the page-object pointed to by sPre. $this->tmpl->setup[$this->sPre.'.'] 00250 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 00251 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 00252 var $noCacheBeforePageGen=''; // 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. 00253 var $tempContent = FALSE; // This flag indicates if temporary content went into the cache during page-generation. 00254 var $forceTemplateParsing=''; // Boolean, passed to TypoScript template class and tells it to render the template forcibly 00255 var $cHash_array=array(); // The array which cHash_calc is based on, see ->makeCacheHash(). 00256 var $hash_base=''; // Loaded with the serialized array that is used for generating a hashstring for the cache 00257 var $pagesTSconfig=''; // May be set to the pagesTSconfig 00258 // PAGE-GENERATION / cOBJ 00259 /* 00260 Eg. insert JS-functions in this array ($additionalHeaderData) to include them once. Use associative keys. 00261 Keys in use: 00262 JSFormValidate : <script type="text/javascript" src="'.$GLOBALS["TSFE"]->absRefPrefix.'t3lib/jsfunc.validateform.js"></script> 00263 JSincludeFormupdate : <script type="text/javascript" src="t3lib/jsfunc.updateform.js"></script> 00264 JSMenuCode, JSMenuCode_menu : JavaScript for the JavaScript menu 00265 JSCode : reserved 00266 JSImgCode : reserved 00267 */ 00268 var $defaultBodyTag='<body bgcolor="#FFFFFF">'; // Default bodytag, if nothing else is set. This can be overridden by applications like TemplaVoila. 00269 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[] = '...') 00270 var $additionalJavaScript=array(); // used to accumulate additional JavaScript-code. Works like additionalHeaderData. Reserved keys at 'openPic' and 'mouseOver' 00271 var $additionalCSS=array(); // used to accumulate additional Style code. Works like additionalHeaderData. 00272 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 00273 'onmousemove' => array(), 00274 'onmouseup' => array(), 00275 'onload' => array(), 00276 ); 00277 var $JSCode=''; // Depreciated, use additionalJavaScript instead. 00278 var $JSImgCode=''; // Used to accumulate JavaScript loaded images (by menus) 00279 var $divSection=''; // Used to accumulate DHTML-layers. 00280 00281 // RENDERING configuration, settings from TypoScript is loaded into these vars. See pagegen.php 00282 var $debug=''; // Debug flag, may output special debug html-code. 00283 var $intTarget=''; // Default internal target 00284 var $extTarget=''; // Default external target 00285 var $MP_defaults=array(); // Keys are page ids and values are default &MP (mount point) values to set when using the linking features...) 00286 var $spamProtectEmailAddresses=0; // If set, typolink() function encrypts email addresses. Is set in pagegen-class. 00287 var $absRefPrefix=''; // Absolute Reference prefix 00288 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 '/' 00289 var $compensateFieldWidth=''; // Factor for form-field widths compensation 00290 var $lockFilePath=''; // Lock file path 00291 var $ATagParams=''; // <A>-tag parameters 00292 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. 00293 var $sWordList=''; // Is set to the incoming array sword_list in case of a page-view jumped to from a search-result. 00294 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. 00295 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. 00296 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. 00297 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. 00298 var $sys_language_uid=0; // Site language, 0 (zero) is default, int+ is uid pointing to a sys_language record. Should reflect which language it DOES actually display! 00299 var $sys_language_mode=''; // Site language mode 00300 var $sys_language_content=0; // Site content selection uid 00301 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...] 00302 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") 00303 00304 // RENDERING data 00305 var $applicationData=Array(); // 'Global' Storage for various applications. Keys should be 'tx_'.extKey for extensions. 00306 var $register=Array(); 00307 var $registerStack=Array(); // Stack used for storing array and retrieving register arrays (see LOAD_REGISTER and CLEAR_REGISTER) 00308 var $cObjectDepthCounter = 50; // Checking that the function is not called eternally. This is done by interrupting at a depth of 50 00309 var $recordRegister = Array(); // used by cObj->RECORDS and cObj->CONTENT to ensure the a records is NOT rendered twice through it! 00310 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 00311 var $accessKey =array(); // Used by class tslib_menu to keep track of access-keys. 00312 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. 00313 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 00314 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() 00315 var $uniqueString=''; 00316 var $indexedDocTitle=''; // This value will be used as the title for the page in the indexer (if indexing happens) 00317 var $altPageTitle=''; // Alternative page title (normally the title of the page record). Can be set from applications you make. 00318 var $pEncAllowedParamNames=array(); // An array that holds parameter names (keys) of GET parameters which MAY be MD5/base64 encoded with simulate_static_documents method. 00319 var $baseUrl=''; // The Base url set for the page header. 00320 var $anchorPrefix=''; // The proper anchor prefix needed when using speaking urls. (only set if baseUrl is set) 00321 00322 // Page content render object 00323 var $cObj =''; // is instantiated object of tslib_cObj 00324 00325 // CONTENT accumulation 00326 var $content=''; // All page content is accumulated in this variable. See pagegen.php 00327 00328 // GENERAL 00329 var $clientInfo=''; // Set to the browser: net / msie if 4+ browsers 00330 var $scriptParseTime=0; 00331 var $TCAloaded = 0; // Set ONLY if the full TCA is loaded 00332 00333 // Character set (charset) conversion object: 00334 var $csConvObj; // An instance of the "t3lib_cs" class. May be used by any application. 00335 var $defaultCharSet = 'iso-8859-1'; // The default charset used in the frontend if nothing else is set. 00336 var $renderCharset=''; // Internal charset of the frontend during rendering: Defaults to "forceCharset" and if that is not set, to ->defaultCharSet 00337 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. 00338 var $localeCharset=''; // Assumed charset of locale strings. 00339 00340 // LANG: 00341 var $lang=''; // Set to the system language key (used on the site) 00342 var $langSplitIndex=0; // Set to the index number of the language key 00343 var $labelsCharset=''; // Charset of the labels from locallang (based on $this->lang) 00344 var $convCharsetToFrom=''; // Set to the charsets to convert from/to IF there are any difference. Otherwise this stays a string 00345 var $LL_labels_cache=array(); 00346 var $LL_files_cache=array(); 00347 00348 00349 00350 00351 00369 function tslib_fe($TYPO3_CONF_VARS, $id, $type, $no_cache='', $cHash='', $jumpurl='',$MP='',$RDCT='') { 00370 00371 // Setting some variables: 00372 $this->TYPO3_CONF_VARS = $TYPO3_CONF_VARS; 00373 $this->id = $id; 00374 $this->type = $type; 00375 $this->no_cache = $no_cache ? 1 : 0; 00376 $this->cHash = $cHash; 00377 $this->jumpurl = $jumpurl; 00378 $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? (string)$MP : ''; 00379 $this->RDCT = $RDCT; 00380 $this->clientInfo = t3lib_div::clientInfo(); 00381 $this->uniqueString=md5(microtime()); 00382 00383 $this->csConvObj = t3lib_div::makeInstance('t3lib_cs'); 00384 00385 // Call post processing function for constructor: 00386 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'])) { 00387 $_params = array('pObj' => &$this); 00388 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef) { 00389 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00390 } 00391 } 00392 } 00393 00402 function connectToMySQL() { 00403 $this->connectToDB(); 00404 } 00405 00412 function connectToDB() { 00413 if ($GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { 00414 if (!TYPO3_db) { 00415 $this->printError('No database selected','Database Error'); 00416 // Redirects to the Install Tool: 00417 echo '<script type="text/javascript"> 00418 /*<![CDATA[*/ 00419 document.location = "'.TYPO3_mainDir.'install/index.php?mode=123&step=1&password=joh316"; 00420 /*]]>*/ 00421 </script>'; 00422 exit; 00423 } elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) { 00424 $this->printError('Cannot connect to the current database, "'.TYPO3_db.'"','Database Error'); 00425 exit; 00426 } 00427 } else { 00428 if (!TYPO3_db) { 00429 // Redirects to the Install Tool: 00430 echo '<script type="text/javascript"> 00431 /*<![CDATA[*/ 00432 document.location = "'.TYPO3_mainDir.'install/index.php?mode=123&step=1&password=joh316"; 00433 /*]]>*/ 00434 </script>'; 00435 exit; 00436 } 00437 $this->printError('The current username, password or host was not accepted when the connection to the database was attempted to be established!','Database Error'); 00438 exit; 00439 } 00440 00441 00442 // Call post processing function for DB connection: 00443 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'])) { 00444 $_params = array('pObj' => &$this); 00445 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'] as $_funcRef) { 00446 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00447 } 00448 } 00449 } 00450 00457 function sendRedirect() { 00458 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->RDCT, 'cache_md5params')); 00459 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00460 $this->updateMD5paramsRecord($this->RDCT); 00461 header('Location: '.$row['params']); 00462 exit; 00463 } 00464 } 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 /******************************************** 00484 * 00485 * Initializing, resolving page id 00486 * 00487 ********************************************/ 00488 00489 00495 function initFEuser() { 00496 $this->fe_user = t3lib_div::makeInstance('tslib_feUserAuth'); 00497 00498 $this->fe_user->lockIP = $this->TYPO3_CONF_VARS['FE']['lockIP']; 00499 $this->fe_user->lockHashKeyWords = $this->TYPO3_CONF_VARS['FE']['lockHashKeyWords']; 00500 $this->fe_user->checkPid = $this->TYPO3_CONF_VARS['FE']['checkFeUserPid']; 00501 $this->fe_user->lifetime = intval($this->TYPO3_CONF_VARS['FE']['lifetime']); 00502 $this->fe_user->checkPid_value = $GLOBALS['TYPO3_DB']->cleanIntList(t3lib_div::_GP('pid')); // List of pid's acceptable 00503 00504 // Check if a session is transferred: 00505 if (t3lib_div::_GP('FE_SESSION_KEY')) { 00506 $fe_sParts = explode('-',t3lib_div::_GP('FE_SESSION_KEY')); 00507 if (!strcmp(md5($fe_sParts[0].'/'.$this->TYPO3_CONF_VARS['SYS']['encryptionKey']), $fe_sParts[1])) { // If the session key hash check is OK: 00508 $_COOKIE[$this->fe_user->name] = $fe_sParts[0]; 00509 $this->fe_user->forceSetCookie = 1; 00510 } 00511 } 00512 00513 if ($this->TYPO3_CONF_VARS['FE']['dontSetCookie']) { 00514 $this->fe_user->dontSetCookie=1; 00515 } 00516 00517 $this->fe_user->start(); 00518 $this->fe_user->unpack_uc(''); 00519 $this->fe_user->fetchSessionData(); // Gets session data 00520 $recs = t3lib_div::_GP('recs'); 00521 if (is_array($recs)) { // If any record registration is submitted, register the record. 00522 $this->fe_user->record_registration($recs, $this->TYPO3_CONF_VARS['FE']['maxSessionDataSize']); 00523 } 00524 00525 // Call hook for possible manipulation of frontend user object 00526 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'])) { 00527 $_params = array('pObj' => &$this); 00528 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] as $_funcRef) { 00529 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00530 } 00531 } 00532 00533 // For every 60 seconds the is_online timestamp is updated. 00534 if (is_array($this->fe_user->user) && $this->fe_user->user['uid'] && $this->fe_user->user['is_online']<($GLOBALS['EXEC_TIME']-60)) { 00535 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid='.intval($this->fe_user->user['uid']), array('is_online' => $GLOBALS['EXEC_TIME'])); 00536 } 00537 } 00538 00545 function initUserGroups() { 00546 00547 $this->fe_user->showHiddenRecords = $this->showHiddenRecords; // This affects the hidden-flag selecting the fe_groups for the user! 00548 $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!) 00549 00550 if (is_array($this->fe_user->user) && count($this->fe_user->groupData['uid'])) { 00551 $this->loginUser=1; // global flag! 00552 $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! 00553 $gr_array = $this->fe_user->groupData['uid']; 00554 } else { 00555 $this->loginUser=0; 00556 $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! 00557 00558 if ($this->loginAllowedInBranch) { 00559 $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. 00560 } else { 00561 $gr_array = array(); // Set to blank since we will NOT risk any groups being set when no logins are allowed! 00562 } 00563 } 00564 00565 // Clean up. 00566 $gr_array = array_unique($gr_array); // Make unique... 00567 sort($gr_array); // sort 00568 if (count($gr_array)) { 00569 $this->gr_list.=','.implode(',',$gr_array); 00570 } 00571 00572 if ($this->fe_user->writeDevLog) t3lib_div::devLog('Valid usergroups for TSFE: '.$this->gr_list, 'tslib_fe'); 00573 } 00574 00580 function isUserOrGroupSet() { 00581 return is_array($this->fe_user->user) || $this->gr_list!=='0,-1'; 00582 } 00583 00605 function checkAlternativeIdMethods() { 00606 00607 $this->siteScript = t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT'); 00608 00609 // Resolving of "simulateStaticDocuments" URLs: 00610 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 00611 $uParts = parse_url($this->siteScript); // Parse the path: 00612 $fI = t3lib_div::split_fileref($uParts['path']); 00613 00614 if (!$fI['path'] && $fI['file'] && substr($fI['file'],-5)=='.html') { 00615 $parts = explode('.',$fI['file']); 00616 $pCount = count($parts); 00617 if ($pCount>2) { 00618 $this->type = intval($parts[$pCount-2]); 00619 $this->id = $parts[$pCount-3]; 00620 } else { 00621 $this->type = 0; 00622 $this->id = $parts[0]; 00623 } 00624 } 00625 } 00626 00627 // If PATH_INFO 00628 if (t3lib_div::getIndpEnv('PATH_INFO')) { // If pathinfo contains stuff... 00629 $parts=t3lib_div::trimExplode('/',t3lib_div::getIndpEnv('PATH_INFO'),1); 00630 $parts[]='html'; 00631 $pCount = count($parts); 00632 if ($pCount>2) { 00633 $this->type = intval($parts[$pCount-2]); 00634 $this->id = $parts[$pCount-3]; 00635 } else { 00636 $this->type = 0; 00637 $this->id = $parts[0]; 00638 } 00639 $this->absRefPrefix_force=1; 00640 } 00641 00642 // Call post processing function for custom URL methods. 00643 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'])) { 00644 $_params = array('pObj' => &$this); 00645 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef) { 00646 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00647 } 00648 } 00649 } 00650 00657 function clear_preview() { 00658 $this->showHiddenPage = 0; 00659 $this->showHiddenRecords = 0; 00660 $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME']; 00661 $this->fePreview = 0; 00662 } 00663 00670 function determineId() { 00671 00672 // Getting ARG-v values if some 00673 $this->setIDfromArgV(); 00674 00675 // If there is a Backend login we are going to check for any preview settings: 00676 $GLOBALS['TT']->push('beUserLogin',''); 00677 if ($this->beUserLogin) { 00678 $this->fePreview = $GLOBALS['BE_USER']->extGetFeAdminValue('preview'); 00679 00680 // If admin panel preview is enabled... 00681 if ($this->fePreview) { 00682 $fe_user_OLD_USERGROUP = $this->fe_user->user['usergroup']; 00683 00684 $this->showHiddenPage = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenPages'); 00685 $this->showHiddenRecords = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenRecords'); 00686 // simulate date 00687 $simTime = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateDate'); 00688 if ($simTime) $GLOBALS['SIM_EXEC_TIME']=$simTime; 00689 // simulate user 00690 $simUserGroup = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateUserGroup'); 00691 $this->simUserGroup = $simUserGroup; 00692 if ($simUserGroup) $this->fe_user->user['usergroup']=$simUserGroup; 00693 if (!$simUserGroup && !$simTime && !$this->showHiddenPage && !$this->showHiddenRecords) { 00694 $this->fePreview=0; 00695 } 00696 } 00697 00698 // Now it's investigated if the raw page-id points to a hidden page and if so, the flag is set. 00699 // This does not require the preview flag to be set in the admin panel 00700 if ($this->id) { 00701 $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... 00702 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('hidden', 'pages', $idQ.' AND hidden!=0 AND deleted=0'); 00703 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 00704 $this->fePreview = 1; // The preview flag is set only if the current page turns out to actually be hidden! 00705 $this->showHiddenPage = 1; 00706 } 00707 00708 // Check root line for proper connection to tree root (done because of possible preview of page / branch versions) 00709 if (!$this->fePreview) { 00710 00711 // Initialize the page-select functions to check rootline: 00712 $temp_sys_page = t3lib_div::makeInstance('t3lib_pageSelect'); 00713 $temp_sys_page->init($this->showHiddenPage); 00714 00715 // If root line contained NO records and ->error_getRootLine_failPid tells us that it was because of a pid=-1 (indicating a "version" record)...: 00716 if (!count($temp_sys_page->getRootLine($this->id,$this->MP)) && $temp_sys_page->error_getRootLine_failPid==-1) { 00717 00718 // Setting versioningPreview flag and try again: 00719 $temp_sys_page->versioningPreview = TRUE; 00720 if (count($temp_sys_page->getRootLine($this->id,$this->MP))) { 00721 // 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. 00722 $this->fePreview = 1; 00723 #debug('version in rootline...'); 00724 } 00725 } 00726 } 00727 } 00728 00729 // Checking for specific version preview of records: 00730 if (is_array(t3lib_div::_GP('ADMCMD_vPrev'))) { 00731 $this->fePreview = 1; 00732 $this->versionPreviewMap = t3lib_div::_GP('ADMCMD_vPrev'); 00733 } 00734 00735 if ($this->fePreview) { // If the front-end is showing a preview, caching MUST be disabled. 00736 $this->set_no_cache(); 00737 } 00738 } 00739 $GLOBALS['TT']->pull(); 00740 00741 // Now, get the id, validate access etc: 00742 $this->fetch_the_id(); 00743 00744 // Check if backend user has read access to this page. If not, recalculate the id. 00745 if ($this->beUserLogin && $this->fePreview) { 00746 if (!$GLOBALS['BE_USER']->doesUserHaveAccess($this->page,1)) { 00747 // Resetting 00748 $this->clear_preview(); 00749 $this->fe_user->user['usergroup'] = $fe_user_OLD_USERGROUP; 00750 00751 // Fetching the id again, now with the preview settings reset. 00752 $this->fetch_the_id(); 00753 } 00754 } 00755 00756 // Checks if user logins are blocked for a certain branch and if so, will unset user login and re-fetch ID. 00757 $this->loginAllowedInBranch = $this->checkIfLoginAllowedInBranch(); 00758 if (!$this->loginAllowedInBranch) { // Logins are not allowed: 00759 if ($this->isUserOrGroupSet()) { // Only if there is a login will we run this... 00760 00761 // Clear out user and group: 00762 unset($this->fe_user->user); 00763 $this->gr_list = '0,-1'; 00764 00765 // Fetching the id again, now with the preview settings reset. 00766 $this->fetch_the_id(); 00767 } 00768 } 00769 00770 // Final cleaning. 00771 $this->id = $this->contentPid = intval($this->id); // Make sure it's an integer 00772 $this->type = intval($this->type); // Make sure it's an integer 00773 00774 // Call post processing function for id determination: 00775 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) { 00776 $_params = array('pObj' => &$this); 00777 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef) { 00778 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00779 } 00780 } 00781 } 00782 00791 function fetch_the_id() { 00792 $GLOBALS['TT']->push('fetch_the_id initialize/',''); 00793 00794 // Initialize the page-select functions. 00795 $this->sys_page = t3lib_div::makeInstance('t3lib_pageSelect'); 00796 $this->sys_page->init($this->showHiddenPage); 00797 $this->sys_page->versioningPreview = $this->fePreview ? TRUE : FALSE; 00798 if ($this->sys_page->versioningPreview) { 00799 $this->sys_page->versionPreviewMap = $this->versionPreviewMap; 00800 } 00801 00802 // Set the valid usergroups for FE 00803 $this->initUserGroups(); 00804 00805 // Sets sys_page where-clause 00806 $this->setSysPageWhereClause(); 00807 00808 // Splitting $this->id by a period (.). First part is 'id' and second part - if exists - will overrule the &type param if given 00809 $pParts = explode('.',$this->id); 00810 $this->id = $pParts[0]; // Set it. 00811 if (isset($pParts[1])) {$this->type=$pParts[1];} 00812 00813 // Splitting $this->id by a comma (,). First part is 'id' and other parts are just stored for use in scripts. 00814 $this->idParts = explode(',',$this->id); 00815 00816 // Splitting by a '+' sign - used for base64/md5 methods of parameter encryption for simulate static documents. 00817 list($pgID,$SSD_p)=explode('+',$this->idParts[0],2); 00818 if ($SSD_p) { $this->idPartsAnalyze($SSD_p); } 00819 $this->id = $pgID; // Set id 00820 00821 // If $this->id is a string, it's an alias 00822 $this->checkAndSetAlias(); 00823 00824 // The id and type is set to the integer-value - just to be sure... 00825 $this->id = intval($this->id); 00826 $this->type = intval($this->type); 00827 $GLOBALS['TT']->pull(); 00828 00829 // We find the first page belonging to the current domain 00830 $GLOBALS['TT']->push('fetch_the_id domain/',''); 00831 $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']); // the page_id of the current domain 00832 if (!$this->id) { 00833 if ($this->domainStartPage) { 00834 $this->id = $this->domainStartPage; // If the id was not previously set, set it to the id of the domain. 00835 } else { 00836 $theFirstPage = $this->sys_page->getFirstWebPage($this->id); // Find the first 'visible' page in that domain 00837 if ($theFirstPage) { 00838 $this->id = $theFirstPage['uid']; 00839 } else { 00840 $this->printError('No pages are found on the rootlevel!'); 00841 exit; 00842 } 00843 } 00844 } 00845 $GLOBALS['TT']->pull(); 00846 00847 $GLOBALS['TT']->push('fetch_the_id rootLine/',''); 00848 $requestedId = $this->id; // We store the originally requested id 00849 $this->getPageAndRootlineWithDomain($this->domainStartPage); 00850 $GLOBALS['TT']->pull(); 00851 00852 if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) { 00853 $pNotFoundMsg = array( 00854 1 => 'ID was not an accessible page', 00855 2 => 'Subsection was found and not accessible', 00856 3 => 'ID was outside the domain', 00857 ); 00858 $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]); 00859 } 00860 00861 // set no_cache if set 00862 if ($this->page['no_cache']) { 00863 $this->set_no_cache(); 00864 } 00865 00866 // Init SYS_LASTCHANGED 00867 $this->register['SYS_LASTCHANGED'] = intval($this->page['tstamp']); 00868 if ($this->register['SYS_LASTCHANGED'] < intval($this->page['SYS_LASTCHANGED'])) { 00869 $this->register['SYS_LASTCHANGED'] = intval($this->page['SYS_LASTCHANGED']); 00870 } 00871 } 00872 00886 function getPageAndRootline() { 00887 $this->page = $this->sys_page->getPage($this->id); 00888 if (!count($this->page)) { 00889 // If no page, we try to find the page before in the rootLine. 00890 $this->pageNotFound=1; // Page is 'not found' in case the id itself was not an accessible page. code 1 00891 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP); 00892 if (count($this->rootLine)) { 00893 $c=count($this->rootLine)-1; 00894 while($c>0) { 00895 00896 // Add to page access failure history: 00897 $this->pageAccessFailureHistory['direct_access'][] = $this->rootLine[$c]; 00898 00899 // Decrease to next page in rootline and check the access to that, if OK, set as page record and ID value. 00900 $c--; 00901 $this->id = $this->rootLine[$c]['uid']; 00902 $this->page = $this->sys_page->getPage($this->id); 00903 if (count($this->page)){ break; } 00904 } 00905 } 00906 // If still no page... 00907 if (!count($this->page)) { 00908 if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) { 00909 $this->pageNotFoundAndExit('The requested page does not exist!'); 00910 } else { 00911 $this->printError('The requested page does not exist!'); 00912 exit; 00913 } 00914 } 00915 } 00916 // Is the ID a link to another page?? 00917 if ($this->page['doktype']==4) { 00918 $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. 00919 $this->page = $this->getPageShortcut($this->page['shortcut'],$this->page['shortcut_mode'],$this->page['uid']); 00920 $this->id = $this->page['uid']; 00921 } 00922 // Gets the rootLine 00923 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP); 00924 00925 // If not rootline we're off... 00926 if (!count($this->rootLine)) { 00927 $this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')'); 00928 exit; 00929 } 00930 00931 // Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!) 00932 if ($this->checkRootlineForIncludeSection()) { 00933 if (!count($this->rootLine)) { 00934 $this->printError('The requested page was not accessible!'); 00935 exit; 00936 } else { 00937 $el = reset($this->rootLine); 00938 $this->id = $el['uid']; 00939 $this->page = $this->sys_page->getPage($this->id); 00940 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP); 00941 } 00942 } 00943 } 00944 00957 function getPageShortcut($SC,$mode,$thisUid,$itera=20,$pageLog=array()) { 00958 $idArray = t3lib_div::intExplode(',',$SC); 00959 00960 // Find $page record depending on shortcut mode: 00961 switch($mode) { 00962 case 1: 00963 case 2: 00964 $pageArray = $this->sys_page->getMenu($idArray[0]?$idArray[0]:$thisUid,'*','sorting','AND pages.doktype<199 AND pages.doktype!=6'); 00965 $pO = 0; 00966 if ($mode==2 && count($pageArray)) { // random 00967 $this->make_seed(); 00968 $randval = intval(rand(0,count($pageArray)-1)); 00969 $pO = $randval; 00970 } 00971 $c = 0; 00972 reset($pageArray); 00973 while(list(,$pV)=each($pageArray)) { 00974 if ($c==$pO) { 00975 $page = $pV; 00976 break; 00977 } 00978 $c++; 00979 } 00980 break; 00981 default: 00982 $page = $this->sys_page->getPage($idArray[0]); 00983 break; 00984 } 00985 00986 // Check if short cut page was a shortcut itself, if so look up recursively: 00987 if ($page['doktype']==4) { 00988 if (!in_array($page['uid'],$pageLog) && $itera>0) { 00989 $pageLog[] = $page['uid']; 00990 $page = $this->getPageShortcut($page['shortcut'],$page['shortcut_mode'],$page['uid'],$itera-1,$pageLog); 00991 } else { 00992 $pageLog[] = $page['uid']; 00993 $this->printError('Page shortcuts were looping in uids '.implode(',',$pageLog).'...!'); 00994 exit; 00995 } 00996 } 00997 // Return resulting page: 00998 return $page; 00999 } 01000 01007 function checkRootlineForIncludeSection() { 01008 $c=count($this->rootLine); 01009 $removeTheRestFlag=0; 01010 01011 for ($a=0;$a<$c;$a++) { 01012 if (!$this->checkPagerecordForIncludeSection($this->rootLine[$a])) { 01013 // Add to page access failure history: 01014 $this->pageAccessFailureHistory['sub_section'][] = $this->rootLine[$a]; 01015 $removeTheRestFlag=1; 01016 } 01017 if ($this->rootLine[$a]['doktype']==6) { 01018 if ($this->beUserLogin) { // If there is a backend user logged in, check if he has read access to the page: 01019 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($this->id).' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1)); 01020 list($isPage) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 01021 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... 01022 } else { // Dont go here, if there is no backend user logged in. 01023 $removeTheRestFlag=1; 01024 } 01025 } 01026 if ($removeTheRestFlag) { 01027 $this->pageNotFound=2; // Page is 'not found' in case a subsection was found and not accessible, code 2 01028 unset($this->rootLine[$a]); 01029 } 01030 } 01031 return $removeTheRestFlag; 01032 } 01033 01044 function checkEnableFields($row,$bypassGroupCheck=FALSE) { 01045 if ((!$row['hidden'] || $this->showHiddenPage) 01046 && $row['starttime']<=$GLOBALS['SIM_EXEC_TIME'] 01047 && ($row['endtime']==0 || $row['endtime']>$GLOBALS['SIM_EXEC_TIME']) 01048 && ($bypassGroupCheck || $this->checkPageGroupAccess($row)) 01049 ) { return TRUE; } 01050 } 01051 01060 function checkPageGroupAccess($row, $groupList=NULL) { 01061 if(is_null($groupList)) { 01062 $groupList = $this->gr_list; 01063 } 01064 if(!is_array($groupList)) { 01065 $groupList = explode(',', $groupList); 01066 } 01067 $pageGroupList = explode(',', $row['fe_group']); 01068 return count(array_intersect($groupList, $pageGroupList)) > 0; 01069 } 01070 01079 function checkPagerecordForIncludeSection($row) { 01080 return (!$row['extendToSubpages'] || $this->checkEnableFields($row)) ? 1 : 0; 01081 } 01082 01088 function checkIfLoginAllowedInBranch() { 01089 01090 // Initialize: 01091 $c = count($this->rootLine); 01092 $disable = FALSE; 01093 01094 // Traverse root line from root and outwards: 01095 for ($a=0; $a<$c; $a++) { 01096 01097 // If a value is set for login state: 01098 if ($this->rootLine[$a]['fe_login_mode'] > 0) { 01099 01100 // Determine state from value: 01101 $disable = (int)$this->rootLine[$a]['fe_login_mode'] === 1 ? TRUE : FALSE; 01102 } 01103 } 01104 01105 return !$disable; 01106 } 01107 01113 function getPageAccessFailureReasons() { 01114 $output = array(); 01115 01116 $combinedRecords = array_merge( 01117 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! 01118 is_array($this->pageAccessFailureHistory['sub_section']) ? $this->pageAccessFailureHistory['sub_section'] : array() 01119 ); 01120 01121 if (count($combinedRecords)) { 01122 foreach($combinedRecords as $k => $pagerec) { 01123 // 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 01124 // 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! 01125 if (!$k || $pagerec['extendToSubpages']) { 01126 if ($pagerec['hidden']) $output['hidden'][$pagerec['uid']] = TRUE; 01127 if ($pagerec['starttime'] > $GLOBALS['SIM_EXEC_TIME']) $output['starttime'][$pagerec['uid']] = $pagerec['starttime']; 01128 if ($pagerec['endtime']!=0 && $pagerec['endtime'] <= $GLOBALS['SIM_EXEC_TIME']) $output['endtime'][$pagerec['uid']] = $pagerec['endtime']; 01129 if (!$this->checkPageGroupAccess($pagerec)) $output['fe_group'][$pagerec['uid']] = $pagerec['fe_group']; 01130 } 01131 } 01132 } 01133 01134 return $output; 01135 } 01136 01145 function setIDfromArgV() { 01146 if (!$this->id) { 01147 list($theAlias) = explode('&',t3lib_div::getIndpEnv('QUERY_STRING')); 01148 $theAlias = trim($theAlias); 01149 $this->id = $theAlias ? $theAlias : 0; 01150 } 01151 } 01152 01161 function getPageAndRootlineWithDomain($domainStartPage) { 01162 $this->getPageAndRootline(); 01163 01164 // 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. 01165 if ($domainStartPage && is_array($this->rootLine)) { 01166 reset ($this->rootLine); 01167 $idFound = 0; 01168 while(list($key,$val)=each($this->rootLine)) { 01169 if ($val['uid']==$domainStartPage) { 01170 $idFound=1; 01171 break; 01172 } 01173 } 01174 if (!$idFound) { 01175 $this->pageNotFound=3; // Page is 'not found' in case the id was outside the domain, code 3 01176 $this->id = $domainStartPage; 01177 $this->getPageAndRootline(); //re-get the page and rootline if the id was not found. 01178 } 01179 } 01180 } 01181 01188 function setSysPageWhereClause() { 01189 $this->sys_page->where_hid_del.=' AND doktype<200'; 01190 $this->sys_page->where_groupAccess = $this->getPagesGroupClause(); 01191 } 01192 01199 function getPagesGroupClause() { 01200 return ' AND fe_group IN ('.$this->gr_list.')'; 01201 } 01202 01210 function findDomainRecord($recursive=0) { 01211 if ($recursive) { 01212 $host = explode('.',t3lib_div::getIndpEnv('HTTP_HOST')); 01213 while(count($host)) { 01214 $pageUid = $this->sys_page->getDomainStartPage(implode('.',$host),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI')); 01215 if ($pageUid) return $pageUid; else array_shift($host); 01216 } 01217 return $pageUid; 01218 } else { 01219 return $this->sys_page->getDomainStartPage(t3lib_div::getIndpEnv('HTTP_HOST'),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI')); 01220 } 01221 } 01222 01229 function pageNotFoundAndExit($reason='') { 01230 $this->pageNotFoundHandler($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'], $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'], $reason); 01231 exit; 01232 } 01233 01243 function pageNotFoundHandler($code, $header='', $reason='') { 01244 // Issue header in any case: 01245 if ($header) {header($header);} 01246 01247 // Create response: 01248 if (gettype($code)=='boolean' || !strcmp($code,1)) { // Simply boolean; Just shows TYPO3 error page with reason: 01249 $this->printError('The page did not exist or was inaccessible.'.($reason ? ' Reason: '.htmlspecialchars($reason) : '')); 01250 exit; 01251 } elseif (t3lib_div::isFirstPartOfStr($code,'USER_FUNCTION:')) { 01252 $funcRef = trim(substr($code,14)); 01253 $params = array( 01254 'currentUrl' => t3lib_div::getIndpEnv('REQUEST_URI'), 01255 'reasonText' => $reason, 01256 'pageAccessFailureReasons' => $this->getPageAccessFailureReasons() 01257 ); 01258 echo t3lib_div::callUserFunction($funcRef,$params,$this); 01259 exit; 01260 } elseif (t3lib_div::isFirstPartOfStr($code,'READFILE:')) { 01261 $readFile = t3lib_div::getFileAbsFileName(trim(substr($code,9))); 01262 if (@is_file($readFile)) { 01263 $fileContent = t3lib_div::getUrl($readFile); 01264 $fileContent = str_replace('###CURRENT_URL###', t3lib_div::getIndpEnv('REQUEST_URI'), $fileContent); 01265 $fileContent = str_replace('###REASON###', htmlspecialchars($reason), $fileContent); 01266 echo $fileContent; 01267 } else { 01268 $this->printError('Configuration Error: 404 page "'.$readFile.'" could not be found.'); 01269 } 01270 exit; 01271 } elseif (strlen($code)) { 01272 header('Location: '.t3lib_div::locationHeaderUrl($code)); 01273 exit; 01274 } else { 01275 $this->printError('Error.'.($reason ? ' Reason: '.htmlspecialchars($reason) : '')); 01276 exit; 01277 } 01278 } 01279 01287 function checkAndSetAlias() { 01288 if ($this->id && !t3lib_div::testInt($this->id)) { 01289 $aid = $this->sys_page->getPageIdFromAlias($this->id); 01290 if ($aid) {$this->id=$aid;} 01291 } 01292 } 01293 01302 function idPartsAnalyze($str) { 01303 $GET_VARS = ''; 01304 switch(substr($str,0,2)) { 01305 case 'B6': 01306 $addParams = base64_decode(str_replace('_','=',str_replace('-','/',substr($str,2)))); 01307 parse_str($addParams,$GET_VARS); 01308 break; 01309 case 'M5': 01310 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr(substr($str,2), 'cache_md5params')); 01311 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 01312 01313 $this->updateMD5paramsRecord(substr($str,2)); 01314 parse_str($row['params'],$GET_VARS); 01315 break; 01316 } 01317 01318 $this->mergingWithGetVars($GET_VARS); 01319 } 01320 01327 function mergingWithGetVars($GET_VARS) { 01328 if (is_array($GET_VARS)) { 01329 $realGet = t3lib_div::_GET(); // Getting $_GET var, unescaped. 01330 if (!is_array($realGet)) $realGet = array(); 01331 01332 // Merge new values on top: 01333 $realGet = t3lib_div::array_merge_recursive_overrule($realGet,$GET_VARS); 01334 01335 // Write values back to $_GET: 01336 t3lib_div::_GETset($realGet); 01337 01338 // Setting these specifically (like in the init-function): 01339 if (isset($GET_VARS['type'])) $this->type = intval($GET_VARS['type']); 01340 if (isset($GET_VARS['cHash'])) $this->cHash = $GET_VARS['cHash']; 01341 if (isset($GET_VARS['jumpurl'])) $this->jumpurl = $GET_VARS['jumpurl']; 01342 if (isset($GET_VARS['MP'])) $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? $GET_VARS['MP'] : ''; 01343 01344 if (isset($GET_VARS['no_cache']) && $GET_VARS['no_cache']) $this->set_no_cache(); 01345 } 01346 } 01347 01348 01349 01350 01351 01352 01353 01354 01355 01356 01357 01358 01359 01360 01361 01362 01363 01364 /******************************************** 01365 * 01366 * Template and caching related functions. 01367 * 01368 *******************************************/ 01369 01376 function makeCacheHash() { 01377 $GET = t3lib_div::_GET(); 01378 if ($this->cHash && is_array($GET)) { 01379 $this->cHash_array = t3lib_div::cHashParams(t3lib_div::implodeArrayForUrl('',$GET)); 01380 $cHash_calc = t3lib_div::shortMD5(serialize($this->cHash_array)); 01381 01382 if ($cHash_calc!=$this->cHash) { 01383 if ($this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) { 01384 $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash comparison failed)'); 01385 } else { 01386 $this->set_no_cache(); 01387 $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); 01388 } 01389 } 01390 } 01391 } 01392 01400 function reqCHash() { 01401 if (!$this->cHash) { 01402 if ($this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) { 01403 if ($this->tempContent) { $this->clearPageCacheContent(); } 01404 $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash empty)'); 01405 } else { 01406 $this->set_no_cache(); 01407 $GLOBALS['TT']->setTSlogMessage('TSFE->reqCHash(): No &cHash parameter was sent for GET vars though required so caching is disabled ',2); 01408 } 01409 } 01410 } 01411 01422 function cHashParams($addQueryParams) { 01423 return t3lib_div::cHashParams($addQueryParams); 01424 } 01425 01431 function initTemplate() { 01432 $this->tmpl = t3lib_div::makeInstance('t3lib_TStemplate'); 01433 $this->tmpl->init(); 01434 $this->tmpl->tt_track= $this->beUserLogin ? 1 : 0; 01435 } 01436 01443 function getFromCache() { 01444 $this->tmpl->getCurrentPageData(); 01445 $cc = Array(); 01446 if (is_array($this->tmpl->currentPageData)) { 01447 // 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. 01448 // If this hash is not the same in here in this section and after page-generation the page will not be properly cached! 01449 01450 $cc['all'] = $this->tmpl->currentPageData['all']; 01451 $cc['rowSum'] = $this->tmpl->currentPageData['rowSum']; 01452 $cc['rootLine'] = $this->tmpl->currentPageData['rootLine']; // This rootline is used with templates only (matching()-function) 01453 $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. 01454 ksort($this->all); 01455 } 01456 01457 $this->content=''; // clearing the content-variable, which will hold the pagecontent 01458 unset($this->config); // Unsetting the lowlevel config 01459 $this->cacheContentFlag = 0; 01460 01461 // Look for page in cache only if caching is not disabled and if a shift-reload is not sent to the server. 01462 if ($this->all && !$this->no_cache && !$this->headerNoCache()) { 01463 01464 $this->newHash = $this->getHash(); 01465 01466 $GLOBALS['TT']->push('Cache Query',''); 01467 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 01468 'S.*', 01469 'cache_pages S,pages P', 01470 'S.hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->newHash, 'cache_pages').' 01471 AND S.page_id=P.uid 01472 AND S.expires > '.intval($GLOBALS['EXEC_TIME']).' 01473 AND P.deleted=0 01474 AND P.hidden=0 01475 AND P.starttime<='.intval($GLOBALS['EXEC_TIME']).' 01476 AND (P.endtime=0 OR P.endtime>'.intval($GLOBALS['EXEC_TIME']).')' 01477 ); 01478 $GLOBALS['TT']->pull(); 01479 $GLOBALS['TT']->push('Cache Row',''); 01480 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01481 $this->config = (array)unserialize($row['cache_data']); // Fetches the lowlevel config stored with the cached data 01482 $this->content = $row['HTML']; // Getting the content 01483 $this->cacheContentFlag = 1; // Setting flag, so we know, that some cached content is gotten. 01484 $this->cacheExpires = $row['expires']; 01485 01486 if ($this->TYPO3_CONF_VARS['FE']['debug'] || $this->config['config']['debug']) { 01487 $this->content.=chr(10).'<!-- Cached page generated '.Date('d/m Y H:i', $row['tstamp']).'. Expires '.Date('d/m Y H:i', $row['expires']).' -->'; 01488 } 01489 } 01490 $GLOBALS['TT']->pull(); 01491 01492 $GLOBALS['TYPO3_DB']->sql_free_result($res); 01493 } 01494 } 01495 01502 function headerNoCache() { 01503 $disableAcquireCacheData = FALSE; 01504 01505 if ($this->beUserLogin) { 01506 if (strtolower($_SERVER['HTTP_CACHE_CONTROL'])==='no-cache' || strtolower($_SERVER['HTTP_PRAGMA'])==='no-cache') { 01507 $disableAcquireCacheData = TRUE; 01508 } 01509 } 01510 01511 // Call hook for possible by-pass of requiring of page cache (for recaching purpose) 01512 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'])) { 01513 $_params = array('pObj' => &$this, 'disableAcquireCacheData' => &$disableAcquireCacheData); 01514 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'] as $_funcRef) { 01515 t3lib_div::callUserFunction($_funcRef,$_params,$this); 01516 } 01517 } 01518 01519 return $disableAcquireCacheData; 01520 } 01521 01531 function getHash() { 01532 $this->hash_base = serialize( 01533 array( 01534 'all' => $this->all, 01535 'id' => intval($this->id), 01536 'type' => intval($this->type), 01537 'gr_list' => (string)$this->gr_list, 01538 'MP' => (string)$this->MP, 01539 'cHash' => $this->cHash_array 01540 ) 01541 ); 01542 01543 return md5($this->hash_base); 01544 } 01545 01551 function getConfigArray() { 01552 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 01553 $GLOBALS['TT']->push('Parse template',''); 01554 01555 // Force parsing, if set?: 01556 $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing; 01557 01558 // Start parsing the TS template. Might return cached version. 01559 $this->tmpl->start($this->rootLine); 01560 $GLOBALS['TT']->pull(); 01561 01562 if ($this->tmpl->loaded) { 01563 $GLOBALS['TT']->push('Setting the config-array',''); 01564 // t3lib_div::print_array($this->tmpl->setup); 01565 $this->sPre = $this->tmpl->setup['types.'][$this->type]; // toplevel - objArrayName 01566 $this->pSetup = $this->tmpl->setup[$this->sPre.'.']; 01567 01568 if (!is_array($this->pSetup)) { 01569 $this->printError('The page is not configured! [type= '.$this->type.']['.$this->sPre.']'); 01570 exit; 01571 } else { 01572 $this->config['config']=Array(); 01573 01574 // Filling the config-array. 01575 if (is_array($this->tmpl->setup['config.'])) { 01576 $this->config['config'] = $this->tmpl->setup['config.']; 01577 } 01578 if (is_array($this->pSetup['config.'])) { 01579 reset($this->pSetup['config.']); 01580 while(list($theK,$theV)=each($this->pSetup['config.'])) { 01581 $this->config['config'][$theK] = $theV; 01582 } 01583 } 01584 // if .simulateStaticDocuments was not present, the default value will rule. 01585 if (!isset($this->config['config']['simulateStaticDocuments'])) { 01586 $this->config['config']['simulateStaticDocuments'] = $this->TYPO3_CONF_VARS['FE']['simulateStaticDocuments']; 01587 } 01588 01589 // Processing for the config_array: 01590 $this->config['rootLine'] = $this->tmpl->rootLine; 01591 $this->config['mainScript'] = trim($this->config['config']['mainScript']) ? trim($this->config['config']['mainScript']) : 'index.php'; 01592 01593 // STAT: 01594 $theLogFile = $this->TYPO3_CONF_VARS['FE']['logfile_dir'].$this->config['config']['stat_apache_logfile']; 01595 // Add PATH_site left to $theLogFile if the path is not absolute yet 01596 if(!t3lib_div::isAbsPath($theLogFile)) $theLogFile = PATH_site.$theLogFile; 01597 01598 if ($this->config['config']['stat_apache'] && $this->config['config']['stat_apache_logfile'] && !strstr($this->config['config']['stat_apache_logfile'],'/')) { 01599 if(t3lib_div::isAllowedAbsPath($theLogFile) && @is_file($theLogFile) && @is_writable($theLogFile)) { 01600 $this->config['stat_vars']['logFile'] = $theLogFile; 01601 $shortTitle = substr(ereg_replace('[^\.[:alnum:]_-]','_',$this->page['title']),0,30); 01602 $pageName = $this->config['config']['stat_apache_pagenames'] ? $this->config['config']['stat_apache_pagenames'] : '[path][title]--[uid].html'; 01603 $pageName = str_replace('[title]', $shortTitle ,$pageName); 01604 $pageName = str_replace('[uid]',$this->page['uid'],$pageName); 01605 $pageName = str_replace('[alias]',$this->page['alias'],$pageName); 01606 $pageName = str_replace('[type]',$this->page['type'],$pageName); 01607 $temp = $this->config['rootLine']; 01608 array_pop($temp); 01609 $len = t3lib_div::intInRange($this->config['config']['stat_titleLen'],1,100,20); 01610 $pageName = str_replace('[path]', ereg_replace('[^\.[:alnum:]\/_-]','_',$this->sys_page->getPathFromRootline($temp,$len)).'/' ,$pageName); 01611 $this->config['stat_vars']['pageName'] = $pageName; 01612 } else { 01613 $GLOBALS['TT']->setTSlogMessage('Could not set logfile path. Check filepath and permissions.',3); 01614 } 01615 } 01616 $this->config['FEData'] = $this->tmpl->setup['FEData']; 01617 $this->config['FEData.'] = $this->tmpl->setup['FEData.']; 01618 } 01619 $GLOBALS['TT']->pull(); 01620 } else { 01621 $this->printError('No template found!'); 01622 exit; 01623 } 01624 } 01625 01626 // Initialize charset settings etc. 01627 $this->initLLvars(); 01628 01629 // No cache 01630 if ($this->config['config']['no_cache']) { $this->set_no_cache(); } // Set $this->no_cache true if the config.no_cache value is set! 01631 01632 // Check PATH_INFO url 01633 if ($this->absRefPrefix_force && strcmp($this->config['config']['simulateStaticDocuments'],'PATH_INFO')) { 01634 $redirectUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php?id='.$this->id.'&type='.$this->type; 01635 if ($this->config['config']['simulateStaticDocuments_dontRedirectPathInfoError']) { 01636 $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'); 01637 } else { 01638 header('Location: '.t3lib_div::locationHeaderUrl($redirectUrl)); 01639 } 01640 exit; 01641 // $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. 01642 } 01643 } 01644 01645 01646 01647 01648 01649 01650 01651 01652 01653 01654 01655 01656 01657 01658 /******************************************** 01659 * 01660 * Further initialization and data processing 01661 * (jumpurl/submission of forms) 01662 * 01663 *******************************************/ 01664 01673 function getCompressedTCarray() { 01674 global $TCA; 01675 01676 $GLOBALS['TT']->push('Get Compressed TC array'); 01677 if (!$this->TCAloaded) { 01678 // Create hash string for storage / retrieval of cached content: 01679 $tempHash = md5('tables.php:'. 01680 filemtime(TYPO3_extTableDef_script ? PATH_typo3conf.TYPO3_extTableDef_script : PATH_t3lib.'stddb/tables.php'). 01681 (TYPO3_extTableDef_script?filemtime(PATH_typo3conf.TYPO3_extTableDef_script):''). 01682 ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] ? filemtime(PATH_typo3conf.$GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'].'_ext_tables.php') : '') 01683 ); 01684 // Try to fetch if: 01685 list($TCA,$this->TCAcachedExtras) = unserialize($this->sys_page->getHash($tempHash, 0)); 01686 // If no result, create it: 01687 if (!is_array($TCA)) { 01688 $this->includeTCA(0); 01689 $newTc = Array(); 01690 $this->TCAcachedExtras = array(); // Collects other information 01691 01692 foreach($TCA as $key => $val) { 01693 $newTc[$key]['ctrl'] = $val['ctrl']; 01694 $newTc[$key]['feInterface'] = $val['feInterface']; 01695 01696 // Collect information about localization exclusion of fields: 01697 t3lib_div::loadTCA($key); 01698 if (is_array($TCA[$key]['columns'])) { 01699 $this->TCAcachedExtras[$key]['l10n_mode'] = array(); 01700 foreach($TCA[$key]['columns'] as $fN => $fV) { 01701 if ($fV['l10n_mode']) { 01702 $this->TCAcachedExtras[$key]['l10n_mode'][$fN] = $fV['l10n_mode']; 01703 } 01704 } 01705 } 01706 } 01707 01708 // Store it in cache: 01709 $TCA = $newTc; 01710 $this->sys_page->storeHash($tempHash, serialize(array($newTc,$this->TCAcachedExtras)), 'SHORT TC'); 01711 } 01712 } 01713 $GLOBALS['TT']->pull(); 01714 } 01715 01727 function includeTCA($TCAloaded=1) { 01728 global $TCA, $PAGES_TYPES, $LANG_GENERAL_LABELS, $TBE_MODULES; 01729 if (!$this->TCAloaded) { 01730 $TCA = Array(); 01731 include (TYPO3_tables_script ? PATH_typo3conf.TYPO3_tables_script : PATH_t3lib.'stddb/tables.php'); 01732 // Extension additions 01733 if ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE']) { 01734 include(PATH_typo3conf.$GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'].'_ext_tables.php'); 01735 } else { 01736 include(PATH_t3lib.'stddb/load_ext_tables.php'); 01737 } 01738 // ext-script 01739 if (TYPO3_extTableDef_script) { 01740 include (PATH_typo3conf.TYPO3_extTableDef_script); 01741 } 01742 01743 $this->TCAloaded = $TCAloaded; 01744 } 01745 } 01746 01754 function settingLanguage() { 01755 01756 // Get values from TypoScript: 01757 $this->sys_language_uid = $this->sys_language_content = intval($this->config['config']['sys_language_uid']); 01758 list($this->sys_language_mode,$sys_language_content) = t3lib_div::trimExplode(';', $this->config['config']['sys_language_mode']); 01759 $this->sys_language_contentOL = $this->config['config']['sys_language_overlay']; 01760 01761 // If sys_language_uid is set to another language than default: 01762 if ($this->sys_language_uid>0) { 01763 // Request the overlay record for the sys_language_uid: 01764 $olRec = $this->sys_page->getPageOverlay($this->id, $this->sys_language_uid); 01765 if (!count($olRec)) { 01766 01767 // If no OL record exists and a foreign language is asked for... 01768 if ($this->sys_language_uid) { 01769 01770 // If requested translation is not available: 01771 if (t3lib_div::hideIfNotTranslated($this->page['l18n_cfg'])) { 01772 $this->pageNotFoundAndExit('Page is not available in the requested language.'); 01773 } else { 01774 switch((string)$this->sys_language_mode) { 01775 case 'strict': 01776 $this->pageNotFoundAndExit('Page is not available in the requested language (strict).'); 01777 break; 01778 case 'content_fallback': 01779 $fallBackOrder = t3lib_div::intExplode(',', $sys_language_content); 01780 foreach($fallBackOrder as $orderValue) { 01781 if (!strcmp($orderValue,'0') || count($this->sys_page->getPageOverlay($this->id, $orderValue))) { 01782 $this->sys_language_content = $orderValue; // Setting content uid (but leaving the sys_language_uid) 01783 break; 01784 } 01785 } 01786 break; 01787 default: 01788 // Default is that everything defaults to the default language... 01789 $this->sys_language_uid = $this->sys_language_content = 0; 01790 break; 01791 } 01792 } 01793 } 01794 } else { 01795 // Setting sys_language if an overlay record was found (which it is only if a language is used) 01796 $this->page = $this->sys_page->getPageOverlay($this->page, $this->sys_language_uid); 01797 } 01798 } 01799 01800 // Setting sys_language_uid inside sys-page: 01801 $this->sys_page->sys_language_uid = $this->sys_language_uid; 01802 01803 // If default translation is not available: 01804 if ((!$this->sys_language_uid || !$this->sys_language_content) && $this->page['l18n_cfg']&1) { 01805 $this->pageNotFoundAndExit('Page is not available in default language.'); 01806 } 01807 01808 // Updating content of the two rootLines IF the language key is set! 01809 if ($this->sys_language_uid && is_array($this->tmpl->rootLine)) { 01810 reset($this->tmpl->rootLine); 01811 while(list($rLk)=each($this->tmpl->rootLine)) { 01812 $this->tmpl->rootLine[$rLk] = $this->sys_page->getPageOverlay($this->tmpl->rootLine[$rLk]); 01813 } 01814 } 01815 if ($this->sys_language_uid && is_array($this->rootLine)) { 01816 reset($this->rootLine); 01817 while(list($rLk)=each($this->rootLine)) { 01818 $this->rootLine[$rLk] = $this->sys_page->getPageOverlay($this->rootLine[$rLk]); 01819 } 01820 } 01821 01822 // Finding the ISO code: 01823 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" 01824 $sys_language_row = $this->sys_page->getRawRecord('sys_language',$this->sys_language_content,'static_lang_isocode'); 01825 if (is_array($sys_language_row) && $sys_language_row['static_lang_isocode']) { 01826 $stLrow = $this->sys_page->getRawRecord('static_languages',$sys_language_row['static_lang_isocode'],'lg_iso_2'); 01827 $this->sys_language_isocode = $stLrow['lg_iso_2']; 01828 } 01829 } 01830 01831 // Setting softMergeIfNotBlank: 01832 $table_fields = t3lib_div::trimExplode(',', $this->config['config']['sys_language_softMergeIfNotBlank'],1); 01833 foreach($table_fields as $TF) { 01834 list($tN,$fN) = explode(':',$TF); 01835 $this->TCAcachedExtras[$tN]['l10n_mode'][$fN] = 'mergeIfNotBlank'; 01836 } 01837 } 01838 01844 function settingLocale() { 01845 01846 // Setting locale 01847 if ($this->config['config']['locale_all']) { 01848 # Change by Rene Fritz, 22/10 2002 01849 # there`s the problem that PHP parses float values in scripts wrong if the locale LC_NUMERIC is set to something with a komma as decimal point 01850 # this does not work in php 4.2.3 01851 #setlocale('LC_ALL',$this->config['config']['locale_all']); 01852 #setlocale('LC_NUMERIC','en_US'); 01853 01854 # so we set all except LC_NUMERIC 01855 setlocale(LC_COLLATE,$this->config['config']['locale_all']); 01856 setlocale(LC_CTYPE,$this->config['config']['locale_all']); 01857 setlocale(LC_MONETARY,$this->config['config']['locale_all']); 01858 setlocale(LC_TIME,$this->config['config']['locale_all']); 01859 01860 $this->localeCharset = $this->csConvObj->get_locale_charset($this->config['config']['locale_all']); 01861 } 01862 } 01863 01869 function checkDataSubmission() { 01870 if ($_POST['formtype_db'] || $_POST['formtype_mail']) { 01871 $refInfo = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER')); 01872 if (t3lib_div::getIndpEnv('TYPO3_HOST_ONLY')==$refInfo['host'] || $this->TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) { 01873 if ($this->locDataCheck($_POST['locationData'])) { 01874 $ret = ''; 01875 if ($_POST['formtype_mail']) { 01876 $ret = 'email'; 01877 } elseif ($_POST['formtype_db'] && is_array($_POST['data'])) { 01878 $ret = 'fe_tce'; 01879 } 01880 $GLOBALS['TT']->setTSlogMessage('"Check Data Submission": Return value: '.$ret,0); 01881 return $ret; 01882 } 01883 } else $GLOBALS['TT']->setTSlogMessage('"Check Data Submission": HTTP_HOST and REFERER HOST did not match when processing submitted formdata!',3); 01884 } 01885 } 01886 01894 function fe_tce() { 01895 $fe_tce = t3lib_div::makeInstance('tslib_feTCE'); 01896 $fe_tce->start(t3lib_div::_POST('data'),$this->config['FEData.']); 01897 $fe_tce->includeScripts(); 01898 } 01899 01908 function locDataCheck($locationData) { 01909 $locData = explode(':',$locationData); 01910 if (!$locData[1] || $this->sys_page->checkRecord($locData[1],$locData[2],1)) { 01911 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. 01912 return 1; 01913 } else $GLOBALS['TT']->setTSlogMessage('LocationData Error: The page pointed to by location data ('.$locationData.') was not accessible.',2); 01914 } else $GLOBALS['TT']->setTSlogMessage('LocationData Error: Location data ('.$locationData.') record pointed to was not accessible.',2); 01915 } 01916 01924 function sendFormmail() { 01925 $formmail = t3lib_div::makeInstance('t3lib_formmail'); 01926 01927 $EMAIL_VARS = t3lib_div::_POST(); 01928 $locationData = $EMAIL_VARS['locationData']; 01929 unset($EMAIL_VARS['locationData']); 01930 unset($EMAIL_VARS['formtype_mail']); 01931 01932 $integrityCheck = $this->TYPO3_CONF_VARS['FE']['strictFormmail']; 01933 01934 if(!$this->TYPO3_CONF_VARS['FE']['secureFormmail']) { 01935 // Check recipient field: 01936 $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. 01937 foreach($encodedFields as $fieldKey) { 01938 if (strlen($EMAIL_VARS[$fieldKey])) { 01939 if ($res = $this->codeString($EMAIL_VARS[$fieldKey], TRUE)) { // Decode... 01940 $EMAIL_VARS[$fieldKey] = $res; // Set value if OK 01941 } elseif ($integrityCheck) { // Otherwise abort: 01942 $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); 01943 return false; 01944 } else { 01945 $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); 01946 } 01947 } 01948 } 01949 } else { 01950 $locData = explode(':',$locationData); 01951 $record = $this->sys_page->checkRecord($locData[1],$locData[2],1); 01952 $EMAIL_VARS['recipient'] = $record['subheader']; 01953 $EMAIL_VARS['recipient_copy'] = $this->extractRecipientCopy($record['bodytext']); 01954 } 01955 01956 // Hook for preprocessing of the content for formmails: 01957 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass'])) { 01958 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass'] as $_classRef) { 01959 $_procObj = &t3lib_div::getUserObj($_classRef); 01960 $EMAIL_VARS = $_procObj->sendFormmail_preProcessVariables($EMAIL_VARS,$this); 01961 } 01962 } 01963 01964 $formmail->start($EMAIL_VARS); 01965 $formmail->sendtheMail(); 01966 $GLOBALS['TT']->setTSlogMessage('"Formmail" invoked, sending mail to '.$EMAIL_VARS['recipient'],0); 01967 } 01968 01975 function extractRecipientCopy($bodytext) { 01976 $recipient_copy = ''; 01977 $fdef = array(); 01978 //|recipient_copy=hidden|karsten@localhost.localdomain 01979 preg_match('/^[\s]*\|[\s]*recipient_copy[\s]*=[\s]*hidden[\s]*\|(.*)$/m', $bodytext, $fdef); 01980 $recipient_copy = (!empty($fdef[1])) ? $fdef[1] : ''; 01981 return $recipient_copy; 01982 } 01983 01990 function checkJumpUrl() { 01991 global $TCA; 01992 01993 $mid = t3lib_div::_GP('mid'); // mail id, if direct mail link 01994 $rid = t3lib_div::_GP('rid'); // recipient id, if direct mail link 01995 if ((strcmp($this->jumpurl,'') && ((t3lib_div::getIndpEnv('HTTP_REFERER') || $this->TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) || $mid)) || ($this->jumpurl = $this->sys_page->getExtURL($this->page,$this->config['config']['disablePageExternalUrl']))) { 01996 if ($mid && is_array($TCA['sys_dmail'])) { // Yes, it's OK if the link comes from a direct mail. AND sys_dmail module has installed the table, sys_dmail (and therefore we expect sys_dmail_maillog as well!) 01997 $temp_recip=explode('_',$rid); 01998 $url_id=0; 01999 if (t3lib_div::testInt($this->jumpurl)) { 02000 $temp_res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('mailContent', 'sys_dmail', 'uid='.intval($mid)); 02001 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($temp_res)) { 02002 $temp_unpackedMail = unserialize($row['mailContent']); 02003 $url_id=$this->jumpurl; 02004 if ($this->jumpurl>=0) { 02005 $responseType=1; // Link (number) 02006 $this->jumpurl = $temp_unpackedMail['html']['hrefs'][$url_id]['absRef']; 02007 } else { 02008 $responseType=2; // Link (number, plaintext) 02009 $this->jumpurl = $temp_unpackedMail['plain']['link_ids'][abs($url_id)]; 02010 } 02011 switch($temp_recip[0]) { 02012 case 't': 02013 $theTable = 'tt_address'; 02014 break; 02015 case 'f': 02016 $theTable = 'fe_users'; 02017 break; 02018 default: 02019 $theTable=''; 02020 break; 02021 } 02022 if ($theTable) { 02023 $recipRow = $this->sys_page->getRawRecord($theTable,$temp_recip[1]); 02024 if (is_array($recipRow)) { 02025 // debug($recipRow); 02026 $authCode = t3lib_div::stdAuthCode($recipRow['uid']); 02027 $rowFieldsArray = explode(',', 'uid,name,title,email,phone,www,address,company,city,zip,country,fax,firstname'); 02028 reset($rowFieldsArray); 02029 while(list(,$substField)=each($rowFieldsArray)) { 02030 $this->jumpurl = str_replace('###USER_'.$substField.'###', $recipRow[$substField], $this->jumpurl); 02031 } 02032 $this->jumpurl = str_replace('###SYS_TABLE_NAME###', $tableNameChar, $this->jumpurl); // Put in the tablename of the userinformation 02033 $this->jumpurl = str_replace('###SYS_MAIL_ID###', $mid, $this->jumpurl); // Put in the uid of the mail-record 02034 $this->jumpurl = str_replace('###SYS_AUTHCODE###', $authCode, $this->jumpurl); 02035 02036 // debug($this->jumpurl); 02037 } 02038 } 02039 } 02040 02041 $GLOBALS['TYPO3_DB']->sql_free_result($temp_res); 02042 02043 if (!$this->jumpurl) die('Error: No further link. Please report error to the mail sender.'); 02044 } else { 02045 $responseType=-1; // received (url, dmailerping) 02046 } 02047 if ($responseType!=0) { 02048 $insertFields = array( 02049 'mid' => intval($mid), 02050 'rtbl' => $temp_recip[0], 02051 'rid' => intval($temp_recip[1]), 02052 'tstamp' => time(), 02053 'url' => $this->jumpurl, 02054 'response_type' => intval($responseType), 02055 'url_id' => intval($url_id) 02056 ); 02057 02058 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_dmail_maillog', $insertFields); 02059 } 02060 } 02061 } else { 02062 unset($this->jumpurl); 02063 } 02064 } 02065 02072 function jumpUrl() { 02073 if ($this->jumpurl) { 02074 if (t3lib_div::_GP('juSecure')) { 02075 $hArr = array( 02076 $this->jumpurl, 02077 t3lib_div::_GP('locationData'), 02078 $this->TYPO3_CONF_VARS['SYS']['encryptionKey'] 02079 ); 02080 $calcJuHash=t3lib_div::shortMD5(serialize($hArr)); 02081 $locationData = t3lib_div::_GP('locationData'); 02082 $juHash = t3lib_div::_GP('juHash'); 02083 if ($juHash == $calcJuHash) { 02084 if ($this->locDataCheck($locationData)) { 02085 $this->jumpurl = rawurldecode($this->jumpurl); // 211002 - goes with cObj->filelink() rawurlencode() of filenames so spaces can be allowed. 02086 if (@is_file($this->jumpurl)) { 02087 $mimeType = t3lib_div::_GP('mimeType'); 02088 $mimeType = $mimeType ? $mimeType : 'application/octet-stream'; 02089 Header('Content-Type: '.$mimeType); 02090 Header('Content-Disposition: attachment; filename='.basename($this->jumpurl)); 02091 readfile($this->jumpurl); 02092 exit; 02093 } else die('jumpurl Secure: "'.$this->jumpurl.'" was not a valid file!'); 02094 } else die('jumpurl Secure: locationData, '.$locationData.', was not accessible.'); 02095 } else die('jumpurl Secure: Calculated juHash, '.$calcJuHash.', did not match the submitted juHash.'); 02096 } else { 02097 $TSConf = $this->getPagesTSconfig(); 02098 if ($TSConf['TSFE.']['jumpUrl_transferSession']) { 02099 $uParts = parse_url($this->jumpurl); 02100 $params = '&FE_SESSION_KEY='.rawurlencode($this->fe_user->id.'-'.md5($this->fe_user->id.'/'.$this->TYPO3_CONF_VARS['SYS']['encryptionKey'])); 02101 $this->jumpurl.=($uParts['query']?'':'?').$params; // Add the session parameter ... 02102 } 02103 Header('Location: '.$this->jumpurl); 02104 exit; 02105 } 02106 } 02107 } 02108 02115 function setUrlIdToken() { 02116 if ($this->config['config']['ftu']) { 02117 $this->getMethodUrlIdToken = $this->TYPO3_CONF_VARS['FE']['get_url_id_token']; 02118 } else { 02119 $this->getMethodUrlIdToken = ''; 02120 } 02121 } 02122 02123 02124 02125 02126 02127 02128 02129 02130 02131 02132 02133 02134 02135 02136 02137 02138 02139 02140 02141 02142 02143 02144 02145 02146 /******************************************** 02147 * 02148 * Page generation; cache handling 02149 * 02150 *******************************************/ 02151 02158 function isGeneratePage() { 02159 return (!$this->cacheContentFlag && !$this->jumpurl); 02160 } 02161 02168 function tempPageCacheContent() { 02169 $this->tempContent = FALSE; 02170 02171 if (!$this->no_cache) { 02172 $seconds = 30; 02173 $stdMsg = ' 02174 <html> 02175 <head> 02176 <title>'.htmlspecialchars($this->tmpl->printTitle($this->page['title'])).'</title> 02177 <meta http-equiv="refresh" content="3; URL='.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'" /> 02178 </head> 02179 <body bgcolor="white"> 02180 <div align="center" style="font-family:Verdana,Arial,Helvetica" color="#cccccc"> 02181 <strong>Page is being generated.</strong><br /> 02182 If this message does not disappear within '.$seconds.' seconds, please reload. 02183 </div> 02184 </body> 02185 </html>'; 02186 $temp_content = $this->config['config']['message_page_is_being_generated'] ? $this->config['config']['message_page_is_being_generated'] : $stdMsg; 02187 02188 $this->setPageCacheContent($temp_content, '', $GLOBALS['EXEC_TIME']+$seconds); 02189 $this->tempContent = TRUE; // This flag shows that temporary content is put in the cache 02190 } 02191 } 02192 02198 function realPageCacheContent() { 02199 $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 02200 $timeOutTime = $GLOBALS['EXEC_TIME']+$cache_timeout; 02201 if ($this->config['config']['cache_clearAtMidnight']) { 02202 $midnightTime = mktime (0,0,0,date('m',$timeOutTime),date('d',$timeOutTime),date('Y',$timeOutTime)); 02203 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. 02204 $timeOutTime = $midnightTime; 02205 } 02206 } 02207 $this->config['hash_base'] = $this->hash_base; 02208 $this->setPageCacheContent($this->content, $this->config, $timeOutTime); 02209 02210 // Hook for cache post processing (eg. writing static files!) 02211 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'])) { 02212 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'] as $_classRef) { 02213 $_procObj = &t3lib_div::getUserObj($_classRef); 02214 $_procObj->insertPageIncache($this,$timeOutTime); 02215 } 02216 } 02217 } 02218 02228 function setPageCacheContent($c,$d,$t) { 02229 $this->clearPageCacheContent(); 02230 $insertFields = array( 02231 'hash' => $this->newHash, 02232 'page_id' => $this->id, 02233 'HTML' => $c, 02234 'cache_data' => serialize($d), 02235 'expires' => $t, 02236 'tstamp' => $GLOBALS['EXEC_TIME'] 02237 ); 02238 02239 $this->cacheExpires = $t; 02240 02241 if ($this->page_cache_reg1) { 02242 $insertFields['reg1'] = intval($this->page_cache_reg1); 02243 } 02244 02245 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pages', $insertFields); 02246 } 02247 02253 function clearPageCacheContent() { 02254 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->newHash, 'cache_pages')); 02255 } 02256 02263 function clearPageCacheContent_pidList($pidList) { 02264 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'page_id IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($pidList).')'); 02265 } 02266 02274 function setSysLastChanged() { 02275 if ($this->page['SYS_LASTCHANGED'] < intval($this->register['SYS_LASTCHANGED'])) { 02276 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid='.intval($this->id), array('SYS_LASTCHANGED' => intval($this->register['SYS_LASTCHANGED']))); 02277 } 02278 } 02279 02280 02281 02282 02283 02284 02285 02286 02287 02288 02289 02290 02291 02292 02293 02294 02295 02296 02297 02298 02299 /******************************************** 02300 * 02301 * Page generation; rendering and inclusion 02302 * 02303 *******************************************/ 02304 02310 function generatePage_preProcessing() { 02311 ksort($this->all); 02312 // 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! 02313 $this->newHash = $this->getHash(); 02314 02315 // 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. 02316 $this->tempPageCacheContent(); 02317 02318 02319 // Setting cache_timeout_default. May be overridden by PHP include scritps. 02320 $this->cacheTimeOutDefault = intval($this->config['config']['cache_period']); 02321 02322 // page is generated 02323 $this->no_cacheBeforePageGen = $this->no_cache; 02324 } 02325 02332 function generatePage_whichScript() { 02333 if (!$this->TYPO3_CONF_VARS['FE']['noPHPscriptInclude'] && $this->config['config']['pageGenScript']) { 02334 return $this->tmpl->getFileName($this->config['config']['pageGenScript']); 02335 } 02336 } 02337 02344 function generatePage_postProcessing() { 02345 // 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. 02346 if ($this->no_cacheBeforePageGen) $this->set_no_cache(); 02347 02348 // Tidy up the code, if flag... 02349 if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'all') { 02350 $GLOBALS['TT']->push('Tidy, all',''); 02351 $this->content = $this->tidyHTML($this->content); 02352 $GLOBALS['TT']->pull(); 02353 } 02354 02355 // XHTML-clean the code, if flag set 02356 if ($this->doXHTML_cleaning() == 'all') { 02357 $GLOBALS['TT']->push('XHTML clean, all',''); 02358 $XHTML_clean = t3lib_div::makeInstance('t3lib_parsehtml'); 02359 $this->content = $XHTML_clean->XHTML_clean($this->content); 02360 $GLOBALS['TT']->pull(); 02361 } 02362 02363 // Fix local anchors in links, if flag set 02364 if ($this->doLocalAnchorFix() == 'all') { 02365 $GLOBALS['TT']->push('Local anchor fix, all',''); 02366 $this->prefixLocalAnchorsWithScript(); 02367 $GLOBALS['TT']->pull(); 02368 } 02369 02370 // Hook for post-processing of page content cached/non-cached: 02371 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'])) { 02372 $_params = array('pObj' => &$this); 02373 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'] as $_funcRef) { 02374 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02375 } 02376 } 02377 02378 // Processing if caching is enabled: 02379 if (!$this->no_cache) { 02380 // Tidy up the code, if flag... 02381 if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'cached') { 02382 $GLOBALS['TT']->push('Tidy, cached',''); 02383 $this->content = $this->tidyHTML($this->content); 02384 $GLOBALS['TT']->pull(); 02385 } 02386 // XHTML-clean the code, if flag set 02387 if ($this->doXHTML_cleaning() == 'cached') { 02388 $GLOBALS['TT']->push('XHTML clean, cached',''); 02389 $XHTML_clean = t3lib_div::makeInstance('t3lib_parsehtml'); 02390 $this->content = $XHTML_clean->XHTML_clean($this->content); 02391 $GLOBALS['TT']->pull(); 02392 } 02393 // Fix local anchors in links, if flag set 02394 if ($this->doLocalAnchorFix() == 'cached') { 02395 $GLOBALS['TT']->push('Local anchor fix, cached',''); 02396 $this->prefixLocalAnchorsWithScript(); 02397 $GLOBALS['TT']->pull(); 02398 } 02399 02400 // Hook for post-processing of page content before being cached: 02401 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'])) { 02402 $_params = array('pObj' => &$this); 02403 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'] as $_funcRef) { 02404 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02405 } 02406 } 02407 } 02408 02409 // 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! 02410 $this->content = $this->convOutputCharset($this->content,'mainpage'); 02411 02412 // Hook for indexing pages 02413 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageIndexing'])) { 02414 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageIndexing'] as $_classRef) { 02415 $_procObj = &t3lib_div::getUserObj($_classRef); 02416 $_procObj->hook_indexContent($this); 02417 } 02418 } 02419 02420 // Storing for cache: 02421 if (!$this->no_cache) { 02422 $this->realPageCacheContent(); 02423 } 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) 02424 $this->clearPageCacheContent(); 02425 } 02426 02427 // Sets sys-last-change: 02428 $this->setSysLastChanged(); 02429 } 02430 02436 function INTincScript() { 02437 $GLOBALS['TT']->push('Split content'); 02438 $INTiS_splitC = explode('<!--INT_SCRIPT.',$this->content); // Splits content with the key. 02439 $this->content=''; 02440 $GLOBALS['TT']->setTSlogMessage('Parts: '.count($INTiS_splitC)); 02441 $GLOBALS['TT']->pull(); 02442 02443 // Depreciated stuff: 02444 $this->additionalHeaderData = is_array($this->config['INTincScript_ext']['additionalHeaderData']) ? $this->config['INTincScript_ext']['additionalHeaderData'] : array(); 02445 $this->additionalJavaScript = $this->config['INTincScript_ext']['additionalJavaScript']; 02446 $this->additionalCSS = $this->config['INTincScript_ext']['additionalCSS']; 02447 $this->JSCode = $this->additionalHeaderData['JSCode']; 02448 $this->JSImgCode = $this->additionalHeaderData['JSImgCode']; 02449 $this->divSection=''; 02450 02451 $INTiS_config = $GLOBALS['TSFE']->config['INTincScript']; 02452 foreach($INTiS_splitC as $INTiS_c => $INTiS_cPart) { 02453 if (substr($INTiS_cPart,32,3)=='-->') { // If the split had a comment-end after 32 characters it's probably a split-string 02454 $GLOBALS['TT']->push('Include '.$INTiS_config[$INTiS_key]['file'],''); 02455 $INTiS_key = 'INT_SCRIPT.'.substr($INTiS_cPart,0,32); 02456 $incContent=''; 02457 if (is_array($INTiS_config[$INTiS_key])) { 02458 $INTiS_cObj = unserialize($INTiS_config[$INTiS_key]['cObj']); 02459 $INTiS_cObj->INT_include=1; 02460 switch($INTiS_config[$INTiS_key]['type']) { 02461 case 'SCRIPT': 02462 $incContent = $INTiS_cObj->PHP_SCRIPT($INTiS_config[$INTiS_key]['conf']); 02463 break; 02464 case 'COA': 02465 $incContent = $INTiS_cObj->COBJ_ARRAY($INTiS_config[$INTiS_key]['conf']); 02466 break; 02467 case 'FUNC': 02468 $incContent = $INTiS_cObj->USER($INTiS_config[$INTiS_key]['conf']); 02469 break; 02470 case 'POSTUSERFUNC': 02471 $incContent = $INTiS_cObj->callUserFunction($INTiS_config[$INTiS_key]['postUserFunc'], $INTiS_config[$INTiS_key]['conf'], $INTiS_config[$INTiS_key]['content']); 02472 break; 02473 } 02474 } 02475 $this->content.= $this->convOutputCharset($incContent,'INC-'.$INTiS_c); 02476 $this->content.= substr($INTiS_cPart,35); 02477 $GLOBALS['TT']->pull($incContent); 02478 } else { 02479 $this->content.= ($INTiS_c?'<!--INT_SCRIPT.':'').$INTiS_cPart; 02480 } 02481 } 02482 $GLOBALS['TT']->push('Substitute header section'); 02483 $this->INTincScript_loadJSCode(); 02484 $this->content = str_replace('<!--HD_'.$this->config['INTincScript_ext']['divKey'].'-->', $this->convOutputCharset(implode(chr(10),$this->additionalHeaderData),'HD'), $this->content); 02485 $this->content = str_replace('<!--TDS_'.$this->config['INTincScript_ext']['divKey'].'-->', $this->convOutputCharset($this->divSection,'TDS'), $this->content); 02486 $this->setAbsRefPrefix(); 02487 $GLOBALS['TT']->pull(); 02488 } 02489 02496 function INTincScript_loadJSCode() { 02497 if ($this->JSImgCode) { // If any images added, then add them to the javascript section 02498 $this->additionalHeaderData['JSImgCode']=' 02499 <script type="text/javascript"> 02500 /*<![CDATA[*/ 02501 <!-- 02502 if (version == "n3") { 02503 '.trim($this->JSImgCode).' 02504 } 02505 // --> 02506 /*]]>*/ 02507 </script>'; 02508 } 02509 if ($this->JSCode || count($this->additionalJavaScript)) { // Add javascript 02510 $this->additionalHeaderData['JSCode']=' 02511 <script type="text/javascript"> 02512 /*<![CDATA[*/ 02513 <!-- 02514 '.implode(chr(10),$this->additionalJavaScript).' 02515 '.trim($this->JSCode).' 02516 // --> 02517 /*]]>*/ 02518 </script>'; 02519 } 02520 if (count($this->additionalCSS)) { // Add javascript 02521 $this->additionalHeaderData['_CSS']=' 02522 <style type="text/css"> 02523 /*<![CDATA[*/ 02524 <!-- 02525 '.implode(chr(10),$this->additionalCSS).' 02526 // --> 02527 /*]]>*/ 02528 </style>'; 02529 } 02530 } 02531 02537 function isINTincScript() { 02538 return (is_array($this->config['INTincScript']) && !$this->jumpurl); 02539 } 02540 02546 function doXHTML_cleaning() { 02547 return $this->config['config']['xhtml_cleaning']; 02548 } 02549 02555 function doLocalAnchorFix() { 02556 return $this->config['config']['prefixLocalAnchors']; 02557 } 02558 02559 02560 02561 02562 02563 02564 02565 02566 02567 02568 02569 02570 02571 02572 02573 02574 /******************************************** 02575 * 02576 * Finished off; outputting, storing session data, statistics... 02577 * 02578 *******************************************/ 02579 02586 function isOutputting() { 02587 02588 // Initialize by status of jumpUrl: 02589 $enableOutput = (!$this->jumpurl); 02590 02591 // Call hook for possible disabling of output: 02592 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['isOutputting'])) { 02593 $_params = array('pObj' => &$this, 'enableOutput' => &$enableOutput); 02594 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['isOutputting'] as $_funcRef) { 02595 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02596 } 02597 } 02598 02599 return $enableOutput; 02600 } 02601 02609 function processOutput() { 02610 02611 // Set header for charset-encoding unless disabled 02612 if (!$this->config['config']['disableCharsetHeader']) { 02613 $headLine = 'Content-Type:text/html;charset='.trim($this->metaCharset); 02614 header($headLine); 02615 } 02616 02617 // Set cache related headers to client (used to enable proxy / client caching!) 02618 if ($this->config['config']['sendCacheHeaders']) { 02619 $this->sendCacheHeaders(); 02620 } 02621 02622 // Set headers, if any 02623 if ($this->config['config']['additionalHeaders']) { 02624 $headerArray = explode('|', $this->config['config']['additionalHeaders']); 02625 while(list(,$headLine)=each($headerArray)) { 02626 $headLine = trim($headLine); 02627 header($headLine); 02628 } 02629 } 02630 02631 // Make substitution of eg. username/uid in content only if cache-headers for client/proxy caching is NOT sent! 02632 if (!$this->isClientCachable) { 02633 $this->contentStrReplace(); 02634 } 02635 02636 // Tidy up the code, if flag... 02637 if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'output') { 02638 $GLOBALS['TT']->push('Tidy, output',''); 02639 $this->content = $this->tidyHTML($this->content); 02640 $GLOBALS['TT']->pull(); 02641 } 02642 // XHTML-clean the code, if flag set 02643 if ($this->doXHTML_cleaning() == 'output') { 02644 $GLOBALS['TT']->push('XHTML clean, output',''); 02645 $XHTML_clean = t3lib_div::makeInstance('t3lib_parsehtml'); 02646 $this->content = $XHTML_clean->XHTML_clean($this->content); 02647 $GLOBALS['TT']->pull(); 02648 } 02649 // Fix local anchors in links, if flag set 02650 if ($this->doLocalAnchorFix() == 'output') { 02651 $GLOBALS['TT']->push('Local anchor fix, output',''); 02652 $this->prefixLocalAnchorsWithScript(); 02653 $GLOBALS['TT']->pull(); 02654 } 02655 02656 // Hook for post-processing of page content before output: 02657 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'])) { 02658 $_params = array('pObj' => &$this); 02659 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'] as $_funcRef) { 02660 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02661 } 02662 } 02663 02664 /* if ($this->beUserLogin && t3lib_div::_GP('ADMCMD_view')) { // This is a try to change target=_top to target=_self if pages are shown in the Web>View module... 02665 $this->content = str_replace('target="_top"','target="_self"',$this->content); 02666 $this->content = str_replace('target=_top','target="_self"',$this->content); 02667 }*/ 02668 02669 // 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! 02670 if ($this->config['config']['enableContentLengthHeader'] && !$this->isEXTincScript() && !$this->beUserLogin) { 02671 header('Content-Length: '.strlen($this->content)); 02672 } 02673 } 02674 02682 function sendCacheHeaders() { 02683 02684 // Getting status whether we can send cache control headers for proxy caching: 02685 $doCache = $this->isStaticCacheble(); 02686 02687 // 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... 02688 $loginsDeniedCfg = !$this->config['config']['sendCacheHeaders_onlyWhenLoginDeniedInBranch'] || !$this->loginAllowedInBranch; 02689 02690 // Finally, when backend users are logged in, do not send cache headers at all (Admin Panel might be displayed for instance). 02691 if ($doCache 02692 && !$this->beUserLogin 02693 && $loginsDeniedCfg) { 02694 02695 // Build headers: 02696 $headers = array( 02697 'Last-Modified: '.gmdate('D, d M Y H:i:s T', $this->register['SYS_LASTCHANGED']), 02698 'Expires: '.gmdate('D, d M Y H:i:s T', $this->cacheExpires), 02699 'ETag: '.md5($this->content), 02700 'Cache-Control: max-age='.($this->cacheExpires - $GLOBALS['EXEC_TIME']), // no-cache 02701 'Pragma: public', 02702 ); 02703 02704 $this->isClientCachable = TRUE; 02705 } else { 02706 // Build headers: 02707 $headers = array( 02708 #'Last-Modified: '.gmdate('D, d M Y H:i:s T', $this->register['SYS_LASTCHANGED']), 02709 #'ETag: '.md5($this->content), 02710 02711 #'Cache-Control: no-cache', 02712 #'Pragma: no-cache', 02713 'Cache-Control: private', // Changed to this according to Ole Tange, FI.dk 02714 ); 02715 02716 $this->isClientCachable = FALSE; 02717 02718 // Now, if a backend user is logged in, tell him in the Admin Panel log what the caching status would have been: 02719 if ($this->beUserLogin) { 02720 if ($doCache) { 02721 $GLOBALS['TT']->setTSlogMessage('Cache-headers with max-age "'.($this->cacheExpires - $GLOBALS['EXEC_TIME']).'" would have been sent'); 02722 } else { 02723 $reasonMsg = ''; 02724 $reasonMsg.= !$this->no_cache ? '' : 'Caching disabled (no_cache). '; 02725 $reasonMsg.= !$this->isINTincScript() ? '' : '*_INT object(s) on page. '; 02726 $reasonMsg.= !$this->isEXTincScript() ? '' : '*_EXT object(s) on page. '; 02727 $reasonMsg.= !is_array($this->fe_user->user) ? '' : 'Frontend user logged in. '; 02728 $GLOBALS['TT']->setTSlogMessage('Cache-headers would disable proxy caching! Reason(s): "'.$reasonMsg.'"',1); 02729 } 02730 } 02731 } 02732 02733 // Send headers: 02734 foreach($headers as $hL) { 02735 header($hL); 02736 } 02737 } 02738 02749 function isStaticCacheble() { 02750 $doCache = !$this->no_cache 02751 && !$this->isINTincScript() 02752 && !$this->isEXTincScript() 02753 && !$this->isUserOrGroupSet(); 02754 return $doCache; 02755 } 02756 02762 function contentStrReplace() { 02763 // Substitutes username mark with the username 02764 if ($this->fe_user->user['uid']) { 02765 02766 // User name: 02767 $token = trim($this->config['config']['USERNAME_substToken']); 02768 $this->content = str_replace($token ? $token : '<!--###USERNAME###-->',$this->fe_user->user['username'],$this->content); 02769 02770 // User uid (if configured): 02771 $token = trim($this->config['config']['USERUID_substToken']); 02772 if ($token) { 02773 $this->content = str_replace($token, $this->fe_user->user['uid'], $this->content); 02774 } 02775 } 02776 // Substitutes get_URL_ID in case of GET-fallback 02777 if ($this->getMethodUrlIdToken) { 02778 $this->content = str_replace($this->getMethodUrlIdToken, $this->fe_user->get_URL_ID, $this->content); 02779 } 02780 } 02781 02788 function isEXTincScript() { 02789 return is_array($this->config['EXTincScript']); 02790 } 02791 02797 function storeSessionData() { 02798 $this->fe_user->storeSessionData(); 02799 } 02800 02807 function setParseTime() { 02808 // Compensates for the time consumed with Back end user initialization. 02809 $this->scriptParseTime = $GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_end']) 02810 - $GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_start']) 02811 - ($GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'])-$GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'])); 02812 } 02813 02819 function statistics() { 02820 if ($this->config['config']['stat'] && 02821 (!strcmp('',$this->config['config']['stat_typeNumList']) || t3lib_div::inList(str_replace(' ','',$this->config['config']['stat_typeNumList']), $this->type)) && 02822 (!$this->config['config']['stat_excludeBEuserHits'] || !$this->beUserLogin) && 02823 (!$this->config['config']['stat_excludeIPList'] || !t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'),str_replace(' ','',$this->config['config']['stat_excludeIPList'])))) { 02824 02825 $GLOBALS['TT']->push('Stat'); 02826 if (t3lib_extMgm::isLoaded('sys_stat') && $this->config['config']['stat_mysql']) { 02827 02828 // Jumpurl: 02829 $sword = t3lib_div::_GP('sword'); 02830 if ($sword) { 02831 $jumpurl_msg = 'sword:'.$sword; 02832 } elseif ($this->jumpurl) { 02833 $jumpurl_msg = 'jumpurl:'.$this->jumpurl; 02834 } else { 02835 $jumpurl_msg = ''; 02836 } 02837 02838 // Flags: bits: 0 = BE_user, 1=Cached page? 02839 $flags=0; 02840 if ($this->beUserLogin) {$flags|=1;} 02841 if ($this->cacheContentFlag) {$flags|=2;} 02842 02843 // Ref url: 02844 $refUrl = t3lib_div::getIndpEnv('HTTP_REFERER'); 02845 $thisUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR'); 02846 if (t3lib_div::isFirstPartOfStr($refUrl,$thisUrl)) { 02847 $refUrl='[LOCAL]'; 02848 } 02849 02850 $insertFields = array( 02851 'page_id' => intval($this->id), // id 02852 'page_type' => intval($this->type), // type 02853 'jumpurl' => $jumpurl_msg, // jumpurl message 02854 'feuser_id' => $this->fe_user->user['uid'], // fe_user id, integer 02855 'cookie' => $this->fe_user->id, // cookie as set or retrieve. If people has cookies disabled this will vary all the time... 02856 '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... 02857 'rl0' => $this->config['rootLine'][0]['uid'], // RootLevel 0 uid 02858 'rl1' => $this->config['rootLine'][1]['uid'], // RootLevel 1 uid 02859 'client_browser' => $GLOBALS['CLIENT']['BROWSER'], // Client browser (net, msie, opera) 02860 'client_version' => $GLOBALS['CLIENT']['VERSION'], // Client version (double value) 02861 'client_os' => $GLOBALS['CLIENT']['SYSTEM'], // Client Operating system (win, mac, unix) 02862 'parsetime' => intval($this->scriptParseTime), // Parsetime for the page. 02863 'flags' => $flags, // Flags: Is be user logged in? Is page cached? 02864 'IP' => t3lib_div::getIndpEnv('REMOTE_ADDR'), // Remote IP address 02865 'host' => t3lib_div::getIndpEnv('REMOTE_HOST'), // Remote Host Address 02866 'referer' => $refUrl, // Referer URL 02867 'browser' => t3lib_div::getIndpEnv('HTTP_USER_AGENT'), // User Agent Info. 02868 'tstamp' => $GLOBALS['EXEC_TIME'] // Time stamp 02869 ); 02870 02871 // Hook for preprocessing the list of fields to insert into sys_stat: 02872 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sys_stat-PreProcClass'])) { 02873 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sys_stat-PreProcClass'] as $_classRef) { 02874 $_procObj = &t3lib_div::getUserObj($_classRef); 02875 $insertFields = $_procObj->sysstat_preProcessFields($insertFields,$this); 02876 } 02877 } 02878 02879 02880 $GLOBALS['TT']->push('Store SQL'); 02881 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_stat', $insertFields); 02882 $GLOBALS['TT']->pull(); 02883 } 02884 02885 // Apache: 02886 if ($this->config['config']['stat_apache'] && $this->config['stat_vars']['pageName']) { 02887 if (@is_file($this->config['stat_vars']['logFile'])) { 02888 $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); 02889 if (!$this->config['config']['stat_apache_notExtended']) { 02890 $LogLine.= ' "'.t3lib_div::getIndpEnv('HTTP_REFERER').'" "'.t3lib_div::getIndpEnv('HTTP_USER_AGENT').'"'; 02891 } 02892 02893 switch($this->TYPO3_CONF_VARS['FE']['logfile_write']) { 02894 case 'fputs': 02895 $GLOBALS['TT']->push('Write to log file (fputs)'); 02896 $logfilehandle = fopen($this->config['stat_vars']['logFile'], 'a'); 02897 fputs($logfilehandle, $LogLine."\n"); 02898 @fclose($logfilehandle); 02899 $GLOBALS['TT']->pull(); 02900 break; 02901 default: 02902 $GLOBALS['TT']->push('Write to log file (echo)'); 02903 if (TYPO3_OS=="WIN") { 02904 $execCmd = 'echo '.$LogLine.' >> '.$this->config['stat_vars']['logFile']; 02905 } else { 02906 $execCmd = 'echo "'.addslashes($LogLine).'" >> '.$this->config['stat_vars']['logFile']; 02907 } 02908 exec($execCmd); 02909 $GLOBALS['TT']->pull(); 02910 break; 02911 } 02912 02913 $GLOBALS['TT']->setTSlogMessage('Writing to logfile: OK',0); 02914 } else { 02915 $GLOBALS['TT']->setTSlogMessage('Writing to logfile: Error - logFile did not exist or OS is Windows!',3); 02916 } 02917 } 02918 $GLOBALS['TT']->pull(); 02919 } 02920 } 02921 02927 function previewInfo() { 02928 if ($this->fePreview) { 02929 $stdMsg = ' 02930 <br /> 02931 <div align="center"> 02932 <table border="3" bordercolor="black" cellpadding="2" bgcolor="red"> 02933 <tr> 02934 <td> <font face="Verdana" size="1"><b>PREVIEW!</b></font> </td> 02935 </tr> 02936 </table> 02937 </div>'; 02938 $temp_content = $this->config['config']['message_preview'] ? $this->config['config']['message_preview'] : $stdMsg; 02939 echo $temp_content; 02940 } 02941 } 02942 02948 function hook_eofe() { 02949 02950 // Call hook for end-of-frontend processing: 02951 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe'])) { 02952 $_params = array('pObj' => &$this); 02953 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe'] as $_funcRef) { 02954 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02955 } 02956 } 02957 } 02958 02964 function beLoginLinkIPList() { 02965 if ($this->config['config']['beLoginLinkIPList']) { 02966 if (t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $this->config['config']['beLoginLinkIPList'])) { 02967 $label = !$this->beUserLogin ? $this->config['config']['beLoginLinkIPList_login'] : $this->config['config']['beLoginLinkIPList_logout']; 02968 if ($label) { 02969 if (!$this->beUserLogin) { 02970 $link = '<a href="'.htmlspecialchars(TYPO3_mainDir.'index.php?redirect_url='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI"))).'">'.$label.'</a>'; 02971 } else { 02972 $link = '<a href="'.htmlspecialchars(TYPO3_mainDir.'index.php?L=OUT&redirect_url='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI"))).'">'.$label.'</a>'; 02973 } 02974 return $link; 02975 } 02976 } 02977 } 02978 } 02979 02980 02981 02982 02983 02984 02985 02986 02987 02988 02989 02990 02991 02992 02993 02994 02995 02996 02997 02998 02999 03000 03001 /******************************************** 03002 * 03003 * Various internal API functions 03004 * 03005 *******************************************/ 03006 03007 03019 function makeSimulFileName($inTitle,$page,$type,$addParams='',$no_cache='') { 03020 $titleChars = intval($this->config['config']['simulateStaticDocuments_addTitle']); 03021 // Default value is 30 but values > 1 will be override this 03022 if($titleChars==1) { $titleChars = 30; } 03023 03024 $out = ''; 03025 if ($titleChars) { 03026 $out = $this->fileNameASCIIPrefix($inTitle, $titleChars); 03027 } 03028 $enc = ''; 03029 03030 if (strcmp($addParams,'') && !$no_cache) { 03031 switch ((string)$this->config['config']['simulateStaticDocuments_pEnc']) { 03032 case 'md5': 03033 $md5 = substr(md5($addParams),0,10); 03034 $enc = '+M5'.$md5; 03035 03036 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('md5hash', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($md5, 'cache_md5params')); 03037 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 03038 $insertFields = array( 03039 'md5hash' => $md5, 03040 'tstamp' => time(), 03041 'type' => 1, 03042 'params' => $addParams 03043 ); 03044 03045 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_md5params', $insertFields); 03046 } 03047 break; 03048 case 'base64': 03049 $enc = '+B6'.str_replace('=','_',str_replace('/','-',base64_encode($addParams))); 03050 break; 03051 } 03052 } 03053 // Setting page and type number: 03054 $url = $out.$page.$enc; 03055 $url.= ($type || $out || !$this->config['config']['simulateStaticDocuments_noTypeIfNoTitle']) ? '.'.$type : ''; 03056 return $url; 03057 } 03058 03066 function simulateStaticDocuments_pEnc_onlyP_proc($linkVars) { 03067 $remainLinkVars = ''; 03068 if (strcmp($linkVars,'')) { 03069 $p = explode('&',$linkVars); 03070 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? 03071 $rem = array(); 03072 foreach($p as $k => $v) { 03073 if (strlen($v)) { 03074 list($pName) = explode('=',$v,2); 03075 $pName = rawurldecode($pName); 03076 if (!$this->pEncAllowedParamNames[$pName]) { 03077 unset($p[$k]); 03078 $rem[] = $v; 03079 } 03080 } else unset($p[$k]); 03081 } 03082 03083 $linkVars = count($p) ? '&'.implode('&',$p) : ''; 03084 $remainLinkVars = count($rem) ? '&'.implode('&',$rem) : ''; 03085 } 03086 return array($linkVars, $remainLinkVars); 03087 } 03088 03095 function getSimulFileName() { 03096 $url=''; 03097 $url.=$this->makeSimulFileName($this->page['title'], $this->page['alias']?$this->page['alias']:$this->id, $this->type).'.html'; 03098 return $url; 03099 } 03100 03109 function fileNameASCIIPrefix($inTitle,$titleChars,$mergeChar='.') { 03110 $out = $this->csConvObj->specCharsToASCII($this->renderCharset, $inTitle); 03111 $out = ereg_replace('[^[:alnum:]_-]','_',trim(substr($out,0,$titleChars))); 03112 $out = ereg_replace('[_-]*$','',$out); 03113 $out = ereg_replace('^[_-]*','',$out); 03114 $out = ereg_replace('([_-])[_-]*','\1',$out); 03115 if (strlen($out)) $out.=$mergeChar; 03116 03117 return $out; 03118 } 03119 03127 function encryptEmail($string,$back=0) { 03128 $out = ''; 03129 03130 if ($this->spamProtectEmailAddresses === 'ascii') { 03131 for ($a=0; $a<strlen($string); $a++) { 03132 $out .= '&#'.ord(substr($string, $a, 1)).';'; 03133 } 03134 } else { 03135 for ($a=0; $a<strlen($string); $a++) { 03136 $charValue = ord(substr($string,$a,1)); 03137 $charValue+= intval($this->spamProtectEmailAddresses)*($back?-1:1); 03138 $out.= chr($charValue); 03139 } 03140 } 03141 return $out; 03142 } 03143 03153 function codeString($string, $decode=FALSE) { 03154 03155 if ($decode) { 03156 list($md5Hash, $str) = explode(':',$string,2); 03157 $newHash = substr(md5($this->TYPO3_CONF_VARS['SYS']['encryptionKey'].':'.$str),0,10); 03158 if (!strcmp($md5Hash, $newHash)) { 03159 $str = base64_decode($str); 03160 $str = $this->roundTripCryptString($str); 03161 return $str; 03162 } else return FALSE; // Decoding check failed! Original string not produced by this server! 03163 } else { 03164 $str = $string; 03165 $str = $this->roundTripCryptString($str); 03166 $str = base64_encode($str); 03167 $newHash = substr(md5($this->TYPO3_CONF_VARS['SYS']['encryptionKey'].':'.$str),0,10); 03168 return $newHash.':'.$str; 03169 } 03170 } 03171 03179 function roundTripCryptString($string) { 03180 $out = ''; 03181 $strLen = strlen($string); 03182 $cryptLen = strlen($this->TYPO3_CONF_VARS['SYS']['encryptionKey']); 03183 03184 for ($a=0; $a < $strLen; $a++) { 03185 $xorVal = $cryptLen>0 ? ord($this->TYPO3_CONF_VARS['SYS']['encryptionKey']{($a%$cryptLen)}) : 255; 03186 $out.= chr(ord($string{$a}) ^ $xorVal); 03187 } 03188 03189 return $out; 03190 } 03191 03199 function checkFileInclude($incFile) { 03200 return !$this->TYPO3_CONF_VARS['FE']['noPHPscriptInclude'] 03201 || substr($incFile,0,14)=='media/scripts/' 03202 || substr($incFile,0,4+strlen(TYPO3_mainDir))==TYPO3_mainDir.'ext/' 03203 || substr($incFile,0,7+strlen(TYPO3_mainDir))==TYPO3_mainDir.'sysext/' 03204 || substr($incFile,0,14)=='typo3conf/ext/'; 03205 } 03206 03214 function newCObj() { 03215 $this->cObj =t3lib_div::makeInstance('tslib_cObj'); 03216 $this->cObj->start($this->page,'pages'); 03217 } 03218 03227 function setAbsRefPrefix() { 03228 if ($this->absRefPrefix) { 03229 $this->content = str_replace('"media/', '"'.$this->absRefPrefix.'media/', $this->content); 03230 $this->content = str_replace('"fileadmin/', '"'.$this->absRefPrefix.'fileadmin/', $this->content); 03231 } 03232 } 03233 03241 function baseUrlWrap($url) { 03242 if ($this->baseUrl) { 03243 $urlParts = parse_url($url); 03244 if (!strlen($urlParts['scheme']) && $url{0}!=='/') { 03245 $url = $this->baseUrl.$url; 03246 } 03247 } 03248 return $url; 03249 } 03250 03260 function printError($label,$header='Error!') { 03261 t3lib_timeTrack::debug_typo3PrintError($header,$label,0,t3lib_div::getIndpEnv('TYPO3_SITE_URL')); 03262 } 03263 03271 function updateMD5paramsRecord($hash) { 03272 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_md5params'), array('tstamp' => time())); 03273 } 03274 03282 function tidyHTML($content) { 03283 if ($this->TYPO3_CONF_VARS['FE']['tidy'] && $this->TYPO3_CONF_VARS['FE']['tidy_path']) { 03284 $oldContent = $content; 03285 $fname = t3lib_div::tempnam('Typo3_Tidydoc_'); // Create temporary name 03286 @unlink ($fname); // Delete if exists, just to be safe. 03287 $fp = fopen ($fname,'wb'); // Open for writing 03288 fputs ($fp, $content); // Put $content 03289 @fclose ($fp); // Close 03290 03291 exec ($this->TYPO3_CONF_VARS['FE']['tidy_path'].' '.$fname, $output); // run the $content through 'tidy', which formats the HTML to nice code. 03292 @unlink ($fname); // Delete the tempfile again 03293 $content = implode(chr(10),$output); 03294 if (!trim($content)) { 03295 $content = $oldContent; // Restore old content due empty return value. 03296 $GLOBALS['TT']->setTSlogMessage('"tidy" returned an empty value!',2); 03297 } 03298 $GLOBALS['TT']->setTSlogMessage('"tidy" content lenght: '.strlen($content),0); 03299 } 03300 return $content; 03301 } 03302 03308 function prefixLocalAnchorsWithScript() { 03309 $scriptPath = substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL'))); 03310 $this->content = eregi_replace('(<(a|area)[[:space:]]+href=")(#[^"]*")','\1'.htmlspecialchars($scriptPath).'\3',$this->content); 03311 } 03312 03313 03314 03315 03316 03317 03318 03319 03320 03321 03322 03323 03324 03325 03326 03327 03328 03329 03330 03331 03332 03333 03334 03335 03336 03337 03338 03339 03340 /******************************************** 03341 * 03342 * Various external API functions - for use in plugins etc. 03343 * 03344 *******************************************/ 03345 03346 03352 function getStorageSiterootPids() { 03353 $res=array(); 03354 reset($this->rootLine); 03355 while(list(,$rC)=each($this->rootLine)) { 03356 if (!$res['_STORAGE_PID']) $res['_STORAGE_PID']=intval($rC['storage_pid']); 03357 if (!$res['_SITEROOT']) $res['_SITEROOT']=$rC['is_siteroot']?intval($rC['uid']):0; 03358 } 03359 return $res; 03360 } 03361 03367 function getPagesTSconfig() { 03368 if (!is_array($this->pagesTSconfig)) { 03369 reset($this->rootLine); 03370 $TSdataArray = array(); 03371 $TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig']; // Setting default configuration: 03372 while(list($k,$v)=each($this->rootLine)) { 03373 $TSdataArray[]=$v['TSconfig']; 03374 } 03375 // Parsing the user TS (or getting from cache) 03376 $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray); 03377 $userTS = implode(chr(10).'[GLOBAL]'.chr(10),$TSdataArray); 03378 $hash = md5('pageTS:'.$userTS); 03379 $cachedContent = $this->sys_page->getHash($hash,0); 03380 if (isset($cachedContent)) { 03381 $this->pagesTSconfig = unserialize($cachedContent); 03382 } else { 03383 $parseObj = t3lib_div::makeInstance('t3lib_TSparser'); 03384 $parseObj->parse($userTS); 03385 $this->pagesTSconfig = $parseObj->setup; 03386 $this->sys_page->storeHash($hash,serialize($this->pagesTSconfig),'PAGES_TSconfig'); 03387 } 03388 } 03389 return $this->pagesTSconfig; 03390 } 03391 03400 function setJS($key,$content='') { 03401 if ($key) { 03402 switch($key) { 03403 case 'mouseOver': 03404 $this->additionalJavaScript[$key]= 03405 ' // JS function for mouse-over 03406 function over(name,imgObj) { // 03407 if (version == "n3" && document[name]) {document[name].src = eval(name+"_h.src");} 03408 else if (imgObj) {imgObj.src = eval(name+"_h.src");} 03409 } 03410 // JS function for mouse-out 03411 function out(name,imgObj) { // 03412 if (version == "n3" && document[name]) {document[name].src = eval(name+"_n.src");} 03413 else if (imgObj) {imgObj.src = eval(name+"_n.src");} 03414 }'; 03415 break; 03416 case 'openPic': 03417 $this->additionalJavaScript[$key]= 03418 ' function openPic(url,winName,winParams) { // 03419 var theWindow = window.open(url,winName,winParams); 03420 if (theWindow) {theWindow.focus();} 03421 }'; 03422 break; 03423 default: 03424 $this->additionalJavaScript[$key]=$content; 03425 break; 03426 } 03427 } 03428 } 03429 03438 function setCSS($key,$content) { 03439 if ($key) { 03440 switch($key) { 03441 default: 03442 $this->additionalCSS[$key]=$content; 03443 break; 03444 } 03445 } 03446 } 03447 03453 function make_seed() { 03454 list($usec, $sec) = explode(' ', microtime()); 03455 $seedV = (float)$sec + ((float)$usec * 100000); 03456 srand($seedV); 03457 } 03458 03466 function uniqueHash($str='') { 03467 return md5($this->uniqueString.'_'.$str.$this->uniqueCounter++); 03468 } 03469 03475 function set_no_cache() { 03476 $this->no_cache = 1; 03477 } 03478 03485 function set_cache_timeout_default($seconds) { 03486 $this->cacheTimeOutDefault = intval($seconds); 03487 } 03488 03501 function plainMailEncoded($email,$subject,$message,$headers='') { 03502 $urlmode=$this->config['config']['notification_email_urlmode']; // '76', 'all', '' 03503 03504 if ($urlmode) { 03505 $message=t3lib_div::substUrlsInPlainText($message,$urlmode); 03506 } 03507 03508 t3lib_div::plainMailEncoded( 03509 $email, 03510 $subject, 03511 $message, 03512 $headers, 03513 $this->config['config']['notification_email_encoding'], 03514 $this->config['config']['notification_email_charset']?$this->config['config']['notification_email_charset']:'ISO-8859-1' 03515 ); 03516 } 03517 03518 03519 03520 03521 03522 03523 03524 03525 03526 03527 03528 03529 03530 /********************************************* 03531 * 03532 * Localization and character set conversion 03533 * 03534 *********************************************/ 03535 03542 function sL($input) { 03543 if (strcmp(substr($input,0,4),'LLL:')) { 03544 $t = explode('|',$input); 03545 return $t[$this->langSplitIndex] ? $t[$this->langSplitIndex] : $t[0]; 03546 } else { 03547 if (!isset($this->LL_labels_cache[$this->lang][$input])) { // If cached label 03548 $restStr = trim(substr($input,4)); 03549 $extPrfx=''; 03550 if (!strcmp(substr($restStr,0,4),'EXT:')) { 03551 $restStr = trim(substr($restStr,4)); 03552 $extPrfx='EXT:'; 03553 } 03554 $parts = explode(':',$restStr); 03555 $parts[0]=$extPrfx.$parts[0]; 03556 if (!isset($this->LL_files_cache[$parts[0]])) { // Getting data if not cached 03557 $this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]); 03558 } 03559 $this->LL_labels_cache[$this->lang][$input] = $this->csConv($this->getLLL($parts[1],$this->LL_files_cache[$parts[0]])); 03560 } 03561 return $this->LL_labels_cache[$this->lang][$input]; 03562 } 03563 } 03564 03571 function readLLfile($fileRef) { 03572 return t3lib_div::readLLfile($fileRef,$this->lang); 03573 } 03574 03582 function getLLL($index,$LOCAL_LANG) { 03583 if (strcmp($LOCAL_LANG[$this->lang][$index],'')) { 03584 return $LOCAL_LANG[$this->lang][$index]; 03585 } else { 03586 return $LOCAL_LANG['default'][$index]; 03587 } 03588 } 03589 03596 function initLLvars() { 03597 03598 // Setting language key and split index: 03599 $this->lang = $this->config['config']['language'] ? $this->config['config']['language'] : 'default'; 03600 03601 $ls = explode('|',TYPO3_languages); 03602 while(list($i,$v)=each($ls)) { 03603 if ($v==$this->lang) {$this->langSplitIndex=$i; break;} 03604 } 03605 03606 // Setting charsets: 03607 $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. 03608 $this->metaCharset = $this->csConvObj->parse_charset($this->config['config']['metaCharset'] ? $this->config['config']['metaCharset'] : $this->renderCharset); // Output charset of HTML page. 03609 $this->labelsCharset = $this->csConvObj->parse_charset($this->csConvObj->charSetArray[$this->lang] ? $this->csConvObj->charSetArray[$this->lang] : 'iso-8859-1'); 03610 if ($this->renderCharset != $this->labelsCharset) { 03611 $this->convCharsetToFrom = array( 03612 'from' => $this->labelsCharset, 03613 'to' => $this->renderCharset 03614 ); 03615 } 03616 } 03617 03630 function csConv($str,$from='') { 03631 if ($from) { 03632 $output = $this->csConvObj->conv($str,$this->csConvObj->parse_charset($from),$this->renderCharset,1); 03633 return $output ? $output : $str; 03634 } elseif (is_array($this->convCharsetToFrom)) { 03635 return $this->csConvObj->conv($str,$this->convCharsetToFrom['from'],$this->convCharsetToFrom['to'],1); 03636 } else { 03637 return $str; 03638 } 03639 } 03640 03648 function convOutputCharset($content,$label='') { 03649 if ($this->renderCharset != $this->metaCharset) { 03650 $content = $this->csConvObj->conv($content,$this->renderCharset,$this->metaCharset,TRUE); 03651 } 03652 03653 return $content; 03654 } 03655 03661 function convPOSTCharset() { 03662 if ($this->renderCharset != $this->metaCharset && is_array($_POST) && count($_POST)) { 03663 $this->csConvObj->convArray($_POST,$this->metaCharset,$this->renderCharset); 03664 $GLOBALS['HTTP_POST_VARS'] = $_POST; 03665 } 03666 } 03667 } 03668 03669 03670 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']) { 03671 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']); 03672 } 03673 ?>