Translated using Weblate (Spanish)
[phpmyadmin.git] / server_binlog.php
blob0efae229b05b4cfa543fa261aa4c29bce85739cd
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 /**
10 * requirements
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 $response = PMA_Response::getInstance();
20 $url_params = array();
22 /**
23 * Need to find the real end of rows?
25 if (! isset($_REQUEST['pos'])) {
26 $pos = 0;
27 } else {
28 /* We need this to be a integer */
29 $pos = (int) $_REQUEST['pos'];
32 if (! isset($_REQUEST['log'])
33 || ! array_key_exists($_REQUEST['log'], $binary_logs)
34 ) {
35 $_REQUEST['log'] = '';
36 } else {
37 $url_params['log'] = $_REQUEST['log'];
40 $sql_query = 'SHOW BINLOG EVENTS';
41 if (! empty($_REQUEST['log'])) {
42 $sql_query .= ' IN \'' . $_REQUEST['log'] . '\'';
44 if ($GLOBALS['cfg']['MaxRows'] !== 'all') {
45 $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows'];
48 /**
49 * Sends the query
51 $result = PMA_DBI_query($sql_query);
53 /**
54 * prepare some vars for displaying the result table
56 // Gets the list of fields properties
57 if (isset($result) && $result) {
58 $num_rows = PMA_DBI_numRows($result);
59 } else {
60 $num_rows = 0;
63 if (empty($_REQUEST['dontlimitchars'])) {
64 $dontlimitchars = false;
65 } else {
66 $dontlimitchars = true;
67 $url_params['dontlimitchars'] = 1;
70 /**
71 * Displays the sub-page heading
73 $html = '<h2>' . "\n"
74 . PMA_Util::getImage('s_tbl.png')
75 . ' ' . __('Binary log') . "\n"
76 . '</h2>' . "\n";
78 /**
79 * Display log selector.
81 if (count($binary_logs) > 1) {
82 $html .= '<form action="server_binlog.php" method="get">';
83 $html .= PMA_generate_common_hidden_inputs($url_params);
84 $html .= '<fieldset><legend>';
85 $html .= __('Select binary log to view');
86 $html .= '</legend><select name="log">';
87 $full_size = 0;
88 foreach ($binary_logs as $each_log) {
89 $html .= '<option value="' . $each_log['Log_name'] . '"';
90 if ($each_log['Log_name'] == $_REQUEST['log']) {
91 $html .= ' selected="selected"';
93 $html .= '>' . $each_log['Log_name'];
94 if (isset($each_log['File_size'])) {
95 $full_size += $each_log['File_size'];
96 $html .= ' ('
97 . implode(
98 ' ',
99 PMA_Util::formatByteDown(
100 $each_log['File_size'], 3, 2
103 . ')';
105 $html .= '</option>';
107 $html .= '</select> ';
108 $html .= count($binary_logs) . ' ' . __('Files') . ', ';
109 if ($full_size > 0) {
110 $html .= implode(
111 ' ', PMA_Util::formatByteDown($full_size)
114 $html .= '</fieldset>';
115 $html .= '<fieldset class="tblFooters">';
116 $html .= '<input type="submit" value="' . __('Go') . '" />';
117 $html .= '</fieldset>';
118 $html .= '</form>';
121 $html .= PMA_Util::getMessage(PMA_Message::success());
124 * Displays the page
126 $html .= '<table cellpadding="2" cellspacing="1">'
127 . '<thead>'
128 . '<tr>'
129 . '<td colspan="6" class="center">';
131 // we do not now how much rows are in the binlog
132 // so we can just force 'NEXT' button
133 if ($pos > 0) {
134 $this_url_params = $url_params;
135 if ($pos > $GLOBALS['cfg']['MaxRows']) {
136 $this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows'];
139 $html .= '<a href="server_binlog.php'
140 . PMA_generate_common_url($this_url_params) . '"';
141 if ($GLOBALS['cfg']['NavigationBarIconic']) {
142 $html .= ' title="' . _pgettext('Previous page', 'Previous') . '">';
143 } else {
144 $html .= '>' . _pgettext('Previous page', 'Previous');
145 } // end if... else...
146 $html .= ' &lt; </a> - ';
149 $this_url_params = $url_params;
150 if ($pos > 0) {
151 $this_url_params['pos'] = $pos;
153 if ($dontlimitchars) {
154 unset($this_url_params['dontlimitchars']);
155 $tempTitle = __('Truncate Shown Queries');
156 $tempImgMode = 'partial';
157 } else {
158 $this_url_params['dontlimitchars'] = 1;
159 $tempTitle = __('Show Full Queries');
160 $tempImgMode = 'full';
162 $html .= '<a href="server_binlog.php' . PMA_generate_common_url($this_url_params)
163 . '" title="' . $tempTitle . '">'
164 . '<img src="' .$pmaThemeImage . 's_' . $tempImgMode . 'text.png"'
165 . 'alt="' . $tempTitle . '" /></a>';
167 // we do not now how much rows are in the binlog
168 // so we can just force 'NEXT' button
169 if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
170 $this_url_params = $url_params;
171 $this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows'];
172 $html .= ' - <a href="server_binlog.php' . PMA_generate_common_url($this_url_params)
173 . '"';
174 if ($GLOBALS['cfg']['NavigationBarIconic']) {
175 $html .= ' title="' . _pgettext('Next page', 'Next') . '">';
176 } else {
177 $html .= '>' . _pgettext('Next page', 'Next');
178 } // end if... else...
179 $html .= ' &gt; </a>';
182 $html .= '</td>'
183 . '</tr>'
184 . '<tr>'
185 . '<th>' . __('Log name') . '</th>'
186 . '<th>' . __('Position') . '</th>'
187 . '<th>' . __('Event type') . '</th>'
188 . '<th>' . __('Server ID') . '</th>'
189 . '<th>' . __('Original position') . '</th>'
190 . '<th>' . __('Information') . '</th>'
191 . '</tr>'
192 . '</thead>'
193 . '<tbody>';
195 $odd_row = true;
196 while ($value = PMA_DBI_fetchAssoc($result)) {
197 if (! $dontlimitchars
198 && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']
200 $value['Info'] = PMA_substr(
201 $value['Info'], 0, $GLOBALS['cfg']['LimitChars']
202 ) . '...';
205 $html .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">'
206 . '<td>&nbsp;' . $value['Log_name'] . '&nbsp;</td>'
207 . '<td class="right">&nbsp;' . $value['Pos'] . '&nbsp;</td>'
208 . '<td>&nbsp;' . $value['Event_type'] . '&nbsp;</td>'
209 . '<td class="right">&nbsp;' . $value['Server_id'] . '&nbsp;</td>'
210 . '<td class="right">&nbsp;'
211 . (isset($value['Orig_log_pos'])
212 ? $value['Orig_log_pos'] : $value['End_log_pos'])
213 . '&nbsp;</td>'
214 . '<td>&nbsp;' . htmlspecialchars($value['Info']) . '&nbsp;</td>'
215 . '</tr>';
217 $odd_row = !$odd_row;
219 $html .= '</tbody>'
220 . '</table>';
222 $response->addHTML($html);