Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / server_binlog.php
blob20f9070a665ccc3d2cdeb5229241b32c66a4be87
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 ($GLOBALS['cfg']['NavigationBarIconic']) {
141 echo ' title="' . _pgettext('Previous page', 'Previous') . '">';
142 } else {
143 echo '>' . _pgettext('Previous page', 'Previous');
144 } // end if... else...
145 echo ' &lt; </a> - ';
148 $this_url_params = $url_params;
149 if ($pos > 0) {
150 $this_url_params['pos'] = $pos;
152 if ($dontlimitchars) {
153 unset($this_url_params['dontlimitchars']);
154 $tempTitle = __('Truncate Shown Queries');
155 $tempImgMode = 'partial';
156 } else {
157 $this_url_params['dontlimitchars'] = 1;
158 $tempTitle = __('Show Full Queries');
159 $tempImgMode = 'full';
161 echo '<a href="server_binlog.php' . PMA_generate_common_url($this_url_params)
162 . '" title="' . $tempTitle . '">'
163 . '<img src="' .$pmaThemeImage . 's_' . $tempImgMode . 'text.png"'
164 . 'alt="' . $tempTitle . '" /></a>';
166 // we do not now how much rows are in the binlog
167 // so we can just force 'NEXT' button
168 if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
169 $this_url_params = $url_params;
170 $this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows'];
171 echo ' - <a href="server_binlog.php' . PMA_generate_common_url($this_url_params)
172 . '"';
173 if ($GLOBALS['cfg']['NavigationBarIconic']) {
174 echo ' title="' . _pgettext('Next page', 'Next') . '">';
175 } else {
176 echo '>' . _pgettext('Next page', 'Next');
177 } // end if... else...
178 echo ' &gt; </a>';
181 echo '</td>'
182 . '</tr>'
183 . '<tr>'
184 . '<th>' . __('Log name') . '</th>'
185 . '<th>' . __('Position') . '</th>'
186 . '<th>' . __('Event type') . '</th>'
187 . '<th>' . __('Server ID') . '</th>'
188 . '<th>' . __('Original position') . '</th>'
189 . '<th>' . __('Information') . '</th>'
190 . '</tr>'
191 . '</thead>'
192 . '<tbody>';
194 $odd_row = true;
195 while ($value = PMA_DBI_fetch_assoc($result)) {
196 if (! $dontlimitchars
197 && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']
199 $value['Info'] = PMA_substr(
200 $value['Info'], 0, $GLOBALS['cfg']['LimitChars']
201 ) . '...';
204 echo '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">'
205 . '<td>&nbsp;' . $value['Log_name'] . '&nbsp;</td>'
206 . '<td class="right">&nbsp;' . $value['Pos'] . '&nbsp;</td>'
207 . '<td>&nbsp;' . $value['Event_type'] . '&nbsp;</td>'
208 . '<td class="right">&nbsp;' . $value['Server_id'] . '&nbsp;</td>'
209 . '<td class="right">&nbsp;'
210 . (isset($value['Orig_log_pos'])
211 ? $value['Orig_log_pos'] : $value['End_log_pos'])
212 . '&nbsp;</td>'
213 . '<td>&nbsp;' . htmlspecialchars($value['Info']) . '&nbsp;</td>'
214 . '</tr>';
216 $odd_row = !$odd_row;
218 echo '</tbody>'
219 . '</table>';