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 $response = PMA_Response
::getInstance();
20 $url_params = array();
23 * Need to find the real end of rows?
25 if (! isset($_REQUEST['pos'])) {
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)
35 $_REQUEST['log'] = '';
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'];
51 $result = PMA_DBI_query($sql_query);
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);
63 if (empty($_REQUEST['dontlimitchars'])) {
64 $dontlimitchars = false;
66 $dontlimitchars = true;
67 $url_params['dontlimitchars'] = 1;
71 * Displays the sub-page heading
74 . PMA_Util
::getImage('s_tbl.png')
75 . ' ' . __('Binary log') . "\n"
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">';
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'];
99 PMA_Util
::formatByteDown(
100 $each_log['File_size'], 3, 2
105 $html .= '</option>';
107 $html .= '</select> ';
108 $html .= count($binary_logs) . ' ' . __('Files') . ', ';
109 if ($full_size > 0) {
111 ' ', PMA_Util
::formatByteDown($full_size)
114 $html .= '</fieldset>';
115 $html .= '<fieldset class="tblFooters">';
116 $html .= '<input type="submit" value="' . __('Go') . '" />';
117 $html .= '</fieldset>';
121 $html .= PMA_Util
::getMessage(PMA_Message
::success());
126 $html .= '<table cellpadding="2" cellspacing="1">'
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
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') . '">';
144 $html .= '>' . _pgettext('Previous page', 'Previous');
145 } // end if... else...
146 $html .= ' < </a> - ';
149 $this_url_params = $url_params;
151 $this_url_params['pos'] = $pos;
153 if ($dontlimitchars) {
154 unset($this_url_params['dontlimitchars']);
155 $tempTitle = __('Truncate Shown Queries');
156 $tempImgMode = 'partial';
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)
174 if ($GLOBALS['cfg']['NavigationBarIconic']) {
175 $html .= ' title="' . _pgettext('Next page', 'Next') . '">';
177 $html .= '>' . _pgettext('Next page', 'Next');
178 } // end if... else...
179 $html .= ' > </a>';
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>'
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']
205 $html .= '<tr class="noclick ' . ($odd_row ?
'odd' : 'even') . '">'
206 . '<td> ' . $value['Log_name'] . ' </td>'
207 . '<td class="right"> ' . $value['Pos'] . ' </td>'
208 . '<td> ' . $value['Event_type'] . ' </td>'
209 . '<td class="right"> ' . $value['Server_id'] . ' </td>'
210 . '<td class="right"> '
211 . (isset($value['Orig_log_pos'])
212 ?
$value['Orig_log_pos'] : $value['End_log_pos'])
214 . '<td> ' . htmlspecialchars($value['Info']) . ' </td>'
217 $odd_row = !$odd_row;
222 $response->addHTML($html);