dbh becomes controllink
This commit is contained in:
@@ -7,6 +7,7 @@ $Source$
|
|||||||
|
|
||||||
2005-11-20 Marc Delisle <lem9@users.sourceforge.net>
|
2005-11-20 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
### 2.7.0-rc1 released
|
### 2.7.0-rc1 released
|
||||||
|
* many files: $dbh becomes $controllink for better contrast with $userlink
|
||||||
|
|
||||||
2005-11-20 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
2005-11-20 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
* libraries/common.lib.php::PMA_showMySQLDocu()
|
* libraries/common.lib.php::PMA_showMySQLDocu()
|
||||||
|
@@ -293,8 +293,8 @@ if (isset($disp_row) && is_array($disp_row)) {
|
|||||||
/**
|
/**
|
||||||
* Close MySql connections
|
* Close MySql connections
|
||||||
*/
|
*/
|
||||||
if (isset($dbh) && $dbh) {
|
if (isset($controllink) && $controllink) {
|
||||||
@PMA_DBI_close($dbh);
|
@PMA_DBI_close($controllink);
|
||||||
}
|
}
|
||||||
if (isset($userlink) && $userlink) {
|
if (isset($userlink) && $userlink) {
|
||||||
@PMA_DBI_close($userlink);
|
@PMA_DBI_close($userlink);
|
||||||
|
@@ -898,7 +898,7 @@ if (isset($Field) && count($Field) > 0) {
|
|||||||
*/
|
*/
|
||||||
function PMA_getRelatives($from) {
|
function PMA_getRelatives($from) {
|
||||||
global $tab_left, $tab_know, $fromclause;
|
global $tab_left, $tab_know, $fromclause;
|
||||||
global $dbh, $db, $cfgRelation;
|
global $controllink, $db, $cfgRelation;
|
||||||
|
|
||||||
if ($from == 'master') {
|
if ($from == 'master') {
|
||||||
$to = 'foreign';
|
$to = 'foreign';
|
||||||
@@ -914,9 +914,9 @@ if (isset($Field) && count($Field) > 0) {
|
|||||||
. ' AND ' . $to . '_db = \'' . PMA_sqlAddslashes($db) . '\''
|
. ' AND ' . $to . '_db = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
. ' AND ' . $from . '_table IN ' . $in_know
|
. ' AND ' . $from . '_table IN ' . $in_know
|
||||||
. ' AND ' . $to . '_table IN ' . $in_left;
|
. ' AND ' . $to . '_table IN ' . $in_left;
|
||||||
PMA_DBI_select_db($cfgRelation['db'], $dbh);
|
PMA_DBI_select_db($cfgRelation['db'], $controllink);
|
||||||
$relations = @PMA_DBI_query($rel_query, $dbh);
|
$relations = @PMA_DBI_query($rel_query, $controllink);
|
||||||
PMA_DBI_select_db($db, $dbh);
|
PMA_DBI_select_db($db, $controllink);
|
||||||
while ($row = PMA_DBI_fetch_assoc($relations)) {
|
while ($row = PMA_DBI_fetch_assoc($relations)) {
|
||||||
$found_table = $row[$to . '_table'];
|
$found_table = $row[$to . '_table'];
|
||||||
if (isset($tab_left[$found_table])) {
|
if (isset($tab_left[$found_table])) {
|
||||||
|
@@ -71,8 +71,8 @@ require_once('./libraries/relation.lib.php'); // for PMA_setHistory()
|
|||||||
/**
|
/**
|
||||||
* Close database connections
|
* Close database connections
|
||||||
*/
|
*/
|
||||||
if ( isset( $GLOBALS['dbh'] ) && $GLOBALS['dbh'] ) {
|
if ( isset( $GLOBALS['controllink'] ) && $GLOBALS['controllink'] ) {
|
||||||
@PMA_DBI_close( $GLOBALS['dbh'] );
|
@PMA_DBI_close( $GLOBALS['controllink'] );
|
||||||
}
|
}
|
||||||
if ( isset( $GLOBALS['userlink'] ) && $GLOBALS['userlink'] ) {
|
if ( isset( $GLOBALS['userlink'] ) && $GLOBALS['userlink'] ) {
|
||||||
@PMA_DBI_close( $GLOBALS['userlink'] );
|
@PMA_DBI_close( $GLOBALS['userlink'] );
|
||||||
|
8
left.php
8
left.php
@@ -117,8 +117,8 @@ if ( $num_dbs === 0 ) {
|
|||||||
/**
|
/**
|
||||||
* Close MySql connections
|
* Close MySql connections
|
||||||
*/
|
*/
|
||||||
if (isset($dbh) && $dbh) {
|
if (isset($controllink) && $controllink) {
|
||||||
@PMA_DBI_close($dbh);
|
@PMA_DBI_close($controllink);
|
||||||
}
|
}
|
||||||
if (isset($userlink) && $userlink) {
|
if (isset($userlink) && $userlink) {
|
||||||
@PMA_DBI_close($userlink);
|
@PMA_DBI_close($userlink);
|
||||||
@@ -498,8 +498,8 @@ function PMA_displayTableList( $tables, $visible = false,
|
|||||||
/**
|
/**
|
||||||
* Close MySql connections
|
* Close MySql connections
|
||||||
*/
|
*/
|
||||||
if (isset($dbh) && $dbh) {
|
if (isset($controllink) && $controllink) {
|
||||||
@PMA_DBI_close($dbh);
|
@PMA_DBI_close($controllink);
|
||||||
}
|
}
|
||||||
if (isset($userlink) && $userlink) {
|
if (isset($userlink) && $userlink) {
|
||||||
@PMA_DBI_close($userlink);
|
@PMA_DBI_close($userlink);
|
||||||
|
@@ -49,14 +49,14 @@ function PMA_getBookmarksParam()
|
|||||||
*/
|
*/
|
||||||
function PMA_listBookmarks($db, $cfgBookmark)
|
function PMA_listBookmarks($db, $cfgBookmark)
|
||||||
{
|
{
|
||||||
global $dbh;
|
global $controllink;
|
||||||
|
|
||||||
$query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
|
$query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
|
||||||
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
|
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
. ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
|
. ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
|
||||||
. ' OR user = \'\')'
|
. ' OR user = \'\')'
|
||||||
. ' ORDER BY label';
|
. ' ORDER BY label';
|
||||||
$result = PMA_DBI_query($query, $dbh, PMA_DBI_QUERY_STORE);
|
$result = PMA_DBI_query($query, $controllink, PMA_DBI_QUERY_STORE);
|
||||||
|
|
||||||
// There are some bookmarks -> store them
|
// There are some bookmarks -> store them
|
||||||
// use the unique id as the key
|
// use the unique id as the key
|
||||||
@@ -90,7 +90,7 @@ function PMA_listBookmarks($db, $cfgBookmark)
|
|||||||
*/
|
*/
|
||||||
function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id', $action_bookmark_all = FALSE)
|
function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id', $action_bookmark_all = FALSE)
|
||||||
{
|
{
|
||||||
global $dbh;
|
global $controllink;
|
||||||
|
|
||||||
if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
|
if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
|
||||||
return '';
|
return '';
|
||||||
@@ -101,7 +101,7 @@ function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id', $action_bo
|
|||||||
. ($action_bookmark_all? '' : ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
|
. ($action_bookmark_all? '' : ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
|
||||||
. ' OR user = \'\')' )
|
. ' OR user = \'\')' )
|
||||||
. ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
|
. ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
|
||||||
$result = PMA_DBI_try_query($query, $dbh);
|
$result = PMA_DBI_try_query($query, $controllink);
|
||||||
if (!$result) return FALSE;
|
if (!$result) return FALSE;
|
||||||
list($bookmark_query) = PMA_DBI_fetch_row($result) or array(FALSE);
|
list($bookmark_query) = PMA_DBI_fetch_row($result) or array(FALSE);
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id', $action_bo
|
|||||||
*/
|
*/
|
||||||
function &PMA_queryDBBookmarks($db, $cfgBookmark, &$table_array)
|
function &PMA_queryDBBookmarks($db, $cfgBookmark, &$table_array)
|
||||||
{
|
{
|
||||||
global $dbh;
|
global $controllink;
|
||||||
$bookmarks = array();
|
$bookmarks = array();
|
||||||
|
|
||||||
if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
|
if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
|
||||||
@@ -139,7 +139,7 @@ function &PMA_queryDBBookmarks($db, $cfgBookmark, &$table_array)
|
|||||||
$query = 'SELECT label, query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
|
$query = 'SELECT label, query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
|
||||||
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
|
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
. (count($search_for) > 0 ? ' AND label IN (' . implode(', ', $search_for) . ')' : '');
|
. (count($search_for) > 0 ? ' AND label IN (' . implode(', ', $search_for) . ')' : '');
|
||||||
$result = PMA_DBI_try_query($query, $dbh, PMA_DBI_QUERY_STORE);
|
$result = PMA_DBI_try_query($query, $controllink, PMA_DBI_QUERY_STORE);
|
||||||
if (!$result || PMA_DBI_num_rows($result) < 1) return $bookmarks;
|
if (!$result || PMA_DBI_num_rows($result) < 1) return $bookmarks;
|
||||||
while ($row = PMA_DBI_fetch_assoc($result)) {
|
while ($row = PMA_DBI_fetch_assoc($result)) {
|
||||||
$bookmarks[$row['label']] = $row['query'];
|
$bookmarks[$row['label']] = $row['query'];
|
||||||
@@ -163,11 +163,11 @@ function &PMA_queryDBBookmarks($db, $cfgBookmark, &$table_array)
|
|||||||
*/
|
*/
|
||||||
function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
|
function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
|
||||||
{
|
{
|
||||||
global $dbh;
|
global $controllink;
|
||||||
|
|
||||||
$query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
|
$query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
|
||||||
. ' (id, dbase, user, query, label) VALUES (NULL, \'' . PMA_sqlAddslashes($fields['dbase']) . '\', \'' . ($all_users ? '' : PMA_sqlAddslashes($fields['user'])) . '\', \'' . PMA_sqlAddslashes(urldecode($fields['query'])) . '\', \'' . PMA_sqlAddslashes($fields['label']) . '\')';
|
. ' (id, dbase, user, query, label) VALUES (NULL, \'' . PMA_sqlAddslashes($fields['dbase']) . '\', \'' . ($all_users ? '' : PMA_sqlAddslashes($fields['user'])) . '\', \'' . PMA_sqlAddslashes(urldecode($fields['query'])) . '\', \'' . PMA_sqlAddslashes($fields['label']) . '\')';
|
||||||
$result = PMA_DBI_query($query, $dbh);
|
$result = PMA_DBI_query($query, $controllink);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} // end of the 'PMA_addBookmarks()' function
|
} // end of the 'PMA_addBookmarks()' function
|
||||||
@@ -186,13 +186,13 @@ function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
|
|||||||
*/
|
*/
|
||||||
function PMA_deleteBookmarks($db, $cfgBookmark, $id)
|
function PMA_deleteBookmarks($db, $cfgBookmark, $id)
|
||||||
{
|
{
|
||||||
global $dbh;
|
global $controllink;
|
||||||
|
|
||||||
$query = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
|
$query = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
|
||||||
. ' WHERE (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
|
. ' WHERE (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
|
||||||
. ' OR user = \'\')'
|
. ' OR user = \'\')'
|
||||||
. ' AND id = ' . $id;
|
. ' AND id = ' . $id;
|
||||||
$result = PMA_DBI_try_query($query, $dbh);
|
$result = PMA_DBI_try_query($query, $controllink);
|
||||||
} // end of the 'PMA_deleteBookmarks()' function
|
} // end of the 'PMA_deleteBookmarks()' function
|
||||||
|
|
||||||
|
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
// vim: expandtab sw=4 ts=4 sts=4:
|
// vim: expandtab sw=4 ts=4 sts=4:
|
||||||
|
|
||||||
// Get user's global privileges and some db-specific privileges
|
// Get user's global privileges and some db-specific privileges
|
||||||
// ($dbh and $userlink are links to MySQL defined in the "common.lib.php" library)
|
// ($controllink and $userlink are links to MySQL defined in the "common.lib.php" library)
|
||||||
// Note: if no controluser is defined, $dbh contains $userlink
|
// Note: if no controluser is defined, $controllink contains $userlink
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true (int > 0) if current user is superuser
|
* returns true (int > 0) if current user is superuser
|
||||||
@@ -97,7 +97,7 @@ if (PMA_MYSQL_INT_VERSION >= 40102) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Before MySQL 4.1.2, we first try to find a priv in mysql.user. Hopefuly
|
// Before MySQL 4.1.2, we first try to find a priv in mysql.user. Hopefuly
|
||||||
// the controluser is correctly defined; but here, $dbh could contain
|
// the controluser is correctly defined; but here, $controllink could contain
|
||||||
// $userlink so maybe the SELECT will fail
|
// $userlink so maybe the SELECT will fail
|
||||||
|
|
||||||
if (!$is_create_db_priv) {
|
if (!$is_create_db_priv) {
|
||||||
@@ -106,7 +106,7 @@ if (PMA_MYSQL_INT_VERSION >= 40102) {
|
|||||||
$mysql_cur_user = substr($mysql_cur_user_and_host, 0, strrpos($mysql_cur_user_and_host, '@'));
|
$mysql_cur_user = substr($mysql_cur_user_and_host, 0, strrpos($mysql_cur_user_and_host, '@'));
|
||||||
|
|
||||||
$local_query = 'SELECT Create_priv, Reload_priv FROM mysql.user WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($mysql_cur_user), 'quoted') . ' OR ' . PMA_convert_using('User') . ' = ' . PMA_convert_using('', 'quoted') . ';';
|
$local_query = 'SELECT Create_priv, Reload_priv FROM mysql.user WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($mysql_cur_user), 'quoted') . ' OR ' . PMA_convert_using('User') . ' = ' . PMA_convert_using('', 'quoted') . ';';
|
||||||
$rs_usr = PMA_DBI_try_query($local_query, $dbh, PMA_DBI_QUERY_STORE); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
|
$rs_usr = PMA_DBI_try_query($local_query, $controllink, PMA_DBI_QUERY_STORE); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
|
||||||
if ($rs_usr) {
|
if ($rs_usr) {
|
||||||
while ($result_usr = PMA_DBI_fetch_assoc($rs_usr)) {
|
while ($result_usr = PMA_DBI_fetch_assoc($rs_usr)) {
|
||||||
if (!$is_create_db_priv) {
|
if (!$is_create_db_priv) {
|
||||||
@@ -130,7 +130,7 @@ if (PMA_MYSQL_INT_VERSION >= 40102) {
|
|||||||
if (!$is_create_db_priv) {
|
if (!$is_create_db_priv) {
|
||||||
$local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE ' . PMA_convert_using('Create_priv') . ' = ' . PMA_convert_using('Y', 'quoted') . ' AND (' . PMA_convert_using('User') . ' = ' .PMA_convert_using(PMA_sqlAddslashes($mysql_cur_user), 'quoted') . ' OR ' . PMA_convert_using('User') . ' = ' . PMA_convert_using('', 'quoted') . ');';
|
$local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE ' . PMA_convert_using('Create_priv') . ' = ' . PMA_convert_using('Y', 'quoted') . ' AND (' . PMA_convert_using('User') . ' = ' .PMA_convert_using(PMA_sqlAddslashes($mysql_cur_user), 'quoted') . ' OR ' . PMA_convert_using('User') . ' = ' . PMA_convert_using('', 'quoted') . ');';
|
||||||
|
|
||||||
$rs_usr = PMA_DBI_try_query($local_query, $dbh, PMA_DBI_QUERY_STORE);
|
$rs_usr = PMA_DBI_try_query($local_query, $controllink, PMA_DBI_QUERY_STORE);
|
||||||
if ($rs_usr) {
|
if ($rs_usr) {
|
||||||
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
|
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
|
||||||
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards
|
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards
|
||||||
@@ -151,11 +151,11 @@ if (PMA_MYSQL_INT_VERSION >= 40102) {
|
|||||||
// Finally, let's try to get the user's privileges by using SHOW
|
// Finally, let's try to get the user's privileges by using SHOW
|
||||||
// GRANTS...
|
// GRANTS...
|
||||||
// Maybe we'll find a little CREATE priv there :)
|
// Maybe we'll find a little CREATE priv there :)
|
||||||
$rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user_and_host . ';', $dbh, PMA_DBI_QUERY_STORE);
|
$rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user_and_host . ';', $controllink, PMA_DBI_QUERY_STORE);
|
||||||
if (!$rs_usr) {
|
if (!$rs_usr) {
|
||||||
// OK, now we'd have to guess the user's hostname, but we
|
// OK, now we'd have to guess the user's hostname, but we
|
||||||
// only try out the 'username'@'%' case.
|
// only try out the 'username'@'%' case.
|
||||||
$rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user . ';', $dbh, PMA_DBI_QUERY_STORE);
|
$rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user . ';', $controllink, PMA_DBI_QUERY_STORE);
|
||||||
}
|
}
|
||||||
unset($local_query);
|
unset($local_query);
|
||||||
if ($rs_usr) {
|
if ($rs_usr) {
|
||||||
|
@@ -971,7 +971,7 @@ function PMA_getTableCount( $db ) {
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cfg, $dblist) {
|
function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $rs, $userlink, $cfg, $dblist) {
|
||||||
if ($only_db_check == FALSE) {
|
if ($only_db_check == FALSE) {
|
||||||
// try to get the available dbs list
|
// try to get the available dbs list
|
||||||
// use userlink by default
|
// use userlink by default
|
||||||
@@ -984,7 +984,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
|
|||||||
$auth_query = 'SELECT User, Select_priv '
|
$auth_query = 'SELECT User, Select_priv '
|
||||||
. 'FROM mysql.user '
|
. 'FROM mysql.user '
|
||||||
. 'WHERE User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\'';
|
. 'WHERE User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\'';
|
||||||
$rs = PMA_DBI_try_query($auth_query, $dbh);
|
$rs = PMA_DBI_try_query($auth_query, $controllink);
|
||||||
} // end
|
} // end
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1009,7 +1009,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
|
|||||||
// 1. get allowed dbs from the "mysql.db" table
|
// 1. get allowed dbs from the "mysql.db" table
|
||||||
// lem9: User can be blank (anonymous user)
|
// lem9: User can be blank (anonymous user)
|
||||||
$local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Select_priv = \'Y\' AND (User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\' OR User = \'\')';
|
$local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Select_priv = \'Y\' AND (User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\' OR User = \'\')';
|
||||||
$rs = PMA_DBI_try_query($local_query, $dbh);
|
$rs = PMA_DBI_try_query($local_query, $controllink);
|
||||||
if ($rs && @PMA_DBI_num_rows($rs)) {
|
if ($rs && @PMA_DBI_num_rows($rs)) {
|
||||||
// Will use as associative array of the following 2 code
|
// Will use as associative array of the following 2 code
|
||||||
// lines:
|
// lines:
|
||||||
@@ -1033,7 +1033,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
|
|||||||
}
|
}
|
||||||
} // end while
|
} // end while
|
||||||
PMA_DBI_free_result($rs);
|
PMA_DBI_free_result($rs);
|
||||||
$uva_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['dbh']);
|
$uva_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['controllink']);
|
||||||
// loic1: all databases cases - part 2
|
// loic1: all databases cases - part 2
|
||||||
if (isset($uva_mydbs['%'])) {
|
if (isset($uva_mydbs['%'])) {
|
||||||
while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
|
while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
|
||||||
@@ -1069,7 +1069,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
|
|||||||
|
|
||||||
// 2. get allowed dbs from the "mysql.tables_priv" table
|
// 2. get allowed dbs from the "mysql.tables_priv" table
|
||||||
$local_query = 'SELECT DISTINCT Db FROM mysql.tables_priv WHERE Table_priv LIKE \'%Select%\' AND User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\'';
|
$local_query = 'SELECT DISTINCT Db FROM mysql.tables_priv WHERE Table_priv LIKE \'%Select%\' AND User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\'';
|
||||||
$rs = PMA_DBI_try_query($local_query, $dbh);
|
$rs = PMA_DBI_try_query($local_query, $controllink);
|
||||||
if ($rs && @PMA_DBI_num_rows($rs)) {
|
if ($rs && @PMA_DBI_num_rows($rs)) {
|
||||||
while ($row = PMA_DBI_fetch_assoc($rs)) {
|
while ($row = PMA_DBI_fetch_assoc($rs)) {
|
||||||
if (PMA_isInto($row['Db'], $dblist) == -1) {
|
if (PMA_isInto($row['Db'], $dblist) == -1) {
|
||||||
@@ -1454,9 +1454,9 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
// must be open after this one so it would be default one for all the
|
// must be open after this one so it would be default one for all the
|
||||||
// scripts)
|
// scripts)
|
||||||
if ($cfg['Server']['controluser'] != '') {
|
if ($cfg['Server']['controluser'] != '') {
|
||||||
$dbh = PMA_DBI_connect($cfg['Server']['controluser'], $cfg['Server']['controlpass'], TRUE);
|
$controllink = PMA_DBI_connect($cfg['Server']['controluser'], $cfg['Server']['controlpass'], TRUE);
|
||||||
} else {
|
} else {
|
||||||
$dbh = PMA_DBI_connect($cfg['Server']['user'], $cfg['Server']['password'], TRUE);
|
$controllink = PMA_DBI_connect($cfg['Server']['user'], $cfg['Server']['password'], TRUE);
|
||||||
} // end if ... else
|
} // end if ... else
|
||||||
|
|
||||||
// Pass #1 of DB-Config to read in master level DB-Config will go here
|
// Pass #1 of DB-Config to read in master level DB-Config will go here
|
||||||
@@ -1494,7 +1494,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
// The current position
|
// The current position
|
||||||
if ($dblist[$i] == '*' && $dblist_asterisk_bool == FALSE) {
|
if ($dblist[$i] == '*' && $dblist_asterisk_bool == FALSE) {
|
||||||
$dblist_asterisk_bool = TRUE;
|
$dblist_asterisk_bool = TRUE;
|
||||||
$dblist_full = PMA_safe_db_list(FALSE, $dbh, FALSE, $rs, $userlink, $cfg, $dblist);
|
$dblist_full = PMA_safe_db_list(FALSE, $controllink, FALSE, $rs, $userlink, $cfg, $dblist);
|
||||||
foreach ($dblist_full as $dbl_val) {
|
foreach ($dblist_full as $dbl_val) {
|
||||||
if (!in_array($dbl_val, $dblist)) {
|
if (!in_array($dbl_val, $dblist)) {
|
||||||
$true_dblist[] = $dbl_val;
|
$true_dblist[] = $dbl_val;
|
||||||
@@ -1510,17 +1510,17 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
$local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\'';
|
$local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\'';
|
||||||
// here, a PMA_DBI_query() could fail silently
|
// here, a PMA_DBI_query() could fail silently
|
||||||
// if SHOW DATABASES is disabled
|
// if SHOW DATABASES is disabled
|
||||||
$rs = PMA_DBI_try_query($local_query, $dbh);
|
$rs = PMA_DBI_try_query($local_query, $controllink);
|
||||||
|
|
||||||
if ($i == 0
|
if ($i == 0
|
||||||
&& (substr(PMA_DBI_getError($dbh), 1, 4) == 1045)) {
|
&& (substr(PMA_DBI_getError($controllink), 1, 4) == 1045)) {
|
||||||
// "SHOW DATABASES" statement is disabled
|
// "SHOW DATABASES" statement is disabled
|
||||||
$true_dblist[] = str_replace('\\_', '_', str_replace('\\%', '%', $dblist[$i]));
|
$true_dblist[] = str_replace('\\_', '_', str_replace('\\%', '%', $dblist[$i]));
|
||||||
$is_show_dbs = FALSE;
|
$is_show_dbs = FALSE;
|
||||||
}
|
}
|
||||||
// Debug
|
// Debug
|
||||||
// else if (PMA_DBI_getError($dbh)) {
|
// else if (PMA_DBI_getError($controllink)) {
|
||||||
// PMA_mysqlDie(PMA_DBI_getError($dbh), $local_query, FALSE);
|
// PMA_mysqlDie(PMA_DBI_getError($controllink), $local_query, FALSE);
|
||||||
// }
|
// }
|
||||||
while ($row = @PMA_DBI_fetch_row($rs)) {
|
while ($row = @PMA_DBI_fetch_row($rs)) {
|
||||||
$true_dblist[] = $row[0];
|
$true_dblist[] = $row[0];
|
||||||
@@ -1543,7 +1543,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
} // end if (!$dblist_cnt)
|
} // end if (!$dblist_cnt)
|
||||||
|
|
||||||
if (isset($dblist_full) && !count($dblist_full)) {
|
if (isset($dblist_full) && !count($dblist_full)) {
|
||||||
$dblist = PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cfg, $dblist);
|
$dblist = PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $rs, $userlink, $cfg, $dblist);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end server connecting
|
} // end server connecting
|
||||||
|
@@ -24,19 +24,19 @@
|
|||||||
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
* @author Mike Beck <mikebeck@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
function PMA_query_as_cu($sql, $show_error = TRUE, $options = 0) {
|
function PMA_query_as_cu($sql, $show_error = TRUE, $options = 0) {
|
||||||
global $err_url_0, $db, $dbh, $cfgRelation;
|
global $err_url_0, $db, $controllink, $cfgRelation;
|
||||||
|
|
||||||
if ($dbh == $GLOBALS['userlink']) {
|
if ($controllink == $GLOBALS['userlink']) {
|
||||||
PMA_DBI_select_db($cfgRelation['db'], $dbh);
|
PMA_DBI_select_db($cfgRelation['db'], $controllink);
|
||||||
}
|
}
|
||||||
if ($show_error) {
|
if ($show_error) {
|
||||||
$result = PMA_DBI_query($sql, $dbh, $options);
|
$result = PMA_DBI_query($sql, $controllink, $options);
|
||||||
} else {
|
} else {
|
||||||
$result = @PMA_DBI_try_query($sql, $dbh, $options);
|
$result = @PMA_DBI_try_query($sql, $controllink, $options);
|
||||||
} // end if... else...
|
} // end if... else...
|
||||||
// It makes no sense to restore database on control user
|
// It makes no sense to restore database on control user
|
||||||
if ($dbh == $GLOBALS['userlink']) {
|
if ($controllink == $GLOBALS['userlink']) {
|
||||||
PMA_DBI_select_db($db, $dbh);
|
PMA_DBI_select_db($db, $controllink);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
*/
|
*/
|
||||||
function PMA_getRelationsParam($verbose = FALSE)
|
function PMA_getRelationsParam($verbose = FALSE)
|
||||||
{
|
{
|
||||||
global $cfg, $server, $err_url_0, $db, $table, $dbh;
|
global $cfg, $server, $err_url_0, $db, $table, $controllink;
|
||||||
global $cfgRelation;
|
global $cfgRelation;
|
||||||
|
|
||||||
$cfgRelation = array();
|
$cfgRelation = array();
|
||||||
@@ -106,7 +106,7 @@ function PMA_getRelationsParam($verbose = FALSE)
|
|||||||
// I was thinking of checking if they have all required columns but I
|
// I was thinking of checking if they have all required columns but I
|
||||||
// fear it might be too slow
|
// fear it might be too slow
|
||||||
|
|
||||||
PMA_DBI_select_db($cfgRelation['db'], $dbh);
|
PMA_DBI_select_db($cfgRelation['db'], $controllink);
|
||||||
$tab_query = 'SHOW TABLES FROM ' . PMA_backquote($cfgRelation['db']);
|
$tab_query = 'SHOW TABLES FROM ' . PMA_backquote($cfgRelation['db']);
|
||||||
$tab_rs = PMA_query_as_cu($tab_query, FALSE, PMA_DBI_QUERY_STORE);
|
$tab_rs = PMA_query_as_cu($tab_query, FALSE, PMA_DBI_QUERY_STORE);
|
||||||
|
|
||||||
|
@@ -85,7 +85,7 @@ if ($cfgRelation['pdfwork']) {
|
|||||||
|
|
||||||
if (isset($autolayout)) {
|
if (isset($autolayout)) {
|
||||||
// save the page number
|
// save the page number
|
||||||
$pdf_page_number = PMA_DBI_insert_id((isset($dbh)?$dbh:''));
|
$pdf_page_number = PMA_DBI_insert_id((isset($controllink)?$controllink:''));
|
||||||
|
|
||||||
// get the tables that have relations, by descending
|
// get the tables that have relations, by descending
|
||||||
// number of links
|
// number of links
|
||||||
|
@@ -366,8 +366,8 @@ unset( $_input_query_history, $sql, $history );
|
|||||||
/**
|
/**
|
||||||
* Close MySql connections
|
* Close MySql connections
|
||||||
*/
|
*/
|
||||||
if (isset($dbh) && $dbh) {
|
if (isset($controllink) && $controllink) {
|
||||||
PMA_DBI_close($dbh);
|
PMA_DBI_close($controllink);
|
||||||
}
|
}
|
||||||
if (isset($userlink) && $userlink) {
|
if (isset($userlink) && $userlink) {
|
||||||
PMA_DBI_close($userlink);
|
PMA_DBI_close($userlink);
|
||||||
|
@@ -113,8 +113,8 @@ if (!isset($resize)) {
|
|||||||
/**
|
/**
|
||||||
* Close MySql non-persistent connections
|
* Close MySql non-persistent connections
|
||||||
*/
|
*/
|
||||||
if (isset($GLOBALS['dbh']) && $GLOBALS['dbh']) {
|
if (isset($GLOBALS['controllink']) && $GLOBALS['controllink']) {
|
||||||
@PMA_DBI_close($GLOBALS['dbh']);
|
@PMA_DBI_close($GLOBALS['controllink']);
|
||||||
}
|
}
|
||||||
if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) {
|
if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) {
|
||||||
@PMA_DBI_close($GLOBALS['userlink']);
|
@PMA_DBI_close($GLOBALS['userlink']);
|
||||||
|
Reference in New Issue
Block a user