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
3232 3232
	 * Abstraction method which returns System Environment Variables regardless of server OS, CGI/MODULE version etc. Basically this is SERVER variables for most of them.
3233 3233
	 * This should be used instead of getEnv() and $_SERVER/ENV_VARS to get reliable values for all situations.
3234 3234
	 *
3235
	 * @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
3235
	 * @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
3236 3236
	 * @return string Value based on the input key, independent of server/os environment.
3237 3237
	 */
3238 3238
	static public function getIndpEnv($getEnvName) {
......
3464 3464
					$retVal = $_SERVER['SSL_SESSION_ID'] || strtolower($_SERVER['HTTPS']) === 'on' || (string)$_SERVER['HTTPS'] === '1' ? TRUE : FALSE;
3465 3465
				}
3466 3466
				break;
3467
			case 'TYPO3_DISABLE_CORE_UPDATER':
3468
				$retVal = self::getRedirectEnvironmentVariable($getEnvName);
3469
				break;
3467 3470
			case '_ARRAY':
3468 3471
				$out = array();
3469 3472
				// Here, list ALL possible keys to this function for debug display.
......
3502 3505
	}
3503 3506

  
3504 3507
	/**
3508
	 * Returns an environment variable taking possible "REDIRECT_"
3509
	 * prefixes into account (e.g. due to PHP running in CGI mode)
3510
	 *
3511
	 * The given environment variable will be prefixed at maximum of 5 times.
3512
	 *
3513
	 * @param string $environmentVariable the environment variable to retrieve
3514
	 * @return mixed
3515
	 */
3516
	static protected function getRedirectEnvironmentVariable($environmentVariable) {
3517
		for ($prefixCount = 0; $prefixCount < 5; ++$prefixCount) {
3518
			$environmentVariableName = str_repeat('REDIRECT_', $prefixCount) . $environmentVariable;
3519

  
3520
			if (isset($_SERVER[$environmentVariableName])) {
3521
				return $_SERVER[$environmentVariableName];
3522
			}
3523
		}
3524
		return NULL;
3525
	}
3526

  
3527
	/**
3505 3528
	 * Gets the unixtime as milliseconds.
3506 3529
	 *
3507 3530
	 * @return integer The unixtime as milliseconds
typo3/sysext/install/Classes/Service/CoreUpdateService.php
94 94
	 * @return boolean
95 95
	 */
96 96
	public function isCoreUpdateEnabled() {
97
		return (getenv('TYPO3_DISABLE_CORE_UPDATER') !== '1');
97
		return (GeneralUtility::getIndpEnv('TYPO3_DISABLE_CORE_UPDATER') !== '1');
98 98
	}
99 99

  
100 100
	/**
(2-2/2)