pageUnavailable.diff

Administrator Admin, 2008-01-21 03:23

Download (14.3 KB)

View differences:

t3lib/config_default.php (working copy)
202 202
		'compressionDebugInfo' => 0,			// Boolean. If set, then in the end of the pages, the sizes of the compressed and non-compressed document is output. This should be used ONLY as a test, because the content is compressed twice in order to output this statistics!
203 203
		'pageNotFound_handling' => '',			// How TYPO3 should handle requests for non-existing/accessible pages. false (default): The 'nearest' page is shown. TRUE or '1': An TYPO3 error box is displayed. Strings: page to show (reads content and outputs with correct headers), eg. 'notfound.html' or 'http://www.domain.org/errors/notfound.html'. If prefixed "REDIRECT:" it will redirect to the URL/script after the prefix (original behaviour). If prefixed with "READFILE:" then it will expect the remaining string to be a HTML file which will be read and outputted directly after having the marker "###CURRENT_URL###" substituted with REQUEST_URI and ###REASON### with reason text, for example: "READFILE:fileadmin/notfound.html". Another option is the prefix "USER_FUNCTION:" which will call a user function, eg. "USER_FUNCTION:typo3conf/pageNotFoundHandling.php:user_pageNotFound->pageNotFound" where the file must contain a class "user_pageNotFound" with a method "pageNotFound" inside with two parameters, $param and $ref
204 204
		'pageNotFound_handling_statheader' => 'HTTP/1.0 404 Not Found',			// If 'pageNotFound_handling' is enabled, this string will always be sent as header before the actual handling.
205
		'pageUnavailable_handling' => '',		// How TYPO3 should handle requests when pages are unavailable due to system problems. false (default): A static error message is displayed. Strings: page to show (reads content and outputs with correct headers), eg. 'unavailable.html' or 'http://www.domain.org/errors/unavailable.html'. If prefixed "REDIRECT:" it will redirect to the URL/script after the prefix (original behaviour). If prefixed with "READFILE:" then it will expect the remaining string to be a HTML file which will be read and outputted directly after having the marker "###CURRENT_URL###" substituted with REQUEST_URI and ###REASON### with reason text, for example: "READFILE:fileadmin/unavailable.html". Another option is the prefix "USER_FUNCTION:" which will call a user function, eg. "USER_FUNCTION:typo3conf/pageUnavailableHandling.php:user_pageUnavailable->pageUnavailable" where the file must contain a class "user_pageUnavailable" with a method "pageUnavailable" inside with two parameters, $param and $ref
206
		'pageUnavailable_handling_statheader' => 'HTTP/1.0 503 Service Temporarily Unavailable',		// If 'pageUnavailable_handling' is enabled, this string will always be sent as header before the actual handling.
207
		'pageUnavailable_force' => 0,			// Boolean. If true, pageUnavailable_handling is used for every frontend page. This is useful during temporary site maintenance. 
205 208
		'pageNotFoundOnCHashError' => 0,		// Boolean. If true, a page not found call is made when cHash evaluation error occurs. By default they will just disable caching but still display page output.
206 209
		'userFuncClassPrefix' => 'user_',		// This prefix must be the first part of any function or class name called from TypoScript, for instance in the stdWrap function.
207 210
		'addRootLineFields' => '',				// Comma-list of fields from the 'pages'-table. These fields are added to the select query for fields in the rootline.
typo3/sysext/cms/tslib/class.tslib_fe.php (working copy)
467 467
					</script>';
468 468
				exit;
469 469
			} elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db))	{
470
				header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
471
				$this->printError('Cannot connect to the current database, "'.TYPO3_db.'"','Database Error');
472
				exit;
470
				if ($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'])	{
471
					$this->pageUnavailableAndExit('Cannot connect to the current database, "'.TYPO3_db.'"');
472
				} else {
473
					header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
474
					$this->printError('Cannot connect to the current database, "'.TYPO3_db.'"','Database Error');
475
					exit;
476
				}
473 477
			}
474 478
		} else {
475 479
			if (!TYPO3_db)	{
......
481 485
					</script>';
482 486
				exit;
483 487
			}
484
			header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
485
			$this->printError('The current username, password or host was not accepted when the connection to the database was attempted to be established!','Database Error');
486
			exit;
488
			
489
			if ($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'])	{
490
				$this->pageUnavailableAndExit('The current username, password or host was not accepted when the connection to the database was attempted to be established!');
491
			} else {
492
				header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
493
				$this->printError('The current username, password or host was not accepted when the connection to the database was attempted to be established!','Database Error');
494
				exit;
495
			}
487 496
		}
