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