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