488 497

  
489 498

  
......
895 904
				if ($theFirstPage)	{
896 905
					$this->id = $theFirstPage['uid'];
897 906
				} else {
898
					header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
899
					t3lib_div::sysLog('No pages are found on the rootlevel!', 'cms', 3);
900
					$this->printError('No pages are found on the rootlevel!');
901
					exit;
907
					if ($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'])	{
908
						$this->pageUnavailableAndExit('No pages are found on the rootlevel!');
909
					} else {
910
						header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
911
						t3lib_div::sysLog('No pages are found on the rootlevel!', 'cms', 3);
912
						$this->printError('No pages are found on the rootlevel!');
913
						exit;
914
					}
902 915
				}
903 916
			}
904 917
		}
......
1008 1021
				$this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);
1009 1022
			}
1010 1023
			if (!count($this->rootLine))	{
1011
				header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1012
				t3lib_div::sysLog('The requested page didn\'t have a proper connection to the tree-root! ('.$this->sys_page->error_getRootLine.')', 'cms', 3);
1013
				$this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')');
1014
				exit;
1024
				if ($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'])	{
1025
					$this->pageUnavailableAndExit('The requested page didn\'t have a proper connection to the tree-root!');
1026
				} else {
1027
					header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1028
					t3lib_div::sysLog('The requested page didn\'t have a proper connection to the tree-root! ('.$this->sys_page->error_getRootLine.')', 'cms', 3);
1029
					$this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')');
1030
					exit;
1031
				}
1015 1032
			}
1016 1033
			$this->fePreview = 1;
1017 1034
		}
......
1019 1036
			// Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!)
1020 1037
		if ($this->checkRootlineForIncludeSection())	{
1021 1038
			if (!count($this->rootLine))	{
1022
				header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1023
				t3lib_div::sysLog('The requested page was not accessible!', 'cms', 3);
1024
				$this->printError('The requested page was not accessible!');
1025
				exit;
1039
				if ($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'])	{
1040
					$this->pageUnavailableAndExit('The requested page was not accesible!');
1041
				} else {
1042
					header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1043
					t3lib_div::sysLog('The requested page was not accessible!', 'cms', 3);
1044
					$this->printError('The requested page was not accessible!');
1045
					exit;
1046
				}
1026 1047
			} else {
1027 1048
				$el = reset($this->rootLine);
1028 1049
				$this->id = $el['uid'];
......
1301 1322
			return $this->sys_page->getDomainStartPage(t3lib_div::getIndpEnv('HTTP_HOST'),t3lib_div::getIndpEnv('SCRIPT_NAME'),t3lib_div::getIndpEnv('REQUEST_URI'));
1302 1323
		}
1303 1324
	}
1325
	
1326
	/**
1327
	 * Page unavailable handler for use in frontend plugins from extensions.
1328
	 *
1329
	 * @param	string		Reason text
1330
	 * @param	string		HTTP header to send
1331
	 * @return	void		Function exits.
1332
	 */
