| @@ 2644-2664 (lines=21) @@ | ||
| 2641 | break; |
|
| 2642 | case 'REMOTE_ADDR': |
|
| 2643 | $retVal = $_SERVER['REMOTE_ADDR']; |
|
| 2644 | if (self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) { |
|
| 2645 | $ip = self::trimExplode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 2646 | // Choose which IP in list to use |
|
| 2647 | if (!empty($ip)) { |
|
| 2648 | switch ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyHeaderMultiValue']) { |
|
| 2649 | case 'last': |
|
| 2650 | $ip = array_pop($ip); |
|
| 2651 | break; |
|
| 2652 | case 'first': |
|
| 2653 | $ip = array_shift($ip); |
|
| 2654 | break; |
|
| 2655 | case 'none': |
|
| 2656 | ||
| 2657 | default: |
|
| 2658 | $ip = ''; |
|
| 2659 | } |
|
| 2660 | } |
|
| 2661 | if (self::validIP($ip)) { |
|
| 2662 | $retVal = $ip; |
|
| 2663 | } |
|
| 2664 | } |
|
| 2665 | break; |
|
| 2666 | case 'HTTP_HOST': |
|
| 2667 | // if it is not set we're most likely on the cli |
|
| @@ 2669-2689 (lines=21) @@ | ||
| 2666 | case 'HTTP_HOST': |
|
| 2667 | // if it is not set we're most likely on the cli |
|
| 2668 | $retVal = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 2669 | if (isset($_SERVER['REMOTE_ADDR']) && static::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) { |
|
| 2670 | $host = self::trimExplode(',', $_SERVER['HTTP_X_FORWARDED_HOST']); |
|
| 2671 | // Choose which host in list to use |
|
| 2672 | if (!empty($host)) { |
|
| 2673 | switch ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyHeaderMultiValue']) { |
|
| 2674 | case 'last': |
|
| 2675 | $host = array_pop($host); |
|
| 2676 | break; |
|
| 2677 | case 'first': |
|
| 2678 | $host = array_shift($host); |
|
| 2679 | break; |
|
| 2680 | case 'none': |
|
| 2681 | ||
| 2682 | default: |
|
| 2683 | $host = ''; |
|
| 2684 | } |
|
| 2685 | } |
|
| 2686 | if ($host) { |
|
| 2687 | $retVal = $host; |
|
| 2688 | } |
|
| 2689 | } |
|
| 2690 | if (!static::isAllowedHostHeaderValue($retVal)) { |
|
| 2691 | throw new \UnexpectedValueException( |
|
| 2692 | 'The current host header value does not match the configured trusted hosts pattern! Check the pattern defined in $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'trustedHostsPattern\'] and adapt it, if you want to allow the current host header \'' . $retVal . '\' for your installation.', |
|