diff options
-rwxr-xr-x | ChangeLog | 1 | ||||
-rw-r--r-- | browse_foreigners.php | 4 | ||||
-rw-r--r-- | db_details_qbe.php | 8 | ||||
-rw-r--r-- | footer.inc.php | 4 | ||||
-rw-r--r-- | left.php | 8 | ||||
-rw-r--r-- | libraries/bookmark.lib.php | 20 | ||||
-rw-r--r-- | libraries/check_user_privileges.lib.php | 14 | ||||
-rw-r--r-- | libraries/common.lib.php | 26 | ||||
-rw-r--r-- | libraries/relation.lib.php | 18 | ||||
-rw-r--r-- | pdf_pages.php | 2 | ||||
-rw-r--r-- | querywindow.php | 4 | ||||
-rw-r--r-- | transformation_wrapper.php | 4 |
12 files changed, 57 insertions, 56 deletions
@@ -7,6 +7,7 @@ $Source$ 2005-11-20 Marc Delisle <lem9@users.sourceforge.net> ### 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> * libraries/common.lib.php::PMA_showMySQLDocu() diff --git a/browse_foreigners.php b/browse_foreigners.php index c1ddbbdcf9..cb5c65371a 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -293,8 +293,8 @@ if (isset($disp_row) && is_array($disp_row)) { /** * Close MySql connections */ -if (isset($dbh) && $dbh) { - @PMA_DBI_close($dbh); +if (isset($controllink) && $controllink) { + @PMA_DBI_close($controllink); } if (isset($userlink) && $userlink) { @PMA_DBI_close($userlink); diff --git a/db_details_qbe.php b/db_details_qbe.php index 09fa999b99..3df2616fcd 100644 --- a/db_details_qbe.php +++ b/db_details_qbe.php @@ -898,7 +898,7 @@ if (isset($Field) && count($Field) > 0) { */ function PMA_getRelatives($from) { global $tab_left, $tab_know, $fromclause; - global $dbh, $db, $cfgRelation; + global $controllink, $db, $cfgRelation; if ($from == 'master') { $to = 'foreign'; @@ -914,9 +914,9 @@ if (isset($Field) && count($Field) > 0) { . ' AND ' . $to . '_db = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND ' . $from . '_table IN ' . $in_know . ' AND ' . $to . '_table IN ' . $in_left; - PMA_DBI_select_db($cfgRelation['db'], $dbh); - $relations = @PMA_DBI_query($rel_query, $dbh); - PMA_DBI_select_db($db, $dbh); + PMA_DBI_select_db($cfgRelation['db'], $controllink); + $relations = @PMA_DBI_query($rel_query, $controllink); + PMA_DBI_select_db($db, $controllink); while ($row = PMA_DBI_fetch_assoc($relations)) { $found_table = $row[$to . '_table']; if (isset($tab_left[$found_table])) { diff --git a/footer.inc.php b/footer.inc.php index a4da9f1814..d879bc34d3 100644 --- a/footer.inc.php +++ b/footer.inc.php @@ -71,8 +71,8 @@ require_once('./libraries/relation.lib.php'); // for PMA_setHistory() /** * Close database connections */ -if ( isset( $GLOBALS['dbh'] ) && $GLOBALS['dbh'] ) { - @PMA_DBI_close( $GLOBALS['dbh'] ); +if ( isset( $GLOBALS['controllink'] ) && $GLOBALS['controllink'] ) { + @PMA_DBI_close( $GLOBALS['controllink'] ); } if ( isset( $GLOBALS['userlink'] ) && $GLOBALS['userlink'] ) { @PMA_DBI_close( $GLOBALS['userlink'] ); @@ -117,8 +117,8 @@ if ( $num_dbs === 0 ) { /** * Close MySql connections */ - if (isset($dbh) && $dbh) { - @PMA_DBI_close($dbh); + if (isset($controllink) && $controllink) { + @PMA_DBI_close($controllink); } if (isset($userlink) && $userlink) { @PMA_DBI_close($userlink); @@ -498,8 +498,8 @@ function PMA_displayTableList( $tables, $visible = false, /** * Close MySql connections */ -if (isset($dbh) && $dbh) { - @PMA_DBI_close($dbh); +if (isset($controllink) && $controllink) { + @PMA_DBI_close($controllink); } if (isset($userlink) && $userlink) { @PMA_DBI_close($userlink); diff --git a/libraries/bookmark.lib.php b/libraries/bookmark.lib.php index b501c070c8..c303679a3c 100644 --- a/libraries/bookmark.lib.php +++ b/libraries/bookmark.lib.php @@ -49,14 +49,14 @@ function PMA_getBookmarksParam() */ function PMA_listBookmarks($db, $cfgBookmark) { - global $dbh; + global $controllink; $query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table']) . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\'' . ' OR user = \'\')' . ' 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 // 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) { - global $dbh; + global $controllink; if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) { 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']) . '\'' . ' OR user = \'\')' ) . ' AND ' . PMA_backquote($id_field) . ' = ' . $id; - $result = PMA_DBI_try_query($query, $dbh); + $result = PMA_DBI_try_query($query, $controllink); if (!$result) return 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) { - global $dbh; + global $controllink; $bookmarks = array(); 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']) . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'' . (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; while ($row = PMA_DBI_fetch_assoc($result)) { $bookmarks[$row['label']] = $row['query']; @@ -163,11 +163,11 @@ function &PMA_queryDBBookmarks($db, $cfgBookmark, &$table_array) */ function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false) { - global $dbh; + global $controllink; $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']) . '\')'; - $result = PMA_DBI_query($query, $dbh); + $result = PMA_DBI_query($query, $controllink); return TRUE; } // end of the 'PMA_addBookmarks()' function @@ -186,13 +186,13 @@ function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false) */ function PMA_deleteBookmarks($db, $cfgBookmark, $id) { - global $dbh; + global $controllink; $query = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table']) . ' WHERE (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\'' . ' OR user = \'\')' . ' AND id = ' . $id; - $result = PMA_DBI_try_query($query, $dbh); + $result = PMA_DBI_try_query($query, $controllink); } // end of the 'PMA_deleteBookmarks()' function diff --git a/libraries/check_user_privileges.lib.php b/libraries/check_user_privileges.lib.php index 6dae50693c..7a7bf6c924 100644 --- a/libraries/check_user_privileges.lib.php +++ b/libraries/check_user_privileges.lib.php @@ -3,8 +3,8 @@ // vim: expandtab sw=4 ts=4 sts=4: // Get user's global privileges and some db-specific privileges -// ($dbh and $userlink are links to MySQL defined in the "common.lib.php" library) -// Note: if no controluser is defined, $dbh contains $userlink +// ($controllink and $userlink are links to MySQL defined in the "common.lib.php" library) +// Note: if no controluser is defined, $controllink contains $userlink /** * returns true (int > 0) if current user is superuser @@ -97,7 +97,7 @@ if (PMA_MYSQL_INT_VERSION >= 40102) { } else { // 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 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, '@')); $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) { while ($result_usr = PMA_DBI_fetch_assoc($rs_usr)) { if (!$is_create_db_priv) { @@ -130,7 +130,7 @@ if (PMA_MYSQL_INT_VERSION >= 40102) { 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') . ');'; - $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) { $re0 = '(^|(\\\\\\\\)+|[^\])'; // non-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 // GRANTS... // 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) { // OK, now we'd have to guess the user's hostname, but we // 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); if ($rs_usr) { diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 23297e81b6..2d3c2506ca 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -971,7 +971,7 @@ function PMA_getTableCount( $db ) { * * @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) { // try to get the available dbs list // 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 ' . 'FROM mysql.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 } @@ -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 // 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 = \'\')'; - $rs = PMA_DBI_try_query($local_query, $dbh); + $rs = PMA_DBI_try_query($local_query, $controllink); if ($rs && @PMA_DBI_num_rows($rs)) { // Will use as associative array of the following 2 code // lines: @@ -1033,7 +1033,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf } } // end while 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 if (isset($uva_mydbs['%'])) { 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 $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)) { while ($row = PMA_DBI_fetch_assoc($rs)) { 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 // scripts) 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 { - $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 // 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 if ($dblist[$i] == '*' && $dblist_asterisk_bool == FALSE) { $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) { if (!in_array($dbl_val, $dblist)) { $true_dblist[] = $dbl_val; @@ -1510,17 +1510,17 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { $local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\''; // here, a PMA_DBI_query() could fail silently // if SHOW DATABASES is disabled - $rs = PMA_DBI_try_query($local_query, $dbh); + $rs = PMA_DBI_try_query($local_query, $controllink); if ($i == 0 - && (substr(PMA_DBI_getError($dbh), 1, 4) == 1045)) { + && (substr(PMA_DBI_getError($controllink), 1, 4) == 1045)) { // "SHOW DATABASES" statement is disabled $true_dblist[] = str_replace('\\_', '_', str_replace('\\%', '%', $dblist[$i])); $is_show_dbs = FALSE; } // Debug - // else if (PMA_DBI_getError($dbh)) { - // PMA_mysqlDie(PMA_DBI_getError($dbh), $local_query, FALSE); + // else if (PMA_DBI_getError($controllink)) { + // PMA_mysqlDie(PMA_DBI_getError($controllink), $local_query, FALSE); // } while ($row = @PMA_DBI_fetch_row($rs)) { $true_dblist[] = $row[0]; @@ -1543,7 +1543,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { } // end if (!$dblist_cnt) 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 diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index 018f315827..641bdfc04c 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -24,19 +24,19 @@ * @author Mike Beck <mikebeck@users.sourceforge.net> */ 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']) { - PMA_DBI_select_db($cfgRelation['db'], $dbh); + if ($controllink == $GLOBALS['userlink']) { + PMA_DBI_select_db($cfgRelation['db'], $controllink); } if ($show_error) { - $result = PMA_DBI_query($sql, $dbh, $options); + $result = PMA_DBI_query($sql, $controllink, $options); } else { - $result = @PMA_DBI_try_query($sql, $dbh, $options); + $result = @PMA_DBI_try_query($sql, $controllink, $options); } // end if... else... // It makes no sense to restore database on control user - if ($dbh == $GLOBALS['userlink']) { - PMA_DBI_select_db($db, $dbh); + if ($controllink == $GLOBALS['userlink']) { + PMA_DBI_select_db($db, $controllink); } if ($result) { @@ -69,7 +69,7 @@ */ 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; $cfgRelation = array(); @@ -106,7 +106,7 @@ function PMA_getRelationsParam($verbose = FALSE) // I was thinking of checking if they have all required columns but I // 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_rs = PMA_query_as_cu($tab_query, FALSE, PMA_DBI_QUERY_STORE); diff --git a/pdf_pages.php b/pdf_pages.php index 2a3e94564b..439938d01a 100644 --- a/pdf_pages.php +++ b/pdf_pages.php @@ -85,7 +85,7 @@ if ($cfgRelation['pdfwork']) { if (isset($autolayout)) { // 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 // number of links diff --git a/querywindow.php b/querywindow.php index 49c6248b73..82341a0119 100644 --- a/querywindow.php +++ b/querywindow.php @@ -366,8 +366,8 @@ unset( $_input_query_history, $sql, $history ); /** * Close MySql connections */ -if (isset($dbh) && $dbh) { - PMA_DBI_close($dbh); +if (isset($controllink) && $controllink) { + PMA_DBI_close($controllink); } if (isset($userlink) && $userlink) { PMA_DBI_close($userlink); diff --git a/transformation_wrapper.php b/transformation_wrapper.php index cb979b0aba..5caeb6a3cb 100644 --- a/transformation_wrapper.php +++ b/transformation_wrapper.php @@ -113,8 +113,8 @@ if (!isset($resize)) { /** * Close MySql non-persistent connections */ -if (isset($GLOBALS['dbh']) && $GLOBALS['dbh']) { - @PMA_DBI_close($GLOBALS['dbh']); +if (isset($GLOBALS['controllink']) && $GLOBALS['controllink']) { + @PMA_DBI_close($GLOBALS['controllink']); } if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) { @PMA_DBI_close($GLOBALS['userlink']); |