From a56222d99a37b5a3901a8a216e829a09c791473e Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Tue, 13 Mar 2007 09:55:19 +0000 Subject: [PATCH] improved displaying of binary logs: - limit displayed rows to $cfg[MaxRows] - show single and summary log file size (MySQL >= 5.0.7) cleaned up the code added some more sanity checks source documentation --- ChangeLog | 3 +- libraries/server_common.inc.php | 39 +++--- server_binlog.php | 233 +++++++++++++++++++++++++------- 3 files changed, 207 insertions(+), 68 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8ecd2625..5f5669177 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,7 +6,7 @@ $Id$ $HeadURL$ + [import] support handling of DELIMITER to mimic mysql CLI, thanks to fb1 -- bug #1674914 [structure] changing definition of a TIMESTAMP field +- bug #1674914 [structure] changing definition of a TIMESTAMP field - bug #1615530 [upload] added more specific error message if field upload fails - [gui] avoid displaying a wide selector in server selection + [core] added PMA_fatalError() and made use of it @@ -21,6 +21,7 @@ $HeadURL$ + [export] YAML export (see yaml.org), thanks to Bryce Thornton + [upload] moved file upload functionality into own class + [upload] make use of $cfg['TempDir'] for file uploads ++ [server] improved display of binary logs 2.10.1.0 (not released yet) ===================== diff --git a/libraries/server_common.inc.php b/libraries/server_common.inc.php index ca80eb567..7e7cf2ec4 100644 --- a/libraries/server_common.inc.php +++ b/libraries/server_common.inc.php @@ -1,11 +1,19 @@ 0) { - $binary_logs = array(); - while ($row = PMA_DBI_fetch_array($binlogs)) { - $binary_logs[] = $row[0]; - } - $has_binlogs = TRUE; - } - PMA_DBI_free_result($binlogs); -} -unset($binlogs); +/** + * @global array binary log files + */ +$binary_logs = PMA_DBI_fetch_result('SHOW MASTER LOGS', 'Log_name', null, null, + PMA_DBI_QUERY_STORE); ?> diff --git a/server_binlog.php b/server_binlog.php index d7cf8e2b4..8d0e4d2d9 100644 --- a/server_binlog.php +++ b/server_binlog.php @@ -1,57 +1,83 @@ ' . "\n" - . ($cfg['MainPageIconic'] ? '' : '' ) - . ' ' . $strBinaryLog . "\n" - . '' . "\n"; - -if (!isset($log)) { - $log = ''; +if (! isset($_REQUEST['pos'])) { + $pos = 0; +} else { + /* We need this to be a integer */ + $pos = (int) $_REQUEST['pos']; } -/** - * Display log selector. - */ -if (count($binary_logs) > 1) { - echo '
'; - echo PMA_generate_common_hidden_inputs(); - echo '
'; - echo $strSelectBinaryLog; - echo ''; - echo '
'; - echo '
'; - echo ''; - echo '
'; - echo '
'; +if (! isset($_REQUEST['log']) || ! array_key_exists($_REQUEST['log'], $binary_logs)) { + $_REQUEST['log'] = ''; +} else { + $url_params['log'] = $_REQUEST['log']; } - $sql_query = 'SHOW BINLOG EVENTS'; -if (!empty($log)) { - $sql_query .= ' IN \'' . $log . '\''; +if (! empty($_REQUEST['log'])) { + $sql_query .= ' IN \'' . $_REQUEST['log'] . '\''; +} +if ($GLOBALS['cfg']['MaxRows'] !== 'all') { + $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows']; } /** @@ -59,34 +85,146 @@ if (!empty($log)) { */ $result = PMA_DBI_query($sql_query); -PMA_showMessage($GLOBALS['strSuccess']); +/** + * prepare some vars for displaying the result table + */ +// Gets the list of fields properties +if (isset($result) && $result) { + $num_rows = PMA_DBI_num_rows($result); +} else { + $num_rows = 0; +} +if (empty($_REQUEST['dontlimitchars'])) { + $dontlimitchars = false; +} else { + $dontlimitchars = true; + $url_params['dontlimitchars'] = 1; +} + +/** + * Displays the sub-page heading + */ +echo '

' . "\n" + . ($GLOBALS['cfg']['MainPageIconic'] ? '' : '' ) + . ' ' . $GLOBALS['strBinaryLog'] . "\n" + . '

' . "\n"; + +/** + * Display log selector. + */ +if (count($binary_logs) > 1) { + echo '
'; + echo PMA_generate_common_hidden_inputs($url_params); + echo '
'; + echo $GLOBALS['strSelectBinaryLog']; + echo ' '; + echo count($binary_logs) . ' ' . $GLOBALS['strFiles'] . ', '; + if ($full_size > 0) { + echo implode(' ', PMA_formatByteDown($full_size)); + } + echo '
'; + echo '
'; + echo ''; + echo '
'; + echo '
'; +} + +PMA_showMessage($GLOBALS['strSuccess']); /** * Displays the page */ ?> + + alt="" /> + + + <?php echo $GLOBALS['strShowFullQueries']; ?> + = $GLOBALS['cfg']['MaxRows']) { + $this_url_params = $url_params; + $this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows']; + echo ' - '; + } else { + echo '>' . $GLOBALS['strNext']; + } // end if... else... + echo ' > '; +} +?> + - - - - - - + + + + + + + + $GLOBALS['cfg']['LimitChars']) { +while ($value = PMA_DBI_fetch_assoc($result)) { + if (! $dontlimitchars && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']) { $value['Info'] = PMA_substr($value['Info'], 0, $GLOBALS['cfg']['LimitChars']) . '...'; } ?> @@ -102,6 +240,7 @@ while($value = PMA_DBI_fetch_assoc($result)) { $odd_row = !$odd_row; } ?> +
- - 0) { + $this_url_params = $url_params; + if ($pos > $GLOBALS['cfg']['MaxRows']) { + $this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows']; + } + + echo ''; + } else { + echo '>' . $GLOBALS['strPrevious']; + } // end if... else... + echo ' < - '; +} + +$this_url_params = $url_params; +if ($pos > 0) { + $this_url_params['pos'] = $pos; +} +if ($dontlimitchars) { + unset($this_url_params['dontlimitchars']); + ?> + + <?php echo empty($full) ? $strShowFullQueries : $strTruncateQueries; ?>