4.0.9-dev
[phpmyadmin.git] / server_binlog.php
blob8c82d5f25b785442c168bd49da2a40c08861a513
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * display the binary logs and the content of the selected
6 * @package PhpMyAdmin
7 */
9 /**
12 require_once 'libraries/common.inc.php';
14 /**
15 * Does the common work, provides $binary_logs
17 require_once 'libraries/server_common.inc.php';
19 $url_params = array();
21 /**
22 * Need to find the real end of rows?
24 if (! isset($_REQUEST['pos'])) {
25 $pos = 0;
26 } else {
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)
33 ) {
34 $_REQUEST['log'] = '';
35 } else {
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'];
47 /**
48 * Sends the query
50 $result = PMA_DBI_query($sql_query);
52 /**
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);
58 } else {
59 $num_rows = 0;
62 if (empty($_REQUEST['dontlimitchars'])) {
63 $dontlimitchars = false;
64 } else {
65 $dontlimitchars = true;
66 $url_params['dontlimitchars'] = 1;
69 /**
70 * Displays the sub-page heading
72 echo '<h2>' . "\n"
73 . PMA_Util::getImage('s_tbl.png')
74 . ' ' . __('Binary log') . "\n"
75 . '</h2>' . "\n";
77 /**
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">';
86 $full_size = 0;
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'];
95 echo ' ('
96 . implode(
97 ' ',
98 PMA_Util::formatByteDown(
99 $each_log['File_size'], 3, 2
102 . ')';
104 echo '</option>';
106 echo '</select> ';
107 echo count($binary_logs) . ' ' . __('Files') . ', ';
108 if ($full_size > 0) {
109 echo implode(
110 ' ', PMA_Util::formatByteDown($full_size)
113 echo '</fieldset>';
114 echo '<fieldset class="tblFooters">';
115 echo '<input type="submit" value="' . __('Go') . '" />';
116 echo '</fieldset>';
117 echo '</form>';
120 echo PMA_Util::getMessage(PMA_Message::success());
123 * Displays the page
125 echo '<table cellpadding="2" cellspacing="1">'
126 . '<thead>'
127 . '<tr>'
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
132 if ($pos > 0) {
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 (in_array(
141 $GLOBALS['cfg']['TableNavigationLinksMode'],
142 array('icons', 'both')
145 echo ' title="' . _pgettext('Previous page', 'Previous') . '">';
146 } else {
147 echo '>' . _pgettext('Previous page', 'Previous');
148 } // end if... else...
149 echo ' &lt; </a> - ';
152 $this_url_params = $url_params;
153 if ($pos > 0) {
154 $this_url_params['pos'] = $pos;
156 if ($dontlimitchars) {
157 unset($this_url_params['dontlimitchars']);
158 $tempTitle = __('Truncate Shown Queries');
159 $tempImgMode = 'partial';
160 } else {
161 $this_url_params['dontlimitchars'] = 1;
162 $tempTitle = __('Show Full Queries');
163 $tempImgMode = 'full';
165 echo '<a href="server_binlog.php' . PMA_generate_common_url($this_url_params)
166 . '" title="' . $tempTitle . '">'
167 . '<img src="' .$pmaThemeImage . 's_' . $tempImgMode . 'text.png"'
168 . 'alt="' . $tempTitle . '" /></a>';
170 // we do not now how much rows are in the binlog
171 // so we can just force 'NEXT' button
172 if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
173 $this_url_params = $url_params;
174 $this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows'];
175 echo ' - <a href="server_binlog.php' . PMA_generate_common_url($this_url_params)
176 . '"';
177 if (in_array(
178 $GLOBALS['cfg']['TableNavigationLinksMode'],
179 array('icons', 'both')
182 echo ' title="' . _pgettext('Next page', 'Next') . '">';
183 } else {
184 echo '>' . _pgettext('Next page', 'Next');
185 } // end if... else...
186 echo ' &gt; </a>';
189 echo '</td>'
190 . '</tr>'
191 . '<tr>'
192 . '<th>' . __('Log name') . '</th>'
193 . '<th>' . __('Position') . '</th>'
194 . '<th>' . __('Event type') . '</th>'
195 . '<th>' . __('Server ID') . '</th>'
196 . '<th>' . __('Original position') . '</th>'
197 . '<th>' . __('Information') . '</th>'
198 . '</tr>'
199 . '</thead>'
200 . '<tbody>';
202 $odd_row = true;
203 while ($value = PMA_DBI_fetch_assoc($result)) {
204 if (! $dontlimitchars
205 && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']
207 $value['Info'] = PMA_substr(
208 $value['Info'], 0, $GLOBALS['cfg']['LimitChars']
209 ) . '...';
212 echo '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">'
213 . '<td>&nbsp;' . $value['Log_name'] . '&nbsp;</td>'
214 . '<td class="right">&nbsp;' . $value['Pos'] . '&nbsp;</td>'
215 . '<td>&nbsp;' . $value['Event_type'] . '&nbsp;</td>'
216 . '<td class="right">&nbsp;' . $value['Server_id'] . '&nbsp;</td>'
217 . '<td class="right">&nbsp;'
218 . (isset($value['Orig_log_pos'])
219 ? $value['Orig_log_pos'] : $value['End_log_pos'])
220 . '&nbsp;</td>'
221 . '<td>&nbsp;' . htmlspecialchars($value['Info']) . '&nbsp;</td>'
222 . '</tr>';
224 $odd_row = !$odd_row;
226 echo '</tbody>'
227 . '</table>';