From fc270335cf323b0ce6c60daa6121e6e073537ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Dec 2005 13:21:00 +0000 Subject: [PATCH] Add support for hiding databases (RFE #1372865). --- ChangeLog | 5 +++++ Documentation.html | 8 ++++++++ libraries/common.lib.php | 2 +- libraries/config.default.php | 1 + libraries/database_interface.lib.php | 6 +++--- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e67dbbf23..1e074d43a 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,11 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-12-16 Michal Čihař + * Documentation.html, libraries/common.lib.php, + libraries/config.default.php, libraries/database_interface.lib.php: Add + support for hiding databases (RFE #1372865). + 2005-12-14 Sebastian Mendel * libraries/Config.class.php: - added check is_readable for user config file diff --git a/Documentation.html b/Documentation.html index dd6c257e7..02d8194c8 100755 --- a/Documentation.html +++ b/Documentation.html @@ -648,6 +648,14 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON <pma_db>.* TO 'pma'@'localhost'; order. +
+ $cfg['Servers'][$i]['hide_db'] string +
+
+ Regullar expression for hiding some databases. This only hides them + from listing, but user is still able to access them. +
+
$cfg['Servers'][$i]['verbose'] string
Only useful when using phpMyAdmin with multiple server entries. If set, diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 3808576e3..3afbabbe7 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -988,7 +988,7 @@ if (!defined('PMA_MINIMUM_COMMON')) { // authentification process -> gets the available databases list if (count($dblist)) { foreach ($dblist as $key => $db) { - if (!@PMA_DBI_select_db($db)) { + if (!@PMA_DBI_select_db($db, $link) || (!empty($GLOBALS['cfg']['Server']['hide_db']) && preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db))) { unset($dblist[$key]); } // end if } // end for diff --git a/libraries/config.default.php b/libraries/config.default.php index add1dd6b0..c7a9976f3 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -75,6 +75,7 @@ $cfg['Servers'][$i]['password'] = ''; // MySQL password (only need $cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only // this db is displayed in left frame // It may also be an array of db-names, where sorting order is relevant. +$cfg['Servers'][$i]['hide_db'] = ''; // Database name to be hidden from listings $cfg['Servers'][$i]['verbose'] = ''; // Verbose name for this host - leave blank to show the hostname $cfg['Servers'][$i]['pmadb'] = ''; // Database used for Relation, Bookmark and PDF Features diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index 174c6c79d..e6bdedba6 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -176,9 +176,9 @@ function PMA_DBI_get_dblist($link = null) // Before MySQL 4.0.2, SHOW DATABASES could send the // whole list, so check if we really have access: - if ( PMA_MYSQL_INT_VERSION < 40002 ) { - foreach ( $dbs_array as $key => $db ) { - if ( ! PMA_DBI_select_db( $db, $link ) ) { + if (PMA_MYSQL_INT_VERSION < 40002 || !empty($GLOBALS['cfg']['Server']['hide_db'])) { + foreach ($dbs_array as $key => $db) { + if (!@PMA_DBI_select_db($db, $link) || (!empty($GLOBALS['cfg']['Server']['hide_db']) && preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db))) { unset( $dbs_array[$key] ); } }