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

@@ -556,7 +556,7 @@ if ($is_minimum_common == FALSE) {
*/ */
function PMA_showHint($hint_message) function PMA_showHint($hint_message)
{ {
return '<img src="' . $GLOBALS['pmaThemeImage'] . 'b_tipp.png" width="16" height="16" border="0" alt="' . $hint_message . '" title="' . $hint_message . '" align="middle" />'; return '<img src="' . $GLOBALS['pmaThemeImage'] . 'b_tipp.png" width="16" height="16" border="0" alt="' . $hint_message . '" title="' . $hint_message . '" align="middle" />';
} }
/** /**
@@ -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
@@ -1181,7 +1187,7 @@ if ($is_minimum_common == FALSE) {
PMA_auth_fails(); PMA_auth_fails();
unset($allowDeny_forbidden); //Clean up after you! unset($allowDeny_forbidden); //Clean up after you!
} }
// The user can work with only some databases // The user can work with only some databases
if (isset($cfg['Server']['only_db']) && $cfg['Server']['only_db'] != '') { if (isset($cfg['Server']['only_db']) && $cfg['Server']['only_db'] != '') {
if (is_array($cfg['Server']['only_db'])) { if (is_array($cfg['Server']['only_db'])) {
@@ -2317,7 +2323,7 @@ if (typeof(document.getElementById) != 'undefined'
*/ */
function PMA_buttonOrImage($button_name, $button_class, $image_name, $text, $image) { function PMA_buttonOrImage($button_name, $button_class, $image_name, $text, $image) {
global $pmaThemeImage, $propicon; global $pmaThemeImage, $propicon;
/* Opera has trouble with <input type="image"> */ /* Opera has trouble with <input type="image"> */
/* IE has trouble with <button> */ /* IE has trouble with <button> */
if (PMA_USR_BROWSER_AGENT != 'IE') { if (PMA_USR_BROWSER_AGENT != 'IE') {