1333
	function pageUnavailableAndExit($reason='', $header='')	{
1334
		$header = $header ? $header : $this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling_statheader'];
1335
		$this->pageUnavailableHandler($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'], $header, $reason);
1336
		exit;
1337
	}
1304 1338

  
1305 1339
	/**
1306 1340
	 * Page-not-found handler for use in frontend plugins from extensions.
......
1314 1348
		$this->pageNotFoundHandler($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'], $header, $reason);
1315 1349
		exit;
1316 1350
	}
1351
	
1352
	/**
1353
	 * Page unavailable handler. Acts a wrapper for the pageErrorHandler method.
1354
	 *
1355
	 * @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.
1356
	 * @param	string		If set, this is passed directly to the PHP function, header()
1357
	 * @param	string		If set, error messages will also mention this as the reason for the page-not-found.
1358
	 * @return	void		(The function exits!)
1359
	 */
1360
	function pageUnavailableHandler($code, $header, $reason)	{
1361
		$this->pageErrorHandler($code, $header, $reason);
1362
	}
1363
	
1364
	/**
1365
	 * Page not found handler. Acts a wrapper for the pageErrorHandler method.
1366
	 *
1367
	 * @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.
1368
	 * @param	string		If set, this is passed directly to the PHP function, header()
1369
	 * @param	string		If set, error messages will also mention this as the reason for the page-not-found.
1370
	 * @return	void		(The function exits!)
1371
	 */
1372
	function pageNotFoundHandler($code, $header='', $reason='')	{
1373
		$this->pageErrorHandler($code, $header, $reason);
1374
	}
1317 1375

  
1318 1376
	/**
1319
	 * Page not found handler.
1377
	 * Generic error page handler.
1320 1378
	 * Exits.
1321 1379
	 *
1322 1380
	 * @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.
......
1324 1382
	 * @param	string		If set, error messages will also mention this as the reason for the page-not-found.
1325 1383
	 * @return	void		(The function exits!)
1326 1384
	 */
1327
	function pageNotFoundHandler($code, $header='', $reason='')	{
1385
	function pageErrorHandler($code, $header='', $reason='')	{
1328 1386

  
1329 1387
			// Issue header in any case:
1330 1388
		if ($header)	{
......
1842 1900
				$this->pSetup = $this->tmpl->setup[$this->sPre.'.'];
1843 1901

  
1844 1902
				if (!is_array($this->pSetup))	{
1845
					header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1846
					t3lib_div::sysLog('The page is not configured! [type= '.$this->type.']['.$this->sPre.']', 'cms', 3);
1847
					$this->printError('The page is not configured! [type= '.$this->type.']['.$this->sPre.']');
1848
					exit;
1903
					if ($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'])	{
1904
						$this->pageUnavailableAndExit('The page is not configured! [type= '.$this->type.']['.$this->sPre.']');
1905
					} else {
1906
						header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1907
						t3lib_div::sysLog('The page is not configured! [type= '.$this->type.']['.$this->sPre.']', 'cms', 3);
1908
						$this->printError('The page is not configured! [type= '.$this->type.']['.$this->sPre.']');
1909
						exit;
1910
					}
1849 1911
				} else {
1850 1912
					$this->config['config']=Array();
1851 1913

  
......
1911 1973
				}
1912 1974
				$GLOBALS['TT']->pull();
1913 1975
			} else {
1914
				header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1915
				t3lib_div::sysLog('No template found!', 'cms', 3);
1916
				$this->printError('No template found!');
1917
				exit;
1976
				if ($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'])	{
1977
					$this->pageUnavailableAndExit('No template found!');
1978
				} else {
1979
					header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1980
					t3lib_div::sysLog('No template found!', 'cms', 3);
1981
					$this->printError('No template found!');
1982
					exit;
1983
				}
1918 1984
			}
1919 1985
		}
1920 1986

  
......
1979 2045
		if ($this->absRefPrefix_force && strcmp($this->config['config']['simulateStaticDocuments'],'PATH_INFO'))	{
1980 2046
			$redirectUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php?id='.$this->id.'&type='.$this->type;
1981 2047
			if ($this->config['config']['simulateStaticDocuments_dontRedirectPathInfoError'])	{
1982
				header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
1983
				t3lib_div::sysLog('PATH_INFO was not configured for this website, and the URL tries to find the page by PATH_INFO!', 'cms', 3);
1984
				$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');
2048
				if ($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'])	{
2049
					$this->pageUnavailableAndExit('PATH_INFO was not configured for this website, and the URL tries to find the page by PATH_INFO!');
2050
				} else {
2051
					header( 'HTTP/1.0 503 Service Temporarily Unavailable' );
2052
					t3lib_div::sysLog('PATH_INFO was not configured for this website, and the URL tries to find the page by PATH_INFO!', 'cms', 3);
2053
					$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');
2054
				}
1985 2055
			} else {
1986 2056
				header('Location: '.t3lib_div::locationHeaderUrl($redirectUrl));
1987 2057
			}
typo3/sysext/cms/tslib/index_ts.php (working copy)
163 163
		t3lib_div::_GP('MP'),
164 164
		t3lib_div::_GP('RDCT')
165 165
	);
166

  
167
if($TYPO3_CONF_VARS['FE']['pageUnavailable_force']) {
168
	$TSFE->pageUnavailableAndExit('This page is temporarily unavailable.');
169
}
170
	
171
	
166 172
$TSFE->connectToDB();
167 173

  
168 174
	// In case of a keyword-authenticated preview, re-initialize the TSFE object: