2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * display the binary logs and the content of the selected
12 require_once 'libraries/common.inc.php';
15 * Does the common work, provides $binary_logs
17 require_once 'libraries/server_common.inc.php';
19 $url_params = array();
22 * Need to find the real end of rows?
24 if (! isset($_REQUEST['pos'])) {
27 /* We need this to be a integer */
28 $pos = (int) $_REQUEST['pos'];
31 if (! isset($_REQUEST['log'])
32 ||
! array_key_exists($_REQUEST['log'], $binary_logs)
34 $_REQUEST['log'] = '';
36 $url_params['log'] = $_REQUEST['log'];
39 $sql_query = 'SHOW BINLOG EVENTS';
40 if (! empty($_REQUEST['log'])) {
41 $sql_query .= ' IN \'' . $_REQUEST['log'] . '\'';
43 if ($GLOBALS['cfg']['MaxRows'] !== 'all') {
44 $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows'];
50 $result = PMA_DBI_query($sql_query);
53 * prepare some vars for displaying the result table
55 // Gets the list of fields properties
56 if (isset($result) && $result) {
57 $num_rows = PMA_DBI_num_rows($result);
62 if (empty($_REQUEST['dontlimitchars'])) {
63 $dontlimitchars = false;
65 $dontlimitchars = true;
66 $url_params['dontlimitchars'] = 1;
70 * Displays the sub-page heading
73 . PMA_Util
::getImage('s_tbl.png')
74 . ' ' . __('Binary log') . "\n"
78 * Display log selector.
80 if (count($binary_logs) > 1) {
81 echo '<form action="server_binlog.php" method="get">';
82 echo PMA_generate_common_hidden_inputs($url_params);
83 echo '<fieldset><legend>';
84 echo __('Select binary log to view');
85 echo '</legend><select name="log">';
87 foreach ($binary_logs as $each_log) {
88 echo '<option value="' . $each_log['Log_name'] . '"';
89 if ($each_log['Log_name'] == $_REQUEST['log']) {
90 echo ' selected="selected"';
92 echo '>' . $each_log['Log_name'];
93 if (isset($each_log['File_size'])) {
94 $full_size +
= $each_log['File_size'];
98 PMA_Util
::formatByteDown(
99 $each_log['File_size'], 3, 2
107 echo count($binary_logs) . ' ' . __('Files') . ', ';
108 if ($full_size > 0) {
110 ' ', PMA_Util
::formatByteDown($full_size)
114 echo '<fieldset class="tblFooters">';
115 echo '<input type="submit" value="' . __('Go') . '" />';
120 echo PMA_Util
::getMessage(PMA_Message
::success());
125 echo '<table cellpadding="2" cellspacing="1">'
128 . '<td colspan="6" class="center">';
130 // we do not now how much rows are in the binlog
131 // so we can just force 'NEXT' button
133 $this_url_params = $url_params;
134 if ($pos > $GLOBALS['cfg']['MaxRows']) {
135 $this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows'];
138 echo '<a href="server_binlog.php'
139 . PMA_generate_common_url($this_url_params) . '"';
140 if ($GLOBALS['cfg']['NavigationBarIconic']) {
141 echo ' title="' . _pgettext('Previous page', 'Previous') . '">';
143 echo '>' . _pgettext('Previous page', 'Previous');
144 } // end if... else...
145 echo ' < </a> - ';
148 $this_url_params = $url_params;
150 $this_url_params['pos'] = $pos;
152 if ($dontlimitchars) {
153 unset($this_url_params['dontlimitchars']);
154 $tempTitle = __('Truncate Shown Queries');
155 $tempImgMode = 'partial';
157 $this_url_params['dontlimitchars'] = 1;
158 $tempTitle = __('Show Full Queries');
159 $tempImgMode = 'full';
161 echo '<a href="server_binlog.php' . PMA_generate_common_url($this_url_params)
162 . '" title="' . $tempTitle . '">'
163 . '<img src="' .$pmaThemeImage . 's_' . $tmpImgMode . 'text.png"'
164 . 'alt="' . $tempTitle . '" /></a>';
166 // we do not now how much rows are in the binlog
167 // so we can just force 'NEXT' button
168 if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
169 $this_url_params = $url_params;
170 $this_url_params['pos'] = $pos +
$GLOBALS['cfg']['MaxRows'];
171 echo ' - <a href="server_binlog.php' . PMA_generate_common_url($this_url_params)
173 if ($GLOBALS['cfg']['NavigationBarIconic']) {
174 echo ' title="' . _pgettext('Next page', 'Next') . '">';
176 echo '>' . _pgettext('Next page', 'Next');
177 } // end if... else...
184 . '<th>' . __('Log name') . '</th>'
185 . '<th>' . __('Position') . '</th>'
186 . '<th>' . __('Event type') . '</th>'
187 . '<th>' . __('Server ID') . '</th>'
188 . '<th>' . __('Original position') . '</th>'
189 . '<th>' . __('Information') . '</th>'
195 while ($value = PMA_DBI_fetch_assoc($result)) {
196 if (! $dontlimitchars
197 && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']
199 $value['Info'] = PMA_substr(
200 $value['Info'], 0, $GLOBALS['cfg']['LimitChars']
204 echo '<tr class="noclick ' . ($odd_row ?
'odd' : 'even') . '">'
205 . '<td> ' . $value['Log_name'] . ' </td>'
206 . '<td class="right"> ' . $value['Pos'] . ' </td>'
207 . '<td> ' . $value['Event_type'] . ' </td>'
208 . '<td class="right"> ' . $value['Server_id'] . ' </td>'
209 . '<td class="right"> '
210 . (isset($value['Orig_log_pos'])
211 ?
$value['Orig_log_pos'] : $value['End_log_pos'])
213 . '<td> ' . htmlspecialchars($value['Info']) . ' </td>'
216 $odd_row = !$odd_row;