From 93f73a02504d5b858a9b4444fe345627b4d262c4 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 3 Mar 2003 12:24:51 +0000 Subject: [PATCH] $cfg['PmaAbsoluteUri'] autodetection did not work as expected if php was in CGI mode. --- ChangeLog | 4 +++- libraries/common.lib.php3 | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7566d388..20d2be104 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10,7 +10,9 @@ $Source$ containing quotes. * libraries/common.lib.php3: - Avoid reloading the left frame twice; - - PHP3 compatibility. + - PHP3 compatibility; + - $cfg['PmaAbsoluteUri'] autodetection did not work as expected if php was + in CGI mode. 2003-03-03 Marc Delisle * badwords.txt: bug 692874: "date" is not a reserved word diff --git a/libraries/common.lib.php3 b/libraries/common.lib.php3 index 3a579c318..d48a20306 100644 --- a/libraries/common.lib.php3 +++ b/libraries/common.lib.php3 @@ -557,6 +557,12 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} if (isset($$SERVER_ARRAY['SERVER_PORT'])) { $SERVER_PORT = $$SERVER_ARRAY['SERVER_PORT']; } + if (isset($$SERVER_ARRAY['REQUEST_URI'])) { + $REQUEST_URI = $$SERVER_ARRAY['REQUEST_URI']; + } + if (isset($$SERVER_ARRAY['PATH_INFO'])) { + $PATH_INFO = $$SERVER_ARRAY['PATH_INFO']; + } $port_in_HTTP_HOST = (strpos($HTTP_HOST, ':') > 0); $cfg['PmaAbsoluteUri'] = ((!empty($HTTPS) && strtolower($HTTPS) != 'off') ? 'https' : 'http') . '://' . $HTTP_HOST; @@ -568,7 +574,15 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} $cfg['PmaAbsoluteUri'] .= ((!empty($SERVER_PORT) && !$port_in_HTTP_HOST) ? ':' . $SERVER_PORT : ''); } - $cfg['PmaAbsoluteUri'] .= substr($PHP_SELF, 0, strrpos($PHP_SELF, '/') + 1); + // 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. + if (isset($REQUEST_URI)) { + $cfg['PmaAbsoluteUri'] .= substr($REQUEST_URI, 0, strrpos($REQUEST_URI, '/') + 1); + } else if (isset($PATH_INFO)) { + $cfg['PmaAbsoluteUri'] .= substr($PATH_INFO, 0, strrpos($PATH_INFO, '/') + 1); + } else { + $cfg['PmaAbsoluteUri'] .= substr($PHP_SELF, 0, strrpos($PHP_SELF, '/') + 1); + } // We display the warning by default, but not if it is disabled thru // via the $cfg['PmaAbsoluteUri_DisableWarning'] variable.