Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2004 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 ***************************************************************/ 00192 class tslib_fe { 00193 00194 // CURRENT PAGE: 00195 var $id=''; // The page id (int) 00196 var $type=''; // RO The type (int) 00197 var $idParts=array(); // Loaded with the id, exploded by ',' 00198 var $cHash=''; // The submitted cHash 00199 var $no_cache=''; // Page will not be cached. Write only true. Never clear value (some other code might have reasons to set it true) 00200 var $rootLine=''; // The rootLine (all the way to tree root, not only the current site!) (array) 00201 var $page=''; // The pagerecord (array) 00202 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. 00203 var $sys_page=''; // The object with pagefunctions (object) 00204 var $jumpurl=''; 00205 var $pageNotFound=0; // Is set to 1 if a pageNotFound handler could have been called. 00206 var $domainStartPage=0; // Domain start page 00207 var $MP=''; 00208 var $RDCT=''; 00209 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... 00210 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. 00211 00212 // USER 00213 var $fe_user=''; // The user (object) 00214 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. 00215 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... 00216 var $beUserLogin=''; // Flag that indicates if a Backend user is logged in! 00217 00218 // PREVIEW 00219 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. 00220 var $showHiddenPage=''; // Flag indicating that hidden pages should be shown, selected and so on. This goes for almost all selection of pages! 00221 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. 00222 var $simUserGroup='0'; // Value that contains the simulated usergroup if any 00223 var $versionPreviewMap=array(); // Versioning Preview record map (temporary, for sys_page) 00224 00225 // CONFIGURATION 00226 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. 00227 var $config=''; // 'CONFIG' object from TypoScript. Array generated based on the TypoScript configuration of the current page. Saved with the cached pages. 00228 var $TCAcachedExtras=array(); // Array of cached information from TCA. This is NOT TCA itself! 00229 00230 // TEMPLATE / CACHE 00231 var $tmpl=''; // The TypoScript template object. Used to parse the TypoScript template 00232 var $cacheTimeOutDefault=''; // Is set to the time-to-live time of cached pages. If false, default is 60*60*24, which is 24 hours. 00233 var $cacheContentFlag=''; // Set internally if cached content is fetched from the database 00234 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. 00235 var $sPre=''; // toplevel - objArrayName, eg 'page' 00236 var $pSetup=''; // TypoScript configuration of the page-object pointed to by sPre. $this->tmpl->setup[$this->sPre.'.'] 00237 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 00238 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 00239 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. 00240 var $tempContent=''; // This flag indicates if temporary content went into the cache during page-generation. 00241 var $forceTemplateParsing=''; // Boolean, passed to TypoScript template class and tells it to render the template forcibly 00242 var $cHash_array=array(); // The array which cHash_calc is based on, see ->makeCacheHash(). 00243 var $hash_base=''; // Loaded with the serialized array that is used for generating a hashstring for the cache 00244 var $pagesTSconfig=''; // May be set to the pagesTSconfig 00245 // PAGE-GENERATION / cOBJ 00246 /* 00247 Eg. insert JS-functions in this array ($additionalHeaderData) to include them once. Use associative keys. 00248 Keys in use: 00249 JSFormValidate : <script type="text/javascript" src="'.$GLOBALS["TSFE"]->absRefPrefix.'t3lib/jsfunc.validateform.js"></script> 00250 JSincludeFormupdate : <script type="text/javascript" src="t3lib/jsfunc.updateform.js"></script> 00251 JSMenuCode, JSMenuCode_menu : JavaScript for the JavaScript menu 00252 JSCode : reserved 00253 JSImgCode : reserved 00254 */ 00255 var $defaultBodyTag='<body bgcolor="#FFFFFF">'; // Default bodytag, if nothing else is set. This can be overridden by applications like TemplaVoila. 00256 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[] = '...') 00257 var $additionalJavaScript=array(); // used to accumulate additional JavaScript-code. Works like additionalHeaderData. Reserved keys at 'openPic' and 'mouseOver' 00258 var $additionalCSS=array(); // used to accumulate additional Style code. Works like additionalHeaderData. 00259 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 00260 'onmousemove' => array(), 00261 'onmouseup' => array(), 00262 'onload' => array(), 00263 ); 00264 var $JSCode=''; // Depreciated, use additionalJavaScript instead. 00265 var $JSImgCode=''; // Used to accumulate JavaScript loaded images (by menus) 00266 var $divSection=''; // Used to accumulate DHTML-layers. 00267 00268 // RENDERING configuration, settings from TypoScript is loaded into these vars. See pagegen.php 00269 var $debug=''; // Debug flag, may output special debug html-code. 00270 var $intTarget=''; // Default internal target 00271 var $extTarget=''; // Default external target 00272 var $MP_defaults=array(); // Keys are page ids and values are default &MP (mount point) values to set when using the linking features...) 00273 var $spamProtectEmailAddresses=0; // If set, typolink() function encrypts email addresses. Is set in pagegen-class. 00274 var $absRefPrefix=''; // Absolute Reference prefix 00275 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 '/' 00276 var $compensateFieldWidth=''; // Factor for form-field widths compensation 00277 var $lockFilePath=''; // Lock file path 00278 var $ATagParams=''; // <A>-tag parameters 00279 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. 00280 var $sWordList=''; // Is set to the incoming array sword_list in case of a page-view jumped to from a search-result. 00281 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. 00282 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. 00283 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. 00284 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. 00285 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! 00286 var $sys_language_mode=''; // Site language mode 00287 var $sys_language_content=0; // Site content selection uid 00288 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...] 00289 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") 00290 00291 // RENDERING data 00292 var $applicationData=Array(); // 'Global' Storage for various applications. Keys should be 'tx_'.extKey for extensions. 00293 var $register=Array(); 00294 var $registerStack=Array(); // Stack used for storing array and retrieving register arrays (see LOAD_REGISTER and CLEAR_REGISTER) 00295 var $cObjectDepthCounter = 50; // Checking that the function is not called eternally. This is done by interrupting at a depth of 50 00296 var $recordRegister = Array(); // used by cObj->RECORDS and cObj->CONTENT to ensure the a records is NOT rendered twice through it! 00297 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 00298 var $accessKey =array(); // Used by class tslib_menu to keep track of access-keys. 00299 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. 00300 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 00301 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() 00302 var $uniqueString=''; 00303 var $indexedDocTitle=''; // This value will be used as the title for the page in the indexer (if indexing happens) 00304 var $altPageTitle=''; // Alternative page title (normally the title of the page record). Can be set from applications you make. 00305 var $pEncAllowedParamNames=array(); // An array that holds parameter names (keys) of GET parameters which MAY be MD5/base64 encoded with simulate_static_documents method. 00306 var $baseUrl=''; // The Base url set for the page header. 00307 var $anchorPrefix=''; // The proper anchor prefix needed when using speaking urls. (only set if baseUrl is set) 00308 00309 // Page content render object 00310 var $cObj =''; // is instantiated object of tslib_cObj 00311 00312 // CONTENT accumulation 00313 var $content=''; // All page content is accumulated in this variable. See pagegen.php 00314 00315 // GENERAL 00316 var $clientInfo=''; // Set to the browser: net / msie if 4+ browsers 00317 var $scriptParseTime=0; 00318 var $TCAloaded = 0; // Set ONLY if the full TCA is loaded 00319 00320 // Character set (charset) conversion object: 00321 var $csConvObj; // An instance of the "t3lib_cs" class. May be used by any application. 00322 var $defaultCharSet = 'iso-8859-1'; // The default charset used in the frontend if nothing else is set. 00323 var $renderCharset=''; // Internal charset of the frontend during rendering: Defaults to "forceCharset" and if that is not set, to ->defaultCharSet 00324 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. 00325 var $localeCharset=''; // Assumed charset of locale strings. 00326 00327 // LANG: 00328 var $lang=''; // Set to the system language key (used on the site) 00329 var $langSplitIndex=0; // Set to the index number of the language key 00330 var $labelsCharset=''; // Charset of the labels from locallang (based on $this->lang) 00331 var $convCharsetToFrom=''; // Set to the charsets to convert from/to IF there are any difference. Otherwise this stays a string 00332 var $LL_labels_cache=array(); 00333 var $LL_files_cache=array(); 00334 00335 00336 00337 00338 00356 function tslib_fe($TYPO3_CONF_VARS, $id, $type, $no_cache='', $cHash='', $jumpurl='',$MP='',$RDCT='') { 00357 00358 // Setting some variables: 00359 $this->TYPO3_CONF_VARS = $TYPO3_CONF_VARS; 00360 $this->id = $id; 00361 $this->type = $type; 00362 $this->no_cache = $no_cache ? 1 : 0; 00363 $this->cHash = $cHash; 00364 $this->jumpurl = $jumpurl; 00365 $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? $MP : ''; 00366 $this->RDCT = $RDCT; 00367 $this->clientInfo = t3lib_div::clientInfo(); 00368 $this->uniqueString=md5(microtime()); 00369 00370 $this->csConvObj = t3lib_div::makeInstance('t3lib_cs'); 00371 00372 // Call post processing function for constructor: 00373 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'])) { 00374 $_params = array('pObj' => &$this); 00375 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef) { 00376 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00377 } 00378 } 00379 } 00380 00387 function connectToMySQL() { 00388 if ($GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { 00389 if (!TYPO3_db) { 00390 $this->printError('No database selected','Database Error'); 00391 // Redirects to the Install Tool: 00392 echo '<script type="text/javascript"> 00393 /*<![CDATA[*/ 00394 document.location = "'.TYPO3_mainDir.'install/index.php?mode=123&step=1&password=joh316"; 00395 /*]]>*/ 00396 </script>'; 00397 exit; 00398 } elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) { 00399 $this->printError('Cannot connect to the current database, "'.TYPO3_db.'"','Database Error'); 00400 exit; 00401 } 00402 } else { 00403 if (!TYPO3_db) { 00404 // Redirects to the Install Tool: 00405 echo '<script type="text/javascript"> 00406 /*<![CDATA[*/ 00407 document.location = "'.TYPO3_mainDir.'install/index.php?mode=123&step=1&password=joh316"; 00408 /*]]>*/ 00409 </script>'; 00410 exit; 00411 } 00412 $this->printError('The current username, password or host was not accepted when the connection to the database was attempted to be established!','Database Error'); 00413 exit; 00414 } 00415 } 00416 00423 function sendRedirect() { 00424 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash="'.$GLOBALS['TYPO3_DB']->quoteStr($this->RDCT, 'cache_md5params').'"'); 00425 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00426 $this->updateMD5paramsRecord($this->RDCT); 00427 header('Location: '.$row['params']); 00428 exit; 00429 } 00430 } 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 /******************************************** 00450 * 00451 * Initializing, resolving page id 00452 * 00453 ********************************************/ 00454 00455 00461 function initFEuser() { 00462 $this->fe_user = t3lib_div::makeInstance('tslib_feUserAuth'); 00463 00464 $this->fe_user->lockIP = $this->TYPO3_CONF_VARS['FE']['lockIP']; 00465 $this->fe_user->lockHashKeyWords = $this->TYPO3_CONF_VARS['FE']['lockHashKeyWords']; 00466 $this->fe_user->checkPid = $this->TYPO3_CONF_VARS['FE']['checkFeUserPid']; 00467 $this->fe_user->checkPid_value = $GLOBALS['TYPO3_DB']->cleanIntList(t3lib_div::_GP('pid')); // List of pid's acceptable 00468 00469 // Check if a session is transferred: 00470 if (t3lib_div::_GP('FE_SESSION_KEY')) { 00471 $fe_sParts = explode('-',t3lib_div::_GP('FE_SESSION_KEY')); 00472 if (!strcmp(md5($fe_sParts[0].'/'.$this->TYPO3_CONF_VARS['SYS']['encryptionKey']), $fe_sParts[1])) { // If the session key hash check is OK: 00473 $_COOKIE[$this->fe_user->name]=$fe_sParts[0]; 00474 $this->fe_user->forceSetCookie=1; 00475 } 00476 } 00477 00478 if ($this->TYPO3_CONF_VARS['FE']['dontSetCookie']) { 00479 $this->fe_user->dontSetCookie=1; 00480 } 00481 00482 $this->fe_user->start(); 00483 $this->fe_user->unpack_uc(''); 00484 $this->fe_user->fetchSessionData(); // Gets session data 00485 $recs = t3lib_div::_GP('recs'); 00486 if (is_array($recs)) { // If any record registration is submitted, register the record. 00487 $this->fe_user->record_registration($recs); 00488 } 00489 00490 // For every 60 seconds the is_online timestamp is updated. 00491 if (is_array($this->fe_user->user) && $this->fe_user->user['is_online']<($GLOBALS['EXEC_TIME']-60)) { 00492 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid='.intval($this->fe_user->user['uid']), array('is_online' => $GLOBALS['EXEC_TIME'])); 00493 } 00494 } 00495 00501 function initUserGroups() { 00502 // Sets ->loginUser and ->gr_list based on front-end user status. 00503 $this->fe_user->showHiddenRecords = $this->showHiddenRecords; // This affects the hidden-flag selecting the fe_groups for the user! 00504 // if (is_array($this->fe_user->user) && $this->fe_user->fetchGroupData()) { 00505 $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. 00506 if (is_array($this->fe_user->user) && count($this->fe_user->groupData['uid'])) { 00507 $this->loginUser=1; // global flag! 00508 $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! 00509 $gr_array = $this->fe_user->groupData['uid']; 00510 } else { 00511 $this->loginUser=0; 00512 $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! 00513 $gr_array = $this->fe_user->groupData['uid']; 00514 } 00515 00516 // TYPO3_CONF_VARS']['FE']['IPmaskMountGroups'] moved to sysext/sv/class.tx_sv_auth.php service 00517 00518 // Clean up. 00519 $gr_array = array_unique($gr_array); // Make unique... 00520 sort($gr_array); // sort 00521 if (count($gr_array)) { 00522 $this->gr_list.=','.implode(',',$gr_array); 00523 } 00524 00525 if ($this->fe_user->writeDevLog) t3lib_div::devLog('Valid usergroups for TSFE: '.$this->gr_list, 'tslib_fe'); 00526 } 00527 00528 00549 function checkAlternativeIdMethods() { 00550 00551 $this->siteScript = t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT'); 00552 00553 // Resolving of "simulateStaticDocuments" URLs: 00554 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 00555 $uParts = parse_url($this->siteScript); // Parse the path: 00556 $fI = t3lib_div::split_fileref($uParts['path']); 00557 00558 if (!$fI['path'] && $fI['file'] && substr($fI['file'],-5)=='.html') { 00559 $parts = explode('.',$fI['file']); 00560 $pCount = count($parts); 00561 if ($pCount>2) { 00562 $this->type = intval($parts[$pCount-2]); 00563 $this->id = $parts[$pCount-3]; 00564 } else { 00565 $this->type = 0; 00566 $this->id = $parts[0]; 00567 } 00568 } 00569 } 00570 00571 // If PATH_INFO 00572 if (t3lib_div::getIndpEnv('PATH_INFO')) { // If pathinfo contains stuff... 00573 $parts=t3lib_div::trimExplode('/',t3lib_div::getIndpEnv('PATH_INFO'),1); 00574 $parts[]='html'; 00575 $pCount = count($parts); 00576 if ($pCount>2) { 00577 $this->type = intval($parts[$pCount-2]); 00578 $this->id = $parts[$pCount-3]; 00579 } else { 00580 $this->type = 0; 00581 $this->id = $parts[0]; 00582 } 00583 $this->absRefPrefix_force=1; 00584 } 00585 00586 // Call post processing function for custom URL methods. 00587 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'])) { 00588 $_params = array('pObj' => &$this); 00589 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef) { 00590 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00591 } 00592 } 00593 } 00594 00601 function clear_preview() { 00602 $this->showHiddenPage = 0; 00603 $this->showHiddenRecords = 0; 00604 $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME']; 00605 $this->fePreview = 0; 00606 } 00607 00614 function determineId() { 00615 00616 // Getting ARG-v values if some 00617 $this->setIDfromArgV(); 00618 00619 // If there is a Backend login we are going to check for any preview settings: 00620 $GLOBALS['TT']->push('beUserLogin',''); 00621 if ($this->beUserLogin) { 00622 $this->fePreview = $GLOBALS['BE_USER']->extGetFeAdminValue('preview'); 00623 00624 // If admin panel preview is enabled... 00625 if ($this->fePreview) { 00626 $fe_user_OLD_USERGROUP = $this->fe_user->user['usergroup']; 00627 00628 $this->showHiddenPage = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenPages'); 00629 $this->showHiddenRecords = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenRecords'); 00630 // simulate date 00631 $simTime = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateDate'); 00632 if ($simTime) $GLOBALS['SIM_EXEC_TIME']=$simTime; 00633 // simulate user 00634 $simUserGroup = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateUserGroup'); 00635 $this->simUserGroup = $simUserGroup; 00636 if ($simUserGroup) $this->fe_user->user['usergroup']=$simUserGroup; 00637 if (!$simUserGroup && !$simTime && !$this->showHiddenPage && !$this->showHiddenRecords) { 00638 $this->fePreview=0; 00639 } 00640 } 00641 00642 // Now it's investigated if the raw page-id points to a hidden page and if so, the flag is set. 00643 // This does not require the preview flag to be set in the admin panel 00644 if ($this->id) { 00645 $idQ = t3lib_div::testInt($this->id) ? 'uid="'.intval($this->id).'"' : 'alias="'.$GLOBALS['TYPO3_DB']->quoteStr($this->id, 'pages').'" AND pid>=0'; // pid>=0 added for the sake of versioning... 00646 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('hidden', 'pages', $idQ.' AND hidden AND NOT deleted'); 00647 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 00648 $this->fePreview = 1; // The preview flag is set only if the current page turns out to actually be hidden! 00649 $this->showHiddenPage = 1; 00650 } 00651 00652 // Check root line for proper connection to tree root (done because of possible preview of page / branch versions) 00653 if (!$this->fePreview) { 00654 00655 // Initialize the page-select functions to check rootline: 00656 $temp_sys_page = t3lib_div::makeInstance('t3lib_pageSelect'); 00657 $temp_sys_page->init($this->showHiddenPage); 00658 00659 // If root line contained NO records and ->error_getRootLine_failPid tells us that it was because of a pid=-1 (indicating a "version" record)...: 00660 if (!count($temp_sys_page->getRootLine($this->id,$this->MP)) && $temp_sys_page->error_getRootLine_failPid==-1) { 00661 00662 // Setting versioningPreview flag and try again: 00663 $temp_sys_page->versioningPreview = TRUE; 00664 if (count($temp_sys_page->getRootLine($this->id,$this->MP))) { 00665 // 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. 00666 $this->fePreview = 1; 00667 #debug('version in rootline...'); 00668 } 00669 } 00670 } 00671 } 00672 00673 // Checking for specific version preview of records: 00674 if (is_array(t3lib_div::_GP('ADMCMD_vPrev'))) { 00675 $this->fePreview = 1; 00676 $this->versionPreviewMap = t3lib_div::_GP('ADMCMD_vPrev'); 00677 } 00678 00679 if ($this->fePreview) { // If the front-end is showing a preview, caching MUST be disabled. 00680 $this->set_no_cache(); 00681 } 00682 } 00683 $GLOBALS['TT']->pull(); 00684 00685 // Now, get the id, validate access etc: 00686 $this->fetch_the_id(); 00687 00688 // Check if backend user has read access to this page. If not, recalculate the id. 00689 if ($this->beUserLogin && $this->fePreview) { 00690 if (!$GLOBALS['BE_USER']->doesUserHaveAccess($this->page,1)) { 00691 // Resetting 00692 $this->clear_preview(); 00693 $this->fe_user->user['usergroup'] = $fe_user_OLD_USERGROUP; 00694 // Fetching the id again, now with the preview settings reset. 00695 $this->fetch_the_id(); 00696 } 00697 } 00698 // Final cleaning. 00699 $this->id = $this->contentPid = intval($this->id); // Make sure it's an integer 00700 $this->type = intval($this->type); // Make sure it's an integer 00701 00702 00703 // Call post processing function for id determination: 00704 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) { 00705 $_params = array('pObj' => &$this); 00706 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef) { 00707 t3lib_div::callUserFunction($_funcRef,$_params,$this); 00708 } 00709 } 00710 } 00711 00720 function fetch_the_id() { 00721 $GLOBALS['TT']->push('fetch_the_id initialize/',''); 00722 00723 // Initialize the page-select functions. 00724 $this->sys_page = t3lib_div::makeInstance('t3lib_pageSelect'); 00725 $this->sys_page->init($this->showHiddenPage); 00726 $this->sys_page->versioningPreview = $this->fePreview ? TRUE : FALSE; 00727 if ($this->sys_page->versioningPreview) { 00728 $this->sys_page->versionPreviewMap = $this->versionPreviewMap; 00729 #debug($this->sys_page->versionPreviewMap); 00730 } 00731 00732 // Set the valid usergroups for FE 00733 $this->initUserGroups(); 00734 00735 // Sets sys_page where-clause 00736 $this->setSysPageWhereClause(); 00737 00738 // Splitting $this->id by a period (.). First part is 'id' and second part - if exists - will overrule the &type param if given 00739 $pParts = explode('.',$this->id); 00740 $this->id = $pParts[0]; // Set it. 00741 if (isset($pParts[1])) {$this->type=$pParts[1];} 00742 00743 // Splitting $this->id by a comma (,). First part is 'id' and other parts are just stored for use in scripts. 00744 $this->idParts = explode(',',$this->id); 00745 00746 // Splitting by a '+' sign - used for base64/md5 methods of parameter encryption for simulate static documents. 00747 list($pgID,$SSD_p)=explode('+',$this->idParts[0],2); 00748 if ($SSD_p) { $this->idPartsAnalyze($SSD_p); } 00749 $this->id = $pgID; // Set id 00750 00751 // If $this->id is a string, it's an alias 00752 $this->checkAndSetAlias(); 00753 00754 // The id and type is set to the integer-value - just to be sure... 00755 $this->id = intval($this->id); 00756 $this->type = intval($this->type); 00757 $GLOBALS['TT']->pull(); 00758 00759 // We find the first page belonging to the current domain 00760 $GLOBALS['TT']->push('fetch_the_id domain/',''); 00761 $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']); // the page_id of the current domain 00762 if (!$this->id) { 00763 if ($this->domainStartPage) { 00764 $this->id = $this->domainStartPage; // If the id was not previously set, set it to the id of the domain. 00765 } else { 00766 $theFirstPage = $this->sys_page->getFirstWebPage($this->id); // Find the first 'visible' page in that domain 00767 if ($theFirstPage) { 00768 $this->id = $theFirstPage['uid']; 00769 } else { 00770 $this->printError('No pages are found on the rootlevel!'); 00771 exit; 00772 } 00773 } 00774 } 00775 $GLOBALS['TT']->pull(); 00776 00777 $GLOBALS['TT']->push('fetch_the_id rootLine/',''); 00778 $requestedId = $this->id; // We store the originally requested id 00779 $this->getPageAndRootlineWithDomain($this->domainStartPage); 00780 $GLOBALS['TT']->pull(); 00781 00782 if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) { 00783 $pNotFoundMsg = array( 00784 1 => 'ID was not an accessible page', 00785 2 => 'Subsection was found and not accessible', 00786 3 => 'ID was outside the domain', 00787 ); 00788 $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]); 00789 } 00790 00791 // set no_cache if set 00792 if ($this->page['no_cache']) { 00793 $this->set_no_cache(); 00794 } 00795 // Init SYS_LASTCHANGED 00796 $this->register['SYS_LASTCHANGED'] = intval($this->page['tstamp']); 00797 } 00798 00812 function getPageAndRootline() { 00813 $this->page = $this->sys_page->getPage($this->id); 00814 if (!count($this->page)) { 00815 // If no page, we try to find the page before in the rootLine. 00816 $this->pageNotFound=1; // Page is 'not found' in case the id itself was not an accessible page. code 1 00817 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP); 00818 if (count($this->rootLine)) { 00819 $c=count($this->rootLine)-1; 00820 while($c>0) { 00821 $c--; 00822 $this->id=$this->rootLine[$c]['uid']; 00823 $this->page = $this->sys_page->getPage($this->id); 00824 if (count($this->page)){break;} 00825 } 00826 } 00827 // If still no page... 00828 if (!count($this->page)) { 00829 if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) { 00830 $this->pageNotFoundAndExit('The requested page does not exist!'); 00831 } else { 00832 $this->printError('The requested page does not exist!'); 00833 exit; 00834 } 00835 } 00836 } 00837 // Is the ID a link to another page?? 00838 if ($this->page['doktype']==4) { 00839 $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. 00840 $this->page = $this->getPageShortcut($this->page['shortcut'],$this->page['shortcut_mode'],$this->page['uid']); 00841 $this->id = $this->page['uid']; 00842 } 00843 // Gets the rootLine 00844 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP); 00845 00846 // If not rootline we're off... 00847 if (!count($this->rootLine)) { 00848 $this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')'); 00849 exit; 00850 } 00851 00852 // Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!) 00853 if ($this->checkRootlineForIncludeSection()) { 00854 if (!count($this->rootLine)) { 00855 $this->printError('The requested page was not accessible!'); 00856 exit; 00857 } else { 00858 $el = reset($this->rootLine); 00859 $this->id = $el['uid']; 00860 $this->page = $this->sys_page->getPage($this->id); 00861 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP); 00862 } 00863 } 00864 } 00865 00878 function getPageShortcut($SC,$mode,$thisUid,$itera=20,$pageLog=array()) { 00879 $idArray = t3lib_div::intExplode(',',$SC); 00880 00881 // Find $page record depending on shortcut mode: 00882 switch($mode) { 00883 case 1: 00884 case 2: 00885 $pageArray = $this->sys_page->getMenu($idArray[0]?$idArray[0]:$thisUid,'*','sorting','AND pages.doktype<199 AND pages.doktype!=6'); 00886 $pO = 0; 00887 if ($mode==2 && count($pageArray)) { // random 00888 $this->make_seed(); 00889 $randval = intval(rand(0,count($pageArray)-1)); 00890 $pO = $randval; 00891 } 00892 $c = 0; 00893 reset($pageArray); 00894 while(list(,$pV)=each($pageArray)) { 00895 if ($c==$pO) { 00896 $page = $pV; 00897 break; 00898 } 00899 $c++; 00900 } 00901 break; 00902 default: 00903 $page = $this->sys_page->getPage($idArray[0]); 00904 break; 00905 } 00906 00907 // Check if short cut page was a shortcut itself, if so look up recursively: 00908 if ($page['doktype']==4) { 00909 if (!in_array($page['uid'],$pageLog) && $itera>0) { 00910 $pageLog[] = $page['uid']; 00911 $page = $this->getPageShortcut($page['shortcut'],$page['shortcut_mode'],$page['uid'],$itera-1,$pageLog); 00912 } else { 00913 $pageLog[] = $page['uid']; 00914 $this->printError('Page shortcuts were looping in uids '.implode(',',$pageLog).'...!'); 00915 exit; 00916 } 00917 } 00918 // Return resulting page: 00919 return $page; 00920 } 00921 00928 function checkRootlineForIncludeSection() { 00929 $c=count($this->rootLine); 00930 $removeTheRestFlag=0; 00931 for ($a=0;$a<$c;$a++) { 00932 if (!$this->checkPagerecordForIncludeSection($this->rootLine[$a])) { 00933 $removeTheRestFlag=1; 00934 } 00935 if ($this->rootLine[$a]['doktype']==6) { 00936 if ($this->beUserLogin) { // If there is a backend user logged in, check if he has read access to the page: 00937 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($this->id).' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1)); 00938 list($isPage) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 00939 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... 00940 } else { // Dont go here, if there is no backend user logged in. 00941 $removeTheRestFlag=1; 00942 } 00943 } 00944 if ($removeTheRestFlag) { 00945 $this->pageNotFound=2; // Page is 'not found' in case a subsection was found and not accessible, code 2 00946 unset($this->rootLine[$a]); 00947 } 00948 } 00949 return $removeTheRestFlag; 00950 } 00951 00961 function checkEnableFields($row) { 00962 if ((!$row['hidden'] || $this->showHiddenPage) 00963 && $row['starttime']<=$GLOBALS['SIM_EXEC_TIME'] 00964 && ($row['endtime']==0 || $row['endtime']>$GLOBALS['SIM_EXEC_TIME']) 00965 && $this->checkPageGroupAccess($row) 00966 ) { 00967 return 1; 00968 } 00969 } 00970 00979 function checkPageGroupAccess($row, $groupList=NULL) { 00980 if(is_null($groupList)) { 00981 $groupList = $this->gr_list; 00982 } 00983 if(!is_array($groupList)) { 00984 $groupList = explode(',', $groupList); 00985 } 00986 $pageGroupList = explode(',', $row['fe_group']); 00987 return count(array_intersect($groupList, $pageGroupList)) > 0; 00988 } 00989 00998 function checkPagerecordForIncludeSection($row) { 00999 return (!$row['extendToSubpages'] || $this->checkEnableFields($row)) ? 1 : 0; 01000 } 01001 01010 function setIDfromArgV() { 01011 if (!$this->id) { 01012 list($theAlias) = explode('&',t3lib_div::getIndpEnv('QUERY_STRING')); 01013 $theAlias = trim($theAlias); 01014 $this->id = $theAlias ? $theAlias : 0; 01015 } 01016 } 01017 01026 function getPageAndRootlineWithDomain($domainStartPage) { 01027 $this->getPageAndRootline(); 01028 01029 // 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. 01030 if ($domainStartPage && is_array($this->rootLine)) { 01031 reset ($this->rootLine); 01032 $idFound = 0; 01033 while(list($key,$val)=each($this->rootLine)) { 01034 if ($val['uid']==$domainStartPage) { 01035 $idFound=1; 01036 break; 01037 } 01038 } 01039 if (!$idFound) { 01040 $this->pageNotFound=3; // Page is 'not found' in case the id was outside the domain, code 3 01041 $this->id = $domainStartPage; 01042 $this->getPageAndRootline(); //re-get the page and rootline if the id was not found. 01043 } 01044 } 01045 } 01046 01053 function setSysPageWhereClause() { 01054 $this->sys_page->where_hid_del.=' AND doktype<200'.$this->getPagesGroupClause(); 01055 } 01056 01063 function getPagesGroupClause() { 01064 return ' AND fe_group IN ('.$this->gr_list.')'; 01065 } 01066 01074 function findDomainRecord($recursive=0) { 01075 if ($recursive) { 01076 $host = explode('.',t3lib_div::getIndpEnv('HTTP_HOST')); 01077 while(count($host)) { 01078 $pageUid = $this->sys_page->getDomainStartPage(implode('.',$host),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI')); 01079 if ($pageUid) return $pageUid; else array_shift($host); 01080 } 01081 return $pageUid; 01082 } else { 01083 return $this->sys_page->getDomainStartPage(t3lib_div::getIndpEnv('HTTP_HOST'),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI')); 01084 } 01085 } 01086 01093 function pageNotFoundAndExit($reason='') { 01094 $this->pageNotFoundHandler($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'], $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'], $reason); 01095 exit; 01096 } 01097 01107 function pageNotFoundHandler($code, $header='', $reason='') { 01108 // Issue header in any case: 01109 if ($header) {header($header);} 01110 01111 // Create response: 01112 if (gettype($code)=='boolean' || !strcmp($code,1)) { 01113 $this->printError('The page did not exist or was inaccessible.'.($reason ? ' Reason: '.htmlspecialchars($reason) : '')); 01114 exit; 01115 } elseif (t3lib_div::testInt($code)) { 01116 $this->printError('Error '.$code.($reason ? ' Reason: '.htmlspecialchars($reason) : '')); 01117 exit; 01118 } elseif (t3lib_div::isFirstPartOfStr($code,'READFILE:')) { 01119 $readFile = t3lib_div::getFileAbsFileName(trim(substr($code,9))); 01120 if (@is_file($readFile)) { 01121 $fileContent = t3lib_div::getUrl($readFile); 01122 $fileContent = str_replace('###CURRENT_URL###', t3lib_div::getIndpEnv('REQUEST_URI'), $fileContent); 01123 $fileContent = str_replace('###REASON###', htmlspecialchars($reason), $fileContent); 01124 echo $fileContent; 01125 } else { 01126 $this->printError('Configuration Error: 404 page "'.$readFile.'" could not be found.'); 01127 } 01128 exit; 01129 } elseif (strlen($code)) { 01130 header('Location: '.t3lib_div::locationHeaderUrl($code)); 01131 exit; 01132 } else { 01133 $this->printError('Error.'.($reason ? ' Reason: '.htmlspecialchars($reason) : '')); 01134 exit; 01135 } 01136 } 01137 01145 function checkAndSetAlias() { 01146 if ($this->id && !t3lib_div::testInt($this->id)) { 01147 $aid = $this->sys_page->getPageIdFromAlias($this->id); 01148 if ($aid) {$this->id=$aid;} 01149 } 01150 } 01151 01160 function idPartsAnalyze($str) { 01161 $GET_VARS = ''; 01162 switch(substr($str,0,2)) { 01163 case 'B6': 01164 $addParams = base64_decode(str_replace('_','=',str_replace('-','/',substr($str,2)))); 01165 parse_str($addParams,$GET_VARS); 01166 break; 01167 case 'M5': 01168 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash="'.$GLOBALS['TYPO3_DB']->quoteStr(substr($str,2), 'cache_md5params').'"'); 01169 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 01170 01171 $this->updateMD5paramsRecord(substr($str,2)); 01172 parse_str($row['params'],$GET_VARS); 01173 break; 01174 } 01175 01176 $this->mergingWithGetVars($GET_VARS); 01177 } 01178 01185 function mergingWithGetVars($GET_VARS) { 01186 if (is_array($GET_VARS)) { 01187 $realGet = t3lib_div::_GET(); // Getting $_GET var, unescaped. 01188 if (!is_array($realGet)) $realGet = array(); 01189 01190 // Merge new values on top: 01191 $realGet = t3lib_div::array_merge_recursive_overrule($realGet,$GET_VARS); 01192 01193 // Write values back to $_GET: 01194 t3lib_div::_GETset($realGet); 01195 01196 // Setting these specifically (like in the init-function): 01197 if (isset($GET_VARS['type'])) $this->type = intval($GET_VARS['type']); 01198 if (isset($GET_VARS['cHash'])) $this->cHash = $GET_VARS['cHash']; 01199 if (isset($GET_VARS['jumpurl'])) $this->jumpurl = $GET_VARS['jumpurl']; 01200 if (isset($GET_VARS['MP'])) $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? $GET_VARS['MP'] : ''; 01201 01202 if (isset($GET_VARS['no_cache']) && $GET_VARS['no_cache']) $this->set_no_cache(); 01203 } 01204 } 01205 01206 01207 01208 01209 01210 01211 01212 01213 01214 01215 01216 01217 01218 01219 01220 01221 01222 /******************************************** 01223 * 01224 * Template and caching related functions. 01225 * 01226 *******************************************/ 01227 01233 function makeCacheHash() { 01234 $GET = t3lib_div::_GET(); 01235 if ($this->cHash && is_array($GET)) { 01236 $pA = $this->cHashParams(t3lib_div::implodeArrayForUrl('',$GET)); 01237 $this->cHash_array = $pA; 01238 $cHash_calc = t3lib_div::shortMD5(serialize($this->cHash_array)); 01239 #debug(array($cHash_calc,$this->cHash,$pA)); 01240 if ($cHash_calc!=$this->cHash) { 01241 $this->set_no_cache(); 01242 $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($pA)).'"',2); 01243 } 01244 } 01245 } 01246 01256 function cHashParams($addQueryParams) { 01257 $params = explode('&',substr($addQueryParams,1)); // Splitting parameters up 01258 01259 // Make array: 01260 $pA = array(); 01261 foreach($params as $theP) { 01262 $pKV = explode('=', $theP); // SPlitting single param by '=' sign 01263 if (!t3lib_div::inList('id,type,no_cache,cHash,MP,ftu',$pKV[0])) { 01264 $pA[$pKV[0]] = (string)rawurldecode($pKV[1]); 01265 } 01266 } 01267 $pA['encryptionKey'] = $this->TYPO3_CONF_VARS['SYS']['encryptionKey']; 01268 ksort($pA); 01269 return $pA; 01270 } 01271 01277 function initTemplate() { 01278 $this->tmpl = t3lib_div::makeInstance('t3lib_TStemplate'); 01279 $this->tmpl->init(); 01280 $this->tmpl->tt_track= $this->beUserLogin ? 1 : 0; 01281 } 01282 01289 function getFromCache() { 01290 $this->tmpl->getCurrentPageData(); 01291 $cc = Array(); 01292 if (is_array($this->tmpl->currentPageData)) { 01293 // 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. 01294 // If this hash is not the same in here in this section and after page-generation the page will not be properly cached! 01295 01296 $cc['all'] = $this->tmpl->currentPageData['all']; 01297 $cc['rowSum'] = $this->tmpl->currentPageData['rowSum']; 01298 $cc['rootLine'] = $this->tmpl->currentPageData['rootLine']; // This rootline is used with templates only (matching()-function) 01299 $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. 01300 ksort($this->all); 01301 } 01302 01303 $this->content=''; // clearing the content-variable, which will hold the pagecontent 01304 unset($this->config); // Unsetting the lowlevel config 01305 $this->cacheContentFlag=0; 01306 if ($this->all && !$this->no_cache) { 01307 $this->newHash = $this->getHash(); 01308 01309 $GLOBALS['TT']->push('Cache Query',''); 01310 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 01311 'S.*', 01312 'cache_pages AS S,pages AS P', 01313 'S.hash="'.$GLOBALS['TYPO3_DB']->quoteStr($this->newHash, 'cache_pages').'" 01314 AND S.page_id=P.uid 01315 AND S.expires > '.intval($GLOBALS['EXEC_TIME']).' 01316 AND NOT P.deleted 01317 AND NOT P.hidden 01318 AND P.starttime<='.intval($GLOBALS['EXEC_TIME']).' 01319 AND (P.endtime=0 OR P.endtime>'.intval($GLOBALS['EXEC_TIME']).')' 01320 ); 01321 $GLOBALS['TT']->pull(); 01322 $GLOBALS['TT']->push('Cache Row',''); 01323 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01324 $this->config = unserialize($row['cache_data']); // Fetches the lowlevel config stored with the cached data 01325 $this->content = $row['HTML']; // Getting the content 01326 $this->cacheContentFlag=1; // Setting flag, so we know, that some cached content is gotten. 01327 01328 if ($this->TYPO3_CONF_VARS['FE']['debug'] || $this->config['config']['debug']) { 01329 $this->content.=chr(10).'<!-- Cached page generated '.Date('d/m Y H:i', $row['tstamp']).'. Expires '.Date('d/m Y H:i', $row['expires']).' -->'; 01330 } 01331 } 01332 $GLOBALS['TT']->pull(); 01333 01334 $GLOBALS['TYPO3_DB']->sql_free_result($res); 01335 } 01336 } 01337 01347 function getHash() { 01348 $this->hash_base = serialize( 01349 array( 01350 'all' => $this->all, 01351 'id' => intval($this->id), 01352 'type' => intval($this->type), 01353 'gr_list' => $this->gr_list, 01354 'MP' => $this->MP, 01355 'cHash' => $this->cHash_array 01356 ) 01357 ); 01358 01359 return md5($this->hash_base); 01360 } 01361 01367 function getConfigArray() { 01368 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 01369 $GLOBALS['TT']->push('Parse template',''); 01370 01371 // Force parsing, if set?: 01372 $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing; 01373 01374 // Start parsing the TS template. Might return cached version. 01375 $this->tmpl->start($this->rootLine); 01376 $GLOBALS['TT']->pull(); 01377 01378 if ($this->tmpl->loaded) { 01379 $GLOBALS['TT']->push('Setting the config-array',''); 01380 // t3lib_div::print_array($this->tmpl->setup); 01381 $this->sPre = $this->tmpl->setup['types.'][$this->type]; // toplevel - objArrayName 01382 $this->pSetup = $this->tmpl->setup[$this->sPre.'.']; 01383 01384 if (!is_array($this->pSetup)) { 01385 $this->printError('The page is not configured! [type= '.$this->type.']['.$this->sPre.']'); 01386 exit; 01387 } else { 01388 $this->config['config']=Array(); 01389 01390 // Filling the config-array. 01391 if (is_array($this->tmpl->setup['config.'])) { 01392 $this->config['config'] = $this->tmpl->setup['config.']; 01393 } 01394 if (is_array($this->pSetup['config.'])) { 01395 reset($this->pSetup['config.']); 01396 while(list($theK,$theV)=each($this->pSetup['config.'])) { 01397 $this->config['config'][$theK] = $theV; 01398 } 01399 } 01400 // if .simulateStaticDocuments was not present, the default value will rule. 01401 if (!isset($this->config['config']['simulateStaticDocuments'])) { 01402 $this->config['config']['simulateStaticDocuments'] = $this->TYPO3_CONF_VARS['FE']['simulateStaticDocuments']; 01403 } 01404 01405 // Processing for the config_array: 01406 $this->config['rootLine'] = $this->tmpl->rootLine; 01407 $this->config['mainScript'] = trim($this->config['config']['mainScript']) ? trim($this->config['config']['mainScript']) : 'index.php'; 01408 01409 // STAT: 01410 $theLogFile = $this->TYPO3_CONF_VARS['FE']['logfile_dir'].$this->config['config']['stat_apache_logfile']; 01411 // Add PATH_site left to $theLogFile if the path is not absolute yet 01412 if(!ereg("^/", $theLogFile)) $theLogFile = PATH_site.$theLogFile; 01413 01414 if ($this->config['config']['stat_apache'] && $this->config['config']['stat_apache_logfile'] && !strstr($this->config['config']['stat_apache_logfile'],'/')) { 01415 if(t3lib_div::isAllowedAbsPath($theLogFile) && @is_file($theLogFile) && @is_writable($theLogFile)) { 01416 $this->config['stat_vars']['logFile'] = $theLogFile; 01417 $shortTitle = substr(ereg_replace('[^\.[:alnum:]_-]','_',$this->page['title']),0,30); 01418 $pageName = $this->config['config']['stat_apache_pagenames'] ? $this->config['config']['stat_apache_pagenames'] : '[path][title]--[uid].html'; 01419 $pageName = str_replace('[title]', $shortTitle ,$pageName); 01420 $pageName = str_replace('[uid]',$this->page['uid'],$pageName); 01421 $pageName = str_replace('[alias]',$this->page['alias'],$pageName); 01422 $pageName = str_replace('[type]',$this->page['type'],$pageName); 01423 $temp = $this->config['rootLine']; 01424 array_pop($temp); 01425 $len = t3lib_div::intInRange($this->config['config']['stat_titleLen'],1,100,20); 01426 $pageName = str_replace('[path]', ereg_replace('[^\.[:alnum:]\/_-]','_',$this->sys_page->getPathFromRootline($temp,$len)).'/' ,$pageName); 01427 $this->config['stat_vars']['pageName'] = $pageName; 01428 } else { 01429 $GLOBALS['TT']->setTSlogMessage('Could not set logfile path. Check filepath and permissions.',3); 01430 } 01431 } 01432 $this->config['FEData'] = $this->tmpl->setup['FEData']; 01433 $this->config['FEData.'] = $this->tmpl->setup['FEData.']; 01434 } 01435 $GLOBALS['TT']->pull(); 01436 } else { 01437 $this->printError('No template found!'); 01438 exit; 01439 } 01440 } 01441 01442 // Initialize charset settings etc. 01443 $this->initLLvars(); 01444 01445 // No cache 01446 if ($this->config['config']['no_cache']) {$this->set_no_cache();} // Set $this->no_cache true if the config.no_cache value is set! 01447 01448 // Check PATH_INFO url 01449 if ($this->absRefPrefix_force && strcmp($this->config['config']['simulateStaticDocuments'],'PATH_INFO')) { 01450 $redirectUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php?id='.$this->id.'&type='.$this->type; 01451 if ($this->config['config']['simulateStaticDocuments_dontRedirectPathInfoError']) { 01452 $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'); 01453 } else { 01454 header('Location: '.t3lib_div::locationHeaderUrl($redirectUrl)); 01455 } 01456 exit; 01457 // $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. 01458 } 01459 } 01460 01461 01462 01463 01464 01465 01466 01467 01468 01469 01470 01471 01472 01473 01474 /******************************************** 01475 * 01476 * Further initialization and data processing 01477 * (jumpurl/submission of forms) 01478 * 01479 *******************************************/ 01480 01489 function getCompressedTCarray() { 01490 global $TCA; 01491 01492 $GLOBALS['TT']->push('Get Compressed TC array'); 01493 if (!$this->TCAloaded) { 01494 // Create hash string for storage / retrieval of cached content: 01495 $tempHash = md5('tables.php:'. 01496 filemtime(TYPO3_extTableDef_script ? PATH_typo3conf.TYPO3_extTableDef_script : PATH_t3lib.'stddb/tables.php'). 01497 (TYPO3_extTableDef_script?filemtime(PATH_typo3conf.TYPO3_extTableDef_script):''). 01498 ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] ? filemtime(PATH_typo3conf.$GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'].'_ext_tables.php') : '') 01499 ); 01500 // Try to fetch if: 01501 list($TCA,$this->TCAcachedExtras) = unserialize($this->sys_page->getHash($tempHash, 0)); 01502 // If no result, create it: 01503 if (!is_array($TCA)) { 01504 $this->includeTCA(0); 01505 $newTc = Array(); 01506 $this->TCAcachedExtras = array(); // Collects other information 01507 01508 foreach($TCA as $key => $val) { 01509 $newTc[$key]['ctrl'] = $val['ctrl']; 01510 $newTc[$key]['feInterface'] = $val['feInterface']; 01511 01512 // Collect information about localization exclusion of fields: 01513 t3lib_div::loadTCA($key); 01514 if (is_array($TCA[$key]['columns'])) { 01515 $this->TCAcachedExtras[$key]['l10n_mode'] = array(); 01516 foreach($TCA[$key]['columns'] as $fN => $fV) { 01517 if ($fV['l10n_mode']) { 01518 $this->TCAcachedExtras[$key]['l10n_mode'][$fN] = $fV['l10n_mode']; 01519 } 01520 } 01521 } 01522 } 01523 01524 // Store it in cache: 01525 $TCA = $newTc; 01526 $this->sys_page->storeHash($tempHash, serialize(array($newTc,$this->TCAcachedExtras)), 'SHORT TC'); 01527 } 01528 } 01529 $GLOBALS['TT']->pull(); 01530 } 01531 01543 function includeTCA($TCAloaded=1) { 01544 global $TCA, $PAGES_TYPES, $LANG_GENERAL_LABELS, $TBE_MODULES; 01545 if (!$this->TCAloaded) { 01546 $TCA = Array(); 01547 include (TYPO3_tables_script ? PATH_typo3conf.TYPO3_tables_script : PATH_t3lib.'stddb/tables.php'); 01548 // Extension additions 01549 if ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE']) { 01550 include(PATH_typo3conf.$GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'].'_ext_tables.php'); 01551 } else { 01552 include(PATH_t3lib.'stddb/load_ext_tables.php'); 01553 } 01554 // ext-script 01555 if (TYPO3_extTableDef_script) { 01556 include (PATH_typo3conf.TYPO3_extTableDef_script); 01557 } 01558 01559 $this->TCAloaded = $TCAloaded; 01560 } 01561 } 01562 01570 function settingLanguage() { 01571 01572 // Get values from TypoScript: 01573 $this->sys_language_uid = $this->sys_language_content = intval($this->config['config']['sys_language_uid']); 01574 list($this->sys_language_mode,$sys_language_content) = t3lib_div::trimExplode(';', $this->config['config']['sys_language_mode']); 01575 $this->sys_language_contentOL = $this->config['config']['sys_language_overlay']; 01576 01577 // If sys_language_uid is set to another language than default: 01578 if ($this->sys_language_uid>0) { 01579 // Request the overlay record for the sys_language_uid: 01580 $olRec = $this->sys_page->getPageOverlay($this->id, $this->sys_language_uid); 01581 if (!count($olRec)) { 01582 01583 // If no OL record exists and a foreign language is asked for... 01584 if ($this->sys_language_uid) { 01585 01586 // If requested translation is not available: 01587 if ($this->page['l18n_cfg']&2) { 01588 $this->pageNotFoundAndExit('Page is not available in the requested language.'); 01589 } else { 01590 switch((string)$this->sys_language_mode) { 01591 case 'strict': 01592 $this->pageNotFoundAndExit('Page is not available in the requested language (strict).'); 01593 break; 01594 case 'content_fallback': 01595 $fallBackOrder = t3lib_div::intExplode(',', $sys_language_content); 01596 foreach($fallBackOrder as $orderValue) { 01597 if (!strcmp($orderValue,'0') || count($this->sys_page->getPageOverlay($this->id, $orderValue))) { 01598 $this->sys_language_content = $orderValue; // Setting content uid (but leaving the sys_language_uid) 01599 break; 01600 } 01601 } 01602 break; 01603 default: 01604 // Default is that everything defaults to the default language... 01605 $this->sys_language_uid = $this->sys_language_content = 0; 01606 break; 01607 } 01608 } 01609 } 01610 } else { 01611 // Setting sys_language if an overlay record was found (which it is only if a language is used) 01612 $this->page = $this->sys_page->getPageOverlay($this->page, $this->sys_language_uid); 01613 } 01614 } 01615 01616 // Setting sys_language_uid inside sys-page: 01617 $this->sys_page->sys_language_uid = $this->sys_language_uid; 01618 01619 // If default translation is not available: 01620 if ((!$this->sys_language_uid || !$this->sys_language_content) && $this->page['l18n_cfg']&1) { 01621 $this->pageNotFoundAndExit('Page is not available in default language.'); 01622 } 01623 01624 // Updating content of the two rootLines IF the language key is set! 01625 if ($this->sys_language_uid && is_array($this->tmpl->rootLine)) { 01626 reset($this->tmpl->rootLine); 01627 while(list($rLk)=each($this->tmpl->rootLine)) { 01628 $this->tmpl->rootLine[$rLk] = $this->sys_page->getPageOverlay($this->tmpl->rootLine[$rLk]); 01629 } 01630 } 01631 if ($this->sys_language_uid && is_array($this->rootLine)) { 01632 reset($this->rootLine); 01633 while(list($rLk)=each($this->rootLine)) { 01634 $this->rootLine[$rLk] = $this->sys_page->getPageOverlay($this->rootLine[$rLk]); 01635 } 01636 } 01637 01638 // Finding the ISO code: 01639 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" 01640 $sys_language_row = $this->sys_page->getRawRecord('sys_language',$this->sys_language_content,'static_lang_isocode'); 01641 if (is_array($sys_language_row) && $sys_language_row['static_lang_isocode']) { 01642 $stLrow = $this->sys_page->getRawRecord('static_languages',$sys_language_row['static_lang_isocode'],'lg_iso_2'); 01643 $this->sys_language_isocode = $stLrow['lg_iso_2']; 01644 } 01645 } 01646 01647 // Setting softMergeIfNotBlank: 01648 $table_fields = t3lib_div::trimExplode(',', $this->config['config']['sys_language_softMergeIfNotBlank'],1); 01649 foreach($table_fields as $TF) { 01650 list($tN,$fN) = explode(':',$TF); 01651 $this->TCAcachedExtras[$tN]['l10n_mode'][$fN] = 'mergeIfNotBlank'; 01652 } 01653 } 01654 01660 function settingLocale() { 01661 01662 // Setting locale 01663 if ($this->config['config']['locale_all']) { 01664 # Change by Rene Fritz, 22/10 2002 01665 # 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 01666 # this does not work in php 4.2.3 01667 #setlocale('LC_ALL',$this->config['config']['locale_all']); 01668 #setlocale('LC_NUMERIC','en_US'); 01669 01670 # so we set all except LC_NUMERIC 01671 setlocale(LC_COLLATE,$this->config['config']['locale_all']); 01672 setlocale(LC_CTYPE,$this->config['config']['locale_all']); 01673 setlocale(LC_MONETARY,$this->config['config']['locale_all']); 01674 setlocale(LC_TIME,$this->config['config']['locale_all']); 01675 01676 $this->localeCharset = $this->csConvObj->get_locale_charset($this->config['config']['locale_all']); 01677 } 01678 } 01679 01685 function checkDataSubmission() { 01686 if ($_POST['formtype_db'] || $_POST['formtype_mail']) { 01687 $refInfo = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER')); 01688 if (t3lib_div::getIndpEnv('TYPO3_HOST_ONLY')==$refInfo['host'] || $this->TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) { 01689 if ($this->locDataCheck($_POST['locationData'])) { 01690 $ret = ''; 01691 if ($_POST['formtype_mail']) { 01692 $ret = 'email'; 01693 } elseif ($_POST['formtype_db'] && is_array($_POST['data'])) { 01694 $ret = 'fe_tce'; 01695 } 01696 $GLOBALS['TT']->setTSlogMessage('"Check Data Submission": Return value: '.$ret,0); 01697 return $ret; 01698 } 01699 } else $GLOBALS['TT']->setTSlogMessage('"Check Data Submission": HTTP_HOST and REFERER HOST did not match when processing submitted formdata!',3); 01700 } 01701 } 01702 01710 function fe_tce() { 01711 $fe_tce = t3lib_div::makeInstance('tslib_feTCE'); 01712 $fe_tce->start(t3lib_div::_POST('data'),$this->config['FEData.']); 01713 $fe_tce->includeScripts(); 01714 } 01715 01724 function locDataCheck($locationData) { 01725 $locData = explode(':',$locationData); 01726 if (!$locData[1] || $this->sys_page->checkRecord($locData[1],$locData[2],1)) { 01727 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. 01728 return 1; 01729 } else $GLOBALS['TT']->setTSlogMessage('LocationData Error: The page pointed to by location data ('.$locationData.') was not accessible.',2); 01730 } else $GLOBALS['TT']->setTSlogMessage('LocationData Error: Location data ('.$locationData.') record pointed to was not accessible.',2); 01731 } 01732 01740 function sendFormmail() { 01741 $formmail = t3lib_div::makeInstance('t3lib_formmail'); 01742 01743 $EMAIL_VARS = t3lib_div::_POST(); 01744 unset($EMAIL_VARS['locationData']); 01745 unset($EMAIL_VARS['formtype_mail']); 01746 01747 $integrityCheck = $this->TYPO3_CONF_VARS['FE']['strictFormmail']; 01748 01749 // Check recipient field: 01750 $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. 01751 foreach($encodedFields as $fieldKey) { 01752 if (strlen($EMAIL_VARS[$fieldKey])) { 01753 if ($res = $this->codeString($EMAIL_VARS[$fieldKey], TRUE)) { // Decode... 01754 $EMAIL_VARS[$fieldKey] = $res; // Set value if OK 01755 } elseif ($integrityCheck) { // Otherwise abort: 01756 $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); 01757 return FALSE; 01758 } else { 01759 $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); 01760 } 01761 } 01762 } 01763 01764 // Hook for preprocessing of the content for formmails: 01765 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass'])) { 01766 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass'] as $_classRef) { 01767 $_procObj = &t3lib_div::getUserObj($_classRef); 01768 $EMAIL_VARS = $_procObj->sendFormmail_preProcessVariables($EMAIL_VARS,$this); 01769 } 01770 } 01771 01772 $formmail->start($EMAIL_VARS); 01773 $formmail->sendtheMail(); 01774 $GLOBALS['TT']->setTSlogMessage('"Formmail" invoked, sending mail to '.$EMAIL_VARS['recipient'],0); 01775 } 01776 01783 function checkJumpUrl() { 01784 global $TCA; 01785 01786 $mid = t3lib_div::_GP('mid'); // mail id, if direct mail link 01787 $rid = t3lib_div::_GP('rid'); // recipient id, if direct mail link 01788 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']))) { 01789 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!) 01790 $temp_recip=explode('_',$rid); 01791 $url_id=0; 01792 if (t3lib_div::testInt($this->jumpurl)) { 01793 $temp_res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('mailContent', 'sys_dmail', 'uid='.intval($mid)); 01794 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($temp_res)) { 01795 $temp_unpackedMail = unserialize($row['mailContent']); 01796 $url_id=$this->jumpurl; 01797 if ($this->jumpurl>=0) { 01798 $responseType=1; // Link (number) 01799 $this->jumpurl = $temp_unpackedMail['html']['hrefs'][$url_id]['absRef']; 01800 } else { 01801 $responseType=2; // Link (number, plaintext) 01802 $this->jumpurl = $temp_unpackedMail['plain']['link_ids'][abs($url_id)]; 01803 } 01804 switch($temp_recip[0]) { 01805 case 't': 01806 $theTable = 'tt_address'; 01807 break; 01808 case 'f': 01809 $theTable = 'fe_users'; 01810 break; 01811 default: 01812 $theTable=''; 01813 break; 01814 } 01815 if ($theTable) { 01816 $recipRow = $this->sys_page->getRawRecord($theTable,$temp_recip[1]); 01817 if (is_array($recipRow)) { 01818 // debug($recipRow); 01819 $authCode = t3lib_div::stdAuthCode($recipRow['uid']); 01820 $rowFieldsArray = explode(',', 'uid,name,title,email,phone,www,address,company,city,zip,country,fax,firstname'); 01821 reset($rowFieldsArray); 01822 while(list(,$substField)=each($rowFieldsArray)) { 01823 $this->jumpurl = str_replace('###USER_'.$substField.'###', $recipRow[$substField], $this->jumpurl); 01824 } 01825 $this->jumpurl = str_replace('###SYS_TABLE_NAME###', $tableNameChar, $this->jumpurl); // Put in the tablename of the userinformation 01826 $this->jumpurl = str_replace('###SYS_MAIL_ID###', $mid, $this->jumpurl); // Put in the uid of the mail-record 01827 $this->jumpurl = str_replace('###SYS_AUTHCODE###', $authCode, $this->jumpurl); 01828 01829 // debug($this->jumpurl); 01830 } 01831 } 01832 } 01833 01834 $GLOBALS['TYPO3_DB']->sql_free_result($temp_res); 01835 01836 if (!$this->jumpurl) die('Error: No further link. Please report error to the mail sender.'); 01837 } else { 01838 $responseType=-1; // received (url, dmailerping) 01839 } 01840 if ($responseType!=0) { 01841 $insertFields = array( 01842 'mid' => intval($mid), 01843 'rtbl' => $temp_recip[0], 01844 'rid' => intval($temp_recip[1]), 01845 'tstamp' => time(), 01846 'url' => $this->jumpurl, 01847 'response_type' => intval($responseType), 01848 'url_id' => intval($url_id) 01849 ); 01850 01851 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_dmail_maillog', $insertFields); 01852 } 01853 } 01854 } else { 01855 unset($this->jumpurl); 01856 } 01857 } 01858 01865 function jumpUrl() { 01866 if ($this->jumpurl) { 01867 if (t3lib_div::_GP('juSecure')) { 01868 $hArr = array( 01869 $this->jumpurl, 01870 t3lib_div::_GP('locationData'), 01871 $this->TYPO3_CONF_VARS['SYS']['encryptionKey'] 01872 ); 01873 $calcJuHash=t3lib_div::shortMD5(serialize($hArr)); 01874 $locationData = t3lib_div::_GP('locationData'); 01875 $juHash = t3lib_div::_GP('juHash'); 01876 if ($juHash == $calcJuHash) { 01877 if ($this->locDataCheck($locationData)) { 01878 $this->jumpurl = rawurldecode($this->jumpurl); // 211002 - goes with cObj->filelink() rawurlencode() of filenames so spaces can be allowed. 01879 if (@is_file($this->jumpurl)) { 01880 $mimeType = t3lib_div::_GP('mimeType'); 01881 $mimeType = $mimeType ? $mimeType : 'application/octet-stream'; 01882 Header('Content-Type: '.$mimeType); 01883 Header('Content-Disposition: attachment; filename='.basename($this->jumpurl)); 01884 readfile($this->jumpurl); 01885 exit; 01886 } else die('jumpurl Secure: "'.$this->jumpurl.'" was not a valid file!'); 01887 } else die('jumpurl Secure: locationData, '.$locationData.', was not accessible.'); 01888 } else die('jumpurl Secure: Calculated juHash, '.$calcJuHash.', did not match the submitted juHash.'); 01889 } else { 01890 $TSConf = $this->getPagesTSconfig(); 01891 if ($TSConf['TSFE.']['jumpUrl_transferSession']) { 01892 $uParts = parse_url($this->jumpurl); 01893 $params = '&FE_SESSION_KEY='.rawurlencode($this->fe_user->id.'-'.md5($this->fe_user->id.'/'.$this->TYPO3_CONF_VARS['SYS']['encryptionKey'])); 01894 $this->jumpurl.=($uParts['query']?'':'?').$params; // Add the session parameter ... 01895 } 01896 Header('Location: '.$this->jumpurl); 01897 exit; 01898 } 01899 } 01900 } 01901 01908 function setUrlIdToken() { 01909 if ($this->config['config']['ftu']) { 01910 $this->getMethodUrlIdToken = $this->TYPO3_CONF_VARS['FE']['get_url_id_token']; 01911 } else { 01912 $this->getMethodUrlIdToken = ''; 01913 } 01914 } 01915 01916 01917 01918 01919 01920 01921 01922 01923 01924 01925 01926 01927 01928 01929 01930 01931 01932 01933 01934 01935 01936 01937 01938 01939 /******************************************** 01940 * 01941 * Page generation; cache handling 01942 * 01943 *******************************************/ 01944 01951 function isGeneratePage() { 01952 return (!$this->cacheContentFlag && !$this->jumpurl); 01953 } 01954 01961 function tempPageCacheContent() { 01962 $this->tempContent=0; 01963 if (!$this->no_cache) { 01964 $seconds=30; 01965 $stdMsg = ' 01966 <html> 01967 <head> 01968 <title>'.htmlspecialchars($this->tmpl->printTitle($this->page['title'])).'</title> 01969 <meta http-equiv=Refresh Content="3; Url='.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'" /> 01970 </head> 01971 <body bgcolor="white"> 01972 <font size="1" face="VERDANA,ARIAL,HELVETICA" color="#cccccc"> 01973 <div align="center"> 01974 <b>Page is being generated.</b><br /> 01975 If this message does not disappear within '.$seconds.' seconds, please reload. 01976 </div> 01977 </font> 01978 </body> 01979 </html>'; 01980 $temp_content = $this->config['config']['message_page_is_being_generated'] ? $this->config['config']['message_page_is_being_generated'] : $stdMsg; 01981 01982 $this->setPageCacheContent($temp_content,'',$GLOBALS['EXEC_TIME']+$seconds); 01983 $this->tempContent=1; // This flag shows that temporary content is put in the cache 01984 } 01985 } 01986 01992 function realPageCacheContent() { 01993 $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 01994 $timeOutTime = $GLOBALS['EXEC_TIME']+$cache_timeout; 01995 if ($this->config['config']['cache_clearAtMidnight']) { 01996 $midnightTime = mktime (0,0,0,date('m',$timeOutTime),date('d',$timeOutTime),date('Y',$timeOutTime)); 01997 if ($midnightTime > time()) { // If the midnight time of the expire-day is greater than the current time, we may set the timeOutTime to the new midnighttime. 01998 $timeOutTime = $midnightTime; 01999 } 02000 } 02001 $this->config['hash_base'] = $this->hash_base; 02002 $this->setPageCacheContent($this->content,$this->config,$timeOutTime); 02003 02004 // Hook for cache post processing (eg. writing static files!) 02005 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'])) { 02006 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'] as $_classRef) { 02007 $_procObj = &t3lib_div::getUserObj($_classRef); 02008 $_procObj->insertPageIncache($this,$timeOutTime); 02009 } 02010 } 02011 } 02012 02022 function setPageCacheContent($c,$d,$t) { 02023 $this->clearPageCacheContent(); 02024 $insertFields = array( 02025 'hash' => $this->newHash, 02026 'page_id' => $this->id, 02027 'HTML' => $c, 02028 'cache_data' => serialize($d), 02029 'expires' => $t, 02030 'tstamp' => time() 02031 ); 02032 if ($this->page_cache_reg1) { 02033 $insertFields['reg1'] = intval($this->page_cache_reg1); 02034 } 02035 02036 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pages', $insertFields); 02037 } 02038 02044 function clearPageCacheContent() { 02045 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'hash="'.$GLOBALS['TYPO3_DB']->quoteStr($this->newHash, 'cache_pages').'"'); 02046 } 02047 02054 function clearPageCacheContent_pidList($pidList) { 02055 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'page_id IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($pidList).')'); 02056 } 02057 02065 function setSysLastChanged() { 02066 if ($this->page['SYS_LASTCHANGED'] < intval($this->register['SYS_LASTCHANGED'])) { 02067 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid='.intval($this->id), array('SYS_LASTCHANGED' => intval($this->register['SYS_LASTCHANGED']))); 02068 } 02069 } 02070 02071 02072 02073 02074 02075 02076 02077 02078 02079 02080 02081 02082 02083 02084 02085 02086 02087 02088 02089 02090 /******************************************** 02091 * 02092 * Page generation; rendering and inclusion 02093 * 02094 *******************************************/ 02095 02101 function generatePage_preProcessing() { 02102 ksort($this->all); 02103 // 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! 02104 $this->newHash = $this->getHash(); 02105 02106 // 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. 02107 $this->tempPageCacheContent(); 02108 02109 02110 // Setting cache_timeout_default. May be overridden by PHP include scritps. 02111 $this->cacheTimeOutDefault = intval($this->config['config']['cache_period']); 02112 02113 // page is generated 02114 $this->no_cacheBeforePageGen = $this->no_cache; 02115 } 02116 02123 function generatePage_whichScript() { 02124 if (!$this->TYPO3_CONF_VARS['FE']['noPHPscriptInclude'] && $this->config['config']['pageGenScript']) { 02125 return $this->tmpl->getFileName($this->config['config']['pageGenScript']); 02126 } 02127 } 02128 02135 function generatePage_postProcessing() { 02136 // 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. 02137 if ($this->no_cacheBeforePageGen) $this->set_no_cache(); 02138 02139 // Tidy up the code, if flag... 02140 if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'all') { 02141 $GLOBALS['TT']->push('Tidy, all',''); 02142 $this->content = $this->tidyHTML($this->content); 02143 $GLOBALS['TT']->pull(); 02144 } 02145 02146 // XHTML-clean the code, if flag set 02147 if ($this->doXHTML_cleaning() == 'all') { 02148 $GLOBALS['TT']->push('XHTML clean, all',''); 02149 $XHTML_clean = t3lib_div::makeInstance('t3lib_parsehtml'); 02150 $this->content = $XHTML_clean->XHTML_clean($this->content); 02151 $GLOBALS['TT']->pull(); 02152 } 02153 02154 // Fix local anchors in links, if flag set 02155 if ($this->doLocalAnchorFix() == 'all') { 02156 $GLOBALS['TT']->push('Local anchor fix, all',''); 02157 $this->prefixLocalAnchorsWithScript(); 02158 $GLOBALS['TT']->pull(); 02159 } 02160 02161 // Hook for post-processing of page content cached/non-cached: 02162 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'])) { 02163 $_params = array('pObj' => &$this); 02164 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'] as $_funcRef) { 02165 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02166 } 02167 } 02168 02169 // Processing if caching is enabled: 02170 if (!$this->no_cache) { 02171 // Tidy up the code, if flag... 02172 if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'cached') { 02173 $GLOBALS['TT']->push('Tidy, cached',''); 02174 $this->content = $this->tidyHTML($this->content); 02175 $GLOBALS['TT']->pull(); 02176 } 02177 // XHTML-clean the code, if flag set 02178 if ($this->doXHTML_cleaning() == 'cached') { 02179 $GLOBALS['TT']->push('XHTML clean, cached',''); 02180 $XHTML_clean = t3lib_div::makeInstance('t3lib_parsehtml'); 02181 $this->content = $XHTML_clean->XHTML_clean($this->content); 02182 $GLOBALS['TT']->pull(); 02183 } 02184 // Fix local anchors in links, if flag set 02185 if ($this->doLocalAnchorFix() == 'cached') { 02186 $GLOBALS['TT']->push('Local anchor fix, cached',''); 02187 $this->prefixLocalAnchorsWithScript(); 02188 $GLOBALS['TT']->pull(); 02189 } 02190 02191 // Hook for post-processing of page content before being cached: 02192 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'])) { 02193 $_params = array('pObj' => &$this); 02194 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'] as $_funcRef) { 02195 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02196 } 02197 } 02198 } 02199 02200 // Hook for indexing pages 02201 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageIndexing'])) { 02202 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageIndexing'] as $_classRef) { 02203 $_procObj = &t3lib_div::getUserObj($_classRef); 02204 $_procObj->hook_indexContent($this); 02205 } 02206 } 02207 02208 // Convert char-set for output: 02209 $this->content = $this->convOutputCharset($this->content,'mainpage'); 02210 02211 // Storing for cache: 02212 if (!$this->no_cache) { 02213 $this->realPageCacheContent(); 02214 } 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) 02215 $this->clearPageCacheContent(); 02216 } 02217 02218 // Sets sys-last-change: 02219 $this->setSysLastChanged(); 02220 } 02221 02227 function INTincScript() { 02228 $GLOBALS['TT']->push('Split content'); 02229 $INTiS_splitC = explode('<!--INT_SCRIPT.',$this->content); // Splits content with the key. 02230 $this->content=''; 02231 $GLOBALS['TT']->setTSlogMessage('Parts: '.count($INTiS_splitC)); 02232 $GLOBALS['TT']->pull(); 02233 02234 // Depreciated stuff: 02235 $this->additionalHeaderData = is_array($this->config['INTincScript_ext']['additionalHeaderData']) ? $this->config['INTincScript_ext']['additionalHeaderData'] : array(); 02236 $this->additionalJavaScript = $this->config['INTincScript_ext']['additionalJavaScript']; 02237 $this->additionalCSS = $this->config['INTincScript_ext']['additionalCSS']; 02238 $this->JSCode = $this->additionalHeaderData['JSCode']; 02239 $this->JSImgCode = $this->additionalHeaderData['JSImgCode']; 02240 $this->divSection=''; 02241 02242 $INTiS_config = $GLOBALS['TSFE']->config['INTincScript']; 02243 foreach($INTiS_splitC as $INTiS_c => $INTiS_cPart) { 02244 if (substr($INTiS_cPart,32,3)=='-->') { // If the split had a comment-end after 32 characters it's probably a split-string 02245 $GLOBALS['TT']->push('Include '.$INTiS_config[$INTiS_key]['file'],''); 02246 $INTiS_key = 'INT_SCRIPT.'.substr($INTiS_cPart,0,32); 02247 $incContent=''; 02248 if (is_array($INTiS_config[$INTiS_key])) { 02249 $INTiS_cObj = unserialize($INTiS_config[$INTiS_key]['cObj']); 02250 $INTiS_cObj->INT_include=1; 02251 switch($INTiS_config[$INTiS_key]['type']) { 02252 case 'SCRIPT': 02253 $incContent = $INTiS_cObj->PHP_SCRIPT($INTiS_config[$INTiS_key]['conf']); 02254 break; 02255 case 'COA': 02256 $incContent = $INTiS_cObj->COBJ_ARRAY($INTiS_config[$INTiS_key]['conf']); 02257 break; 02258 case 'FUNC': 02259 $incContent = $INTiS_cObj->USER($INTiS_config[$INTiS_key]['conf']); 02260 break; 02261 case 'POSTUSERFUNC': 02262 $incContent = $INTiS_cObj->callUserFunction($INTiS_config[$INTiS_key]['postUserFunc'], $INTiS_config[$INTiS_key]['conf'], $INTiS_config[$INTiS_key]['content']); 02263 break; 02264 } 02265 } 02266 $this->content.= $this->convOutputCharset($incContent,'INC-'.$INTiS_c); 02267 $this->content.= substr($INTiS_cPart,35); 02268 $GLOBALS['TT']->pull($incContent); 02269 } else { 02270 $this->content.= ($INTiS_c?'<!--INT_SCRIPT.':'').$INTiS_cPart; 02271 } 02272 } 02273 $GLOBALS['TT']->push('Substitute header section'); 02274 $this->INTincScript_loadJSCode(); 02275 $this->content = str_replace('<!--HD_'.$this->config['INTincScript_ext']['divKey'].'-->', $this->convOutputCharset(implode(chr(10),$this->additionalHeaderData),'HD'), $this->content); 02276 $this->content = str_replace('<!--TDS_'.$this->config['INTincScript_ext']['divKey'].'-->', $this->convOutputCharset($this->divSection,'TDS'), $this->content); 02277 $this->setAbsRefPrefix(); 02278 $GLOBALS['TT']->pull(); 02279 } 02280 02287 function INTincScript_loadJSCode() { 02288 if ($this->JSImgCode) { // If any images added, then add them to the javascript section 02289 $this->additionalHeaderData['JSImgCode']=' 02290 <script type="text/javascript"> 02291 /*<![CDATA[*/ 02292 <!-- 02293 if (version == "n3") { 02294 '.trim($this->JSImgCode).' 02295 } 02296 // --> 02297 /*]]>*/ 02298 </script>'; 02299 } 02300 if ($this->JSCode || count($this->additionalJavaScript)) { // Add javascript 02301 $this->additionalHeaderData['JSCode']=' 02302 <script type="text/javascript"> 02303 /*<![CDATA[*/ 02304 <!-- 02305 '.implode(chr(10),$this->additionalJavaScript).' 02306 '.trim($this->JSCode).' 02307 // --> 02308 /*]]>*/ 02309 </script>'; 02310 } 02311 if (count($this->additionalCSS)) { // Add javascript 02312 $this->additionalHeaderData['_CSS']=' 02313 <style type="text/css"> 02314 /*<![CDATA[*/ 02315 <!-- 02316 '.implode(chr(10),$this->additionalCSS).' 02317 // --> 02318 /*]]>*/ 02319 </style>'; 02320 } 02321 } 02322 02328 function isINTincScript() { 02329 return (is_array($this->config['INTincScript']) && !$this->jumpurl); 02330 } 02331 02337 function doXHTML_cleaning() { 02338 return $this->config['config']['xhtml_cleaning']; 02339 } 02340 02346 function doLocalAnchorFix() { 02347 return $this->config['config']['prefixLocalAnchors']; 02348 } 02349 02350 02351 02352 02353 02354 02355 02356 02357 02358 02359 02360 02361 02362 02363 02364 02365 /******************************************** 02366 * 02367 * Finished off; outputting, storing session data, statistics... 02368 * 02369 *******************************************/ 02370 02377 function isOutputting() { 02378 return (!$this->jumpurl); 02379 } 02380 02388 function processOutput() { 02389 // Substitutes username mark with the username 02390 if ($this->fe_user->user['uid']) { 02391 $token = trim($this->config['config']['USERNAME_substToken']); 02392 $this->content = str_replace($token ? $token : '<!--###USERNAME###-->',$this->fe_user->user['username'],$this->content); 02393 } 02394 // Substitutes get_URL_ID in case of GET-fallback 02395 if ($this->getMethodUrlIdToken) { 02396 $this->content = str_replace($this->getMethodUrlIdToken, $this->fe_user->get_URL_ID, $this->content); 02397 } 02398 02399 // Set header for charset-encoding unless disabled 02400 if (!$this->config['config']['disableCharsetHeader']) { 02401 $headLine = 'Content-Type:text/html;charset='.trim($this->metaCharset); 02402 header ($headLine); 02403 } 02404 02405 // Set headers, if any 02406 if ($this->config['config']['additionalHeaders']) { 02407 $headerArray = explode('|', $this->config['config']['additionalHeaders']); 02408 while(list(,$headLine)=each($headerArray)) { 02409 $headLine = trim($headLine); 02410 header($headLine); 02411 } 02412 } 02413 02414 // Tidy up the code, if flag... 02415 if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'output') { 02416 $GLOBALS['TT']->push('Tidy, output',''); 02417 $this->content = $this->tidyHTML($this->content); 02418 $GLOBALS['TT']->pull(); 02419 } 02420 // XHTML-clean the code, if flag set 02421 if ($this->doXHTML_cleaning() == 'output') { 02422 $GLOBALS['TT']->push('XHTML clean, output',''); 02423 $XHTML_clean = t3lib_div::makeInstance('t3lib_parsehtml'); 02424 $this->content = $XHTML_clean->XHTML_clean($this->content); 02425 $GLOBALS['TT']->pull(); 02426 } 02427 // Fix local anchors in links, if flag set 02428 if ($this->doLocalAnchorFix() == 'output') { 02429 $GLOBALS['TT']->push('Local anchor fix, output',''); 02430 $this->prefixLocalAnchorsWithScript(); 02431 $GLOBALS['TT']->pull(); 02432 } 02433 02434 // Hook for post-processing of page content before output: 02435 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'])) { 02436 $_params = array('pObj' => &$this); 02437 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'] as $_funcRef) { 02438 t3lib_div::callUserFunction($_funcRef,$_params,$this); 02439 } 02440 } 02441 02442 /* 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... 02443 $this->content = str_replace('target="_top"','target="_self"',$this->content); 02444 $this->content = str_replace('target=_top','target="_self"',$this->content); 02445 }*/ 02446 } 02447 02454 function isEXTincScript() { 02455 return is_array($this->config['EXTincScript']); 02456 } 02457 02463 function storeSessionData() { 02464 $this->fe_user->storeSessionData(); 02465 } 02466 02473 function setParseTime() { 02474 // Compensates for the time consumed with Back end user initialization. 02475 $this->scriptParseTime = $GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_end']) 02476 - $GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_start']) 02477 - ($GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'])-$GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'])); 02478 } 02479 02485 function statistics() { 02486 if ($this->config['config']['stat'] && 02487 (!strcmp('',$this->config['config']['stat_typeNumList']) || t3lib_div::inList(str_replace(' ','',$this->config['config']['stat_typeNumList']), $this->type)) && 02488 (!$this->config['config']['stat_excludeBEuserHits'] || !$this->beUserLogin) && 02489 (!$this->config['config']['stat_excludeIPList'] || !t3lib_div::inList(str_replace(' ','',$this->config['config']['stat_excludeIPList']), t3lib_div::getIndpEnv('REMOTE_ADDR')))) { 02490 $GLOBALS['TT']->push('Stat'); 02491 if (t3lib_extMgm::isLoaded('sys_stat') && $this->config['config']['stat_mysql']) { 02492 02493 // Jumpurl: 02494 $sword = t3lib_div::_GP('sword'); 02495 if ($sword) { 02496 $jumpurl_msg = 'sword:'.$sword; 02497 } elseif ($this->jumpurl) { 02498 $jumpurl_msg = 'jumpurl:'.$this->jumpurl; 02499 } else { 02500 $jumpurl_msg = ''; 02501 } 02502 02503 // Flags: bits: 0 = BE_user, 1=Cached page? 02504 $flags=0; 02505 if ($this->beUserLogin) {$flags|=1;} 02506 if ($this->cacheContentFlag) {$flags|=2;} 02507 02508 // Ref url: 02509 $refUrl = t3lib_div::getIndpEnv('HTTP_REFERER'); 02510 $thisUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR'); 02511 if (t3lib_div::isFirstPartOfStr($refUrl,$thisUrl)) { 02512 $refUrl='[LOCAL]'; 02513 } 02514 02515 $insertFields = array( 02516 'page_id' => intval($this->id), // id 02517 'page_type' => intval($this->type), // type 02518 'jumpurl' => $jumpurl_msg, // jumpurl message 02519 'feuser_id' => $this->fe_user->user['uid'], // fe_user id, integer 02520 'cookie' => $this->fe_user->id, // cookie as set or retrieve. If people has cookies disabled this will vary all the time... 02521 '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... 02522 'rl0' => $this->config['rootLine'][0]['uid'], // RootLevel 0 uid 02523 'rl1' => $this->config['rootLine'][1]['uid'], // RootLevel 1 uid 02524 'client_browser' => $GLOBALS['CLIENT']['BROWSER'], // Client browser (net, msie, opera) 02525 'client_version' => $GLOBALS['CLIENT']['VERSION'], // Client version (double value) 02526 'client_os' => $GLOBALS['CLIENT']['SYSTEM'], // Client Operating system (win, mac, unix) 02527 'parsetime' => intval($this->scriptParseTime), // Parsetime for the page. 02528 'flags' => $flags, // Flags: Is be user logged in? Is page cached? 02529 'IP' => t3lib_div::getIndpEnv('REMOTE_ADDR'), // Remote IP address 02530 'host' => t3lib_div::getIndpEnv('REMOTE_HOST'), // Remote Host Address 02531 'referer' => $refUrl, // Referer URL 02532 'browser' => t3lib_div::getIndpEnv('HTTP_USER_AGENT'), // User Agent Info. 02533 'tstamp' => $GLOBALS['EXEC_TIME'] // Time stamp 02534 ); 02535 02536 $GLOBALS['TT']->push('Store SQL'); 02537 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_stat', $insertFields); 02538 $GLOBALS['TT']->pull(); 02539 } 02540 02541 // Apache: 02542 if ($this->config['config']['stat_apache'] && $this->config['stat_vars']['pageName']) { 02543 if (@is_file($this->config['stat_vars']['logFile']) && TYPO3_OS!='WIN') { 02544 $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); 02545 if (!$this->config['config']['stat_apache_notExtended']) { 02546 $LogLine.= ' "'.t3lib_div::getIndpEnv('HTTP_REFERER').'" "'.t3lib_div::getIndpEnv('HTTP_USER_AGENT').'"'; 02547 } 02548 02549 switch($this->TYPO3_CONF_VARS['FE']['logfile_write']) { 02550 case 'fputs': 02551 $GLOBALS['TT']->push('Write to log file (fputs)'); 02552 $logfilehandle = fopen($this->config['stat_vars']['logFile'], 'a'); 02553 fputs($logfilehandle, $LogLine."\n"); 02554 @fclose($logfilehandle); 02555 $GLOBALS['TT']->pull(); 02556 break; 02557 default: 02558 $GLOBALS['TT']->push('Write to log file (echo)'); 02559 $execCmd = 'echo "'.addslashes($LogLine).'" >> '.$this->config['stat_vars']['logFile']; 02560 exec($execCmd); 02561 $GLOBALS['TT']->pull(); 02562 break; 02563 } 02564 02565 $GLOBALS['TT']->setTSlogMessage('Writing to logfile: OK',0); 02566 } else { 02567 $GLOBALS['TT']->setTSlogMessage('Writing to logfile: Error - logFile did not exist or OS is Windows!',3); 02568 } 02569 } 02570 $GLOBALS['TT']->pull(); 02571 } 02572 } 02573 02579 function previewInfo() { 02580 if ($this->fePreview) { 02581 $stdMsg = ' 02582 <br /> 02583 <div align="center"> 02584 <table border="3" bordercolor="black" cellpadding="2" bgcolor="red"> 02585 <tr> 02586 <td> <font face="Verdana" size="1"><b>PREVIEW!</b></font> </td> 02587 </tr> 02588 </table> 02589 </div>'; 02590 $temp_content = $this->config['config']['message_preview'] ? $this->config['config']['message_preview'] : $stdMsg; 02591 echo $temp_content; 02592 } 02593 } 02594 02600 function beLoginLinkIPList() { 02601 if ($this->config['config']['beLoginLinkIPList']) { 02602 if (t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $this->config['config']['beLoginLinkIPList'])) { 02603 $label = !$this->beUserLogin ? $this->config['config']['beLoginLinkIPList_login'] : $this->config['config']['beLoginLinkIPList_logout']; 02604 if ($label) { 02605 if (!$this->beUserLogin) { 02606 $link = '<a href="'.htmlspecialchars(TYPO3_mainDir.'index.php?redirect_url='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI"))).'">'.$label.'</a>'; 02607 } else { 02608 $link = '<a href="'.htmlspecialchars(TYPO3_mainDir.'index.php?L=OUT&redirect_url='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI"))).'">'.$label.'</a>'; 02609 } 02610 return $link; 02611 } 02612 } 02613 } 02614 } 02615 02616 02617 02618 02619 02620 02621 02622 02623 02624 02625 02626 02627 02628 02629 02630 02631 02632 02633 02634 02635 02636 02637 /******************************************** 02638 * 02639 * Various internal API functions 02640 * 02641 *******************************************/ 02642 02643 02655 function makeSimulFileName($inTitle,$page,$type,$addParams='',$no_cache='') { 02656 $titleChars = intval($this->config['config']['simulateStaticDocuments_addTitle']); 02657 $out = ''; 02658 if ($titleChars) { 02659 $out = $this->csConvObj->specCharsToASCII($this->renderCharset, $inTitle); 02660 $out= ereg_replace('[^[:alnum:]_-]','_',trim(substr($out,0,$titleChars))); 02661 $out= ereg_replace('_*$','',$out); 02662 $out= ereg_replace('^_*','',$out); 02663 if ($out) $out.='.'; 02664 } 02665 $enc = ''; 02666 if (strcmp($addParams,'') && !$no_cache) { 02667 switch ((string)$this->config['config']['simulateStaticDocuments_pEnc']) { 02668 case 'md5': 02669 $md5=substr(md5($addParams),0,10); 02670 $enc='+M5'.$md5; 02671 02672 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('md5hash', 'cache_md5params', 'md5hash="'.$GLOBALS['TYPO3_DB']->quoteStr($md5, 'cache_md5params').'"'); 02673 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 02674 $insertFields = array( 02675 'md5hash' => $md5, 02676 'tstamp' => time(), 02677 'type' => 1, 02678 'params' => $addParams 02679 ); 02680 02681 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_md5params', $insertFields); 02682 } 02683 break; 02684 case 'base64': 02685 $enc='+B6'.str_replace('=','_',str_replace('/','-',base64_encode($addParams))); 02686 break; 02687 } 02688 } 02689 // Setting page and type number: 02690 $url = $out.$page.$enc; 02691 $url.= ($type || $out || !$this->config['config']['simulateStaticDocuments_noTypeIfNoTitle']) ? '.'.$type : ''; 02692 return $url; 02693 } 02694 02702 function simulateStaticDocuments_pEnc_onlyP_proc($linkVars) { 02703 $remainLinkVars = ''; 02704 if (strcmp($linkVars,'')) { 02705 $p = explode('&',$linkVars); 02706 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? 02707 $rem = array(); 02708 foreach($p as $k => $v) { 02709 if (strlen($v)) { 02710 list($pName) = explode('=',$v,2); 02711 $pName = rawurldecode($pName); 02712 if (!$this->pEncAllowedParamNames[$pName]) { 02713 unset($p[$k]); 02714 $rem[] = $v; 02715 } 02716 } else unset($p[$k]); 02717 } 02718 02719 $linkVars = count($p) ? '&'.implode('&',$p) : ''; 02720 $remainLinkVars = count($rem) ? '&'.implode('&',$rem) : ''; 02721 } 02722 return array($linkVars, $remainLinkVars); 02723 } 02724 02731 function getSimulFileName() { 02732 $url=''; 02733 $url.=$this->makeSimulFileName($this->page['title'], $this->page['alias']?$this->page['alias']:$this->id, $this->type).'.html'; 02734 return $url; 02735 } 02736 02744 function encryptEmail($string,$back=0) { 02745 $out = ''; 02746 for ($a=0; $a<strlen($string); $a++) { 02747 $charValue = ord(substr($string,$a,1)); 02748 $charValue+= intval($this->spamProtectEmailAddresses)*($back?-1:1); 02749 $out.= chr($charValue); 02750 } 02751 return $out; 02752 } 02753 02763 function codeString($string, $decode=FALSE) { 02764 02765 if ($decode) { 02766 list($md5Hash, $str) = explode(':',$string,2); 02767 $newHash = substr(md5($this->TYPO3_CONF_VARS['SYS']['encryptionKey'].':'.$str),0,10); 02768 if (!strcmp($md5Hash, $newHash)) { 02769 $str = base64_decode($str); 02770 $str = $this->roundTripCryptString($str); 02771 return $str; 02772 } else return FALSE; // Decoding check failed! Original string not produced by this server! 02773 } else { 02774 $str = $string; 02775 $str = $this->roundTripCryptString($str); 02776 $str = base64_encode($str); 02777 $newHash = substr(md5($this->TYPO3_CONF_VARS['SYS']['encryptionKey'].':'.$str),0,10); 02778 return $newHash.':'.$str; 02779 } 02780 } 02781 02789 function roundTripCryptString($string) { 02790 $out = ''; 02791 $strLen = strlen($string); 02792 $cryptLen = strlen($this->TYPO3_CONF_VARS['SYS']['encryptionKey']); 02793 02794 for ($a=0; $a < $strLen; $a++) { 02795 $xorVal = $cryptLen>0 ? ord($this->TYPO3_CONF_VARS['SYS']['encryptionKey']{($a%$cryptLen)}) : 255; 02796 $out.= chr(ord($string{$a}) ^ $xorVal); 02797 } 02798 02799 return $out; 02800 } 02801 02809 function checkFileInclude($incFile) { 02810 return !$this->TYPO3_CONF_VARS['FE']['noPHPscriptInclude'] 02811 || substr($incFile,0,14)=='media/scripts/' 02812 || substr($incFile,0,4+strlen(TYPO3_mainDir))==TYPO3_mainDir.'ext/' 02813 || substr($incFile,0,7+strlen(TYPO3_mainDir))==TYPO3_mainDir.'sysext/' 02814 || substr($incFile,0,14)=='typo3conf/ext/'; 02815 } 02816 02824 function newCObj() { 02825 $this->cObj =t3lib_div::makeInstance('tslib_cObj'); 02826 $this->cObj->start($this->page,'pages'); 02827 } 02828 02837 function setAbsRefPrefix() { 02838 if ($this->absRefPrefix) { 02839 $this->content = str_replace('"media/', '"'.$this->absRefPrefix.'media/', $this->content); 02840 $this->content = str_replace('"fileadmin/', '"'.$this->absRefPrefix.'fileadmin/', $this->content); 02841 } 02842 } 02843 02851 function baseUrlWrap($url) { 02852 if ($this->baseUrl) { 02853 $urlParts = parse_url($url); 02854 if (!strlen($urlParts['scheme']) && $url{0}!=='/') { 02855 $url = $this->baseUrl.$url; 02856 } 02857 } 02858 return $url; 02859 } 02860 02870 function printError($label,$header='Error!') { 02871 t3lib_timeTrack::debug_typo3PrintError($header,$label,0,t3lib_div::getIndpEnv('TYPO3_SITE_URL')); 02872 } 02873 02881 function updateMD5paramsRecord($hash) { 02882 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_md5params', 'md5hash="'.$GLOBALS['TYPO3_DB']->quoteStr($hash, 'cache_md5params').'"', array('tstamp' => time())); 02883 } 02884 02892 function tidyHTML($content) { 02893 if ($this->TYPO3_CONF_VARS['FE']['tidy'] && $this->TYPO3_CONF_VARS['FE']['tidy_path']) { 02894 $oldContent = $content; 02895 $fname = t3lib_div::tempnam('Typo3_Tidydoc_'); // Create temporary name 02896 @unlink ($fname); // Delete if exists, just to be safe. 02897 $fp = fopen ($fname,'wb'); // Open for writing 02898 fputs ($fp, $content); // Put $content 02899 @fclose ($fp); // Close 02900 02901 exec ($this->TYPO3_CONF_VARS['FE']['tidy_path'].' '.$fname, $output); // run the $content through 'tidy', which formats the HTML to nice code. 02902 @unlink ($fname); // Delete the tempfile again 02903 $content = implode(chr(10),$output); 02904 if (!trim($content)) { 02905 $content = $oldContent; // Restore old content due empty return value. 02906 $GLOBALS['TT']->setTSlogMessage('"tidy" returned an empty value!',2); 02907 } 02908 $GLOBALS['TT']->setTSlogMessage('"tidy" content lenght: '.strlen($content),0); 02909 } 02910 return $content; 02911 } 02912 02918 function prefixLocalAnchorsWithScript() { 02919 $scriptPath = substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL'))); 02920 $this->content = eregi_replace('(<(a|area)[[:space:]]+href=")(#[^"]*")','\1'.htmlspecialchars($scriptPath).'\3',$this->content); 02921 } 02922 02923 02924 02925 02926 02927 02928 02929 02930 02931 02932 02933 02934 02935 02936 02937 02938 02939 02940 02941 02942 02943 02944 02945 02946 02947 02948 02949 02950 /******************************************** 02951 * 02952 * Various external API functions - for use in plugins etc. 02953 * 02954 *******************************************/ 02955 02956 02962 function getStorageSiterootPids() { 02963 $res=array(); 02964 reset($this->rootLine); 02965 while(list(,$rC)=each($this->rootLine)) { 02966 if (!$res['_STORAGE_PID']) $res['_STORAGE_PID']=intval($rC['storage_pid']); 02967 if (!$res['_SITEROOT']) $res['_SITEROOT']=$rC['is_siteroot']?intval($rC['uid']):0; 02968 } 02969 return $res; 02970 } 02971 02977 function getPagesTSconfig() { 02978 if (!is_array($this->pagesTSconfig)) { 02979 reset($this->rootLine); 02980 $TSdataArray = array(); 02981 $TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig']; // Setting default configuration: 02982 while(list($k,$v)=each($this->rootLine)) { 02983 $TSdataArray[]=$v['TSconfig']; 02984 } 02985 // Parsing the user TS (or getting from cache) 02986 $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray); 02987 $userTS = implode(chr(10).'[GLOBAL]'.chr(10),$TSdataArray); 02988 $hash = md5('pageTS:'.$userTS); 02989 $cachedContent = $this->sys_page->getHash($hash,0); 02990 if (isset($cachedContent)) { 02991 $this->pagesTSconfig = unserialize($cachedContent); 02992 } else { 02993 $parseObj = t3lib_div::makeInstance('t3lib_TSparser'); 02994 $parseObj->parse($userTS); 02995 $this->pagesTSconfig = $parseObj->setup; 02996 $this->sys_page->storeHash($hash,serialize($this->pagesTSconfig),'PAGES_TSconfig'); 02997 } 02998 } 02999 return $this->pagesTSconfig; 03000 } 03001 03010 function setJS($key,$content='') { 03011 if ($key) { 03012 switch($key) { 03013 case 'mouseOver': 03014 $this->additionalJavaScript[$key]= 03015 ' // JS function for mouse-over 03016 function over(name,imgObj) { // 03017 if (version == "n3" && document[name]) {document[name].src = eval(name+"_h.src");} 03018 else if (imgObj) {imgObj.src = eval(name+"_h.src");} 03019 } 03020 // JS function for mouse-out 03021 function out(name,imgObj) { // 03022 if (version == "n3" && document[name]) {document[name].src = eval(name+"_n.src");} 03023 else if (imgObj) {imgObj.src = eval(name+"_n.src");} 03024 }'; 03025 break; 03026 case 'openPic': 03027 $this->additionalJavaScript[$key]= 03028 ' function openPic(url,winName,winParams) { // 03029 var theWindow = window.open(url,winName,winParams); 03030 if (theWindow) {theWindow.focus();} 03031 }'; 03032 break; 03033 default: 03034 $this->additionalJavaScript[$key]=$content; 03035 break; 03036 } 03037 } 03038 } 03039 03048 function setCSS($key,$content) { 03049 if ($key) { 03050 switch($key) { 03051 default: 03052 $this->additionalCSS[$key]=$content; 03053 break; 03054 } 03055 } 03056 } 03057 03063 function make_seed() { 03064 list($usec, $sec) = explode(' ', microtime()); 03065 $seedV = (float)$sec + ((float)$usec * 100000); 03066 srand($seedV); 03067 } 03068 03076 function uniqueHash($str='') { 03077 return md5($this->uniqueString.'_'.$str.$this->uniqueCounter++); 03078 } 03079 03085 function set_no_cache() { 03086 $this->no_cache = 1; 03087 } 03088 03095 function set_cache_timeout_default($seconds) { 03096 $this->cacheTimeOutDefault = intval($seconds); 03097 } 03098 03111 function plainMailEncoded($email,$subject,$message,$headers='') { 03112 $urlmode=$this->config['config']['notification_email_urlmode']; // '76', 'all', '' 03113 03114 if ($urlmode) { 03115 $message=t3lib_div::substUrlsInPlainText($message,$urlmode); 03116 } 03117 03118 t3lib_div::plainMailEncoded( 03119 $email, 03120 $subject, 03121 $message, 03122 $headers, 03123 $this->config['config']['notification_email_encoding'], 03124 $this->config['config']['notification_email_charset']?$this->config['config']['notification_email_charset']:'ISO-8859-1' 03125 ); 03126 } 03127 03128 03129 03130 03131 03132 03133 03134 03135 03136 03137 03138 03139 03140 /************************** 03141 * 03142 * Localization 03143 * 03144 **************************/ 03145 03152 function sL($input) { 03153 if (strcmp(substr($input,0,4),'LLL:')) { 03154 $t = explode('|',$input); 03155 return $t[$this->langSplitIndex] ? $t[$this->langSplitIndex] : $t[0]; 03156 } else { 03157 if (!isset($this->LL_labels_cache[$this->lang][$input])) { // If cached label 03158 $restStr = trim(substr($input,4)); 03159 $extPrfx=''; 03160 if (!strcmp(substr($restStr,0,4),'EXT:')) { 03161 $restStr = trim(substr($restStr,4)); 03162 $extPrfx='EXT:'; 03163 } 03164 $parts = explode(':',$restStr); 03165 $parts[0]=$extPrfx.$parts[0]; 03166 if (!isset($this->LL_files_cache[$parts[0]])) { // Getting data if not cached 03167 $this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]); 03168 } 03169 $this->LL_labels_cache[$this->lang][$input] = $this->csConv($this->getLLL($parts[1],$this->LL_files_cache[$parts[0]])); 03170 } 03171 return $this->LL_labels_cache[$this->lang][$input]; 03172 } 03173 } 03174 03181 function readLLfile($fileRef) { 03182 $file = t3lib_div::getFileAbsFileName($fileRef); 03183 if (@is_file($file)) { 03184 include($file); 03185 } 03186 return is_array($LOCAL_LANG)?$LOCAL_LANG:array(); 03187 } 03188 03196 function getLLL($index,$LOCAL_LANG) { 03197 if (strcmp($LOCAL_LANG[$this->lang][$index],'')) { 03198 return $LOCAL_LANG[$this->lang][$index]; 03199 } else { 03200 return $LOCAL_LANG['default'][$index]; 03201 } 03202 } 03203 03210 function initLLvars() { 03211 03212 // Setting language key and split index: 03213 $this->lang = $this->config['config']['language'] ? $this->config['config']['language'] : 'default'; 03214 03215 $ls = explode('|',TYPO3_languages); 03216 while(list($i,$v)=each($ls)) { 03217 if ($v==$this->lang) {$this->langSplitIndex=$i; break;} 03218 } 03219 03220 // Setting charsets: 03221 $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. 03222 $this->metaCharset = $this->csConvObj->parse_charset($this->config['config']['metaCharset'] ? $this->config['config']['metaCharset'] : $this->renderCharset); // Output charset of HTML page. 03223 $this->labelsCharset = $this->csConvObj->parse_charset($this->csConvObj->charSetArray[$this->lang] ? $this->csConvObj->charSetArray[$this->lang] : 'iso-8859-1'); 03224 if ($this->renderCharset != $this->labelsCharset) { 03225 $this->convCharsetToFrom = array( 03226 'from' => $this->labelsCharset, 03227 'to' => $this->renderCharset 03228 ); 03229 } 03230 } 03231 03244 function csConv($str,$from='') { 03245 if ($from) { 03246 $output = $this->csConvObj->conv($str,$this->csConvObj->parse_charset($from),$this->renderCharset,1); 03247 return $output ? $output : $str; 03248 } elseif (is_array($this->convCharsetToFrom)) { 03249 return $this->csConvObj->conv($str,$this->convCharsetToFrom['from'],$this->convCharsetToFrom['to'],1); 03250 } else { 03251 return $str; 03252 } 03253 } 03254 03262 function convOutputCharset($content,$label) { 03263 if ($this->renderCharset != $this->metaCharset) { 03264 $content = $this->csConvObj->conv($content,$this->renderCharset,$this->metaCharset,TRUE); 03265 } 03266 03267 return $content; 03268 } 03269 03275 function convPOSTCharset() { 03276 if ($this->renderCharset != $this->metaCharset && is_array($_POST) && count($_POST)) { 03277 $this->csConvObj->convArray($_POST,$this->metaCharset,$this->renderCharset); 03278 $GLOBALS['HTTP_POST_VARS'] = $_POST; 03279 } 03280 } 03281 } 03282 03283 03284 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']) { 03285 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']); 03286 } 03287 ?>