replaced $_SERVER with getenv()

This commit is contained in:
Sebastian Mendel
2006-03-06 10:49:45 +00:00
parent c499116261
commit 76f0235061
2 changed files with 95 additions and 88 deletions

View File

@@ -5,6 +5,9 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2006-03-06 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* libraries/Config.class.php: replaced $_SERVER with getenv()
2006-03-04 Marc Delisle <lem9@users.sourceforge.net> 2006-03-04 Marc Delisle <lem9@users.sourceforge.net>
* lang/swedish: Update, thanks to Björn T. Hallberg - bjornth. * lang/swedish: Update, thanks to Björn T. Hallberg - bjornth.
* import.php, libraries/common.lib.php: bug #1413880, page status not * import.php, libraries/common.lib.php: bug #1413880, page status not

View File

@@ -2,6 +2,10 @@
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
/**
* Configuration class
*
*/
class PMA_Config class PMA_Config
{ {
/** /**
@@ -125,8 +129,8 @@ class PMA_Config
*/ */
function checkClient() function checkClient()
{ {
if (!empty($_SERVER['HTTP_USER_AGENT'])) { if (getenv('HTTP_USER_AGENT')) {
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; $HTTP_USER_AGENT = getenv('HTTP_USER_AGENT');
} elseif (!isset($HTTP_USER_AGENT)) { } elseif (!isset($HTTP_USER_AGENT)) {
$HTTP_USER_AGENT = ''; $HTTP_USER_AGENT = '';
} }
@@ -226,8 +230,8 @@ class PMA_Config
*/ */
function checkWebServer() function checkWebServer()
{ {
if ( isset( $_SERVER['SERVER_SOFTWARE'] ) if (getenv('SERVER_SOFTWARE')
&& stristr($_SERVER['SERVER_SOFTWARE'], 'Microsoft/IIS') ) { && stristr(getenv('SERVER_SOFTWARE'), 'Microsoft/IIS')) {
$this->set('PMA_IS_IIS', 1); $this->set('PMA_IS_IIS', 1);
} else { } else {
$this->set('PMA_IS_IIS', 0); $this->set('PMA_IS_IIS', 0);
@@ -273,7 +277,7 @@ class PMA_Config
} }
/** /**
* re-init object after loadiong from session file * re-init object after loading from session file
* checks config file for changes and relaods if neccessary * checks config file for changes and relaods if neccessary
*/ */
function __wakeup() function __wakeup()
@@ -495,51 +499,51 @@ class PMA_Config
$url = array(); $url = array();
// At first we try to parse REQUEST_URI, it might contain full URI // At first we try to parse REQUEST_URI, it might contain full URI
if ( ! empty($_SERVER['REQUEST_URI'] ) ) { if (getenv('REQUEST_URI')) {
$url = parse_url($_SERVER['REQUEST_URI']); $url = parse_url(getenv('REQUEST_URI'));
} }
// If we don't have scheme, we didn't have full URL so we need to // If we don't have scheme, we didn't have full URL so we need to
// dig deeper // dig deeper
if (empty($url['scheme'])) { if (empty($url['scheme'])) {
// Scheme // Scheme
if ( ! empty( $_SERVER['HTTP_SCHEME'] ) ) { if (getenv('HTTP_SCHEME')) {
$url['scheme'] = $_SERVER['HTTP_SCHEME']; $url['scheme'] = getenv('HTTP_SCHEME');
} else { } else {
$url['scheme'] = $url['scheme'] =
!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' getenv('HTTPS') && strtolower(getenv('HTTPS')) != 'off'
? 'https' ? 'https'
: 'http'; : 'http';
} }
// Host and port // Host and port
if ( ! empty( $_SERVER['HTTP_HOST'] ) ) { if (getenv('HTTP_HOST')) {
if ( strpos($_SERVER['HTTP_HOST'], ':') !== false ) { if (strpos(getenv('HTTP_HOST'), ':') !== false) {
list($url['host'], $url['port']) = list($url['host'], $url['port']) =
explode(':', $_SERVER['HTTP_HOST']); explode(':', getenv('HTTP_HOST'));
} else { } else {
$url['host'] = $_SERVER['HTTP_HOST']; $url['host'] = getenv('HTTP_HOST');
} }
} elseif ( ! empty( $_SERVER['SERVER_NAME'] ) ) { } elseif (getenv('SERVER_NAME')) {
$url['host'] = $_SERVER['SERVER_NAME']; $url['host'] = getenv('SERVER_NAME');
} else { } else {
$this->error_pma_uri = true; $this->error_pma_uri = true;
return false; return false;
} }
// If we didn't set port yet... // If we didn't set port yet...
if ( empty( $url['port'] ) && ! empty( $_SERVER['SERVER_PORT'] ) ) { if (empty($url['port']) && getenv('SERVER_PORT')) {
$url['port'] = $_SERVER['SERVER_PORT']; $url['port'] = getenv('SERVER_PORT');
} }
// And finally the path could be already set from REQUEST_URI // And finally the path could be already set from REQUEST_URI
if (empty($url['path'])) { if (empty($url['path'])) {
if (!empty($_SERVER['PATH_INFO'])) { if (getenv('PATH_INFO')) {
$path = parse_url($_SERVER['PATH_INFO']); $path = parse_url(getenv('PATH_INFO'));
} else { } else {
// PHP_SELF in CGI often points to cgi executable, so use it // PHP_SELF in CGI often points to cgi executable, so use it
// as last choice // as last choice
$path = parse_url($_SERVER['PHP_SELF']); $path = parse_url(getenv('PHP_SELF'));
} }
$url['path'] = $path['path']; $url['path'] = $path['path'];
} }
@@ -609,7 +613,7 @@ class PMA_Config
if (substr($pma_absolute_uri, 0, 7) != 'http://' if (substr($pma_absolute_uri, 0, 7) != 'http://'
&& substr($pma_absolute_uri, 0, 8) != 'https://') { && substr($pma_absolute_uri, 0, 8) != 'https://') {
$pma_absolute_uri = $pma_absolute_uri =
(!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' (getenv('HTTPS') && strtolower(getenv('HTTPS')) != 'off'
? 'https' ? 'https'
: 'http') : 'http')
. ':' . (substr($pma_absolute_uri, 0, 2) == '//' ? '' : '//') . ':' . (substr($pma_absolute_uri, 0, 2) == '//' ? '' : '//')
@@ -685,19 +689,19 @@ class PMA_Config
$url = array(); $url = array();
// At first we try to parse REQUEST_URI, it might contain full URI // At first we try to parse REQUEST_URI, it might contain full URI
if ( ! empty($_SERVER['REQUEST_URI'] ) ) { if (getenv('REQUEST_URI')) {
$url = parse_url($_SERVER['REQUEST_URI']); $url = parse_url(getenv('REQUEST_URI'));
} }
// If we don't have scheme, we didn't have full URL so we need to // If we don't have scheme, we didn't have full URL so we need to
// dig deeper // dig deeper
if (empty($url['scheme'])) { if (empty($url['scheme'])) {
// Scheme // Scheme
if ( ! empty( $_SERVER['HTTP_SCHEME'] ) ) { if (getenv('HTTP_SCHEME')) {
$url['scheme'] = $_SERVER['HTTP_SCHEME']; $url['scheme'] = getenv('HTTP_SCHEME');
} else { } else {
$url['scheme'] = $url['scheme'] =
!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' getenv('HTTPS') && strtolower(getenv('HTTPS')) != 'off'
? 'https' ? 'https'
: 'http'; : 'http';
} }
@@ -732,23 +736,23 @@ class PMA_Config
return $cookie_path; return $cookie_path;
} }
if ( ! empty($_SERVER['REQUEST_URI'] ) ) { if (getenv('REQUEST_URI')) {
$url = parse_url($_SERVER['REQUEST_URI']); $url = parse_url(getenv('REQUEST_URI'));
} }
// If we don't have path // If we don't have path
if (empty($url['path'])) { if (empty($url['path'])) {
if (!empty($_SERVER['PATH_INFO'])) { if (getenv('PATH_INFO')) {
$url = parse_url($_SERVER['PATH_INFO']); $url = parse_url(getenv('PATH_INFO'));
} else { } elseif (getenv('PHP_SELF')) {
// PHP_SELF in CGI often points to cgi executable, so use it // PHP_SELF in CGI often points to cgi executable, so use it
// as last choice // as last choice
$url = parse_url($_SERVER['PHP_SELF']); $url = parse_url(getenv('PHP_SELF'));
} }
} }
$cookie_path = substr($url['path'], 0, $cookie_path = substr($url['path'], 0, strrpos($url['path'], '/'))
strrpos($url['path'], '/')) . '/'; . '/';
return $cookie_path; return $cookie_path;
} }