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