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
This commit is contained in:
@@ -21,6 +21,7 @@ $HeadURL$
|
|||||||
+ [export] YAML export (see yaml.org), thanks to Bryce Thornton
|
+ [export] YAML export (see yaml.org), thanks to Bryce Thornton
|
||||||
+ [upload] moved file upload functionality into own class
|
+ [upload] moved file upload functionality into own class
|
||||||
+ [upload] make use of $cfg['TempDir'] for file uploads
|
+ [upload] make use of $cfg['TempDir'] for file uploads
|
||||||
|
+ [server] improved display of binary logs
|
||||||
|
|
||||||
2.10.1.0 (not released yet)
|
2.10.1.0 (not released yet)
|
||||||
=====================
|
=====================
|
||||||
|
@@ -1,11 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
/* $Id$ */
|
/* vim: expandtab sw=4 ts=4 sts=4: */
|
||||||
// vim: expandtab sw=4 ts=4 sts=4:
|
/**
|
||||||
|
* @uses PMA_generate_common_url()
|
||||||
|
* @uses PMA_isSuperuser()
|
||||||
|
* @uses PMA_DBI_select_db()
|
||||||
|
* @uses PMA_DBI_fetch_result()
|
||||||
|
* @uses PMA_DBI_QUERY_STORE
|
||||||
|
* @uses $userlink
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets some core libraries
|
* Gets some core libraries
|
||||||
*/
|
*/
|
||||||
require_once('./libraries/common.lib.php');
|
require_once './libraries/common.lib.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles some variables that may have been sent by the calling script
|
* Handles some variables that may have been sent by the calling script
|
||||||
@@ -30,12 +38,11 @@ $err_url = 'main.php' . $url_query;
|
|||||||
/**
|
/**
|
||||||
* Displays the headers
|
* Displays the headers
|
||||||
*/
|
*/
|
||||||
require_once('./libraries/header.inc.php');
|
require_once './libraries/header.inc.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for superuser privileges
|
* @global boolean Checks for superuser privileges
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$is_superuser = PMA_isSuperuser();
|
$is_superuser = PMA_isSuperuser();
|
||||||
|
|
||||||
// now, select the mysql db
|
// now, select the mysql db
|
||||||
@@ -43,17 +50,9 @@ if ($is_superuser) {
|
|||||||
PMA_DBI_select_db('mysql', $userlink);
|
PMA_DBI_select_db('mysql', $userlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
$has_binlogs = FALSE;
|
/**
|
||||||
$binlogs = PMA_DBI_try_query('SHOW MASTER LOGS', null, PMA_DBI_QUERY_STORE);
|
* @global array binary log files
|
||||||
if ($binlogs) {
|
*/
|
||||||
if (PMA_DBI_num_rows($binlogs) > 0) {
|
$binary_logs = PMA_DBI_fetch_result('SHOW MASTER LOGS', 'Log_name', null, null,
|
||||||
$binary_logs = array();
|
PMA_DBI_QUERY_STORE);
|
||||||
while ($row = PMA_DBI_fetch_array($binlogs)) {
|
|
||||||
$binary_logs[] = $row[0];
|
|
||||||
}
|
|
||||||
$has_binlogs = TRUE;
|
|
||||||
}
|
|
||||||
PMA_DBI_free_result($binlogs);
|
|
||||||
}
|
|
||||||
unset($binlogs);
|
|
||||||
?>
|
?>
|
||||||
|
@@ -1,57 +1,83 @@
|
|||||||
<?php
|
<?php
|
||||||
/* $Id$ */
|
/* vim: expandtab sw=4 ts=4 sts=4: */
|
||||||
// vim: expandtab sw=4 ts=4 sts=4:
|
/**
|
||||||
|
* display the binary logs and the content of the selected
|
||||||
|
*
|
||||||
|
* @uses $cfg['MainPageIconic']
|
||||||
|
* @uses $cfg['NavigationBarIconic']
|
||||||
|
* @uses $cfg['MaxRows']
|
||||||
|
* @uses $cfg['LimitChars']
|
||||||
|
* @uses $pmaThemeImage
|
||||||
|
* @uses $GLOBALS['strBinaryLog']
|
||||||
|
* @uses $GLOBALS['strGo']
|
||||||
|
* @uses $GLOBALS['strTruncateQueries']
|
||||||
|
* @uses $GLOBALS['strShowFullQueries']
|
||||||
|
* @uses $GLOBALS['strBinLogName']
|
||||||
|
* @uses $GLOBALS['strBinLogPosition']
|
||||||
|
* @uses $GLOBALS['strBinLogEventType']
|
||||||
|
* @uses $GLOBALS['strBinLogServerId']
|
||||||
|
* @uses $GLOBALS['strBinLogOriginalPosition']
|
||||||
|
* @uses $GLOBALS['strBinLogInfo']
|
||||||
|
* @uses $GLOBALS['strFiles']
|
||||||
|
* @uses $GLOBALS['strPrevious']
|
||||||
|
* @uses $GLOBALS['strNext']
|
||||||
|
* @uses $binary_logs
|
||||||
|
* @uses PMA_generate_common_hidden_inputs()
|
||||||
|
* @uses PMA_generate_common_url()
|
||||||
|
* @uses PMA_formatByteDown()
|
||||||
|
* @uses PMA_showMessage()
|
||||||
|
* @uses PMA_DBI_fetch_assoc()
|
||||||
|
* @uses PMA_strlen()
|
||||||
|
* @uses PMA_substr()
|
||||||
|
* @uses $_REQUEST['pos']
|
||||||
|
* @uses $_REQUEST['log']
|
||||||
|
* @uses $_REQUEST['dontlimitchars']
|
||||||
|
* @uses count()
|
||||||
|
* @uses array_key_exists()
|
||||||
|
* @uses implode()
|
||||||
|
* @uses htmlspecialchars()
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once './libraries/common.lib.php';
|
require_once './libraries/common.lib.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the common work
|
* Does the common work, provides $binary_logs
|
||||||
*/
|
*/
|
||||||
require_once './libraries/server_common.inc.php';
|
require_once './libraries/server_common.inc.php';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the links
|
* Displays the links
|
||||||
*/
|
*/
|
||||||
require './libraries/server_links.inc.php';
|
require_once './libraries/server_links.inc.php';
|
||||||
|
|
||||||
|
$url_params = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the sub-page heading
|
* Need to find the real end of rows?
|
||||||
*/
|
*/
|
||||||
echo '<h2>' . "\n"
|
if (! isset($_REQUEST['pos'])) {
|
||||||
. ($cfg['MainPageIconic'] ? '<img src="' . $pmaThemeImage . 's_process.png" width="16" height="16" border="0" hspace="2" align="middle" alt="" />' : '' )
|
$pos = 0;
|
||||||
. ' ' . $strBinaryLog . "\n"
|
} else {
|
||||||
. '</h2>' . "\n";
|
/* We need this to be a integer */
|
||||||
|
$pos = (int) $_REQUEST['pos'];
|
||||||
if (!isset($log)) {
|
|
||||||
$log = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
if (! isset($_REQUEST['log']) || ! array_key_exists($_REQUEST['log'], $binary_logs)) {
|
||||||
* Display log selector.
|
$_REQUEST['log'] = '';
|
||||||
*/
|
} else {
|
||||||
if (count($binary_logs) > 1) {
|
$url_params['log'] = $_REQUEST['log'];
|
||||||
echo '<form action="server_binlog.php" method="get">';
|
|
||||||
echo PMA_generate_common_hidden_inputs();
|
|
||||||
echo '<fieldset><legend>';
|
|
||||||
echo $strSelectBinaryLog;
|
|
||||||
echo '</legend><select name="log">';
|
|
||||||
foreach ($binary_logs as $name) {
|
|
||||||
echo '<option value="' . $name . '"' . ($name == $log ? ' selected="selected"' : '') . '>' . $name . '</option>';
|
|
||||||
}
|
|
||||||
echo '</select>';
|
|
||||||
echo '</fieldset>';
|
|
||||||
echo '<fieldset class="tblFooters">';
|
|
||||||
echo '<input type="submit" value="' . $strGo . '" />';
|
|
||||||
echo '</fieldset>';
|
|
||||||
echo '</form>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql_query = 'SHOW BINLOG EVENTS';
|
$sql_query = 'SHOW BINLOG EVENTS';
|
||||||
if (!empty($log)) {
|
if (! empty($_REQUEST['log'])) {
|
||||||
$sql_query .= ' IN \'' . $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);
|
$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 '<h2>' . "\n"
|
||||||
|
. ($GLOBALS['cfg']['MainPageIconic'] ? '<img src="' . $pmaThemeImage . 's_process.png" width="16" height="16" border="0" hspace="2" align="middle" alt="" />' : '' )
|
||||||
|
. ' ' . $GLOBALS['strBinaryLog'] . "\n"
|
||||||
|
. '</h2>' . "\n";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display log selector.
|
||||||
|
*/
|
||||||
|
if (count($binary_logs) > 1) {
|
||||||
|
echo '<form action="server_binlog.php" method="get">';
|
||||||
|
echo PMA_generate_common_hidden_inputs($url_params);
|
||||||
|
echo '<fieldset><legend>';
|
||||||
|
echo $GLOBALS['strSelectBinaryLog'];
|
||||||
|
echo '</legend><select name="log">';
|
||||||
|
$full_size = 0;
|
||||||
|
foreach ($binary_logs as $each_log) {
|
||||||
|
echo '<option value="' . $each_log['Log_name'] . '"';
|
||||||
|
if ($each_log['Log_name'] == $_REQUEST['log']) {
|
||||||
|
echo ' selected="selected"';
|
||||||
|
}
|
||||||
|
echo '>' . $each_log['Log_name'];
|
||||||
|
if (isset($each_log['File_size'])) {
|
||||||
|
$full_size += $each_log['File_size'];
|
||||||
|
echo ' (' . implode(' ', PMA_formatByteDown($each_log['File_size'], 3, 2)) . ')';
|
||||||
|
}
|
||||||
|
echo '</option>';
|
||||||
|
}
|
||||||
|
echo '</select> ';
|
||||||
|
echo count($binary_logs) . ' ' . $GLOBALS['strFiles'] . ', ';
|
||||||
|
if ($full_size > 0) {
|
||||||
|
echo implode(' ', PMA_formatByteDown($full_size));
|
||||||
|
}
|
||||||
|
echo '</fieldset>';
|
||||||
|
echo '<fieldset class="tblFooters">';
|
||||||
|
echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
|
||||||
|
echo '</fieldset>';
|
||||||
|
echo '</form>';
|
||||||
|
}
|
||||||
|
|
||||||
|
PMA_showMessage($GLOBALS['strSuccess']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the page
|
* Displays the page
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<table border="0" cellpadding="2" cellspacing="1">
|
<table border="0" cellpadding="2" cellspacing="1">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" align="center">
|
<td colspan="6" align="center">
|
||||||
<a href="./server_binlog.php?<?php echo $url_query . (!empty($log) ? '&log=' . htmlspecialchars($log) : '' ) . (empty($full) ? '&full=1' : ''); ?>"
|
<?php
|
||||||
title="<?php echo empty($full) ? $strShowFullQueries : $strTruncateQueries; ?>">
|
// we do not now how much rows are in the binlog
|
||||||
<img src="<?php echo $pmaThemeImage . 's_' . (empty($full) ? 'full' : 'partial'); ?>text.png"
|
// so we can just force 'NEXT' button
|
||||||
|
if ($pos > 0) {
|
||||||
|
$this_url_params = $url_params;
|
||||||
|
if ($pos > $GLOBALS['cfg']['MaxRows']) {
|
||||||
|
$this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows'];
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<a href="./server_binlog.php' . PMA_generate_common_url($this_url_params) . '"';
|
||||||
|
if ($GLOBALS['cfg']['NavigationBarIconic']) {
|
||||||
|
echo ' title="' . $GLOBALS['strPrevious'] . '">';
|
||||||
|
} else {
|
||||||
|
echo '>' . $GLOBALS['strPrevious'];
|
||||||
|
} // end if... else...
|
||||||
|
echo ' < </a> - ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this_url_params = $url_params;
|
||||||
|
if ($pos > 0) {
|
||||||
|
$this_url_params['pos'] = $pos;
|
||||||
|
}
|
||||||
|
if ($dontlimitchars) {
|
||||||
|
unset($this_url_params['dontlimitchars']);
|
||||||
|
?>
|
||||||
|
<a href="./server_binlog.php<?php echo PMA_generate_common_url($this_url_params); ?>"
|
||||||
|
title="<?php $GLOBALS['strTruncateQueries']; ?>">
|
||||||
|
<img src="<?php echo $pmaThemeImage; ?>s_partialtext.png"
|
||||||
width="50" height="20" border="0"
|
width="50" height="20" border="0"
|
||||||
alt="<?php echo empty($full) ? $strShowFullQueries : $strTruncateQueries; ?>" /></a></td>
|
alt="<?php echo $GLOBALS['strTruncateQueries']; ?>" /></a>
|
||||||
|
<?php
|
||||||
|
} else {
|
||||||
|
$this_url_params['dontlimitchars'] = 1;
|
||||||
|
?>
|
||||||
|
<a href="./server_binlog.php<?php echo PMA_generate_common_url($this_url_params); ?>"
|
||||||
|
title="<?php $GLOBALS['strShowFullQueries']; ?>">
|
||||||
|
<img src="<?php echo $pmaThemeImage; ?>s_fulltext.png"
|
||||||
|
width="50" height="20" border="0"
|
||||||
|
alt="<?php echo $GLOBALS['strShowFullQueries']; ?>" /></a>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
// we do not now how much rows are in the binlog
|
||||||
|
// so we can just force 'NEXT' button
|
||||||
|
if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
|
||||||
|
$this_url_params = $url_params;
|
||||||
|
$this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows'];
|
||||||
|
echo ' - <a href="./server_binlog.php' . PMA_generate_common_url($this_url_params) . '"';
|
||||||
|
if ($GLOBALS['cfg']['NavigationBarIconic']) {
|
||||||
|
echo ' title="' . $GLOBALS['strNext'] . '">';
|
||||||
|
} else {
|
||||||
|
echo '>' . $GLOBALS['strNext'];
|
||||||
|
} // end if... else...
|
||||||
|
echo ' > </a>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo $strBinLogName; ?></th>
|
<th><?php echo $GLOBALS['strBinLogName']; ?></th>
|
||||||
<th><?php echo $strBinLogPosition; ?></th>
|
<th><?php echo $GLOBALS['strBinLogPosition']; ?></th>
|
||||||
<th><?php echo $strBinLogEventType; ?></th>
|
<th><?php echo $GLOBALS['strBinLogEventType']; ?></th>
|
||||||
<th><?php echo $strBinLogServerId; ?></th>
|
<th><?php echo $GLOBALS['strBinLogServerId']; ?></th>
|
||||||
<th><?php echo $strBinLogOriginalPosition; ?></th>
|
<th><?php echo $GLOBALS['strBinLogOriginalPosition']; ?></th>
|
||||||
<th><?php echo $strBinLogInfo; ?></th>
|
<th><?php echo $GLOBALS['strBinLogInfo']; ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$odd_row = true;
|
$odd_row = true;
|
||||||
while($value = PMA_DBI_fetch_assoc($result)) {
|
while ($value = PMA_DBI_fetch_assoc($result)) {
|
||||||
if (empty($full) && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']) {
|
if (! $dontlimitchars && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']) {
|
||||||
$value['Info'] = PMA_substr($value['Info'], 0, $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;
|
$odd_row = !$odd_row;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user