Fix URI detection in case REQUEST_URI contains full URI (patch #1044123).

This commit is contained in:
Michal Čihař
2004-10-25 13:01:38 +00:00
parent bd5b4bfab9
commit d6b965b4ac
2 changed files with 32 additions and 22 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2004-10-25 Michal Čihař <michal@cihar.com>
* libraries/common.lib.php: Fix URI detection in case REQUEST_URI contains
full URI (patch #1044123).
2004-10-24 Michael Keck <mkkeck@users.sourceforge.net> 2004-10-24 Michael Keck <mkkeck@users.sourceforge.net>
* config.inc.php, themes/*/layout.inc.php: * config.inc.php, themes/*/layout.inc.php:
bug #1050666 - Query window too small darkblue/orange theme bug #1050666 - Query window too small darkblue/orange theme

View File

@@ -1009,29 +1009,35 @@ if ($is_minimum_common == FALSE) {
if (isset(${$SERVER_ARRAY}['HTTP_SCHEME'])) { if (isset(${$SERVER_ARRAY}['HTTP_SCHEME'])) {
$HTTP_SCHEME = ${$SERVER_ARRAY}['HTTP_SCHEME']; $HTTP_SCHEME = ${$SERVER_ARRAY}['HTTP_SCHEME'];
} }
if (!empty($HTTP_SCHEME)) {
$cfg['PmaAbsoluteUri'] = $HTTP_SCHEME . '://'; // in some cases $REQUEST_URI contains full URI including protocol and host, so just use it:
if (isset($REQUEST_URI) && preg_match('@https?://@', $REQUEST_URI)) {
$cfg['PmaAbsoluteUri'] = substr($REQUEST_URI, 0, strrpos($REQUEST_URI, '/') + 1);
} else { } else {
$cfg['PmaAbsoluteUri'] = ((!empty($HTTPS) && strtolower($HTTPS) != 'off') ? 'https' : 'http') . '://'; if (!empty($HTTP_SCHEME)) {
} $cfg['PmaAbsoluteUri'] = $HTTP_SCHEME . '://';
$port_in_HTTP_HOST = (strpos($HTTP_HOST, ':') > 0); } else {
$cfg['PmaAbsoluteUri'] .= $HTTP_HOST; $cfg['PmaAbsoluteUri'] = ((!empty($HTTPS) && strtolower($HTTPS) != 'off') ? 'https' : 'http') . '://';
}
$port_in_HTTP_HOST = (strpos($HTTP_HOST, ':') > 0);
$cfg['PmaAbsoluteUri'] .= $HTTP_HOST;
// if $cfg['PmaAbsoluteUri'] is empty and port == 80 or port == 443, do not add ":80" or ":443" // if $cfg['PmaAbsoluteUri'] is empty and port == 80 or port == 443, do not add ":80" or ":443"
// to the generated URL -> prevents a double password query in case of http authentication. // to the generated URL -> prevents a double password query in case of http authentication.
if (!(!$port_in_HTTP_HOST && !empty($SERVER_PORT) && ($SERVER_PORT == 80 || $SERVER_PORT == 443))) { if (!(!$port_in_HTTP_HOST && !empty($SERVER_PORT) && ($SERVER_PORT == 80 || $SERVER_PORT == 443))) {
$cfg['PmaAbsoluteUri'] .= ((!empty($SERVER_PORT) && !$port_in_HTTP_HOST) ? ':' . $SERVER_PORT : ''); $cfg['PmaAbsoluteUri'] .= ((!empty($SERVER_PORT) && !$port_in_HTTP_HOST) ? ':' . $SERVER_PORT : '');
} }
// rabus: if php is in CGI mode, $PHP_SELF often contains the path to the CGI executable. // rabus: if php is in CGI mode, $PHP_SELF often contains the path to the CGI executable.
// This is why we try to get the path from $REQUEST_URI or $PATH_INFO first. // This is why we try to get the path from $REQUEST_URI or $PATH_INFO first.
if (isset($REQUEST_URI)) { if (isset($REQUEST_URI)) {
$cfg['PmaAbsoluteUri'] .= substr($REQUEST_URI, 0, strrpos($REQUEST_URI, '/') + 1); $cfg['PmaAbsoluteUri'] .= substr($REQUEST_URI, 0, strrpos($REQUEST_URI, '/') + 1);
} else if (isset($PATH_INFO)) { } else if (isset($PATH_INFO)) {
$cfg['PmaAbsoluteUri'] .= substr($PATH_INFO, 0, strrpos($PATH_INFO, '/') + 1); $cfg['PmaAbsoluteUri'] .= substr($PATH_INFO, 0, strrpos($PATH_INFO, '/') + 1);
} else { } else {
$cfg['PmaAbsoluteUri'] .= substr($PHP_SELF, 0, strrpos($PHP_SELF, '/') + 1); $cfg['PmaAbsoluteUri'] .= substr($PHP_SELF, 0, strrpos($PHP_SELF, '/') + 1);
}
} }
// We display the warning by default, but not if it is disabled thru // We display the warning by default, but not if it is disabled thru