From fb72aaa04a06a0a1095b8483ec9cb0786dccf754 Mon Sep 17 00:00:00 2001 From: xmujay Date: Fri, 7 Jun 2013 22:13:18 +0800 Subject: [PATCH 1/5] refactor server_plugins.php: 1. change HTML mixture to php 2. change long code to functions 3. move functions to libraries/server_plugins.lib.php --- libraries/server_plugins.lib.php | 215 +++++++++++++++++++++++++++++++ server_plugins.php | 139 +------------------- 2 files changed, 221 insertions(+), 133 deletions(-) create mode 100644 libraries/server_plugins.lib.php diff --git a/libraries/server_plugins.lib.php b/libraries/server_plugins.lib.php new file mode 100644 index 0000000000..1316dd2444 --- /dev/null +++ b/libraries/server_plugins.lib.php @@ -0,0 +1,215 @@ +' . "\n" + . PMA_Util::getImage('b_engine.png') + . "\n" . __('Plugins') . "\n" + . '' . "\n"; + return $html; +} + +/** + * Returns the html for plugin and module Info. + * + * @param Array $plugins Plugin list + * + * @param Array $modules Module list + * + * @return string + */ +function PMA_getPluginAndModuleInfo($plugins, $modules) +{ + $html = ''; + $html .= '
'; + $html .= ''; + $html .= PMA_getPluginTab($plugins); + $html .= PMA_getModuleTab($modules); + $html .= '
'; + return $html; +} + +/** + * Returns the html for plugin Tab. + * + * @param Array $plugins list + * + * @return string + */ +function PMA_getPluginTab($plugins) +{ + $html = '
'; + $html .= ''; + $html .= '
'; + + foreach ($plugins as $plugin_type => $plugin_list) { + $key = 'plugins-' . preg_replace('/[^a-z]/', '', strtolower($plugin_type)); + sort($plugin_list); + + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + + $html .= PMA_getPluginList($plugin_list); + + $html .= ''; + $html .= '
'; + $html .= ''; + $html .= __('Begin'); + $html .= PMA_Util::getImage('s_asc.png'); + $html .= ''; + $html .= htmlspecialchars($plugin_type); + $html .= '
' . __('Plugin') . '' . __('Module') . '' . __('Library') . '' . __('Version') . '' . __('Author') . '' . __('License') . '
'; + } + $html .= '
'; + return $html; +} + +/** + * Returns the html for plugin List. + * + * @param Array $plugin_list list + * + * @return string + */ +function PMA_getPluginList($plugin_list) +{ + $html = ""; + $odd_row = false; + foreach ($plugin_list as $plugin) { + $odd_row = !$odd_row; + $html .= ''; + $html .= '' . htmlspecialchars($plugin['plugin_name']) . ''; + $html .= '' . htmlspecialchars($plugin['module_name']) . ''; + $html .= '' . htmlspecialchars($plugin['module_library']) . ''; + $html .= '' . htmlspecialchars($plugin['module_version']) . ''; + $html .= '' . htmlspecialchars($plugin['module_author']) . ''; + $html .= '' . htmlspecialchars($plugin['module_license']) . ''; + $html .= ''; + } + return $html; +} + +/** + * Returns the html for Module Tab. + * + * @param Array $modules list + * + * @return string + */ +function PMA_getModuleTab($modules) +{ + $html = '
'; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + + $html .= PMA_getModuleList($modules); + $html .= ''; + $html .= '
' . __('Module') . '' . __('Description') . '' . __('Library') . '' . __('Version') . '' . __('Author') . '' . __('License') . '
'; + $html .= '
'; + return $html; +} + +/** + * Returns the html for module List. + * + * @param Array $modules list + * + * @return string + */ +function PMA_getModuleList($modules) +{ + $html = ""; + $odd_row = false; + foreach ($modules as $module_name => $module) { + $odd_row = !$odd_row; + $html .= ''; + $html .= '' . htmlspecialchars($module_name) . ''; + $html .= '' . htmlspecialchars($module['info']['module_description']) . ''; + $html .= '' . htmlspecialchars($module['info']['module_library']) . ''; + $html .= '' . htmlspecialchars($module['info']['module_version']) . ''; + $html .= '' . htmlspecialchars($module['info']['module_author']) . ''; + $html .= '' . htmlspecialchars($module['info']['module_license']) . ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + + foreach ($module['plugins'] as $plugin_type => $plugin_list) { + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + } + + $html .= ''; + $html .= '
' + . htmlspecialchars($plugin_type) . ''; + for ($i = 0; $i < count($plugin_list); $i++) { + $html .= ($i != 0 ? '
' : '') + . htmlspecialchars($plugin_list[$i]['plugin_name']); + if (!$plugin_list[$i]['is_active']) { + $html .= ' ' . __('disabled') . ''; + } + } + $html .= '
'; + $html .= ''; + $html .= ''; + } + return $html; +} + +?> diff --git a/server_plugins.php b/server_plugins.php index 9ee1218c7c..6e8090fa84 100644 --- a/server_plugins.php +++ b/server_plugins.php @@ -23,14 +23,7 @@ $scripts->addFile('server_plugins.js'); * Does the common work */ require 'libraries/server_common.inc.php'; - -/** - * Displays the sub-page heading - */ -echo '

