typo3-sslproxy.patch

Administrator Admin, 2005-12-19 17:44

Download (5.4 KB)

View differences:

typo3.8.1/t3lib/class.t3lib_div.php 2005-12-19 16:21:12.951449893 +0000
2663 2663
		*/
2664 2664

  
2665 2665
#		if ($getEnvName=='HTTP_REFERER')	return '';
2666

  
2667

  
2668
		if (
2669
				!empty($_SERVER["HTTP_X_FORWARDED_HOST"]) &&
2670
				($_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"]) &&
2671
				!empty($GLOBALS['TYPO3_CONF_VARS']['BE']['ReverseProxyDirectory'])
2672
		) {
2673
			$sslproxy = $GLOBALS['TYPO3_CONF_VARS']['BE']['ReverseProxyDirectory'];
2674
		} else {
2675
			$sslproxy = "";
2676
		}
2677

  
2678
#error_log( "getIndpEnv($getEnvName) in " . $_SERVER['PHP_SELF'],0);
2679

  
2666 2680
		switch((string)$getEnvName)	{
2667 2681
			case 'SCRIPT_NAME':
2668
				return (php_sapi_name()=='cgi'||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_INFO']?$_SERVER['ORIG_PATH_INFO']:$_SERVER['PATH_INFO']) ? ($_SERVER['ORIG_PATH_INFO']?$_SERVER['ORIG_PATH_INFO']:$_SERVER['PATH_INFO']) : ($_SERVER['ORIG_SCRIPT_NAME']?$_SERVER['ORIG_SCRIPT_NAME']:$_SERVER['SCRIPT_NAME']);
2682
				$retval = (php_sapi_name()=='cgi'||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_INFO']?$_SERVER['ORIG_PATH_INFO']:$_SERVER['PATH_INFO']) ? ($_SERVER['ORIG_PATH_INFO']?$_SERVER['ORIG_PATH_INFO']:$_SERVER['PATH_INFO']) : ($_SERVER['ORIG_SCRIPT_NAME']?$_SERVER['ORIG_SCRIPT_NAME']:$_SERVER['SCRIPT_NAME']);
2683
#				return $retval;
2684
				error_log("SCRIPT_NAME    Result <1>: " . $sslproxy .  $retval . " in " . $_SERVER['PHP_SELF'] ." - SSLPROXY: $sslproxy", 0);
2685
				return $sslproxy . $retval;
2669 2686
			break;
2670 2687
			case 'SCRIPT_FILENAME':
2671 2688
				return str_replace('//','/', str_replace('\\','/', (php_sapi_name()=='cgi'||php_sapi_name()=='isapi' ||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED'])? ($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED']):($_SERVER['ORIG_SCRIPT_FILENAME']?$_SERVER['ORIG_SCRIPT_FILENAME']:$_SERVER['SCRIPT_FILENAME'])));
......
2673 2690
			case 'REQUEST_URI':
2674 2691
					// Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))
2675 2692
				if (!$_SERVER['REQUEST_URI'])	{	// This is for ISS/CGI which does not have the REQUEST_URI available.
2676
					return '/'.ereg_replace('^/','',t3lib_div::getIndpEnv('SCRIPT_NAME')).
2693
					return $sslproxy . '/'.ereg_replace('^/','',t3lib_div::getIndpEnv('SCRIPT_NAME')).
2677 2694
						($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:'');
2678
				} else return $_SERVER['REQUEST_URI'];
2695
				} else {
2696
					error_log( "     Result <2>: " . $sslproxy .  $_SERVER['REQUEST_URI'], 0);
2697
#					return $sslproxy . $_SERVER['REQUEST_URI'];
2698

  
2699
					return $_SERVER['REQUEST_URI'];
2700
				}
2679 2701
			break;
2680 2702
			case 'PATH_INFO':
2681 2703
					// $_SERVER['PATH_INFO']!=$_SERVER['SCRIPT_NAME'] is necessary because some servers (Windows/CGI) are seen to set PATH_INFO equal to script_name
......
2690 2712
			case 'REMOTE_ADDR':
2691 2713
			case 'REMOTE_HOST':
2692 2714
			case 'HTTP_REFERER':
2693
			case 'HTTP_HOST':
2694 2715
			case 'HTTP_USER_AGENT':
2695 2716
			case 'HTTP_ACCEPT_LANGUAGE':
2696 2717
			case 'QUERY_STRING':
2697 2718
				return $_SERVER[$getEnvName];
2698
			break;
2719
				break;
2720
			case 'HTTP_HOST':
2721
				if (!empty ($sslproxy)) {
2722
					return $GLOBALS['TYPO3_CONF_VARS']['BE']['ReverseProxyServer'] ;
2723
				} else { 
2724
					return $_SERVER[$getEnvName];
2725
				}
2726
				break;
2699 2727
			case 'TYPO3_DOCUMENT_ROOT':
2700 2728
				// Some CGI-versions (LA13CGI) and mod-rewrite rules on MODULE versions will deliver a 'wrong' DOCUMENT_ROOT (according to our description). Further various aliases/mod_rewrite rules can disturb this as well.
2701 2729
				// Therefore the DOCUMENT_ROOT is now always calculated as the SCRIPT_FILENAME minus the end part shared with SCRIPT_NAME.
......
2713 2741
				return $DR;
2714 2742
			break;
2715 2743
			case 'TYPO3_HOST_ONLY':
2744
				if (!empty($sslproxy)) return $GLOBALS[$TYPO3_CONF_VARS['BE']['ReverseProxyServer']];
2716 2745
				$p = explode(':',$_SERVER['HTTP_HOST']);
2717 2746
				return $p[0];
2718 2747
			break;
......
2721 2750
				return $p[1];
2722 2751
			break;
2723 2752
			case 'TYPO3_REQUEST_HOST':
2724
				return (t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://').
2725
					$_SERVER['HTTP_HOST'];
2753
				$retval = (t3lib_div::getIndpEnv('TYPO3_SSL') ?
2754
						'https://' : 'http://');
2755
				if (empty($sslproxy)) {
2756
					$retval .= $_SERVER['HTTP_HOST'];	
2757
				} else {
2758
					$retval .=
2759
						$GLOBALS['TYPO3_CONF_VARS']['BE']['ReverseProxyServer'];
2760
				}
2761
#				echo "TYPO3_REQUEST_HOST: $retval";
2762
				return $retval;
2763
#					$GLOBALS['TYPO3_CONF_VARS']['BE']['ReverseProxyServer']	; 
2726 2764
			break;
2727 2765
			case 'TYPO3_REQUEST_URL':
2728
				return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::getIndpEnv('REQUEST_URI');
2766
				return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').$sslproxy . t3lib_div::getIndpEnv('REQUEST_URI');
2729 2767
			break;
2730 2768
			case 'TYPO3_REQUEST_SCRIPT':
2731 2769
				return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::getIndpEnv('SCRIPT_NAME');
......
2746 2784
				return substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL')));
2747 2785
			break;
2748 2786
			case 'TYPO3_SSL':
2749
				return $_SERVER['SSL_SESSION_ID'] || !strcmp($_SERVER['HTTPS'],'on') ? TRUE : FALSE;
2787
				if ($sslproxy) return true;
2788
				return $_SERVER['SSL_SESSION_ID'] ||
2789
					!strcmp($_SERVER['HTTPS'],'on' #||
2790
#					$sslproxy != ""
2791
					) ? TRUE : FALSE;
2750 2792
			break;
2751 2793
			case '_ARRAY':
2752 2794
				$out = array();