updated database list:

- added PMA_getServerCollation()
  - display server collation in db list footer
- added PMA_DBI_get_databases_full()
  - make use of info_schema on MySQL 5
  - always display db stats for MySQL 5
- fixed html output
- replaced " with ' in some queries
This commit is contained in:
Sebastian Mendel
2005-11-05 19:48:05 +00:00
parent d3a3f2aeb8
commit 39ecba0de6
4 changed files with 392 additions and 298 deletions

View File

@@ -5,9 +5,19 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2005-11-04 Sebastian Mendel <cybot_tm@users.sourceforge.net> 2005-11-05 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* themes/*/css/theme_right.css.php: * themes/*/css/theme_right.css.php:
dropped deprecated style classes dropped deprecated style classes
* server_databases, libraries/databases_interface.lib.php,
libraries/mysql_charsets.lib.php:
updated database list:
- added PMA_getServerCollation()
- display server collation in db list footer
- added PMA_DBI_get_databases_full()
- make use of info_schema on MySQL 5
- always display db stats for MySQL 5
- fixed html output
- replaced " with ' in some queries
2005-11-04 Marc Delisle <lem9@users.sourceforge.net> 2005-11-04 Marc Delisle <lem9@users.sourceforge.net>
* lang/spanish: Updated, thanks to Daniel Hinostroza (hinostroza) * lang/spanish: Updated, thanks to Daniel Hinostroza (hinostroza)

View File