' . "\n" - . PMA_Util::getImage('b_engine.png') - . "\n" . __('Plugins') . "\n" - . '

' . "\n"; +require 'libraries/server_plugins.lib.php'; /** * Prepare plugin list @@ -56,129 +49,9 @@ ksort($plugins); /** * Displays the page */ -?> - -
- +$response->addHTML(PMA_getSubPageHeader()); +$response->addHTML(PMA_getPluginAndModuleInfo($plugins, $modules)); -
- -
- $plugin_list) { - $key = 'plugins-' . preg_replace('/[^a-z]/', '', strtolower($plugin_type)); - sort($plugin_list); - ?> - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
-
- - - - - - - - - - - - - $module) { - $odd_row = !$odd_row; - ?> - - - - - - - - - - - - - -
- - - $plugin_list) { - ?> - - - - - - -
- ' : '') . htmlspecialchars($plugin_list[$i]['plugin_name']); - if (!$plugin_list[$i]['is_active']) { - echo ' ' . __('disabled') . ''; - } - } - ?> -
-
-
-
+exit; + +?> From c745ac4bd779209d786f4d406006fec460dbd458 Mon Sep 17 00:00:00 2001 From: xmujay Date: Fri, 7 Jun 2013 22:19:24 +0800 Subject: [PATCH 2/5] fix code indention --- libraries/server_plugins.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/server_plugins.lib.php b/libraries/server_plugins.lib.php index 1316dd2444..4750ee1a13 100644 --- a/libraries/server_plugins.lib.php +++ b/libraries/server_plugins.lib.php @@ -47,10 +47,10 @@ function PMA_getPluginAndModuleInfo($plugins, $modules) $html .= '
  • ' . __('Plugins') . '
  • '; $html .= '
  • ' . __('Modules') . '
  • '; $html .= ''; - $html .= PMA_getPluginTab($plugins); - $html .= PMA_getModuleTab($modules); + $html .= PMA_getPluginTab($plugins); + $html .= PMA_getModuleTab($modules); $html .= ''; - return $html; + return $html; } /** @@ -171,7 +171,7 @@ function PMA_getModuleTab($modules) */ function PMA_getModuleList($modules) { - $html = ""; + $html = ""; $odd_row = false; foreach ($modules as $module_name => $module) { $odd_row = !$odd_row; From a20ba0899e30742a8cc4d561daf7a70e6663bf51 Mon Sep 17 00:00:00 2001 From: xmujay Date: Fri, 7 Jun 2013 22:42:50 +0800 Subject: [PATCH 3/5] using space instead of Tab --- libraries/server_plugins.lib.php | 256 +++++++++++++++---------------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/libraries/server_plugins.lib.php b/libraries/server_plugins.lib.php index 4750ee1a13..77bf299187 100644 --- a/libraries/server_plugins.lib.php +++ b/libraries/server_plugins.lib.php @@ -21,11 +21,11 @@ if (! defined('PHPMYADMIN')) { */ function PMA_getSubPageHeader() { - $html = '

    ' . "\n" + $html = '

    ' . "\n" . PMA_Util::getImage('b_engine.png') . "\n" . __('Plugins') . "\n" . '

    ' . "\n"; - return $html; + return $html; } /** @@ -39,18 +39,18 @@ function PMA_getSubPageHeader() */ function PMA_getPluginAndModuleInfo($plugins, $modules) { - $html = ''; - $html .= '
    '; - $html .= ''; - $html .= PMA_getPluginTab($plugins); - $html .= PMA_getModuleTab($modules); - $html .= '
    '; - return $html; + $html = ''; + $html .= '
    '; + $html .= ''; + $html .= PMA_getPluginTab($plugins); + $html .= PMA_getModuleTab($modules); + $html .= '
    '; + return $html; } /** @@ -62,49 +62,49 @@ function PMA_getPluginAndModuleInfo($plugins, $modules) */ function PMA_getPluginTab($plugins) { - $html = '
    '; - $html .= ''; - $html .= '
    '; - - foreach ($plugins as $plugin_type => $plugin_list) { - $key = 'plugins-' . preg_replace('/[^a-z]/', '', strtolower($plugin_type)); - sort($plugin_list); - - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - - $html .= PMA_getPluginList($plugin_list); - - $html .= ''; - $html .= '
    '; - $html .= ''; - $html .= __('Begin'); - $html .= PMA_Util::getImage('s_asc.png'); - $html .= ''; - $html .= htmlspecialchars($plugin_type); - $html .= '
    ' . __('Plugin') . '' . __('Module') . '' . __('Library') . '' . __('Version') . '' . __('Author') . '' . __('License') . '
    '; - } - $html .= '
    '; - return $html; + $html = '
    '; + $html .= ''; + $html .= '
    '; + + foreach ($plugins as $plugin_type => $plugin_list) { + $key = 'plugins-' . preg_replace('/[^a-z]/', '', strtolower($plugin_type)); + sort($plugin_list); + + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + + $html .= PMA_getPluginList($plugin_list); + + $html .= ''; + $html .= '
    '; + $html .= ''; + $html .= __('Begin'); + $html .= PMA_Util::getImage('s_asc.png'); + $html .= ''; + $html .= htmlspecialchars($plugin_type); + $html .= '
    ' . __('Plugin') . '' . __('Module') . '' . __('Library') . '' . __('Version') . '' . __('Author') . '' . __('License') . '
    '; + } + $html .= '
    '; + return $html; } /** @@ -116,20 +116,20 @@ function PMA_getPluginTab($plugins) */ function PMA_getPluginList($plugin_list) { - $html = ""; - $odd_row = false; - foreach ($plugin_list as $plugin) { - $odd_row = !$odd_row; - $html .= ''; - $html .= '' . htmlspecialchars($plugin['plugin_name']) . ''; - $html .= '' . htmlspecialchars($plugin['module_name']) . ''; - $html .= '' . htmlspecialchars($plugin['module_library']) . ''; - $html .= '' . htmlspecialchars($plugin['module_version']) . ''; - $html .= '' . htmlspecialchars($plugin['module_author']) . ''; - $html .= '' . htmlspecialchars($plugin['module_license']) . ''; - $html .= ''; - } - return $html; + $html = ""; + $odd_row = false; + foreach ($plugin_list as $plugin) { + $odd_row = !$odd_row; + $html .= ''; + $html .= '' . htmlspecialchars($plugin['plugin_name']) . ''; + $html .= '' . htmlspecialchars($plugin['module_name']) . ''; + $html .= '' . htmlspecialchars($plugin['module_library']) . ''; + $html .= '' . htmlspecialchars($plugin['module_version']) . ''; + $html .= '' . htmlspecialchars($plugin['module_author']) . ''; + $html .= '' . htmlspecialchars($plugin['module_license']) . ''; + $html .= ''; + } + return $html; } /** @@ -141,25 +141,25 @@ function PMA_getPluginList($plugin_list) */ function PMA_getModuleTab($modules) { - $html = '
    '; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; + $html = '
    '; + $html .= '
    ' . __('Module') . '' . __('Description') . '' . __('Library') . '' . __('Version') . '' . __('Author') . '' . __('License') . '
    '; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; - $html .= PMA_getModuleList($modules); - $html .= ''; - $html .= '
    ' . __('Module') . '' . __('Description') . '' . __('Library') . '' . __('Version') . '' . __('Author') . '' . __('License') . '
    '; - $html .= '
    '; - return $html; + $html .= PMA_getModuleList($modules); + $html .= ''; + $html .= ''; + $html .= ''; + return $html; } /** @@ -171,45 +171,45 @@ function PMA_getModuleTab($modules) */ function PMA_getModuleList($modules) { - $html = ""; - $odd_row = false; - foreach ($modules as $module_name => $module) { - $odd_row = !$odd_row; - $html .= ''; - $html .= '' . htmlspecialchars($module_name) . ''; - $html .= '' . htmlspecialchars($module['info']['module_description']) . ''; - $html .= '' . htmlspecialchars($module['info']['module_library']) . ''; - $html .= '' . htmlspecialchars($module['info']['module_version']) . ''; - $html .= '' . htmlspecialchars($module['info']['module_author']) . ''; - $html .= '' . htmlspecialchars($module['info']['module_license']) . ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - - foreach ($module['plugins'] as $plugin_type => $plugin_list) { - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - } - - $html .= ''; - $html .= '
    ' - . htmlspecialchars($plugin_type) . ''; - for ($i = 0; $i < count($plugin_list); $i++) { - $html .= ($i != 0 ? '
    ' : '') - . htmlspecialchars($plugin_list[$i]['plugin_name']); - if (!$plugin_list[$i]['is_active']) { - $html .= ' ' . __('disabled') . ''; - } - } - $html .= '
    '; - $html .= ''; - $html .= ''; - } - return $html; + $html = ""; + $odd_row = false; + foreach ($modules as $module_name => $module) { + $odd_row = !$odd_row; + $html .= ''; + $html .= '' . htmlspecialchars($module_name) . ''; + $html .= '' . htmlspecialchars($module['info']['module_description']) . ''; + $html .= '' . htmlspecialchars($module['info']['module_library']) . ''; + $html .= '' . htmlspecialchars($module['info']['module_version']) . ''; + $html .= '' . htmlspecialchars($module['info']['module_author']) . ''; + $html .= '' . htmlspecialchars($module['info']['module_license']) . ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + + foreach ($module['plugins'] as $plugin_type => $plugin_list) { + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + } + + $html .= ''; + $html .= '
    ' + . htmlspecialchars($plugin_type) . ''; + for ($i = 0; $i < count($plugin_list); $i++) { + $html .= ($i != 0 ? '
    ' : '') + . htmlspecialchars($plugin_list[$i]['plugin_name']); + if (!$plugin_list[$i]['is_active']) { + $html .= ' ' . __('disabled') . ''; + } + } + $html .= '
    '; + $html .= ''; + $html .= ''; + } + return $html; } ?> From fc3e0d961edc59a944f5b4df7fadfcd6da8d2c5a Mon Sep 17 00:00:00 2001 From: xmujay Date: Fri, 7 Jun 2013 23:32:17 +0800 Subject: [PATCH 4/5] move PMA_getSubPageHeader to server_common.inc.php --- libraries/server_bin_log.lib.php | 16 ---------------- libraries/server_common.inc.php | 24 ++++++++++++++++++++++++ libraries/server_plugins.lib.php | 16 ---------------- server_binlog.php | 2 +- server_plugins.php | 2 +- 5 files changed, 26 insertions(+), 34 deletions(-) diff --git a/libraries/server_bin_log.lib.php b/libraries/server_bin_log.lib.php index 4707441090..6adf498cd7 100644 --- a/libraries/server_bin_log.lib.php +++ b/libraries/server_bin_log.lib.php @@ -12,22 +12,6 @@ if (! defined('PHPMYADMIN')) { exit; } -/** - * Returns the html for the sub-page heading - * - * @param null - * - * @return string - */ -function PMA_getSubPageHeader() -{ - $html = '

    ' . "\n" - . PMA_Util::getImage('s_tbl.png') - . ' ' . __('Binary log') . "\n" - . '

    ' . "\n"; - return $html; -} - /** * Returns the html for log selector. * diff --git a/libraries/server_common.inc.php b/libraries/server_common.inc.php index 2a60a6e8f5..485c7bc579 100644 --- a/libraries/server_common.inc.php +++ b/libraries/server_common.inc.php @@ -55,4 +55,28 @@ $binary_logs = PMA_DRIZZLE PMA_Util::checkParameters( array('is_superuser', 'url_query'), false ); + +/** + * Returns the html for the sub-page heading + * + * @param string $type Sub page type + * + * @return string + */ +function PMA_getSubPageHeader($type) +{ + $res = array(); + + $res['plugins']['icon'] = 'b_engine.png'; + $res['plugins']['text'] = __('Plugins'); + + $res['binlog']['icon'] = 's_tbl.png'; + $res['binlog']['text'] = __('Binary log'); + + $html = '

    ' . "\n" + . PMA_Util::getImage($res[$type]['icon']) + . ' ' . $res[$type]['text'] . "\n" + . '

    ' . "\n"; + return $html; +} ?> diff --git a/libraries/server_plugins.lib.php b/libraries/server_plugins.lib.php index 77bf299187..122f7c45fb 100644 --- a/libraries/server_plugins.lib.php +++ b/libraries/server_plugins.lib.php @@ -12,22 +12,6 @@ if (! defined('PHPMYADMIN')) { exit; } -/** - * Returns the html for the sub-page heading - * - * @param null - * - * @return string - */ -function PMA_getSubPageHeader() -{ - $html = '

    ' . "\n" - . PMA_Util::getImage('b_engine.png') - . "\n" . __('Plugins') . "\n" - . '

    ' . "\n"; - return $html; -} - /** * Returns the html for plugin and module Info. * diff --git a/server_binlog.php b/server_binlog.php index 8a38fdb578..022697f5f5 100644 --- a/server_binlog.php +++ b/server_binlog.php @@ -33,7 +33,7 @@ if (!empty($_REQUEST['dontlimitchars'])) { $response = PMA_Response::getInstance(); -$response->addHTML(PMA_getSubPageHeader()); +$response->addHTML(PMA_getSubPageHeader('binlog')); $response->addHTML(PMA_getLogSelector($binary_logs, $url_params)); $response->addHTML(PMA_getLogInfo($binary_logs, $url_params)); diff --git a/server_plugins.php b/server_plugins.php index 6e8090fa84..0d997ac028 100644 --- a/server_plugins.php +++ b/server_plugins.php @@ -49,7 +49,7 @@ ksort($plugins); /** * Displays the page */ -$response->addHTML(PMA_getSubPageHeader()); +$response->addHTML(PMA_getSubPageHeader('plugins')); $response->addHTML(PMA_getPluginAndModuleInfo($plugins, $modules)); exit; From bfb6dec7e6b08e774393b93da73b47aa899cd76c Mon Sep 17 00:00:00 2001 From: xmujay Date: Sat, 8 Jun 2013 00:02:45 +0800 Subject: [PATCH 5/5] fix the issues: 1. replace tab with space in server_bin_log.lib.php 2. move $bin_log to server_binlog.php 3. add server common function file server_common.lib.php --- libraries/server_bin_log.lib.php | 380 +++++++++++++++---------------- libraries/server_common.inc.php | 35 +-- libraries/server_common.lib.php | 36 +++ server_binlog.php | 14 +- 4 files changed, 241 insertions(+), 224 deletions(-) create mode 100644 libraries/server_common.lib.php diff --git a/libraries/server_bin_log.lib.php b/libraries/server_bin_log.lib.php index 6adf498cd7..a1dcdfc585 100644 --- a/libraries/server_bin_log.lib.php +++ b/libraries/server_bin_log.lib.php @@ -23,48 +23,48 @@ if (! defined('PHPMYADMIN')) { */ function PMA_getLogSelector($binary_log_file_names, $url_params) { - $html = ""; - if (count($binary_log_file_names) > 1) { - $html .= '
    '; - $html .= PMA_generate_common_hidden_inputs($url_params); - $html .= '
    '; - $html .= __('Select binary log to view'); - $html .= ''; - $html .= '
    '; - $html .= '
    '; - } - - return $html; + $html = ""; + if (count($binary_log_file_names) > 1) { + $html .= '
    '; + $html .= PMA_generate_common_hidden_inputs($url_params); + $html .= '
    '; + $html .= __('Select binary log to view'); + $html .= ''; + $html .= '
    '; + $html .= '
    '; + } + + return $html; } /** @@ -78,74 +78,74 @@ function PMA_getLogSelector($binary_log_file_names, $url_params) */ 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; - } + /** + * 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_getAllLogItemInfo($result, $dontlimitchars); - - $html .= '' - . '
    '; - - $html .= PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars); - - $html .= '
    ' . __('Log name') . '' . __('Position') . '' . __('Event type') . '' . __('Server ID') . '' . __('Original position') . '' . __('Information') . '
    '; - - return $html; + //html output + $html = PMA_Util::getMessage(PMA_Message::success(), $sql_query); + $html .= '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . ''; + + $html .= PMA_getAllLogItemInfo($result, $dontlimitchars); + + $html .= '' + . '
    '; + + $html .= PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars); + + $html .= '
    ' . __('Log name') . '' . __('Position') . '' . __('Event type') . '' . __('Server ID') . '' . __('Original position') . '' . __('Information') . '
    '; + + return $html; } /** @@ -163,60 +163,60 @@ function PMA_getLogInfo($binary_log_file_names, $url_params) */ 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; + $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; } /** @@ -230,33 +230,33 @@ function PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars) */ 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; + $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/libraries/server_common.inc.php b/libraries/server_common.inc.php index 485c7bc579..ad6caa203f 100644 --- a/libraries/server_common.inc.php +++ b/libraries/server_common.inc.php @@ -39,44 +39,13 @@ if ($is_superuser && ! PMA_DRIZZLE) { $GLOBALS['dbi']->selectDb('mysql', $userlink); } -/** - * @global array binary log files - */ -$binary_logs = PMA_DRIZZLE - ? null - : $GLOBALS['dbi']->fetchResult( - 'SHOW MASTER LOGS', - 'Log_name', - null, - null, - PMA_DatabaseInterface::QUERY_STORE - ); - PMA_Util::checkParameters( array('is_superuser', 'url_query'), false ); /** - * Returns the html for the sub-page heading - * - * @param string $type Sub page type - * - * @return string + * shared functions for server page */ -function PMA_getSubPageHeader($type) -{ - $res = array(); +require_once './libraries/server_common.lib.php'; - $res['plugins']['icon'] = 'b_engine.png'; - $res['plugins']['text'] = __('Plugins'); - - $res['binlog']['icon'] = 's_tbl.png'; - $res['binlog']['text'] = __('Binary log'); - - $html = '

    ' . "\n" - . PMA_Util::getImage($res[$type]['icon']) - . ' ' . $res[$type]['text'] . "\n" - . '

    ' . "\n"; - return $html; -} ?> diff --git a/libraries/server_common.lib.php b/libraries/server_common.lib.php new file mode 100644 index 0000000000..1b99c3c623 --- /dev/null +++ b/libraries/server_common.lib.php @@ -0,0 +1,36 @@ +' . "\n" + . PMA_Util::getImage($res[$type]['icon']) + . ' ' . $res[$type]['text'] . "\n" + . '' . "\n"; + return $html; +} + +?> diff --git a/server_binlog.php b/server_binlog.php index 022697f5f5..45d08494fa 100644 --- a/server_binlog.php +++ b/server_binlog.php @@ -12,12 +12,24 @@ require_once 'libraries/common.inc.php'; /** - * Does the common work, provides $binary_logs + * Does the common work */ require_once 'libraries/server_common.inc.php'; require_once 'libraries/server_bin_log.lib.php'; +/** + * array binary log files + */ +$binary_logs = PMA_DRIZZLE + ? null + : $GLOBALS['dbi']->fetchResult( + 'SHOW MASTER LOGS', + 'Log_name', + null, + null, + PMA_DatabaseInterface::QUERY_STORE + ); if (! isset($_REQUEST['log']) || ! array_key_exists($_REQUEST['log'], $binary_logs)