Bug #15135 » typo3-sslproxy.patch
typo3.8.1/t3lib/class.t3lib_div.php 2005-12-19 16:21:12.951449893 +0000 | ||
---|---|---|
*/
|
||
# if ($getEnvName=='HTTP_REFERER') return '';
|
||
if (
|
||
!empty($_SERVER["HTTP_X_FORWARDED_HOST"]) &&
|
||
($_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"]) &&
|
||
!empty($GLOBALS['TYPO3_CONF_VARS']['BE']['ReverseProxyDirectory'])
|
||
) {
|
||
$sslproxy = $GLOBALS['TYPO3_CONF_VARS']['BE']['ReverseProxyDirectory'];
|
||
} else {
|
||
$sslproxy = "";
|
||
}
|
||
#error_log( "getIndpEnv($getEnvName) in " . $_SERVER['PHP_SELF'],0);
|
||
switch((string)$getEnvName) {
|
||
case 'SCRIPT_NAME':
|
||
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']);
|
||
$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']);
|
||
# return $retval;
|
||
error_log("SCRIPT_NAME Result <1>: " . $sslproxy . $retval . " in " . $_SERVER['PHP_SELF'] ." - SSLPROXY: $sslproxy", 0);
|
||
return $sslproxy . $retval;
|
||
break;
|
||
case 'SCRIPT_FILENAME':
|
||
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'])));
|
||
... | ... | |
case 'REQUEST_URI':
|
||
// Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))
|
||
if (!$_SERVER['REQUEST_URI']) { // This is for ISS/CGI which does not have the REQUEST_URI available.
|
||
return '/'.ereg_replace('^/','',t3lib_div::getIndpEnv('SCRIPT_NAME')).
|
||
return $sslproxy . '/'.ereg_replace('^/','',t3lib_div::getIndpEnv('SCRIPT_NAME')).
|
||
($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:'');
|
||
} else return $_SERVER['REQUEST_URI'];
|
||
} else {
|
||
error_log( " Result <2>: " . $sslproxy . $_SERVER['REQUEST_URI'], 0);
|
||
# return $sslproxy . $_SERVER['REQUEST_URI'];
|
||
return $_SERVER['REQUEST_URI'];
|
||
}
|
||
break;
|
||
case 'PATH_INFO':
|
||
// $_SERVER['PATH_INFO']!=$_SERVER['SCRIPT_NAME'] is necessary because some servers (Windows/CGI) are seen to set PATH_INFO equal to script_name
|
||
... | ... | |
case 'REMOTE_ADDR':
|
||
case 'REMOTE_HOST':
|
||
case 'HTTP_REFERER':
|
||
case 'HTTP_HOST':
|
||
case 'HTTP_USER_AGENT':
|
||
case 'HTTP_ACCEPT_LANGUAGE':
|
||
case 'QUERY_STRING':
|
||
return $_SERVER[$getEnvName];
|
||
break;
|
||
break;
|
||
case 'HTTP_HOST':
|
||
if (!empty ($sslproxy)) {
|
||
return $GLOBALS['TYPO3_CONF_VARS']['BE']['ReverseProxyServer'] ;
|
||
} else {
|
||
return $_SERVER[$getEnvName];
|
||
}
|
||
break;
|
||
case 'TYPO3_DOCUMENT_ROOT':
|
||
// 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.
|
||
// Therefore the DOCUMENT_ROOT is now always calculated as the SCRIPT_FILENAME minus the end part shared with SCRIPT_NAME.
|
||
... | ... | |
return $DR;
|
||
break;
|
||
case 'TYPO3_HOST_ONLY':
|
||
if (!empty($sslproxy)) return $GLOBALS[$TYPO3_CONF_VARS['BE']['ReverseProxyServer']];
|
||
$p = explode(':',$_SERVER['HTTP_HOST']);
|
||
return $p[0];
|
||
break;
|
||
... | ... | |
return $p[1];
|
||
break;
|
||
case 'TYPO3_REQUEST_HOST':
|
||
return (t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://').
|
||
$_SERVER['HTTP_HOST'];
|
||
$retval = (t3lib_div::getIndpEnv('TYPO3_SSL') ?
|
||
'https://' : 'http://');
|
||
if (empty($sslproxy)) {
|
||
$retval .= $_SERVER['HTTP_HOST'];
|
||
} else {
|
||
$retval .=
|
||
$GLOBALS['TYPO3_CONF_VARS']['BE']['ReverseProxyServer'];
|
||
}
|
||
# echo "TYPO3_REQUEST_HOST: $retval";
|
||
return $retval;
|
||
# $GLOBALS['TYPO3_CONF_VARS']['BE']['ReverseProxyServer'] ;
|
||
break;
|
||
case 'TYPO3_REQUEST_URL':
|
||
return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::getIndpEnv('REQUEST_URI');
|
||
return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').$sslproxy . t3lib_div::getIndpEnv('REQUEST_URI');
|
||
break;
|
||
case 'TYPO3_REQUEST_SCRIPT':
|
||
return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::getIndpEnv('SCRIPT_NAME');
|
||
... | ... | |
return substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL')));
|
||
break;
|
||
case 'TYPO3_SSL':
|
||
return $_SERVER['SSL_SESSION_ID'] || !strcmp($_SERVER['HTTPS'],'on') ? TRUE : FALSE;
|
||
if ($sslproxy) return true;
|
||
return $_SERVER['SSL_SESSION_ID'] ||
|
||
!strcmp($_SERVER['HTTPS'],'on' #||
|
||
# $sslproxy != ""
|
||
) ? TRUE : FALSE;
|
||
break;
|
||
case '_ARRAY':
|
||
$out = array();
|