Code Duplication    Length = 14-14 lines in 2 locations

core/startup/ParameterConfirmationToken.php 1 location

@@ 169-182 (lines=14) @@
166
		// See https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
167
		// See https://support.microsoft.com/?kbID=307347
168
		$headerOverride = false;
169
		if(TRUSTED_PROXY) {
170
			$headers = (defined('SS_TRUSTED_PROXY_PROTOCOL_HEADER')) ? array(SS_TRUSTED_PROXY_PROTOCOL_HEADER) : null;
171
			if(!$headers) {
172
				// Backwards compatible defaults
173
				$headers = array('HTTP_X_FORWARDED_PROTO', 'HTTP_X_FORWARDED_PROTOCOL', 'HTTP_FRONT_END_HTTPS');
174
			}
175
			foreach($headers as $header) {
176
				$headerCompareVal = ($header === 'HTTP_FRONT_END_HTTPS' ? 'on' : 'https');
177
				if(!empty($_SERVER[$header]) && strtolower($_SERVER[$header]) == $headerCompareVal) {
178
					$headerOverride = true;
179
					break;
180
				}
181
			}
182
		}
183
184
		if($headerOverride) {
185
			$proto = 'https';

control/Director.php 1 location

@@ 514-527 (lines=14) @@
511
		// See https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
512
		// See https://support.microsoft.com/?kbID=307347
513
		$headerOverride = false;
514
		if(TRUSTED_PROXY) {
515
			$headers = (defined('SS_TRUSTED_PROXY_PROTOCOL_HEADER')) ? array(SS_TRUSTED_PROXY_PROTOCOL_HEADER) : null;
516
			if(!$headers) {
517
				// Backwards compatible defaults
518
				$headers = array('HTTP_X_FORWARDED_PROTO', 'HTTP_X_FORWARDED_PROTOCOL', 'HTTP_FRONT_END_HTTPS');
519
			}
520
			foreach($headers as $header) {
521
				$headerCompareVal = ($header === 'HTTP_FRONT_END_HTTPS' ? 'on' : 'https');
522
				if(!empty($_SERVER[$header]) && strtolower($_SERVER[$header]) == $headerCompareVal) {
523
					$headerOverride = true;
524
					break;
525
				}
526
			}
527
		}
528
529
		if ($protocol = Config::inst()->get('Director', 'alternate_protocol')) {
530
			$return = ($protocol == 'https');