<?php
...
function checkPmaAbsoluteUri()
{
// Setup a default value to let the people and lazy syadmins work anyway,
// they'll get an error if the autodetect code doesn't work
$pma_absolute_uri = $this->get('PmaAbsoluteUri');
$is_https = $this->get('is_https');
if (strlen($pma_absolute_uri) < 5
// needed to catch http/https switch
|| ($is_https && substr($pma_absolute_uri, 0, 6) != 'https:')
|| (!$is_https && substr($pma_absolute_uri, 0, 5) != 'http:')
) {
$url = array();
// At first we try to parse REQUEST_URI, it might contain full URL
if (PMA_getenv('REQUEST_URI')) {
$url = @parse_url(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
if ($url === false) {
$url = array('path' => $_SERVER['REQUEST_URI']);
}
}
// If we don't have scheme, we didn't have full URL so we need to
// dig deeper
if (empty($url['scheme'])) {
// Scheme
if (PMA_getenv('HTTP_SCHEME')) {
$url['scheme'] = PMA_getenv('HTTP_SCHEME');
} else {
$url['scheme'] =
PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
? 'https'
: 'http';
}
// Host and port
if (PMA_getenv('HTTP_HOST')) {
if (strpos(PMA_getenv('HTTP_HOST'), ':') !== false) {
list($url['host'], $url['port']) =
explode(':', PMA_getenv('HTTP_HOST'));
} else {
$url['host'] = PMA_getenv('HTTP_HOST');
}
} elseif (PMA_getenv('SERVER_NAME')) {
$url['host'] = PMA_getenv('SERVER_NAME');
} else {
$this->error_pma_uri = true;
return false;
}
// If we didn't set port yet...
if (empty($url['port']) && PMA_getenv('SERVER_PORT')) {
$url['port'] = PMA_getenv('SERVER_PORT');
}
// And finally the path could be already set from REQUEST_URI
if (empty($url['path'])) {
if (PMA_getenv('PATH_INFO')) {
$path = parse_url(PMA_getenv('PATH_INFO'));
} else {
// PHP_SELF in CGI often points to cgi executable, so use it
// as last choice
$path = parse_url(PMA_getenv('PHP_SELF'));
}
$url['path'] = $path['path'];
}
}
// Make url from parts we have
$pma_absolute_uri = $url['scheme'] . '://';
// Was there user information?
if (!empty($url['user'])) {
$pma_absolute_uri .= $url['user'];
if (!empty($url['pass'])) {
$pma_absolute_uri .= ':' . $url['pass'];
}
$pma_absolute_uri .= '@';
}
// Add hostname
$pma_absolute_uri .= $url['host'];
// Add port, if it not the default one
if (! empty($url['port'])
&& (($url['scheme'] == 'http' && $url['port'] != 80)
|| ($url['scheme'] == 'https' && $url['port'] != 443))) {
$pma_absolute_uri .= ':' . $url['port'];
}
// And finally path, without script name, the 'a' is there not to
// strip our directory, when path is only /pmadir/ without filename.
// Backslashes returned by Windows have to be changed.
// Only replace backslashes by forward slashes if on Windows,
// as the backslash could be valid on a non-Windows system.
if ($this->get('PMA_IS_WINDOWS') == 1) {
$path = str_replace("\\", "/", dirname($url['path'] . 'a'));
} else {
$path = dirname($url['path'] . 'a');
}
// To work correctly within transformations overview:
if (defined('PMA_PATH_TO_BASEDIR') && PMA_PATH_TO_BASEDIR == '../../') {
if ($this->get('PMA_IS_WINDOWS') == 1) {
$path = str_replace("\\", "/", dirname(dirname($path)));
} else {
$path = dirname(dirname($path));
}
}
// in vhost situations, there could be already an ending slash
if (substr($path, -1) != '/') {
$path .= '/';
}
$pma_absolute_uri .= $path;
// We used to display a warning if PmaAbsoluteUri wasn't set, but now
// the autodetect code works well enough that we don't display the
// warning at all. The user can still set PmaAbsoluteUri manually.
// See
// http://sf.net/tracker/?func=detail&aid=1257134&group_id=23067&atid=377411
} else {
// The URI is specified, however users do often specify this
// wrongly, so we try to fix this.
// Adds a trailing slash et the end of the phpMyAdmin uri if it
// does not exist.
if (substr($pma_absolute_uri, -1) != '/') {
$pma_absolute_uri .= '/';
}
// If URI doesn't start with http:// or https://, we will add
// this.
if (substr($pma_absolute_uri, 0, 7) != 'http://'
&& substr($pma_absolute_uri, 0, 8) != 'https://') {
$pma_absolute_uri =
(PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
? 'https'
: 'http')
. ':' . (substr($pma_absolute_uri, 0, 2) == '//' ? '' : '//')
. $pma_absolute_uri;
}
}
$this->set('PmaAbsoluteUri', $pma_absolute_uri); // <-- Auskommentieren !!!
/*
* #############################################################
* # Die vorherige Zeile auskommentieren, sobald man in der #
* # config.inc.php die richtige absolute URL eingetragen hat. #
* #############################################################
*/
}
...
?>