Conditional Ajax on db rename
[phpmyadmin/crack.git] / server_binlog.php
blob60a5b57af060b00d776fbb261464127d4640cf49
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 * @uses $cfg['MainPageIconic']
7 * @uses $cfg['NavigationBarIconic']
8 * @uses $cfg['MaxRows']
9 * @uses $cfg['LimitChars']
10 * @uses $pmaThemeImage
11 * @uses $binary_logs
12 * @uses PMA_generate_common_hidden_inputs()
13 * @uses PMA_generate_common_url()
14 * @uses PMA_formatByteDown()
15 * @uses PMA_DBI_fetch_assoc()
16 * @uses PMA_strlen()
17 * @uses PMA_substr()
18 * @uses $_REQUEST['pos']
19 * @uses $_REQUEST['log']
20 * @uses $_REQUEST['dontlimitchars']
21 * @uses count()
22 * @uses array_key_exists()
23 * @uses implode()
24 * @uses htmlspecialchars()
25 * @package phpMyAdmin
28 /**
31 require_once './libraries/common.inc.php';
33 /**
34 * Does the common work, provides $binary_logs
36 require_once './libraries/server_common.inc.php';
38 /**
39 * Displays the links
41 require_once './libraries/server_links.inc.php';
43 $url_params = array();
45 /**
46 * Need to find the real end of rows?
48 if (! isset($_REQUEST['pos'])) {
49 $pos = 0;
50 } else {
51 /* We need this to be a integer */
52 $pos = (int) $_REQUEST['pos'];
55 if (! isset($_REQUEST['log']) || ! array_key_exists($_REQUEST['log'], $binary_logs)) {
56 $_REQUEST['log'] = '';
57 } else {
58 $url_params['log'] = $_REQUEST['log'];
61 $sql_query = 'SHOW BINLOG EVENTS';
62 if (! empty($_REQUEST['log'])) {
63 $sql_query .= ' IN \'' . $_REQUEST['log'] . '\'';
65 if ($GLOBALS['cfg']['MaxRows'] !== 'all') {
66 $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows'];
69 /**
70 * Sends the query
72 $result = PMA_DBI_query($sql_query);
74 /**
75 * prepare some vars for displaying the result table
77 // Gets the list of fields properties
78 if (isset($result) && $result) {
79 $num_rows = PMA_DBI_num_rows($result);
80 } else {
81 $num_rows = 0;
84 if (empty($_REQUEST['dontlimitchars'])) {
85 $dontlimitchars = false;
86 } else {
87 $dontlimitchars = true;
88 $url_params['dontlimitchars'] = 1;
91 /**
92 * Displays the sub-page heading
94 echo '<h2>' . "\n"
95 . ($GLOBALS['cfg']['MainPageIconic'] ? '<img src="' . $pmaThemeImage . 's_process.png" width="16" height="16" border="0" hspace="2" align="middle" alt="" />' : '')
96 . ' ' . __('Binary log') . "\n"
97 . '</h2>' . "\n";
99 /**
100 * Display log selector.
102 if (count($binary_logs) > 1) {
103 echo '<form action="server_binlog.php" method="get">';
104 echo PMA_generate_common_hidden_inputs($url_params);
105 echo '<fieldset><legend>';
106 echo __('Select binary log to view');
107 echo '</legend><select name="log">';
108 $full_size = 0;
109 foreach ($binary_logs as $each_log) {
110 echo '<option value="' . $each_log['Log_name'] . '"';
111 if ($each_log['Log_name'] == $_REQUEST['log']) {
112 echo ' selected="selected"';
114 echo '>' . $each_log['Log_name'];
115 if (isset($each_log['File_size'])) {
116 $full_size += $each_log['File_size'];
117 echo ' (' . implode(' ', PMA_formatByteDown($each_log['File_size'], 3, 2)) . ')';
119 echo '</option>';
121 echo '</select> ';
122 echo count($binary_logs) . ' ' . __('Files') . ', ';
123 if ($full_size > 0) {
124 echo implode(' ', PMA_formatByteDown($full_size));
126 echo '</fieldset>';
127 echo '<fieldset class="tblFooters">';
128 echo '<input type="submit" value="' . __('Go') . '" />';
129 echo '</fieldset>';
130 echo '</form>';
133 PMA_Message::success()->display();
136 * Displays the page
139 <table border="0" cellpadding="2" cellspacing="1">
140 <thead>
141 <tr>
142 <td colspan="6" align="center">
143 <?php
144 // we do not now how much rows are in the binlog
145 // so we can just force 'NEXT' button
146 if ($pos > 0) {
147 $this_url_params = $url_params;
148 if ($pos > $GLOBALS['cfg']['MaxRows']) {
149 $this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows'];
152 echo '<a href="./server_binlog.php' . PMA_generate_common_url($this_url_params) . '"';
153 if ($GLOBALS['cfg']['NavigationBarIconic']) {
154 echo ' title="' . __('Previous') . '">';
155 } else {
156 echo '>' . __('Previous');
157 } // end if... else...
158 echo ' &lt; </a> - ';
161 $this_url_params = $url_params;
162 if ($pos > 0) {
163 $this_url_params['pos'] = $pos;
165 if ($dontlimitchars) {
166 unset($this_url_params['dontlimitchars']);
168 <a href="./server_binlog.php<?php echo PMA_generate_common_url($this_url_params); ?>"
169 title="<?php __('Truncate Shown Queries'); ?>">
170 <img src="<?php echo $pmaThemeImage; ?>s_partialtext.png"
171 width="50" height="20" border="0"
172 alt="<?php echo __('Truncate Shown Queries'); ?>" /></a>
173 <?php
174 } else {
175 $this_url_params['dontlimitchars'] = 1;
177 <a href="./server_binlog.php<?php echo PMA_generate_common_url($this_url_params); ?>"
178 title="<?php __('Show Full Queries'); ?>">
179 <img src="<?php echo $pmaThemeImage; ?>s_fulltext.png"
180 width="50" height="20" border="0"
181 alt="<?php echo __('Show Full Queries'); ?>" /></a>
182 <?php
184 // we do not now how much rows are in the binlog
185 // so we can just force 'NEXT' button
186 if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
187 $this_url_params = $url_params;
188 $this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows'];
189 echo ' - <a href="./server_binlog.php' . PMA_generate_common_url($this_url_params) . '"';
190 if ($GLOBALS['cfg']['NavigationBarIconic']) {
191 echo ' title="' . __('Next') . '">';
192 } else {
193 echo '>' . __('Next');
194 } // end if... else...
195 echo ' &gt; </a>';
198 </td>
199 </tr>
200 <tr>
201 <th><?php echo __('Log name'); ?></th>
202 <th><?php echo __('Position'); ?></th>
203 <th><?php echo __('Event type'); ?></th>
204 <th><?php echo __('Server ID'); ?></th>
205 <th><?php echo __('Original position'); ?></th>
206 <th><?php echo __('Information'); ?></th>
207 </tr>
208 </thead>
209 <tbody>
210 <?php
211 $odd_row = true;
212 while ($value = PMA_DBI_fetch_assoc($result)) {
213 if (! $dontlimitchars && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']) {
214 $value['Info'] = PMA_substr($value['Info'], 0, $GLOBALS['cfg']['LimitChars']) . '...';
217 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
218 <td>&nbsp;<?php echo $value['Log_name']; ?>&nbsp;</td>
219 <td align="right">&nbsp;<?php echo $value['Pos']; ?>&nbsp;</td>
220 <td>&nbsp;<?php echo $value['Event_type']; ?>&nbsp;</td>
221 <td align="right">&nbsp;<?php echo $value['Server_id']; ?>&nbsp;</td>
222 <td align="right">&nbsp;<?php echo isset($value['Orig_log_pos']) ? $value['Orig_log_pos'] : $value['End_log_pos']; ?>&nbsp;</td>
223 <td>&nbsp;<?php echo htmlspecialchars($value['Info']); ?>&nbsp;</td>
224 </tr>
225 <?php
226 $odd_row = !$odd_row;
229 </tbody>
230 </table>
231 <?php
235 * Sends the footer
237 require './libraries/footer.inc.php';