PageRenderTime 31ms CodeModel.GetById 14ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/phpmyadmin/server_binlog.php

https://bitbucket.org/adarshj/convenient_website
PHP | 218 lines | 157 code | 19 blank | 42 comment | 30 complexity | 8d436b149581d16c7a57a7f52a76646a MD5 | raw file
  1<?php
  2/* vim: set expandtab sw=4 ts=4 sts=4: */
  3/**
  4 * display the binary logs and the content of the selected
  5 *
  6 * @package PhpMyAdmin
  7 */
  8
  9/**
 10 *
 11 */
 12require_once './libraries/common.inc.php';
 13
 14/**
 15 * Does the common work, provides $binary_logs
 16 */
 17require_once './libraries/server_common.inc.php';
 18
 19/**
 20 * Displays the links
 21 */
 22require_once './libraries/server_links.inc.php';
 23
 24$url_params = array();
 25
 26/**
 27 * Need to find the real end of rows?
 28 */
 29if (! isset($_REQUEST['pos'])) {
 30    $pos = 0;
 31} else {
 32    /* We need this to be a integer */
 33    $pos = (int) $_REQUEST['pos'];
 34}
 35
 36if (! isset($_REQUEST['log']) || ! array_key_exists($_REQUEST['log'], $binary_logs)) {
 37    $_REQUEST['log'] = '';
 38} else {
 39    $url_params['log'] = $_REQUEST['log'];
 40}
 41
 42$sql_query = 'SHOW BINLOG EVENTS';
 43if (! empty($_REQUEST['log'])) {
 44    $sql_query .= ' IN \'' . $_REQUEST['log'] . '\'';
 45}
 46if ($GLOBALS['cfg']['MaxRows'] !== 'all') {
 47    $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows'];
 48}
 49
 50/**
 51 * Sends the query
 52 */
 53$result = PMA_DBI_query($sql_query);
 54
 55/**
 56 * prepare some vars for displaying the result table
 57 */
 58// Gets the list of fields properties
 59if (isset($result) && $result) {
 60    $num_rows = PMA_DBI_num_rows($result);
 61} else {
 62    $num_rows = 0;
 63}
 64
 65if (empty($_REQUEST['dontlimitchars'])) {
 66    $dontlimitchars = false;
 67} else {
 68    $dontlimitchars = true;
 69    $url_params['dontlimitchars'] = 1;
 70}
 71
 72/**
 73 * Displays the sub-page heading
 74 */
 75echo '<h2>' . "\n"
 76   . ($GLOBALS['cfg']['MainPageIconic'] ? PMA_getImage('s_tbl.png') : '')
 77   . '    ' . __('Binary log') . "\n"
 78   . '</h2>' . "\n";
 79
 80/**
 81 * Display log selector.
 82 */
 83if (count($binary_logs) > 1) {
 84    echo '<form action="server_binlog.php" method="get">';
 85    echo PMA_generate_common_hidden_inputs($url_params);
 86    echo '<fieldset><legend>';
 87    echo __('Select binary log to view');
 88    echo '</legend><select name="log">';
 89    $full_size = 0;
 90    foreach ($binary_logs as $each_log) {
 91        echo '<option value="' . $each_log['Log_name'] . '"';
 92        if ($each_log['Log_name'] == $_REQUEST['log']) {
 93            echo ' selected="selected"';
 94        }
 95        echo '>' . $each_log['Log_name'];
 96        if (isset($each_log['File_size'])) {
 97            $full_size += $each_log['File_size'];
 98            echo ' (' . implode(' ', PMA_formatByteDown($each_log['File_size'], 3, 2)) . ')';
 99        }
100        echo '</option>';
101    }
102    echo '</select> ';
103    echo count($binary_logs) . ' ' . __('Files') . ', ';
104    if ($full_size > 0) {
105        echo implode(' ', PMA_formatByteDown($full_size));
106    }
107    echo '</fieldset>';
108    echo '<fieldset class="tblFooters">';
109    echo '<input type="submit" value="' . __('Go') . '" />';
110    echo '</fieldset>';
111    echo '</form>';
112}
113
114PMA_showMessage(PMA_Message::success());
115
116/**
117 * Displays the page
118 */
119?>
120<table border="0" cellpadding="2" cellspacing="1">
121<thead>
122<tr>
123    <td colspan="6" align="center">
124<?php
125// we do not now how much rows are in the binlog
126// so we can just force 'NEXT' button
127if ($pos > 0) {
128    $this_url_params = $url_params;
129    if ($pos > $GLOBALS['cfg']['MaxRows']) {
130        $this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows'];
131    }
132
133    echo '<a href="./server_binlog.php' . PMA_generate_common_url($this_url_params) . '"';
134    if ($GLOBALS['cfg']['NavigationBarIconic']) {
135        echo ' title="' . _pgettext('Previous page', 'Previous') . '">';
136    } else {
137        echo '>' . _pgettext('Previous page', 'Previous');
138    } // end if... else...
139    echo ' &lt; </a> - ';
140}
141
142$this_url_params = $url_params;
143if ($pos > 0) {
144    $this_url_params['pos'] = $pos;
145}
146if ($dontlimitchars) {
147    unset($this_url_params['dontlimitchars']);
148    ?>
149        <a href="./server_binlog.php<?php echo PMA_generate_common_url($this_url_params); ?>"
150            title="<?php __('Truncate Shown Queries'); ?>">
151                <img src="<?php echo $pmaThemeImage; ?>s_partialtext.png"
152                    alt="<?php echo __('Truncate Shown Queries'); ?>" /></a>
153    <?php
154} else {
155    $this_url_params['dontlimitchars'] = 1;
156    ?>
157        <a href="./server_binlog.php<?php echo PMA_generate_common_url($this_url_params); ?>"
158            title="<?php __('Show Full Queries'); ?>">
159                <img src="<?php echo $pmaThemeImage; ?>s_fulltext.png"
160                    alt="<?php echo __('Show Full Queries'); ?>" /></a>
161    <?php
162}
163// we do not now how much rows are in the binlog
164// so we can just force 'NEXT' button
165if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
166    $this_url_params = $url_params;
167    $this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows'];
168    echo ' - <a href="./server_binlog.php' . PMA_generate_common_url($this_url_params) . '"';
169    if ($GLOBALS['cfg']['NavigationBarIconic']) {
170        echo ' title="' . _pgettext('Next page', 'Next') . '">';
171    } else {
172        echo '>' . _pgettext('Next page', 'Next');
173    } // end if... else...
174    echo ' &gt; </a>';
175}
176?>
177    </td>
178</tr>
179<tr>
180    <th><?php echo __('Log name'); ?></th>
181    <th><?php echo __('Position'); ?></th>
182    <th><?php echo __('Event type'); ?></th>
183    <th><?php echo __('Server ID'); ?></th>
184    <th><?php echo __('Original position'); ?></th>
185    <th><?php echo __('Information'); ?></th>
186</tr>
187</thead>
188<tbody>
189<?php
190$odd_row = true;
191while ($value = PMA_DBI_fetch_assoc($result)) {
192    if (! $dontlimitchars && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']) {
193        $value['Info'] = PMA_substr($value['Info'], 0, $GLOBALS['cfg']['LimitChars']) . '...';
194    }
195    ?>
196<tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
197    <td>&nbsp;<?php echo $value['Log_name']; ?>&nbsp;</td>
198    <td align="right">&nbsp;<?php echo $value['Pos']; ?>&nbsp;</td>
199    <td>&nbsp;<?php echo $value['Event_type']; ?>&nbsp;</td>
200    <td align="right">&nbsp;<?php echo $value['Server_id']; ?>&nbsp;</td>
201    <td align="right">&nbsp;<?php echo isset($value['Orig_log_pos']) ? $value['Orig_log_pos'] : $value['End_log_pos']; ?>&nbsp;</td>
202    <td>&nbsp;<?php echo htmlspecialchars($value['Info']); ?>&nbsp;</td>
203</tr>
204    <?php
205    $odd_row = !$odd_row;
206}
207?>
208</tbody>
209</table>
210<?php
211
212
213/**
214 * Sends the footer
215 */
216require './libraries/footer.inc.php';
217
218?>