From b7796e429cbc5ba8f9d7a657c13a42b0d926620b Mon Sep 17 00:00:00 2001
From: Marc Delisle
Date: Wed, 27 Dec 2006 14:08:43 +0000
Subject: [PATCH] patch #1592366, using a host name as a URL parameter
---
ChangeLog | 5 +++++
Documentation.html | 5 +++++
libraries/common.lib.php | 21 ++++++++++++++++++++-
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 614f6afe6..d6a7fff4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,11 @@ phpMyAdmin - ChangeLog
$Id$
$HeadURL$
+2006-12-27 Marc Delisle
+ * Documentation.html, libraries/common.lib.php: patch #1592366,
+ possibility of using the host name as a parameter in the URL,
+ thanks to Arnold Daniels
+
2006-12-26 Marc Delisle
* export.php: set $local_query only if we are exporting data
* export.php, libraries/export/latex.php, /sql.php, /htmlword.php,
diff --git a/Documentation.html b/Documentation.html
index cc8d02c7b..a858ee598 100644
--- a/Documentation.html
+++ b/Documentation.html
@@ -3169,6 +3169,11 @@ $cfg['Servers'][$i]['AllowDeny']['rules'] = array(
For example, a missing "www", or entering with an IP address
while a domain name is defined in the config file.
+
+
+When starting phpMyAdmin, you can use the db, pma_username, pma_password and server parameters. This last one can contain either the numeric host index (from $i of the configuration file) or one of the host names present in the configuration file. Using pma_username and pma_password has been tested along with the usage of 'cookie' auth_type.
+
Browsers or client OS
diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index 290442927..1ae3315c2 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -3004,6 +3004,24 @@ if (! defined('PMA_MINIMUM_COMMON')) {
*/
require_once './libraries/string.lib.php';
+ /**
+ * Lookup server by name
+ * by Arnold - Helder Hosting
+ * (see FAQ 4.8)
+ */
+ if (! empty($_REQUEST['server']) && is_string($_REQUEST['server']) && ! ctype_digit($_REQUEST['server'])) {
+ foreach ($cfg['Servers'] as $i => $server) {
+ if ($server['host'] == $_REQUEST['server']) {
+ $_REQUEST['server'] = $i;
+ break;
+ }
+ }
+ if (is_string($_REQUEST['server'])) {
+ unset($_REQUEST['server']);
+ }
+ unset($i);
+ }
+
/**
* If no server is selected, make sure that $cfg['Server'] is empty (so
* that nothing will work), and skip server authentication.
@@ -3012,7 +3030,8 @@ if (! defined('PMA_MINIMUM_COMMON')) {
* present a choice of servers in the case that there are multiple servers
* and '$cfg['ServerDefault'] = 0' is set.
*/
- if (isset($_REQUEST['server']) && is_string($_REQUEST['server']) && ! empty($_REQUEST['server']) && ! empty($cfg['Servers'][$_REQUEST['server']])) {
+
+ if (isset($_REQUEST['server']) && (is_string($_REQUEST['server']) || is_numeric($_REQUEST['server'])) && ! empty($_REQUEST['server']) && ! empty($cfg['Servers'][$_REQUEST['server']])) {
$GLOBALS['server'] = $_REQUEST['server'];
$cfg['Server'] = $cfg['Servers'][$GLOBALS['server']];
} else {