Added MySQLi library; Removed calls to old mysql_wrappers library.

This commit is contained in:
Alexander M. Turek
2004-01-22 02:13:48 +00:00
parent 597dca0f1b
commit 2915b5c3ce
62 changed files with 1086 additions and 906 deletions

View File

@@ -5,6 +5,35 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2004-01-22 Alexander M. Turek <innocenteyes@derrabus.de>
* libraries/dbi/mysqli.dbi.lib.php: Experimental new MySQLi library.
* browse_foreigners.php, db_create.php, db_datadict.php,
db_details_common.php, db_details_db_info.php, db_details_qbe.php,
db_details_structure.php, db_printview.php, export.php, ldi_table.php,
left.php, main.php, mult_submits.php, pdf_pages.php, pdf_schema.php,
querywindow.php, read_dump.php, server_common.inc.php,
server_privileges.php, server_processlist.php, server_status.php,
server_variables.php, sql.php, tbl_addfield.php, tbl_alter.php,
tbl_change.php, tbl_create.php, tbl_index.php, tbl_move_copy.php,
tbl_printview.php, tbl_properties.inc.php, tbl_properties_operations.php,
tbl_properties_table_info.php, tbl_query_box.php, tbl_relation.php,
tbl_rename.php, tbl_replace.php, tbl_select.php,
transformation_wrapper.php, user_password.php, libraries/bookmark.lib.php,
libraries/common.lib.php, libraries/db_table_exists.lib.php,
libraries/display_tbl:lib.php, libraries/get_foreign.lib.php,
libraries/mysql_charsets.lib.php, libraries/relation.lib.php,
libraries/transformations.lib.php, libraries/auth/config.auth.lib.php,
libraries/auth/cookie.auth.lib.php, libraries/export/*.php:
- Removed most remaining calls to old mysql_wrappers library;
- Small optimizations and XHTML fixes.
* libraries/database_interface.lib.php, libraries/dbi/mysql.dbi.lib.php:
- Moved PMA_DBI_get_dblist() definition to database_interface.lib;
- Fixed "undefined constant" warning (bug #881637);
- Added new functions: PMA_DBI_select_db(), PMA_DBI_get_fields(),
PMA_DBI_get_fields_meta();
- Bypassing charset conversion code for MySQL >= 4.1 experimentally.
* Documentation.html: Changed my email address.
2004-01-21 Michal Cihar <thesiswritten@cihar.com> 2004-01-21 Michal Cihar <thesiswritten@cihar.com>
* lang/czech: Fixed unclear message. * lang/czech: Fixed unclear message.

View File

@@ -2417,7 +2417,7 @@ To create a new, empty mimetype please see libraries/transformations/template_ge
phpMyAdmin provides experimental support for MySQL&nbsp;4.1 and 5.0. That phpMyAdmin provides experimental support for MySQL&nbsp;4.1 and 5.0. That
means that although you can assign character sets to a table or field, means that although you can assign character sets to a table or field,
phpMyAdmin will not recode the data when inserting or extracting it. phpMyAdmin will not recode the data when inserting or extracting it.
Instead, it will still use the character set you specified for the MySQL Instead, it will still use the character set you specified for the MySQL
onnection.<br /> onnection.<br />
When compiling php, we strongly recommend that you manually link the MySQL When compiling php, we strongly recommend that you manually link the MySQL
extension to a MySQL client library of at least the same version since the extension to a MySQL client library of at least the same version since the
@@ -3522,13 +3522,13 @@ To create a new, empty mimetype please see libraries/transformations/template_ge
</p> </p>
<h4> <h4>
[6.22] Bookmarks: Can I execute a default bookmark automatically [6.22] Bookmarks: Can I execute a default bookmark automatically
when entering Browse mode for a table? when entering Browse mode for a table?
</h4> </h4>
<p> <p>
Yes. If a bookmark has the same label as a table name, it will be Yes. If a bookmark has the same label as a table name, it will be
executed. executed.
</p> </p>
<a name="faqproject"></a><br /> <a name="faqproject"></a><br />
<h3>[7. phpMyAdmin project]</h3> <h3>[7. phpMyAdmin project]</h3>
@@ -3790,7 +3790,7 @@ CREDITS, in chronological order
* main author of the version 2.1.0.1 * main author of the version 2.1.0.1
* bugfixes * bugfixes
- Alexander M. Turek &lt;derrabus_at_gmx.de&gt; - Alexander M. Turek &lt;me_at_derrabus.de&gt;
* XML exports * XML exports
* MySQL 4 related features * MySQL 4 related features
* various features and fixes * various features and fixes

View File

@@ -142,31 +142,31 @@ if (isset($disp) && $disp) {
function dimsort($arrayA, $arrayB) { function dimsort($arrayA, $arrayB) {
$keyA = key($arrayA); $keyA = key($arrayA);
$keyB = key($arrayB); $keyB = key($arrayB);
if ($arrayA[$keyA] == $arrayB[$keyB]) { if ($arrayA[$keyA] == $arrayB[$keyB]) {
return 0; return 0;
} }
return ($arrayA[$keyA] < $arrayB[$keyB]) ? -1 : 1; return ($arrayA[$keyA] < $arrayB[$keyB]) ? -1 : 1;
} }
$mysql_key_relrow = array(); $mysql_key_relrow = array();
$mysql_val_relrow = array(); $mysql_val_relrow = array();
$count = 0; $count = 0;
while ($relrow = @PMA_mysql_fetch_array($disp)) { while ($relrow = @PMA_DBI_fetch_assoc($disp)) {
if ($foreign_display != FALSE) { if ($foreign_display != FALSE) {
$val = $relrow[$foreign_display]; $val = $relrow[$foreign_display];
} else { } else {
$val = ''; $val = '';
} }
$mysql_key_relrow[$count] = array($relrow[$foreign_field] => $val); $mysql_key_relrow[$count] = array($relrow[$foreign_field] => $val);
$mysql_val_relrow[$count] = array($val => $relrow[$foreign_field]); $mysql_val_relrow[$count] = array($val => $relrow[$foreign_field]);
$count++; $count++;
} }
usort($mysql_val_relrow, 'dimsort'); usort($mysql_val_relrow, 'dimsort');
$hcount = 0; $hcount = 0;
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
$hcount++; $hcount++;

View File

@@ -29,7 +29,7 @@ if (isset($db_charset) && isset($mysql_charsets) && in_array($db_charset, $mysql
} }
$sql_query .= ';'; $sql_query .= ';';
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, FALSE, $err_url); $result = PMA_DBI_query($sql_query);
/** /**

View File

@@ -52,15 +52,11 @@ if ($cfgRelation['commwork']) {
/** /**
* Selects the database and gets tables names * Selects the database and gets tables names
*/ */
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$sql = 'SHOW TABLES FROM ' . PMA_backquote($db); $rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
$rowset = @PMA_mysql_query($sql);
if (!$rowset) {
exit();
}
$count = 0; $count = 0;
while ($row = PMA_mysql_fetch_array($rowset)) { while ($row = PMA_DBI_fetch_assoc($rowset)) {
$myfieldname = 'Tables_in_' . htmlspecialchars($db); $myfieldname = 'Tables_in_' . htmlspecialchars($db);
$table = $row[$myfieldname]; $table = $row[$myfieldname];
if ($cfgRelation['commwork']) { if ($cfgRelation['commwork']) {
@@ -76,21 +72,17 @@ while ($row = PMA_mysql_fetch_array($rowset)) {
* Gets table informations * Gets table informations
*/ */
// The 'show table' statement works correct since 3.23.03 // The 'show table' statement works correct since 3.23.03
$local_query = 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''; $result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); $showtable = PMA_DBI_fetch_assoc($result);
$showtable = PMA_mysql_fetch_array($result);
$num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); $num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
$show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
if ($result) { PMA_DBI_free_result($result);
PMA_DBI_free_result($result);
}
/** /**
* Gets table keys and retains them * Gets table keys and retains them
*/ */
$local_query = 'SHOW KEYS FROM ' . PMA_backquote($table); $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
$primary = ''; $primary = '';
$indexes = array(); $indexes = array();
$lastIndex = ''; $lastIndex = '';
@@ -98,7 +90,7 @@ while ($row = PMA_mysql_fetch_array($rowset)) {
$indexes_data = array(); $indexes_data = array();
$pk_array = array(); // will be use to emphasis prim. keys in the table $pk_array = array(); // will be use to emphasis prim. keys in the table
// view // view
while ($row = PMA_mysql_fetch_array($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
// Backups the list of primary keys // Backups the list of primary keys
if ($row['Key_name'] == 'PRIMARY') { if ($row['Key_name'] == 'PRIMARY') {
$primary .= $row['Column_name'] . ', '; $primary .= $row['Column_name'] . ', ';
@@ -133,8 +125,7 @@ while ($row = PMA_mysql_fetch_array($rowset)) {
/** /**
* Gets fields properties * Gets fields properties
*/ */
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table); $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck) // Check if we can use Relations (Mike Beck)
if (!empty($cfgRelation['relation'])) { if (!empty($cfgRelation['relation'])) {
@@ -190,7 +181,7 @@ while ($row = PMA_mysql_fetch_array($rowset)) {
<?php <?php
$i = 0; $i = 0;
while ($row = PMA_mysql_fetch_array($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
$bgcolor = ($i % 2) ?$cfg['BgcolorOne'] : $cfg['BgcolorTwo']; $bgcolor = ($i % 2) ?$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
$i++; $i++;

View File

@@ -25,7 +25,7 @@ $err_url = $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db);
if (!isset($is_db) || !$is_db) { if (!isset($is_db) || !$is_db) {
// Not a valid db name -> back to the welcome page // Not a valid db name -> back to the welcome page
if (!empty($db)) { if (!empty($db)) {
$is_db = @PMA_mysql_select_db($db); $is_db = PMA_DBI_select_db($db);
} }
if (empty($db) || !$is_db) { if (empty($db) || !$is_db) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
@@ -38,7 +38,7 @@ if (!isset($is_db) || !$is_db) {
*/ */
if (isset($submitcharset) && PMA_MYSQL_INT_VERSION >= 40101) { if (isset($submitcharset) && PMA_MYSQL_INT_VERSION >= 40101) {
$sql_query = 'ALTER DATABASE ' . PMA_backquote($db) . ' DEFAULT CHARACTER SET ' . $db_charset; $sql_query = 'ALTER DATABASE ' . PMA_backquote($db) . ' DEFAULT CHARACTER SET ' . $db_charset;
$result = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query, '', $err_url); $result = PMA_DBI_query($sql_query);
$message = $strSuccess; $message = $strSuccess;
} }

View File

@@ -18,11 +18,10 @@ PMA_checkParameters(array('db'));
$tables = array(); $tables = array();
// Special speedup for newer MySQL Versions (in 4.0 format changed) // Special speedup for newer MySQL Versions (in 4.0 format changed)
if ($cfg['SkipLockedTables'] == TRUE) { if ($cfg['SkipLockedTables'] == TRUE) {
$local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db); $db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
$db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
// Blending out tables in use // Blending out tables in use
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) { if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
while ($tmp = PMA_mysql_fetch_row($db_info_result)) { while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
// if in use memorize tablename // if in use memorize tablename
if (preg_match('@in_use=[1-9]+@i', $tmp[1])) { if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
$sot_cache[$tmp[0]] = TRUE; $sot_cache[$tmp[0]] = TRUE;
@@ -31,14 +30,12 @@ if ($cfg['SkipLockedTables'] == TRUE) {
PMA_DBI_free_result($db_info_result); PMA_DBI_free_result($db_info_result);
if (isset($sot_cache)) { if (isset($sot_cache)) {
$local_query = 'SHOW TABLES FROM ' . PMA_backquote($db); $db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
$db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) { if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
while ($tmp = PMA_mysql_fetch_row($db_info_result)) { while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
if (!isset($sot_cache[$tmp[0]])) { if (!isset($sot_cache[$tmp[0]])) {
$local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\''; $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
$sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
$sts_tmp = PMA_mysql_fetch_array($sts_result);
$tables[] = $sts_tmp; $tables[] = $sts_tmp;
} else { // table in use } else { // table in use
$tables[] = array('Name' => $tmp[0]); $tables[] = array('Name' => $tmp[0]);
@@ -51,13 +48,13 @@ if ($cfg['SkipLockedTables'] == TRUE) {
} }
} }
if (!isset($sot_ready)) { if (!isset($sot_ready)) {
$local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db); $db_info_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
$db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) { if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
while ($sts_tmp = PMA_mysql_fetch_array($db_info_result)) { while ($sts_tmp = PMA_DBI_fetch_assoc($db_info_result)) {
$tables[] = $sts_tmp; $tables[] = $sts_tmp;
} }
PMA_DBI_free_result($db_info_result); PMA_DBI_free_result($db_info_result);
unset($db_info_result);
} }
} }
$num_tables = (isset($tables) ? count($tables) : 0); $num_tables = (isset($tables) ? count($tables) : 0);

View File

@@ -37,8 +37,8 @@ else {
// Drop link if allowed // Drop link if allowed
if (!$cfg['AllowUserDropDatabase']) { if (!$cfg['AllowUserDropDatabase']) {
// Check if the user is a Superuser // Check if the user is a Superuser
$links_result = @PMA_mysql_query('USE mysql'); $cfg['AllowUserDropDatabase'] = PMA_DBI_select_db('mysql');
$cfg['AllowUserDropDatabase'] = (!PMA_mysql_error()); PMA_DBI_select_db($db);
} }
if ($cfg['AllowUserDropDatabase']) { if ($cfg['AllowUserDropDatabase']) {
$lnk5 = 'sql.php'; $lnk5 = 'sql.php';

View File

@@ -114,7 +114,7 @@ if ($row < 0) {
/** /**
* Prepares the form * Prepares the form
*/ */
$tbl_result = PMA_mysql_list_tables($db); $tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
$tbl_result_cnt = PMA_DBI_num_rows($tbl_result); $tbl_result_cnt = PMA_DBI_num_rows($tbl_result);
$i = 0; $i = 0;
$k = 0; $k = 0;
@@ -129,8 +129,8 @@ if (!empty($TableList)) {
// The tables list gets from MySQL // The tables list gets from MySQL
while ($i < $tbl_result_cnt) { while ($i < $tbl_result_cnt) {
$tbl = PMA_mysql_tablename($tbl_result, $i); list($tbl) = PMA_DBI_fetch_row($tbl_result);
$fld_results = @PMA_mysql_list_fields_alternate($db, $tbl) or PMA_mysqlDie(PMA_mysql_error(), 'PMA_mysql_list_fields_alternate(' . $db . ', ' . $tbl . ')', FALSE, $err_url); $fld_results = PMA_DBI_get_fields($db, $tbl);
$fld_results_cnt = ($fld_results) ? count($fld_results) : 0; $fld_results_cnt = ($fld_results) ? count($fld_results) : 0;
$j = 0; $j = 0;
@@ -779,12 +779,11 @@ if (isset($Field) && count($Field) > 0) {
// ( When the control user is the same as the normal user // ( When the control user is the same as the normal user
// because he is using one of his databases as pmadb, // because he is using one of his databases as pmadb,
// the last db selected is not always the one where we need to work) // the last db selected is not always the one where we need to work)
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
foreach($tab_all AS $tab) { foreach($tab_all AS $tab) {
$ind_qry = 'SHOW INDEX FROM ' . PMA_backquote($tab); $ind_rs = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tab) . ';');
$ind_rs = PMA_mysql_query($ind_qry); while ($ind = PMA_DBI_fetch_assoc($ind_rs)) {
while ($ind = PMA_mysql_fetch_array($ind_rs)) {
$col1 = $tab . '.' . $ind['Column_name']; $col1 = $tab . '.' . $ind['Column_name'];
if (isset($col_all[$col1])) { if (isset($col_all[$col1])) {
if ($ind['non_unique'] == 0) { if ($ind['non_unique'] == 0) {
@@ -853,10 +852,12 @@ if (isset($Field) && count($Field) > 0) {
if ($checked_tables[$tab] != 1 ) { if ($checked_tables[$tab] != 1 ) {
$rows_qry = 'SELECT COUNT(1) AS anz ' $rows_qry = 'SELECT COUNT(1) AS anz '
. 'FROM ' . PMA_backquote($tab); . 'FROM ' . PMA_backquote($tab);
$rows_rs = PMA_mysql_query($rows_qry); $rows_rs = PMA_DBI_query($rows_qry);
while ($res = PMA_mysql_fetch_array($rows_rs)) { while ($res = PMA_DBI_fetch_assoc($rows_rs)) {
$tsize[$tab] = $res['anz']; $tsize[$tab] = $res['anz'];
} }
PMA_DBI_free_result($rows_rs);
unset($rows_rs);
$checked_tables[$tab] = 1; $checked_tables[$tab] = 1;
} }
$csize[$tab] = $tsize[$tab]; $csize[$tab] = $tsize[$tab];
@@ -928,16 +929,10 @@ 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;
if (isset($dbh)) { PMA_DBI_select_db($cfgRelation['db'], $dbh);
PMA_mysql_select_db($cfgRelation['db'], $dbh); $relations = @PMA_DBI_query($rel_query, $dbh);
$relations = @PMA_mysql_query($rel_query, $dbh) or PMA_mysqlDie(PMA_mysql_error($dbh), $rel_query, '', $err_url_0); PMA_DBI_select_db($db, $dbh);
PMA_mysql_select_db($db, $dbh); while ($row = PMA_DBI_fetch_assoc($relations)) {
} else {
PMA_mysql_select_db($cfgRelation['db']);
$relations = @PMA_mysql_query($rel_query) or PMA_mysqlDie('', $rel_query, '', $err_url_0);
PMA_mysql_select_db($db);
}
while ($row = PMA_mysql_fetch_array($relations)) {
$found_table = $row[$to . '_table']; $found_table = $row[$to . '_table'];
if (isset($tab_left[$found_table])) { if (isset($tab_left[$found_table])) {
$fromclause .= "\n" . ' LEFT JOIN ' $fromclause .= "\n" . ' LEFT JOIN '

View File

@@ -156,8 +156,8 @@ else {
$tooltip_truename = array(); $tooltip_truename = array();
$tooltip_aliasname = array(); $tooltip_aliasname = array();
$result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db)); $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
while ($tmp = PMA_mysql_fetch_array($result)) { while ($tmp = PMA_DBI_fetch_assoc($result)) {
$tooltip_truename[$tmp['Name']] = ($cfg['ShowTooltipAliasTB'] ? (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']) : $tmp['Name']); $tooltip_truename[$tmp['Name']] = ($cfg['ShowTooltipAliasTB'] ? (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']) : $tmp['Name']);
$tooltip_aliasname[$tmp['Name']] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')); $tooltip_aliasname[$tmp['Name']] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : ''));
if (isset($tmp['Create_time']) && !empty($tmp['Create_time'])) { if (isset($tmp['Create_time']) && !empty($tmp['Create_time'])) {
@@ -345,9 +345,10 @@ else {
$local_query = 'SELECT COUNT(*) AS count FROM ' $local_query = 'SELECT COUNT(*) AS count FROM '
. PMA_backquote($db) . '.' . PMA_backquote($db) . '.'
. PMA_backquote($table); . PMA_backquote($table);
$table_info_result = PMA_mysql_query($local_query) $table_info_result = PMA_DBI_query($local_query);
or PMA_mysqlDie('', $local_query, '', $err_url_0); list($row_count) = PMA_DBI_fetch_row($table_info_result);
$row_count = PMA_mysql_result($table_info_result, 0, 'count'); PMA_DBI_free_result($table_info_result);
unset($table_info_result);
$sum_entries += $row_count; $sum_entries += $row_count;
} else { } else {
$row_count = $sts_data['Rows']; $row_count = $sts_data['Rows'];
@@ -660,10 +661,12 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) {
<?php echo $strPageNumber; ?>&nbsp; <?php echo $strPageNumber; ?>&nbsp;
<select name="pdf_page_number"> <select name="pdf_page_number">
<?php <?php
while ($pages = @PMA_mysql_fetch_array($test_rs)) { while ($pages = @PMA_DBI_fetch_assoc($test_rs)) {
echo "\n" . ' ' echo "\n" . ' '
. '<option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>'; . '<option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>';
} // end while } // end while
PMA_DBI_free_result($test_rs);
unset($test_rs);
echo "\n"; echo "\n";
?> ?>
</select><br /> </select><br />

View File

@@ -32,46 +32,45 @@ $cfgRelation = PMA_getRelationsParam();
// staybyte: speedup view on locked tables - 11 June 2001 // staybyte: speedup view on locked tables - 11 June 2001
// Special speedup for newer MySQL Versions (in 4.0 format changed) // Special speedup for newer MySQL Versions (in 4.0 format changed)
if ($cfg['SkipLockedTables'] == TRUE) { if ($cfg['SkipLockedTables'] == TRUE) {
$local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db); $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
// Blending out tables in use // Blending out tables in use
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) { if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
while ($tmp = PMA_mysql_fetch_array($result)) { while ($tmp = PMA_DBI_fetch_row($result)) {
// if in use memorize tablename // if in use memorize tablename
if (preg_match('@in_use=[1-9]+@i', $tmp[0])) { if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
$sot_cache[$tmp[0]] = TRUE; $sot_cache[$tmp[0]] = TRUE;
} }
} }
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
unset($result);
if (isset($sot_cache)) { if (isset($sot_cache)) {
$local_query = 'SHOW TABLES FROM ' . PMA_backquote($db); $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) { if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
while ($tmp = PMA_mysql_fetch_array($result)) { while ($tmp = PMA_DBI_fetch_row($result)) {
if (!isset($sot_cache[$tmp[0]])) { if (!isset($sot_cache[$tmp[0]])) {
$local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\''; $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
$sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
$sts_tmp = PMA_mysql_fetch_array($sts_result);
$tables[] = $sts_tmp; $tables[] = $sts_tmp;
} else { // table in use } else { // table in use
$tables[] = array('Name' => $tmp[0]); $tables[] = array('Name' => $tmp[0]);
} }
} }
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
unset($result);
$sot_ready = TRUE; $sot_ready = TRUE;
} }
} }
} }
} }
if (!isset($sot_ready)) { if (!isset($sot_ready)) {
$local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db); $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); if (PMA_DBI_num_rows($result) > 0) {
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) { while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
while ($sts_tmp = PMA_mysql_fetch_array($result)) {
$tables[] = $sts_tmp; $tables[] = $sts_tmp;
} }
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
unset($res);
} }
} }
$num_tables = (isset($tables) ? count($tables) : 0); $num_tables = (isset($tables) ? count($tables) : 0);

View File

@@ -20,14 +20,8 @@ $url_query .= '&amp;goto=db_search.php';
/** /**
* Get the list of tables from the current database * Get the list of tables from the current database
*/ */
$list_tables = PMA_mysql_list_tables($db); $tables = PMA_DBI_get_tables($db);
$num_tables = ($list_tables ? PMA_DBI_num_rows($list_tables) : 0); $num_tables = count($tables);
for ($i = 0; $i < $num_tables; $i++) {
$tables[] = PMA_mysql_tablename($list_tables, $i);
}
if ($num_tables) {
PMA_DBI_free_result($list_tables);
}
/** /**
@@ -63,17 +57,14 @@ if (isset($submit_search)) {
$sqlstr_delete = 'DELETE'; $sqlstr_delete = 'DELETE';
// Fields to select // Fields to select
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']); $res = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']) . ';');
$res = @PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, FALSE, $err_url); while (list($current) = PMA_DBI_fetch_row($res)) {
$res_cnt = ($res ? PMA_DBI_num_rows($res) : 0); $tblfields[] = PMA_backquote($current);
for ($i = 0; $i < $res_cnt; $i++) { } // while
$tblfields[] = PMA_backquote(PMA_mysql_result($res, $i, 'field')); PMA_DBI_free_result($res);
} // end if unset($current, $res);
$sqlstr_fieldstoselect = ' ' . implode(', ', $tblfields); $sqlstr_fieldstoselect = ' ' . implode(', ', $tblfields);
$tblfields_cnt = count($tblfields); $tblfields_cnt = count($tblfields);
if ($res) {
PMA_DBI_free_result($res);
}
// Table to use // Table to use
$sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table); $sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table);
@@ -187,14 +178,10 @@ if (isset($submit_search)) {
$newsearchsqls = PMA_getSearchSqls($onetable, $search_str, $search_option); $newsearchsqls = PMA_getSearchSqls($onetable, $search_str, $search_option);
// Executes the "COUNT" statement // Executes the "COUNT" statement
$local_query = $newsearchsqls['select_count']; $res = PMA_DBI_query($newsearchsqls['select_count']);
$res = @PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, FALSE, $err_url); $res_cnt = PMA_DBI_fetch_assoc($res);
if ($res) { $res_cnt = $res_cnt['count'];
$res_cnt = PMA_mysql_result($res, 0, 'count'); PMA_DBI_free_result($res);
PMA_DBI_free_result($res);
} else {
$res_cnt = 0;
} // end if... else ...
$num_search_result_total = $res_cnt; $num_search_result_total = $res_cnt;
echo ' <!-- Search results in table ' . $onetable . ' (' . $res_cnt . ') -->' . "\n" echo ' <!-- Search results in table ' . $onetable . ' (' . $res_cnt . ') -->' . "\n"
@@ -226,14 +213,11 @@ if (isset($submit_search)) {
$newsearchsqls = PMA_getSearchSqls($table_select[$i], $search_str, $search_option); $newsearchsqls = PMA_getSearchSqls($table_select[$i], $search_str, $search_option);
// Executes the "COUNT" statement // Executes the "COUNT" statement
$local_query = $newsearchsqls['select_count']; $res = PMA_DBI_query($newsearchsqls['select_count']);
$res = @PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, FALSE, $err_url); $res_cnt = PMA_DBI_fetch_assoc($res);
if ($res) { $res_cnt = $res_cnt['count'];
$res_cnt = PMA_mysql_result($res, 0, 'count'); PMA_DBI_free_result($res);
PMA_DBI_free_result($res); unset($res);
} else {
$res_cnt = 0;
} // end if... else ...
$num_search_result_total += $res_cnt; $num_search_result_total += $res_cnt;
echo ' <!-- Search results in table ' . $table_select[$i] . ' (' . $res_cnt . ') -->' . "\n" echo ' <!-- Search results in table ' . $table_select[$i] . ' (' . $res_cnt . ') -->' . "\n"

View File

@@ -309,8 +309,8 @@ if (!$save_on_server) {
// Check if we have something to export // Check if we have something to export
if ($export_type == 'database') { if ($export_type == 'database') {
$tables = PMA_mysql_list_tables($db); $tables = PMA_DBI_get_tables($db);
$num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0; $num_tables = count($tables);
if ($num_tables == 0) { if ($num_tables == 0) {
$message = $strNoTablesFound; $message = $strNoTablesFound;
$js_to_run = 'functions.js'; $js_to_run = 'functions.js';
@@ -369,15 +369,15 @@ if ($export_type == 'server') {
|| !isset($tmp_select)) { || !isset($tmp_select)) {
PMA_exportDBHeader($current_db); PMA_exportDBHeader($current_db);
PMA_exportDBCreate($current_db); PMA_exportDBCreate($current_db);
$tables = PMA_mysql_list_tables($current_db); $tables = PMA_DBI_get_tables($current_db);
$num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0; foreach ($tables as $table) {
$i = 0;
while ($i < $num_tables) {
$table = PMA_mysql_tablename($tables, $i);
$local_query = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table); $local_query = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
if (isset($GLOBALS[$what . '_structure'])) PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates); if (isset($GLOBALS[$what . '_structure'])) {
if (isset($GLOBALS[$what . '_data'])) PMA_exportData($current_db, $table, $crlf, $err_url, $local_query); PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates);
$i++; }
if (isset($GLOBALS[$what . '_data'])) {
PMA_exportData($current_db, $table, $crlf, $err_url, $local_query);
}
} }
PMA_exportDBFooter($current_db); PMA_exportDBFooter($current_db);
} }
@@ -389,16 +389,18 @@ if ($export_type == 'server') {
$tmp_select = '|' . $tmp_select . '|'; $tmp_select = '|' . $tmp_select . '|';
} }
$i = 0; $i = 0;
while ($i < $num_tables) { foreach ($tables as $table) {
$table = PMA_mysql_tablename($tables, $i);
$local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table); $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $table . '|')) if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $table . '|'))
|| !isset($tmp_select)) { || !isset($tmp_select)) {
if (isset($GLOBALS[$what . '_structure'])) PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates); if (isset($GLOBALS[$what . '_structure'])) {
if (isset($GLOBALS[$what . '_data'])) PMA_exportData($db, $table, $crlf, $err_url, $local_query); PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates);
}
if (isset($GLOBALS[$what . '_data'])) {
PMA_exportData($db, $table, $crlf, $err_url, $local_query);
}
} }
$i++;
} }
PMA_exportDBFooter($db); PMA_exportDBFooter($db);
} else { } else {
@@ -415,7 +417,7 @@ if ($export_type == 'server') {
if (!empty($sql_query)) { if (!empty($sql_query)) {
$local_query = $sql_query . $add_query; $local_query = $sql_query . $add_query;
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
} else { } else {
$local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query; $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query;
} }

View File

@@ -152,15 +152,15 @@ if (PMA_MYSQL_INT_VERSION < 32349) {
} }
if (PMA_MYSQL_INT_VERSION > 40003) { if (PMA_MYSQL_INT_VERSION > 40003) {
$tmp_query = "SHOW VARIABLES LIKE 'local\\_infile'"; $result = PMA_DBI_try_query('SHOW VARIABLES LIKE \'local\\_infile\';');
$result = PMA_mysql_query($tmp_query);
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) { if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
$tmp = PMA_mysql_fetch_row($result); $tmp = PMA_DBI_fetch_row($result);
if ($tmp[1] == 'ON') { if ($tmp[1] == 'ON') {
$local_option_selected = TRUE; $local_option_selected = TRUE;
} }
} }
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
unset($result);
} }
?> ?>

View File

@@ -406,7 +406,7 @@ if ($num_dbs > 1) {
if (!empty($db_start) && $db == $db_start) { if (!empty($db_start) && $db == $db_start) {
$selected_db = $j; $selected_db = $j;
} }
$tables = @PMA_mysql_list_tables($db); $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
$num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0; $num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
$common_url_query = PMA_generate_common_url($db); $common_url_query = PMA_generate_common_url($db);
if ($num_tables) { if ($num_tables) {
@@ -421,8 +421,8 @@ if ($num_dbs > 1) {
&& (!$cfg['LeftFrameLight'] || $selected_db == $j)) { && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
$tooltip = array(); $tooltip = array();
$tooltip_name = array(); $tooltip_name = array();
$result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db)); $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
while ($tmp = PMA_mysql_fetch_array($result)) { while ($tmp = PMA_DBI_fetch_assoc($result)) {
$tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : ''); $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
$tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']); $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
@@ -471,8 +471,7 @@ if ($num_dbs > 1) {
<?php <?php
// Displays the list of tables from the current database // Displays the list of tables from the current database
$tablestack = array(); $tablestack = array();
for ($t = 0; $t < $num_tables; $t++) { while (list($table) = PMA_DBI_fetch_row($tables)) {
$table = PMA_mysql_tablename($tables, $t);
$alias = (!empty($tooltip_name) && isset($tooltip_name[$table])) $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
? htmlspecialchars($tooltip_name[$table]) ? htmlspecialchars($tooltip_name[$table])
: ''; : '';
@@ -512,7 +511,7 @@ if ($num_dbs > 1) {
$tablestack['']['pma_name'][] = $table; $tablestack['']['pma_name'][] = $table;
$tablestack['']['pma_list_item'][] = $list_item; $tablestack['']['pma_list_item'][] = $list_item;
} }
} // end for $t (tables list) } // end while (tables list)
PMA_nestedSet($j, $tablestack); PMA_nestedSet($j, $tablestack);
?> ?>
@@ -530,8 +529,7 @@ if ($num_dbs > 1) {
// Builds the databases' names list // Builds the databases' names list
if (!empty($db_start) && $db == $db_start) { if (!empty($db_start) && $db == $db_start) {
// Gets the list of tables from the current database // Gets the list of tables from the current database
for ($t = 0; $t < $num_tables; $t++) { while (list($table) = PMA_DBI_fetch_row($tables)) {
$table = PMA_mysql_tablename($tables, $t);
$url_title = (!empty($tooltip) && isset($tooltip[$table])) $url_title = (!empty($tooltip) && isset($tooltip[$table]))
? htmlentities($tooltip[$table]) ? htmlentities($tooltip[$table])
: ''; : '';
@@ -548,7 +546,7 @@ if ($num_dbs > 1) {
} else { } else {
$table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n"; $table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
} }
} // end for $t (tables list) } // end while (tables list)
if (!$table_list) { if (!$table_list) {
$table_list = ' <br /><br />' . "\n" $table_list = ' <br /><br />' . "\n"
@@ -618,7 +616,7 @@ if ($num_dbs > 1) {
// Case where only one database has to be displayed // Case where only one database has to be displayed
else if ($num_dbs == 1) { else if ($num_dbs == 1) {
$db = $dblist[0]; $db = $dblist[0];
$tables = @PMA_mysql_list_tables($db); $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
$num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0; $num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
$common_url_query = PMA_generate_common_url($db); $common_url_query = PMA_generate_common_url($db);
if ($num_tables) { if ($num_tables) {
@@ -632,8 +630,8 @@ else if ($num_dbs == 1) {
&& $num_tables) { && $num_tables) {
$tooltip = array(); $tooltip = array();
$tooltip_name = array(); $tooltip_name = array();
$result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db)); $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
while ($tmp = PMA_mysql_fetch_array($result)) { while ($tmp = PMA_DBI_fetch_assoc($result)) {
$tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : ''); $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
$tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']); $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
@@ -692,8 +690,7 @@ else if ($num_dbs == 1) {
// Displays the list of tables from the current database // Displays the list of tables from the current database
$tablestack = array(); $tablestack = array();
for ($j = 0; $j < $num_tables; $j++) { while (list($table) = PMA_DBI_fetch_row($tables)) {
$table = PMA_mysql_tablename($tables, $j);
$alias = (!empty($tooltip_name) && isset($tooltip_name[$table])) $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
? htmlentities($tooltip_name[$table]) ? htmlentities($tooltip_name[$table])
: ''; : '';

View File

@@ -44,7 +44,7 @@ function PMA_auth_check()
function PMA_auth_set_user() function PMA_auth_set_user()
{ {
return TRUE; return TRUE;
} // end of the 'PMA_auth_set_user()' function } // end of the 'PMA_auth_set_user()' function
/** /**
@@ -69,8 +69,8 @@ function PMA_auth_fails()
{ {
global $php_errormsg, $cfg; global $php_errormsg, $cfg;
global $right_font_family, $font_size, $font_bigger; global $right_font_family, $font_size, $font_bigger;
if (PMA_mysql_error()) { if (PMA_DBI_getError()) {
$conn_error = PMA_mysql_error(); $conn_error = PMA_DBI_getError();
} else if (isset($php_errormsg)) { } else if (isset($php_errormsg)) {
$conn_error = $php_errormsg; $conn_error = $php_errormsg;
} else { } else {

View File

@@ -591,8 +591,8 @@ global $conn_error;
// Deletes password cookie and displays the login form // Deletes password cookie and displays the login form
setcookie('pma_cookie_password', base64_encode(''), 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); setcookie('pma_cookie_password', base64_encode(''), 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']);
if (PMA_mysql_error()) { if (PMA_DBI_getError()) {
$conn_error = PMA_mysql_error(); $conn_error = PMA_DBI_getError();
} else if (isset($php_errormsg)) { } else if (isset($php_errormsg)) {
$conn_error = $php_errormsg; $conn_error = $php_errormsg;
} else { } else {

View File

@@ -38,29 +38,29 @@ function PMA_getBookmarksParam()
/** /**
* Gets the list of bookmarks defined for the current database * Gets the list of bookmarks defined for the current database
* *
* @param string the current database name * @global resource the controluser db connection handle
* @param array the bookmark parameters for the current user
* *
* @return mixed the bookmarks list if defined, false else * @param string the current database name
* @param array the bookmark parameters for the current user
*
* @return mixed the bookmarks list if defined, false else
* *
* @access public * @access public
*/ */
function PMA_listBookmarks($db, $cfgBookmark) function PMA_listBookmarks($db, $cfgBookmark)
{ {
global $dbh;
$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 = \'\')';
if (isset($GLOBALS['dbh'])) { $result = PMA_DBI_query($query, $dbh);
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
} else {
$result = PMA_mysql_query($query);
}
// There is some bookmarks -> store them // There is some bookmarks -> store them
if ($result > 0 && PMA_DBI_num_rows($result) > 0) { if ($result > 0 && PMA_DBI_num_rows($result) > 0) {
$flag = 1; $flag = 1;
while ($row = PMA_mysql_fetch_row($result)) { while ($row = PMA_DBI_fetch_row($result)) {
$bookmark_list[$flag . ' - ' . $row[0]] = $row[1]; $bookmark_list[$flag . ' - ' . $row[0]] = $row[1];
$flag++; $flag++;
} // end while } // end while
@@ -76,17 +76,20 @@ function PMA_listBookmarks($db, $cfgBookmark)
/** /**
* Gets the sql command from a bookmark * Gets the sql command from a bookmark
* *
* @param string the current database name * @global resource the controluser db connection handle
* @param array the bookmark parameters for the current user
* @param mixed the id of the bookmark to get
* @param string which field to look up the $id
* *
* @return string the sql query * @param string the current database name
* @param array the bookmark parameters for the current user
* @param mixed the id of the bookmark to get
* @param string which field to look up the $id
*
* @return string the sql query
* *
* @access public * @access public
*/ */
function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id') function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id')
{ {
global $dbh;
if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) { if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
return ''; return '';
@@ -97,12 +100,8 @@ function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id')
. ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\'' . ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')' . ' OR user = \'\')'
. ' AND ' . PMA_backquote($id_field) . ' = ' . $id; . ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
if (isset($GLOBALS['dbh'])) { $result = PMA_DBI_try_query($query, $dbh);
$result = PMA_mysql_query($query, $GLOBALS['dbh']); list($bookmark_query) = PMA_DBI_fetch_row($result) or array(FALSE);
} else {
$result = PMA_mysql_query($query);
}
$bookmark_query = @PMA_mysql_result($result, 0, 'query') OR FALSE;
return $bookmark_query; return $bookmark_query;
} // end of the 'PMA_queryBookmarks()' function } // end of the 'PMA_queryBookmarks()' function
@@ -111,33 +110,23 @@ function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id')
/** /**
* Adds a bookmark * Adds a bookmark
* *
* @param array the properties of the bookmark to add * @global resource the controluser db connection handle
* @param array the bookmark parameters for the current user
* @param boolean whether to make the bookmark available for all users
* *
* @return boolean whether the INSERT succeeds or not * @param array the properties of the bookmark to add
* @param array the bookmark parameters for the current user
* @param boolean whether to make the bookmark available for all users
*
* @return boolean whether the INSERT succeeds or not
* *
* @access public * @access public
*/ */
function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false) function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
{ {
global $dbh;
$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 (\'\', \'' . 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 (\'\', \'' . PMA_sqlAddslashes($fields['dbase']) . '\', \'' . ($all_users ? '' : PMA_sqlAddslashes($fields['user'])) . '\', \'' . PMA_sqlAddslashes(urldecode($fields['query'])) . '\', \'' . PMA_sqlAddslashes($fields['label']) . '\')';
if (isset($GLOBALS['dbh'])) { $result = PMA_DBI_query($query, $dbh);
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
if (PMA_mysql_error($GLOBALS['dbh'])) {
$error = PMA_mysql_error($GLOBALS['dbh']);
require_once('./header.inc.php');
PMA_mysqlDie($error);
}
} else {
$result = PMA_mysql_query($query);
if (PMA_mysql_error()) {
$error = PMA_mysql_error();
require_once('./header.inc.php');
PMA_mysqlDie($error);
}
}
return TRUE; return TRUE;
} // end of the 'PMA_addBookmarks()' function } // end of the 'PMA_addBookmarks()' function
@@ -146,6 +135,8 @@ function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
/** /**
* Deletes a bookmark * Deletes a bookmark
* *
* @global resource the controluser db connection handle
*
* @param string the current database name * @param string the current database name
* @param array the bookmark parameters for the current user * @param array the bookmark parameters for the current user
* @param integer the id of the bookmark to get * @param integer the id of the bookmark to get
@@ -154,15 +145,13 @@ function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
*/ */
function PMA_deleteBookmarks($db, $cfgBookmark, $id) function PMA_deleteBookmarks($db, $cfgBookmark, $id)
{ {
global $dbh;
$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;
if (isset($GLOBALS['dbh'])) { $result = PMA_DBI_try_query($query, $dbh);
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
} else {
$result = PMA_mysql_query($query);
}
} // end of the 'PMA_deleteBookmarks()' function } // end of the 'PMA_deleteBookmarks()' function

View File

@@ -458,7 +458,7 @@ if ($is_minimum_common == FALSE) {
require_once('./header.inc.php'); require_once('./header.inc.php');
if (!$error_message) { if (!$error_message) {
$error_message = PMA_mysql_error(); $error_message = PMA_DBI_getError();
} }
if (!$the_query && !empty($GLOBALS['sql_query'])) { if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query']; $the_query = $GLOBALS['sql_query'];
@@ -583,7 +583,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_mysql_query($auth_query, $dbh); // Debug: or PMA_mysqlDie('', $auth_query, FALSE); $rs = PMA_DBI_try_query($auth_query, $dbh);
} // end } // end
} }
@@ -591,7 +591,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
// usable db list // usable db list
if (!$dblist_cnt if (!$dblist_cnt
&& ($rs && @PMA_DBI_num_rows($rs))) { && ($rs && @PMA_DBI_num_rows($rs))) {
$row = PMA_mysql_fetch_array($rs); $row = PMA_DBI_fetch_assoc($rs);
PMA_DBI_free_result($rs); PMA_DBI_free_result($rs);
// Correction uva 19991215 // Correction uva 19991215
// Previous code assumed database "mysql" admin table "db" column // Previous code assumed database "mysql" admin table "db" column
@@ -608,7 +608,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_mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE); $rs = PMA_DBI_try_query($local_query, $dbh);
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:
@@ -620,7 +620,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
// populating $dblist[], as previous code did. But it is // populating $dblist[], as previous code did. But it is
// now populated with actual database names instead of // now populated with actual database names instead of
// with regular expressions. // with regular expressions.
while ($row = PMA_mysql_fetch_array($rs)) { while ($row = PMA_DBI_fetch_assoc($rs)) {
// loic1: all databases cases - part 1 // loic1: all databases cases - part 1
if (empty($row['Db']) || $row['Db'] == '%') { if (empty($row['Db']) || $row['Db'] == '%') {
$uva_mydbs['%'] = 1; $uva_mydbs['%'] = 1;
@@ -632,15 +632,15 @@ 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 = mysql_list_dbs($GLOBALS['dbh']); $uva_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['dbh']);
// loic1: all databases cases - part 2 // loic1: all databases cases - part 2
if (isset($uva_mydbs['%'])) { if (isset($uva_mydbs['%'])) {
while ($uva_row = PMA_mysql_fetch_array($uva_alldbs)) { while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
$dblist[] = $uva_row[0]; $dblist[] = $uva_row[0];
} // end while } // end while
} // end if } // end if
else { else {
while ($uva_row = PMA_mysql_fetch_array($uva_alldbs)) { while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
$uva_db = $uva_row[0]; $uva_db = $uva_row[0];
if (isset($uva_mydbs[$uva_db]) && $uva_mydbs[$uva_db] == 1) { if (isset($uva_mydbs[$uva_db]) && $uva_mydbs[$uva_db] == 1) {
$dblist[] = $uva_db; $dblist[] = $uva_db;
@@ -668,9 +668,9 @@ 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_mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE); $rs = PMA_DBI_try_query($local_query, $dbh);
if ($rs && @PMA_DBI_num_rows($rs)) { if ($rs && @PMA_DBI_num_rows($rs)) {
while ($row = PMA_mysql_fetch_array($rs)) { while ($row = PMA_DBI_fetch_assoc($rs)) {
if (PMA_isInto($row['Db'], $dblist) == -1) { if (PMA_isInto($row['Db'], $dblist) == -1) {
$dblist[] = $row['Db']; $dblist[] = $row['Db'];
} }
@@ -996,7 +996,7 @@ if ($is_minimum_common == FALSE) {
// Connects to the server (validates user's login) // Connects to the server (validates user's login)
$userlink = PMA_DBI_connect($cfg['Server']['user'], $cfg['Server']['password']); $userlink = PMA_DBI_connect($cfg['Server']['user'], $cfg['Server']['password']);
if (empty($dbh)) { if (empty($dbh)) {
$dbh = $userlink; $dbh = $userlink;
} }
@@ -1044,18 +1044,18 @@ if ($is_minimum_common == FALSE) {
} }
if ($is_show_dbs && ereg('(^|[^\])(_|%)', $dblist[$i])) { if ($is_show_dbs && ereg('(^|[^\])(_|%)', $dblist[$i])) {
$local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\''; $local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\'';
$rs = PMA_mysql_query($local_query, $dbh); $rs = PMA_DBI_query($local_query, $dbh);
// "SHOW DATABASES" statement is disabled // "SHOW DATABASES" statement is disabled
if ($i == 0 if ($i == 0
&& (PMA_mysql_error() && mysql_errno() == 1045)) { && (substr(PMA_DBI_getError($dbh), 1, 4) == 1045)) {
$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_mysql_error()) { // else if (PMA_DBI_getError($dbh)) {
// PMA_mysqlDie('', $local_query, FALSE); // PMA_mysqlDie(PMA_DBI_getError($dbh), $local_query, FALSE);
// } // }
while ($row = @PMA_mysql_fetch_row($rs)) { while ($row = @PMA_DBI_fetch_row($rs)) {
$true_dblist[] = $row[0]; $true_dblist[] = $row[0];
} // end while } // end while
if ($rs) { if ($rs) {
@@ -1110,7 +1110,7 @@ if ($is_minimum_common == FALSE) {
if ($num_dbs) { if ($num_dbs) {
$true_dblist = array(); $true_dblist = array();
for ($i = 0; $i < $num_dbs; $i++) { for ($i = 0; $i < $num_dbs; $i++) {
$dblink = @PMA_mysql_select_db($dblist[$i]); $dblink = @PMA_DBI_select_db($dblist[$i]);
if ($dblink) { if ($dblink) {
$true_dblist[] = $dblist[$i]; $true_dblist[] = $dblist[$i];
} // end if } // end if
@@ -1245,9 +1245,8 @@ if ($is_minimum_common == FALSE) {
function PMA_countRecords($db, $table, $ret = FALSE) function PMA_countRecords($db, $table, $ret = FALSE)
{ {
global $err_url, $cfg; global $err_url, $cfg;
$local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''; $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); $showtable = PMA_DBI_fetch_assoc($result);
$showtable = PMA_mysql_fetch_array($result);
$num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); $num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
if ($num < $cfg['MaxExactCount']) { if ($num < $cfg['MaxExactCount']) {
unset($num); unset($num);
@@ -1255,8 +1254,8 @@ if ($is_minimum_common == FALSE) {
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
if (!isset($num)) { if (!isset($num)) {
$result = PMA_mysql_query('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)) or PMA_mysqlDie('', $local_query, '', $err_url); $result = PMA_DBI_query('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
$num = ($result) ? PMA_mysql_result($result, 0, 'num') : 0; list($num) = ($result) ? PMA_DBI_fetch_row($result) : array(0);
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
} }
if ($ret) { if ($ret) {
@@ -1302,9 +1301,9 @@ if (typeof(window.parent) != 'undefined'
// Corrects the tooltip text via JS if required // Corrects the tooltip text via JS if required
else if (!empty($GLOBALS['table']) && $cfg['ShowTooltip']) { else if (!empty($GLOBALS['table']) && $cfg['ShowTooltip']) {
$result = @PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\''); $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\'');
if ($result) { if ($result) {
$tbl_status = PMA_mysql_fetch_array($result, MYSQL_ASSOC); $tbl_status = PMA_DBI_fetch_assoc($result);
$tooltip = (empty($tbl_status['Comment'])) $tooltip = (empty($tbl_status['Comment']))
? '' ? ''
: $tbl_status['Comment'] . ' '; : $tbl_status['Comment'] . ' ';
@@ -1333,14 +1332,14 @@ if (typeof(document.getElementById) != 'undefined'
if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query']) if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query'])
&& $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) { && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
if (!isset($tbl_status)) { if (!isset($tbl_status)) {
$result = @PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\''); $result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\'');
if ($result) { if ($result) {
$tbl_status = PMA_mysql_fetch_array($result, MYSQL_ASSOC); $tbl_status = PMA_DBI_fetch_assoc($result);
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
} }
} }
if (isset($tbl_status) && (int) $tbl_status['Index_length'] > 1024) { if (isset($tbl_status) && (int) $tbl_status['Index_length'] > 1024) {
@PMA_mysql_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])); PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
} }
} }
unset($tbl_status); unset($tbl_status);

View File

@@ -15,4 +15,61 @@ function PMA_DBI_query($query, $dbh = '') {
return $res; return $res;
} }
function PMA_DBI_get_dblist($link = NULL) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
$res = PMA_DBI_try_query('SHOW DATABASES;', $link);
$dbs_array = array();
while ($row = PMA_DBI_fetch_row($res)) {
// Before MySQL 4.0.2, SHOW DATABASES could send the
// whole list, so check if we really have access:
if (PMA_MYSQL_CLIENT_API < 40002) {
$dblink = @PMA_DBI_select_db($row[0], $link);
if (!$dblink) {
continue;
}
}
$dbs_array[] = $row[0];
}
PMA_DBI_free_result($res);
unset($res);
return $dbs_array;
}
function PMA_DBI_get_tables($database, $link = NULL) {
$result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($database) . ';');
$tables = array();
while (list($current) = PMA_DBI_fetch_row($result)) {
$tables[] = $current;
}
PMA_DBI_free_result($result);
return $tables;
}
function PMA_DBI_get_fields($database, $table, $link = NULL) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
$result = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table), $link);
$fields = array();
while ($row = PMA_DBI_fetch_assoc($result)) {
$fields[] = $row;
}
return $fields;
}
?> ?>

View File

@@ -10,7 +10,7 @@
if (!isset($is_db) || !$is_db) { if (!isset($is_db) || !$is_db) {
// Not a valid db name -> back to the welcome page // Not a valid db name -> back to the welcome page
if (!empty($db)) { if (!empty($db)) {
$is_db = @PMA_mysql_select_db($db); $is_db = @PMA_DBI_select_db($db);
} }
if (empty($db) || !$is_db) { if (empty($db) || !$is_db) {
if (!isset($is_transformation_wrapper)) { if (!isset($is_transformation_wrapper)) {
@@ -22,7 +22,7 @@ if (!isset($is_db) || !$is_db) {
if (!isset($is_table) || !$is_table) { if (!isset($is_table) || !$is_table) {
// Not a valid table name -> back to the db_details.php // Not a valid table name -> back to the db_details.php
if (!empty($table)) { if (!empty($table)) {
$is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''); $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
} }
if (empty($table) if (empty($table)
|| !($is_table && @PMA_DBI_num_rows($is_table))) { || !($is_table && @PMA_DBI_num_rows($is_table))) {

View File

@@ -6,8 +6,6 @@
* Interface to the classic MySQL extension * Interface to the classic MySQL extension
*/ */
require_once('./libraries/charset_conversion.lib.php');
/** /**
* Loads the mysql extensions if it is not loaded yet * Loads the mysql extensions if it is not loaded yet
*/ */
@@ -36,6 +34,7 @@ function PMA_DBI_connect($user, $password) {
$server_port = (empty($cfg['Server']['port'])) $server_port = (empty($cfg['Server']['port']))
? '' ? ''
: ':' . $cfg['Server']['port']; : ':' . $cfg['Server']['port'];
if (strtolower($cfg['Server']['connect_type']) == 'tcp') { if (strtolower($cfg['Server']['connect_type']) == 'tcp') {
$cfg['Server']['socket'] = ''; $cfg['Server']['socket'] = '';
} }
@@ -64,10 +63,10 @@ function PMA_DBI_connect($user, $password) {
} // end if } // end if
if (!defined('PMA_MYSQL_INT_VERSION')) { if (!defined('PMA_MYSQL_INT_VERSION')) {
$result = PMA_DBI_try_query('SELECT VERSION() AS version', $link); $result = mysql_query('SELECT VERSION() AS version', $link);
if ($result != FALSE && @mysql_num_rows($result) > 0) { if ($result != FALSE && @mysql_num_rows($result) > 0) {
$row = PMA_DBI_fetch_assoc($result); $row = mysql_fetch_row($result);
$match = explode('.', $row['version']); $match = explode('.', $row[0]);
mysql_free_result($result); mysql_free_result($result);
} }
if (!isset($row)) { if (!isset($row)) {
@@ -75,14 +74,35 @@ function PMA_DBI_connect($user, $password) {
define('PMA_MYSQL_STR_VERSION', '3.23.32'); define('PMA_MYSQL_STR_VERSION', '3.23.32');
} else{ } else{
define('PMA_MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2]))); define('PMA_MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
define('PMA_MYSQL_STR_VERSION', $row['version']); define('PMA_MYSQL_STR_VERSION', $row[0]);
unset($result, $row, $match); unset($result, $row, $match);
} }
} }
if (PMA_MYSQL_INT_VERSION >= 40100) {
mysql_query('SET CHARACTER SET utf8;', $link);
mysql_query('SET SESSION character_set_connection = \'utf8\';', $link);
} else {
require_once('./libraries/charset_conversion.lib.php');
}
return $link; return $link;
} }
function PMA_DBI_select_db($dbname, $link = '') {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
if (PMA_MYSQL_INT_VERSION < 40100) {
$dbname = PMA_convert_charset($dbname);
}
return mysql_select_db($dbname, $link);
}
function PMA_DBI_try_query($query, $link = '') { function PMA_DBI_try_query($query, $link = '') {
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
@@ -91,6 +111,9 @@ function PMA_DBI_try_query($query, $link = '') {
return FALSE; return FALSE;
} }
} }
if (PMA_MYSQL_INT_VERSION < 40100) {
$query = PMA_convert_charset($query);
}
return mysql_query(PMA_convert_charset($query), $link); return mysql_query(PMA_convert_charset($query), $link);
} }
@@ -104,7 +127,8 @@ function PMA_mysql_fetch_array($result, $type = FALSE) {
} else { } else {
$data = mysql_fetch_array($result); $data = mysql_fetch_array($result);
} }
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) { if (PMA_MYSQL_INT_VERSION >= 40100
|| !(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
/* No recoding -> return data as we got them */ /* No recoding -> return data as we got them */
return $data; return $data;
} else { } else {
@@ -142,7 +166,7 @@ function PMA_DBI_fetch_row($result) {
} }
function PMA_DBI_free_result($result) { function PMA_DBI_free_result($result) {
return mysql_free_result($result); return @mysql_free_result($result);
} }
function PMA_DBI_getError($link = '') { function PMA_DBI_getError($link = '') {
@@ -154,22 +178,15 @@ function PMA_DBI_getError($link = '') {
} }
} }
$error = mysql_errno($link); $error = mysql_errno($link);
if ($error) { if ($error && PMA_MYSQL_INT_VERSION >= 40100) {
$error = mysql_errno($link); $error = '#' . ((string) $error) . ' - ' . mysql_error($link);
if (!empty($error)) { } elseif ($error) {
$error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset(mysql_error($link)); $error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset(mysql_error($link));
}
} }
return $error;
} }
function PMA_DBI_close($link = '') { function PMA_DBI_close($link = '') {
if (empty($link)) {
$link = $GLOBALS['userlink'];
}
@mysql_close($link);
}
function PMA_DBI_get_dblist($link = '') {
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
@@ -177,25 +194,7 @@ function PMA_DBI_get_dblist($link = '') {
return FALSE; return FALSE;
} }
} }
$res = PMA_DBI_try_query('SHOW DATABASES;', $link); return @mysql_close($link);
$dbs_array = array();
while ($row = PMA_DBI_fetch_row($res)) {
// not sure if we have to convert before the (possible) select_db()
$dbname = PMA_convert_display_charset($row[0]);
// Before MySQL 4.0.2, SHOW DATABASES could send the
// whole list, so check if we really have access:
if (PMA_MYSQL_CLIENT_API < 40002) {
$dblink = @PMA_mysql_select_db($dbname);
if (!dblink) {
continue;
}
}
$dbs_array[] = $dbname;
}
PMA_DBI_free_result($res);
unset($res);
return $dbs_array;
} }
function PMA_DBI_num_rows($result) { function PMA_DBI_num_rows($result) {
@@ -224,4 +223,13 @@ function PMA_DBI_affected_rows($link) {
return mysql_affected_rows($link); return mysql_affected_rows($link);
} }
?> function PMA_DBI_get_fields_meta($result) {
$fields = array();
$num_fields = mysql_num_fields($result);
for ($i = 0; $i < $num_fields; $i++) {
$fields[] = mysql_fetch_field($result, $i);
}
return $fields;
}
?>

View File

@@ -0,0 +1,216 @@
<?php
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* Interface to the improved MySQL extension (MySQLi)
*/
/**
* Loads the MySQLi extension if it is not loaded yet
*/
if (!@function_exists('mysqli_connect')) {
PMA_dl('mysqli');
}
// check whether mysql is available
if (!@function_exists('mysqli_connect')) {
require_once('./libraries/header_http.inc.php');
echo $strCantLoadMySQL . '<br />' . "\n" // TODO: Replace by a MySQLi related message
. '<a href="./Documentation.html#faqmysql" target="documentation">' . $GLOBALS['strDocu'] . '</a>' . "\n";
exit;
}
// MySQL client API
if (!defined('PMA_MYSQL_CLIENT_API')) {
$client_api = explode('.', mysqli_get_client_info());
define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2])));
unset($client_api);
}
function PMA_DBI_connect($user, $password) {
global $cfg, $php_errormsg;
$server_port = (empty($cfg['Server']['port']))
? FALSE
: (int) $cfg['Server']['port'];
if (strtolower($cfg['Server']['connect_type']) == 'tcp') {
$cfg['Server']['socket'] = '';
}
$server_socket = (empty($cfg['Server']['socket']))
? FALSE
: $cfg['Server']['socket'];
$link = mysqli_connect($cfg['Server']['host'], $user, $password, FALSE, $server_port, $server_socket);
if (empty($link)) {
PMA_auth_fails();
} // end if
if (!defined('PMA_MYSQL_INT_VERSION')) {
$result = mysqli_query($link, 'SELECT VERSION() AS version;', MYSQLI_STORE_RESULT);
if ($result != FALSE && @mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_row($result);
$match = explode('.', $row[0]);
mysqli_free_result($result);
}
if (!isset($row)) {
define('PMA_MYSQL_INT_VERSION', 32332);
define('PMA_MYSQL_STR_VERSION', '3.23.32');
} else{
define('PMA_MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
define('PMA_MYSQL_STR_VERSION', $row[0]);
unset($result, $row, $match);
}
}
if (PMA_MYSQL_INT_VERSION >= 40100) {
mysqli_query($link, 'SET CHARACTER SET utf8;', MYSQLI_STORE_RESULT);
mysqli_query($link, 'SET SESSION character_set_connection = \'utf8\';', MYSQLI_STORE_RESULT);
} else {
require_once('./libraries/charset_conversion.lib.php');
}
return $link;
}
function PMA_DBI_select_db($dbname, $link = '') {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
if (PMA_MYSQL_INT_VERSION < 40100) {
$dbname = PMA_convert_charset($dbname);
}
return mysqli_select_db($link, $dbname);
}
function PMA_DBI_try_query($query, $link = '') {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
if (PMA_MYSQL_INT_VERSION < 40100) {
$query = PMA_convert_charset($query);
}
return mysqli_query($link, $query, MYSQLI_USE_RESULT);
}
// The following function is meant for internal use only.
// Do not call it from outside this library!
function PMA_mysqli_fetch_array($result, $type = FALSE) {
global $cfg, $allow_recoding, $charset, $convcharset;
if ($type != FALSE) {
$data = mysqli_fetch_array($result, $type);
} else {
$data = mysqli_fetch_array($result);
}
if (PMA_MYSQL_INT_VERSION >= 40100
|| !(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
/* No recoding -> return data as we got them */
return $data;
} else {
$ret = array();
$num = mysqli_num_fields($result);
$fields = mysqli_fetch_fields($result);
$i = 0;
for($i = 0; $i < $num; $i++) {
if (!$meta) {
/* No meta information available -> we guess that it should be converted */
if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]);
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]);
} else {
/* Meta information available -> check type of field and convert it according to the type */
if (stristr($fields[$i]->type, 'BLOB') || stristr($fields[$i]->type, 'BINARY')) {
if (isset($data[$i])) $ret[$i] = $data[$i];
if (isset($data[$fields[$i]->name])) $ret[PMA_convert_display_charset($fields[$i]->name)] = $data[$fields[$i]->name];
} else {
if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]);
if (isset($data[$fields[$i]->name])) $ret[PMA_convert_display_charset($fields[$i]->name)] = PMA_convert_display_charset($data[$fields[$i]->name]);
}
}
}
return $ret;
}
}
function PMA_DBI_fetch_assoc($result) {
return PMA_mysqli_fetch_array($result, MYSQLI_ASSOC);
}
function PMA_DBI_fetch_row($result) {
return PMA_mysqli_fetch_array($result, MYSQLI_NUM);
}
function PMA_DBI_free_result($result) {
return @mysqli_free_result($result);
}
function PMA_DBI_getError($link = '') {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
$error = mysqli_errno($link);
if ($error && PMA_MYSQL_INT_VERSION >= 40100) {
$error = '#' . ((string) $error) . ' - ' . mysqli_error($link);
} elseif ($error) {
$error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset(mysqli_error($link));
}
return $error;
}
function PMA_DBI_close($link = '') {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
return @mysqli_close($link);
}
function PMA_DBI_num_rows($result) {
return @mysqli_num_rows($result);
}
function PMA_DBI_insert_id($link) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
return mysqli_insert_id($link);
}
function PMA_DBI_affected_rows($link) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
return mysqli_affected_rows($link);
}
function PMA_DBI_get_fields_meta($result) {
return mysqli_fetch_fields($result);
}
?>

View File

@@ -485,13 +485,12 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) { isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
// grab indexes data: // grab indexes data:
$local_query = 'SHOW KEYS FROM ' . PMA_backquote($table); $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); $idx_cnt = PMA_DBI_num_rows($result);
$idx_cnt = PMA_DBI_num_rows($result);
$prev_index = ''; $prev_index = '';
for ($i = 0; $i < $idx_cnt; $i++) { for ($i = 0; $i < $idx_cnt; $i++) {
$row = (defined('PMA_IDX_INCLUDED') ? $ret_keys[$i] : PMA_mysql_fetch_array($result)); $row = (defined('PMA_IDX_INCLUDED') ? $ret_keys[$i] : PMA_DBI_fetch_assoc($result));
if ($row['Key_name'] != $prev_index ){ if ($row['Key_name'] != $prev_index ){
$indexes[] = $row['Key_name']; $indexes[] = $row['Key_name'];
@@ -749,7 +748,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// FROM `PMA_relation` AS `1` , `PMA_relation` AS `2` // FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
if (($is_join if (($is_join
&& !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . $fields_meta[$i]->name . '~i', $select_stt[1], $parts)) && !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . $fields_meta[$i]->name . '~i', $select_stt[1], $parts))
|| ( isset($analyzed_sql[0]['select_expr'][$i]['expr']) || ( isset($analyzed_sql[0]['select_expr'][$i]['expr'])
&& isset($analyzed_sql[0]['select_expr'][$i]['column']) && isset($analyzed_sql[0]['select_expr'][$i]['column'])
&& $analyzed_sql[0]['select_expr'][$i]['expr'] != && $analyzed_sql[0]['select_expr'][$i]['expr'] !=
@@ -974,7 +973,10 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
// loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row' // loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row'
// to get the NULL values // to get the NULL values
while ($row = PMA_mysql_fetch_array($dt_result)) { // rabus: This function needs a little rework.
// Using MYSQL_BOTH just pollutes the memory!
while ($row = PMA_mysql_fetch_array($dt_result)) { // !UNWRAPPED FUNCTION!
// lem9: "vertical display" mode stuff // lem9: "vertical display" mode stuff
if (($row_no != 0) && ($repeat_cells != 0) && !($row_no % $repeat_cells) && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { if (($row_no != 0) && ($repeat_cells != 0) && !($row_no % $repeat_cells) && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
@@ -1029,7 +1031,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
// "primary" key to use in links // "primary" key to use in links
if ($is_display['edit_lnk'] == 'ur' /* || $is_display['edit_lnk'] == 'dr' */) { if ($is_display['edit_lnk'] == 'ur' /* || $is_display['edit_lnk'] == 'dr' */) {
for ($i = 0; $i < $fields_cnt; ++$i) { for ($i = 0; $i < $fields_cnt; ++$i) {
$field_flags = PMA_mysql_field_flags($dt_result, $i); $field_flags = PMA_mysql_field_flags($dt_result, $i); // !UNWRAPPED FUNCTION!
$meta = $fields_meta[$i]; $meta = $fields_meta[$i];
// do not use an alias in a condition // do not use an alias in a condition
@@ -1300,9 +1302,9 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
. ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
. ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' WHERE ' . PMA_backquote($map[$meta->name][1])
. ' = ' . $row[$pointer]; . ' = ' . $row[$pointer];
$dispresult = PMA_mysql_query($dispsql); $dispresult = PMA_DBI_try_query($dispsql);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) { if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
$dispval = PMA_mysql_result($dispresult, 0); list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
} }
else { else {
$dispval = $GLOBALS['strLinkNotFound']; $dispval = $GLOBALS['strLinkNotFound'];
@@ -1338,7 +1340,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
// TEXT fields type, however TEXT fields must be displayed // TEXT fields type, however TEXT fields must be displayed
// even if $cfg['ShowBlob'] is false -> get the true type // even if $cfg['ShowBlob'] is false -> get the true type
// of the fields. // of the fields.
$field_flags = PMA_mysql_field_flags($dt_result, $i); $field_flags = PMA_mysql_field_flags($dt_result, $i); // !UNWRAPPED FUNCTION!
if (stristr($field_flags, 'BINARY')) { if (stristr($field_flags, 'BINARY')) {
$blobtext = '[BLOB'; $blobtext = '[BLOB';
if (isset($row[$pointer])) { if (isset($row[$pointer])) {
@@ -1385,7 +1387,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
} }
// loic1: displays special characters from binaries // loic1: displays special characters from binaries
$field_flags = PMA_mysql_field_flags($dt_result, $i); $field_flags = PMA_mysql_field_flags($dt_result, $i); // !UNWRAPPED FUNCTION!
if (stristr($field_flags, 'BINARY')) { if (stristr($field_flags, 'BINARY')) {
$row[$pointer] = str_replace("\x00", '\0', $row[$pointer]); $row[$pointer] = str_replace("\x00", '\0', $row[$pointer]);
$row[$pointer] = str_replace("\x08", '\b', $row[$pointer]); $row[$pointer] = str_replace("\x08", '\b', $row[$pointer]);
@@ -1427,9 +1429,9 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
. ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
. ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' WHERE ' . PMA_backquote($map[$meta->name][1])
. ' = \'' . PMA_sqlAddslashes($row[$pointer]) . '\''; . ' = \'' . PMA_sqlAddslashes($row[$pointer]) . '\'';
$dispresult = @PMA_mysql_query($dispsql); $dispresult = PMA_DBI_try_query($dispsql);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) { if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
$dispval = PMA_mysql_result($dispresult, 0); list($dispval) = PMA_DBI_fetch_row($dispresult);
} }
else { else {
$dispval = $GLOBALS['strLinkNotFound']; $dispval = $GLOBALS['strLinkNotFound'];

View File

@@ -113,18 +113,18 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $escaped; global $escaped;
// Gets the data from the database // Gets the data from the database
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $error_url); $result = PMA_DBI_query($sql_query);
$fields_cnt = mysql_num_fields($result); $fields_cnt = PMA_DBI_num_fields($result);
// If required, get fields name at the first line // If required, get fields name at the first line
if (isset($GLOBALS['showcsvnames']) && $GLOBALS['showcsvnames'] == 'yes') { if (isset($GLOBALS['showcsvnames']) && $GLOBALS['showcsvnames'] == 'yes') {
$schema_insert = ''; $schema_insert = '';
for ($i = 0; $i < $fields_cnt; $i++) { for ($i = 0; $i < $fields_cnt; $i++) {
if ($enclosed == '') { if ($enclosed == '') {
$schema_insert .= stripslashes(mysql_field_name($result, $i)); $schema_insert .= stripslashes(mysql_field_name($result, $i)); //! UNWRAPPED FUNCTION!
} else { } else {
$schema_insert .= $enclosed $schema_insert .= $enclosed
. str_replace($enclosed, $escaped . $enclosed, stripslashes(mysql_field_name($result, $i))) . str_replace($enclosed, $escaped . $enclosed, stripslashes(mysql_field_name($result, $i))) //! UNWRAPPED FUNCTION!
. $enclosed; . $enclosed;
} }
$schema_insert .= $separator; $schema_insert .= $separator;
@@ -134,7 +134,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
} // end if } // end if
// Format the data // Format the data
while ($row = PMA_mysql_fetch_row($result)) { while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = ''; $schema_insert = '';
for ($j = 0; $j < $fields_cnt; $j++) { for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j])) { if (!isset($row[$j])) {

View File

@@ -159,7 +159,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
} }
// print the whole table // print the whole table
while ($record = PMA_mysql_fetch_array($result, MYSQL_ASSOC)) { while ($record = PMA_DBI_fetch_assoc($result)) {
$buffer = ''; $buffer = '';
// print each row // print each row
@@ -212,9 +212,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
/** /**
* Gets fields properties * Gets fields properties
*/ */
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table); $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url); $result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck) // Check if we can use Relations (Mike Beck)
@@ -237,9 +237,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
* Get the unique keys in the table * Get the unique keys in the table
*/ */
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db); $keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_mysql_query($keys_query) or PMA_mysqlDie('', $keys_query, '', $error_url); $keys_result = PMA_DBI_query($keys_query);
$unique_keys = array(); $unique_keys = array();
while($key = PMA_mysql_fetch_array($keys_result)) { while($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) $unique_keys[] = $key['Column_name']; if ($key['Non_unique'] == 0) $unique_keys[] = $key['Column_name'];
} }
@@ -298,7 +298,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) return FALSE;
while ($row = PMA_mysql_fetch_array($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
$type = $row['Type']; $type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001 // reformat mysql query output - staybyte - 9. June 2001

View File

@@ -21,9 +21,9 @@ error_reporting(E_ALL);
* even for 'text' fields. * even for 'text' fields.
*/ */
function PMA_fieldTypes($db, $table,$use_backquotes) { function PMA_fieldTypes($db, $table,$use_backquotes) {
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$table_def = PMA_mysql_query('SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)); $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
while($row = @PMA_mysql_fetch_array($table_def)) { while($row = PMA_DBI_fetch_assoc($table_def)) {
$types[PMA_backquote($row['Field'],$use_backquotes)] = ereg_replace('\\(.*', '', $row['Type']); $types[PMA_backquote($row['Field'],$use_backquotes)] = ereg_replace('\\(.*', '', $row['Type']);
} }
return $types; return $types;
@@ -154,10 +154,10 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
$new_crlf = $crlf; $new_crlf = $crlf;
$result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table) . '\''); $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table) . '\'');
if ($result != FALSE) { if ($result != FALSE) {
if (PMA_DBI_num_rows($result) > 0) { if (PMA_DBI_num_rows($result) > 0) {
$tmpres = PMA_mysql_fetch_array($result); $tmpres = PMA_DBI_fetch_assoc($result);
if (isset($GLOBALS['auto_increment']) && !empty($tmpres['Auto_increment'])) { if (isset($GLOBALS['auto_increment']) && !empty($tmpres['Auto_increment'])) {
$auto_increment .= ' AUTO_INCREMENT=' . $tmpres['Auto_increment'] . ' '; $auto_increment .= ' AUTO_INCREMENT=' . $tmpres['Auto_increment'] . ' ';
} }
@@ -189,13 +189,13 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
// Steve Alberty's patch for complete table dump, // Steve Alberty's patch for complete table dump,
// Whether to quote table and fields names or not // Whether to quote table and fields names or not
if ($use_backquotes) { if ($use_backquotes) {
PMA_mysql_query('SET SQL_QUOTE_SHOW_CREATE = 1'); PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 1');
} else { } else {
PMA_mysql_query('SET SQL_QUOTE_SHOW_CREATE = 0'); PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0');
} }
$result = PMA_mysql_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table)); $result = PMA_DBI_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table));
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) { if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
$tmpres = PMA_mysql_fetch_array($result); $tmpres = PMA_DBI_fetch_row($result);
// Fix for case problems with winwin, thanks to // Fix for case problems with winwin, thanks to
// Pawe<77> Szczepa<70>ski <pauluz at users.sourceforge.net> // Pawe<77> Szczepa<70>ski <pauluz at users.sourceforge.net>
$pos = strpos($tmpres[1], ' ('); $pos = strpos($tmpres[1], ' (');
@@ -395,9 +395,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
$buffer = ''; $buffer = '';
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $error_url); $result = PMA_DBI_query($sql_query);
if ($result != FALSE) { if ($result != FALSE) {
$fields_cnt = mysql_num_fields($result); $fields_cnt = PMA_DBI_num_fields($result);
$rows_cnt = PMA_DBI_num_rows($result); $rows_cnt = PMA_DBI_num_rows($result);
// get the real types of the table's fields (in an array) // get the real types of the table's fields (in an array)
@@ -415,7 +415,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) { if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) {
$field_set[$j] = PMA_backquote($analyzed_sql[0]['select_expr'][$j]['column'], $use_backquotes); $field_set[$j] = PMA_backquote($analyzed_sql[0]['select_expr'][$j]['column'], $use_backquotes);
} else { } else {
$field_set[$j] = PMA_backquote(PMA_mysql_field_name($result, $j), $use_backquotes); $field_set[$j] = PMA_backquote(PMA_mysql_field_name($result, $j), $use_backquotes); //! UNWRAPPED FUNCTION!
} }
$type = $field_types[$field_set[$j]]; $type = $field_types[$field_set[$j]];
@@ -468,7 +468,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
$replace = array('\0', '\n', '\r', '\Z'); $replace = array('\0', '\n', '\r', '\Z');
$current_row = 0; $current_row = 0;
while ($row = PMA_mysql_fetch_row($result)) { while ($row = PMA_DBI_fetch_row($result)) {
$current_row++; $current_row++;
for ($j = 0; $j < $fields_cnt; $j++) { for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j])) { if (!isset($row[$j])) {

View File

@@ -27,7 +27,7 @@ function PMA_exportComment($text) {
function PMA_exportHeader() { function PMA_exportHeader() {
global $crlf; global $crlf;
global $cfg; global $cfg;
if ($GLOBALS['output_charset_conversion']) { if ($GLOBALS['output_charset_conversion']) {
$charset = $GLOBALS['charset_of_file']; $charset = $GLOBALS['charset_of_file'];
} else { } else {
@@ -113,18 +113,18 @@ function PMA_exportDBCreate($db) {
* @access public * @access public
*/ */
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $error_url); $result = PMA_DBI_query($sql_query);
$columns_cnt = mysql_num_fields($result); $columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) { for ($i = 0; $i < $columns_cnt; $i++) {
$columns[$i] = stripslashes(mysql_field_name($result, $i)); $columns[$i] = stripslashes(mysql_field_name($result, $i)); //! UNWRAPPED FUNCTION!
} }
unset($i); unset($i);
$buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf; $buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) return FALSE;
while ($record = PMA_mysql_fetch_array($result, MYSQL_ASSOC)) { while ($record = PMA_DBI_fetch_assoc($result)) {
$buffer = ' <' . $table . '>' . $crlf; $buffer = ' <' . $table . '>' . $crlf;
for ($i = 0; $i < $columns_cnt; $i++) { for ($i = 0; $i < $columns_cnt; $i++) {
// There is no way to dectect a "NULL" value with PHP3 // There is no way to dectect a "NULL" value with PHP3
@@ -134,7 +134,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
} }
} }
$buffer .= ' </' . $table . '>' . $crlf; $buffer .= ' </' . $table . '>' . $crlf;
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) return FALSE;
} }
PMA_DBI_free_result($result); PMA_DBI_free_result($result);

View File

@@ -36,7 +36,7 @@ if ($foreigners && isset($foreigners[$field])) {
. ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table) . ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table)
. (($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display)) . (($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display))
. (isset($foreign_limit) ? $foreign_limit : ''); . (isset($foreign_limit) ? $foreign_limit : '');
$disp = PMA_mysql_query($dispsql); $disp = PMA_DBI_query($dispsql);
} }
else { else {
unset($disp); unset($disp);

View File

@@ -4,11 +4,10 @@
if (PMA_MYSQL_INT_VERSION >= 40100){ if (PMA_MYSQL_INT_VERSION >= 40100){
$res = PMA_mysql_query('SHOW CHARACTER SET;', $userlink) $res = PMA_DBI_query('SHOW CHARACTER SET;');
or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW CHARACTER SET;');
$mysql_charsets = array(); $mysql_charsets = array();
while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) { while ($row = PMA_DBI_fetch_assoc($res)) {
$mysql_charsets[] = $row['Charset']; $mysql_charsets[] = $row['Charset'];
$mysql_charsets_maxlen[$row['Charset']] = $row['Maxlen']; $mysql_charsets_maxlen[$row['Charset']] = $row['Maxlen'];
$mysql_charsets_descriptions[$row['Charset']] = $row['Description']; $mysql_charsets_descriptions[$row['Charset']] = $row['Description'];
@@ -16,15 +15,14 @@ if (PMA_MYSQL_INT_VERSION >= 40100){
@PMA_DBI_free_result($res); @PMA_DBI_free_result($res);
unset($res, $row); unset($res, $row);
$res = PMA_mysql_query('SHOW COLLATION;', $userlink) $res = PMA_DBI_query('SHOW COLLATION;');
or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW COLLATION;');
$mysql_charsets_count = count($mysql_charsets); $mysql_charsets_count = count($mysql_charsets);
sort($mysql_charsets, SORT_STRING); sort($mysql_charsets, SORT_STRING);
$mysql_collations = array_flip($mysql_charsets); $mysql_collations = array_flip($mysql_charsets);
$mysql_default_collations = $mysql_collations_flat = array();; $mysql_default_collations = $mysql_collations_flat = array();;
while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) { while ($row = PMA_DBI_fetch_assoc($res)) {
if (!is_array($mysql_collations[$row['Charset']])) { if (!is_array($mysql_collations[$row['Charset']])) {
$mysql_collations[$row['Charset']] = array($row['Collation']); $mysql_collations[$row['Charset']] = array($row['Collation']);
} else { } else {
@@ -233,9 +231,9 @@ if (PMA_MYSQL_INT_VERSION >= 40100){
// MySQL 4.1.0 does not support seperate charset settings // MySQL 4.1.0 does not support seperate charset settings
// for databases. // for databases.
$sql_query = 'SHOW CREATE DATABASE `' . $db . '`;'; $res = PMA_DBI_query('SHOW CREATE DATABASE `' . $db . '`;');
$res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); $row = PMA_DBI_fetch_row($res);
$row = PMA_mysql_fetch_row($res); PMA_DBI_free_result($res);
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
$tokenized = explode(' ', $row[1]); $tokenized = explode(' ', $row[1]);
unset($row, $res, $sql_query); unset($row, $res, $sql_query);

View File

@@ -10,15 +10,15 @@
/** /**
* Executes a query as controluser if possible, otherwise as normal user * Executes a query as controluser if possible, otherwise as normal user
* *
* @param string the query to execute * @param string the query to execute
* @param boolean whether to display SQL error messages or not * @param boolean whether to display SQL error messages or not
* *
* @return integer the result id * @return integer the result id
* *
* @global string the URL of the page to show in case of error * @global string the URL of the page to show in case of error
* @global string the name of db to come back to * @global string the name of db to come back to
* @global integer the ressource id of DB connect as controluser * @global resource the resource id of DB connect as controluser
* @global array configuration infos about the relations stuff * @global array configuration infos about the relations stuff
* *
* @access public * @access public
* *
@@ -27,28 +27,20 @@
function PMA_query_as_cu($sql, $show_error = TRUE) { function PMA_query_as_cu($sql, $show_error = TRUE) {
global $err_url_0, $db, $dbh, $cfgRelation; global $err_url_0, $db, $dbh, $cfgRelation;
if (isset($dbh)) { PMA_DBI_select_db($cfgRelation['db'], $dbh);
PMA_mysql_select_db($cfgRelation['db'], $dbh); if ($show_error) {
$result = @PMA_mysql_query($sql, $dbh); $result = PMA_DBI_query($sql, $dbh);
if (!$result && $show_error == TRUE) {
PMA_mysqlDie(mysql_error($dbh), $sql, '', $err_url_0);
}
PMA_mysql_select_db($db, $dbh);
} else { } else {
PMA_mysql_select_db($cfgRelation['db']); $result = PMA_DBI_try_query($sql, $dbh);
$result = @PMA_mysql_query($sql);
if ($result && $show_error == TRUE) {
PMA_mysqlDie('', $sql, '', $err_url_0);
}
PMA_mysql_select_db($db);
} // end if... else... } // end if... else...
PMA_DBI_select_db($db, $dbh);
if ($result) { if ($result) {
return $result; return $result;
} else { } else {
return FALSE; return FALSE;
} }
} // end of the "PMA_query_as_cu()" function } // end of the "PMA_query_as_cu()" function
/** /**
@@ -109,12 +101,12 @@ function PMA_getRelationsParam($verbose = FALSE)
// example enable relations but not pdf... // example enable relations but not pdf...
// 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_mysql_select_db($cfgRelation['db']); // PMA_DBI_select_db($cfgRelation['db']);
$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); $tab_rs = PMA_query_as_cu($tab_query, FALSE);
while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) { while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) {
if ($curr_table[0] == $cfg['Server']['bookmarktable']) { if ($curr_table[0] == $cfg['Server']['bookmarktable']) {
$cfgRelation['bookmark'] = $curr_table[0]; $cfgRelation['bookmark'] = $curr_table[0];
} else if ($curr_table[0] == $cfg['Server']['relation']) { } else if ($curr_table[0] == $cfg['Server']['relation']) {
@@ -150,7 +142,7 @@ function PMA_getRelationsParam($verbose = FALSE)
$mime_field_mimetype = FALSE; $mime_field_mimetype = FALSE;
$mime_field_transformation = FALSE; $mime_field_transformation = FALSE;
$mime_field_transformation_options = FALSE; $mime_field_transformation_options = FALSE;
while ($curr_mime_field = @PMA_mysql_fetch_array($mime_rs)) { while ($curr_mime_field = @PMA_DBI_fetch_assoc($mime_rs)) {
if ($curr_mime_field[0] == 'mimetype') { if ($curr_mime_field[0] == 'mimetype') {
$mime_field_mimetype = TRUE; $mime_field_mimetype = TRUE;
} else if ($curr_mime_field[0] == 'transformation') { } else if ($curr_mime_field[0] == 'transformation') {
@@ -291,7 +283,7 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') {
} }
$relations = PMA_query_as_cu($rel_query); $relations = PMA_query_as_cu($rel_query);
$i = 0; $i = 0;
while ($relrow = @PMA_mysql_fetch_array($relations)) { while ($relrow = @PMA_DBI_fetch_assoc($relations)) {
$field = $relrow['master_field']; $field = $relrow['master_field'];
$foreign[$field]['foreign_db'] = $relrow['foreign_db']; $foreign[$field]['foreign_db'] = $relrow['foreign_db'];
$foreign[$field]['foreign_table'] = $relrow['foreign_table']; $foreign[$field]['foreign_table'] = $relrow['foreign_table'];
@@ -303,8 +295,8 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') {
if (($source == 'both' || $source == 'innodb') && !empty($table)) { if (($source == 'both' || $source == 'innodb') && !empty($table)) {
$show_create_table_query = 'SHOW CREATE TABLE ' $show_create_table_query = 'SHOW CREATE TABLE '
. PMA_backquote($db) . '.' . PMA_backquote($table); . PMA_backquote($db) . '.' . PMA_backquote($table);
$show_create_table_res = PMA_mysql_query($show_create_table_query); $show_create_table_res = PMA_DBI_query($show_create_table_query);
list(,$show_create_table) = PMA_mysql_fetch_row($show_create_table_res); list(,$show_create_table) = PMA_DBI_fetch_row($show_create_table_res);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
@@ -367,7 +359,7 @@ function PMA_getDisplayField($db, $table) {
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$disp_res = PMA_query_as_cu($disp_query); $disp_res = PMA_query_as_cu($disp_query);
$row = ($disp_res ? PMA_mysql_fetch_array($disp_res) : ''); $row = ($disp_res ? PMA_DBI_fetch_assoc($disp_res) : '');
if (isset($row['display_field'])) { if (isset($row['display_field'])) {
return $row['display_field']; return $row['display_field'];
} else { } else {
@@ -407,7 +399,7 @@ function PMA_getComments($db, $table = '') {
} }
$i = 0; $i = 0;
while ($row = @PMA_mysql_fetch_array($com_rs)) { while ($row = PMA_DBI_fetch_assoc($com_rs)) {
$i++; $i++;
$col = ($table != '' ? $row['column_name'] : $i); $col = ($table != '' ? $row['column_name'] : $i);
@@ -471,7 +463,7 @@ function PMA_setComment($db, $table, $key, $value, $removekey = '') {
$test_rs = PMA_query_as_cu($test_qry); $test_rs = PMA_query_as_cu($test_qry);
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
$row = @PMA_mysql_fetch_array($test_rs); $row = PMA_DBI_fetch_assoc($test_rs);
if (strlen($value) > 0 || strlen($row['mimetype']) > 0 || strlen($row['transformation']) > 0 || strlen($row['transformation_options']) > 0) { if (strlen($value) > 0 || strlen($row['mimetype']) > 0 || strlen($row['transformation']) > 0 || strlen($row['transformation_options']) > 0) {
$upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info']) $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info'])
@@ -554,7 +546,7 @@ function PMA_getHistory($username) {
$history = array(); $history = array();
while ($row = @PMA_mysql_fetch_array($hist_rs)) { while ($row = @PMA_DBI_fetch_assoc($hist_rs)) {
$history[] = $row; $history[] = $row;
} }
@@ -579,7 +571,7 @@ function PMA_purgeHistory($username) {
$purge_rs = PMA_query_as_cu('SELECT timevalue FROM ' . PMA_backquote($cfgRelation['history']) . ' WHERE username = \'' . PMA_sqlAddSlashes($username) . '\' ORDER BY timevalue DESC LIMIT ' . $cfg['QueryHistoryMax'] . ', 1'); $purge_rs = PMA_query_as_cu('SELECT timevalue FROM ' . PMA_backquote($cfgRelation['history']) . ' WHERE username = \'' . PMA_sqlAddSlashes($username) . '\' ORDER BY timevalue DESC LIMIT ' . $cfg['QueryHistoryMax'] . ', 1');
$i = 0; $i = 0;
$row = @PMA_mysql_fetch_array($purge_rs); $row = PMA_DBI_fetch_row($purge_rs);
if (is_array($row) && isset($row[0]) && $row[0] > 0) { if (is_array($row) && isset($row[0]) && $row[0] > 0) {
$maxtime = $row[0]; $maxtime = $row[0];
@@ -609,7 +601,7 @@ function PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, $ma
$ret = '<option value=""></option>' . "\n"; $ret = '<option value=""></option>' . "\n";
$reloptions = array('content-id' => array(), 'id-content' => array()); $reloptions = array('content-id' => array(), 'id-content' => array());
while ($relrow = @PMA_mysql_fetch_array($disp)) { while ($relrow = @PMA_DBI_fetch_assoc($disp)) {
$key = $relrow[$foreign_field]; $key = $relrow[$foreign_field];
if (strlen($relrow[$foreign_display]) <= $cfg['LimitChars']) { if (strlen($relrow[$foreign_display]) <= $cfg['LimitChars']) {
$value = (($foreign_display != FALSE) ? htmlspecialchars($relrow[$foreign_display]) : ''); $value = (($foreign_display != FALSE) ? htmlspecialchars($relrow[$foreign_display]) : '');

View File

@@ -96,7 +96,7 @@ function PMA_getMIME($db, $table, $strict = false) {
. ' AND (mimetype != \'\'' . (!$strict ? ' OR transformation != \'\' OR transformation_options != \'\'' : '') . ')'; . ' AND (mimetype != \'\'' . (!$strict ? ' OR transformation != \'\' OR transformation_options != \'\'' : '') . ')';
$com_rs = PMA_query_as_cu($com_qry); $com_rs = PMA_query_as_cu($com_qry);
while ($row = @PMA_mysql_fetch_array($com_rs)) { while ($row = @PMA_DBI_fetch_assoc($com_rs)) {
$col = $row['column_name']; $col = $row['column_name'];
$mime[$col]['mimetype'] = $row['mimetype']; $mime[$col]['mimetype'] = $row['mimetype'];
$mime[$col]['transformation'] = $row['transformation']; $mime[$col]['transformation'] = $row['transformation'];
@@ -137,7 +137,7 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation, $transformat
$test_rs = PMA_query_as_cu($test_qry); $test_rs = PMA_query_as_cu($test_qry);
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
$row = @PMA_mysql_fetch_array($test_rs); $row = @PMA_DBI_fetch_assoc($test_rs);
if (!$forcedelete && (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0 || strlen($row['comment']) > 0)) { if (!$forcedelete && (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0 || strlen($row['comment']) > 0)) {
$upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info']) $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info'])

View File

@@ -71,10 +71,9 @@ if ($server > 0) {
// if (!empty($cfg['Server']['socket']) && PMA_PHP_INT_VERSION >= 30010) { // if (!empty($cfg['Server']['socket']) && PMA_PHP_INT_VERSION >= 30010) {
// $server_info .= ':' . $cfg['Server']['socket']; // $server_info .= ':' . $cfg['Server']['socket'];
// } // }
$res = PMA_DBI_query('SELECT USER();'); $res = PMA_DBI_query('SELECT USER();');
$row = PMA_DBI_fetch_row($res); list($mysql_cur_user_and_host) = PMA_DBI_fetch_row($res);
$mysql_cur_user_and_host = $row[0]; $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, '@'));
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
unset($res, $row); unset($res, $row);
@@ -202,8 +201,7 @@ if ($server > 0) {
// the first inexistant db name that we find, in most cases it's probably // the first inexistant db name that we find, in most cases it's probably
// the one he just dropped :) // the one he just dropped :)
if (!$is_create_priv) { if (!$is_create_priv) {
$local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Create_priv = \'Y\' AND User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\''; $rs_usr = PMA_DBI_try_query('SELECT DISTINCT Db FROM mysql.db WHERE Create_priv = \'Y\' AND User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\';', $dbh);
$rs_usr = PMA_DBI_try_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
if ($rs_usr) { if ($rs_usr) {
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards $re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards $re1 = '(^|[^\])(\\\)+'; // escaped wildcards
@@ -223,13 +221,11 @@ if ($server > 0) {
// 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 :)
$local_query = 'SHOW GRANTS FOR ' . $mysql_cur_user_and_host; $rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user_and_host . ';', $dbh);
$rs_usr = PMA_DBI_try_query($local_query, $dbh);
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.
$local_query = 'SHOW GRANTS FOR ' . $mysql_cur_user; $rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user . ';', $dbh);
$rs_usr = PMA_DBI_try_query($local_query, $dbh);
} }
unset($local_query); unset($local_query);
if ($rs_usr) { if ($rs_usr) {

View File

@@ -253,16 +253,16 @@ else if ($mult_btn == $strYes) {
$sql_query .= $a_query . ';' . "\n"; $sql_query .= $a_query . ';' . "\n";
if ($query_type != 'drop_db') { if ($query_type != 'drop_db') {
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
} }
$result = @PMA_mysql_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url); $result = @PMA_DBI_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url);
} // end if } // end if
} // end for } // end for
if ($query_type == 'drop_tbl' if ($query_type == 'drop_tbl'
|| $query_type == 'drop_fld') { || $query_type == 'drop_fld') {
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$result = @PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url); $result = PMA_DBI_query($sql_query);
} elseif ($query_type == 'repair_tbl' } elseif ($query_type == 'repair_tbl'
|| $query_type == 'analyze_tbl' || $query_type == 'analyze_tbl'
|| $query_type == 'check_tbl' || $query_type == 'check_tbl'

View File

@@ -95,7 +95,7 @@ if ($cfgRelation['pdfwork']) {
// first put all the master tables at beginning // first put all the master tables at beginning
// of the list, so they are near the center of // of the list, so they are near the center of
// the schema // the schema
while (list(,$master_table) = mysql_fetch_row($master_tables_rs)) { while (list(,$master_table) = PMA_DBI_fetch_row($master_tables_rs)) {
$all_tables[] = $master_table; $all_tables[] = $master_table;
} }
@@ -221,9 +221,8 @@ if ($cfgRelation['pdfwork']) {
// We will need an array of all tables in this db // We will need an array of all tables in this db
$selectboxall = array('--'); $selectboxall = array('--');
$alltab_qry = 'SHOW TABLES FROM ' . PMA_backquote($db); $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
$alltab_rs = @PMA_mysql_query($alltab_qry) or PMA_mysqlDie('', $alltab_qry, '', $err_url_0); while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
while ($val = @PMA_mysql_fetch_array($alltab_rs)) {
$selectboxall[] = $val[0]; $selectboxall[] = $val[0];
} }
@@ -240,7 +239,7 @@ if ($cfgRelation['pdfwork']) {
<input type="hidden" name="do" value="choosepage" /> <input type="hidden" name="do" value="choosepage" />
<select name="chpage" onchange="this.form.submit()"> <select name="chpage" onchange="this.form.submit()">
<?php <?php
while ($curr_page = @PMA_mysql_fetch_array($page_rs)) { while ($curr_page = PMA_DBI_fetch_assoc($page_rs)) {
echo "\n" . ' ' echo "\n" . ' '
. '<option value="' . $curr_page['page_nr'] . '"'; . '<option value="' . $curr_page['page_nr'] . '"';
if (isset($chpage) && $chpage == $curr_page['page_nr']) { if (isset($chpage) && $chpage == $curr_page['page_nr']) {
@@ -292,7 +291,7 @@ $array_sh_page = array();
$draginit = ''; $draginit = '';
$reset_draginit = ''; $reset_draginit = '';
$i = 0; $i = 0;
while ($temp_sh_page = @PMA_mysql_fetch_array($page_rs)) { while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) {
$array_sh_page[] = $temp_sh_page; $array_sh_page[] = $temp_sh_page;
} }
@@ -322,15 +321,17 @@ foreach($array_sh_page AS $key => $temp_sh_page) {
$local_query = 'SHOW FIELDS FROM ' $local_query = 'SHOW FIELDS FROM '
. PMA_backquote($temp_sh_page['table_name'] ) . PMA_backquote($temp_sh_page['table_name'] )
. ' FROM ' . PMA_backquote($db); . ' FROM ' . PMA_backquote($db);
$fields_rs = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); $fields_rs = PMA_DBI_query($local_query);
unset($local_query);
$fields_cnt = PMA_DBI_num_rows($fields_rs); $fields_cnt = PMA_DBI_num_rows($fields_rs);
echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>'; echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>';
while ($row = PMA_mysql_fetch_array($fields_rs)) { while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
echo "<br>".htmlspecialchars($row['Field'])."\n"; echo '<br />' . htmlspecialchars($row['Field']) . "\n";s
} }
echo '</div>' . "\n"; echo '</div>' . "\n";
PMA_DBI_free_result($fields_rs); PMA_DBI_free_result($fields_rs);
unset($fields_rs);
$i++; $i++;
} }

View File

@@ -282,7 +282,7 @@ class PMA_PDF extends FPDF
echo "\n"; echo "\n";
require_once('./footer.inc.php'); require_once('./footer.inc.php');
} // end of the "PMA_PDF_die()" function } // end of the "PMA_PDF_die()" function
/** /**
@@ -312,7 +312,7 @@ class PMA_PDF extends FPDF
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND page_nr = \'' . $pdf_page_number . '\''; . ' AND page_nr = \'' . $pdf_page_number . '\'';
$test_rs = PMA_query_as_cu($test_query); $test_rs = PMA_query_as_cu($test_query);
$pages = @PMA_mysql_fetch_array($test_rs); $pages = @PMA_DBI_fetch_assoc($test_rs);
$this->SetFont('', 'B', 14); $this->SetFont('', 'B', 14);
$this->Cell(0,6, ucfirst($pages['page_descr']),'B',1,'C'); $this->Cell(0,6, ucfirst($pages['page_descr']),'B',1,'C');
$this->SetFont('', ''); $this->SetFont('', '');
@@ -683,12 +683,12 @@ class PMA_RT_Table
$this->table_name = $table_name; $this->table_name = $table_name;
$sql = 'DESCRIBE ' . PMA_backquote($table_name); $sql = 'DESCRIBE ' . PMA_backquote($table_name);
$result = PMA_mysql_query($sql); $result = PMA_DBI_try_query($sql);
if (!$result || !PMA_DBI_num_rows($result)) { if (!$result || !PMA_DBI_num_rows($result)) {
$pdf->PMA_PDF_die(sprintf($GLOBALS['strPdfInvalidTblName'], $table_name)); $pdf->PMA_PDF_die(sprintf($GLOBALS['strPdfInvalidTblName'], $table_name));
} }
// load fields // load fields
while ($row = PMA_mysql_fetch_array($result)) { while ($row = PMA_DBI_fetch_row($result)) {
$this->fields[] = $row[0]; $this->fields[] = $row[0];
} }
@@ -710,17 +710,16 @@ class PMA_RT_Table
if (!$result || !PMA_DBI_num_rows($result)) { if (!$result || !PMA_DBI_num_rows($result)) {
$pdf->PMA_PDF_die(sprintf($GLOBALS['strConfigureTableCoord'], $table_name)); $pdf->PMA_PDF_die(sprintf($GLOBALS['strConfigureTableCoord'], $table_name));
} }
list($this->x, $this->y) = PMA_mysql_fetch_array($result); list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x; $this->x = (double) $this->x;
$this->y = (double) $this->y; $this->y = (double) $this->y;
// displayfield // displayfield
$this->displayfield = PMA_getDisplayField($db, $table_name); $this->displayfield = PMA_getDisplayField($db, $table_name);
// index // index
$sql = 'SHOW index FROM ' . PMA_backquote($table_name); $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table_name) . ';');
$result = PMA_mysql_query($sql); if (PMA_DBI_num_rows($result) > 0) {
if ($result && PMA_DBI_num_rows($result) > 0) { while ($row = PMA_DBI_fetch_assoc($result)) {
while ($row = PMA_mysql_fetch_array($result)) {
if ($row['Key_name'] == 'PRIMARY') { if ($row['Key_name'] == 'PRIMARY') {
$this->primary[] = $row['Column_name']; $this->primary[] = $row['Column_name'];
} }
@@ -1043,7 +1042,7 @@ class PMA_RT
. ' WHERE page_nr = ' . $pdf_page_number; . ' WHERE page_nr = ' . $pdf_page_number;
$_name_rs = PMA_query_as_cu($_name_sql); $_name_rs = PMA_query_as_cu($_name_sql);
if ($_name_rs) { if ($_name_rs) {
$_name_row = PMA_mysql_fetch_row($_name_rs); $_name_row = PMA_DBI_fetch_row($_name_rs);
$filename = $_name_row[0] . '.pdf'; $filename = $_name_row[0] . '.pdf';
} }
// i don't know if there is a chance for this to happen, but rather be on the safe side: // i don't know if there is a chance for this to happen, but rather be on the safe side:
@@ -1112,7 +1111,7 @@ class PMA_RT
$pdf->PMA_PDF_die($GLOBALS['strPdfNoTables']); $pdf->PMA_PDF_die($GLOBALS['strPdfNoTables']);
// die('No tables'); // die('No tables');
} }
while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) { while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) {
$alltables[] = PMA_sqlAddslashes($curr_table['table_name']); $alltables[] = PMA_sqlAddslashes($curr_table['table_name']);
//$intable = '\'' . implode('\', \'', $alltables) . '\''; //$intable = '\'' . implode('\', \'', $alltables) . '\'';
} }
@@ -1200,7 +1199,7 @@ class PMA_RT
// $norelations = TRUE; // $norelations = TRUE;
// if ($result && PMA_DBI_num_rows($result) > 0) { // if ($result && PMA_DBI_num_rows($result) > 0) {
// $norelations = FALSE; // $norelations = FALSE;
// while ($row = PMA_mysql_fetch_array($result)) { // while ($row = PMA_DBI_fetch_assoc($result)) {
// $this->PMA_RT_addRelation($row['master_table'] , $row['master_field'], $row['foreign_table'], $row['foreign_field']); // $this->PMA_RT_addRelation($row['master_table'] , $row['master_field'], $row['foreign_table'], $row['foreign_field']);
// } // }
// } // }
@@ -1233,9 +1232,8 @@ function PMA_RT_DOC($alltables ){
$pdf->Cell(0,6,$i.' '. $table,0,1,'L',0,$pdf->PMA_links['doc'][$table]['-']); $pdf->Cell(0,6,$i.' '. $table,0,1,'L',0,$pdf->PMA_links['doc'][$table]['-']);
//$pdf->Ln(1); //$pdf->Ln(1);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table); $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); while ($row = PMA_DBI_fetch_assoc($result)) {
while ($row = PMA_mysql_fetch_array($result)) {
$pdf->SetX(20); $pdf->SetX(20);
$field_name = $row['Field']; $field_name = $row['Field'];
$pdf->PMA_links['doc'][$table][$field_name] =$pdf->AddLink(); $pdf->PMA_links['doc'][$table][$field_name] =$pdf->AddLink();
@@ -1270,28 +1268,26 @@ function PMA_RT_DOC($alltables ){
$mime_map = PMA_getMIME($db, $table, true); $mime_map = PMA_getMIME($db, $table, true);
} }
/** /**
* Gets table informations * Gets table informations
*/ */
$local_query = "SHOW TABLE STATUS LIKE '" . PMA_sqlAddslashes($table, TRUE) . "'"; $result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); $showtable = PMA_DBI_fetch_assoc($result);
$showtable = PMA_mysql_fetch_array($result);
$num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); $num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
$show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
$create_time = (isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : ''); $create_time = (isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : '');
$update_time = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : ''); $update_time = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : '');
$check_time = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : ''); $check_time = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : '');
if ($result) { PMA_DBI_free_result($result);
PMA_DBI_free_result($result); unset($result);
}
/** /**
* Gets table keys and retains them * Gets table keys and retains them
*/ */
$local_query = 'SHOW KEYS FROM ' . PMA_backquote($table); $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
$primary = ''; $primary = '';
$indexes = array(); $indexes = array();
$lastIndex = ''; $lastIndex = '';
@@ -1299,7 +1295,7 @@ function PMA_RT_DOC($alltables ){
$indexes_data = array(); $indexes_data = array();
$pk_array = array(); // will be use to emphasis prim. keys in the table $pk_array = array(); // will be use to emphasis prim. keys in the table
// view // view
while ($row = PMA_mysql_fetch_array($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
// Backups the list of primary keys // Backups the list of primary keys
if ($row['Key_name'] == 'PRIMARY') { if ($row['Key_name'] == 'PRIMARY') {
$primary .= $row['Column_name'] . ', '; $primary .= $row['Column_name'] . ', ';
@@ -1333,8 +1329,7 @@ function PMA_RT_DOC($alltables ){
/** /**
* Gets fields properties * Gets fields properties
*/ */
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table); $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
@@ -1412,7 +1407,7 @@ function PMA_RT_DOC($alltables ){
} }
$pdf->SetFont('', ''); $pdf->SetFont('', '');
while ($row = PMA_mysql_fetch_array($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
$bgcolor = ($i % 2) ?$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']; $bgcolor = ($i % 2) ?$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
$i++; $i++;
@@ -1518,7 +1513,7 @@ $all_tab_same_wide = (isset($all_tab_same_wide) && $all_tab_same_wide == 'on'
$with_doc = (isset($with_doc) && $with_doc == 'on') ? 1 : 0; $with_doc = (isset($with_doc) && $with_doc == 'on') ? 1 : 0;
$orientation = (isset($orientation) && $orientation == 'P') ? 'P' : 'L'; $orientation = (isset($orientation) && $orientation == 'P') ? 'P' : 'L';
$paper = isset($paper) ? $paper : 'A4'; $paper = isset($paper) ? $paper : 'A4';
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$rt = new PMA_RT($pdf_page_number, $show_table_dimension, $show_color, $show_grid, $all_tab_same_wide, $orientation, $paper); $rt = new PMA_RT($pdf_page_number, $show_table_dimension, $show_color, $show_grid, $all_tab_same_wide, $orientation, $paper);
?> ?>

View File

@@ -283,10 +283,10 @@ if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && $cfg['QueryFrameDebug']) {
* Close MySql connections * Close MySql connections
*/ */
if (isset($dbh) && $dbh) { if (isset($dbh) && $dbh) {
@mysql_close($dbh); DBI_close($dbh);
} }
if (isset($userlink) && $userlink) { if (isset($userlink) && $userlink) {
@mysql_close($userlink); DBI_close($userlink);
} }

View File

@@ -148,8 +148,7 @@ if (!$cfg['AllowUserDropDatabase']
// Checks if the user is a Superuser // Checks if the user is a Superuser
// TODO: set a global variable with this information // TODO: set a global variable with this information
// loic1: optimized query // loic1: optimized query
$result = @PMA_mysql_query('USE mysql'); if (!($result = PMA_DBI_select_db('mysql'))) {
if (PMA_mysql_error()) {
require_once('./header.inc.php'); require_once('./header.inc.php');
PMA_mysqlDie($strNoDropDatabases, '', '', $err_url); PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
} }
@@ -243,7 +242,7 @@ if ($sql_query != '') {
} }
// Runs multiple queries // Runs multiple queries
else if (PMA_mysql_select_db($db)) { else if (PMA_DBI_select_db($db)) {
$mult = TRUE; $mult = TRUE;
$info_msg = ''; $info_msg = '';
$info_count = 0; $info_count = 0;
@@ -257,7 +256,7 @@ if ($sql_query != '') {
require('./sql.php'); require('./sql.php');
} }
$result = PMA_mysql_query($a_sql_query); $result = PMA_DBI_try_query($a_sql_query);
if ($result == FALSE) { // readdump failed if ($result == FALSE) { // readdump failed
if (isset($my_die) && $cfg['IgnoreMultiSubmitErrors']) { if (isset($my_die) && $cfg['IgnoreMultiSubmitErrors']) {
$my_die[] = "\n\n" . $a_sql_query; $my_die[] = "\n\n" . $a_sql_query;
@@ -346,8 +345,8 @@ if ($goto == 'tbl_properties.php') {
if (!isset($table)) { if (!isset($table)) {
$goto = 'db_details.php'; $goto = 'db_details.php';
} else { } else {
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''); $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
if (!($is_table && @PMA_DBI_num_rows($is_table))) { if (!($is_table && @PMA_DBI_num_rows($is_table))) {
$goto = 'db_details.php'; $goto = 'db_details.php';
unset($table); unset($table);
@@ -361,7 +360,7 @@ if ($goto == 'db_details.php') {
if (!isset($db)) { if (!isset($db)) {
$goto = 'main.php'; $goto = 'main.php';
} else { } else {
$is_db = @PMA_mysql_select_db($db); $is_db = @PMA_DBI_select_db($db);
if (!$is_db) { if (!$is_db) {
$goto = 'main.php'; $goto = 'main.php';
unset($db); unset($db);

View File

@@ -35,10 +35,15 @@ require_once('./header.inc.php');
// priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql' // priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
// (even if they cannot see the tables) // (even if they cannot see the tables)
$is_superuser = @PMA_mysql_query('SELECT COUNT(*) FROM mysql.user', $userlink); $is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user');
// now, select the mysql db // now, select the mysql db
if ($is_superuser) { if ($is_superuser) {
@PMA_mysql_query('USE mysql', $userlink); PMA_DBI_free_result($is_superuser);
PMA_DBI_select_db('mysql', $userlink);
$is_superuser = TRUE;
} else {
$is_superuser = FALSE;
} }
?> ?>

View File

@@ -73,10 +73,8 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE)
array('Repl_client_priv', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient']) array('Repl_client_priv', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient'])
); );
if (!empty($row) && isset($row['Table_priv'])) { if (!empty($row) && isset($row['Table_priv'])) {
$sql_query = 'SHOW COLUMNS FROM `tables_priv` LIKE "Table_priv";'; $res = PMA_DBI_query('SHOW COLUMNS FROM `tables_priv` LIKE "Table_priv";', $userlink);
$res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); $row1 = PMA_DBI_fetch_assoc($res);
unset($sql_query);
$row1 = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
$av_grants = explode ('\',\'' , substr($row1['Type'], 5, strlen($row1['Type']) - 7)); $av_grants = explode ('\',\'' , substr($row1['Type'], 5, strlen($row1['Type']) - 7));
unset($row1); unset($row1);
@@ -160,11 +158,9 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent =
} else { } else {
$sql_query = 'SELECT `Table_priv` FROM `tables_priv` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '" AND `Table_name` = "' . $table . '";'; $sql_query = 'SELECT `Table_priv` FROM `tables_priv` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '" AND `Table_name` = "' . $table . '";';
} }
$res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); $res = PMA_DBI_query($sql_query);
if ($res) { $row = PMA_DBI_fetch_assoc($res);
$row = PMA_mysql_fetch_array($res, MYSQL_ASSOC); PMA_DBI_free_result($res);
}
@PMA_DBI_free_result($res);
} }
if (empty($row)) { if (empty($row)) {
if ($table == '*') { if ($table == '*') {
@@ -173,9 +169,8 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent =
} else if ($table == '*') { } else if ($table == '*') {
$sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;'; $sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;';
} }
$res = PMA_mysql_query($sql_query, $userlink) $res = PMA_DBI_query($sql_query);
or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); while ($row1 = PMA_DBI_fetch_row($res)) {
while ($row1 = PMA_mysql_fetch_row($res)) {
if (substr($row1[0], 0, 4) == 'max_') { if (substr($row1[0], 0, 4) == 'max_') {
$row[$row1[0]] = 0; $row[$row1[0]] = 0;
} else { } else {
@@ -188,40 +183,32 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent =
} }
} }
if (isset($row['Table_priv'])) { if (isset($row['Table_priv'])) {
$sql_query = 'SHOW COLUMNS FROM `tables_priv` LIKE "Table_priv";'; $res = PMA_DBI_query('SHOW COLUMNS FROM `tables_priv` LIKE "Table_priv";', $userlink);
$res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); $row1 = PMA_DBI_fetch_assoc($res);
unset($sql_query);
$row1 = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
$av_grants = explode ('\',\'' , substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3)); $av_grants = explode ('\',\'' , substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3));
unset($row1); unset($res, $row1);
$users_grants = explode(',', $row['Table_priv']); $users_grants = explode(',', $row['Table_priv']);
foreach ($av_grants as $current_grant) { foreach ($av_grants as $current_grant) {
$row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N'; $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';
} }
unset($row['Table_priv']); unset($row['Table_priv'], $current_grant, $av_grants, $users_grants);
unset($current_grant); $res = PMA_DBI_query('SHOW COLUMNS FROM `' . $db . '`.`' . $table . '`;');
unset($av_grants); $columns = array();
unset($users_grants); while ($row1 = PMA_DBI_fetch_row($res)) {
if ($res = PMA_mysql_query('SHOW COLUMNS FROM `' . $db . '`.`' . $table . '`;', $userlink)) { $columns[$row1[0]] = array(
$columns = array(); 'Select' => FALSE,
while ($row1 = PMA_mysql_fetch_row($res)) { 'Insert' => FALSE,
$columns[$row1[0]] = array( 'Update' => FALSE,
'Select' => FALSE, 'References' => FALSE
'Insert' => FALSE, );
'Update' => FALSE,
'References' => FALSE
);
}
PMA_DBI_free_result($res);
unset($res);
unset($row1);
} }
PMA_DBI_free_result($res);
unset($res, $row1);
} }
if (!empty($columns)) { if (!empty($columns)) {
$sql_query = 'SELECT `Column_name`, `Column_priv` FROM `columns_priv` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '" AND `Table_name` = "' . $table . '";'; $res = PMA_DBI_query('SELECT `Column_name`, `Column_priv` FROM `columns_priv` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '" AND `Table_name` = "' . $table . '";');
$res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); while ($row1 = PMA_DBI_fetch_row($res)) {
while ($row1 = PMA_mysql_fetch_row($res)) {
$row1[1] = explode(',', $row1[1]); $row1[1] = explode(',', $row1[1]);
foreach ($row1[1] as $current) { foreach ($row1[1] as $current) {
$columns[$row1[0]][$current] = TRUE; $columns[$row1[0]][$current] = TRUE;
@@ -487,9 +474,9 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0)
. $spaces . ' </td>' . "\n" . $spaces . ' </td>' . "\n"
. $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
. $spaces . ' <select name="pred_hostname" id="select_pred_hostname" title="' . $GLOBALS['strHost'] . '"' . "\n"; . $spaces . ' <select name="pred_hostname" id="select_pred_hostname" title="' . $GLOBALS['strHost'] . '"' . "\n";
$res = PMA_mysql_query('SELECT USER();', $userlink); $res = PMA_DBI_query('SELECT USER();');
$row = @PMA_mysql_fetch_row($res); $row = PMA_DBI_fetch_row($res);
@PMA_DBI_free_result($res); PMA_DBI_free_result($res);
unset($res); unset($res);
if (!empty($row[0])) { if (!empty($row[0])) {
$thishost = str_replace("'", '', substr($row[0], (strrpos($row[0], '@') + 1))); $thishost = str_replace("'", '', substr($row[0], (strrpos($row[0], '@') + 1)));
@@ -544,20 +531,19 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0)
. $spaces . ' <input type="password" name="pma_pw2" id="text_pma_pw2" class="textfield" title="' . $GLOBALS['strReType'] . '" onchange="pred_password.value = \'userdefined\';" />' . "\n" . $spaces . ' <input type="password" name="pma_pw2" id="text_pma_pw2" class="textfield" title="' . $GLOBALS['strReType'] . '" onchange="pred_password.value = \'userdefined\';" />' . "\n"
. $spaces . ' </td>' . "\n" . $spaces . ' </td>' . "\n"
. $spaces . '</tr>' . "\n"; . $spaces . '</tr>' . "\n";
} // end of the 'PMA_displayUserAndHostFields()' function } // end of the 'PMA_displayUserAndHostFields()' function
/** /**
* Changes / copies a user, part I * Changes / copies a user, part I
*/ */
if (!empty($change_copy)) { if (!empty($change_copy)) {
$local_query = 'SELECT * FROM `mysql`.`user` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";'; $res = PMA_DBI_query('SELECT * FROM `mysql`.`user` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";');
$res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
if (!$res) { if (!$res) {
$message = $strNoUsersFound; $message = $strNoUsersFound;
unset($change_copy); unset($change_copy);
} else { } else {
$row = PMA_mysql_fetch_array($res, MYSQL_ASSOC); $row = PMA_DBI_fetch_assoc($res);
extract($row, EXTR_OVERWRITE); extract($row, EXTR_OVERWRITE);
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
$queries = array(); $queries = array();
@@ -585,17 +571,15 @@ if (!empty($adduser_submit) || !empty($change_copy)) {
$hostname = ''; $hostname = '';
break; break;
case 'thishost': case 'thishost':
$res = PMA_mysql_query('SELECT USER();', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SELECT USER();'); $res = PMA_DBI_query('SELECT USER();');
$row = PMA_mysql_fetch_row($res); $row = PMA_DBI_fetch_row($res);
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
unset($res); unset($res);
$hostname = substr($row[0], (strrpos($row[0], '@') + 1)); $hostname = substr($row[0], (strrpos($row[0], '@') + 1));
unset($row); unset($row);
break; break;
} }
$local_query = 'SELECT "foo" FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";'; $res = PMA_DBI_query('SELECT "foo" FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";');
$res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
unset($local_query);
if (PMA_DBI_affected_rows($userlink) == 1) { if (PMA_DBI_affected_rows($userlink) == 1) {
$message = sprintf($strUserAlreadyExists, '<i>\'' . $username . '\'@\'' . $hostname . '\'</i>'); $message = sprintf($strUserAlreadyExists, '<i>\'' . $username . '\'@\'' . $hostname . '\'</i>');
$adduser = 1; $adduser = 1;
@@ -639,7 +623,7 @@ if (!empty($adduser_submit) || !empty($change_copy)) {
$real_sql_query .= ';'; $real_sql_query .= ';';
$sql_query .= ';'; $sql_query .= ';';
if (empty($change_copy)) { if (empty($change_copy)) {
PMA_mysql_query($real_sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); PMA_DBI_try_query($real_sql_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query);
$message = $strAddUserMessage; $message = $strAddUserMessage;
} else { } else {
$queries[] = $sql_query; $queries[] = $sql_query;
@@ -655,17 +639,14 @@ if (!empty($adduser_submit) || !empty($change_copy)) {
* Changes / copies a user, part III * Changes / copies a user, part III
*/ */
if (!empty($change_copy)) { if (!empty($change_copy)) {
$local_query = 'SELECT * FROM `mysql`.`db` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";'; $res = PMA_DBI_query('SELECT * FROM `mysql`.`db` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";');
$res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query); while ($row = PMA_DBI_fetch_assoc($res)) {
while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
$queries[] = 'GRANT ' . join(', ', PMA_extractPrivInfo($row)) . ' ON `' . $row['Db'] . '`.* TO "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '"' . ($row['Grant_priv'] == 'Y' ? ' WITH GRANT OPTION' : '') . ';'; $queries[] = 'GRANT ' . join(', ', PMA_extractPrivInfo($row)) . ' ON `' . $row['Db'] . '`.* TO "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '"' . ($row['Grant_priv'] == 'Y' ? ' WITH GRANT OPTION' : '') . ';';
} }
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
$local_query = 'SELECT `Db`, `Table_name`, `Table_priv` FROM `mysql`.`tables_priv` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";'; $res = PMA_DBI_query('SELECT `Db`, `Table_name`, `Table_priv` FROM `mysql`.`tables_priv` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";', $userlink);
$res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query); while ($row = PMA_DBI_fetch_assoc($res)) {
while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) { $res2 = PMA_DBI_query('SELECT `Column_name`, `Column_priv` FROM `mysql`.`columns_priv` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '" AND `Db` = "' . $row['Db'] . '";');
$local_query = 'SELECT `Column_name`, `Column_priv` FROM `mysql`.`columns_priv` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '" AND `Db` = "' . $row['Db'] . '";';
$res2 = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
$tmp_privs1 = PMA_extractPrivInfo($row); $tmp_privs1 = PMA_extractPrivInfo($row);
$tmp_privs2 = array( $tmp_privs2 = array(
'Select' => array(), 'Select' => array(),
@@ -673,7 +654,7 @@ if (!empty($change_copy)) {
'Update' => array(), 'Update' => array(),
'References' => array() 'References' => array()
); );
while ($row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC)) { while ($row2 = PMA_DBI_fetch_assoc($res2)) {
$tmp_array = explode(',', $row2['Column_priv']); $tmp_array = explode(',', $row2['Column_priv']);
if (in_array('Select', $tmp_array)) { if (in_array('Select', $tmp_array)) {
$tmp_privs2['Select'][] = $row2['Column_name']; $tmp_privs2['Select'][] = $row2['Column_name'];
@@ -735,12 +716,16 @@ if (!empty($update_privs)) {
} }
} }
$sql_query2 .= ';'; $sql_query2 .= ';';
PMA_mysql_query($sql_query0, $userlink); // this query may fail, but this does not matter :o) if (!PMA_DBI_try_query($sql_query0)) { // this query may fail, but this does not matter :o)
if (isset($sql_query1)) { unset($sql_query0);
PMA_mysql_query($sql_query1, $userlink); // this one may fail, too...
} }
PMA_mysql_query($sql_query2, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query2); if (isset($sql_query1) && !PMA_DBI_try_query($sql_query1)) { // this one may fail, too...
$sql_query = $sql_query0 . ' ' . (isset($sql_query1) ? $sql_query1 . ' ' : '') . $sql_query2; unset($sql_query1);
}
PMA_DBI_query($sql_query2);
$sql_query = (isset($sql_query0) ? $sql_query0 . ' ' : '')
. (isset($sql_query1) ? $sql_query1 . ' ' : '')
. $sql_query2;
$message = sprintf($strUpdatePrivMessage, '\'' . $username . '\'@\'' . $hostname . '\''); $message = sprintf($strUpdatePrivMessage, '\'' . $username . '\'@\'' . $hostname . '\'');
} }
@@ -752,9 +737,11 @@ if (!empty($revokeall)) {
$db_and_table = PMA_backquote($dbname) . '.' . (empty($tablename) ? '*' : PMA_backquote($tablename)); $db_and_table = PMA_backquote($dbname) . '.' . (empty($tablename) ? '*' : PMA_backquote($tablename));
$sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";'; $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";';
$sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";'; $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";';
PMA_mysql_query($sql_query0, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query0); PMA_DBI_query($sql_query0);
PMA_mysql_query($sql_query1, $userlink); // this one may fail, too... if (!PMA_DBI_try_query($sql_query1)) { // this one may fail, too...
$sql_query = $sql_query0 . ' ' . $sql_query1; unset($sql_query1);
}
$sql_query = $sql_query0 . (isset($sql_query1) ? ' ' . $sql_query1 : '');
$message = sprintf($strRevokeMessage, '\'' . $username . '\'@\'' . $hostname . '\''); $message = sprintf($strRevokeMessage, '\'' . $username . '\'@\'' . $hostname . '\'');
if (empty($tablename)) { if (empty($tablename)) {
unset($dbname); unset($dbname);
@@ -769,8 +756,8 @@ if (!empty($revokeall)) {
*/ */
if (!empty($change_pw)) { if (!empty($change_pw)) {
if ($nopass == 1) { if ($nopass == 1) {
$sql_query = 'SET PASSWORD FOR "' . $username . '"@"' . $hostname . '" = ""'; $sql_query = 'SET PASSWORD FOR "' . $username . '"@"' . $hostname . '" = "";';
PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink)); PMA_DBI_query($sql_query);
$message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\''); $message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\'');
} else if (empty($pma_pw) || empty($pma_pw2)) { } else if (empty($pma_pw) || empty($pma_pw2)) {
$message = $strPasswordEmpty; $message = $strPasswordEmpty;
@@ -783,7 +770,7 @@ if (!empty($change_pw)) {
} }
$local_query = 'SET PASSWORD FOR "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '" = PASSWORD("' . PMA_sqlAddslashes($pma_pw) . '")'; $local_query = 'SET PASSWORD FOR "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '" = PASSWORD("' . PMA_sqlAddslashes($pma_pw) . '")';
$sql_query = 'SET PASSWORD FOR "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '" = PASSWORD("' . $hidden_pw . '")'; $sql_query = 'SET PASSWORD FOR "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '" = PASSWORD("' . $hidden_pw . '")';
PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink)); PMA_DBI_try_query($local_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query);
$message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\''); $message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\'');
} }
} }
@@ -805,10 +792,10 @@ if (!empty($delete) || (!empty($change_copy) && $mode < 4)) {
if ($mode == 2) { if ($mode == 2) {
// The SHOW GRANTS query may fail if the user has not been loaded // The SHOW GRANTS query may fail if the user has not been loaded
// into memory // into memory
$res = PMA_mysql_query('SHOW GRANTS FOR "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";', $userlink); $res = PMA_DBI_try_query('SHOW GRANTS FOR "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";');
if ($res) { if ($res) {
$queries[] = 'REVOKE ALL PRIVILEGES ON *.* FROM "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";'; $queries[] = 'REVOKE ALL PRIVILEGES ON *.* FROM "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";';
while ($row = PMA_mysql_fetch_row($res)) { while ($row = PMA_DBI_fetch_row($res)) {
$this_table = substr($row[0], (strpos($row[0], 'ON') + 3), (strpos($row[0], ' TO ') - strpos($row[0], 'ON') - 3)); $this_table = substr($row[0], (strpos($row[0], 'ON') + 3), (strpos($row[0], ' TO ') - strpos($row[0], 'ON') - 3));
if ($this_table != '*.*') { if ($this_table != '*.*') {
$queries[] = 'REVOKE ALL PRIVILEGES ON ' . $this_table . ' FROM "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";'; $queries[] = 'REVOKE ALL PRIVILEGES ON ' . $this_table . ' FROM "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";';
@@ -845,7 +832,7 @@ if (!empty($delete) || (!empty($change_copy) && $mode < 4)) {
} }
foreach ($queries as $sql_query) { foreach ($queries as $sql_query) {
if ($sql_query{0} != '#') { if ($sql_query{0} != '#') {
PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink)); PMA_DBI_query($sql_query, $userlink);
} }
} }
$sql_query = join("\n", $queries); $sql_query = join("\n", $queries);
@@ -862,7 +849,7 @@ if (!empty($delete) || (!empty($change_copy) && $mode < 4)) {
if (!empty($change_copy)) { if (!empty($change_copy)) {
foreach ($queries as $sql_query) { foreach ($queries as $sql_query) {
if ($sql_query{0} != '#') { if ($sql_query{0} != '#') {
PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink)); PMA_DBI_query($sql_query);
} }
} }
$message = $strSuccess; $message = $strSuccess;
@@ -874,12 +861,9 @@ if (!empty($change_copy)) {
* Reloads the privilege tables into memory * Reloads the privilege tables into memory
*/ */
if (!empty($flush_privileges)) { if (!empty($flush_privileges)) {
$sql_query = 'FLUSH PRIVILEGES'; $sql_query = 'FLUSH PRIVILEGES;';
if (@PMA_mysql_query($sql_query, $userlink)) { PMA_DBI_query($sql_query);
$message = $strPrivilegesReloaded; $message = $strPrivilegesReloaded;
} else {
PMA_mysqlDie(PMA_mysql_error($userlink));
}
} }
@@ -900,7 +884,7 @@ if (empty($adduser) && empty($checkprivs)) {
. '</h2>' . "\n"; . '</h2>' . "\n";
$oldPrivTables = FALSE; $oldPrivTables = FALSE;
if (PMA_MYSQL_INT_VERSION >= 40002) { if (PMA_MYSQL_INT_VERSION >= 40002) {
$res = PMA_mysql_query('SELECT `User`, `Host`, IF(`Password` = "", "N", "Y") AS "Password", `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv` FROM `user` ORDER BY `User` ASC, `Host` ASC;', $userlink); $res = PMA_DBI_try_query('SELECT `User`, `Host`, IF(`Password` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . '"", "N", "Y") AS "Password", `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv` FROM `user` ORDER BY `User` ASC, `Host` ASC;');
if (!$res) { if (!$res) {
// the query failed! This may have two reasons: // the query failed! This may have two reasons:
// - the user has not enough privileges // - the user has not enough privileges
@@ -909,7 +893,7 @@ if (empty($adduser) && empty($checkprivs)) {
} }
} }
if (empty($res) || PMA_MYSQL_INT_VERSION < 40002) { if (empty($res) || PMA_MYSQL_INT_VERSION < 40002) {
$res = PMA_mysql_query('SELECT `User`, `Host`, IF(`Password` = "", "N", "Y") AS "Password", `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Index_priv`, `Alter_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv` FROM `user` ORDER BY `User` ASC, `Host` ASC;', $userlink); $res = PMA_DBI_try_query('SELECT `User`, `Host`, IF(`Password` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . '"", "N", "Y") AS "Password", `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Index_priv`, `Alter_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv` FROM `user` ORDER BY `User` ASC, `Host` ASC;');
if (!$res) { if (!$res) {
// the query failed! This may have two reasons: // the query failed! This may have two reasons:
// - the user has not enough privileges // - the user has not enough privileges
@@ -919,7 +903,7 @@ if (empty($adduser) && empty($checkprivs)) {
} }
if (!$res) { if (!$res) {
echo '<i>' . $strNoPrivileges . '</i>' . "\n"; echo '<i>' . $strNoPrivileges . '</i>' . "\n";
@PMA_DBI_free_result($res); PMA_DBI_free_result($res);
unset($res); unset($res);
} else { } else {
if ($oldPrivTables) { if ($oldPrivTables) {
@@ -943,7 +927,7 @@ if (empty($adduser) && empty($checkprivs)) {
. ' <th>&nbsp;' . $strAction . '&nbsp;</th>' . "\n"; . ' <th>&nbsp;' . $strAction . '&nbsp;</th>' . "\n";
echo ' </tr>' . "\n"; echo ' </tr>' . "\n";
$useBgcolorOne = TRUE; $useBgcolorOne = TRUE;
for ($i = 0; $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC); $i++) { for ($i = 0; $row = PMA_DBI_fetch_assoc($res); $i++) {
echo ' <tr>' . "\n" echo ' <tr>' . "\n"
. ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><input type="checkbox" name="selected_usr[]" id="checkbox_sel_users_' . $i . '" value="' . htmlspecialchars($row['User'] . '@' . $row['Host']) . '"' . (empty($checkall) ? '' : ' checked="checked"') . ' /></td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><input type="checkbox" name="selected_usr[]" id="checkbox_sel_users_' . $i . '" value="' . htmlspecialchars($row['User'] . '@' . $row['Host']) . '"' . (empty($checkall) ? '' : ' checked="checked"') . ' /></td>' . "\n"
. ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><label for="checkbox_sel_users_' . $i . '">' . (empty($row['User']) ? '<span style="color: #FF0000">' . $strAny . '</span>' : htmlspecialchars($row['User'])) . '</label></td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><label for="checkbox_sel_users_' . $i . '">' . (empty($row['User']) ? '<span style="color: #FF0000">' . $strAny . '</span>' : htmlspecialchars($row['User'])) . '</label></td>' . "\n"
@@ -1017,8 +1001,8 @@ if (empty($adduser) && empty($checkprivs)) {
} }
} }
echo '</h2>' . "\n"; echo '</h2>' . "\n";
$res = PMA_mysql_query('SELECT "foo" FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";', $userlink); $res = PMA_DBI_query('SELECT "foo" FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";');
if (PMA_DBI_affected_rows($userlink) <= 0) { if (PMA_DBI_affected_rows($userlink) < 1) {
echo $strUserNotFound; echo $strUserNotFound;
require_once('./footer.inc.php'); require_once('./footer.inc.php');
} }
@@ -1056,7 +1040,7 @@ if (empty($adduser) && empty($checkprivs)) {
} else { } else {
$sql_query = 'SELECT `Table_name`, `Table_priv`, IF(`Column_priv` = "", 0, 1) AS "Column_priv" FROM `tables_priv` WHERE `Host` = "' . $hostname . '" AND `User` = "' . PMA_sqlAddslashes($username) . '" AND `Db` = "' . $dbname . '" ORDER BY `Table_name` ASC;'; $sql_query = 'SELECT `Table_name`, `Table_priv`, IF(`Column_priv` = "", 0, 1) AS "Column_priv" FROM `tables_priv` WHERE `Host` = "' . $hostname . '" AND `User` = "' . PMA_sqlAddslashes($username) . '" AND `Db` = "' . $dbname . '" ORDER BY `Table_name` ASC;';
} }
$res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); $res = PMA_DBI_query($sql_query);
if (PMA_DBI_affected_rows($userlink) == 0) { if (PMA_DBI_affected_rows($userlink) == 0) {
echo ' <tr>' . "\n" echo ' <tr>' . "\n"
. ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="6"><center><i>' . $strNone . '</i></center></td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="6"><center><i>' . $strNone . '</i></center></td>' . "\n"
@@ -1064,11 +1048,11 @@ if (empty($adduser) && empty($checkprivs)) {
} else { } else {
$useBgcolorOne = TRUE; $useBgcolorOne = TRUE;
if (empty($dbname)) { if (empty($dbname)) {
$res2 = PMA_mysql_query('SELECT `Db` FROM `tables_priv` WHERE `Host` = "' . $hostname . '" AND `User` = "' . PMA_sqlAddslashes($username) . '" GROUP BY `Db` ORDER BY `Db` ASC;') or PMA_mysqlDie(PMA_mysql_error($userlink), 'SELECT `Db` FROM `tables_priv` WHERE `Host` = "' . $hostname . '" AND `User` = "' . PMA_sqlAddslashes($username) . '" GROUP BY `Db` ORDER BY `Db` ASC;'); $res2 = PMA_DBI_query('SELECT `Db` FROM `tables_priv` WHERE `Host` = "' . $hostname . '" AND `User` = "' . PMA_sqlAddslashes($username) . '" GROUP BY `Db` ORDER BY `Db` ASC;');
$row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC); $row2 = PMA_DBI_fetch_assoc($res2);
} }
$found_rows = array(); $found_rows = array();
while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) { while ($row = PMA_DBI_fetch_assoc($res)) {
while (empty($dbname) && $row2 && $row['Db'] > $row2['Db']) { while (empty($dbname) && $row2 && $row['Db'] > $row2['Db']) {
$found_rows[] = $row2['Db']; $found_rows[] = $row2['Db'];
@@ -1083,7 +1067,7 @@ if (empty($adduser) && empty($checkprivs)) {
. ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '">' . $strEdit . '</a></td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '">' . $strEdit . '</a></td>' . "\n"
. ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '&amp;revokeall=1">' . $strRevoke . '</a></td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '&amp;revokeall=1">' . $strRevoke . '</a></td>' . "\n"
. ' </tr>' . "\n"; . ' </tr>' . "\n";
$row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC); $row2 = PMA_DBI_fetch_assoc($res2);
$useBgcolorOne = !$useBgcolorOne; $useBgcolorOne = !$useBgcolorOne;
} // end while } // end while
$found_rows[] = empty($dbname) ? $row['Db'] : $row['Table_name']; $found_rows[] = empty($dbname) ? $row['Db'] : $row['Table_name'];
@@ -1099,7 +1083,7 @@ if (empty($adduser) && empty($checkprivs)) {
|| (!empty($dbname) && $row['Column_priv'])) { || (!empty($dbname) && $row['Column_priv'])) {
echo $strYes; echo $strYes;
if (empty($dbname)) { if (empty($dbname)) {
$row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC); $row2 = PMA_DBI_fetch_assoc($res2);
} }
} else { } else {
echo $strNo; echo $strNo;
@@ -1125,7 +1109,7 @@ if (empty($adduser) && empty($checkprivs)) {
. ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '">' . $strEdit . '</a></td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '">' . $strEdit . '</a></td>' . "\n"
. ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '&amp;revokeall=1">' . $strRevoke . '</a></td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '&amp;revokeall=1">' . $strRevoke . '</a></td>' . "\n"
. ' </tr>' . "\n"; . ' </tr>' . "\n";
$row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC); $row2 = PMA_DBI_fetch_assoc($res2);
$useBgcolorOne = !$useBgcolorOne; $useBgcolorOne = !$useBgcolorOne;
} // end while } // end while
@@ -1146,9 +1130,9 @@ if (empty($adduser) && empty($checkprivs)) {
. ' <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n"; . ' <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
if (empty($dbname)) { if (empty($dbname)) {
echo ' <label for="text_dbname">' . $strAddPrivilegesOnDb . ':</label>' . "\n"; echo ' <label for="text_dbname">' . $strAddPrivilegesOnDb . ':</label>' . "\n";
$res = PMA_mysql_query('SHOW DATABASES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW DATABASES;'); $res = PMA_DBI_query('SHOW DATABASES;');
$pred_db_array = array(); $pred_db_array = array();
while ($row = PMA_mysql_fetch_row($res)) { while ($row = PMA_DBI_fetch_row($res)) {
if (!isset($found_rows) || !in_array($row[0], $found_rows)) { if (!isset($found_rows) || !in_array($row[0], $found_rows)) {
$pred_db_array[] = $row[0]; $pred_db_array[] = $row[0];
} }
@@ -1168,9 +1152,9 @@ if (empty($adduser) && empty($checkprivs)) {
} else { } else {
echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\n" echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\n"
. ' <label for="text_tablename">' . $strAddPrivilegesOnTbl . ':</label>' . "\n"; . ' <label for="text_tablename">' . $strAddPrivilegesOnTbl . ':</label>' . "\n";
if ($res = @PMA_mysql_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';', $userlink)) { if ($res = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';')) {
$pred_tbl_array = array(); $pred_tbl_array = array();
while ($row = PMA_mysql_fetch_row($res)) { while ($row = PMA_DBI_fetch_row($res)) {
if (!isset($found_rows) || !in_array($row[0], $found_rows)) { if (!isset($found_rows) || !in_array($row[0], $found_rows)) {
$pred_tbl_array[] = $row[0]; $pred_tbl_array[] = $row[0];
} }
@@ -1318,19 +1302,19 @@ if (empty($adduser) && empty($checkprivs)) {
// Starting with MySQL 4.0.0, we may use UNION SELECTs and this makes // Starting with MySQL 4.0.0, we may use UNION SELECTs and this makes
// the job much easier here! // the job much easier here!
$sql_query = '(SELECT `User`, `Host`, `Db`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv` FROM `db` WHERE "' . $checkprivs . '" LIKE `Db` AND NOT (`Select_priv` = "N" AND `Insert_priv` = "N" AND `Update_priv` = "N" AND `Delete_priv` = "N" AND `Create_priv` = "N" AND `Drop_priv` = "N" AND `Grant_priv` = "N" AND `References_priv` = "N")) UNION (SELECT `User`, `Host`, "*" AS "Db", `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv` FROM `user` WHERE NOT (`Select_priv` = "N" AND `Insert_priv` = "N" AND `Update_priv` = "N" AND `Delete_priv` = "N" AND `Create_priv` = "N" AND `Drop_priv` = "N" AND `Grant_priv` = "N" AND `References_priv` = "N")) ORDER BY `User` ASC, `Host` ASC, `Db` ASC;'; $sql_query = '(SELECT `User`, `Host`, `Db`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv` FROM `db` WHERE "' . $checkprivs . '" LIKE `Db` AND NOT (`Select_priv` = "N" AND `Insert_priv` = "N" AND `Update_priv` = "N" AND `Delete_priv` = "N" AND `Create_priv` = "N" AND `Drop_priv` = "N" AND `Grant_priv` = "N" AND `References_priv` = "N")) UNION (SELECT `User`, `Host`, "*" AS "Db", `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv` FROM `user` WHERE NOT (`Select_priv` = "N" AND `Insert_priv` = "N" AND `Update_priv` = "N" AND `Delete_priv` = "N" AND `Create_priv` = "N" AND `Drop_priv` = "N" AND `Grant_priv` = "N" AND `References_priv` = "N")) ORDER BY `User` ASC, `Host` ASC, `Db` ASC;';
$res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); $res = PMA_DBI_query($sql_query);
$row = PMA_mysql_fetch_array($res, MYSQL_ASSOC); $row = PMA_DBI_fetch_assoc($res);
if ($row) { if ($row) {
$found = TRUE; $found = TRUE;
} }
} else { } else {
// With MySQL 3, we need 2 seperate queries here. // With MySQL 3, we need 2 seperate queries here.
$sql_query = 'SELECT * FROM `user` WHERE NOT (`Select_priv` = "N" AND `Insert_priv` = "N" AND `Update_priv` = "N" AND `Delete_priv` = "N" AND `Create_priv` = "N" AND `Drop_priv` = "N" AND `Grant_priv` = "N" AND `References_priv` = "N") ORDER BY `User` ASC, `Host` ASC;'; $sql_query = 'SELECT * FROM `user` WHERE NOT (`Select_priv` = "N" AND `Insert_priv` = "N" AND `Update_priv` = "N" AND `Delete_priv` = "N" AND `Create_priv` = "N" AND `Drop_priv` = "N" AND `Grant_priv` = "N" AND `References_priv` = "N") ORDER BY `User` ASC, `Host` ASC;';
$res1 = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); $res1 = PMA_DBI_query($sql_query);
$row1 = PMA_mysql_fetch_array($res1, MYSQL_ASSOC); $row1 = PMA_DBI_fetch_assoc($res1);
$sql_query = 'SELECT * FROM `db` WHERE "' . $checkprivs . '" LIKE `Db` AND NOT (`Select_priv` = "N" AND `Insert_priv` = "N" AND `Update_priv` = "N" AND `Delete_priv` = "N" AND `Create_priv` = "N" AND `Drop_priv` = "N" AND `Grant_priv` = "N" AND `References_priv` = "N") ORDER BY `User` ASC, `Host` ASC;'; $sql_query = 'SELECT * FROM `db` WHERE "' . $checkprivs . '" LIKE `Db` AND NOT (`Select_priv` = "N" AND `Insert_priv` = "N" AND `Update_priv` = "N" AND `Delete_priv` = "N" AND `Create_priv` = "N" AND `Drop_priv` = "N" AND `Grant_priv` = "N" AND `References_priv` = "N") ORDER BY `User` ASC, `Host` ASC;';
$res2 = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); $res2 = PMA_DBI_query($sql_query);
$row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC); $row2 = PMA_DBI_fetch_assoc($res2);
if ($row1 || $row2) { if ($row1 || $row2) {
$found = TRUE; $found = TRUE;
} }
@@ -1344,7 +1328,7 @@ if (empty($adduser) && empty($checkprivs)) {
$current_host = $row['Host']; $current_host = $row['Host'];
while ($row && $current_user == $row['User'] && $current_host == $row['Host']) { while ($row && $current_user == $row['User'] && $current_host == $row['Host']) {
$current_privileges[] = $row; $current_privileges[] = $row;
$row = PMA_mysql_fetch_array($res, MYSQL_ASSOC); $row = PMA_DBI_fetch_assoc($res);
} }
} else { } else {
$current_privileges = array(); $current_privileges = array();
@@ -1352,7 +1336,7 @@ if (empty($adduser) && empty($checkprivs)) {
$current_user = $row1['User']; $current_user = $row1['User'];
$current_host = $row1['Host']; $current_host = $row1['Host'];
$current_privileges = array($row1); $current_privileges = array($row1);
$row1 = PMA_mysql_fetch_array($res1, MYSQL_ASSOC); $row1 = PMA_DBI_fetch_assoc($res1);
} else { } else {
$current_user = $row2['User']; $current_user = $row2['User'];
$current_host = $row2['Host']; $current_host = $row2['Host'];
@@ -1360,7 +1344,7 @@ if (empty($adduser) && empty($checkprivs)) {
} }
while ($row2 && $current_user == $row2['User'] && $current_host == $row2['Host']) { while ($row2 && $current_user == $row2['User'] && $current_host == $row2['Host']) {
$current_privileges[] = $row2; $current_privileges[] = $row2;
$row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC); $row2 = PMA_DBI_fetch_assoc($res2);
} }
} }
echo ' <tr>' . "\n" echo ' <tr>' . "\n"

View File

@@ -13,8 +13,7 @@ require_once('./server_common.inc.php');
* Kills a selected process * Kills a selected process
*/ */
if (!empty($kill)) { if (!empty($kill)) {
$sql_query = 'KILL ' . $kill . ';'; if (PMA_DBI_try_query('KILL ' . $kill . ';')) {
if (@PMA_mysql_query($sql_query, $userlink)) {
$message = sprintf($strThreadSuccessfullyKilled, $kill); $message = sprintf($strThreadSuccessfullyKilled, $kill);
} else { } else {
$message = sprintf($strCouldNotKill, $kill); $message = sprintf($strCouldNotKill, $kill);
@@ -40,9 +39,8 @@ echo '<h2>' . "\n"
* Sends the query and buffers the result * Sends the query and buffers the result
*/ */
$serverProcesses = array(); $serverProcesses = array();
$sql_query = 'SHOW' . (empty($full) ? '' : ' FULL') . ' PROCESSLIST;'; $res = PMA_DBI_query('SHOW' . (empty($full) ? '' : ' FULL') . ' PROCESSLIST;');
$res = @PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); while ($row = PMA_DBI_fetch_assoc($res)) {
while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
$serverProcesses[] = $row; $serverProcesses[] = $row;
} }
@PMA_DBI_free_result($res); @PMA_DBI_free_result($res);

View File

@@ -22,9 +22,8 @@ if (!empty($innodbstatus)) {
echo '<h2>' . "\n" echo '<h2>' . "\n"
. ' ' . $strInnodbStat . "\n" . ' ' . $strInnodbStat . "\n"
. '</h2>' . "\n"; . '</h2>' . "\n";
$sql_query = 'SHOW INNODB STATUS;'; $res = PMA_DBI_query('SHOW INNODB STATUS;');
$res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); $row = PMA_DBI_fetch_row($res);
$row = PMA_mysql_fetch_row($res);
echo '<pre>' . "\n" echo '<pre>' . "\n"
. htmlspecialchars($row[0]) . "\n" . htmlspecialchars($row[0]) . "\n"
. '</pre>' . "\n"; . '</pre>' . "\n";
@@ -52,25 +51,23 @@ if (!$is_superuser && !$cfg['ShowMysqlInfo']) {
/** /**
* Sends the query and buffers the result * Sends the query and buffers the result
*/ */
$res = @PMA_mysql_query('SHOW STATUS;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW STATUS;'); $res = PMA_DBI_query('SHOW STATUS;');
while ($row = PMA_mysql_fetch_row($res)) { while ($row = PMA_DBI_fetch_row($res)) {
$serverStatus[$row[0]] = $row[1]; $serverStatus[$row[0]] = $row[1];
} }
@PMA_DBI_free_result($res); PMA_DBI_free_result($res);
unset($res); unset($res, $row);
unset($row);
/** /**
* Displays the page * Displays the page
*/ */
//Uptime calculation //Uptime calculation
$res = @PMA_mysql_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime'] . ';'); $res = PMA_DBI_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime'] . ';');
$row = PMA_mysql_fetch_row($res); $row = PMA_DBI_fetch_row($res);
echo sprintf($strServerStatusUptime, PMA_timespanFormat($serverStatus['Uptime']), PMA_localisedDate($row[0])) . "\n"; echo sprintf($strServerStatusUptime, PMA_timespanFormat($serverStatus['Uptime']), PMA_localisedDate($row[0])) . "\n";
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
unset($res); unset($res, $row);
unset($row);
//Get query statistics //Get query statistics
$queryStats = array(); $queryStats = array();
$tmp_array = $serverStatus; $tmp_array = $serverStatus;
@@ -272,9 +269,9 @@ if (!empty($serverStatus)) {
</li> </li>
<?php <?php
} }
$res = PMA_mysql_query('SHOW VARIABLES LIKE "have_innodb";', $userlink); $res = PMA_DBI_query('SHOW VARIABLES LIKE "have_innodb";');
if ($res) { if ($res) {
$row = PMA_mysql_fetch_row($res); $row = PMA_DBI_fetch_row($res);
if (!empty($row[1]) && $row[1] == 'YES') { if (!empty($row[1]) && $row[1] == 'YES') {
?> ?>
<br /> <br />

View File

@@ -36,22 +36,25 @@ if (!$is_superuser && !$cfg['ShowMysqlVars']) {
* Sends the queries and buffers the results * Sends the queries and buffers the results
*/ */
if (PMA_MYSQL_INT_VERSION >= 40003) { if (PMA_MYSQL_INT_VERSION >= 40003) {
$res = @PMA_mysql_query('SHOW SESSION VARIABLES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW SESSION VARIABLES;'); $res = PMA_DBI_query('SHOW SESSION VARIABLES;');
while ($row = PMA_mysql_fetch_row($res)) { while ($row = PMA_DBI_fetch_row($res)) {
$serverVars[$row[0]] = $row[1]; $serverVars[$row[0]] = $row[1];
} }
@PMA_DBI_free_result($res); PMA_DBI_free_result($res);
$res = @PMA_mysql_query('SHOW GLOBAL VARIABLES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW GLOBAL VARIABLES;'); unset($res, $row);
while ($row = PMA_mysql_fetch_row($res)) { $res = PMA_DBI_query('SHOW GLOBAL VARIABLES;');
while ($row = PMA_DBI_fetch_row($res)) {
$serverVarsGlobal[$row[0]] = $row[1]; $serverVarsGlobal[$row[0]] = $row[1];
} }
@PMA_DBI_free_result($res); PMA_DBI_free_result($res);
unset($res, $row);
} else { } else {
$res = @PMA_mysql_query('SHOW VARIABLES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW VARIABLES;'); $res = PMA_DBI_query('SHOW VARIABLES;');
while ($row = PMA_mysql_fetch_row($res)) { while ($row = PMA_DBI_fetch_row($res)) {
$serverVars[$row[0]] = $row[1]; $serverVars[$row[0]] = $row[1];
} }
@PMA_DBI_free_result($res); PMA_DBI_free_result($res);
unset($res, $row);
} }
unset($res); unset($res);
unset($row); unset($row);

49
sql.php
View File

@@ -59,8 +59,7 @@ if (!defined('PMA_CHK_DROP')
// Checks if the user is a Superuser // Checks if the user is a Superuser
// TODO: set a global variable with this information // TODO: set a global variable with this information
// loic1: optimized query // loic1: optimized query
$result = @PMA_mysql_query('USE mysql'); if (!($result = PMA_DBI_select_db('mysql'))) {
if (PMA_mysql_error()) {
require_once('./header.inc.php'); require_once('./header.inc.php');
PMA_mysqlDie($strNoDropDatabases, '', '', $err_url); PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
} // end if } // end if
@@ -285,7 +284,7 @@ else {
$full_sql_query = $sql_query; $full_sql_query = $sql_query;
} // end if...else } // end if...else
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
// If the query is a DELETE query with no WHERE clause, get the number of // If the query is a DELETE query with no WHERE clause, get the number of
// rows that will be deleted (mysql_affected_rows will always return 0 in // rows that will be deleted (mysql_affected_rows will always return 0 in
@@ -293,9 +292,9 @@ else {
if ($is_delete if ($is_delete
&& preg_match('@^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$@i', $sql_query, $parts) && preg_match('@^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$@i', $sql_query, $parts)
&& !preg_match('@[[:space:]]WHERE[[:space:]]@i', $parts[3])) { && !preg_match('@[[:space:]]WHERE[[:space:]]@i', $parts[3])) {
$cnt_all_result = @PMA_mysql_query('SELECT COUNT(*) as count' . $parts[2]); $cnt_all_result = @PMA_DBI_try_query('SELECT COUNT(*) as count' . $parts[2]);
if ($cnt_all_result) { if ($cnt_all_result) {
$num_rows = PMA_mysql_result($cnt_all_result, 0, 'count'); $num_rows = PMA_DBI_result($cnt_all_result, 0, 'count');
PMA_DBI_free_result($cnt_all_result); PMA_DBI_free_result($cnt_all_result);
} else { } else {
$num_rows = 0; $num_rows = 0;
@@ -314,7 +313,7 @@ else {
list($usec, $sec) = explode(' ',microtime()); list($usec, $sec) = explode(' ',microtime());
$querytime_before = ((float)$usec + (float)$sec); $querytime_before = ((float)$usec + (float)$sec);
$result = @PMA_mysql_query($full_sql_query); $result = @PMA_DBI_try_query($full_sql_query);
list($usec, $sec) = explode(' ',microtime()); list($usec, $sec) = explode(' ',microtime());
$querytime_after = ((float)$usec + (float)$sec); $querytime_after = ((float)$usec + (float)$sec);
@@ -322,14 +321,14 @@ else {
$GLOBALS['querytime'] = $querytime_after - $querytime_before; $GLOBALS['querytime'] = $querytime_after - $querytime_before;
// Displays an error message if required and stop parsing the script // Displays an error message if required and stop parsing the script
if (PMA_mysql_error()) { if ($error = PMA_DBI_getError()) {
$error = PMA_mysql_error();
require_once('./header.inc.php'); require_once('./header.inc.php');
$full_err_url = (preg_match('@^(db_details|tbl_properties)@', $err_url)) $full_err_url = (preg_match('@^(db_details|tbl_properties)@', $err_url))
? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query) ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
: $err_url; : $err_url;
PMA_mysqlDie($error, $full_sql_query, '', $full_err_url); PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
} }
unset($error);
// Gets the number of rows affected/returned // Gets the number of rows affected/returned
// (This must be done immediately after the query because // (This must be done immediately after the query because
@@ -343,15 +342,14 @@ else {
// Checks if the current database has changed // Checks if the current database has changed
// This could happen if the user sends a query like "USE `database`;" // This could happen if the user sends a query like "USE `database`;"
$res = PMA_mysql_query('SELECT DATABASE() AS "db";'); $res = PMA_DBI_query('SELECT DATABASE() AS "db";');
$row = PMA_mysql_fetch_array($res); $row = PMA_DBI_fetch_row($res);
if (is_array($row) && isset($row['db']) && $db != $row['db']) { if (is_array($row) && isset($row[0]) && $db != $row[0]) {
$db = $row['db']; $db = $row[0];
$reload = 1; $reload = 1;
} }
@PMA_DBI_free_result($res); @PMA_DBI_free_result($res);
unset($res); unset($res, $row);
unset($row);
// tmpfile remove after convert encoding appended by Y.Kawada // tmpfile remove after convert encoding appended by Y.Kawada
if (function_exists('PMA_kanji_file_conv') if (function_exists('PMA_kanji_file_conv')
@@ -457,15 +455,16 @@ else {
//DEBUG echo "trace cq=" . $count_query . "<br/>"; //DEBUG echo "trace cq=" . $count_query . "<br/>";
if (PMA_MYSQL_INT_VERSION < 40000) { if (PMA_MYSQL_INT_VERSION < 40000) {
if ($cnt_all_result = PMA_mysql_query($count_query)) { if ($cnt_all_result = PMA_DBI_try_query($count_query)) {
if ($is_group && $count_what == '*') { if ($is_group && $count_what == '*') {
$unlim_num_rows = @PMA_DBI_num_rows($cnt_all_result); $unlim_num_rows = @PMA_DBI_num_rows($cnt_all_result);
} else { } else {
$unlim_num_rows = PMA_mysql_result($cnt_all_result, 0, 'count'); $unlim_num_rows = PMA_DBI_fetch_assoc($cnt_all_result);
$unlim_num_rows = $unlim_num_rows['count'];
} }
PMA_DBI_free_result($cnt_all_result); PMA_DBI_free_result($cnt_all_result);
} else { } else {
if (mysql_error()) { if (PMA_DBI_getError()) {
// there are some cases where the generated // there are some cases where the generated
// count_query (for MySQL 3) is wrong, // count_query (for MySQL 3) is wrong,
@@ -477,7 +476,7 @@ else {
} }
} }
} else { } else {
PMA_mysql_query($count_query); PMA_DBI_query($count_query);
// if (mysql_error()) { // if (mysql_error()) {
// void. I tried the case // void. I tried the case
// (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`) // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
@@ -487,8 +486,8 @@ else {
// and although the generated count_query is wrong // and although the generated count_query is wrong
// the SELECT FOUND_ROWS() work! // the SELECT FOUND_ROWS() work!
// } // }
$cnt_all_result = PMA_mysql_query('SELECT FOUND_ROWS() as count'); $cnt_all_result = PMA_DBI_query('SELECT FOUND_ROWS() as count;');
$unlim_num_rows = PMA_mysql_result($cnt_all_result,0,'count'); list($unlim_num_rows) = PMA_DBI_fetch_row($cnt_all_result);
} }
} // end else "just browsing" } // end else "just browsing"
@@ -558,7 +557,7 @@ else {
if (!isset($table)) { if (!isset($table)) {
$goto = 'db_details.php'; $goto = 'db_details.php';
} else { } else {
$is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''); $is_table = @PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
if (!($is_table && @PMA_DBI_num_rows($is_table))) { if (!($is_table && @PMA_DBI_num_rows($is_table))) {
$goto = 'db_details.php'; $goto = 'db_details.php';
unset($table); unset($table);
@@ -572,7 +571,7 @@ else {
if (!isset($db)) { if (!isset($db)) {
$goto = 'main.php'; $goto = 'main.php';
} else { } else {
$is_db = @PMA_mysql_select_db($db); $is_db = @PMA_DBI_select_db($db);
if (!$is_db) { if (!$is_db) {
$goto = 'main.php'; $goto = 'main.php';
unset($db); unset($db);
@@ -623,10 +622,8 @@ else {
// Gets the list of fields properties // Gets the list of fields properties
if (isset($result) && $result) { if (isset($result) && $result) {
while ($field = PMA_mysql_fetch_field($result)) { $fields_meta = PMA_DBI_get_fields_meta($result);
$fields_meta[] = $field; $fields_cnt = count($fields_meta);
}
$fields_cnt = count($fields_meta);
} }
// Display previous update query (from tbl_replace) // Display previous update query (from tbl_replace)

View File

@@ -101,11 +101,10 @@ if (isset($submit)) {
// To allow replication, we first select the db to use and then run queries // To allow replication, we first select the db to use and then run queries
// on this db. // on this db.
$sql_query = 'USE ' . PMA_backquote($db); PMA_DBI_select_db($db) or PMA_mysqlDie(PMA_getError(), 'USE ' . PMA_backquotes($db), '', $err_url);
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD ' . $query; $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD ' . $query;
$error_create = false; $error_create = FALSE;
$result = PMA_mysql_query($sql_query) or $error_create = true; PMA_DBI_try_query($sql_query) or $error_create = TRUE;
if ($error_create == false) { if ($error_create == false) {
@@ -123,8 +122,8 @@ if (isset($submit)) {
} // end for } // end for
$primary = preg_replace('@, $@', '', $primary); $primary = preg_replace('@, $@', '', $primary);
if (!empty($primary)) { if (!empty($primary)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ')'; $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ');';
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); $result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';'; $sql_query_cpy .= "\n" . $sql_query . ';';
} }
} // end if } // end if
@@ -142,7 +141,7 @@ if (isset($submit)) {
$index = preg_replace('@, $@', '', $index); $index = preg_replace('@, $@', '', $index);
if (!empty($index)) { if (!empty($index)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')'; $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')';
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); $result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';'; $sql_query_cpy .= "\n" . $sql_query . ';';
} }
} // end if } // end if
@@ -160,7 +159,7 @@ if (isset($submit)) {
$unique = preg_replace('@, $@', '', $unique); $unique = preg_replace('@, $@', '', $unique);
if (!empty($unique)) { if (!empty($unique)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')'; $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')';
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); $result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';'; $sql_query_cpy .= "\n" . $sql_query . ';';
} }
} // end if } // end if
@@ -177,7 +176,7 @@ if (isset($submit)) {
$fulltext = preg_replace('@, $@', '', $fulltext); $fulltext = preg_replace('@, $@', '', $fulltext);
if (!empty($fulltext)) { if (!empty($fulltext)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')'; $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')';
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); $result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';'; $sql_query_cpy .= "\n" . $sql_query . ';';
} }
} // end if } // end if

View File

@@ -72,14 +72,13 @@ if (isset($submit)) {
// To allow replication, we first select the db to use and then run queries // To allow replication, we first select the db to use and then run queries
// on this db. // on this db.
$sql_query = 'USE ' . PMA_backquote($db); PMA_DBI_select_db($db) or PMA_mysqlDie(PMA_DBI_getError(), 'USE ' . PMA_backquote($db) . ';', '', $err_url);
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
// Optimization fix - 2 May 2001 - Robbat2 // Optimization fix - 2 May 2001 - Robbat2
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' . $query; $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' . $query;
$error_create = false; $error_create = FALSE;
$result = PMA_mysql_query($sql_query) or $error_create = true; $result = PMA_DBI_try_query($sql_query) or $error_create = TRUE;
if ($error_create == false) { if ($error_create == FALSE) {
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered; $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
$btnDrop = 'Fake'; $btnDrop = 'Fake';
@@ -175,9 +174,8 @@ if ($abort == FALSE) {
} else { } else {
$field = PMA_sqlAddslashes($selected[$i], TRUE); $field = PMA_sqlAddslashes($selected[$i], TRUE);
} }
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . " LIKE '$field'"; $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ' LIKE \'' . $field . '\';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); $fields_meta[] = PMA_DBI_fetch_assoc($result);
$fields_meta[] = PMA_mysql_fetch_array($result);
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
} }

View File

@@ -78,8 +78,8 @@ echo '<br />';
/** /**
* Get the list of the fields of the current table * Get the list of the fields of the current table
*/ */
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$table_def = PMA_mysql_query('SHOW FIELDS FROM ' . PMA_backquote($table)); $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
if (isset($primary_key)) { if (isset($primary_key)) {
if (is_array($primary_key)) { if (is_array($primary_key)) {
$primary_key_array = $primary_key; $primary_key_array = $primary_key;
@@ -90,11 +90,10 @@ if (isset($primary_key)) {
$row = array(); $row = array();
$result = array(); $result = array();
foreach($primary_key_array AS $rowcount => $primary_key) { foreach($primary_key_array AS $rowcount => $primary_key) {
$local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key; $result[$rowcount] = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';');
$result[$rowcount] = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); $row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]);
$row[$rowcount] = PMA_mysql_fetch_array($result[$rowcount]);
$primary_keys[$rowcount] = $primary_key; $primary_keys[$rowcount] = $primary_key;
// No row returned // No row returned
if (!$row[$rowcount]) { if (!$row[$rowcount]) {
unset($row[$rowcount]); unset($row[$rowcount]);
@@ -119,8 +118,7 @@ if (isset($primary_key)) {
} // end if (no record returned) } // end if (no record returned)
} }
} else { } else {
$local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1'; $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
unset($row); unset($row);
} }
@@ -200,7 +198,7 @@ $fields_cnt = PMA_DBI_num_rows($table_def);
$insert_mode = (!isset($row) ? TRUE : FALSE); $insert_mode = (!isset($row) ? TRUE : FALSE);
$loop_array = (isset($row) ? $row : array(0 => FALSE)); $loop_array = (isset($row) ? $row : array(0 => FALSE));
while ($trow = PMA_mysql_fetch_array($table_def)) { while ($trow = PMA_DBI_fetch_assoc($table_def)) {
$trow_table_def[] = $trow; $trow_table_def[] = $trow;
} }
@@ -240,12 +238,12 @@ foreach($loop_array AS $vrowcount => $vrow) {
// Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one) // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
$m_rows = $o_rows + 1; $m_rows = $o_rows + 1;
for ($i = 0; $i < $fields_cnt; $i++) { for ($i = 0; $i < $fields_cnt; $i++) {
// Display the submit button after every 15 lines --swix // Display the submit button after every 15 lines --swix
// (wanted to use an <a href="#bottom"> and <a name> instead, // (wanted to use an <a href="#bottom"> and <a name> instead,
// but it didn't worked because of the <base href>) // but it didn't worked because of the <base href>)
if ((($i % 15) == 0) && ($i != 0)) { if ((($i % 15) == 0) && ($i != 0)) {
?> ?>
<tr> <tr>
@@ -256,12 +254,12 @@ foreach($loop_array AS $vrowcount => $vrow) {
<?php <?php
} // end if } // end if
echo "\n"; echo "\n";
$row_table_def = $trow_table_def[$i]; $row_table_def = $trow_table_def[$i];
$row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']); $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);
$field = $row_table_def['Field']; $field = $row_table_def['Field'];
// garvin: possible workaround. If current field is numerical, do not try to // garvin: possible workaround. If current field is numerical, do not try to
// access the result-array with its 'associative' key but with its numerical // access the result-array with its 'associative' key but with its numerical
// represantation. // represantation.
@@ -270,7 +268,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
} else { } else {
$rowfield = $field; $rowfield = $field;
} }
// d a t e t i m e // d a t e t i m e
// //
// loic1: current date should not be set as default if the field is NULL // loic1: current date should not be set as default if the field is NULL
@@ -295,16 +293,16 @@ foreach($loop_array AS $vrowcount => $vrow) {
} }
$len = (preg_match('@float|double@', $row_table_def['Type'])) $len = (preg_match('@float|double@', $row_table_def['Type']))
? 100 ? 100
: @mysql_field_len($vresult, $i); : @mysql_field_len($vresult, $i); // !UNWRAPPED FUNCTION!
$first_timestamp = 0; $first_timestamp = 0;
$bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
?> ?>
<tr> <tr>
<td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center" bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($field); ?></td> <td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center" bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($field); ?></td>
<?php <?php
echo "\n"; echo "\n";
// The type column // The type column
$is_binary = stristr($row_table_def['Type'], ' binary'); $is_binary = stristr($row_table_def['Type'], ' binary');
$is_blob = stristr($row_table_def['Type'], 'blob'); $is_blob = stristr($row_table_def['Type'], 'blob');
@@ -326,7 +324,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
$type = $row_table_def['Type']; $type = $row_table_def['Type'];
$type_nowrap = ' nowrap="nowrap"'; $type_nowrap = ' nowrap="nowrap"';
break; break;
default: default:
$type = $row_table_def['Type']; $type = $row_table_def['Type'];
$type_nowrap = ' nowrap="nowrap"'; $type_nowrap = ' nowrap="nowrap"';
@@ -338,7 +336,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
</td> </td>
<?php <?php
echo "\n"; echo "\n";
// Prepares the field value // Prepares the field value
$real_null_value = FALSE; $real_null_value = FALSE;
if (isset($vrow)) { if (isset($vrow)) {
@@ -378,7 +376,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
$special_chars = htmlspecialchars($row_table_def['Default']); $special_chars = htmlspecialchars($row_table_def['Default']);
$backup_field = ''; $backup_field = '';
} }
// The function column // The function column
// ------------------- // -------------------
// Change by Bernard M. Piller <bernard@bmpsystems.com> // Change by Bernard M. Piller <bernard@bmpsystems.com>
@@ -400,7 +398,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
<?php <?php
echo "\n"; echo "\n";
$selected = ''; $selected = '';
// garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR' // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
// or something similar. Then directly look up the entry in the RestrictFunctions array, // or something similar. Then directly look up the entry in the RestrictFunctions array,
// which will then reveal the available dropdown options // which will then reveal the available dropdown options
@@ -411,10 +409,10 @@ foreach($loop_array AS $vrowcount => $vrow) {
} else { } else {
$dropdown = array(); $dropdown = array();
} }
$dropdown_built = array(); $dropdown_built = array();
$op_spacing_needed = FALSE; $op_spacing_needed = FALSE;
// garvin: loop on the dropdown array and print all available options for that field. // garvin: loop on the dropdown array and print all available options for that field.
$cnt_dropdown = count($dropdown); $cnt_dropdown = count($dropdown);
for ($j = 0; $j < $cnt_dropdown; $j++) { for ($j = 0; $j < $cnt_dropdown; $j++) {
@@ -428,7 +426,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
$dropdown_built[$dropdown[$j]] = 'TRUE'; $dropdown_built[$dropdown[$j]] = 'TRUE';
$op_spacing_needed = TRUE; $op_spacing_needed = TRUE;
} }
// garvin: For compatibility's sake, do not let out all other functions. Instead // garvin: For compatibility's sake, do not let out all other functions. Instead
// print a seperator (blank) and then show ALL functions which weren't shown // print a seperator (blank) and then show ALL functions which weren't shown
// yet. // yet.
@@ -445,7 +443,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
echo '<option value="">--------</option>' . "\n"; echo '<option value="">--------</option>' . "\n";
$op_spacing_needed = FALSE; $op_spacing_needed = FALSE;
} }
echo ' '; echo ' ';
echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n"; echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
} }
@@ -458,7 +456,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
} }
} // end if ($cfg['ShowFunctionFields']) } // end if ($cfg['ShowFunctionFields'])
echo "\n"; echo "\n";
// The null column // The null column
// --------------- // ---------------
echo ' <td bgcolor="' . $bgcolor . '">' . "\n"; echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
@@ -491,12 +489,12 @@ foreach($loop_array AS $vrowcount => $vrow) {
echo ' &nbsp;' . "\n"; echo ' &nbsp;' . "\n";
} }
echo ' </td>' . "\n"; echo ' </td>' . "\n";
// The value column (depends on type) // The value column (depends on type)
// ---------------- // ----------------
require('./libraries/get_foreign.lib.php'); require('./libraries/get_foreign.lib.php');
if (isset($foreign_link) && $foreign_link == true) { if (isset($foreign_link) && $foreign_link == true) {
?> ?>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
@@ -556,7 +554,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
<input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" /> <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" />
<?php <?php
echo "\n" . ' ' . $backup_field; echo "\n" . ' ' . $backup_field;
// show dropdown or radio depend on length // show dropdown or radio depend on length
if (strlen($row_table_def['Type']) > 20) { if (strlen($row_table_def['Type']) > 20) {
echo "\n"; echo "\n";
@@ -565,7 +563,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
<option value=""></option> <option value=""></option>
<?php <?php
echo "\n"; echo "\n";
for ($j = 0; $j < $enum_cnt; $j++) { for ($j = 0; $j < $enum_cnt; $j++) {
// Removes automatic MySQL escape format // Removes automatic MySQL escape format
$enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j])); $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
@@ -578,7 +576,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
} }
echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n"; echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
} // end for } // end for
?> ?>
</select> </select>
<?php <?php
@@ -598,7 +596,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
echo 'tabindex="' . (($i * $m_rows) + 1) . '" />' . "\n"; echo 'tabindex="' . (($i * $m_rows) + 1) . '" />' . "\n";
echo ' <label for="field_' . ($i * $m_rows) . '_3_' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n"; echo ' <label for="field_' . ($i * $m_rows) . '_3_' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n";
} // end for } // end for
} // end else } // end else
echo "\n"; echo "\n";
?> ?>
@@ -608,7 +606,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
} }
else if ($type == 'set') { else if ($type == 'set') {
$set = PMA_getEnumSetOptions($row_table_def['Type']); $set = PMA_getEnumSetOptions($row_table_def['Type']);
if (isset($vset)) { if (isset($vset)) {
unset($vset); unset($vset);
} }
@@ -666,7 +664,7 @@ foreach($loop_array AS $vrowcount => $vrow) {
<textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($i*$m_rows); ?>_3" <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($i*$m_rows); ?>_3"
<?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" ><?php echo $special_chars; ?></textarea> <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" ><?php echo $special_chars; ?></textarea>
<?php <?php
} else { } else {
if ($len < 4) { if ($len < 4) {
$fieldsize = $maxlength = 4; $fieldsize = $maxlength = 4;
@@ -681,11 +679,11 @@ foreach($loop_array AS $vrowcount => $vrow) {
<input type="text" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3" /> <input type="text" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3" />
<?php <?php
} // end if...elseif...else } // end if...elseif...else
// Upload choice (only for BLOBs because the binary // Upload choice (only for BLOBs because the binary
// attribute does not imply binary contents) // attribute does not imply binary contents)
// (displayed whatever value the ProtectBinary has) // (displayed whatever value the ProtectBinary has)
if ($is_upload && $is_blob) { if ($is_upload && $is_blob) {
echo '<input type="file" name="fields_upload_' . urlencode($field) . $vkey . '" class="textfield" id="field_' . ($i * $m_rows) . '_3" size="10" />&nbsp;'; echo '<input type="file" name="fields_upload_' . urlencode($field) . $vkey . '" class="textfield" id="field_' . ($i * $m_rows) . '_3" size="10" />&nbsp;';
@@ -701,9 +699,9 @@ foreach($loop_array AS $vrowcount => $vrow) {
$this_field_max_size = $max_field_sizes[$type]; $this_field_max_size = $max_field_sizes[$type];
} }
echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n"; echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n";
echo ' ' . PMA_generateHiddenMaxFileSize($this_field_max_size) . "\n"; echo ' ' . PMA_generateHiddenMaxFileSize($this_field_max_size) . "\n";
} }
if (!empty($cfg['UploadDir'])) { if (!empty($cfg['UploadDir'])) {
if (substr($cfg['UploadDir'], -1) != '/') { if (substr($cfg['UploadDir'], -1) != '/') {
$cfg['UploadDir'] .= '/'; $cfg['UploadDir'] .= '/';
@@ -731,9 +729,9 @@ foreach($loop_array AS $vrowcount => $vrow) {
echo ' ' . $strWebServerUploadDirectoryError . "\n"; echo ' ' . $strWebServerUploadDirectoryError . "\n";
} }
} // end if (web-server upload directory) } // end if (web-server upload directory)
echo '</td>'; echo '</td>';
} // end else if ( binary or blob) } // end else if ( binary or blob)
else { else {
// For char or varchar, respect the maximum length (M); for other // For char or varchar, respect the maximum length (M); for other

View File

@@ -25,13 +25,13 @@ $err_url = 'tbl_properties.php?' . PMA_generate_common_url($db, $table);
/** /**
* Selects the database to work with * Selects the database to work with
*/ */
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
/** /**
* The form used to define the structure of the table has been submitted * The form used to define the structure of the table has been submitted
*/ */
$abort = false; $abort = FALSE;
if (isset($submit)) { if (isset($submit)) {
$sql_query = $query_cpy = ''; $sql_query = $query_cpy = '';
@@ -174,10 +174,10 @@ if (isset($submit)) {
} }
// Executes the query // Executes the query
$error_create = false; $error_create = FALSE;
$result = PMA_mysql_query($sql_query) or $error_create = true; $result = PMA_DBI_try_query($sql_query) or $error_create = TRUE;
if ($error_create == false) { if ($error_create == FALSE) {
$sql_query = $query_cpy . ';'; $sql_query = $query_cpy . ';';
unset($query_cpy); unset($query_cpy);
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated; $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated;
@@ -211,7 +211,7 @@ if (isset($submit)) {
// to prevent total loss of that data, we embed the form once again. // to prevent total loss of that data, we embed the form once again.
// The variable $regenerate will be used to restore data in tbl_properties.inc.php // The variable $regenerate will be used to restore data in tbl_properties.inc.php
$num_fields = $orig_num_fields; $num_fields = $orig_num_fields;
$regenerate = true; $regenerate = TRUE;
} }
} // end do create table } // end do create table

View File

@@ -29,7 +29,7 @@ $index_types = array(
if (!defined('PMA_IDX_INCLUDED')) { if (!defined('PMA_IDX_INCLUDED')) {
// Not a valid db name -> back to the welcome page // Not a valid db name -> back to the welcome page
if (!empty($db)) { if (!empty($db)) {
$is_db = @PMA_mysql_select_db($db); $is_db = PMA_DBI_select_db($db);
} }
if (empty($db) || !$is_db) { if (empty($db) || !$is_db) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
@@ -37,10 +37,10 @@ if (!defined('PMA_IDX_INCLUDED')) {
} }
// Not a valid table name -> back to the default db_details sub-page // Not a valid table name -> back to the default db_details sub-page
if (!empty($table)) { if (!empty($table)) {
$is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''); $is_table = PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
} }
if (empty($table) if (empty($table)
|| !($is_table && @PMA_DBI_num_rows($is_table))) { || !($is_table && PMA_DBI_num_rows($is_table))) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); header('Location: ' . $cfg['PmaAbsoluteUri'] . $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit; exit;
} else if (isset($is_table)) { } else if (isset($is_table)) {
@@ -70,12 +70,12 @@ if (defined('PMA_IDX_INCLUDED')) {
$idx_cnt = count($ret_keys); $idx_cnt = count($ret_keys);
} else { } else {
$local_query = 'SHOW KEYS FROM ' . PMA_backquote($table); $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table);
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); $result = PMA_DBI_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
$idx_cnt = PMA_DBI_num_rows($result); $idx_cnt = PMA_DBI_num_rows($result);
} }
for ($i = 0; $i < $idx_cnt; $i++) { for ($i = 0; $i < $idx_cnt; $i++) {
$row = (defined('PMA_IDX_INCLUDED') ? $ret_keys[$i] : PMA_mysql_fetch_array($result)); $row = (defined('PMA_IDX_INCLUDED') ? $ret_keys[$i] : PMA_DBI_fetch_assoc($result));
if ($row['Key_name'] != $prev_index ){ if ($row['Key_name'] != $prev_index ){
$indexes[] = $row['Key_name']; $indexes[] = $row['Key_name'];
@@ -110,16 +110,15 @@ if (defined('PMA_IDX_INCLUDED')) {
// Get fields and stores their name/type // Get fields and stores their name/type
// fields had already been grabbed in "tbl_properties.php" // fields had already been grabbed in "tbl_properties.php"
if (defined('PMA_IDX_INCLUDED')) { if (defined('PMA_IDX_INCLUDED')) {
mysql_data_seek($fields_rs, 0); mysql_data_seek($fields_rs, 0); // !UNWRAPPED FUNCTION!
} else { } else {
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table); $fields_rs = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
$fields_rs = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
$fields_cnt = PMA_DBI_num_rows($fields_rs); $fields_cnt = PMA_DBI_num_rows($fields_rs);
} }
$fields_names = array(); $fields_names = array();
$fields_types = array(); $fields_types = array();
while ($row = PMA_mysql_fetch_array($fields_rs)) { while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
$fields_names[] = $row['Field']; $fields_names[] = $row['Field'];
// loic1: set or enum types: slashes single quotes inside options // loic1: set or enum types: slashes single quotes inside options
if (preg_match('@^(set|enum)\((.+)\)$@i', $row['Type'], $tmp)) { if (preg_match('@^(set|enum)\((.+)\)$@i', $row['Type'], $tmp)) {
@@ -201,7 +200,7 @@ if (!defined('PMA_IDX_INCLUDED')
$sql_query .= $index_fields . ')'; $sql_query .= $index_fields . ')';
} }
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, FALSE, $err_url); $result = PMA_DBI_query($sql_query);
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered; $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
$active_page = 'tbl_properties_structure.php'; $active_page = 'tbl_properties_structure.php';

View File

@@ -25,10 +25,10 @@ function PMA_myHandler($sql_insert = '')
global $sql_insert_data; global $sql_insert_data;
$sql_insert = preg_replace('~INSERT INTO (`?)' . $table . '(`?)~i', 'INSERT INTO ' . $target, $sql_insert); $sql_insert = preg_replace('~INSERT INTO (`?)' . $table . '(`?)~i', 'INSERT INTO ' . $target, $sql_insert);
$result = PMA_mysql_query($sql_insert) or PMA_mysqlDie('', $sql_insert, '', $GLOBALS['err_url']); $result = PMA_DBI_query($sql_insert);
$sql_insert_data .= $sql_insert . ';' . "\n"; $sql_insert_data .= $sql_insert . ';' . "\n";
} // end of the 'PMA_myHandler()' function } // end of the 'PMA_myHandler()' function
/** /**
* Inserts existing entries in a PMA_* table by reading a value from an old entry * Inserts existing entries in a PMA_* table by reading a value from an old entry
@@ -78,7 +78,7 @@ global $cfgRelation;
. ' WHERE ' . implode(' AND ', $where_parts); . ' WHERE ' . implode(' AND ', $where_parts);
$table_copy_rs = PMA_query_as_cu($table_copy_query); $table_copy_rs = PMA_query_as_cu($table_copy_query);
while ($table_copy_row = @PMA_mysql_fetch_array($table_copy_rs)) { while ($table_copy_row = @PMA_DBI_fetch_assoc($table_copy_rs)) {
$value_parts = array(); $value_parts = array();
foreach($table_copy_row AS $_key => $_val) { foreach($table_copy_row AS $_key => $_val) {
if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') { if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') {
@@ -92,7 +92,7 @@ global $cfgRelation;
. ' (\'' . implode('\', \'', $value_parts) . '\', \'' . implode('\', \'', $new_value_parts) . '\')'; . ' (\'' . implode('\', \'', $value_parts) . '\', \'' . implode('\', \'', $new_value_parts) . '\')';
$new_table_rs = PMA_query_as_cu($new_table_query); $new_table_rs = PMA_query_as_cu($new_table_query);
$last_id = (@function_exists('mysql_insert_id') ? @PMA_DBI_insert_id() : -1); $last_id = PMA_DBI_insert_id();
} // end while } // end while
return $last_id; return $last_id;
@@ -117,7 +117,7 @@ $err_url = 'tbl_properties.php?' . PMA_generate_common_url($db, $table);
/** /**
* Selects the database to work with * Selects the database to work with
*/ */
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
/** /**
@@ -141,7 +141,7 @@ if (isset($new_name) && trim($new_name) != '') {
// This could avoid some problems with replicated databases, when // This could avoid some problems with replicated databases, when
// moving table from replicated one to not replicated one // moving table from replicated one to not replicated one
PMA_mysql_select_db($target_db); PMA_DBI_select_db($target_db);
$target = PMA_backquote($target_db) . '.' . PMA_backquote($new_name); $target = PMA_backquote($target_db) . '.' . PMA_backquote($new_name);
@@ -169,11 +169,7 @@ if (isset($new_name) && trim($new_name) != '') {
$drop_query = ''; $drop_query = '';
if (isset($drop_if_exists) && $drop_if_exists == 'true') { if (isset($drop_if_exists) && $drop_if_exists == 'true') {
$drop_query = 'DROP TABLE IF EXISTS ' . PMA_backquote($target_db) . '.' . PMA_backquote($new_name); $drop_query = 'DROP TABLE IF EXISTS ' . PMA_backquote($target_db) . '.' . PMA_backquote($new_name);
$result = @PMA_mysql_query($drop_query); $result = PMA_DBI_query($drop_query);
if (PMA_mysql_error()) {
require_once('./header.inc.php');
PMA_mysqlDie('', $sql_structure, '', $err_url);
}
if (isset($sql_query)) { if (isset($sql_query)) {
$sql_query .= "\n" . $drop_query . ';'; $sql_query .= "\n" . $drop_query . ';';
@@ -183,14 +179,11 @@ if (isset($new_name) && trim($new_name) != '') {
// garvin: If an existing table gets deleted, maintain any entries // garvin: If an existing table gets deleted, maintain any entries
// for the PMA_* tables // for the PMA_* tables
$maintain_relations = true; $maintain_relations = TRUE;
} }
$result = @PMA_mysql_query($sql_structure); $result = @PMA_DBI_query($sql_structure);
if (PMA_mysql_error()) { if (isset($sql_query)) {
require_once('./header.inc.php');
PMA_mysqlDie('', $sql_structure, '', $err_url);
} else if (isset($sql_query)) {
$sql_query .= "\n" . $sql_structure . ';'; $sql_query .= "\n" . $sql_structure . ';';
} else { } else {
$sql_query = $sql_structure . ';'; $sql_query = $sql_structure . ';';
@@ -207,11 +200,8 @@ if (isset($new_name) && trim($new_name) != '') {
/* Generate query back */ /* Generate query back */
$sql_constraints = PMA_SQP_formatHtml($parsed_sql, 'query_only'); $sql_constraints = PMA_SQP_formatHtml($parsed_sql, 'query_only');
$result = @PMA_mysql_query($sql_constraints); $result = PMA_DBI_query($sql_constraints);
if (PMA_mysql_error()) { if (isset($sql_query)) {
require_once('./header.inc.php');
PMA_mysqlDie('', $sql_structure, '', $err_url);
} else if (isset($sql_query)) {
$sql_query .= "\n" . $sql_constraints; $sql_query .= "\n" . $sql_constraints;
} else { } else {
$sql_query = $sql_constraints; $sql_query = $sql_constraints;
@@ -225,12 +215,8 @@ if (isset($new_name) && trim($new_name) != '') {
// Copy the data // Copy the data
if ($result != FALSE && ($what == 'data' || $what == 'dataonly')) { if ($result != FALSE && ($what == 'data' || $what == 'dataonly')) {
$sql_insert_data = 'INSERT INTO ' . $target . ' SELECT * FROM ' . $source; $sql_insert_data = 'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
$result = @PMA_mysql_query($sql_insert_data); PMA_DBI_query($sql_insert_data);
if (PMA_mysql_error()) { $sql_query .= "\n\n" . $sql_insert_data . ';';
require_once('./header.inc.php');
PMA_mysqlDie('', $sql_insert_data, '', $err_url);
}
$sql_query .= "\n\n" . $sql_insert_data . ';';
} }
require_once('./libraries/relation.lib.php'); require_once('./libraries/relation.lib.php');
@@ -241,14 +227,10 @@ if (isset($new_name) && trim($new_name) != '') {
// This could avoid some problems with replicated databases, when // This could avoid some problems with replicated databases, when
// moving table from replicated one to not replicated one // moving table from replicated one to not replicated one
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$sql_drop_table = 'DROP TABLE ' . $source; $sql_drop_table = 'DROP TABLE ' . $source;
$result = @PMA_mysql_query($sql_drop_table); PMA_DBI_query($sql_drop_table);
if (PMA_mysql_error()) {
require_once('./header.inc.php');
PMA_mysqlDie('', $sql_drop_table, '', $err_url);
}
// garvin: Move old entries from PMA-DBs to new table // garvin: Move old entries from PMA-DBs to new table
if ($cfgRelation['commwork']) { if ($cfgRelation['commwork']) {
@@ -323,7 +305,7 @@ if (isset($new_name) && trim($new_name) != '') {
. ' AND table_name = \'' . PMA_sqlAddslashes($new_name) . '\''; . ' AND table_name = \'' . PMA_sqlAddslashes($new_name) . '\'';
$pdf_rs = PMA_query_as_cu($pdf_query); $pdf_rs = PMA_query_as_cu($pdf_query);
while ($pdf_copy_row = @PMA_mysql_fetch_array($pdf_rs)) { while ($pdf_copy_row = PMA_DBI_fetch_assoc($pdf_rs)) {
$table_query = 'UPDATE ' . PMA_backquote($cfgRelation['pdf_pages']) $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['pdf_pages'])
. ' SET db_name = \'' . PMA_sqlAddslashes($target_db) . '\'' . ' SET db_name = \'' . PMA_sqlAddslashes($target_db) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
@@ -350,7 +332,7 @@ if (isset($new_name) && trim($new_name) != '') {
$comments_copy_rs = PMA_query_as_cu($comments_copy_query); $comments_copy_rs = PMA_query_as_cu($comments_copy_query);
// Write every comment as new copied entry. [MIME] // Write every comment as new copied entry. [MIME]
while ($comments_copy_row = @PMA_mysql_fetch_array($comments_copy_rs)) { while ($comments_copy_row = PMA_DBI_fetch_assoc($comments_copy_rs)) {
$new_comment_query = 'REPLACE INTO ' . PMA_backquote($cfgRelation['column_info']) $new_comment_query = 'REPLACE INTO ' . PMA_backquote($cfgRelation['column_info'])
. ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') ' . ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') '
. ' VALUES(' . ' VALUES('

View File

@@ -38,7 +38,7 @@ if (isset($table)) {
/** /**
* Selects the database * Selects the database
*/ */
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
/** /**
@@ -79,21 +79,17 @@ foreach($the_tables AS $key => $table) {
/** /**
* Gets table informations * Gets table informations
*/ */
$local_query = 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''; $result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); $showtable = PMA_DBI_fetch_assoc($result);
$showtable = PMA_mysql_fetch_array($result);
$num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); $num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
$show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
if ($result) { PMA_DBI_free_result($result);
PMA_DBI_free_result($result);
}
/** /**
* Gets table keys and retains them * Gets table keys and retains them
*/ */
$local_query = 'SHOW KEYS FROM ' . PMA_backquote($table); $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
$primary = ''; $primary = '';
$indexes = array(); $indexes = array();
$lastIndex = ''; $lastIndex = '';
@@ -101,7 +97,7 @@ foreach($the_tables AS $key => $table) {
$indexes_data = array(); $indexes_data = array();
$pk_array = array(); // will be use to emphasis prim. keys in the table $pk_array = array(); // will be use to emphasis prim. keys in the table
// view // view
while ($row = PMA_mysql_fetch_array($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
// Backups the list of primary keys // Backups the list of primary keys
if ($row['Key_name'] == 'PRIMARY') { if ($row['Key_name'] == 'PRIMARY') {
$primary .= $row['Column_name'] . ', '; $primary .= $row['Column_name'] . ', ';
@@ -135,8 +131,7 @@ foreach($the_tables AS $key => $table) {
/** /**
* Gets fields properties * Gets fields properties
*/ */
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table); $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck) // Check if we can use Relations (Mike Beck)
@@ -193,7 +188,7 @@ foreach($the_tables AS $key => $table) {
<?php <?php
$i = 0; $i = 0;
while ($row = PMA_mysql_fetch_array($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
$bgcolor = ($i % 2) ?$cfg['BgcolorOne'] : $cfg['BgcolorTwo']; $bgcolor = ($i % 2) ?$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
$i++; $i++;

View File

@@ -558,10 +558,9 @@ if ($action == 'tbl_create.php') {
// change by staybyte - 11 June 2001 // change by staybyte - 11 June 2001
if ($action == 'tbl_create.php') { if ($action == 'tbl_create.php') {
// find mysql capability - staybyte - 11. June 2001 // find mysql capability - staybyte - 11. June 2001
$query = 'SHOW VARIABLES LIKE \'have_%\''; $result = PMA_DBI_try_query('SHOW VARIABLES LIKE \'have_%\';');
$result = PMA_mysql_query($query);
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) { if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
while ($tmp = PMA_mysql_fetch_array($result)) { while ($tmp = PMA_DBI_fetch_assoc($result)) {
if (isset($tmp['Variable_name'])) { if (isset($tmp['Variable_name'])) {
switch ($tmp['Variable_name']) { switch ($tmp['Variable_name']) {
case 'have_bdb': case 'have_bdb':

View File

@@ -28,18 +28,18 @@ require_once('./libraries/mysql_charsets.lib.php');
if (isset($submitcomment)) { if (isset($submitcomment)) {
if (empty($prev_comment) || urldecode($prev_comment) != $comment) { if (empty($prev_comment) || urldecode($prev_comment) != $comment) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\''; $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url); $result = PMA_DBI_query($sql_query);
$message = $strSuccess; $message = $strSuccess;
} }
} }
if (isset($submittype)) { if (isset($submittype)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' TYPE = ' . $tbl_type; $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' TYPE = ' . $tbl_type;
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url); $result = PMA_DBI_query($sql_query);
$message = $strSuccess; $message = $strSuccess;
} }
if (isset($submitcharset)) { if (isset($submitcharset)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' DEFAULT CHARACTER SET = ' . $tbl_charset; $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' DEFAULT CHARACTER SET = ' . $tbl_charset;
$result = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query, '', $err_url); $result = PMA_DBI_query($sql_query);
$message = $strSuccess; $message = $strSuccess;
} }
if (isset($submitoptions)) { if (isset($submitoptions)) {
@@ -48,7 +48,7 @@ if (isset($submitoptions)) {
. (isset($checksum) ? ' checksum=1': ' checksum=0') . (isset($checksum) ? ' checksum=1': ' checksum=0')
. (isset($delay_key_write) ? ' delay_key_write=1': ' delay_key_write=0') . (isset($delay_key_write) ? ' delay_key_write=1': ' delay_key_write=0')
. (isset($auto_increment) ? ' auto_increment=' . PMA_sqlAddslashes($auto_increment) : ''); . (isset($auto_increment) ? ' auto_increment=' . PMA_sqlAddslashes($auto_increment) : '');
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url); $result = PMA_DBI_query($sql_query);
$message = $strSuccess; $message = $strSuccess;
} }
@@ -65,7 +65,7 @@ if (isset($message)) {
if (isset($submitorderby) && !empty($order_field)) { if (isset($submitorderby) && !empty($order_field)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) $sql_query = 'ALTER TABLE ' . PMA_backquote($table)
. ' ORDER BY ' . PMA_backquote(urldecode($order_field)); . ' ORDER BY ' . PMA_backquote(urldecode($order_field));
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url); $result = PMA_DBI_query($sql_query);
PMA_showMessage($strSuccess); PMA_showMessage($strSuccess);
} // end if } // end if
@@ -80,11 +80,12 @@ require('./tbl_properties_table_info.php');
* Get columns names * Get columns names
*/ */
$local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db); $local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url); $result = PMA_DBI_query($local_query);
for ($i = 0; $row = PMA_mysql_fetch_array($result); $i++) { for ($i = 0; $row = PMA_DBI_fetch_assoc($result); $i++) {
$columns[$i] = $row['Field']; $columns[$i] = $row['Field'];
} }
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
unset($result);
/** /**
@@ -296,10 +297,10 @@ echo "\n";
if ($cfgRelation['relwork'] && $tbl_type != "INNODB") { if ($cfgRelation['relwork'] && $tbl_type != "INNODB") {
// we need this PMA_mysql_select_db if the user has access to more than one db // we need this PMA_DBI_select_db if the user has access to more than one db
// and $db is not the last of the list, because PMA_availableDatabases() // and $db is not the last of the list, because PMA_availableDatabases()
// has made a PMA_mysql_select_db() on the last one // has made a PMA_DBI_select_db() on the last one
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$foreign = PMA_getForeigners($db, $table); $foreign = PMA_getForeigners($db, $table);
if ($foreign) { if ($foreign) {
@@ -369,10 +370,9 @@ if ($cfgRelation['relwork'] && $tbl_type != "INNODB") {
<!-- Table type --> <!-- Table type -->
<?php <?php
// modify robbat2 code - staybyte - 11. June 2001 // modify robbat2 code - staybyte - 11. June 2001
$query = 'SHOW VARIABLES LIKE \'have_%\''; $result = PMA_DBI_query('SHOW VARIABLES LIKE \'have_%\';');
$result = PMA_mysql_query($query);
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) { if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
while ($tmp = PMA_mysql_fetch_array($result)) { while ($tmp = PMA_DBI_fetch_assoc($result)) {
if (isset($tmp['Variable_name'])) { if (isset($tmp['Variable_name'])) {
switch ($tmp['Variable_name']) { switch ($tmp['Variable_name']) {
case 'have_bdb': case 'have_bdb':

View File

@@ -46,12 +46,11 @@ if ((!empty($submit_mult) && isset($selected_fld))
} }
// 2. Gets table keys and retains them // 2. Gets table keys and retains them
$local_query = 'SHOW KEYS FROM ' . PMA_backquote($table); $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
$primary = ''; $primary = '';
$ret_keys = array(); $ret_keys = array();
$pk_array = array(); // will be use to emphasis prim. keys in the table view $pk_array = array(); // will be use to emphasis prim. keys in the table view
while ($row = PMA_mysql_fetch_array($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
$ret_keys[] = $row; $ret_keys[] = $row;
// Backups the list of primary keys // Backups the list of primary keys
if ($row['Key_name'] == 'PRIMARY') { if ($row['Key_name'] == 'PRIMARY') {
@@ -62,8 +61,7 @@ while ($row = PMA_mysql_fetch_array($result)) {
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
// 3. Get fields // 3. Get fields
$local_query = 'SHOW FULL FIELDS FROM ' . PMA_backquote($table); $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';');
$fields_rs = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
$fields_cnt = PMA_DBI_num_rows($fields_rs); $fields_cnt = PMA_DBI_num_rows($fields_rs);
@@ -115,7 +113,7 @@ $i = 0;
$aryFields = array(); $aryFields = array();
$checked = (!empty($checkall) ? ' checked="checked"' : ''); $checked = (!empty($checkall) ? ' checked="checked"' : '');
while ($row = PMA_mysql_fetch_array($fields_rs)) { while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
$i++; $i++;
$bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
$aryFields[] = $row['Field']; $aryFields[] = $row['Field'];

View File

@@ -15,9 +15,8 @@ PMA_checkParameters(array('db', 'table'));
* Gets table informations * Gets table informations
*/ */
// The 'show table' statement works correct since 3.23.03 // The 'show table' statement works correct since 3.23.03
$local_query = 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''; $table_info_result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
$table_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); $showtable = PMA_DBI_fetch_assoc($table_info_result);
$showtable = PMA_mysql_fetch_array($table_info_result);
$tbl_type = strtoupper($showtable['Type']); $tbl_type = strtoupper($showtable['Type']);
$tbl_charset = empty($showtable['Collation']) ? '' : $showtable['Collation']; $tbl_charset = empty($showtable['Collation']) ? '' : $showtable['Collation'];
$table_info_num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); $table_info_num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);

View File

@@ -33,18 +33,12 @@ unset($sql_query);
*/ */
$fields_cnt = 0; $fields_cnt = 0;
if (isset($db) && isset($table) && $table != '' && $db != '') { if (isset($db) && isset($table) && $table != '' && $db != '') {
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db); $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';');
$result = @PMA_mysql_query($local_query); $fields_cnt = PMA_DBI_num_rows($result);
if (!$result) { while ($row = PMA_DBI_fetch_assoc($result)) {
PMA_mysqlDie('', $local_query, '', $err_url); $fields_list[] = $row['Field'];
} } // end while
else { PMA_DBI_free_result($result);
$fields_cnt = PMA_DBI_num_rows($result);
while ($row = PMA_mysql_fetch_array($result)) {
$fields_list[] = $row['Field'];
} // end while
PMA_DBI_free_result($result);
}
} }
/** /**

View File

@@ -156,7 +156,7 @@ if ($cfgRelation['relwork']
. PMA_backquote($existrel_innodb[$master_field]['constraint']); . PMA_backquote($existrel_innodb[$master_field]['constraint']);
// I tried to send both in one query but it failed // I tried to send both in one query but it failed
$upd_rs = PMA_mysql_query($upd_query); $upd_rs = PMA_DBI_query($upd_query);
} }
// add another // add another
@@ -185,8 +185,8 @@ if ($cfgRelation['relwork']
} // end if... else.... } // end if... else....
if (isset($upd_query)) { if (isset($upd_query)) {
$upd_rs = PMA_mysql_query($upd_query); $upd_rs = PMA_DBI_query($upd_query);
if (PMA_mysql_error() && mysql_errno() == 1005) { if (substr(PMA_DBI_getError(), 1, 4) == '1005') {
echo '<p class="warning">' . $strNoIndex . ' (' . $master_field .')</p>' . PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n"; echo '<p class="warning">' . $strNoIndex . ' (' . $master_field .')</p>' . PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
} }
unset($upd_query); unset($upd_query);
@@ -269,19 +269,18 @@ if ($cfgRelation['relwork']) {
} }
// [0] of the row is the name // [0] of the row is the name
$tab_rs = PMA_mysql_query($tab_query) or PMA_mysqlDie('', $tab_query, '', $err_url_0); $tab_rs = PMA_DBI_query($tab_query);
$selectboxall['nix'] = '--'; $selectboxall['nix'] = '--';
$selectboxall_innodb['nix'] = '--'; $selectboxall_innodb['nix'] = '--';
while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) { while ($curr_table = @PMA_DBI_fetch_row($tab_rs)) {
if (($curr_table[0] != $table) && ($curr_table[0] != $cfg['Server']['relation'])) { if (($curr_table[0] != $table) && ($curr_table[0] != $cfg['Server']['relation'])) {
$fi_query = 'SHOW KEYS FROM ' . PMA_backquote($curr_table[0]); $fi_rs = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($curr_table[0]) . ';');
$fi_rs = PMA_mysql_query($fi_query) or PMA_mysqlDie('', $fi_query, '', $err_url_0);
if ($fi_rs && PMA_DBI_num_rows($fi_rs) > 0) { if ($fi_rs && PMA_DBI_num_rows($fi_rs) > 0) {
$seen_a_primary=FALSE; $seen_a_primary = FALSE;
while ($curr_field = PMA_mysql_fetch_array($fi_rs)) { while ($curr_field = PMA_DBI_fetch_assoc($fi_rs)) {
if (isset($curr_field['Key_name']) && $curr_field['Key_name'] == 'PRIMARY') { if (isset($curr_field['Key_name']) && $curr_field['Key_name'] == 'PRIMARY') {
$seen_a_primary=TRUE; $seen_a_primary = TRUE;
$field_full = $db . '.' .$curr_field['Table'] . '.' . $curr_field['Column_name']; $field_full = $db . '.' .$curr_field['Table'] . '.' . $curr_field['Column_name'];
$field_v = $curr_field['Table'] . '->' . $curr_field['Column_name']; $field_v = $curr_field['Table'] . '->' . $curr_field['Column_name'];
$selectboxall[$field_full] = $field_v; $selectboxall[$field_full] = $field_v;
@@ -320,10 +319,9 @@ if ($cfgRelation['relwork']) {
// current table (see bug report #574851) // current table (see bug report #574851)
} }
else if ($curr_table[0] == $table) { else if ($curr_table[0] == $table) {
$fi_query = 'SHOW KEYS FROM ' . PMA_backquote($curr_table[0]); $fi_rs = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($curr_table[0]) . ';');
$fi_rs = PMA_mysql_query($fi_query) or PMA_mysqlDie('', $fi_query, '', $err_url_0);
if ($fi_rs && PMA_DBI_num_rows($fi_rs) > 0) { if ($fi_rs && PMA_DBI_num_rows($fi_rs) > 0) {
while ($curr_field = PMA_mysql_fetch_array($fi_rs)) { while ($curr_field = PMA_DBI_fetch_assoc($fi_rs)) {
$field_full = $db . '.' . $curr_field['Table'] . '.' . $curr_field['Column_name']; $field_full = $db . '.' . $curr_field['Table'] . '.' . $curr_field['Column_name'];
$field_v = $curr_field['Table'] . '->' . $curr_field['Column_name']; $field_v = $curr_field['Table'] . '->' . $curr_field['Column_name'];
$selectboxall[$field_full] = $field_v; $selectboxall[$field_full] = $field_v;
@@ -339,11 +337,10 @@ if ($cfgRelation['relwork']) {
// Now find out the columns of our $table // Now find out the columns of our $table
$col_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table); $col_rs = PMA_mysql_query('SHOW COLUMNS FROM ' . PMA_backquote($table) . ';');
$col_rs = PMA_mysql_query($col_query) or PMA_mysqlDie('', $col_query, '', $err_url_0);
if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) { if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) {
while ($row = PMA_mysql_fetch_array($col_rs)) { while ($row = PMA_DBI_fetch_assoc($col_rs)) {
$save_row[] = $row; $save_row[] = $row;
} }
$saved_row_cnt = count($save_row); $saved_row_cnt = count($save_row);
@@ -508,8 +505,8 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) {
<option value="">---</option> <option value="">---</option>
<?php <?php
echo "\n"; echo "\n";
mysql_data_seek($col_rs, 0); mysql_data_seek($col_rs, 0); // !UNWRAPPED FUNCTION!
while ($row = @PMA_mysql_fetch_array($col_rs)) { while ($row = @PMA_DBI_fetch_array($col_rs)) {
echo ' <option value="' . htmlspecialchars($row['Field']) . '"'; echo ' <option value="' . htmlspecialchars($row['Field']) . '"';
if (isset($disp) && $row['Field'] == $disp) { if (isset($disp) && $row['Field'] == $disp) {
echo ' selected="selected"'; echo ' selected="selected"';

View File

@@ -31,9 +31,9 @@ if (isset($new_name) && trim($new_name) != '' && strpos($new_name,'.') === FALSE
} }
require_once('./header.inc.php'); require_once('./header.inc.php');
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$sql_query = 'ALTER TABLE ' . PMA_backquote($old_name) . ' RENAME ' . PMA_backquote($new_name); $sql_query = 'ALTER TABLE ' . PMA_backquote($old_name) . ' RENAME ' . PMA_backquote($new_name) . ';';
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); $result = PMA_DBI_query($sql_query);
$message = sprintf($strRenameTableOK, htmlspecialchars($old_name), htmlspecialchars($table)); $message = sprintf($strRenameTableOK, htmlspecialchars($old_name), htmlspecialchars($table));
$reload = 1; $reload = 1;

View File

@@ -74,30 +74,30 @@ $seen_binary = FALSE;
*/ */
if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) { if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
$loop_array = (is_array($primary_key) ? $primary_key : array(0 => $primary_key)); $loop_array = (is_array($primary_key) ? $primary_key : array(0 => $primary_key));
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$query = array(); $query = array();
$message = ''; $message = '';
foreach($loop_array AS $primary_key_index => $enc_primary_key) { foreach($loop_array AS $primary_key_index => $enc_primary_key) {
// Restore the "primary key" to a convenient format // Restore the "primary key" to a convenient format
$primary_key = urldecode($enc_primary_key); $primary_key = urldecode($enc_primary_key);
// Defines the SET part of the sql query // Defines the SET part of the sql query
$valuelist = ''; $valuelist = '';
// Map multi-edit keys to single-level arrays, dependent on how we got the fields // Map multi-edit keys to single-level arrays, dependent on how we got the fields
$me_fields = (isset($fields['multi_edit']) && isset($fields['multi_edit'][$enc_primary_key]) ? $fields['multi_edit'][$enc_primary_key] : (isset($fields) ? $fields : null)); $me_fields = (isset($fields['multi_edit']) && isset($fields['multi_edit'][$enc_primary_key]) ? $fields['multi_edit'][$enc_primary_key] : (isset($fields) ? $fields : null));
$me_fields_prev = (isset($fields_prev['multi_edit']) && isset($fields_prev['multi_edit'][$enc_primary_key]) ? $fields_prev['multi_edit'][$enc_primary_key] : (isset($fields_prev) ? $fields_prev : null)); $me_fields_prev = (isset($fields_prev['multi_edit']) && isset($fields_prev['multi_edit'][$enc_primary_key]) ? $fields_prev['multi_edit'][$enc_primary_key] : (isset($fields_prev) ? $fields_prev : null));
$me_funcs = (isset($funcs['multi_edit']) && isset($funcs['multi_edit'][$enc_primary_key]) ? $funcs['multi_edit'][$enc_primary_key] : (isset($funcs) ? $funcs : null)); $me_funcs = (isset($funcs['multi_edit']) && isset($funcs['multi_edit'][$enc_primary_key]) ? $funcs['multi_edit'][$enc_primary_key] : (isset($funcs) ? $funcs : null));
$me_fields_type = (isset($fields_type['multi_edit']) && isset($fields_type['multi_edit'][$enc_primary_key]) ? $fields_type['multi_edit'][$enc_primary_key] : (isset($fields_type) ? $fields_type : null)); $me_fields_type = (isset($fields_type['multi_edit']) && isset($fields_type['multi_edit'][$enc_primary_key]) ? $fields_type['multi_edit'][$enc_primary_key] : (isset($fields_type) ? $fields_type : null));
$me_fields_null = (isset($fields_null['multi_edit']) && isset($fields_null['multi_edit'][$enc_primary_key]) ? $fields_null['multi_edit'][$enc_primary_key] : (isset($fields_null) ? $fields_null : null)); $me_fields_null = (isset($fields_null['multi_edit']) && isset($fields_null['multi_edit'][$enc_primary_key]) ? $fields_null['multi_edit'][$enc_primary_key] : (isset($fields_null) ? $fields_null : null));
foreach($me_fields AS $key => $val) { foreach($me_fields AS $key => $val) {
$encoded_key = $key; $encoded_key = $key;
$key = urldecode($key); $key = urldecode($key);
require('./tbl_replace_fields.php'); require('./tbl_replace_fields.php');
// No change for this column and no MySQL function is used -> next column // No change for this column and no MySQL function is used -> next column
if (empty($me_funcs[$encoded_key]) if (empty($me_funcs[$encoded_key])
&& isset($me_fields_prev) && isset($me_fields_prev[$encoded_key]) && isset($me_fields_prev) && isset($me_fields_prev[$encoded_key])
@@ -115,7 +115,7 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
} }
} }
} // end while } // end while
// Builds the sql update query // Builds the sql update query
$valuelist = preg_replace('@, $@', '', $valuelist); $valuelist = preg_replace('@, $@', '', $valuelist);
if (!empty($valuelist)) { if (!empty($valuelist)) {
@@ -127,7 +127,7 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
$message = $strAffectedRows . '&nbsp;'; $message = $strAffectedRows . '&nbsp;';
} }
} }
if (empty($valuelist)) { if (empty($valuelist)) {
// No change -> move back to the calling script // No change -> move back to the calling script
$message = $strNoModification; $message = $strNoModification;
@@ -150,12 +150,12 @@ else {
$loop_array = (isset($primary_key) && is_array($primary_key) ? $primary_key : array(0 => (isset($primary_key) ? $primary_key : null))); $loop_array = (isset($primary_key) && is_array($primary_key) ? $primary_key : array(0 => (isset($primary_key) ? $primary_key : null)));
$query = array(); $query = array();
$message = ''; $message = '';
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
foreach($loop_array AS $primary_key_index => $enc_primary_key) { foreach($loop_array AS $primary_key_index => $enc_primary_key) {
$fieldlist = ''; $fieldlist = '';
$valuelist = ''; $valuelist = '';
$me_fields = (isset($fields['multi_edit']) && isset($fields['multi_edit'][$enc_primary_key]) ? $fields['multi_edit'][$enc_primary_key] : (isset($fields) ? $fields : null)); $me_fields = (isset($fields['multi_edit']) && isset($fields['multi_edit'][$enc_primary_key]) ? $fields['multi_edit'][$enc_primary_key] : (isset($fields) ? $fields : null));
$me_fields_prev = (isset($fields_prev['multi_edit']) && isset($fields_prev['multi_edit'][$enc_primary_key]) ? $fields_prev['multi_edit'][$enc_primary_key] : (isset($fields_prev) ? $fields_prev : null)); $me_fields_prev = (isset($fields_prev['multi_edit']) && isset($fields_prev['multi_edit'][$enc_primary_key]) ? $fields_prev['multi_edit'][$enc_primary_key] : (isset($fields_prev) ? $fields_prev : null));
$me_funcs = (isset($funcs['multi_edit']) && isset($funcs['multi_edit'][$enc_primary_key]) ? $funcs['multi_edit'][$enc_primary_key] : (isset($funcs) ? $funcs : null)); $me_funcs = (isset($funcs['multi_edit']) && isset($funcs['multi_edit'][$enc_primary_key]) ? $funcs['multi_edit'][$enc_primary_key] : (isset($funcs) ? $funcs : null));
@@ -164,18 +164,17 @@ else {
// garvin: Get, if sent, any protected fields to insert them here: // garvin: Get, if sent, any protected fields to insert them here:
if (isset($me_fields_type) && is_array($me_fields_type) && isset($enc_primary_key)) { if (isset($me_fields_type) && is_array($me_fields_type) && isset($enc_primary_key)) {
$prot_local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . urldecode($enc_primary_key); $prot_result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . urldecode($enc_primary_key) . ';');
$prot_result = PMA_mysql_query($prot_local_query) or PMA_mysqlDie('', $prot_local_query, '', $err_url); $prot_row = PMA_DBI_fetch_assoc($prot_result);
$prot_row = PMA_mysql_fetch_array($prot_result);
} }
foreach($me_fields AS $key => $val) { foreach($me_fields AS $key => $val) {
$encoded_key = $key; $encoded_key = $key;
$key = urldecode($key); $key = urldecode($key);
$fieldlist .= PMA_backquote($key) . ', '; $fieldlist .= PMA_backquote($key) . ', ';
require('./tbl_replace_fields.php'); require('./tbl_replace_fields.php');
if (empty($me_funcs[$encoded_key])) { if (empty($me_funcs[$encoded_key])) {
$valuelist .= $val . ', '; $valuelist .= $val . ', ';
} else if (($val == '\'\'' } else if (($val == '\'\''
@@ -186,7 +185,7 @@ else {
$valuelist .= $me_funcs[$encoded_key] . '(' . $val . '), '; $valuelist .= $me_funcs[$encoded_key] . '(' . $val . '), ';
} }
} // end while } // end while
// Builds the sql insert query // Builds the sql insert query
$fieldlist = preg_replace('@, $@', '', $fieldlist); $fieldlist = preg_replace('@, $@', '', $fieldlist);
$valuelist = preg_replace('@, $@', '', $valuelist); $valuelist = preg_replace('@, $@', '', $valuelist);
@@ -205,15 +204,13 @@ $total_affected_rows = 0;
$last_message = ''; $last_message = '';
foreach($query AS $query_index => $single_query) { foreach($query AS $query_index => $single_query) {
$result = PMA_mysql_query($single_query); if ($cfg['IgnoreMultiSubmitErrors']) {
$result = PMA_DBI_try_query($single_query);
} else {
$result = PMA_DBI_query($single_query);
}
if (!$result) { if (!$result) {
if ($cfg['IgnoreMultiSubmitErrors']) { $message .= PMA_DBI_getError();
$message .= PMA_mysql_error();
} else {
$error = PMA_mysql_error();
require_once('./header.inc.php');
PMA_mysqlDie($error, '', '', $err_url);
}
} else { } else {
if (@PMA_DBI_affected_rows()) { if (@PMA_DBI_affected_rows()) {
$total_affected_rows += @PMA_DBI_affected_rows(); $total_affected_rows += @PMA_DBI_affected_rows();

View File

@@ -55,40 +55,35 @@ if (!isset($param) || $param[0] == '') {
$err_url = $goto . '?' . PMA_generate_common_url($db, $table); $err_url = $goto . '?' . PMA_generate_common_url($db, $table);
// Gets the list and number of fields // Gets the list and number of fields
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db); $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';');
$result = @PMA_mysql_query($local_query); $fields_cnt = PMA_DBI_num_rows($result);
if (!$result) { while ($row = PMA_DBI_fetch_assoc($result)) {
PMA_mysqlDie('', $local_query, '', $err_url); $fields_list[] = $row['Field'];
} $type = $row['Type'];
else { // reformat mysql query output - staybyte - 9. June 2001
$fields_cnt = PMA_DBI_num_rows($result); $shorttype = substr($type, 0, 3);
while ($row = PMA_mysql_fetch_array($result)) { if ($shorttype == 'set' || $shorttype == 'enu') {
$fields_list[] = $row['Field']; $type = str_replace(',', ', ', $type);
$type = $row['Type']; } else {
// reformat mysql query output - staybyte - 9. June 2001 $type = preg_replace('@BINARY@i', '', $type);
$shorttype = substr($type, 0, 3); $type = preg_replace('@ZEROFILL@i', '', $type);
if ($shorttype == 'set' || $shorttype == 'enu') { $type = preg_replace('@UNSIGNED@i', '', $type);
$type = str_replace(',', ', ', $type); }
} else { if (empty($type)) {
$type = preg_replace('@BINARY@i', '', $type); $type = '&nbsp;';
$type = preg_replace('@ZEROFILL@i', '', $type); }
$type = preg_replace('@UNSIGNED@i', '', $type); $fields_type[] = $type;
} } // end while
if (empty($type)) { PMA_DBI_free_result($result);
$type = '&nbsp;';
}
$fields_type[] = $type;
} // end while
PMA_DBI_free_result($result);
// <markus@noga.de> // <markus@noga.de>
// retrieve keys into foreign fields, if any // retrieve keys into foreign fields, if any
$cfgRelation = PMA_getRelationsParam(); $cfgRelation = PMA_getRelationsParam();
// check also foreigners even if relwork is FALSE (to get // check also foreigners even if relwork is FALSE (to get
// foreign keys from innodb) // foreign keys from innodb)
//$foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE); //$foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
$foreigners = PMA_getForeigners($db, $table); $foreigners = PMA_getForeigners($db, $table);
?> ?>
<form method="post" action="tbl_select.php" name="insertForm"> <form method="post" action="tbl_select.php" name="insertForm">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?> <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="goto" value="<?php echo $goto; ?>" /> <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
@@ -97,13 +92,13 @@ if (!isset($param) || $param[0] == '') {
<?php echo $strSelectFields; ?>&nbsp;:<br /> <?php echo $strSelectFields; ?>&nbsp;:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="param[]" size="<?php echo ($fields_cnt < 10) ? $fields_cnt : 10; ?>" multiple="multiple"> <select name="param[]" size="<?php echo ($fields_cnt < 10) ? $fields_cnt : 10; ?>" multiple="multiple">
<?php <?php
echo "\n"; echo "\n";
// Displays the list of the fields // Displays the list of the fields
for ($i = 0 ; $i < $fields_cnt; $i++) { for ($i = 0 ; $i < $fields_cnt; $i++) {
echo ' <option value="' . htmlspecialchars($fields_list[$i]) . '" selected="selected">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n"; echo ' <option value="' . htmlspecialchars($fields_list[$i]) . '" selected="selected">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
} }
?> ?>
</select><br /> </select><br />
<ul> <ul>
<li> <li>
@@ -125,95 +120,95 @@ if (!isset($param) || $param[0] == '') {
<th><?php echo $strFunction; ?></th> <th><?php echo $strFunction; ?></th>
<th><?php echo $strValue; ?></th> <th><?php echo $strValue; ?></th>
</tr> </tr>
<?php <?php
for ($i = 0; $i < $fields_cnt; $i++) { for ($i = 0; $i < $fields_cnt; $i++) {
echo "\n"; echo "\n";
$bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
?> ?>
<tr> <tr>
<td bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($fields_list[$i]); ?></td> <td bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($fields_list[$i]); ?></td>
<td bgcolor="<?php echo $bgcolor; ?>"><?php echo $fields_type[$i]; ?></td> <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $fields_type[$i]; ?></td>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
<select name="func[]"> <select name="func[]">
<?php <?php
if (preg_match('@char|blob|text|set|enum@i', $fields_type[$i])) { if (preg_match('@char|blob|text|set|enum@i', $fields_type[$i])) {
foreach($textfunctions AS $k => $fc) { foreach($textfunctions AS $k => $fc) {
echo "\n" . ' ' echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">' . htmlspecialchars($fc) . '</option>'; . '<option value="' . htmlspecialchars($fc) . '">' . htmlspecialchars($fc) . '</option>';
} // end while } // end while
} else { } else {
foreach($numfunctions AS $k => $fc) { foreach($numfunctions AS $k => $fc) {
echo "\n" . ' ' echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">' . htmlspecialchars($fc) . '</option>'; . '<option value="' . htmlspecialchars($fc) . '">' . htmlspecialchars($fc) . '</option>';
} // end while } // end while
} // end if... else... } // end if... else...
echo "\n"; echo "\n";
?> ?>
</select> </select>
</td> </td>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
<?php <?php
// <markus@noga.de> // <markus@noga.de>
$field = $fields_list[$i]; $field = $fields_list[$i];
// do not use require_once here // do not use require_once here
require('./libraries/get_foreign.lib.php'); require('./libraries/get_foreign.lib.php');
echo "\n"; echo "\n";
// we got a bug report: in some cases, even if $disp is true, // we got a bug report: in some cases, even if $disp is true,
// there are no rows, so we add a fetch_array // there are no rows, so we add a fetch_array
if ($foreigners && isset($foreigners[$field]) && isset($disp) && $disp && @PMA_mysql_fetch_array($disp)) { if ($foreigners && isset($foreigners[$field]) && isset($disp) && $disp && PMA_DBI_fetch_row($disp)) {
// f o r e i g n k e y s // f o r e i g n k e y s
echo ' <select name="fields[]">' . "\n"; echo ' <select name="fields[]">' . "\n";
// go back to first row // go back to first row
mysql_data_seek($disp,0); mysql_data_seek($disp,0); // !UNWRAPPED FUNCTION!
echo PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, 100); echo PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, 100);
echo ' </select>' . "\n"; echo ' </select>' . "\n";
} else if (isset($foreign_link) && $foreign_link == true) { } else if (isset($foreign_link) && $foreign_link == true) {
?> ?>
<input type="text" name="fields[]" id="field_<?php echo md5($field); ?>[]" class="textfield" /> <input type="text" name="fields[]" id="field_<?php echo md5($field); ?>[]" class="textfield" />
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
document.writeln('<a target="_blank" onclick="window.open(this.href, \'foreigners\', \'width=640,height=240,scrollbars=yes\'); return false" href="browse_foreigners.php?<?php echo PMA_generate_common_url($db, $table); ?>&amp;field=<?php echo urlencode($field); ?>"><?php echo str_replace("'", "\'", $titles['Browse']); ?></a>'); document.writeln('<a target="_blank" onclick="window.open(this.href, \'foreigners\', \'width=640,height=240,scrollbars=yes\'); return false" href="browse_foreigners.php?<?php echo PMA_generate_common_url($db, $table); ?>&amp;field=<?php echo urlencode($field); ?>"><?php echo str_replace("'", "\'", $titles['Browse']); ?></a>');
</script> </script>
<?php <?php
} else if (substr($fields_type[$i], 0, 3)=='enu'){ } else if (substr($fields_type[$i], 0, 3)=='enu'){
// e n u m s // e n u m s
$enum_value=explode(', ', str_replace("'", '', substr($fields_type[$i], 5, -1))); $enum_value=explode(', ', str_replace("'", '', substr($fields_type[$i], 5, -1)));
echo ' <select name="fields[]">' . "\n"; echo ' <select name="fields[]">' . "\n";
echo ' <option value=""></option>' . "\n"; echo ' <option value=""></option>' . "\n";
$cnt_enum_value = count($enum_value); $cnt_enum_value = count($enum_value);
for ($j=0; $j<$cnt_enum_value;$j++){ for ($j=0; $j<$cnt_enum_value;$j++){
echo ' <option value="' . $enum_value[$j] . '">' . $enum_value[$j] . '</option>'; echo ' <option value="' . $enum_value[$j] . '">' . $enum_value[$j] . '</option>';
} // end for } // end for
echo ' </select>' . "\n"; echo ' </select>' . "\n";
} else { } else {
// o t h e r c a s e s // o t h e r c a s e s
echo ' <input type="text" name="fields[]" size="40" class="textfield" />' . "\n"; echo ' <input type="text" name="fields[]" size="40" class="textfield" />' . "\n";
} }
?> ?>
<input type="hidden" name="names[]" value="<?php echo htmlspecialchars($fields_list[$i]); ?>" /> <input type="hidden" name="names[]" value="<?php echo htmlspecialchars($fields_list[$i]); ?>" />
<input type="hidden" name="types[]" value="<?php echo $fields_type[$i]; ?>" /> <input type="hidden" name="types[]" value="<?php echo $fields_type[$i]; ?>" />
</td> </td>
</tr> </tr>
<?php <?php
} // end for } // end for
echo "\n"; echo "\n";
?> ?>
</table><br /> </table><br />
</li> </li>
<li> <li>
<?php echo $strDisplayOrder; ?><br /> <?php echo $strDisplayOrder; ?><br />
<select name="orderField" style="vertical-align: middle"> <select name="orderField" style="vertical-align: middle">
<option value="--nil--"></option> <option value="--nil--"></option>
<?php <?php
echo "\n"; echo "\n";
for ($i = 0; $i < $fields_cnt; $i++) { for ($i = 0; $i < $fields_cnt; $i++) {
echo ' '; echo ' ';
echo '<option value="' . htmlspecialchars($fields_list[$i]) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n"; echo '<option value="' . htmlspecialchars($fields_list[$i]) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
} // end for } // end for
?> ?>
</select> </select>
<input type="radio" name="order" value="ASC" checked="checked" /> <input type="radio" name="order" value="ASC" checked="checked" />
<?php echo $strAscending; ?>&nbsp; <?php echo $strAscending; ?>&nbsp;
@@ -226,8 +221,7 @@ if (!isset($param) || $param[0] == '') {
<input type="hidden" name="max_number_of_fields" value="<?php echo $fields_cnt; ?>" /> <input type="hidden" name="max_number_of_fields" value="<?php echo $fields_cnt; ?>" />
<input type="submit" name="submit" value="<?php echo $strGo; ?>" /> <input type="submit" name="submit" value="<?php echo $strGo; ?>" />
</form> </form>
<?php <?php
} // end if
require_once('./footer.inc.php'); require_once('./footer.inc.php');
} }

View File

@@ -26,16 +26,14 @@ require_once('./libraries/db_table_exists.lib.php');
/** /**
* Get the list of the fields of the current table * Get the list of the fields of the current table
*/ */
PMA_mysql_select_db($db); PMA_DBI_select_db($db);
$table_def = PMA_mysql_query('SHOW FIELDS FROM ' . PMA_backquote($table)); $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table));
if (isset($primary_key)) { if (isset($primary_key)) {
$local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key; $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', ''); $row = PMA_DBI_fetch_assoc($result);
$row = PMA_mysql_fetch_array($result);
} else { } else {
$local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1'; $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;');
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', ''); $row = PMA_DBI_fetch_assoc($result);
$row = PMA_mysql_fetch_array($result);
} }
// No row returned // No row returned

View File

@@ -14,7 +14,7 @@ require_once('./libraries/common.lib.php');
* script * script
*/ */
if (!$cfg['ShowChgPassword']) { if (!$cfg['ShowChgPassword']) {
$cfg['ShowChgPassword'] = @PMA_mysql_query('USE mysql', $userlink); $cfg['ShowChgPassword'] = PMA_DBI_select_db('mysql');
} }
if ($cfg['Server']['auth_type'] == 'config' || !$cfg['ShowChgPassword']) { if ($cfg['Server']['auth_type'] == 'config' || !$cfg['ShowChgPassword']) {
require_once('./header.inc.php'); require_once('./header.inc.php');
@@ -50,7 +50,7 @@ if (isset($nopass)) {
$sql_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')'); $sql_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
$local_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . PMA_sqlAddslashes($pma_pw) . '\')'); $local_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . PMA_sqlAddslashes($pma_pw) . '\')');
$result = @PMA_mysql_query($local_query) or PMA_mysqlDie('', '', FALSE, $err_url); $result = @PMA_DBI_try_query($local_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, FALSE, $err_url);
// Changes password cookie if required // Changes password cookie if required
if ($cfg['Server']['auth_type'] == 'cookie') { if ($cfg['Server']['auth_type'] == 'cookie') {