Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow 0 as name for database, table collumn, alias and index

  • Loading branch information...
commit 7358f5a712f8329a84807dbb27d5a574c3214494 1 parent f298dca
Sebastian Mendel authored
Showing with 195 additions and 182 deletions.
  1. +15 −0 ChangeLog
  2. +1 −1  db_operations.php
  3. +2 −2 export.php
  4. +2 −2 index.php
  5. +2 −2 left.php
  6. +2 −2 libraries/auth/cookie.auth.lib.php
  7. +9 −9 libraries/common.lib.php
  8. +2 −2 libraries/db_details_common.inc.php
  9. +5 −5 libraries/db_table_exists.lib.php
  10. +2 −2 libraries/display_export.lib.php
  11. +8 −8 libraries/display_tbl.lib.php
  12. +1 −1  libraries/export/sql.php
  13. +1 −1  libraries/footer.inc.php
  14. +2 −2 libraries/header.inc.php
  15. +2 −2 libraries/left_header.inc.php
  16. +29 −30 libraries/mult_submits.inc.php
  17. +1 −1  libraries/mysql_charsets.lib.php
  18. +6 −5 libraries/relation.lib.php
  19. +1 −1  libraries/server_common.inc.php
  20. +5 −7 libraries/sql_query_form.lib.php
  21. +3 −3 libraries/sqlparser.lib.php
  22. +2 −1  libraries/tbl_indexes.lib.php
  23. +3 −1 libraries/tbl_move_copy.php
  24. +4 −4 libraries/url_generating.lib.php
  25. +6 −8 querywindow.php
  26. +1 −1  scripts/setup.php
  27. +1 −1  server_databases.php
  28. +32 −30 server_privileges.php
  29. +1 −1  server_processlist.php
  30. +12 −15 sql.php
  31. +9 −9 tbl_addfield.php
  32. +2 −2 tbl_alter.php
  33. +1 −1  tbl_change.php
  34. +12 −12 tbl_create.php
  35. +4 −4 tbl_indexes.php
  36. +4 −4 tbl_replace.php
