From 7358f5a712f8329a84807dbb27d5a574c3214494 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Sat, 14 Jan 2006 23:17:17 +0000 Subject: [PATCH] allow 0 as name for database, table collumn, alias and index --- ChangeLog | 15 +++++++ db_operations.php | 2 +- export.php | 4 +- index.php | 4 +- left.php | 4 +- libraries/auth/cookie.auth.lib.php | 4 +- libraries/common.lib.php | 18 ++++----- libraries/db_details_common.inc.php | 4 +- libraries/db_table_exists.lib.php | 10 ++--- libraries/display_export.lib.php | 4 +- libraries/display_tbl.lib.php | 16 ++++---- libraries/export/sql.php | 2 +- libraries/footer.inc.php | 2 +- libraries/header.inc.php | 4 +- libraries/left_header.inc.php | 4 +- libraries/mult_submits.inc.php | 59 ++++++++++++++------------- libraries/mysql_charsets.lib.php | 2 +- libraries/relation.lib.php | 11 ++--- libraries/server_common.inc.php | 2 +- libraries/sql_query_form.lib.php | 12 +++--- libraries/sqlparser.lib.php | 6 +-- libraries/tbl_indexes.lib.php | 3 +- libraries/tbl_move_copy.php | 4 +- libraries/url_generating.lib.php | 8 ++-- querywindow.php | 14 +++---- scripts/setup.php | 2 +- server_databases.php | 2 +- server_privileges.php | 62 +++++++++++++++-------------- server_processlist.php | 2 +- sql.php | 27 ++++++------- tbl_addfield.php | 18 ++++----- tbl_alter.php | 4 +- tbl_change.php | 2 +- tbl_create.php | 24 +++++------ tbl_indexes.php | 8 ++-- tbl_replace.php | 8 ++-- 36 files changed, 195 insertions(+), 182 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ec89cecf..c0cb53c03 100755 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,21 @@ $Source$ * libraries/display_export.lib.php, css/phpmyadmin.css.php, themes/*/css/theme_right.css.php: 'fixed' layout of export screen for buggy safari and opera + * db_operations.php, export.php, index.php, left.php, + libraries\auth\cookie.auth.lib.php, libraries\common.lib.php, + libraries\db_details_common.inc.php, libraries\db_table_exists.lib.php, + libraries\display_export.lib.php, libraries\display_tbl.lib.php, + libraries\export\sql.php, libraries\footer.inc.php, + libraries\header.inc.php, libraries\left_header.inc.php, + libraries\mult_submits.inc.php, libraries\mysql_charsets.lib.php, + libraries\relation.lib.php, libraries\server_common.inc.php, + libraries\sql_query_form.lib.php, libraries\sqlparser.lib.php, + libraries\tbl_indexes.lib.php, libraries\tbl_move_copy.php, + libraries\url_generating.lib.php, querywindow.php, scripts\setup.php, + server_databases.php, server_privileges.php, server_processlist.php, + sql.php, tbl_addfield.php, tbl_alter.php, tbl_change.php, tbl_create.php, + tbl_indexes.php, tbl_replace.php: + allow 0 as name for database, table collumn, alias and index 2006-01-12 Marc Delisle * Documentation.html: typo, thanks to Cédric Corazza diff --git a/db_operations.php b/db_operations.php index d28f96727..3f3788b7d 100644 --- a/db_operations.php +++ b/db_operations.php @@ -33,7 +33,7 @@ if (isset($db) && $move = FALSE; } - if (!isset($newname) || empty($newname)) { + if (!isset($newname) || !strlen($newname)) { $message = $strDatabaseEmpty; } else { if ($move || diff --git a/export.php b/export.php index 0bc0ad0de..3f3de6544 100644 --- a/export.php +++ b/export.php @@ -23,9 +23,9 @@ require('./libraries/export/' . PMA_securePath($type) . '.php'); // Generate error url if ($export_type == 'server') { $err_url = 'server_export.php?' . PMA_generate_common_url(); -} elseif ($export_type == 'database' && !empty($db)) { +} elseif ($export_type == 'database' && isset($db) && strlen($db)) { $err_url = 'db_details_export.php?' . PMA_generate_common_url($db); -} elseif ($export_type == 'table' && !empty($db) && !empty($table)) { +} elseif ($export_type == 'table' && isset($db) && strlen($db) && isset($table) && strlen($table)) { $err_url = 'tbl_properties_export.php?' . PMA_generate_common_url($db, $table); } else { die('Bad parameters!'); diff --git a/index.php b/index.php index 5f4498814..119da4642 100644 --- a/index.php +++ b/index.php @@ -79,9 +79,9 @@ foreach( $drops as $each_drop ) { } unset( $drops, $each_drop ); -if ( empty( $GLOBALS['db'] ) ) { +if ( ! isset($GLOBALS['db']) || ! strlen($GLOBALS['db']) ) { $main_target = $GLOBALS['cfg']['DefaultTabServer']; -} elseif ( empty( $GLOBALS['table'] ) ) { +} elseif ( ! isset($GLOBALS['table']) || ! strlen($GLOBALS['table']) ) { $_GET['db'] = $GLOBALS['db']; $main_target = $GLOBALS['cfg']['DefaultTabDatabase']; } else { diff --git a/left.php b/left.php index 605cf3412..808bf9f40 100644 --- a/left.php +++ b/left.php @@ -35,7 +35,7 @@ if ($server > 0) { // it defines $num_dbs and $dblist PMA_availableDatabases(); - if ( empty( $db ) && count( $dblist ) === 1 ) { + if ( ( ! isset($db) || ! strlen($db) ) && count( $dblist ) === 1 ) { reset( $dblist ); $db = current( $dblist ); } @@ -175,7 +175,7 @@ $href_left = '', ' $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; - if (!empty($alias)) { + if (strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $column_for_condition = $true_column; @@ -2463,8 +2463,8 @@ window.parent.updateTableTitle('', '', ' back to the welcome page - if (!empty($db)) { + if (isset($db) && strlen($db)) { $is_db = PMA_DBI_select_db($db); } - if (empty($db) || !$is_db) { + if (!isset($db) || !strlen($db) || !$is_db) { PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); exit; } diff --git a/libraries/db_table_exists.lib.php b/libraries/db_table_exists.lib.php index a5a7aaf97..ce5e33a32 100644 --- a/libraries/db_table_exists.lib.php +++ b/libraries/db_table_exists.lib.php @@ -8,10 +8,10 @@ */ if (!isset($is_db) || !$is_db) { // Not a valid db name -> back to the welcome page - if (!empty($db)) { + if (isset($db) && strlen($db)) { $is_db = @PMA_DBI_select_db($db); } - if (empty($db) || !$is_db) { + if (!isset($db) || !strlen($db) || !$is_db) { if (!defined('IS_TRANSFORMATION_WRAPPER')) { PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); } @@ -20,15 +20,15 @@ if (!isset($is_db) || !$is_db) { } // end if (ensures db exists) if (!isset($is_table) || !$is_table) { // Not a valid table name -> back to the db_details.php - if (!empty($table)) { + if (isset($table) && strlen($table)) { $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', NULL, PMA_DBI_QUERY_STORE); } - if (empty($table) + if (! isset($table) && ! strlen($table) || !($is_table && @PMA_DBI_num_rows($is_table))) { $redirect = TRUE; if (!defined('IS_TRANSFORMATION_WRAPPER')) { $redirect = TRUE; - if (!empty($table)) { + if (isset($table) && strlen($table)) { PMA_DBI_free_result($is_table); // SHOW TABLES doesn't show temporary tables, so try select (as it can happen just in case temporary table, it should be fast): $is_table2 = PMA_DBI_try_query('SELECT COUNT(*) FROM `' . PMA_sqlAddslashes($table, TRUE) . '`;', NULL, PMA_DBI_QUERY_STORE); diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index 764636acd..cdb913095 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -36,7 +36,7 @@ function PMA_exportIsActive($what, $val) { - +
table)) ) { + && isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table)) ) { $sort_tbl = PMA_backquote($fields_meta[$i]->table) . ' . '; } else { $sort_tbl = ''; @@ -1229,7 +1229,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; - if (!empty($alias)) { + if (isset($alias) && strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $meta->name = $true_column; @@ -1240,7 +1240,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { if (isset($map[$meta->name])) { // Field to display from the foreign table? - if (!empty($map[$meta->name][2])) { + if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) { $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) @@ -1355,7 +1355,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; - if (!empty($alias)) { + if (isset($alias) && strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $meta->name = $true_column; @@ -1366,7 +1366,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { if (isset($map[$meta->name])) { // Field to display from the foreign table? - if (!empty($map[$meta->name][2])) { + if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) { $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) @@ -1756,7 +1756,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) $tabs = '(\'' . join('\',\'', $target) . '\')'; if ($cfgRelation['displaywork']) { - if (empty($table)) { + if (! isset($table) || ! strlen($table)) { $exist_rel = FALSE; } else { $exist_rel = PMA_getForeigners($db, $table, '', 'both'); diff --git a/libraries/export/sql.php b/libraries/export/sql.php index e39ac6a10..daebc9f83 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -560,7 +560,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) // a binary field // Note: with mysqli, under MySQL 4.1.3, we get the flag // "binary" for those field types (I don't know why) - } else if (stristr($field_flags[$j], 'BINARY') + } elseif (stristr($field_flags[$j], 'BINARY') && isset($GLOBALS['hexforbinary']) && $fields_meta[$j]->type != 'datetime' && $fields_meta[$j]->type != 'date' diff --git a/libraries/footer.inc.php b/libraries/footer.inc.php index c0d083956..507c3cdbf 100644 --- a/libraries/footer.inc.php +++ b/libraries/footer.inc.php @@ -21,7 +21,7 @@ require_once('./libraries/relation.lib.php'); // for PMA_setHistory()