From 77e68e5a392262d43f1b513a30a9523f36d5f760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 2 Nov 2005 19:46:47 +0000 Subject: [PATCH] Use $cfg['Servers'][1] from config.default.php as defaults for settings in config.inc.php (bug #1330847). --- ChangeLog | 3 ++ Documentation.html | 6 ++- config.default.php | 79 +++------------------------------------- libraries/common.lib.php | 39 ++++++++++++++++++++ 4 files changed, 51 insertions(+), 76 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ab4dbae4..666d252e3 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ $Source$ 2005-11-02 Michal Čihař * config.default.php: This is not a configuration file. + * config.default.php, Documentation.html, libraries/common.lib.php: Use + $cfg['Servers'][1] from config.default.php as defaults for settings in + config.inc.php (bug #1330847). 2005-11-02 Sebastian Mendel * libraries/dbg/setup.php: diff --git a/Documentation.html b/Documentation.html index 9a9042c58..0900166dd 100755 --- a/Documentation.html +++ b/Documentation.html @@ -442,8 +442,10 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON <pma_db>.* TO 'pma'@'localhost'; $cfg['Servers'][$i]['host'] contains the hostname of the first server, the second $cfg['Servers'][$i]['host'] the hostname of the second server, etc. - If you have only one server to administer, simply leave free the - hostname of the other $cfg['Server']-entries. + In configuration defaults file, there is just one section for server + definition, howerver you can have as much as you need, just copy that + block or needed parts (you don't have to define all settings, just + those you need to change).

diff --git a/config.default.php b/config.default.php index 90c1b0a5e..491bdc8cf 100644 --- a/config.default.php +++ b/config.default.php @@ -48,8 +48,11 @@ $cfg['blowfish_secret'] = ''; * Server(s) configuration */ $i = 0; -// The $cfg['Servers'] array starts with $cfg['Servers'][1]. Do not use $cfg['Servers'][0]. -// You can disable a server config entry by setting host to ''. +// The $cfg['Servers'] array starts with $cfg['Servers'][1]. Do not use +// $cfg['Servers'][0]. You can disable a server config entry by setting host +// to ''. If you want more than one server, just copy following section +// (including $i incrementation) serveral times. There is no need to define +// full server array, just define values you need to change. $i++; $cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname or IP address $cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port @@ -108,84 +111,12 @@ $cfg['Servers'][$i]['AllowDeny']['order'] // Host authentication order $cfg['Servers'][$i]['AllowDeny']['rules'] // Host authentication rules, leave blank for defaults = array(); -/** - * If you are configuring for only one server, stop here. You can jump to the next - * section called "Other core phpMyAdmin settings." - * The following section allows you to add a second server to this installation. - */ - -$i++; -$cfg['Servers'][$i]['host'] = ''; -$cfg['Servers'][$i]['port'] = ''; -$cfg['Servers'][$i]['socket'] = ''; -$cfg['Servers'][$i]['connect_type'] = 'tcp'; -$cfg['Servers'][$i]['extension'] = 'mysql'; -$cfg['Servers'][$i]['compress'] = FALSE; -$cfg['Servers'][$i]['controluser'] = ''; -$cfg['Servers'][$i]['controlpass'] = ''; -$cfg['Servers'][$i]['auth_type'] = 'config'; -$cfg['Servers'][$i]['user'] = 'root'; -$cfg['Servers'][$i]['password'] = ''; -$cfg['Servers'][$i]['only_db'] = ''; -$cfg['Servers'][$i]['verbose'] = ''; -$cfg['Servers'][$i]['pmadb'] = ''; // 'phpmyadmin' - see scripts/create_tables.sql -$cfg['Servers'][$i]['bookmarktable'] = ''; // 'pma_bookmark' -$cfg['Servers'][$i]['relation'] = ''; // 'pma_relation' -$cfg['Servers'][$i]['table_info'] = ''; // 'pma_table_info' -$cfg['Servers'][$i]['table_coords'] = ''; // 'pma_table_coords' -$cfg['Servers'][$i]['pdf_pages'] = ''; // 'pma_pdf_pages' -$cfg['Servers'][$i]['column_info'] = ''; // 'pma_column_info' -$cfg['Servers'][$i]['history'] = ''; // 'pma_history' -$cfg['Servers'][$i]['verbose_check'] = TRUE; -$cfg['Servers'][$i]['AllowRoot'] = TRUE; -$cfg['Servers'][$i]['AllowDeny']['order'] - = ''; -$cfg['Servers'][$i]['AllowDeny']['rules'] - = array(); - -/** - * This section allows you to configure a third server for this installation. - */ - -$i++; -$cfg['Servers'][$i]['host'] = ''; -$cfg['Servers'][$i]['port'] = ''; -$cfg['Servers'][$i]['socket'] = ''; -$cfg['Servers'][$i]['connect_type'] = 'tcp'; -$cfg['Servers'][$i]['extension'] = 'mysql'; -$cfg['Servers'][$i]['compress'] = FALSE; -$cfg['Servers'][$i]['controluser'] = ''; -$cfg['Servers'][$i]['controlpass'] = ''; -$cfg['Servers'][$i]['auth_type'] = 'config'; -$cfg['Servers'][$i]['user'] = 'root'; -$cfg['Servers'][$i]['password'] = ''; -$cfg['Servers'][$i]['only_db'] = ''; -$cfg['Servers'][$i]['verbose'] = ''; -$cfg['Servers'][$i]['pmadb'] = ''; // 'phpmyadmin' - see scripts/create_tables.sql -$cfg['Servers'][$i]['bookmarktable'] = ''; // 'pma_bookmark' -$cfg['Servers'][$i]['relation'] = ''; // 'pma_relation' -$cfg['Servers'][$i]['table_info'] = ''; // 'pma_table_info' -$cfg['Servers'][$i]['table_coords'] = ''; // 'pma_table_coords' -$cfg['Servers'][$i]['pdf_pages'] = ''; // 'pma_pdf_pages' -$cfg['Servers'][$i]['column_info'] = ''; // 'pma_column_info' -$cfg['Servers'][$i]['history'] = ''; // 'pma_history' -$cfg['Servers'][$i]['verbose_check'] = TRUE; -$cfg['Servers'][$i]['AllowRoot'] = TRUE; - -$cfg['Servers'][$i]['AllowDeny']['order'] - = ''; -$cfg['Servers'][$i]['AllowDeny']['rules'] - = array(); - // If you have more than one server configured, you can set $cfg['ServerDefault'] // to any one of them to autoconnect to that server when phpMyAdmin is started, // or set it to 0 to be given a list of servers without logging in // If you have only one server configured, $cfg['ServerDefault'] *MUST* be // set to that server. $cfg['ServerDefault'] = 1; // Default server (0 = no default server) -$cfg['Server'] = ''; -unset($cfg['Servers'][0]); - /** * Other core phpMyAdmin settings diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 1f0239519..0e4c6a57c 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -87,6 +87,12 @@ if (file_exists('./lang/added_messages.php')) { */ include './config.default.php'; +// Remember default server config +$default_server = $cfg['Servers'][1]; + +// Drop all server, as they have to be configured by user +unset($cfg['Servers']); + /** * Parses the configuration file and gets some constants used to define * versions of phpMyAdmin/php/mysql... @@ -127,6 +133,39 @@ if (file_exists('./config.inc.php')) { */ require_once('./libraries/select_lang.lib.php'); +/** + * Servers array fixups. + */ +// Do we have some server? +if (!isset($cfg['Servers']) || count($cfg['Servers']) == 0) { + // No server => create one with defaults + $cfg['Servers'] = array(1 => $default_server); +} else { + // We have server(s) => apply default config + $new_servers = array(); + foreach($cfg['Servers'] as $key => $val) { + if (!is_int($key) || $key < 1) { + // Show error + header( 'Location: error.php' + . '?lang=' . urlencode( $available_languages[$lang][2] ) + . '&char=' . urlencode( $charset ) + . '&dir=' . urlencode( $text_dir ) + . '&type=' . urlencode( $strError ) + . '&error=' . urlencode( +// FIXME: We could translate this message, however it's translations freeze right now: + sprintf( 'Invalid server index: "%s"', $key)) + . '&' . SID + ); + } + $new_servers[$key] = array_merge($default_server, $val); + } + $cfg['Servers'] = $new_servers; + unset($new_servers); +} + +// Cleanup +unset($default_server); + /** * We really need this one! */