diff --git a/libraries/server_bin_log.lib.php b/libraries/server_bin_log.lib.php
new file mode 100644
index 0000000000..4707441090
--- /dev/null
+++ b/libraries/server_bin_log.lib.php
@@ -0,0 +1,278 @@
+' . "\n"
+ . PMA_Util::getImage('s_tbl.png')
+ . ' ' . __('Binary log') . "\n"
+ . '' . "\n";
+ return $html;
+}
+
+/**
+ * Returns the html for log selector.
+ *
+ * @param Array $binary_log_file_names Binary logs file names
+ *
+ * @param Array $url_params links parameters
+ *
+ * @return string
+ */
+function PMA_getLogSelector($binary_log_file_names, $url_params)
+{
+ $html = "";
+ if (count($binary_log_file_names) > 1) {
+ $html .= '
';
+ }
+
+ return $html;
+}
+
+/**
+ * Returns the html for binary log information.
+ *
+ * @param Array $binary_log_file_names Binary logs file names
+ *
+ * @param Array $url_params links parameters
+ *
+ * @return string
+ */
+function PMA_getLogInfo($binary_log_file_names, $url_params)
+{
+ /**
+ * Need to find the real end of rows?
+ */
+ if (! isset($_REQUEST['pos'])) {
+ $pos = 0;
+ } else {
+ /* We need this to be a integer */
+ $pos = (int) $_REQUEST['pos'];
+ }
+
+ $sql_query = 'SHOW BINLOG EVENTS';
+ if (! empty($_REQUEST['log'])) {
+ $sql_query .= ' IN \'' . $_REQUEST['log'] . '\'';
+ }
+ if ($GLOBALS['cfg']['MaxRows'] !== 'all') {
+ $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows'];
+ }
+
+ /**
+ * Sends the query
+ */
+ $result = $GLOBALS['dbi']->query($sql_query);
+
+ /**
+ * prepare some vars for displaying the result table
+ */
+ // Gets the list of fields properties
+ if (isset($result) && $result) {
+ $num_rows = $GLOBALS['dbi']->numRows($result);
+ } else {
+ $num_rows = 0;
+ }
+
+ if (empty($_REQUEST['dontlimitchars'])) {
+ $dontlimitchars = false;
+ } else {
+ $dontlimitchars = true;
+ $url_params['dontlimitchars'] = 1;
+ }
+
+ //html output
+ $html = PMA_Util::getMessage(PMA_Message::success(), $sql_query);
+ $html .= ''
+ . ''
+ . ''
+ . '| ';
+
+ $html .= PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars);
+
+ $html .= ' | '
+ . '
'
+ . ''
+ . '| ' . __('Log name') . ' | '
+ . '' . __('Position') . ' | '
+ . '' . __('Event type') . ' | '
+ . '' . __('Server ID') . ' | '
+ . '' . __('Original position') . ' | '
+ . '' . __('Information') . ' | '
+ . '
'
+ . ''
+ . '';
+
+ $html .= PMA_getAllLogItemInfo($result, $dontlimitchars);
+
+ $html .= ''
+ . '
';
+
+ return $html;
+}
+
+/**
+ * Returns the html for Navigation Row.
+ *
+ * @param Array $url_params Links parameters
+ *
+ * @param int $pos Position to display
+ *
+ * @param int $num_rows Number of results row
+ *
+ * @param bool $dontlimitchars Whether limit chars
+ *
+ * @return string
+ */
+function PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars)
+{
+ $html = "";
+ // we do not know how much rows are in the binlog
+ // so we can just force 'NEXT' button
+ if ($pos > 0) {
+ $this_url_params = $url_params;
+ if ($pos > $GLOBALS['cfg']['MaxRows']) {
+ $this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows'];
+ }
+
+ $html .= '';
+ } else {
+ $html .= '>' . _pgettext('Previous page', 'Previous');
+ } // end if... else...
+ $html .= ' < - ';
+ }
+
+ $this_url_params = $url_params;
+ if ($pos > 0) {
+ $this_url_params['pos'] = $pos;
+ }
+ if ($dontlimitchars) {
+ unset($this_url_params['dontlimitchars']);
+ $tempTitle = __('Truncate Shown Queries');
+ $tempImgMode = 'partial';
+ } else {
+ $this_url_params['dontlimitchars'] = 1;
+ $tempTitle = __('Show Full Queries');
+ $tempImgMode = 'full';
+ }
+ $html .= ''
+ . '
';
+
+ // we do not now how much rows are in the binlog
+ // so we can just force 'NEXT' button
+ if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
+ $this_url_params = $url_params;
+ $this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows'];
+ $html .= ' - ';
+ } else {
+ $html .= '>' . _pgettext('Next page', 'Next');
+ } // end if... else...
+ $html .= ' > ';
+ }
+
+ return $html;
+}
+
+/**
+ * Returns the html for all binary log items.
+ *
+ * @param resource $result MySQL Query result
+ *
+ * @param bool $dontlimitchars Whether limit chars
+ *
+ * @return string
+ */
+function PMA_getAllLogItemInfo($result, $dontlimitchars)
+{
+ $html = "";
+ $odd_row = true;
+ while ($value = $GLOBALS['dbi']->fetchAssoc($result)) {
+ if (! $dontlimitchars
+ && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']
+ ) {
+ $value['Info'] = PMA_substr(
+ $value['Info'], 0, $GLOBALS['cfg']['LimitChars']
+ ) . '...';
+ }
+
+ $html .= ''
+ . '| ' . $value['Log_name'] . ' | '
+ . ' ' . $value['Pos'] . ' | '
+ . ' ' . $value['Event_type'] . ' | '
+ . ' ' . $value['Server_id'] . ' | '
+ . ' '
+ . (isset($value['Orig_log_pos'])
+ ? $value['Orig_log_pos'] : $value['End_log_pos'])
+ . ' | '
+ . ' ' . htmlspecialchars($value['Info'])
+ . ' | '
+ . '
';
+
+ $odd_row = !$odd_row;
+ }
+ return $html;
+}
+
+?>
diff --git a/server_binlog.php b/server_binlog.php
index b02520b686..8a38fdb578 100644
--- a/server_binlog.php
+++ b/server_binlog.php
@@ -16,18 +16,8 @@ require_once 'libraries/common.inc.php';
*/
require_once 'libraries/server_common.inc.php';
-$response = PMA_Response::getInstance();
-$url_params = array();
+require_once 'libraries/server_bin_log.lib.php';
-/**
- * Need to find the real end of rows?
- */
-if (! isset($_REQUEST['pos'])) {
- $pos = 0;
-} else {
- /* We need this to be a integer */
- $pos = (int) $_REQUEST['pos'];
-}
if (! isset($_REQUEST['log'])
|| ! array_key_exists($_REQUEST['log'], $binary_logs)
@@ -37,188 +27,16 @@ if (! isset($_REQUEST['log'])
$url_params['log'] = $_REQUEST['log'];
}
-$sql_query = 'SHOW BINLOG EVENTS';
-if (! empty($_REQUEST['log'])) {
- $sql_query .= ' IN \'' . $_REQUEST['log'] . '\'';
-}
-if ($GLOBALS['cfg']['MaxRows'] !== 'all') {
- $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows'];
-}
-
-/**
- * Sends the query
- */
-$result = $GLOBALS['dbi']->query($sql_query);
-
-/**
- * prepare some vars for displaying the result table
- */
-// Gets the list of fields properties
-if (isset($result) && $result) {
- $num_rows = $GLOBALS['dbi']->numRows($result);
-} else {
- $num_rows = 0;
-}
-
-if (empty($_REQUEST['dontlimitchars'])) {
- $dontlimitchars = false;
-} else {
- $dontlimitchars = true;
+if (!empty($_REQUEST['dontlimitchars'])) {
$url_params['dontlimitchars'] = 1;
}
-/**
- * Displays the sub-page heading
- */
-$html = '' . "\n"
- . PMA_Util::getImage('s_tbl.png')
- . ' ' . __('Binary log') . "\n"
- . '
' . "\n";
+$response = PMA_Response::getInstance();
-/**
- * Display log selector.
- */
-if (count($binary_logs) > 1) {
- $html .= '';
-}
+$response->addHTML(PMA_getSubPageHeader());
+$response->addHTML(PMA_getLogSelector($binary_logs, $url_params));
+$response->addHTML(PMA_getLogInfo($binary_logs, $url_params));
-$html .= PMA_Util::getMessage(PMA_Message::success());
+exit;
-/**
- * Displays the page
- */
-$html .= ''
- . ''
- . ''
- . '';
-
-// we do not now how much rows are in the binlog
-// so we can just force 'NEXT' button
-if ($pos > 0) {
- $this_url_params = $url_params;
- if ($pos > $GLOBALS['cfg']['MaxRows']) {
- $this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows'];
- }
-
- $html .= '';
- } else {
- $html .= '>' . _pgettext('Previous page', 'Previous');
- } // end if... else...
- $html .= ' < - ';
-}
-
-$this_url_params = $url_params;
-if ($pos > 0) {
- $this_url_params['pos'] = $pos;
-}
-if ($dontlimitchars) {
- unset($this_url_params['dontlimitchars']);
- $tempTitle = __('Truncate Shown Queries');
- $tempImgMode = 'partial';
-} else {
- $this_url_params['dontlimitchars'] = 1;
- $tempTitle = __('Show Full Queries');
- $tempImgMode = 'full';
-}
-$html .= ''
- . ' ';
-
-// we do not now how much rows are in the binlog
-// so we can just force 'NEXT' button
-if ($num_rows >= $GLOBALS['cfg']['MaxRows']) {
- $this_url_params = $url_params;
- $this_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxRows'];
- $html .= ' - ';
- } else {
- $html .= '>' . _pgettext('Next page', 'Next');
- } // end if... else...
- $html .= ' > ';
-}
-
-$html .= ' | '
- . '
'
- . ''
- . '| ' . __('Log name') . ' | '
- . '' . __('Position') . ' | '
- . '' . __('Event type') . ' | '
- . '' . __('Server ID') . ' | '
- . '' . __('Original position') . ' | '
- . '' . __('Information') . ' | '
- . '
'
- . ''
- . '';
-
-$odd_row = true;
-while ($value = $GLOBALS['dbi']->fetchAssoc($result)) {
- if (! $dontlimitchars
- && PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']
- ) {
- $value['Info'] = PMA_substr(
- $value['Info'], 0, $GLOBALS['cfg']['LimitChars']
- ) . '...';
- }
-
- $html .= ''
- . '| ' . $value['Log_name'] . ' | '
- . ' ' . $value['Pos'] . ' | '
- . ' ' . $value['Event_type'] . ' | '
- . ' ' . $value['Server_id'] . ' | '
- . ' '
- . (isset($value['Orig_log_pos'])
- ? $value['Orig_log_pos'] : $value['End_log_pos'])
- . ' | '
- . ' ' . htmlspecialchars($value['Info'])
- . ' | '
- . '
';
-
- $odd_row = !$odd_row;
-}
-$html .= ''
- . '
';
-
-$response->addHTML($html);
+?>