View
15 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 <lem9@users.sourceforge.net>
* Documentation.html: typo, thanks to Cédric Corazza
View
2  db_operations.php
@@ -33,7 +33,7 @@
$move = FALSE;
}
- if (!isset($newname) || empty($newname)) {
+ if (!isset($newname) || !strlen($newname)) {
$message = $strDatabaseEmpty;
} else {
if ($move ||
View
4 export.php
@@ -23,9 +23,9 @@
// 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!');
View
4 index.php
@@ -79,9 +79,9 @@
}
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 {
View
4 left.php
@@ -35,7 +35,7 @@
// 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 @@ function toggle( id, only_open ) {
$element_counter = 0;
-if ( $GLOBALS['cfg']['LeftFrameLight'] && ! empty( $db ) ) {
+if ( $GLOBALS['cfg']['LeftFrameLight'] && isset($db) && strlen($db) ) {
// show selected databasename as link to DefaultTabDatabase-page
// with table count in ()
$common_url_query = PMA_generate_common_url( $db );
View
4 libraries/auth/cookie.auth.lib.php
@@ -467,10 +467,10 @@ function PMA_auth_set_user()
// any parameters to pass?
$url_params = array();
- if ( ! empty($GLOBALS['db']) ) {
+ if ( isset($GLOBALS['db']) && strlen($GLOBALS['db']) ) {
$url_params['db'] = $GLOBALS['db'];
}
- if ( ! empty($GLOBALS['table']) ) {
+ if ( isset($GLOBALS['table']) && strlen($GLOBALS['table']) ) {
$url_params['table'] = $GLOBALS['table'];
}
// Language change from the login panel needs to be remembered
View
18 libraries/common.lib.php
@@ -264,7 +264,7 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $userlink,
// with regular expressions.
while ($row = PMA_DBI_fetch_assoc($rs)) {
// loic1: all databases cases - part 1
- if (empty($row['Db']) || $row['Db'] == '%') {
+ if ( !isset($row['Db']) || ! strlen($row['Db']) || $row['Db'] == '%') {
$uva_mydbs['%'] = 1;
break;
}
@@ -1151,7 +1151,7 @@ function PMA_backquote($a_name, $do_it = true)
{
// '0' is also empty for php :-(
if ($do_it
- && (!empty($a_name) || $a_name == '0') && $a_name != '*') {
+ && strlen($a_name) && $a_name != '*') {
if (is_array($a_name)) {
$result = array();
@@ -1312,7 +1312,7 @@ function PMA_showMessage($message)
$message = PMA_sanitize($message);
// Corrects the tooltip text via JS if required
- if (!empty($GLOBALS['table']) && $cfg['ShowTooltip']) {
+ if ( isset($GLOBALS['table']) && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) {
$result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
if ($result) {
$tbl_status = PMA_DBI_fetch_assoc($result);
@@ -2152,7 +2152,7 @@ function PMA_getUvaCondition($handle, $fields_cnt, $fields_meta, $row)
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 (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 @@ function PMA_userDir($dir)
*/
function PMA_getDbLink($database = null)
{
- if (empty($database)) {
- if (empty($GLOBALS['db'])) {
+ if (!strlen($database)) {
+ if (!strlen($GLOBALS['db'])) {
return '';
}
$database = $GLOBALS['db'];
@@ -2508,17 +2508,17 @@ function PMA_removeCookie($cookie)
*/
function PMA_setCookie($cookie, $value, $default = null)
{
- if (!empty($value) && null !== $default && $value === $default) {
+ if (strlen($value) && null !== $default && $value === $default) {
// remove cookie, default value is used
return PMA_removeCookie($cookie);
}
- if (empty($value) && isset($_COOKIE[$cookie])) {
+ if (! strlen($value) && isset($_COOKIE[$cookie])) {
// remove cookie, value is empty
return PMA_removeCookie($cookie);
}
- if (empty($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) {
+ if (! isset($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) {
// set cookie with new value
return setcookie($cookie, $value, time() + 60*60*24*30,
$GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
View
4 libraries/db_details_common.inc.php
@@ -30,10 +30,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) {
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit;
}
View
10 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 @@
} // 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);
View
4 libraries/display_export.lib.php
@@ -36,7 +36,7 @@ function PMA_exportIsActive($what, $val) {
<?php
$hide_structure = false;
$hide_sql = false;
-$hide_xml = empty($db);
+$hide_xml = (bool) (isset($db) && strlen($db));
if ($export_type == 'server') {
echo PMA_generate_common_hidden_inputs('', '', 1);
} elseif ($export_type == 'database') {
@@ -769,7 +769,7 @@ function show_checked_option() {
//]]>
</script>
-<?php if ( ! empty( $table ) && ! isset( $num_tables ) ) { ?>
+<?php if ( isset($table) && strlen($table) && ! isset( $num_tables ) ) { ?>
<div class="formelementrow">
<?php
echo sprintf( $strDumpXRows,
View
16 libraries/display_tbl.lib.php
@@ -30,7 +30,7 @@
* the "display printable view" option.
* Of course '0'/'1' means the feature won't/will be enabled.
*
- * @param string the synthetic value for display_mode (see §1 a few
+ * @param string the synthetic value for display_mode (see 1 a few
* lines above for explanations)
* @param integer the total number of rows returned by the sql query
* without any programmatically appended "LIMIT" clause
@@ -157,7 +157,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
$the_total = $unlim_num_rows;
}
else if (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
- && (!empty($db) && !empty($table))) {
+ && (isset($db) && strlen($db) && !empty($table))) {
$the_total = PMA_countRecords($db, $table, TRUE);
}
@@ -741,7 +741,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
&& isset($analyzed_sql[0]['select_expr'][$i]['column'])
&& $analyzed_sql[0]['select_expr'][$i]['expr'] !=
$analyzed_sql[0]['select_expr'][$i]['column']
- && !empty($fields_meta[$i]->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');
View
2  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'
View
2  libraries/footer.inc.php
@@ -21,7 +21,7 @@
<script type="text/javascript" language="javascript">
//<![CDATA[
<?php
- if ( ! isset( $GLOBALS['no_history'] ) && ! empty( $GLOBALS['db'] ) && empty( $GLOBALS['error_message'] ) ) {
+ if ( ! isset( $GLOBALS['no_history'] ) && isset( $GLOBALS['db'] ) && strlen($GLOBALS['db']) && empty( $GLOBALS['error_message'] ) ) {
$table = isset( $GLOBALS['table'] ) ? $GLOBALS['table'] : '';
// updates current settings
?>
View
4 libraries/header.inc.php
@@ -166,7 +166,7 @@
$GLOBALS['strServer'],
's_host.png' );
- if (!empty($GLOBALS['db'])) {
+ if (isset($GLOBALS['db']) && strlen($GLOBALS['db'])) {
echo $separator;
printf( $item,
@@ -176,7 +176,7 @@
$GLOBALS['strDatabase'],
's_db.png' );
- if (!empty($GLOBALS['table'])) {
+ if (isset($GLOBALS['table']) && strlen($GLOBALS['table'])) {
require_once('./libraries/tbl_properties_table_info.inc.php');
echo $separator;
View
4 libraries/left_header.inc.php
@@ -8,8 +8,8 @@
*/
if ( empty( $query_url ) ) {
- $db = empty( $db ) ? '' : $db;
- $table = empty( $table ) ? '' : $table;
+ $db = ! isset( $db ) ? '' : $db;
+ $table = ! isset( $table ) ? '' : $table;
$query_url = PMA_generate_common_url( $db, $table );
}
View
59 libraries/mult_submits.inc.php
@@ -8,16 +8,16 @@
*/
if (!empty($submit_mult)
&& ($submit_mult != $strWithChecked)
- && ( !empty($selected_db)
- || !empty($selected_tbl)
- || !empty($selected_fld)
+ && ( ( isset($selected_db) && strlen($selected_db) )
+ || ( isset($selected_tbl) && strlen($selected_tbl) )
+ || ( isset($selected_fld) && strlen($selected_fld) )
|| !empty($rows_to_delete)
)) {
- if (!empty($selected_db)) {
+ if (isset($selected_db) && strlen($selected_db)) {
$selected = $selected_db;
$what = 'drop_db';
- } elseif (!empty($selected_tbl)) {
+ } elseif (isset($selected_tbl) && strlen($selected_tbl)) {
if ($submit_mult == $strPrintView) {
require('./tbl_printview.php');
} else {
@@ -54,7 +54,7 @@
break;
} // end switch
}
- } elseif (!empty($selected_fld)) {
+ } elseif (isset($selected_fld) && strlen($selected_fld)) {
$selected = $selected_fld;
switch ($submit_mult) {
case $strDrop:
@@ -126,12 +126,11 @@
if ( !empty($submit_mult) && !empty($what)) {
$js_to_run = 'functions.js';
unset($message);
- if (!empty($table)) {
+ if (isset($table) && strlen($table)) {
require('./libraries/tbl_properties_common.php');
$url_query .= '&amp;goto=tbl_properties.php&amp;back=tbl_properties.php';
require('./libraries/tbl_properties_table_info.inc.php');
- }
- elseif (!empty($db)) {
+ } elseif (isset($db) && strlen($db)) {
require('./libraries/db_details_common.inc.php');
require('./libraries/db_details_db_info.inc.php');
}
@@ -155,11 +154,11 @@
break;
case 'drop_tbl':
- $current = urldecode($sval);
- if (!empty($views) && in_array($current, $views)) {
+ $current = urldecode($sval);
+ if (!empty($views) && in_array($current, $views)) {
$full_query_views .= (empty($full_query_views) ? 'DROP VIEW ' : ', ')
. PMA_backquote(htmlspecialchars($current));
- } else {
+ } else {
$full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ')
. PMA_backquote(htmlspecialchars($current));
}
@@ -215,12 +214,12 @@
}
if ($what == 'drop_tbl') {
if (!empty($full_query)) {
- $full_query .= ';<br />' . "\n";
- }
- if (!empty($full_query_views)) {
- $full_query .= $full_query_views . ';<br />' . "\n";
- }
- unset($full_query_views);
+ $full_query .= ';<br />' . "\n";
+ }
+ if (!empty($full_query_views)) {
+ $full_query .= $full_query_views . ';<br />' . "\n";
+ }
+ unset($full_query_views);
}
// Displays the form
@@ -317,10 +316,10 @@
case 'drop_tbl':
PMA_relationsCleanupTable($db, $selected[$i]);
- $current = urldecode($selected[$i]);
- if (!empty($views) && in_array($current, $views)) {
- $sql_query_views .= (empty($sql_query_views) ? 'DROP VIEW ' : ', ')
- . PMA_backquote($current);
+ $current = urldecode($selected[$i]);
+ if (!empty($views) && in_array($current, $views)) {
+ $sql_query_views .= (empty($sql_query_views) ? 'DROP VIEW ' : ', ')
+ . PMA_backquote($current);
} else {
$sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ')
. PMA_backquote($current);
@@ -407,9 +406,9 @@
if ($query_type == 'drop_tbl') {
if (!empty($sql_query)) {
- $sql_query .= ';';
- } else if (!empty($sql_query_views)) {
- $sql_query = $sql_query_views . ';';
+ $sql_query .= ';';
+ } elseif (!empty($sql_query_views)) {
+ $sql_query = $sql_query_views . ';';
unset($sql_query_views);
}
}
@@ -419,11 +418,11 @@
} elseif (!$run_parts) {
PMA_DBI_select_db($db);
$result = PMA_DBI_query($sql_query);
- if (!empty($sql_query_views)) {
- $sql_query .= ' ' . $sql_query_views . ';';
- PMA_DBI_query($sql_query_views);
- unset($sql_query_views);
- }
+ if (!empty($sql_query_views)) {
+ $sql_query .= ' ' . $sql_query_views . ';';
+ PMA_DBI_query($sql_query_views);
+ unset($sql_query_views);
+ }
}
}
?>
View
2  libraries/mysql_charsets.lib.php
@@ -122,7 +122,7 @@ function PMA_getDbCollation( $db ) {
// for databases.
PMA_DBI_select_db( $db );
$return = PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE "collation_database"', 0, 1 );
- if ( ! empty( $GLOBALS['db'] ) && $db !== $GLOBALS['db'] ) {
+ if ( isset( $GLOBALS['db'] ) && $db !== $GLOBALS['db'] ) {
PMA_DBI_select_db( $GLOBALS['db'] );
}
return $return;
View
11 libraries/relation.lib.php
@@ -295,7 +295,7 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') {
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '
WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'
AND master_table = \'' . PMA_sqlAddslashes($table) . '\' ';
- if (!empty($column)) {
+ if (isset($column) && strlen($column)) {
$rel_query .= ' AND master_field = \'' . PMA_sqlAddslashes($column) . '\'';
}
$relations = PMA_query_as_cu($rel_query);
@@ -311,7 +311,7 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') {
unset($relations);
}
- if (($source == 'both' || $source == 'innodb') && !empty($table)) {
+ if (($source == 'both' || $source == 'innodb') && isset($table) && strlen($table)) {
$show_create_table_query = 'SHOW CREATE TABLE '
. PMA_backquote($db) . '.' . PMA_backquote($table);
$show_create_table_res = PMA_DBI_query($show_create_table_query);
@@ -372,7 +372,8 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') {
if (isset($GLOBALS['information_schema_relations'][$table])) {
foreach ($GLOBALS['information_schema_relations'][$table] as $field => $relations) {
- if ((empty($column) || $column == $field) && empty($foreign[$field])) {
+ if ( ( ! isset($column) || ! strlen($column) || $column == $field )
+ && ( ! isset($foreign[$field]) || ! strlen($foreign[$field]) ) ) {
$foreign[$field] = $relations;
}
}
@@ -513,7 +514,7 @@ function PMA_getComments($db, $table = '') {
$comment[$col] = $row['comment'];
// if this version supports native comments and this function
// was called with a table parameter
- if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($table)) {
+ if (PMA_MYSQL_INT_VERSION >= 40100 && isset($table) && strlen($table)) {
// if native comment found, use it instead of pmadb
if (!empty($native_comment[$col])) {
$comment[$col] = $native_comment[$col];
@@ -579,7 +580,7 @@ function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode='aut
}
// native mode is only for column comments so we need a table name
- if ($mode == 'native' && !empty($table)) {
+ if ($mode == 'native' && isset($table) && strlen($table)) {
$query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE '
. PMA_generateAlterTable($col, $col, '', '', '', '', FALSE, '', FALSE, '', $comment, '', '');
PMA_DBI_try_query($query, NULL, PMA_DBI_QUERY_STORE);
View
2  libraries/server_common.inc.php
@@ -20,7 +20,7 @@
/**
* Set parameters for links
*/
-$url_query = PMA_generate_common_url((!empty($db) ? $db : ''));
+$url_query = PMA_generate_common_url((isset($db) ? $db : ''));
/**
* Defines the urls to return to in case of error in a sql statement
View
12 libraries/sql_query_form.lib.php
@@ -81,12 +81,11 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
$table = '';
$db = '';
- if ( empty( $GLOBALS['db'] ) ) {
+ if ( ! isset( $GLOBALS['db'] ) || ! strlen($GLOBALS['db']) ) {
// prepare for server related
$goto = empty( $GLOBALS['goto'] ) ?
'server_sql.php' : $GLOBALS['goto'];
- }
- elseif ( empty( $GLOBALS['table'] ) ) {
+ } elseif ( ! isset( $GLOBALS['table'] ) || ! strlen($GLOBALS['table']) ) {
// prepare for db related
$db = $GLOBALS['db'];
$goto = empty( $GLOBALS['goto'] ) ?
@@ -198,13 +197,12 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
$table = '';
$db = '';
$fields_list = array();
- if ( empty( $GLOBALS['db'] ) ) {
+ if ( ! isset( $GLOBALS['db'] ) || ! strlen($GLOBALS['db']) ) {
// prepare for server related
$legend = sprintf( $GLOBALS['strRunSQLQueryOnServer'],
htmlspecialchars(
$GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host'] ) );
- }
- elseif ( empty( $GLOBALS['table'] ) ) {
+ } elseif ( ! isset( $GLOBALS['table'] ) || ! strlen($GLOBALS['table']) ) {
// prepare for db related
$db = $GLOBALS['db'];
// if you want navigation:
@@ -288,7 +286,7 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
foreach ( $fields_list as $field ) {
echo '<option value="'
.PMA_backquote( htmlspecialchars( $field['Field'] ) ) . '"';
- if ( ! empty( $field['Field'] ) && isset($field['Comment']) ) {
+ if ( isset( $field['Field'] ) && strlen($field['Field']) && isset($field['Comment']) ) {
echo ' title="' . htmlspecialchars( $field['Comment'] ) . '"';
}
echo '>' . htmlspecialchars( $field['Field'] ) . '</option>' . "\n";
View
6 libraries/sqlparser.lib.php
@@ -1094,7 +1094,7 @@ function PMA_SQP_analyze($arr)
'column' => ''
);
- if (!empty($alias_for_select_expr)) {
+ if (isset($alias_for_select_expr) && strlen($alias_for_select_expr)) {
// we had found an alias for this select expression
$subresult['select_expr'][$current_select_expr]['alias'] = $alias_for_select_expr;
unset($alias_for_select_expr);
@@ -1156,7 +1156,7 @@ function PMA_SQP_analyze($arr)
'table_alias' => '',
'table_true_name' => ''
);
- if (!empty($alias_for_table_ref)) {
+ if (isset($alias_for_table_ref) && strlen($alias_for_table_ref)) {
$subresult['table_ref'][$current_table_ref]['table_alias'] = $alias_for_table_ref;
unset($alias_for_table_ref);
}
@@ -1193,7 +1193,7 @@ function PMA_SQP_analyze($arr)
$alias = $subresult['table_ref'][$tr]['table_alias'];
$truename = $subresult['table_ref'][$tr]['table_true_name'];
for ($se=0; $se <= $current_select_expr; $se++) {
- if (!empty($alias) && $subresult['select_expr'][$se]['table_true_name']
+ if (isset($alias) && strlen($alias) && $subresult['select_expr'][$se]['table_true_name']
== $alias) {
$subresult['select_expr'][$se]['table_true_name']
= $truename;
View
3  libraries/tbl_indexes.lib.php
@@ -215,7 +215,8 @@ function PMA_show_indexes($table, &$indexes, &$indexes_info, &$indexes_data, $di
echo ' <tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n";
}
- if (!empty($indexes_data[$index_name][$seq_index]['Sub_part'])) {
+ if ( isset($indexes_data[$index_name][$seq_index]['Sub_part'])
+ && strlen($indexes_data[$index_name][$seq_index]['Sub_part']) ) {
echo ' <td>' . $col_name . '</td>' . "\n";
echo ' <td align="right">' . "\n"
. ' ' . $indexes_data[$index_name][$seq_index]['Sub_part'] . "\n"
View
4 libraries/tbl_move_copy.php
@@ -97,7 +97,9 @@ function PMA_table_move_copy($source_db, $source_table, $target_db, $target_tabl
}
$source = PMA_backquote($source_db) . '.' . PMA_backquote($source_table);
- if (empty($target_db)) $target_db = $source_db;
+ if ( ! isset($target_db) || ! strlen($target_db) ) {
+ $target_db = $source_db;
+ }
// Doing a select_db could avoid some problems with replicated databases,
// when moving table from replicated one to not replicated one
View
8 libraries/url_generating.lib.php
@@ -39,10 +39,10 @@ function PMA_generate_common_hidden_inputs( $db = '', $table = '', $indent = 0,
$skip =& $_skip;
} else {
$params = array();
- if ( ! empty( $db ) ) {
+ if ( isset($db) && strlen($db) ) {
$params['db'] = $db;
}
- if ( ! empty( $table ) ) {
+ if ( isset($table) && strlen($table) ) {
$params['table'] = $table;
}
}
@@ -138,10 +138,10 @@ function PMA_generate_common_url ($db = '', $table = '', $delim = '&amp;')
$questionmark = '?';
} else {
$params = array();
- if ( ! empty( $db ) ) {
+ if ( isset($db) && strlen($db) ) {
$params['db'] = $db;
}
- if ( ! empty( $table ) ) {
+ if ( isset($table) && strlen($table) ) {
$params['table'] = $table;
}
$questionmark = '';
View
14 querywindow.php
@@ -8,7 +8,7 @@
* Gets the variables sent to this script, retains the db name that may have
* been defined as startup option and include a core library
*/
-if (!empty($db)) {
+if (isset($db) && strlen($db)) {
$db_start = $db;
}
@@ -235,13 +235,11 @@ function resize() {
if (isset($no_js) && $no_js) {
// ... we redirect to appropriate query sql page
// works only full if $db and $table is also stored/grabbed from $_COOKIE
- if ( ! empty( $table ) ) {
+ if ( isset( $table ) && strlen($table) ) {
require './tbl_properties.php';
- }
- elseif ( ! empty( $db ) ) {
+ } elseif ( isset($db) && strlen($db) ) {
require './db_details.php';
- }
- else {
+ } else {
require './server_sql.php';
}
exit;
@@ -342,8 +340,8 @@ function resize() {
}
unset( $_input_query_history, $sql, $history );
?>
- <input type="hidden" name="db" value="<?php echo (empty($db) ? '' : htmlspecialchars($db)); ?>" />
- <input type="hidden" name="table" value="<?php echo (empty($table) ? '' : htmlspecialchars($table)); ?>" />
+ <input type="hidden" name="db" value="<?php echo (! isset($db) ? '' : htmlspecialchars($db)); ?>" />
+ <input type="hidden" name="table" value="<?php echo (! isset($table) ? '' : htmlspecialchars($table)); ?>" />
<input type="hidden" name="query_history_latest" value="" />
<input type="hidden" name="query_history_latest_db" value="" />
View
2  scripts/setup.php
@@ -1217,7 +1217,7 @@ function load_config($config_file) {
message('error', 'Empty username while using config authentication method!');
$err = TRUE;
}
- if (!empty($new_server['pmadb'])) {
+ if ( isset($new_server['pmadb']) && strlen($new_server['pmadb'])) {
// Just use defaults, should be okay for most users
$pmadb = array();
$pmadb['bookmarktable'] = 'pma_bookmark';
View
2  server_databases.php
@@ -75,7 +75,7 @@ function PMA_dbCmp($a, $b) {
}
if ((!empty($drop_selected_dbs) || isset($query_type)) && ($is_superuser || $cfg['AllowUserDropDatabase'])) {
- if (empty($selected_db) && ! (isset($query_type) && !empty($selected))) {
+ if ((! isset($selected_db) || ! strlen($selected_db)) && ! (isset($query_type) && !empty($selected))) {
$message = $strNoDatabasesSelected;
} else {
$action = 'server_databases.php';
View
62 server_privileges.php
@@ -14,11 +14,11 @@
/**
* Checks if a dropdown box has been used for selecting a database / table
*/
-if (!empty($pred_dbname)) {
+if (isset($pred_dbname) && strlen($pred_dbname)) {
$dbname = $pred_dbname;
unset($pred_dbname);
}
-if (!empty($pred_tablename)) {
+if (isset($pred_tablename) && strlen($pred_tablename)) {
$tablename = $pred_tablename;
unset($pred_tablename);
}
@@ -140,7 +140,7 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE)
} else {
$privs[] = $current_grant[1];
}
- } else if (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) {
+ } elseif (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) {
if ($enableHTML) {
$priv_string = '<dfn title="' . $current_grant[2] . '">' . $current_grant[1] . '</dfn>';
} else {
@@ -946,10 +946,10 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
//
// It looks curious but reflects the way MySQL works
- if (empty($dbname)) {
+ if (! isset($dbname) || ! strlen($dbname)) {
$db_and_table = '*.*';
} else {
- if ( !empty( $tablename ) ) {
+ if ( isset( $tablename ) && strlen($tablename) ) {
$db_and_table = PMA_backquote( PMA_unescape_mysql_wildcards( $dbname ) ) . '.';
$db_and_table .= PMA_backquote( $tablename );
} else {
@@ -973,7 +973,7 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
// FIXME: similar code appears twice in this script
if ( ( isset($Grant_priv) && $Grant_priv == 'Y')
- || ( empty($dbname) && PMA_MYSQL_INT_VERSION >= 40002
+ || ( ( ! isset($dbname) || ! strle($dbname) ) && PMA_MYSQL_INT_VERSION >= 40002
&& ( isset($max_questions) || isset($max_connections)
|| isset($max_updates) || isset($max_user_connections))))
{
@@ -1022,10 +1022,10 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
*/
if (!empty($revokeall)) {
- if (empty($dbname)) {
+ if ( ! isset($dbname) || ! strlen($dbname) ) {
$db_and_table = '*.*';
} else {
- if ( empty( $tablename ) ) {
+ if ( ! isset( $tablename ) || ! strlen($tablename) ) {
$db_and_table = PMA_backquote( $dbname ) . '.';
$db_and_table .= '*';
} else {
@@ -1046,7 +1046,7 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
}
$sql_query = $sql_query0 . (isset($sql_query1) ? ' ' . $sql_query1 : '');
$message = sprintf($GLOBALS['strRevokeMessage'], '\'' . $username . '\'@\'' . $hostname . '\'');
- if (empty($tablename)) {
+ if ( ! isset($tablename) || ! strlen($tablename) ) {
unset($dbname);
} else {
unset($tablename);
@@ -1242,7 +1242,7 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
/**
* Displays the page
*/
-if ( empty( $adduser ) && empty( $checkprivs ) ) {
+if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) ) {
if ( ! isset( $username ) ) {
// No username is given --> display the overview
echo '<h2>' . "\n"
@@ -1545,14 +1545,14 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
echo '<h2>' . "\n"
. ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_usredit.png" width="16" height="16" alt="" />' : '' )
. $GLOBALS['strUser'] . ' <i><a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '">\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'</a></i>' . "\n";
- if ( ! empty( $dbname ) ) {
+ if ( isset( $dbname ) && strlen($dbname) ) {
if ( $dbname_is_wildcard ) {
echo ' - ' . $GLOBALS['strDatabases'];
} else {
echo ' - ' . $GLOBALS['strDatabase'];
}
echo ' <i><a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['url_query'] . '&amp;db=' . urlencode($dbname) . '&amp;reload=1">' . htmlspecialchars($dbname) . '</a></i>' . "\n";
- if ( ! empty( $tablename ) ) {
+ if ( isset( $tablename ) && strlen($tablename) ) {
echo ' - ' . $GLOBALS['strTable'] . ' <i><a href="' . $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['url_query'] . '&amp;db=' . urlencode($dbname) . '&amp;table=' . urlencode($tablename) . '&amp;reload=1">' . htmlspecialchars($tablename) . '</a></i>' . "\n";
}
}
@@ -1570,16 +1570,18 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
. PMA_generate_common_hidden_inputs('', '', 3)
. '<input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
. '<input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
- if ( ! empty( $dbname ) ) {
+ if ( isset( $dbname ) && strlen($dbname) ) {
echo '<input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '" />' . "\n";
- if ( ! empty( $tablename ) ) {
+ if ( isset( $tablename ) && strlen($tablename) ) {
echo ' <input type="hidden" name="tablename" value="' . htmlspecialchars($tablename) . '" />' . "\n";
}
}
- PMA_displayPrivTable((empty($dbname) ? '*' : $dbname), ((empty($dbname) || empty($tablename)) ? '*' : $tablename), TRUE, 3);
+ PMA_displayPrivTable((( ! isset( $dbname ) || ! strlen($dbname) ) ? '*' : $dbname),
+ ((( ! isset( $dbname ) || ! strlen($dbname) ) || ( ! isset( $tablename ) || ! strlen($tablename) )) ? '*' : $tablename),
+ TRUE, 3);
echo '</form>' . "\n";
- if ( empty( $tablename ) && empty( $dbname_is_wildcard ) ) {
+ if ( ( ! isset( $tablename ) || ! strlen($tablename) ) && empty( $dbname_is_wildcard ) ) {
// no table name was given, display all table specific rights
// but only if $dbname contains no wildcards
@@ -1590,13 +1592,13 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
. '<input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
. '<input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n"
. '<fieldset>' . "\n"
- . '<legend>' . (empty($dbname) ? $GLOBALS['strDbPrivileges'] : $GLOBALS['strTblPrivileges']) . '</legend>' . "\n"
+ . '<legend>' . (( ! isset( $dbname ) || ! strlen($dbname) ) ? $GLOBALS['strDbPrivileges'] : $GLOBALS['strTblPrivileges']) . '</legend>' . "\n"
. '<table class="data">' . "\n"
. '<thead>' . "\n"
- . '<tr><th>' . (empty($dbname) ? $GLOBALS['strDatabase'] : $GLOBALS['strTable']) . '</th>' . "\n"
+ . '<tr><th>' . (( ! isset( $dbname ) || ! strlen($dbname) ) ? $GLOBALS['strDatabase'] : $GLOBALS['strTable']) . '</th>' . "\n"
. ' <th>' . $GLOBALS['strPrivileges'] . '</th>' . "\n"
. ' <th>' . $GLOBALS['strGrantOption'] . '</th>' . "\n"
- . ' <th>' . (empty($dbname) ? $GLOBALS['strTblPrivileges'] : $GLOBALS['strColumnPrivileges']) . '</th>' . "\n"
+ . ' <th>' . (( ! isset( $dbname ) || ! strlen($dbname) ) ? $GLOBALS['strTblPrivileges'] : $GLOBALS['strColumnPrivileges']) . '</th>' . "\n"
. ' <th colspan="2">' . $GLOBALS['strAction'] . '</th>' . "\n"
. '</tr>' . "\n"
. '</thead>' . "\n"
@@ -1613,7 +1615,7 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
// we also want privielgs for this user not in table `db` but in other table
$tables = PMA_DBI_fetch_result('SHOW TABLES FROM `mysql`;');
- if ( empty( $dbname ) ) {
+ if ( ( ! isset( $dbname ) || ! strlen($dbname) ) ) {
// no db name given, so we want all privs for the given user
@@ -1775,14 +1777,14 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
$found_rows = array();
//while ( $row = PMA_DBI_fetch_assoc( $res ) ) {
foreach ( $db_rights as $row ) {
- $found_rows[] = empty($dbname) ? $row['Db'] : $row['Table_name'];
+ $found_rows[] = ( ! isset( $dbname ) || ! strlen($dbname) ) ? $row['Db'] : $row['Table_name'];
echo '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n"
- . ' <td>' . htmlspecialchars(empty($dbname) ? $row['Db'] : $row['Table_name']) . '</td>' . "\n"
+ . ' <td>' . htmlspecialchars(( ! isset( $dbname ) || ! strlen($dbname) ) ? $row['Db'] : $row['Table_name']) . '</td>' . "\n"
. ' <td><tt>' . "\n"
. ' ' . join(',' . "\n" . ' ', PMA_extractPrivInfo($row, TRUE)) . "\n"
. ' </tt></td>' . "\n"
- . ' <td>' . (((empty($dbname) && $row['Grant_priv'] == 'Y') || (!empty($dbname) && in_array('Grant', explode(',', $row['Table_priv'])))) ? $GLOBALS['strYes'] : $GLOBALS['strNo']) . '</td>' . "\n"
+ . ' <td>' . (((( ! isset( $dbname ) || ! strlen($dbname) ) && $row['Grant_priv'] == 'Y') || (isset($dbname) && strlen($dbname) && in_array('Grant', explode(',', $row['Table_priv'])))) ? $GLOBALS['strYes'] : $GLOBALS['strNo']) . '</td>' . "\n"
. ' <td>';
if ( ! empty( $row['Table_privs'] ) || ! empty ( $row['Column_priv'] ) ) {
echo $GLOBALS['strYes'];
@@ -1793,15 +1795,15 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
. ' <td>';
printf( $link_edit, urlencode( $username ),
urlencode( $hostname ),
- urlencode( empty($dbname) ? $row['Db'] : $dbname ),
- urlencode( empty($dbname) ? '' : $row['Table_name'] ) );
+ urlencode( ( ! isset( $dbname ) || ! strlen($dbname) ) ? $row['Db'] : $dbname ),
+ urlencode( ( ! isset( $dbname ) || ! strlen($dbname) ) ? '' : $row['Table_name'] ) );
echo '</td>' . "\n"
. ' <td>';
- if ( ! empty( $row['can_delete'] ) || ! empty( $row['Table_name'] ) ) {
+ if ( ! empty( $row['can_delete'] ) || isset( $row['Table_name'] ) && strlen($row['Table_name']) ) {
printf( $link_revoke, urlencode( $username ),
urlencode( $hostname ),
- urlencode( empty( $dbname ) ? $row['Db'] : $dbname ),
- urlencode( empty( $dbname ) ? '' : $row['Table_name'] ) );
+ urlencode( ( ! isset( $dbname ) || ! strlen($dbname) ) ? $row['Db'] : $dbname ),
+ urlencode( ( ! isset( $dbname ) || ! strlen($dbname) ) ? '' : $row['Table_name'] ) );
}
echo '</td>' . "\n"
. '</tr>' . "\n";
@@ -1812,7 +1814,7 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
echo '</tbody>' . "\n"
. '</table>' . "\n";
- if (empty($dbname)) {
+ if ( ! isset( $dbname ) || ! strlen($dbname) ) {
// no database name was give, display select db
@@ -1869,7 +1871,7 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
. '</form>' . "\n";
}
- if ( empty($dbname) && ! $user_does_not_exists ) {
+ if ( ( ! isset( $dbname ) || ! strlen($dbname) ) && ! $user_does_not_exists ) {
echo '<form action="server_privileges.php" method="post" onsubmit="return checkPassword(this);">' . "\n"
. PMA_generate_common_hidden_inputs('', '', 3)
. '<input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
View
2  server_processlist.php
@@ -77,7 +77,7 @@
<td class="value"><?php echo $process['Id']; ?></td>
<td><?php echo $process['User']; ?></td>
<td><?php echo $process['Host']; ?></td>
- <td><?php echo (empty($process['db']) ? '<i>' . $strNone . '</i>' : $process['db']); ?></td>
+ <td><?php echo (( ! isset( $process['db'] ) || ! strlen($process['db']) ) ? '<i>' . $strNone . '</i>' : $process['db']); ?></td>
<td><?php echo $process['Command']; ?></td>
<td class="value"><?php echo $process['Time']; ?></td>
<td><?php echo (empty($process['State']) ? '---' : $process['State']); ?></td>
View
27 sql.php
@@ -24,7 +24,7 @@
} // end if (security checkings)
if (empty($goto)) {
- $goto = (empty($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
+ $goto = (! isset($table) || ! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
$is_gotofile = TRUE;
} // end if
if (!isset($err_url)) {
@@ -156,11 +156,10 @@
if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
$table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
}
- if (isset($analyzed_sql[0]['table_ref'][0]['db'])
- && !empty($analyzed_sql[0]['table_ref'][0]['db'])) {
+ if ( isset($analyzed_sql[0]['table_ref'][0]['db'])
+ && strlen($analyzed_sql[0]['table_ref'][0]['db']) ) {
$db = $analyzed_sql[0]['table_ref'][0]['db'];
- }
- else {
+ } else {
$db = $prev_db;
}
// Nijel: don't change reload, if we already decided to reload in import
@@ -189,7 +188,7 @@
$goto = $back;
}
if ($is_gotofile) {
- if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) {
+ if (strpos(' ' . $goto, 'db_details') == 1 && isset($table) && strlen($table) ) {
unset($table);
}
$active_page = $goto;
@@ -577,9 +576,9 @@
if (isset($purge) && $purge == '1') {
require_once('./libraries/relation_cleanup.lib.php');
- if (isset($table) && isset($db) && !empty($table) && !empty($db)) {
+ if (isset($table) && isset($db) && strlen($table) && strlen($db)) {
PMA_relationsCleanupTable($db, $table);
- } elseif (isset($db) && !empty($db)) {
+ } elseif (isset($db) && strlen($db)) {
PMA_relationsCleanupDatabase($db);
} else {
// garvin: VOID. No DB/Table gets deleted.
@@ -589,7 +588,7 @@
// garvin: If a column gets dropped, do relation magic.
if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
&& isset($db) && isset($table)
- && !empty($db) && !empty($table) && !empty($purgekey)) {
+ && strlen($db) && strlen($table) && !empty($purgekey)) {
require_once('./libraries/relation_cleanup.lib.php');
PMA_relationsCleanupColumn($db, $table, $purgekey);
@@ -694,23 +693,21 @@
} else {
$js_to_run = 'functions.js';
unset($message);
- if (!empty($table)) {
+ if (isset($table) && strlen($table)) {
require('./libraries/tbl_properties_common.php');
$url_query .= '&amp;goto=tbl_properties.php&amp;back=tbl_properties.php';
require('./libraries/tbl_properties_table_info.inc.php');
require('./libraries/tbl_properties_links.inc.php');
- }
- elseif (!empty($db)) {
+ } elseif (isset($db) && strlen($db)) {
require('./libraries/db_details_common.inc.php');
require('./libraries/db_details_db_info.inc.php');
- }
- else {
+ } else {
require('./libraries/server_common.inc.php');
require('./libraries/server_links.inc.php');
}
}
- if (!empty($db)) {
+ if (isset($db) && strlen($db)) {
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
}
View
18 tbl_addfield.php
@@ -93,12 +93,12 @@
$primary_cnt = count($field_primary);
for ($i = 0; $i < $primary_cnt; $i++) {
$j = $field_primary[$i];
- if (!empty($field_name[$j])) {
+ if (isset($field_name[$j]) && strlen($field_name[$j])) {
$primary .= PMA_backquote($field_name[$j]) . ', ';
}
} // end for
$primary = preg_replace('@, $@', '', $primary);
- if (!empty($primary)) {
+ if (strlen($primary)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ');';
$result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';';
@@ -111,12 +111,12 @@
$index_cnt = count($field_index);
for ($i = 0; $i < $index_cnt; $i++) {
$j = $field_index[$i];
- if (!empty($field_name[$j])) {
+ if (isset($field_name[$j]) && strlen($field_name[$j])) {
$index .= PMA_backquote($field_name[$j]) . ', ';
}
} // end for
$index = preg_replace('@, $@', '', $index);
- if (!empty($index)) {
+ if (strlen($index)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')';
$result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';';
@@ -129,12 +129,12 @@
$unique_cnt = count($field_unique);
for ($i = 0; $i < $unique_cnt; $i++) {
$j = $field_unique[$i];
- if (!empty($field_name[$j])) {
+ if (isset($field_name[$j]) && strlen($field_name[$j])) {
$unique .= PMA_backquote($field_name[$j]) . ', ';
}
} // end for
$unique = preg_replace('@, $@', '', $unique);
- if (!empty($unique)) {
+ if (strlen($unique)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')';
$result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';';
@@ -151,7 +151,7 @@
$fulltext .= PMA_backquote($field_name[$j]) . ', ';
} // end for
$fulltext = preg_replace('@, $@', '', $fulltext);
- if (!empty($fulltext)) {
+ if (strlen($fulltext)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')';
$result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';';
@@ -167,7 +167,7 @@
// garvin: Update comment table, if a comment was set.
if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork'] && PMA_MYSQL_INT_VERSION < 40100) {
foreach ($field_comments AS $fieldindex => $fieldcomment) {
- if (!empty($field_name[$fieldindex])) {
+ if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, '', 'pmadb');
}
}
@@ -176,7 +176,7 @@
// garvin: Update comment table for mime types [MIME]
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
foreach ($field_mimetype AS $fieldindex => $mimetype) {
- if (!empty($field_name[$fieldindex])) {
+ if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
}
}
View
4 tbl_alter.php
@@ -83,7 +83,7 @@
// garvin: Update comment table, if a comment was set.
if (PMA_MYSQL_INT_VERSION < 40100 && isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) {
foreach ($field_comments AS $fieldindex => $fieldcomment) {
- if (!empty($field_name[$fieldindex])) {
+ if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, $field_orig[$fieldindex], 'pmadb');
}
}
@@ -130,7 +130,7 @@
// garvin: Update comment table for mime types [MIME]
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
foreach ($field_mimetype AS $fieldindex => $mimetype) {
- if (!empty($field_name[$fieldindex])) {
+ if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
}
}
View
2  tbl_change.php
@@ -376,7 +376,7 @@
}
}
// UPDATE case with an empty and not NULL value under PHP4
- else if (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) {
+ elseif (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) {
$vrow[$rowfield] = date('Y-m-d H:i:s', time());
} // end if... else if...
}
View
24 tbl_create.php
@@ -78,13 +78,13 @@
$primary_cnt = (isset($field_primary) ? count($field_primary) : 0);
for ($i = 0; $i < $primary_cnt; $i++) {
$j = $field_primary[$i];
- if (!empty($field_name[$j])) {
+ if (isset($field_name[$j]) && strlen($field_name[$j])) {
$primary .= PMA_backquote($field_name[$j]) . ', ';
}
} // end for
unset($primary_cnt);
$primary = preg_replace('@, $@', '', $primary);
- if (!empty($primary)) {
+ if (strlen($primary)) {
$sql_query .= ', PRIMARY KEY (' . $primary . ')';
$query_cpy .= ',' . "\n" . ' PRIMARY KEY (' . $primary . ')';
}
@@ -95,13 +95,13 @@
$index_cnt = (isset($field_index) ? count($field_index) : 0);
for ($i = 0;$i < $index_cnt; $i++) {
$j = $field_index[$i];
- if (!empty($field_name[$j])) {
+ if (isset($field_name[$j]) && strlen($field_name[$j])) {
$index .= PMA_backquote($field_name[$j]) . ', ';
}
} // end for
unset($index_cnt);
$index = preg_replace('@, $@', '', $index);
- if (!empty($index)) {
+ if (strlen($index)) {
$sql_query .= ', INDEX (' . $index . ')';
$query_cpy .= ',' . "\n" . ' INDEX (' . $index . ')';
}
@@ -112,13 +112,13 @@
$unique_cnt = (isset($field_unique) ? count($field_unique) : 0);
for ($i = 0; $i < $unique_cnt; $i++) {
$j = $field_unique[$i];
- if (!empty($field_name[$j])) {
+ if (isset($field_name[$j]) && strlen($field_name[$j])) {
$unique .= PMA_backquote($field_name[$j]) . ', ';
}
} // end for
unset($unique_cnt);
$unique = preg_replace('@, $@', '', $unique);
- if (!empty($unique)) {
+ if (strlen($unique)) {
$sql_query .= ', UNIQUE (' . $unique . ')';
$query_cpy .= ',' . "\n" . ' UNIQUE (' . $unique . ')';
}
@@ -129,13 +129,13 @@
$fulltext_cnt = (isset($field_fulltext) ? count($field_fulltext) : 0);
for ($i = 0; $i < $fulltext_cnt; $i++) {
$j = $field_fulltext[$i];
- if (!empty($field_name[$j])) {
+ if (isset($field_name[$j]) && strlen($field_name[$j])) {
$fulltext .= PMA_backquote($field_name[$j]) . ', ';
}
} // end for
$fulltext = preg_replace('@, $@', '', $fulltext);
- if (!empty($fulltext)) {
+ if (strlen($fulltext)) {
$sql_query .= ', FULLTEXT (' . $fulltext . ')';
$query_cpy .= ',' . "\n" . ' FULLTEXT (' . $fulltext . ')';
}
@@ -178,7 +178,7 @@
// garvin: Update comment table, if a comment was set.
if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork'] && PMA_MYSQL_INT_VERSION < 40100) {
foreach ($field_comments AS $fieldindex => $fieldcomment) {
- if (!empty($field_name[$fieldindex])) {
+ if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, '', 'pmadb');
}
}
@@ -187,7 +187,7 @@
// garvin: Update comment table for mime types [MIME]
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
foreach ($field_mimetype AS $fieldindex => $mimetype) {
- if (!empty($field_name[$fieldindex])) {
+ if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
}
}
@@ -218,11 +218,11 @@
PMA_mysqlDie($strTableEmpty, '', '', $err_url);
}
// No valid number of fields
- else if (empty($num_fields) || !is_int($num_fields)) {
+ elseif (empty($num_fields) || !is_int($num_fields)) {
PMA_mysqlDie($strFieldsEmpty, '', '', $err_url);
}
// Does table exist?
- else if (!(PMA_DBI_get_fields($db, $table) === FALSE)) {
+ elseif (!(PMA_DBI_get_fields($db, $table) === FALSE)) {
PMA_mysqlDie(sprintf($strTableAlreadyExists, htmlspecialchars($table)), '', '', $err_url);
}
// Table name and number of fields are valid -> show the form
View
8 tbl_indexes.php
@@ -21,10 +21,10 @@
*/
if (!defined('PMA_IDX_INCLUDED')) {
// 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 ) {
$uri_params = array( 'reload' => '1' );
if ( isset($message) ) {
$uri_params['message'] = $message;
@@ -34,11 +34,11 @@
exit;
}
// Not a valid table name -> back to the default db_details sub-page
- if ( !empty($table) ) {
+ if ( isset($table) && strlen($table) ) {
$is_table = PMA_DBI_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) ) ) {
$uri_params = array( 'reload' => '1', 'db' => $db );
if ( isset($message) ) {
View
8 tbl_replace.php
@@ -70,7 +70,7 @@
$goto .= '&primary_key[]=' . urlencode(PMA_getUvaCondition($res, count($row), $meta, $row));
}
}
-} else if ($goto == 'sql.php') {
+} elseif ($goto == 'sql.php') {
$goto = 'sql.php?'
. PMA_generate_common_url($db, $table, '&')
. '&pos=' . $pos
@@ -79,11 +79,11 @@
. '&repeat_cells=' . $repeat_cells
. '&dontlimitchars=' . $dontlimitchars
. '&sql_query=' . urlencode($sql_query);
-} else if (!empty($goto)) {
+} elseif (!empty($goto)) {
// Security checkings
$is_gotofile = preg_replace('@^([^?]+).*$@', '\\1', $goto);
if (!@file_exists('./' . $is_gotofile)) {
- $goto = (empty($table)) ? 'db_details.php' : 'tbl_properties.php';
+ $goto = (! isset($table) || ! strlen($table)) ? 'db_details.php' : 'tbl_properties.php';
$is_gotofile = TRUE;
} else {
$is_gotofile = ($is_gotofile == $goto);
@@ -261,7 +261,7 @@
$message .= $last_message;
if ($is_gotofile) {
- if ($goto == 'db_details.php' && !empty($table)) {
+ if ($goto == 'db_details.php' && isset($table)) {
unset($table);
}
$js_to_run = 'functions.js';
Please sign in to comment.
Something went wrong with that request. Please try again.