00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00213 class tslib_fe {
00214
00215
00216 var $id='';
00217 var $type='';
00218 var $idParts=array();
00219 var $cHash='';
00220 var $no_cache='';
00221 var $rootLine='';
00222 var $page='';
00223 var $contentPid=0;
00224 var $sys_page='';
00225 var $jumpurl='';
00226 var $pageNotFound=0;
00227 var $domainStartPage=0;
00228 var $pageAccessFailureHistory=array();
00229 var $MP='';
00230 var $RDCT='';
00231 var $page_cache_reg1=0;
00232 var $siteScript='';
00233
00234
00235 var $fe_user='';
00236 var $loginUser='';
00237 var $gr_list='';
00238 var $beUserLogin='';
00239 var $workspacePreview='';
00240 var $loginAllowedInBranch = TRUE;
00241 var $ADMCMD_preview_BEUSER_uid = 0;
00242
00243
00244 var $fePreview='';
00245 var $showHiddenPage='';
00246 var $showHiddenRecords='';
00247 var $simUserGroup='0';
00248
00249
00250 var $TYPO3_CONF_VARS=array();
00251 var $config='';
00252 var $TCAcachedExtras=array();
00253
00254
00255 var $tmpl='';
00256 var $cacheTimeOutDefault='';
00257 var $cacheContentFlag='';
00258 var $cacheExpires=0;
00259 var $isClientCachable=FALSE;
00260 var $all='';
00261 var $sPre='';
00262 var $pSetup='';
00263 var $newHash='';
00264 var $getMethodUrlIdToken='';
00265 var $no_CacheBeforePageGen='';
00266 var $tempContent = FALSE;
00267 var $forceTemplateParsing='';
00268 var $cHash_array=array();
00269 var $hash_base='';
00270 var $pagesTSconfig='';
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 var $defaultBodyTag='<body>';
00282 var $additionalHeaderData=array();
00283 var $additionalJavaScript=array();
00284 var $additionalCSS=array();
00285 var $JSeventFuncCalls = array(
00286 'onmousemove' => array(),
00287 'onmouseup' => array(),
00288 'onload' => array(),
00289 );
00290 var $JSCode='';
00291 var $JSImgCode='';
00292 var $divSection='';
00293
00294
00295 var $debug='';
00296 var $intTarget='';
00297 var $extTarget='';
00298 var $MP_defaults=array();
00299 var $spamProtectEmailAddresses=0;
00300 var $absRefPrefix='';
00301 var $absRefPrefix_force=0;
00302 var $compensateFieldWidth='';
00303 var $lockFilePath='';
00304 var $ATagParams='';
00305 var $sWordRegEx='';
00306 var $sWordList='';
00307 var $linkVars='';
00308 var $excludeCHashVars='';
00309 var $displayEditIcons='';
00310 var $displayFieldEditIcons='';
00311 var $sys_language_uid=0;
00312 var $sys_language_mode='';
00313 var $sys_language_content=0;
00314 var $sys_language_contentOL=0;
00315 var $sys_language_isocode = '';
00316
00317
00318 var $applicationData=Array();
00319 var $register=Array();
00320 var $registerStack=Array();
00321 var $cObjectDepthCounter = 50;
00322 var $recordRegister = Array();
00323 var $currentRecord = '';
00324 var $accessKey =array();
00325 var $imagesOnPage=array();
00326 var $lastImageInfo=array();
00327 var $uniqueCounter=0;
00328 var $uniqueString='';
00329 var $indexedDocTitle='';
00330 var $altPageTitle='';
00331 var $pEncAllowedParamNames=array();
00332 var $baseUrl='';
00333 var $anchorPrefix='';
00334
00335
00336 var $cObj ='';
00337
00338
00339 var $content='';
00340
00341
00342 var $clientInfo='';
00343 var $scriptParseTime=0;
00344 var $TCAloaded = 0;
00345
00346
00347 var $csConvObj;
00348 var $defaultCharSet = 'iso-8859-1';
00349 var $renderCharset='';
00350 var $metaCharset='';
00351 var $localeCharset='';
00352
00353
00354 var $lang='';
00355 var $langSplitIndex=0;
00356 var $labelsCharset='';
00357 var $convCharsetToFrom='';
00358 var $LL_labels_cache=array();
00359 var $LL_files_cache=array();
00360
00361
00362
00363
00364
00382 function tslib_fe($TYPO3_CONF_VARS, $id, $type, $no_cache='', $cHash='', $jumpurl='',$MP='',$RDCT='') {
00383
00384
00385 $this->TYPO3_CONF_VARS = $TYPO3_CONF_VARS;
00386 $this->id = $id;
00387 $this->type = $type;
00388 $this->no_cache = $no_cache ? 1 : 0;
00389 $this->cHash = $cHash;
00390 $this->jumpurl = $jumpurl;
00391 $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? (string)$MP : '';
00392 $this->RDCT = $RDCT;
00393 $this->clientInfo = t3lib_div::clientInfo();
00394 $this->uniqueString=md5(microtime());
00395
00396 $this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
00397
00398
00399 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'])) {
00400 $_params = array('pObj' => &$this);
00401 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef) {
00402 t3lib_div::callUserFunction($_funcRef,$_params,$this);
00403 }
00404 }
00405 }
00406
00415 function connectToMySQL() {
00416 $this->connectToDB();
00417 }
00418
00425 function connectToDB() {
00426 if ($GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
00427 if (!TYPO3_db) {
00428 $this->printError('No database selected','Database Error');
00429
00430 echo '<script type="text/javascript">
00431
00432 window.location.href = "'.TYPO3_mainDir.'install/index.php?mode=123&step=1&password=joh316";
00433
00434 </script>';
00435 exit;
00436 } elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) {
00437 $this->printError('Cannot connect to the current database, "'.TYPO3_db.'"','Database Error');
00438 exit;
00439 }
00440 } else {
00441 if (!TYPO3_db) {
00442
00443 echo '<script type="text/javascript">
00444
00445 window.location.href = "'.TYPO3_mainDir.'install/index.php?mode=123&step=1&password=joh316";
00446
00447 </script>';
00448 exit;
00449 }
00450 $this->printError('The current username, password or host was not accepted when the connection to the database was attempted to be established!','Database Error');
00451 exit;
00452 }
00453
00454
00455
00456 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'])) {
00457 $_params = array('pObj' => &$this);
00458 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'] as $_funcRef) {
00459 t3lib_div::callUserFunction($_funcRef,$_params,$this);
00460 }
00461 }
00462 }
00463
00470 function sendRedirect() {
00471 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->RDCT, 'cache_md5params'));
00472 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00473 $this->updateMD5paramsRecord($this->RDCT);
00474 header('Location: '.$row['params']);
00475 exit;
00476 }
00477 }
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00508 function initFEuser() {
00509 $this->fe_user = t3lib_div::makeInstance('tslib_feUserAuth');
00510
00511 $this->fe_user->lockIP = $this->TYPO3_CONF_VARS['FE']['lockIP'];
00512 $this->fe_user->lockHashKeyWords = $this->TYPO3_CONF_VARS['FE']['lockHashKeyWords'];
00513 $this->fe_user->checkPid = $this->TYPO3_CONF_VARS['FE']['checkFeUserPid'];
00514 $this->fe_user->lifetime = intval($this->TYPO3_CONF_VARS['FE']['lifetime']);
00515 $this->fe_user->checkPid_value = $GLOBALS['TYPO3_DB']->cleanIntList(t3lib_div::_GP('pid'));
00516
00517
00518 if (t3lib_div::_GP('FE_SESSION_KEY')) {
00519 $fe_sParts = explode('-',t3lib_div::_GP('FE_SESSION_KEY'));
00520 if (!strcmp(md5($fe_sParts[0].'/'.$this->TYPO3_CONF_VARS['SYS']['encryptionKey']), $fe_sParts[1])) {
00521 $_COOKIE[$this->fe_user->name] = $fe_sParts[0];
00522 $this->fe_user->forceSetCookie = 1;
00523 }
00524 }
00525
00526 if ($this->TYPO3_CONF_VARS['FE']['dontSetCookie']) {
00527 $this->fe_user->dontSetCookie=1;
00528 }
00529
00530 $this->fe_user->start();
00531 $this->fe_user->unpack_uc('');
00532 $this->fe_user->fetchSessionData();
00533 $recs = t3lib_div::_GP('recs');
00534 if (is_array($recs)) {
00535 $this->fe_user->record_registration($recs, $this->TYPO3_CONF_VARS['FE']['maxSessionDataSize']);
00536 }
00537
00538
00539 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'])) {
00540 $_params = array('pObj' => &$this);
00541 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] as $_funcRef) {
00542 t3lib_div::callUserFunction($_funcRef,$_params,$this);
00543 }
00544 }
00545
00546
00547 if (is_array($this->fe_user->user) && $this->fe_user->user['uid'] && $this->fe_user->user['is_online']<($GLOBALS['EXEC_TIME']-60)) {
00548 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid='.intval($this->fe_user->user['uid']), array('is_online' => $GLOBALS['EXEC_TIME']));
00549 }
00550 }
00551
00558 function initUserGroups() {
00559
00560 $this->fe_user->showHiddenRecords = $this->showHiddenRecords;
00561 $this->fe_user->fetchGroupData();
00562
00563 if (is_array($this->fe_user->user) && count($this->fe_user->groupData['uid'])) {
00564 $this->loginUser=1;
00565 $this->gr_list = '0,-2';
00566 $gr_array = $this->fe_user->groupData['uid'];
00567 } else {
00568 $this->loginUser=0;
00569 $this->gr_list = '0,-1';
00570
00571 if ($this->loginAllowedInBranch) {
00572 $gr_array = $this->fe_user->groupData['uid'];
00573 } else {
00574 $gr_array = array();
00575 }
00576 }
00577
00578
00579 $gr_array = array_unique($gr_array);
00580 sort($gr_array);
00581 if (count($gr_array)) {
00582 $this->gr_list.=','.implode(',',$gr_array);
00583 }
00584
00585 if ($this->fe_user->writeDevLog) t3lib_div::devLog('Valid usergroups for TSFE: '.$this->gr_list, 'tslib_fe');
00586 }
00587
00593 function isUserOrGroupSet() {
00594 return is_array($this->fe_user->user) || $this->gr_list!=='0,-1';
00595 }
00596
00618 function checkAlternativeIdMethods() {
00619
00620 $this->siteScript = t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT');
00621
00622
00623 if ($this->siteScript && substr($this->siteScript,0,9)!='index.php') {
00624 $uParts = parse_url($this->siteScript);
00625 $fI = t3lib_div::split_fileref($uParts['path']);
00626
00627 if (!$fI['path'] && $fI['file'] && substr($fI['file'],-5)=='.html') {
00628 $parts = explode('.',$fI['file']);
00629 $pCount = count($parts);
00630 if ($pCount>2) {
00631 $this->type = intval($parts[$pCount-2]);
00632 $this->id = $parts[$pCount-3];
00633 } else {
00634 $this->type = 0;
00635 $this->id = $parts[0];
00636 }
00637 }
00638 }
00639
00640
00641 if (t3lib_div::getIndpEnv('PATH_INFO')) {
00642 $parts=t3lib_div::trimExplode('/',t3lib_div::getIndpEnv('PATH_INFO'),1);
00643 $parts[]='html';
00644 $pCount = count($parts);
00645 if ($pCount>2) {
00646 $this->type = intval($parts[$pCount-2]);
00647 $this->id = $parts[$pCount-3];
00648 } else {
00649 $this->type = 0;
00650 $this->id = $parts[0];
00651 }
00652 $this->absRefPrefix_force=1;
00653 }
00654
00655
00656 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'])) {
00657 $_params = array('pObj' => &$this);
00658 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef) {
00659 t3lib_div::callUserFunction($_funcRef,$_params,$this);
00660 }
00661 }
00662 }
00663
00670 function clear_preview() {
00671 $this->showHiddenPage = 0;
00672 $this->showHiddenRecords = 0;
00673 $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME'];
00674 $this->fePreview = 0;
00675 }
00676
00683 function determineId() {
00684
00685
00686 $this->setIDfromArgV();
00687
00688
00689 $GLOBALS['TT']->push('beUserLogin','');
00690 if ($this->beUserLogin || $this->doWorkspacePreview()) {
00691
00692
00693 if ($this->beUserLogin) {
00694 $this->fePreview = $GLOBALS['BE_USER']->extGetFeAdminValue('preview') ? 1 : 0;
00695
00696
00697 if ($this->fePreview) {
00698 $fe_user_OLD_USERGROUP = $this->fe_user->user['usergroup'];
00699
00700 $this->showHiddenPage = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenPages');
00701 $this->showHiddenRecords = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenRecords');
00702
00703 $simTime = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateDate');
00704 if ($simTime) $GLOBALS['SIM_EXEC_TIME']=$simTime;
00705
00706 $simUserGroup = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateUserGroup');
00707 $this->simUserGroup = $simUserGroup;
00708 if ($simUserGroup) $this->fe_user->user['usergroup']=$simUserGroup;
00709 if (!$simUserGroup && !$simTime && !$this->showHiddenPage && !$this->showHiddenRecords) {
00710 $this->fePreview=0;
00711 }
00712 }
00713 }
00714
00715 if ($this->id) {
00716
00717
00718
00719 $idQ = t3lib_div::testInt($this->id) ? 'uid='.intval($this->id) : 'alias='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->id, 'pages').' AND pid>=0';
00720 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('hidden', 'pages', $idQ.' AND hidden!=0 AND deleted=0');
00721 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
00722 $this->fePreview = 1;
00723 $this->showHiddenPage = 1;
00724 }
00725
00726
00727 if (!$this->fePreview && $this->whichWorkspace()===0) {
00728
00729
00730 $temp_sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
00731 $temp_sys_page->init($this->showHiddenPage);
00732
00733
00734 if (!count($temp_sys_page->getRootLine($this->id,$this->MP)) && $temp_sys_page->error_getRootLine_failPid==-1) {
00735
00736
00737 $temp_sys_page->versioningPreview = TRUE;
00738 if (count($temp_sys_page->getRootLine($this->id,$this->MP))) {
00739
00740 $this->fePreview = 1;
00741 }
00742 }
00743 }
00744 }
00745
00746
00747 if (($GLOBALS['BE_USER']->user['workspace_preview'] || t3lib_div::_GP('ADMCMD_view') || $this->doWorkspacePreview()) && ($this->whichWorkspace()===-1 || $this->whichWorkspace()>0)) {
00748 $this->fePreview = 2;
00749 }
00750
00751
00752 if ($this->fePreview) {
00753 $this->set_no_cache();
00754 }
00755 }
00756 $GLOBALS['TT']->pull();
00757
00758
00759 $this->fetch_the_id();
00760
00761
00762 if ($this->beUserLogin && $this->fePreview) {
00763 if (!$GLOBALS['BE_USER']->doesUserHaveAccess($this->page,1)) {
00764
00765
00766 $this->clear_preview();
00767 $this->fe_user->user['usergroup'] = $fe_user_OLD_USERGROUP;
00768
00769
00770 $this->fetch_the_id();
00771 }
00772 }
00773
00774
00775 $this->loginAllowedInBranch = $this->checkIfLoginAllowedInBranch();
00776 if (!$this->loginAllowedInBranch) {
00777 if ($this->isUserOrGroupSet()) {
00778
00779
00780 unset($this->fe_user->user);
00781 $this->gr_list = '0,-1';
00782
00783
00784 $this->fetch_the_id();
00785 }
00786 }
00787
00788
00789 $this->id = $this->contentPid = intval($this->id);
00790 $this->type = intval($this->type);
00791
00792
00793 if ($this->fePreview) {
00794 if ($this->page['_ORIG_pid']==-1 && $this->page['t3ver_swapmode']==0) {
00795
00796 $this->contentPid = $this->page['_ORIG_uid'];
00797 }
00798 }
00799
00800
00801 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) {
00802 $_params = array('pObj' => &$this);
00803 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef) {
00804 t3lib_div::callUserFunction($_funcRef,$_params,$this);
00805 }
00806 }
00807 }
00808
00817 function fetch_the_id() {
00818 $GLOBALS['TT']->push('fetch_the_id initialize/','');
00819
00820
00821 $this->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
00822 $this->sys_page->versioningPreview = $this->fePreview ? TRUE : FALSE;
00823 $this->sys_page->versioningWorkspaceId = $this->whichWorkspace();
00824 $this->sys_page->init($this->showHiddenPage);
00825
00826
00827 $this->initUserGroups();
00828
00829
00830 $this->setSysPageWhereClause();
00831
00832
00833 $pParts = explode('.',$this->id);
00834 $this->id = $pParts[0];
00835 if (isset($pParts[1])) {$this->type=$pParts[1];}
00836
00837
00838 $this->idParts = explode(',',$this->id);
00839
00840
00841 list($pgID,$SSD_p)=explode('+',$this->idParts[0],2);
00842 if ($SSD_p) { $this->idPartsAnalyze($SSD_p); }
00843 $this->id = $pgID;
00844
00845
00846 $this->checkAndSetAlias();
00847
00848
00849 $this->id = intval($this->id);
00850 $this->type = intval($this->type);
00851 $GLOBALS['TT']->pull();
00852
00853
00854 $GLOBALS['TT']->push('fetch_the_id domain/','');
00855 $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']);
00856 if (!$this->id) {
00857 if ($this->domainStartPage) {
00858 $this->id = $this->domainStartPage;
00859 } else {
00860 $theFirstPage = $this->sys_page->getFirstWebPage($this->id);
00861 if ($theFirstPage) {
00862 $this->id = $theFirstPage['uid'];
00863 } else {
00864 $this->printError('No pages are found on the rootlevel!');
00865 exit;
00866 }
00867 }
00868 }
00869 $GLOBALS['TT']->pull();
00870
00871 $GLOBALS['TT']->push('fetch_the_id rootLine/','');
00872 $requestedId = $this->id;
00873 $this->getPageAndRootlineWithDomain($this->domainStartPage);
00874 $GLOBALS['TT']->pull();
00875
00876 if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) {
00877 $pNotFoundMsg = array(
00878 1 => 'ID was not an accessible page',
00879 2 => 'Subsection was found and not accessible',
00880 3 => 'ID was outside the domain',
00881 4 => 'The requested page alias does not exist'
00882 );
00883 $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]);
00884 }
00885
00886
00887 if ($this->page['no_cache']) {
00888 $this->set_no_cache();
00889 }
00890
00891
00892 $this->register['SYS_LASTCHANGED'] = intval($this->page['tstamp']);
00893 if ($this->register['SYS_LASTCHANGED'] < intval($this->page['SYS_LASTCHANGED'])) {
00894 $this->register['SYS_LASTCHANGED'] = intval($this->page['SYS_LASTCHANGED']);
00895 }
00896 }
00897
00911 function getPageAndRootline() {
00912 $this->page = $this->sys_page->getPage($this->id);
00913 if (!count($this->page)) {
00914
00915 $this->pageNotFound=1;
00916 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);
00917 if (count($this->rootLine)) {
00918 $c=count($this->rootLine)-1;
00919 while($c>0) {
00920
00921
00922 $this->pageAccessFailureHistory['direct_access'][] = $this->rootLine[$c];
00923
00924
00925 $c--;
00926 $this->id = $this->rootLine[$c]['uid'];
00927 $this->page = $this->sys_page->getPage($this->id);
00928 if (count($this->page)){ break; }
00929 }
00930 }
00931
00932 if (!count($this->page)) {
00933 if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) {
00934 $this->pageNotFoundAndExit('The requested page does not exist!');
00935 } else {
00936 $this->printError('The requested page does not exist!');
00937 exit;
00938 }
00939 }
00940 }
00941
00942
00943 if ($this->page['doktype'] == 199) {
00944 if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) {
00945 $this->pageNotFoundAndExit('The requested page does not exist!');
00946 } else {
00947 $this->printError('The requested page does not exist!');
00948 exit;
00949 }
00950 }
00951
00952
00953 if ($this->page['doktype']==4) {
00954 $this->MP = '';
00955 $this->page = $this->getPageShortcut($this->page['shortcut'],$this->page['shortcut_mode'],$this->page['uid']);
00956 $this->id = $this->page['uid'];
00957 }
00958
00959
00960 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);
00961
00962
00963 if (!count($this->rootLine)) {
00964 $this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')');
00965 exit;
00966 }
00967
00968
00969 if ($this->checkRootlineForIncludeSection()) {
00970 if (!count($this->rootLine)) {
00971 $this->printError('The requested page was not accessible!');
00972 exit;
00973 } else {
00974 $el = reset($this->rootLine);
00975 $this->id = $el['uid'];
00976 $this->page = $this->sys_page->getPage($this->id);
00977 $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);
00978 }
00979 }
00980 }
00981
00994 function getPageShortcut($SC,$mode,$thisUid,$itera=20,$pageLog=array()) {
00995 $idArray = t3lib_div::intExplode(',',$SC);
00996
00997
00998 switch($mode) {
00999 case 1:
01000 case 2:
01001 $pageArray = $this->sys_page->getMenu($idArray[0]?$idArray[0]:$thisUid,'*','sorting','AND pages.doktype<199 AND pages.doktype!=6');
01002 $pO = 0;
01003 if ($mode==2 && count($pageArray)) {
01004 $this->make_seed();
01005 $randval = intval(rand(0,count($pageArray)-1));
01006 $pO = $randval;
01007 }
01008 $c = 0;
01009 reset($pageArray);
01010 while(list(,$pV)=each($pageArray)) {
01011 if ($c==$pO) {
01012 $page = $pV;
01013 break;
01014 }
01015 $c++;
01016 }
01017 break;
01018 default:
01019 $page = $this->sys_page->getPage($idArray[0]);
01020 break;
01021 }
01022
01023
01024 if ($page['doktype']==4) {
01025 if (!in_array($page['uid'],$pageLog) && $itera>0) {
01026 $pageLog[] = $page['uid'];
01027 $page = $this->getPageShortcut($page['shortcut'],$page['shortcut_mode'],$page['uid'],$itera-1,$pageLog);
01028 } else {
01029 $pageLog[] = $page['uid'];
01030 $this->printError('Page shortcuts were looping in uids '.implode(',',$pageLog).'...!');
01031 exit;
01032 }
01033 }
01034
01035 return $page;
01036 }
01037
01044 function checkRootlineForIncludeSection() {
01045 $c=count($this->rootLine);
01046 $removeTheRestFlag=0;
01047
01048 for ($a=0;$a<$c;$a++) {
01049 if (!$this->checkPagerecordForIncludeSection($this->rootLine[$a])) {
01050
01051 $this->pageAccessFailureHistory['sub_section'][] = $this->rootLine[$a];
01052 $removeTheRestFlag=1;
01053 }
01054 if ($this->rootLine[$a]['doktype']==6) {
01055 if ($this->beUserLogin) {
01056 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($this->id).' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1));
01057 list($isPage) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
01058 if (!$isPage) $removeTheRestFlag=1;
01059 } else {
01060 $removeTheRestFlag=1;
01061 }
01062 }
01063 if ($removeTheRestFlag) {
01064 $this->pageNotFound=2;
01065 unset($this->rootLine[$a]);
01066 }
01067 }
01068 return $removeTheRestFlag;
01069 }
01070
01081 function checkEnableFields($row,$bypassGroupCheck=FALSE) {
01082 if ((!$row['hidden'] || $this->showHiddenPage)
01083 && $row['starttime']<=$GLOBALS['SIM_EXEC_TIME']
01084 && ($row['endtime']==0 || $row['endtime']>$GLOBALS['SIM_EXEC_TIME'])
01085 && ($bypassGroupCheck || $this->checkPageGroupAccess($row))
01086 ) { return TRUE; }
01087 }
01088
01097 function checkPageGroupAccess($row, $groupList=NULL) {
01098 if(is_null($groupList)) {
01099 $groupList = $this->gr_list;
01100 }
01101 if(!is_array($groupList)) {
01102 $groupList = explode(',', $groupList);
01103 }
01104 $pageGroupList = explode(',', $row['fe_group'] ? $row['fe_group'] : 0);
01105 return count(array_intersect($groupList, $pageGroupList)) > 0;
01106 }
01107
01116 function checkPagerecordForIncludeSection($row) {
01117 return (!$row['extendToSubpages'] || $this->checkEnableFields($row)) ? 1 : 0;
01118 }
01119
01125 function checkIfLoginAllowedInBranch() {
01126
01127
01128 $c = count($this->rootLine);
01129 $disable = FALSE;
01130
01131
01132 for ($a=0; $a<$c; $a++) {
01133
01134
01135 if ($this->rootLine[$a]['fe_login_mode'] > 0) {
01136
01137
01138 $disable = (int)$this->rootLine[$a]['fe_login_mode'] === 1 ? TRUE : FALSE;
01139 }
01140 }
01141
01142 return !$disable;
01143 }
01144
01150 function getPageAccessFailureReasons() {
01151 $output = array();
01152
01153 $combinedRecords = array_merge(
01154 is_array($this->pageAccessFailureHistory['direct_access']) ? $this->pageAccessFailureHistory['direct_access'] : array(array('fe_group'=>0)),
01155 is_array($this->pageAccessFailureHistory['sub_section']) ? $this->pageAccessFailureHistory['sub_section'] : array()
01156 );
01157
01158 if (count($combinedRecords)) {
01159 foreach($combinedRecords as $k => $pagerec) {
01160
01161
01162 if (!$k || $pagerec['extendToSubpages']) {
01163 if ($pagerec['hidden']) $output['hidden'][$pagerec['uid']] = TRUE;
01164 if ($pagerec['starttime'] > $GLOBALS['SIM_EXEC_TIME']) $output['starttime'][$pagerec['uid']] = $pagerec['starttime'];
01165 if ($pagerec['endtime']!=0 && $pagerec['endtime'] <= $GLOBALS['SIM_EXEC_TIME']) $output['endtime'][$pagerec['uid']] = $pagerec['endtime'];
01166 if (!$this->checkPageGroupAccess($pagerec)) $output['fe_group'][$pagerec['uid']] = $pagerec['fe_group'];
01167 }
01168 }
01169 }
01170
01171 return $output;
01172 }
01173
01182 function setIDfromArgV() {
01183 if (!$this->id) {
01184 list($theAlias) = explode('&',t3lib_div::getIndpEnv('QUERY_STRING'));
01185 $theAlias = trim($theAlias);
01186 $this->id = $theAlias ? $theAlias : 0;
01187 }
01188 }
01189
01198 function getPageAndRootlineWithDomain($domainStartPage) {
01199 $this->getPageAndRootline();
01200
01201
01202 if ($domainStartPage && is_array($this->rootLine)) {
01203 reset ($this->rootLine);
01204 $idFound = 0;
01205 while(list($key,$val)=each($this->rootLine)) {
01206 if ($val['uid']==$domainStartPage) {
01207 $idFound=1;
01208 break;
01209 }
01210 }
01211 if (!$idFound) {
01212 $this->pageNotFound=3;
01213 $this->id = $domainStartPage;
01214 $this->getPageAndRootline();
01215 }
01216 }
01217 }
01218
01225 function setSysPageWhereClause() {
01226 $this->sys_page->where_hid_del.=' AND pages.doktype<200';
01227 $this->sys_page->where_groupAccess = $this->sys_page->getMultipleGroupsWhereClause('pages.fe_group', 'pages');
01228 }
01229
01237 function findDomainRecord($recursive=0) {
01238 if ($recursive) {
01239 $host = explode('.',t3lib_div::getIndpEnv('HTTP_HOST'));
01240 while(count($host)) {
01241 $pageUid = $this->sys_page->getDomainStartPage(implode('.',$host),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI'));
01242 if ($pageUid) return $pageUid; else array_shift($host);
01243 }
01244 return $pageUid;
01245 } else {
01246 return $this->sys_page->getDomainStartPage(t3lib_div::getIndpEnv('HTTP_HOST'),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI'));
01247 }
01248 }
01249
01257 function pageNotFoundAndExit($reason='', $header='') {
01258 $header = $header ? $header : $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'];
01259 $this->pageNotFoundHandler($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'], $header, $reason);
01260 exit;
01261 }
01262
01272 function pageNotFoundHandler($code, $header='', $reason='') {
01273
01274 if ($header) {header($header);}
01275
01276
01277 if (gettype($code)=='boolean' || !strcmp($code,1))