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