diff --git a/libraries/server_bin_log.lib.php b/libraries/server_bin_log.lib.php index 4707441090..a1dcdfc585 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. * @@ -39,48 +23,48 @@ function PMA_getSubPageHeader() */ 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; } /** @@ -94,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; } /** @@ -179,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; } /** @@ -246,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 2a60a6e8f5..ad6caa203f 100644 --- a/libraries/server_common.inc.php +++ b/libraries/server_common.inc.php @@ -39,20 +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 ); + +/** + * shared functions for server page + */ +require_once './libraries/server_common.lib.php'; + ?> 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/libraries/server_plugins.lib.php b/libraries/server_plugins.lib.php new file mode 100644 index 0000000000..122f7c45fb --- /dev/null +++ b/libraries/server_plugins.lib.php @@ -0,0 +1,199 @@ +'; + $html .= 'pma_theme_image = "' . $GLOBALS['pmaThemeImage'] . '"'; + $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_binlog.php b/server_binlog.php index 8a38fdb578..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) @@ -33,7 +45,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 9ee1218c7c..0d997ac028 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('plugins')); +$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; + +?>