Translated using Weblate (Slovenian)
[phpmyadmin.git] / libraries / server_bin_log.lib.php
blob0b1142331ce0811b07cf52296c7714e3f62b7361
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * functions for displaying server binary log
7 * @usedby server_binlog.php
9 * @package PhpMyAdmin
11 if (! defined('PHPMYADMIN')) {
12 exit;
15 /**
16 * Returns the html for log selector.
18 * @param Array $binary_logs Binary logs file names
19 * @param Array $url_params links parameters
21 * @return string
23 function PMA_getLogSelector($binary_logs, $url_params)
25 $html = "";
26 if (count($binary_logs) > 1) {
27 $html .= '<form action="server_binlog.php" method="get">';
28 $html .= PMA_URL_getHiddenInputs($url_params);
29 $html .= '<fieldset><legend>';
30 $html .= __('Select binary log to view');
31 $html .= '</legend><select name="log">';
32 $full_size = 0;
33 foreach ($binary_logs as $each_log) {
34 $html .= '<option value="' . $each_log['Log_name'] . '"';
35 if ($each_log['Log_name'] == $_REQUEST['log']) {
36 $html .= ' selected="selected"';
38 $html .= '>' . $each_log['Log_name'];
39 if (isset($each_log['File_size'])) {
40 $full_size += $each_log['File_size'];
41 $html .= ' ('
42 . implode(
43 ' ',
44 PMA_Util::formatByteDown(
45 $each_log['File_size'], 3, 2
48 . ')';
50 $html .= '</option>';
52 $html .= '</select> ';
53 $html .= count($binary_logs) . ' ' . __('Files') . ', ';
54 if ($full_size > 0) {
55 $html .= implode(
56 ' ', PMA_Util::formatByteDown($full_size)
59 $html .= '</fieldset>';
60 $html .= '<fieldset class="tblFooters">';
61 $html .= '<input type="submit" value="' . __('Go') . '" />';
62 $html .= '</fieldset>';
63 $html .= '</form>';
66 return $html;
69 /**
70 * Returns the html for binary log information.
72 * @param Array $url_params links parameters
74 * @return string
76 function PMA_getLogInfo($url_params)
78 /**
79 * Need to find the real end of rows?
81 if (! isset($_REQUEST['pos'])) {
82 $pos = 0;
83 } else {
84 /* We need this to be a integer */
85 $pos = (int) $_REQUEST['pos'];
88 $sql_query = 'SHOW BINLOG EVENTS';
89 if (! empty($_REQUEST['log'])) {
90 $sql_query .= ' IN \'' . $_REQUEST['log'] . '\'';
92 $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows'];
94 /**
95 * Sends the query
97 $result = $GLOBALS['dbi']->query($sql_query);
99 /**
100 * prepare some vars for displaying the result table
102 // Gets the list of fields properties
103 if (isset($result) && $result) {
104 $num_rows = $GLOBALS['dbi']->numRows($result);
105 } else {
106 $num_rows = 0;
109 if (empty($_REQUEST['dontlimitchars'])) {
110 $dontlimitchars = false;
111 } else {
112 $dontlimitchars = true;
113 $url_params['dontlimitchars'] = 1;
116 //html output
117 $html = PMA_Util::getMessage(PMA_Message::success(), $sql_query);
118 $html .= '<table cellpadding="2" cellspacing="1" id="binlogTable">'
119 . '<thead>'
120 . '<tr>'
121 . '<td colspan="6" class="center">';
123 $html .= PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars);
125 $html .= '</td>'
126 . '</tr>'
127 . '<tr>'
128 . '<th>' . __('Log name') . '</th>'
129 . '<th>' . __('Position') . '</th>'
130 . '<th>' . __('Event type') . '</th>'
131 . '<th>' . __('Server ID') . '</th>'
132 . '<th>' . __('Original position') . '</th>'
133 . '<th>' . __('Information') . '</th>'
134 . '</tr>'
135 . '</thead>'
136 . '<tbody>';
138 $html .= PMA_getAllLogItemInfo($result, $dontlimitchars);
140 $html .= '</tbody>'
141 . '</table>';
143 return $html;
147 * Returns the html for Navigation Row.
149 * @param Array $url_params Links parameters
150 * @param int $pos Position to display
151 * @param int $num_rows Number of results row
152 * @param bool $dontlimitchars Whether limit chars
154 * @return string
156 function PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars)
158 $html = "";
159 // we do not know how much rows are in the binlog
160 // so we can just force 'NEXT' button
161 if ($pos > 0) {
162 $this_url_params = $url_params;
163 if ($pos > $GLOBALS['cfg']['MaxRows']) {
164 $this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows'];
167 $html .= '<a href="server_binlog.php'
168 . PMA_URL_getCommon($this_url_params) . '"';
169 if (PMA_Util::showIcons('TableNavigationLinksMode')) {
170 $html .= ' title="' . _pgettext('Previous page', 'Previous') . '">';
171 } else {
172 $html .= '>' . _pgettext('Previous page', 'Previous');
173 } // end if... else...
174 $html .= ' &lt; </a> - ';
177 $this_url_params = $url_params;
178 if ($pos > 0) {
179 $this_url_params['pos'] = $pos;
181 if ($dontlimitchars) {
182 unset($this_url_params['dontlimitchars']);
183 $tempTitle = __('Truncate Shown Queries');
184 $tempImgMode = 'partial';
185 } else {
186 $this_url_params['dontlimitchars'] = 1;
187 $tempTitle = __('Show Full Queries');
188 $tempImgMode = 'full';
190 $html .= '<a href="server_binlog.php' . PMA_URL_getCommon($this_url_params)
191 . '" title="' . $tempTitle . '">'
192 . '<img src="' . $GLOBALS['pmaThemeImage'] . 's_' . $tempImgMode
193 . 'text.png" alt="' . $tempTitle . '" /></a>';
195 // we do not now how much rows are in the binlog
196 // so we can just force 'NEXT' button
197 if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
198 $this_url_params = $url_params;
199 $this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows'];
200 $html .= ' - <a href="server_binlog.php'
201 . PMA_URL_getCommon($this_url_params)
202 . '"';
203 if (PMA_Util::showIcons('TableNavigationLinksMode')) {
204 $html .= ' title="' . _pgettext('Next page', 'Next') . '">';
205 } else {
206 $html .= '>' . _pgettext('Next page', 'Next');
207 } // end if... else...
208 $html .= ' &gt; </a>';
211 return $html;
215 * Returns the html for all binary log items.
217 * @param resource $result MySQL Query result
218 * @param bool $dontlimitchars Whether limit chars
220 * @return string
222 function PMA_getAllLogItemInfo($result, $dontlimitchars)
224 $html = "";
225 $odd_row = true;
226 while ($value = $GLOBALS['dbi']->fetchAssoc($result)) {
227 $html .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">'
228 . '<td>&nbsp;' . $value['Log_name'] . '&nbsp;</td>'
229 . '<td class="right">&nbsp;' . $value['Pos'] . '&nbsp;</td>'
230 . '<td>&nbsp;' . $value['Event_type'] . '&nbsp;</td>'
231 . '<td class="right">&nbsp;' . $value['Server_id'] . '&nbsp;</td>'
232 . '<td class="right">&nbsp;'
233 . (isset($value['Orig_log_pos'])
234 ? $value['Orig_log_pos'] : $value['End_log_pos'])
235 . '&nbsp;</td>'
236 . '<td>&nbsp;' . PMA_Util::formatSql($value['Info'], ! $dontlimitchars)
237 . '&nbsp;</td></tr>';
239 $odd_row = !$odd_row;
241 return $html;