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

📄 class.tslib_fe.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
		$output = array();		$combinedRecords = array_merge(			is_array($this->pageAccessFailureHistory['direct_access']) ? $this->pageAccessFailureHistory['direct_access'] : array(array('fe_group'=>0)),	// Adding fake first record for direct access if none, otherwise $k==0 below will be indicating a sub-section record to be first direct_access record which is of course false!			is_array($this->pageAccessFailureHistory['sub_section']) ? $this->pageAccessFailureHistory['sub_section'] : array()		);		if (count($combinedRecords))	{			foreach($combinedRecords as $k => $pagerec)	{				// If $k=0 then it is the very first page the original ID was pointing at and that will get a full check of course				// If $k>0 it is parent pages being tested. They are only significant for the access to the first page IF they had the extendToSubpages flag set, hence checked only then!				if (!$k || $pagerec['extendToSubpages'])	{					if ($pagerec['hidden'])	$output['hidden'][$pagerec['uid']] = TRUE;					if ($pagerec['starttime'] > $GLOBALS['SIM_EXEC_TIME'])	$output['starttime'][$pagerec['uid']] = $pagerec['starttime'];					if ($pagerec['endtime']!=0 && $pagerec['endtime'] <= $GLOBALS['SIM_EXEC_TIME'])	$output['endtime'][$pagerec['uid']] = $pagerec['endtime'];					if (!$this->checkPageGroupAccess($pagerec))	$output['fe_group'][$pagerec['uid']] = $pagerec['fe_group'];				}			}		}		return $output;	}	/**	 * This checks if there are ARGV-parameters in the QUERY_STRING and if so, those are used for the id	 * $this->id must be 'false' in order for any processing to happen in here	 * If an id/alias value is extracted from the QUERY_STRING it is set in $this->id	 *	 * @return	void	 * @access private	 */	function setIDfromArgV()	{		if (!$this->id)	{			list($theAlias) = explode('&',t3lib_div::getIndpEnv('QUERY_STRING'));			$theAlias = trim($theAlias);			$this->id = ($theAlias != '' && strpos($theAlias, '=') === false) ? $theAlias : 0;		}	}	/**	 * Gets ->page and ->rootline information based on ->id. ->id may change during this operation.	 * If not inside domain, then default to first page in domain.	 *	 * @param	integer		Page uid of the page where the found domain record is (pid of the domain record)	 * @return	void	 * @access private	 */	function getPageAndRootlineWithDomain($domainStartPage)	{		$this->getPageAndRootline();		// Checks if the $domain-startpage is in the rootLine. This is necessary so that references to page-id's from other domains are not possible.		if ($domainStartPage && is_array($this->rootLine)) {			reset ($this->rootLine);			$idFound = 0;			while(list($key,$val)=each($this->rootLine)) {				if ($val['uid']==$domainStartPage)	{					$idFound=1;					break;				}			}			if (!$idFound)	{				$this->pageNotFound=3;			// Page is 'not found' in case the id was outside the domain, code 3				$this->id = $domainStartPage;				$this->getPageAndRootline();		//re-get the page and rootline if the id was not found.			}		}	}	/**	 * Sets sys_page where-clause	 *	 * @return	void	 * @access private	 */	function setSysPageWhereClause()	{		$this->sys_page->where_hid_del.=' AND pages.doktype<200';		$this->sys_page->where_groupAccess = $this->sys_page->getMultipleGroupsWhereClause('pages.fe_group', 'pages');	}	/**	 * Looking up a domain record based on HTTP_HOST	 *	 * @param	boolean		If set, it looks "recursively" meaning that a domain like "123.456.typo3.com" would find a domain record like "typo3.com" if "123.456.typo3.com" or "456.typo3.com" did not exist.	 * @return	integer		Returns the page id of the page where the domain record was found.	 * @access private	 */	function findDomainRecord($recursive=0)	{		if ($recursive)	{			$host = explode('.',t3lib_div::getIndpEnv('HTTP_HOST'));			while(count($host))	{				$pageUid = $this->sys_page->getDomainStartPage(implode('.',$host),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI'));				if ($pageUid)	return $pageUid; else array_shift($host);			}			return $pageUid;		} else {			return $this->sys_page->getDomainStartPage(t3lib_div::getIndpEnv('HTTP_HOST'),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI'));		}	}	/**	 * Page-not-found handler for use in frontend plugins from extensions.	 *	 * @param	string		Reason text	 * @param	string		HTTP header to send	 * @return	void		Function exits.	 */	function pageNotFoundAndExit($reason='', $header='')	{		$header = $header ? $header : $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'];		$this->pageNotFoundHandler($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'], $header, $reason);		exit;	}	/**	 * Page not found handler.	 * Exits.	 *	 * @param	mixed		Which type of handling; If a true PHP-boolean or TRUE then a ->printError message is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.	 * @param	string		If set, this is passed directly to the PHP function, header()	 * @param	string		If set, error messages will also mention this as the reason for the page-not-found.	 * @return	void		(The function exits!)	 */	function pageNotFoundHandler($code, $header='', $reason='')	{			// Issue header in any case:		if ($header)	{			$headerArr = preg_split('/\r|\n/',$header,-1,PREG_SPLIT_NO_EMPTY);			foreach ($headerArr as $header)	{				header ($header);			}		}			// Convert $code in case it was written as a string (e.g. if edited in Install Tool)			// TODO: Once the Install Tool handles such data types correctly, this workaround should be removed again...		if (!strcasecmp($code,'TRUE'))	{ $code=TRUE; }			// Create response:		if (gettype($code)=='boolean' || !strcmp($code,1))	{	// Simply boolean; Just shows TYPO3 error page with reason:			$this->printError('The page did not exist or was inaccessible.'.($reason ? ' Reason: '.htmlspecialchars($reason) : ''));		} elseif (t3lib_div::isFirstPartOfStr($code,'USER_FUNCTION:')) {			$funcRef = trim(substr($code,14));			$params = array(				'currentUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),				'reasonText' => $reason,				'pageAccessFailureReasons' => $this->getPageAccessFailureReasons()			);			echo t3lib_div::callUserFunction($funcRef,$params,$this);		} elseif (t3lib_div::isFirstPartOfStr($code,'READFILE:')) {			$readFile = t3lib_div::getFileAbsFileName(trim(substr($code,9)));			if (@is_file($readFile))	{				$fileContent = t3lib_div::getUrl($readFile);				$fileContent = str_replace('###CURRENT_URL###', t3lib_div::getIndpEnv('REQUEST_URI'), $fileContent);				$fileContent = str_replace('###REASON###', htmlspecialchars($reason), $fileContent);				echo $fileContent;			} else {				$this->printError('Configuration Error: 404 page "'.$readFile.'" could not be found.');			}		} elseif (t3lib_div::isFirstPartOfStr($code,'REDIRECT:')) {			header('Location: '.t3lib_div::locationHeaderUrl(substr($code,9)));			exit;		} elseif (strlen($code))	{				// Check if URL is relative			$url_parts = parse_url($code);			if ($url_parts['host'] == '')	{				$url_parts['host'] = t3lib_div::getIndpEnv('HTTP_HOST');				$code = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . $code;				$checkBaseTag = false;			} else {				$checkBaseTag = true;			}				// Check recursion			if ($code == t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) {				if ($reason == '') {					$reason = 'Page cannot be found.';				}				$reason.= chr(10) . chr(10) . 'Additionally, ' . $code . ' was not found while trying to retrieve the error document.';				$this->printError('Reason: '.nl2br(htmlspecialchars($reason)));				exit();			}				// Prepare headers			$headerArr = array(				'User-agent: ' . t3lib_div::getIndpEnv('HTTP_USER_AGENT'),				'Referer: ' . t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')			);			$res = t3lib_div::getURL($code, 1, $headerArr);				// Header and content are separated by an empty line			list($header,$content) = split("\r\n\r\n", $res, 2);			$content.= "\r\n";			if (false === $res) {					// Last chance -- redirect				header('Location: '.t3lib_div::locationHeaderUrl($code));			} else {				$forwardHeaders = array(	// Forward these response headers to the client					'Content-Type:',				);				$headerArr = preg_split('/\r|\n/',$header,-1,PREG_SPLIT_NO_EMPTY);				foreach ($headerArr as $header)	{					foreach ($forwardHeaders as $h)	{						if (preg_match('/^'.$h.'/', $header))	{							header ($header);						}					}				}					// Put <base> if necesary				if ($checkBaseTag)	{						// If content already has <base> tag, we do not need to do anything					if (false === stristr($content, '<base '))	{							// Generate href for base tag						$base = $url_parts['scheme'] . '://';						if ($url_parts['user'] != '')	{							$base.= $url_parts['user'];							if ($url_parts['pass'] != '')	{								$base.= ':' . $url_parts['pass'];							}							$base.= '@';						}						$base.= $url_parts['host'];							// Add path portion skipping possible file name						$base.= preg_replace('/(.*\/)[^\/]*/', '\1', $url_parts['path']);							// Put it into content (generate also <head> if necessary)						$replacement = chr(10) . '<base href="' . htmlentities($base) . '" />' . chr(10);						if (stristr($content, '<head>'))	{							$content = preg_replace('/(<head>)/i', '\1' . $replacement, $content);						} else {							$content = preg_replace('/(<html[^>]*>)/i', '\1<head>' . $replacement . '</head>', $content);						}					}				}				echo $content;	// Output the content			}		} else {			$this->printError($reason ? 'Reason: '.htmlspecialchars($reason) : 'Page cannot be found.');		}		exit();	}	/**	 * Fetches the integer page id for a page alias.	 * Looks if ->id is not an integer and if so it will search for a page alias and if found the page uid of that page is stored in $this->id	 *	 * @return	void	 * @access private	 */	function checkAndSetAlias()	{		if ($this->id && !t3lib_div::testInt($this->id))	{			$aid = $this->sys_page->getPageIdFromAlias($this->id);			if ($aid)	{				$this->id = $aid;			} else {				$this->pageNotFound = 4;			}		}	}	/**	 * Analyzes the second part of a id-string (after the "+"), looking for B6 or M5 encoding and if found it will resolve it and restore the variables in global $_GET	 * If values for ->cHash, ->no_cache, ->jumpurl and ->MP is found, they are also loaded into the internal vars of this class.	 *	 * @param	string		String to analyze	 * @return	void	 * @access private	 */	function idPartsAnalyze($str)	{		$GET_VARS = '';		switch(substr($str,0,2))	{			case 'B6':				$addParams = base64_decode(str_replace('_','=',str_replace('-','/',substr($str,2))));				parse_str($addParams,$GET_VARS);			break;			case 'M5':				$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr(substr($str,2), 'cache_md5params'));				$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);				$this->updateMD5paramsRecord(substr($str,2));				parse_str($row['params'],$GET_VARS);			break;		}		$this->me

⌨️ 快捷键说明

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