Project

General

Profile

Bug #53188 » 53188-getindpenv.patch

Implementation via GeneralUtility::getIndpEnv - Mathias Brodala, 2014-03-05 14:33

View differences:

typo3/sysext/core/Classes/Utility/GeneralUtility.php
* Abstraction method which returns System Environment Variables regardless of server OS, CGI/MODULE version etc. Basically this is SERVER variables for most of them.
* This should be used instead of getEnv() and $_SERVER/ENV_VARS to get reliable values for all situations.
*
* @param string $getEnvName Name of the "environment variable"/"server variable" you wish to use. Valid values are SCRIPT_NAME, SCRIPT_FILENAME, REQUEST_URI, PATH_INFO, REMOTE_ADDR, REMOTE_HOST, HTTP_REFERER, HTTP_HOST, HTTP_USER_AGENT, HTTP_ACCEPT_LANGUAGE, QUERY_STRING, TYPO3_DOCUMENT_ROOT, TYPO3_HOST_ONLY, TYPO3_HOST_ONLY, TYPO3_REQUEST_HOST, TYPO3_REQUEST_URL, TYPO3_REQUEST_SCRIPT, TYPO3_REQUEST_DIR, TYPO3_SITE_URL, _ARRAY
* @param string $getEnvName Name of the "environment variable"/"server variable" you wish to use. Valid values are SCRIPT_NAME, SCRIPT_FILENAME, REQUEST_URI, PATH_INFO, REMOTE_ADDR, REMOTE_HOST, HTTP_REFERER, HTTP_HOST, HTTP_USER_AGENT, HTTP_ACCEPT_LANGUAGE, QUERY_STRING, TYPO3_DOCUMENT_ROOT, TYPO3_HOST_ONLY, TYPO3_HOST_ONLY, TYPO3_REQUEST_HOST, TYPO3_REQUEST_URL, TYPO3_REQUEST_SCRIPT, TYPO3_REQUEST_DIR, TYPO3_SITE_URL, TYPO3_DISABLE_CORE_UPDATER, _ARRAY
* @return string Value based on the input key, independent of server/os environment.
*/
static public function getIndpEnv($getEnvName) {
......
$retVal = $_SERVER['SSL_SESSION_ID'] || strtolower($_SERVER['HTTPS']) === 'on' || (string)$_SERVER['HTTPS'] === '1' ? TRUE : FALSE;
}
break;
case 'TYPO3_DISABLE_CORE_UPDATER':
$retVal = self::getRedirectEnvironmentVariable($getEnvName);
break;
case '_ARRAY':
$out = array();
// Here, list ALL possible keys to this function for debug display.
......
}
/**
* Returns an environment variable taking possible "REDIRECT_"
* prefixes into account (e.g. due to PHP running in CGI mode)
*
* The given environment variable will be prefixed at maximum of 5 times.
*
* @param string $environmentVariable the environment variable to retrieve
* @return mixed
*/
static protected function getRedirectEnvironmentVariable($environmentVariable) {
for ($prefixCount = 0; $prefixCount < 5; ++$prefixCount) {
$environmentVariableName = str_repeat('REDIRECT_', $prefixCount) . $environmentVariable;
if (isset($_SERVER[$environmentVariableName])) {
return $_SERVER[$environmentVariableName];
}
}
return NULL;
}
/**
* Gets the unixtime as milliseconds.
*
* @return integer The unixtime as milliseconds
typo3/sysext/install/Classes/Service/CoreUpdateService.php
* @return boolean
*/
public function isCoreUpdateEnabled() {
return (getenv('TYPO3_DISABLE_CORE_UPDATER') !== '1');
return (GeneralUtility::getIndpEnv('TYPO3_DISABLE_CORE_UPDATER') !== '1');
}
/**
(2-2/2)