@@ -26,34 +26,26 @@ function PMA_DBI_query($query, $link = NULL, $options = 0) {
return $res; return $res;
} }
/**
* returns array with database names
*
* @return array $databases
*/
function PMA_DBI_get_dblist( $link = NULL ) { function PMA_DBI_get_dblist( $link = NULL ) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) { $dbs_array = PMA_DBI_fetch_result( 'SHOW DATABASES;', $link );
$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 // Before MySQL 4.0.2, SHOW DATABASES could send the
// whole list, so check if we really have access: // whole list, so check if we really have access:
//if (PMA_MYSQL_CLIENT_API < 40002) {
// Better check the server version, in case the client API
// is more recent than the server version
if ( PMA_MYSQL_INT_VERSION < 40002 ) { if ( PMA_MYSQL_INT_VERSION < 40002 ) {
$dblink = @PMA_DBI_select_db($row[0], $link); foreach ( $dbs_array as $key => $db ) {
if (!$dblink) { if ( ! PMA_DBI_select_db( $db, $link ) ) {
continue; unset( $dbs_array[$key] );
} }
} }
$dbs_array[] = $row[0]; // re-index values
$dbs_array = array_values( $dbs_array );
} }
PMA_DBI_free_result($res);
unset($res);
return $dbs_array; return $dbs_array;
} }
@@ -117,13 +109,13 @@ function PMA_DBI_get_tables_full( $database, $table = false,
// get table information from information_schema // get table information from information_schema
if ( $table ) { if ( $table ) {
if ( true === $tbl_is_group ) { if ( true === $tbl_is_group ) {
$sql_where_table = 'AND `TABLE_NAME` LIKE "' $sql_where_table = 'AND `TABLE_NAME` LIKE \''
. PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%"'; . PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%\'';
} elseif ( 'comment' === $tbl_is_group ) { } elseif ( 'comment' === $tbl_is_group ) {
$sql_where_table = 'AND `TABLE_COMMENT` LIKE "' $sql_where_table = 'AND `TABLE_COMMENT` LIKE \''
. PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%"'; . PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%\'';
} else { } else {
$sql_where_table = 'AND `TABLE_NAME` = "' . addslashes( $table ) . '"'; $sql_where_table = 'AND `TABLE_NAME` = \'' . addslashes( $table ) . '\'';
} }
} else { } else {
$sql_where_table = ''; $sql_where_table = '';
@@ -154,7 +146,7 @@ function PMA_DBI_get_tables_full( $database, $table = false,
`CREATE_OPTIONS` AS `Create_options`, `CREATE_OPTIONS` AS `Create_options`,
`TABLE_COMMENT` AS `Comment` `TABLE_COMMENT` AS `Comment`
FROM `information_schema`.`TABLES` FROM `information_schema`.`TABLES`
WHERE `TABLE_SCHEMA` = "' . addslashes( $database ) . '" WHERE `TABLE_SCHEMA` = \'' . addslashes( $database ) . '\'
' . $sql_where_table; ' . $sql_where_table;
$tables = PMA_DBI_fetch_result( $sql, 'TABLE_NAME', NULL, $link ); $tables = PMA_DBI_fetch_result( $sql, 'TABLE_NAME', NULL, $link );
@@ -163,7 +155,7 @@ function PMA_DBI_get_tables_full( $database, $table = false,
if ( true === $tbl_is_group ) { if ( true === $tbl_is_group ) {
$sql = 'SHOW TABLE STATUS FROM ' $sql = 'SHOW TABLE STATUS FROM '
. PMA_backquote( addslashes( $database ) ) . PMA_backquote( addslashes( $database ) )
.' LIKE "' . PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%"'; .' LIKE \'' . PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%\'';
} else { } else {
$sql = 'SHOW TABLE STATUS FROM ' $sql = 'SHOW TABLE STATUS FROM '
. PMA_backquote( addslashes( $database ) ) . ';'; . PMA_backquote( addslashes( $database ) ) . ';';
@@ -229,6 +221,101 @@ function PMA_DBI_get_tables_full( $database, $table = false,
return $tables; return $tables;
} }
/**
* returns array with databases containing extended infos about them
*
* @param string $databases database
* @param boolean $force_stats retrieve stats also for MySQL < 5
* @param resource $link mysql link
* @return array $databases
*/
function PMA_DBI_get_databases_full( $database = NULL, $force_stats = false, $link = NULL ) {
if ( PMA_MYSQL_INT_VERSION >= 50002 ) {
// get table information from information_schema
if ( $database ) {
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \''
. addslashes( $database ) . '\'';
} else {
$sql_where_schema = '';
}
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
$sql = '
SELECT `information_schema`.`SCHEMATA`.*,
COUNT(`information_schema`.`TABLES`.`TABLE_SCHEMA`)
AS `SCHEMA_TABLES`,
SUM(`information_schema`.`TABLES`.`TABLE_ROWS`)
AS `SCHEMA_TABLE_ROWS`,
SUM(`information_schema`.`TABLES`.`DATA_LENGTH`)
AS `SCHEMA_DATA_LENGTH`,
SUM(`information_schema`.`TABLES`.`MAX_DATA_LENGTH`)
AS `SCHEMA_MAX_DATA_LENGTH`,
SUM(`information_schema`.`TABLES`.`INDEX_LENGTH`)
AS `SCHEMA_INDEX_LENGTH`,
SUM(`information_schema`.`TABLES`.`DATA_LENGTH`
+ `information_schema`.`TABLES`.`INDEX_LENGTH`)
AS `SCHEMA_LENGTH`,
SUM(`information_schema`.`TABLES`.`DATA_FREE`)
AS `SCHEMA_DATA_FREE`
FROM `information_schema`.`SCHEMATA`
LEFT JOIN `information_schema`.`TABLES`
ON `information_schema`.`TABLES`.`TABLE_SCHEMA`
= `information_schema`.`SCHEMATA`.`SCHEMA_NAME`
' . $sql_where_schema . '
GROUP BY `information_schema`.`SCHEMATA`.`SCHEMA_NAME`';
$databases = PMA_DBI_fetch_result( $sql, 'SCHEMA_NAME', NULL, $link );
unset( $sql_where_schema, $sql );
} else {
foreach ( PMA_DBI_get_dblist( $link ) as $database_name ) {
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
if ( $force_stats ) {
require_once 'mysql_charsets.lib.php';
$databases[$database_name]['DEFAULT_COLLATION_NAME']
= PMA_getDbCollation( $database_name );
// get additonal info about tables
$databases[$database_name]['SCHEMA_TABLES'] = 0;
$databases[$database_name]['SCHEMA_TABLE_ROWS'] = 0;
$databases[$database_name]['SCHEMA_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
$res = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote( $database_name ) . ';');
while ( $row = PMA_DBI_fetch_assoc( $res ) ) {
$databases[$database_name]['SCHEMA_TABLES']++;
$databases[$database_name]['SCHEMA_TABLE_ROWS']
+= $row['Rows'];
$databases[$database_name]['SCHEMA_DATA_LENGTH']
+= $row['Data_length'];
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH']
+= $row['Max_data_length'];
$databases[$database_name]['SCHEMA_INDEX_LENGTH']
+= $row['Index_length'];
$databases[$database_name]['SCHEMA_DATA_FREE']
+= $row['Data_free'];
$databases[$database_name]['SCHEMA_LENGTH']
+= $row['Data_length'] + $row['Index_length'];
}
PMA_DBI_free_result( $res );
unset( $res );
}
}
}
if ( $GLOBALS['cfg']['NaturalOrder'] ) {
uksort( $databases, 'strnatcasecmp' );
}
return $databases;
}
function PMA_DBI_get_fields($database, $table, $link = NULL) { function PMA_DBI_get_fields($database, $table, $link = NULL) {
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {

View File

@@ -358,6 +358,16 @@ if (PMA_MYSQL_INT_VERSION >= 40100){
return ' CHARACTER SET ' . $charset . ($charset == $collation ? '' : ' COLLATE ' . $collation); return ' CHARACTER SET ' . $charset . ($charset == $collation ? '' : ' COLLATE ' . $collation);
} }
/**
* returns default server collation from show variables
*
* @uses PMA_DBI_fetch_value()
* @return string $server_collation
*/
function PMA_getServerCollation() {
return PMA_DBI_fetch_value(
'SHOW VARIABLES LIKE \'collation_server\'', 0, 1 );
}
} }
?> ?>

View File

@@ -2,13 +2,6 @@
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
/**
* Checks if the left frame has to be reloaded
*/
require_once('./libraries/grab_globals.lib.php');
/** /**
* Does the common work * Does the common work
*/ */
@@ -29,18 +22,17 @@ require('./server_common.inc.php');
* *
* @access private * @access private
*/ */
function PMA_dbCmp($a, $b) function PMA_dbCmp($a, $b) {
{
global $sort_by, $sort_order; global $sort_by, $sort_order;
if ($GLOBALS['cfg']['NaturalOrder']) { if ($GLOBALS['cfg']['NaturalOrder']) {
$sorter = 'strnatcmp'; $sorter = 'strnatcmp';
} else { } else {
$sorter = 'strcasecmp'; $sorter = 'strcasecmp';
} }
if ($sort_by == 'db_name') { if ($sort_by == 'SCHEMA_NAME') {
return ($sort_order == 'asc' ? 1 : -1) * $sorter($a['db_name'], $b['db_name']); return ($sort_order == 'asc' ? 1 : -1) * $sorter($a['SCHEMA_NAME'], $b['SCHEMA_NAME']);
} elseif ($a[$sort_by] == $b[$sort_by]) { } elseif ($a[$sort_by] == $b[$sort_by]) {
return $sorter($a['db_name'], $b['db_name']); return $sorter($a['SCHEMA_NAME'], $b['SCHEMA_NAME']);
} else { } else {
return ($sort_order == 'asc' ? 1 : -1) * ((int)$a[$sort_by] > (int)$b[$sort_by] ? 1 : -1); return ($sort_order == 'asc' ? 1 : -1) * ((int)$a[$sort_by] > (int)$b[$sort_by] ? 1 : -1);
} }
@@ -48,11 +40,24 @@ function PMA_dbCmp($a, $b)
/** /**
* Gets the databases list - if it has not been built yet * avoids 'undefined index' errors
*/ */
if ($server > 0 && empty($dblist)) { if (empty($sort_by)) {
PMA_availableDatabases(); $sort_by = 'SCHEMA_NAME';
} else {
$sort_by = PMA_sanitize($sort_by);
} }
if (empty($sort_order)) {
if ($sort_by == 'SCHEMA_NAME') {
$sort_order = 'asc';
} else {
$sort_order = 'desc';
}
} else {
$sort_order = PMA_sanitize($sort_order);
}
$dbstats = empty( $dbstats ) ? 0 : 1;
/** /**
@@ -71,13 +76,9 @@ if ((!empty($drop_selected_dbs) || isset($query_type)) && ($is_superuser || $cfg
} else { } else {
$message = sprintf($strDatabasesDropped, 0); $message = sprintf($strDatabasesDropped, 0);
} }
// we need to reload the database list now.
PMA_availableDatabases();
$reload = 1;
} }
} }
/** /**
* Displays the links * Displays the links
*/ */
@@ -92,111 +93,105 @@ echo '<h2>' . "\n"
? '<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"' ? '<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
.' height="16" alt="" />' .' height="16" alt="" />'
: '' ) : '' )
. ( empty($dbstats) ? $strDatabases : $strDatabasesStats ) . "\n" . ( $dbstats ? $strDatabasesStats : $strDatabases ) . "\n"
.'</h2>' . "\n"; .'</h2>' . "\n";
/** /**
* Checks if the user is allowed to do what he tries to... * Checks if the user is allowed to do what he tries to...
*/ */
if (!empty($dbstats) && !$is_superuser) { if ( $dbstats && ! $is_superuser ) {
echo $strNoPrivileges . "\n"; echo $strNoPrivileges . "\n";
require_once('./footer.inc.php'); require_once('./footer.inc.php');
} }
/** /**
* Prepares the statistics * Gets the databases list
*/ */
$statistics = array(); if ( $server > 0 ) {
foreach ($dblist AS $current_db) { $databases = PMA_DBI_get_databases_full( NULL, $dbstats );
$tmp_array = array(
'db_name' => $current_db,
'tbl_cnt' => 0,
'data_sz' => 0,
'idx_sz' => 0,
'tot_sz' => 0
);
if (!empty($dbstats)) {
$res = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($current_db) . ';');
while ($row = PMA_DBI_fetch_assoc($res)) {
$tmp_array['tbl_cnt']++;
$tmp_array['data_sz'] += $row['Data_length'];
$tmp_array['idx_sz'] += $row['Index_length'];
}
PMA_DBI_free_result($res);
unset($res);
}
$tmp_array['tot_sz'] = $tmp_array['data_sz'] + $tmp_array['idx_sz'];
$statistics[] = $tmp_array;
}
// avoids 'undefined index' errors
if (empty($sort_by)) {
$sort_by = 'db_name';
} else { } else {
$sort_by = PMA_sanitize($sort_by); $databases = array();
} }
if (empty($sort_order)) {
if ($sort_by == 'db_name') {
$sort_order = 'asc';
} else {
$sort_order = 'desc';
}
} else {
$sort_order = PMA_sanitize($sort_order);
}
// sorts the array
usort($statistics, 'PMA_dbCmp');
/** /**
* Displays the page * Displays the page
*/ */
if (count($statistics) > 0) { if ( count($databases) > 0 ) {
// sorts the array
usort( $databases, 'PMA_dbCmp' );
// table col order
$column_order = array(
'DEFAULT_COLLATION_NAME' => array(
'disp_name' => $strCollation,
'description_function' => 'PMA_getCollationDescr',
'format' => 'string',
'footer' => PMA_getServerCollation(),
),
'SCHEMA_TABLES' => array(
'disp_name' => $strNumTables,
'format' => 'number',
'footer' => 0,
),
'SCHEMA_TABLE_ROWS' => array(
'disp_name' => $strRows,
'format' => 'number',
'footer' => 0,
),
'SCHEMA_DATA_LENGTH' => array(
'disp_name' => $strData,
'format' => 'byte',
'footer' => 0,
),
'SCHEMA_INDEX_LENGTH' => array(
'disp_name' => $strIndexes,
'format' => 'byte',
'footer' => 0,
),
'SCHEMA_LENGTH' => array(
'disp_name' => $strTotalUC,
'format' => 'byte',
'footer' => 0,
),
'SCHEMA_DATA_FREE' => array(
'disp_name' => $strOverhead,
'format' => 'byte',
'footer' => 0,
),
);
echo '<form action="./server_databases.php" method="post" name="dbStatsForm">' . "\n" echo '<form action="./server_databases.php" method="post" name="dbStatsForm">' . "\n"
. PMA_generate_common_hidden_inputs('', '', 1) . PMA_generate_common_hidden_inputs('', '', 1)
. ' <input type="hidden" name="dbstats" value="' . (empty($dbstats) ? '0' : '1') . '" />' . "\n" . '<input type="hidden" name="dbstats" value="' . $dbstats . '" />' . "\n"
. '<input type="hidden" name="sort_by" value="' . $sort_by . '" />' . "\n" . '<input type="hidden" name="sort_by" value="' . $sort_by . '" />' . "\n"
. '<input type="hidden" name="sort_order" value="' . $sort_order . '" />' . "\n" . '<input type="hidden" name="sort_order" value="' . $sort_order . '" />' . "\n"
. '<table id="tabledatabases" class="data">' . "\n" . '<table id="tabledatabases" class="data">' . "\n"
. '<thead>' . "\n" . '<thead>' . "\n"
. '<tr>' . "\n" . '<tr>' . "\n"
. ($is_superuser || $cfg['AllowUserDropDatabase'] ? ' <th>&nbsp;</th>' . "\n" : '') . ($is_superuser || $cfg['AllowUserDropDatabase'] ? ' <th>&nbsp;</th>' . "\n" : '')
. ' <th>' . "\n" . ' <th><a href="./server_databases.php?' . $url_query . '&amp;dbstats=' . $dbstats . '&amp;sort_by=SCHEMA_NAME&amp;sort_order=' . (($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ? 'desc' : 'asc') . '">' . "\n"
. ' <a href="./server_databases.php?' . $url_query . (!empty($dbstats) ? '&amp;dbstats=1' : '') . '&amp;sort_by=db_name&amp;sort_order=' . (($sort_by == 'db_name' && $sort_order == 'asc') ? 'desc' : 'asc') . '">' . "\n"
. ' ' . $strDatabase . "\n" . ' ' . $strDatabase . "\n"
. ($sort_by == 'db_name' ? ' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '') . ($sort_by == 'SCHEMA_NAME' ? ' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
. ' </a>' . "\n" . ' </a></th>' . "\n";
. ' </th>' . "\n"; $table_columns = 3;
if (!empty($dbstats)) { foreach ( $column_order as $stat_name => $stat ) {
if (PMA_MYSQL_INT_VERSION >= 40101) { if ( array_key_exists( $stat_name, $databases[0] ) ) {
echo ' <th>' . $strCollation . '</th>' . "\n"; if ( $stat['format'] === 'byte' ) {
$table_columns += 2;
$colspan = ' colspan="2"';
} else {
$table_columns++;
$colspan = '';
}
echo ' <th' . $colspan . '>'
.'<a href="./server_databases.php?' . $url_query . '&amp;dbstats=' . (int) $dbstats . '&amp;sort_by=' . urlencode( $stat_name ) . '&amp;sort_order=' . (($sort_by == $stat_name && $sort_order == 'desc') ? 'asc' : 'desc') . '">' . "\n"
.' ' . $stat['disp_name'] . "\n"
.($sort_by == $stat_name ? ' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
.' </a></th>' . "\n";
} }
echo ' <th><a href="./server_databases.php?' . $url_query . '&amp;dbstats=1&amp;sort_by=tbl_cnt&amp;sort_order=' . (($sort_by == 'tbl_cnt' && $sort_order == 'desc') ? 'asc' : 'desc') . '">' . "\n"
. ' ' . $strNumTables . "\n"
. ($sort_by == 'tbl_cnt' ? ' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
. ' </a>' . "\n"
. ' </th>' . "\n"
. ' <th colspan="2">' . "\n"
. ' <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1&amp;sort_by=data_sz&amp;sort_order=' . (($sort_by == 'data_sz' && $sort_order == 'desc') ? 'asc' : 'desc') . '">' . "\n"
. ' ' . $strData . "\n"
. ($sort_by == 'data_sz' ? ' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
. ' </a>' . "\n"
. ' </th>' . "\n"
. ' <th colspan="2">' . "\n"
. ' <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1&amp;sort_by=idx_sz&amp;sort_order=' . (($sort_by == 'idx_sz' && $sort_order == 'desc') ? 'asc' : 'desc') . '">' . "\n"
. ' ' . $strIndexes . "\n"
. ($sort_by == 'idx_sz' ? ' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
. ' </a>' . "\n"
. ' </th>' . "\n"
. ' <th colspan="2">' . "\n"
. ' <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1&amp;sort_by=tot_sz&amp;sort_order=' . (($sort_by == 'tot_sz' && $sort_order == 'desc') ? 'asc' : 'desc') . '">' . "\n"
. ' ' . $strTotalUC . "\n"
. ($sort_by == 'tot_sz' ? ' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
. ' </a>' . "\n"
. ' </th>' . "\n";
} }
if ($is_superuser) { if ($is_superuser) {
echo ' <th>' . ($cfg['PropertiesIconic'] ? '&nbsp;' : $strAction ) . "\n" echo ' <th>' . ($cfg['PropertiesIconic'] ? '&nbsp;' : $strAction ) . "\n"
@@ -205,117 +200,128 @@ if (count($statistics) > 0) {
echo '</tr>' . "\n" echo '</tr>' . "\n"
. '</thead>' . "\n" . '</thead>' . "\n"
. '<tbody>' . "\n"; . '<tbody>' . "\n";
$total_calc = array(
'db_cnt' => 0, $odd_row = true;
'tbl_cnt' => 0, foreach ( $databases as $key => $current ) {
'data_sz' => 0,
'idx_sz' => 0,
'tot_sz' => 0
);
$odd_row = false;
foreach ( $statistics as $current ) {
$odd_row = !$odd_row;
list($data_size, $data_unit) = PMA_formatByteDown($current['data_sz'], 3, 1);
list($idx_size, $idx_unit) = PMA_formatByteDown($current['idx_sz'], 3, 1);
list($tot_size, $tot_unit) = PMA_formatByteDown($current['tot_sz'], 3, 1);
$total_calc['db_cnt']++;
$total_calc['tbl_cnt'] += $current['tbl_cnt'];
$total_calc['data_sz'] += $current['data_sz'];
$total_calc['idx_sz'] += $current['idx_sz'];
$total_calc['tot_sz'] += $current['tot_sz'];
echo '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n"; echo '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n";
$odd_row = ! $odd_row;
if ( $is_superuser || $cfg['AllowUserDropDatabase'] ) { if ( $is_superuser || $cfg['AllowUserDropDatabase'] ) {
echo ' <td class="tool">' . "\n"; echo ' <td class="tool">' . "\n";
if ($current['db_name'] != 'mysql' && (PMA_MYSQL_INT_VERSION < 50002 || $current['db_name'] != 'information_schema')) { if ($current['SCHEMA_NAME'] != 'mysql' && (PMA_MYSQL_INT_VERSION < 50002 || $current['SCHEMA_NAME'] != 'information_schema')) {
echo ' <input type="checkbox" name="selected_db[]" title="' . htmlspecialchars($current['db_name']) . '" value="' . htmlspecialchars($current['db_name']) . '" ' . (empty($checkall) ? '' : 'checked="checked" ') . '/>' . "\n"; echo ' <input type="checkbox" name="selected_db[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . (empty($checkall) ? '' : 'checked="checked" ') . '/>' . "\n";
} else { } else {
echo ' <input type="checkbox" name="selected_db[]" title="' . htmlspecialchars($current['db_name']) . '" value="' . htmlspecialchars($current['db_name']) . '" disabled="disabled"/>' . "\n"; echo ' <input type="checkbox" name="selected_db[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" disabled="disabled"/>' . "\n";
} }
echo ' </td>' . "\n"; echo ' </td>' . "\n";
} }
echo ' <td class="name">' . "\n" echo ' <td class="name">' . "\n"
. ' <a onclick="if ( window.parent.openDb(\'' . urlencode($current['db_name']) . '\') ) return false;" href="index.php?' . $url_query . '&amp;db=' . urlencode($current['db_name']) . '" title="' . sprintf($strJumpToDB, htmlspecialchars($current['db_name'])) . '" target="_parent">' . "\n" . ' <a onclick="if ( window.parent.openDb(\'' . urlencode($current['SCHEMA_NAME']) . '\') ) return false;" href="index.php?' . $url_query . '&amp;db=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf($strJumpToDB, htmlspecialchars($current['SCHEMA_NAME'])) . '" target="_parent">' . "\n"
. ' ' . htmlspecialchars($current['db_name']) . "\n" . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
. ' </a>' . "\n" . ' </a>' . "\n"
. ' </td>' . "\n"; . ' </td>' . "\n";
if (!empty($dbstats)) {
if (PMA_MYSQL_INT_VERSION >= 40101) { foreach ( $column_order as $stat_name => $stat ) {
$current_collation = PMA_getDbCollation($current['db_name']); if ( array_key_exists( $stat_name, $current ) ) {
echo ' <td><dfn title="' . htmlspecialchars(PMA_getCollationDescr($current_collation)) . '">' . "\n" if ( is_numeric( $stat['footer'] ) ) {
. ' ' . htmlspecialchars($current_collation) . "\n" $column_order[$stat_name]['footer'] += $current[$stat_name];
. ' </dfn>' . "\n"
. ' </td>' . "\n";
} }
echo ' <td class="value">' . $current['tbl_cnt'] . '</td>' . "\n" if ( $stat['format'] === 'byte' ) {
. ' <td class="value">' . $data_size . '</td>' . "\n" list( $value, $unit ) = PMA_formatByteDown( $current[$stat_name], 3, 1 );
. ' <td class="unit">' . $data_unit . '</td>' . "\n" } elseif ( $stat['format'] === 'number' ) {
. ' <td class="value">' . $idx_size . '</td>' . "\n" $value = PMA_formatNumber( $current[$stat_name], 0 );
. ' <td class="unit">' . $idx_unit . '</td>' . "\n" } else {
. ' <td class="value"><strong>' . $tot_size . '</strong></td>' . "\n" $value = htmlentities( $current[$stat_name], 0 );
. ' <td class="unit"><strong>' . $tot_unit . '</strong></td>' . "\n";
} }
echo ' <td class="value">';
if ( isset( $stat['description_function'] ) ) {
echo '<dfn title="' . $stat['description_function']( $current[$stat_name] ) . '">';
}
echo $value;
if ( isset( $stat['description_function'] ) ) {
echo '</dfn>';
}
echo '</td>' . "\n";
if ( $stat['format'] === 'byte' ) {
echo ' <td class="unit">' . $unit . '</td>' . "\n";
}
}
}
if ($is_superuser) { if ($is_superuser) {
echo ' <td class="tool">' . "\n" echo ' <td class="tool">' . "\n"
. ' <a onclick="window.parent.setDb(\'' . urlencode($current['db_name']) . '\');" href="./server_privileges.php?' . $url_query . '&amp;checkprivs=' . urlencode($current['db_name']) . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['db_name'])) . '">'. "\n" . ' <a onclick="window.parent.setDb(\'' . urlencode($current['SCHEMA_NAME']) . '\');" href="./server_privileges.php?' . $url_query . '&amp;checkprivs=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['SCHEMA_NAME'])) . '">'. "\n"
. ' ' .($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' .$strCheckPrivs . '" /> ' : $strCheckPrivs ). "\n" . ' ' .($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' .$strCheckPrivs . '" /> ' : $strCheckPrivs ). "\n"
. ' </a>' . "\n" . ' </a></td>' . "\n";
. ' </td>' . "\n";
} }
echo '</tr>' . "\n"; echo '</tr>' . "\n";
} // end foreach ( $statistics as $current ) } // end foreach ( $databases as $key => $current )
if (!empty($dbstats)) { unset( $key, $current, $odd_row );
list($data_size, $data_unit) = PMA_formatByteDown($total_calc['data_sz'], 3, 1);
list($idx_size, $idx_unit) = PMA_formatByteDown($total_calc['idx_sz'], 3, 1); echo '<tr>' . "\n";
list($tot_size, $tot_unit) = PMA_formatByteDown($total_calc['tot_sz'], 3, 1); if ( $is_superuser ) {
echo ' <tr><th>&nbsp;</th>' . "\n"
. ' <th>' . $strTotalUC . ': ' . $total_calc['db_cnt']
. ' </th>' . "\n";
if (PMA_MYSQL_INT_VERSION >= 40101) {
echo ' <th>&nbsp;</th>' . "\n"; echo ' <th>&nbsp;</th>' . "\n";
} }
echo ' <th class="value">' . $total_calc['tbl_cnt'] . '</th>' . "\n" echo ' <th>' . $strTotalUC . ': ' . count( $databases ) . '</th>' . "\n";
. ' <th class="value">' . $data_size . '</th>' . "\n" foreach ( $column_order as $stat_name => $stat ) {
. ' <th class="unit">' . $data_unit . '</th>' . "\n" if ( array_key_exists( $stat_name, $databases[0] ) ) {
. ' <th class="value">' . $idx_size . '</th>' . "\n" if ( $stat['format'] === 'byte' ) {
. ' <th class="unit">' . $idx_unit . '</th>' . "\n" list( $value, $unit ) = PMA_formatByteDown( $stat['footer'], 3, 1 );
. ' <th class="value">' . $tot_size . '</th>' . "\n" } elseif ( $stat['format'] === 'number' ) {
. ' <th class="unit">' . $tot_unit . '</th>' . "\n" $value = PMA_formatNumber( $stat['footer'], 0 );
. ' <th>&nbsp;</th>' . "\n" } else {
. ' </tr>' . "\n"; $value = htmlentities( $stat['footer'], 0 );
} }
echo ' <th class="value">';
if ( isset( $stat['description_function'] ) ) {
echo '<dfn title="' . $stat['description_function']( $stat['footer'] ) . '">';
}
echo $value;
if ( isset( $stat['description_function'] ) ) {
echo '</dfn>';
}
echo '</th>' . "\n";
if ( $stat['format'] === 'byte' ) {
echo ' <th class="unit">' . $unit . '</th>' . "\n";
}
}
}
if ( $is_superuser ) {
echo ' <th>&nbsp;</th>' . "\n";
}
echo '</tr>' . "\n";
unset( $column_order, $stat_name, $stat, $databases );
if ($is_superuser || $cfg['AllowUserDropDatabase']) { if ($is_superuser || $cfg['AllowUserDropDatabase']) {
$common_url_query = PMA_generate_common_url() . '&amp;sort_by=' . $sort_by . '&amp;sort_order=' . $sort_order . '&amp;dbstats=' . (empty($dbstats) ? '0' : '1'); $common_url_query = PMA_generate_common_url() . '&amp;sort_by=' . $sort_by . '&amp;sort_order=' . $sort_order . '&amp;dbstats=' . $dbstats;
echo ' <tr><td colspan="' . (!empty($dbstats) ? '10' : '3') . '">' . "\n" echo '<tr><td colspan="' . $table_columns . '">' . "\n"
. ' <img class="icon" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n" . ' <img class="icon" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n"
. ' <a href="./server_databases.php?' . $common_url_query . '&amp;checkall=1" onclick="setCheckboxes(\'dbStatsForm\', true); return false;">' . "\n" . ' <a href="./server_databases.php?' . $common_url_query . '&amp;checkall=1" onclick="setCheckboxes(\'dbStatsForm\', true); return false;">' . "\n"
. ' ' . $strCheckAll . ' ' . $strCheckAll
. ' </a>' . "\n" . ' </a> / ' . "\n"
. ' / ' . "\n"
. ' <a href="./server_databases.php?' . $common_url_query . '" onclick="setCheckboxes(\'dbStatsForm\', false); return false;">' . "\n" . ' <a href="./server_databases.php?' . $common_url_query . '" onclick="setCheckboxes(\'dbStatsForm\', false); return false;">' . "\n"
. ' ' . $strUncheckAll . ' ' . $strUncheckAll
. ' </a>' . "\n" . ' </a>' . "\n"
. ' </td>' . "\n" . ' <i>' . $strWithChecked . '</i>' . "\n";
PMA_buttonOrImage( 'drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', $strDrop, 'b_deltbl.png' );
echo ' </td>' . "\n"
. '</tr>' . "\n"; . '</tr>' . "\n";
} }
echo '</tbody>' . "\n" echo '</tbody>' . "\n"
.'</table>' . "\n"; .'</table>' . "\n";
unset($data_size); unset( $table_columns );
unset($data_unit);
unset($idx_size); if ( $GLOBALS['cfg']['PropertiesIconic'] ) {
unset($idx_unit);
unset($tot_size);
unset($tot_unit);
if ( $GLOBALS['cfg']['PropertiesIconic'] )
{
// iconic view // iconic view
if ($is_superuser || $cfg['AllowUserDropDatabase']) { if ($is_superuser || $cfg['AllowUserDropDatabase']) {
echo ' <br /><table cellpadding="2" cellspacing="0">' . "\n"; echo '<table cellpadding="2" cellspacing="0">' . "\n";
if ($is_superuser && empty($dbstats)) { if ( $is_superuser && ! $dbstats && PMA_MYSQL_INT_VERSION < 50002 ) {
echo '<tr><td><a href="./server_databases.php?' . $url_query . '&amp;dbstats=1" title="' . $strDatabasesStatsEnable . '">' . "\n" echo '<tr><td><a href="./server_databases.php?' . $url_query . '&amp;dbstats=1" title="' . $strDatabasesStatsEnable . '">' . "\n"
. ' <img class="icon" src="' .$pmaThemeImage . 'b_dbstatistics.png" width="16" height="16" alt="" />' . "\n" . ' <img class="icon" src="' .$pmaThemeImage . 'b_dbstatistics.png" width="16" height="16" alt="" />' . "\n"
. ' </a>' . "\n" . ' </a>' . "\n"
. ' </td><td>' . "\n" . ' </td>' . "\n"
. ' <strong>' . "\n" . ' <td><strong>' . "\n"
. ' <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1" title="' . $strDatabasesStatsEnable . '">' . "\n" . ' <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1" title="' . $strDatabasesStatsEnable . '">' . "\n"
. ' ' . $strDatabasesStatsEnable . "\n" . ' ' . $strDatabasesStatsEnable . "\n"
. ' </a>' . "\n" . ' </a>' . "\n"
@@ -323,7 +329,7 @@ if (count($statistics) > 0) {
. ' </td></tr><tr><td></td><td>' . "\n" . ' </td></tr><tr><td></td><td>' . "\n"
. ' ' . $strDatabasesStatsHeavyTraffic . "\n" . ' ' . $strDatabasesStatsHeavyTraffic . "\n"
. ' <br />&nbsp;</td></tr>' . "\n"; . ' <br />&nbsp;</td></tr>' . "\n";
} else if ($is_superuser && !empty($dbstats)) { } elseif ( $is_superuser && $dbstats ) {
echo '<tr><td><a href="./server_databases.php?' . $url_query . '" title="' . $strDatabasesStatsDisable . '">' . "\n" echo '<tr><td><a href="./server_databases.php?' . $url_query . '" title="' . $strDatabasesStatsDisable . '">' . "\n"
. ' <img class="icon" src="' .$pmaThemeImage . 'b_dbstatistics.png" width="16" height="16" alt="" />' . "\n" . ' <img class="icon" src="' .$pmaThemeImage . 'b_dbstatistics.png" width="16" height="16" alt="" />' . "\n"
. ' </a>' . "\n" . ' </a>' . "\n"
@@ -335,32 +341,20 @@ if (count($statistics) > 0) {
. ' </strong>' . "\n" . ' </strong>' . "\n"
. ' </td></tr><tr><td colspan="2">&nbsp;</td></tr>' . "\n"; . ' </td></tr><tr><td colspan="2">&nbsp;</td></tr>' . "\n";
} }
echo ' <tr><td><img class="icon" src="' .$pmaThemeImage . 'b_deltbl.png" width="16" height="16" alt="" />' . "\n" echo '</table>' . "\n";
. ' </td>' . "\n"
. ' <td><strong>'
. ' ' . $strDropSelectedDatabases
. ' </strong>' . "\n"
. ' </td></tr><tr><td >&nbsp;</td><td>' . "\n"
. ' <input type="submit" name="drop_selected_dbs" value="' . $strDrop . '" id="buttonNo" />' . "\n"
. ' <br />&nbsp;</td></tr>' . "\n"
. ' </table>' . "\n";
} }
} } else {
else
{
// classic view // classic view
if ($is_superuser || $cfg['AllowUserDropDatabase']) { if ($is_superuser || $cfg['AllowUserDropDatabase']) {
echo ' <br /><ul>' . "\n"; echo '<ul>' . "\n";
if ($is_superuser && empty($dbstats)) { if ( $is_superuser && ! $dbstats && PMA_MYSQL_INT_VERSION < 50002 ) {
echo ' <li><strong>' . "\n" echo ' <li><strong>' . "\n"
. ' <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1" title="' . $strDatabasesStatsEnable . '">' . "\n" . ' <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1" title="' . $strDatabasesStatsEnable . '">' . "\n"
. ' ' . $strDatabasesStatsEnable . "\n" . ' ' . $strDatabasesStatsEnable . "\n"
. ' </a>' . "\n" . ' </a>' . "\n"
. ' </strong>' . "\n" . ' </strong><br />' . "\n"
. ' <br />' . "\n" . ' ' . $strDatabasesStatsHeavyTraffic . '</li>' . "\n";
. ' ' . $strDatabasesStatsHeavyTraffic . "\n" } elseif ( $is_superuser && $dbstats ) {
. ' </li>' . "\n";
} else if ($is_superuser && !empty($dbstats)) {
echo ' <li><strong>' . "\n" echo ' <li><strong>' . "\n"
. ' <a href="./server_databases.php?' . $url_query . '" title="' . $strDatabasesStatsDisable . '">' . "\n" . ' <a href="./server_databases.php?' . $url_query . '" title="' . $strDatabasesStatsDisable . '">' . "\n"
. ' ' . $strDatabasesStatsDisable . "\n" . ' ' . $strDatabasesStatsDisable . "\n"
@@ -368,12 +362,7 @@ if (count($statistics) > 0) {
. ' </strong>' . "\n" . ' </strong>' . "\n"
. ' <br /></li>' . "\n"; . ' <br /></li>' . "\n";
} }
echo ' <li><strong>' . $strDropSelectedDatabases . "\n" echo '</ul>' . "\n";
. ' </strong>' . "\n"
. ' <br />' . "\n"
. ' <input type="submit" name="drop_selected_dbs" value="' . $strDrop . '" id="buttonNo" />' . "\n"
. ' </li>' . "\n"
. ' </ul>' . "\n";
} }
} }
echo '</form>' . "\n"; echo '</form>' . "\n";
@@ -387,16 +376,14 @@ if (count($statistics) > 0) {
if ( $GLOBALS['cfg']['PropertiesIconic'] ) if ( $GLOBALS['cfg']['PropertiesIconic'] )
{ {
echo '<table cellpadding="2" cellspacing="0">' . "\n"; echo '<table cellpadding="2" cellspacing="0">' . "\n";
echo '<tr>' . "\n" echo '<tr><td style="vertical-align: baseline;">' . "\n"
. ' <td style="vertical-align: baseline;">' . "\n"
. ' <img class="icon" src="' .$pmaThemeImage . 'b_newdb.png" width="16" height="16" alt="" />' . "\n" . ' <img class="icon" src="' .$pmaThemeImage . 'b_newdb.png" width="16" height="16" alt="" />' . "\n"
. ' </td>' . "\n" . ' </td>' . "\n"
. ' <td>' . "\n"; . ' <td>' . "\n";
} }
else else
{ {
echo '<ul>' . "\n"; echo '<ul><li>' . "\n";
echo ' <li>' . "\n";
} }
require('./libraries/display_create_database.lib.php'); require('./libraries/display_create_database.lib.php');