⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.tslib_fe.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
		$GLOBALS['TT']->pull();		$GLOBALS['TT']->push('fetch_the_id rootLine/','');		$requestedId = $this->id;		// We store the originally requested id		$this->getPageAndRootlineWithDomain($this->domainStartPage);		$GLOBALS['TT']->pull();		if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'])	{			$pNotFoundMsg = array(				1 => 'ID was not an accessible page',				2 => 'Subsection was found and not accessible',				3 => 'ID was outside the domain',				4 => 'The requested page alias does not exist'			);			$this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]);		}			// set no_cache if set		if ($this->page['no_cache'])	{			$this->set_no_cache();		}			// Init SYS_LASTCHANGED		$this->register['SYS_LASTCHANGED'] = intval($this->page['tstamp']);		if ($this->register['SYS_LASTCHANGED'] < intval($this->page['SYS_LASTCHANGED']))	{			$this->register['SYS_LASTCHANGED'] = intval($this->page['SYS_LASTCHANGED']);		}	}	/**	 * Gets the page and rootline arrays based on the id, $this->id	 *	 * If the id does not correspond to a proper page, the 'previous' valid page in the rootline is found	 * If the page is a shortcut (doktype=4), the ->id is loaded with that id	 *	 * Whether or not the ->id is changed to the shortcut id or the previous id in rootline (eg if a page is hidden), the ->page-array and ->rootline is found and must also be valid.	 *	 * Sets or manipulates internal variables such as: $this->id, $this->page, $this->rootLine, $this->MP, $this->pageNotFound	 *	 * @return	void	 * @access private	 */	function getPageAndRootline() {		$this->page = $this->sys_page->getPage($this->id);		if (!count($this->page))	{				// If no page, we try to find the page before in the rootLine.			$this->pageNotFound=1;			// Page is 'not found' in case the id itself was not an accessible page. code 1			$this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);			if (count($this->rootLine))	{				$c=count($this->rootLine)-1;				while($c>0)	{						// Add to page access failure history:					$this->pageAccessFailureHistory['direct_access'][] = $this->rootLine[$c];						// Decrease to next page in rootline and check the access to that, if OK, set as page record and ID value.					$c--;					$this->id = $this->rootLine[$c]['uid'];					$this->page = $this->sys_page->getPage($this->id);					if (count($this->page)){ break; }				}			}				// If still no page...			if (!count($this->page))	{				if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'])	{					$this->pageNotFoundAndExit('The requested page does not exist!');				} else {					$this->printError('The requested page does not exist!');					exit;				}			}		}			// Spacer is not accessible in frontend		if ($this->page['doktype'] == 199)	{			if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'])	{				$this->pageNotFoundAndExit('The requested page does not exist!');			} else {				$this->printError('The requested page does not exist!');				exit;			}		}			// Is the ID a link to another page??		if ($this->page['doktype']==4)	{			$this->MP = '';		// We need to clear MP if the page is a shortcut. Reason is if the short cut goes to another page, then we LEAVE the rootline which the MP expects.			$this->page = $this->getPageShortcut($this->page['shortcut'],$this->page['shortcut_mode'],$this->page['uid']);			$this->id = $this->page['uid'];		}			// Gets the rootLine		$this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);			// If not rootline we're off...		if (!count($this->rootLine))	{			$ws = $this->whichWorkspace();			if ($this->sys_page->error_getRootLine_failPid==-1 && $ws) {				$this->sys_page->versioningPreview = TRUE;				$this->versioningWorkspaceId = $ws;				$this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);			}			if (!count($this->rootLine))	{				$this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')');				exit;			}			$this->fePreview = 1;		}			// Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!)		if ($this->checkRootlineForIncludeSection())	{			if (!count($this->rootLine))	{				$this->printError('The requested page was not accessible!');				exit;			} else {				$el = reset($this->rootLine);				$this->id = $el['uid'];				$this->page = $this->sys_page->getPage($this->id);				$this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);			}		}	}	/**	 * Get page shortcut; Finds the records pointed to by input value $SC (the shortcut value)	 *	 * @param	integer		The value of the "shortcut" field from the pages record	 * @param	integer		The shortcut mode: 1 and 2 will select either first subpage or random subpage; the default is the page pointed to by $SC	 * @param	integer		The current page UID of the page which is a shortcut	 * @param	integer		Safety feature which makes sure that the function is calling itself recursively max 20 times (since this function can find shortcuts to other shortcuts to other shortcuts...)	 * @param	array		An array filled with previous page uids tested by the function - new page uids are evaluated against this to avoid going in circles.	 * @return	mixed		Returns the page record of the page that the shortcut pointed to.	 * @access private	 * @see getPageAndRootline()	 */	function getPageShortcut($SC,$mode,$thisUid,$itera=20,$pageLog=array())	{		$idArray = t3lib_div::intExplode(',',$SC);			// Find $page record depending on shortcut mode:		switch($mode)	{			case 1:			case 2:				$pageArray = $this->sys_page->getMenu($idArray[0]?$idArray[0]:$thisUid,'*','sorting','AND pages.doktype<199 AND pages.doktype!=6');				$pO = 0;				if ($mode==2 && count($pageArray))	{	// random					$this->make_seed();					$randval = intval(rand(0,count($pageArray)-1));					$pO = $randval;				}				$c = 0;				reset($pageArray);				while(list(,$pV)=each($pageArray))	{					if ($c==$pO)	{						$page = $pV;						break;					}					$c++;				}			break;			default:				$page = $this->sys_page->getPage($idArray[0]);			break;		}			// Check if short cut page was a shortcut itself, if so look up recursively:		if ($page['doktype']==4)	{			if (!in_array($page['uid'],$pageLog) && $itera>0)	{				$pageLog[] = $page['uid'];				$page = $this->getPageShortcut($page['shortcut'],$page['shortcut_mode'],$page['uid'],$itera-1,$pageLog);			} else {				$pageLog[] = $page['uid'];				$this->printError('Page shortcuts were looping in uids '.implode(',',$pageLog).'...!');				exit;			}		}			// Return resulting page:		return $page;	}	/**	 * Checks the current rootline for defined sections.	 *	 * @return	boolean	 * @access private	 */	function checkRootlineForIncludeSection()	{		$c=count($this->rootLine);		$removeTheRestFlag=0;		for ($a=0;$a<$c;$a++)	{			if (!$this->checkPagerecordForIncludeSection($this->rootLine[$a]))	{					// Add to page access failure history:				$this->pageAccessFailureHistory['sub_section'][] = $this->rootLine[$a];				$removeTheRestFlag=1;			}			if ($this->rootLine[$a]['doktype']==6)	{				if ($this->beUserLogin)	{	// If there is a backend user logged in, check if he has read access to the page:					$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($this->id).' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1));	// versionOL()?					list($isPage) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);					if (!$isPage)	$removeTheRestFlag=1;	// If there was no page selected, the user apparently did not have read access to the current PAGE (not position in rootline) and we set the remove-flag...				} else {	// Dont go here, if there is no backend user logged in.					$removeTheRestFlag=1;				}			}			if ($removeTheRestFlag)	{				$this->pageNotFound=2;			// Page is 'not found' in case a subsection was found and not accessible, code 2				unset($this->rootLine[$a]);			}		}		return $removeTheRestFlag;	}	/**	 * Checks page record for enableFields	 * Returns true if enableFields does not disable the page record.	 * Takes notice of the ->showHiddenPage flag and uses SIM_EXEC_TIME for start/endtime evaluation	 *	 * @param	array		The page record to evaluate (needs fields: hidden, starttime, endtime, fe_group)	 * @param	boolean		Bypass group-check	 * @return	boolean		True, if record is viewable.	 * @see tslib_cObj::getTreeList(), checkPagerecordForIncludeSection()	 */	function checkEnableFields($row,$bypassGroupCheck=FALSE)	{		if ((!$row['hidden'] || $this->showHiddenPage)			&& $row['starttime']<=$GLOBALS['SIM_EXEC_TIME']			&& ($row['endtime']==0 || $row['endtime']>$GLOBALS['SIM_EXEC_TIME'])			&& ($bypassGroupCheck || $this->checkPageGroupAccess($row))		) { return TRUE; }	}	/**	 * Check group access against a page record	 *	 * @param	array		The page record to evaluate (needs field: fe_group)	 * @param	mixed		List of group id's (comma list or array). Default is $this->gr_list	 * @return	boolean		True, if group access is granted.	 * @access private	 */	function checkPageGroupAccess($row, $groupList=NULL) {		if(is_null($groupList)) {			$groupList = $this->gr_list;		}		if(!is_array($groupList)) {			$groupList = explode(',', $groupList);		}		$pageGroupList = explode(',', $row['fe_group'] ? $row['fe_group'] : 0);		return count(array_intersect($groupList, $pageGroupList)) > 0;	}	/**	 * Checks page record for include section	 *	 * @param	array		The page record to evaluate (needs fields: extendToSubpages + hidden, starttime, endtime, fe_group)	 * @return	boolean		Returns true if either extendToSubpages is not checked or if the enableFields does not disable the page record.	 * @access private	 * @see checkEnableFields(), tslib_cObj::getTreeList(), checkRootlineForIncludeSection()	 */	function checkPagerecordForIncludeSection($row)	{		return (!$row['extendToSubpages'] || $this->checkEnableFields($row)) ? 1 : 0;	}	/**	 * Checks if logins are allowed in the current branch of the page tree. Traverses the full root line and returns TRUE if logins are OK, otherwise false (and then the login user must be unset!)	 *	 * @return	boolean		returns TRUE if logins are OK, otherwise false (and then the login user must be unset!)	 */	function checkIfLoginAllowedInBranch()	{			// Initialize:		$c = count($this->rootLine);		$disable = FALSE;			// Traverse root line from root and outwards:		for ($a=0; $a<$c; $a++)	{				// If a value is set for login state:			if ($this->rootLine[$a]['fe_login_mode'] > 0)	{					// Determine state from value:				$disable = (int)$this->rootLine[$a]['fe_login_mode'] === 1 ? TRUE : FALSE;			}		}		return !$disable;	}	/**	 * Analysing $this->pageAccessFailureHistory into a summary array telling which features disabled display and on which pages and conditions. That data can be used inside a page-not-found handler	 *	 * @return	array		Summary of why page access was not allowed.	 */	function getPageAccessFailureReasons()	{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -