Translated using Weblate (Kurdish Sorani)
[phpmyadmin.git] / libraries / server_bin_log.lib.php
bloba33a72f4e7532dcbc7610bc2db82377f6b4dd5ec
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_log_file_names Binary logs file names
19 * @param Array $url_params links parameters
21 * @return string
23 function PMA_getLogSelector($binary_log_file_names, $url_params)
25 $html = "";
26 if (count($binary_log_file_names) > 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_log_file_names 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_log_file_names) . ' ' . __('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 $binary_log_file_names Binary logs file names
73 * @param Array $url_params links parameters
75 * @return string
77 function PMA_getLogInfo($binary_log_file_names, $url_params)
79 /**
80 * Need to find the real end of rows?
82 if (! isset($_REQUEST['pos'])) {
83 $pos = 0;
84 } else {
85 /* We need this to be a integer */
86 $pos = (int) $_REQUEST['pos'];
89 $sql_query = 'SHOW BINLOG EVENTS';
90 if (! empty($_REQUEST['log'])) {
91 $sql_query .= ' IN \'' . $_REQUEST['log'] . '\'';
93 $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows'];
95 /**
96 * Sends the query
98 $result = $GLOBALS['dbi']->query($sql_query);
101 * prepare some vars for displaying the result table
103 // Gets the list of fields properties
104 if (isset($result) && $result) {
105 $num_rows = $GLOBALS['dbi']->numRows($result);
106 } else {
107 $num_rows = 0;
110 if (empty($_REQUEST['dontlimitchars'])) {
111 $dontlimitchars = false;
112 } else {
113 $dontlimitchars = true;
114 $url_params['dontlimitchars'] = 1;
117 //html output
118 $html = PMA_Util::getMessage(PMA_Message::success(), $sql_query);
119 $html .= '<table cellpadding="2" cellspacing="1" id="binlogTable">'
120 . '<thead>'
121 . '<tr>'
122 . '<td colspan="6" class="center">';
124 $html .= PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars);
126 $html .= '</td>'
127 . '</tr>'
128 . '<tr>'
129 . '<th>' . __('Log name') . '</th>'
130 . '<th>' . __('Position') . '</th>'
131 . '<th>' . __('Event type') . '</th>'
132 . '<th>' . __('Server ID') . '</th>'
133 . '<th>' . __('Original position') . '</th>'
134 . '<th>' . __('Information') . '</th>'
135 . '</tr>'
136 . '</thead>'
137 . '<tbody>';
139 $html .= PMA_getAllLogItemInfo($result, $dontlimitchars);
141 $html .= '</tbody>'
142 . '</table>';
144 return $html;
148 * Returns the html for Navigation Row.
150 * @param Array $url_params Links parameters
151 * @param int $pos Position to display
152 * @param int $num_rows Number of results row
153 * @param bool $dontlimitchars Whether limit chars
155 * @return string
157 function PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars)
159 $html = "";
160 // we do not know how much rows are in the binlog
161 // so we can just force 'NEXT' button
162 if ($pos > 0) {
163 $this_url_params = $url_params;
164 if ($pos > $GLOBALS['cfg']['MaxRows']) {
165 $this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows'];
168 $html .= '<a href="server_binlog.php'
169 . PMA_URL_getCommon($this_url_params) . '"';
170 if (PMA_Util::showIcons('TableNavigationLinksMode')) {
171 $html .= ' title="' . _pgettext('Previous page', 'Previous') . '">';
172 } else {
173 $html .= '>' . _pgettext('Previous page', 'Previous');
174 } // end if... else...
175 $html .= ' &lt; </a> - ';
178 $this_url_params = $url_params;
179 if ($pos > 0) {
180 $this_url_params['pos'] = $pos;
182 if ($dontlimitchars) {
183 unset($this_url_params['dontlimitchars']);
184 $tempTitle = __('Truncate Shown Queries');
185 $tempImgMode = 'partial';
186 } else {
187 $this_url_params['dontlimitchars'] = 1;
188 $tempTitle = __('Show Full Queries');
189 $tempImgMode = 'full';
191 $html .= '<a href="server_binlog.php' . PMA_URL_getCommon($this_url_params)
192 . '" title="' . $tempTitle . '">'
193 . '<img src="' .$GLOBALS['pmaThemeImage'] . 's_' . $tempImgMode . 'text.png"'
194 . 'alt="' . $tempTitle . '" /></a>';
196 // we do not now how much rows are in the binlog
197 // so we can just force 'NEXT' button
198 if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
199 $this_url_params = $url_params;
200 $this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows'];
201 $html .= ' - <a href="server_binlog.php'
202 . PMA_URL_getCommon($this_url_params)
203 . '"';
204 if (PMA_Util::showIcons('TableNavigationLinksMode')) {
205 $html .= ' title="' . _pgettext('Next page', 'Next') . '">';
206 } else {
207 $html .= '>' . _pgettext('Next page', 'Next');
208 } // end if... else...
209 $html .= ' &gt; </a>';
212 return $html;
216 * Returns the html for all binary log items.
218 * @param resource $result MySQL Query result
219 * @param bool $dontlimitchars Whether limit chars
221 * @return string
223 function PMA_getAllLogItemInfo($result, $dontlimitchars)
225 $html = "";
226 $odd_row = true;
227 while ($value = $GLOBALS['dbi']->fetchAssoc($result)) {
228 $html .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">'
229 . '<td>&nbsp;' . $value['Log_name'] . '&nbsp;</td>'
230 . '<td class="right">&nbsp;' . $value['Pos'] . '&nbsp;</td>'
231 . '<td>&nbsp;' . $value['Event_type'] . '&nbsp;</td>'
232 . '<td class="right">&nbsp;' . $value['Server_id'] . '&nbsp;</td>'
233 . '<td class="right">&nbsp;'
234 . (isset($value['Orig_log_pos'])
235 ? $value['Orig_log_pos'] : $value['End_log_pos'])
236 . '&nbsp;</td>'
237 . '<td>&nbsp;' . PMA_Util::formatSql($value['Info'], ! $dontlimitchars)
238 . '&nbsp;</td></tr>';
240 $odd_row = !$odd_row;
242 return $html;