Merge remote-tracking branch 'upstream/master' into unit_testing

This commit is contained in:
ayushchd 2013-07-17 11:47:28 +05:45
commit 2a5183d9f0
31 changed files with 2364 additions and 818 deletions

View File

@ -25,6 +25,7 @@ phpMyAdmin - ChangeLog
- [core] Dropped support for PHP 5.2.
+ rfe #487 and rfe #1405 Find and Replacing column wise
+ rfe #1373 Use same create view dialog for editing a view
+ rfe #316 Configurable menus; allow user groups with customized menus per group
4.0.5.0 (not yet released)
- bug #3977 Not detected configuration storage

View File

@ -59,6 +59,8 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false;
// $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
// $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
// $cfg['Servers'][$i]['recent'] = 'pma__recent';
// $cfg['Servers'][$i]['users'] = 'pma__users';
// $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
/* Contrib / Swekey authentication */
// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';

View File

@ -110,7 +110,7 @@ Basic settings
column names match with words which are MySQL reserved.
If you want to turn off this warning, you can set it to ``true`` and
warning will not longer be displayed
warning will no longer be displayed.
.. config:option:: $cfg['TranslationWarningThreshold']
@ -649,6 +649,29 @@ Server connection settings
* put the table name in :config:option:`$cfg['Servers'][$i]['table\_uiprefs']` (e.g.
``pma__table_uiprefs``)
.. _configurablemenus:
.. config:option:: $cfg['Servers'][$i]['users']
:type: string
:default: ``''``
.. config:option:: $cfg['Servers'][$i]['usergroups']
:type: string
:default: ``''``
Since release 4.1.0 you can create different user groups with menu items
attached to them. Users can be assigned to these groups and the logged in
user would only see menu items configured to the usergroup he is assigned to.
To do this it needs two tables "usergroups" (storing allowed menu items for each
user group) and "users" (storing users and their assignments to user groups).
To allow the usage of this functionality:
* set up :config:option:`$cfg['Servers'][$i]['pmadb']` and the phpMyAdmin configuration storage
* put the correct table names in
:config:option:`$cfg['Servers'][$i]['users']` (e.g. ``pma__users``) and
:config:option:`$cfg['Servers'][$i]['usergroups']` (e.g. ``pma__usergroups``)
.. _tracking:
.. config:option:: $cfg['Servers'][$i]['tracking']

View File

@ -45,4 +45,6 @@ foreach ($hosts as $host) {
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
}

View File

@ -239,3 +239,66 @@ CREATE TABLE IF NOT EXISTS `pma__userconfig` (
)
COMMENT='User preferences storage for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma__users`
--
CREATE TABLE IF NOT EXISTS `pma__users` (
`username` varchar(64) NOT NULL,
`usergroup` varchar(64) NOT NULL,
PRIMARY KEY (`username`,`usergroup`)
)
COMMENT='Users and their assignments to user groups'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma__usergroups`
--
CREATE TABLE IF NOT EXISTS `pma__usergroups` (
`usergroup` varchar(64) NOT NULL,
`server_databases` enum('Y','N') NOT NULL DEFAULT 'N',
`server_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`server_status` enum('Y','N') NOT NULL DEFAULT 'N',
`server_rights` enum('Y','N') NOT NULL DEFAULT 'N',
`server_export` enum('Y','N') NOT NULL DEFAULT 'N',
`server_import` enum('Y','N') NOT NULL DEFAULT 'N',
`server_settings` enum('Y','N') NOT NULL DEFAULT 'N',
`server_binlog` enum('Y','N') NOT NULL DEFAULT 'N',
`server_replication` enum('Y','N') NOT NULL DEFAULT 'N',
`server_vars` enum('Y','N') NOT NULL DEFAULT 'N',
`server_charset` enum('Y','N') NOT NULL DEFAULT 'N',
`server_plugins` enum('Y','N') NOT NULL DEFAULT 'N',
`server_engine` enum('Y','N') NOT NULL DEFAULT 'N',
`db_structure` enum('Y','N') NOT NULL DEFAULT 'N',
`db_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`db_search` enum('Y','N') NOT NULL DEFAULT 'N',
`db_qbe` enum('Y','N') NOT NULL DEFAULT 'N',
`db_export` enum('Y','N') NOT NULL DEFAULT 'N',
`db_import` enum('Y','N') NOT NULL DEFAULT 'N',
`db_operation` enum('Y','N') NOT NULL DEFAULT 'N',
`db_privileges` enum('Y','N') NOT NULL DEFAULT 'N',
`db_routines` enum('Y','N') NOT NULL DEFAULT 'N',
`db_events` enum('Y','N') NOT NULL DEFAULT 'N',
`db_triggers` enum('Y','N') NOT NULL DEFAULT 'N',
`db_tracking` enum('Y','N') NOT NULL DEFAULT 'N',
`db_designer` enum('Y','N') NOT NULL DEFAULT 'N',
`table_browse` enum('Y','N') NOT NULL DEFAULT 'N',
`table_structure` enum('Y','N') NOT NULL DEFAULT 'N',
`table_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`table_search` enum('Y','N') NOT NULL DEFAULT 'N',
`table_insert` enum('Y','N') NOT NULL DEFAULT 'N',
`table_export` enum('Y','N') NOT NULL DEFAULT 'N',
`table_import` enum('Y','N') NOT NULL DEFAULT 'N',
`table_operation` enum('Y','N') NOT NULL DEFAULT 'N',
`table_tracking` enum('Y','N') NOT NULL DEFAULT 'N',
`table_triggers` enum('Y','N') NOT NULL DEFAULT 'N',
PRIMARY KEY (`usergroup`)
)
COMMENT='User groups with configured menu items'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;

View File

@ -225,3 +225,66 @@ CREATE TABLE IF NOT EXISTS `pma__userconfig` (
)
COMMENT='User preferences storage for phpMyAdmin'
COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma__users`
--
CREATE TABLE IF NOT EXISTS `pma__users` (
`username` varchar(64) NOT NULL,
`usergroup` varchar(64) NOT NULL,
PRIMARY KEY (`username`,`usergroup`)
)
COMMENT='Users and their assignments to user groups'
COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma__usergroups`
--
CREATE TABLE IF NOT EXISTS `pma__usergroups` (
`usergroup` varchar(64) NOT NULL,
`server_databases` enum('Y','N') NOT NULL DEFAULT 'N',
`server_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`server_status` enum('Y','N') NOT NULL DEFAULT 'N',
`server_rights` enum('Y','N') NOT NULL DEFAULT 'N',
`server_export` enum('Y','N') NOT NULL DEFAULT 'N',
`server_import` enum('Y','N') NOT NULL DEFAULT 'N',
`server_settings` enum('Y','N') NOT NULL DEFAULT 'N',
`server_binlog` enum('Y','N') NOT NULL DEFAULT 'N',
`server_replication` enum('Y','N') NOT NULL DEFAULT 'N',
`server_vars` enum('Y','N') NOT NULL DEFAULT 'N',
`server_charset` enum('Y','N') NOT NULL DEFAULT 'N',
`server_plugins` enum('Y','N') NOT NULL DEFAULT 'N',
`server_engine` enum('Y','N') NOT NULL DEFAULT 'N',
`db_structure` enum('Y','N') NOT NULL DEFAULT 'N',
`db_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`db_search` enum('Y','N') NOT NULL DEFAULT 'N',
`db_qbe` enum('Y','N') NOT NULL DEFAULT 'N',
`db_export` enum('Y','N') NOT NULL DEFAULT 'N',
`db_import` enum('Y','N') NOT NULL DEFAULT 'N',
`db_operation` enum('Y','N') NOT NULL DEFAULT 'N',
`db_privileges` enum('Y','N') NOT NULL DEFAULT 'N',
`db_routines` enum('Y','N') NOT NULL DEFAULT 'N',
`db_events` enum('Y','N') NOT NULL DEFAULT 'N',
`db_triggers` enum('Y','N') NOT NULL DEFAULT 'N',
`db_tracking` enum('Y','N') NOT NULL DEFAULT 'N',
`db_designer` enum('Y','N') NOT NULL DEFAULT 'N',
`table_browse` enum('Y','N') NOT NULL DEFAULT 'N',
`table_structure` enum('Y','N') NOT NULL DEFAULT 'N',
`table_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`table_search` enum('Y','N') NOT NULL DEFAULT 'N',
`table_insert` enum('Y','N') NOT NULL DEFAULT 'N',
`table_export` enum('Y','N') NOT NULL DEFAULT 'N',
`table_import` enum('Y','N') NOT NULL DEFAULT 'N',
`table_operation` enum('Y','N') NOT NULL DEFAULT 'N',
`table_tracking` enum('Y','N') NOT NULL DEFAULT 'N',
`table_triggers` enum('Y','N') NOT NULL DEFAULT 'N',
PRIMARY KEY (`usergroup`)
)
COMMENT='User groups with configured menu items'
COLLATE utf8_bin;

View File

@ -172,6 +172,7 @@ AJAX.registerTeardown('server_privileges.js', function () {
$('form[name=usersForm]').unbind('submit');
$("#fieldset_delete_user_footer #buttonGo.ajax").die('click');
$("a.edit_user_anchor.ajax").die('click');
$("a.edit_user_group_anchor.ajax").die('click');
$("#edit_user_dialog").find("form.ajax").die('submit');
$("button.mult_submit[value=export]").die('click');
$("a.export_user_anchor.ajax").die('click');
@ -300,6 +301,75 @@ AJAX.registerOnload('server_privileges.js', function () {
}); // end $.post()
}); // end Revoke User
$("a.edit_user_group_anchor.ajax").live('click', function (event) {
event.preventDefault();
$(this).parents('tr').addClass('current_row');
var token = $(this).parents('form').find('input[name="token"]').val();
var $msg = PMA_ajaxShowMessage();
$.get(
$(this).attr('href'),
{
'ajax_request': true,
'edit_user_group_dialog': true,
'token': token
},
function (data) {
if (data.success === true) {
PMA_ajaxRemoveMessage($msg);
var buttonOptions = {};
buttonOptions[PMA_messages.strGo] = function () {
var usrGroup = $('#changeUserGroupDialog')
.find('select[name="userGroup"]')
.val();
var $message = PMA_ajaxShowMessage();
$.get(
'server_privileges.php',
$('#changeUserGroupDialog').find('form').serialize() + '&ajax_request=1',
function (data) {
PMA_ajaxRemoveMessage($message);
if (data.success === true) {
$("#usersForm")
.find('.current_row')
.removeClass('current_row')
.find('.usrGroup')
.text(usrGroup);
} else {
PMA_ajaxShowMessage(data.error, false);
$("#usersForm")
.find('.current_row')
.removeClass('current_row');
}
}
);
$(this).dialog("close");
};
buttonOptions[PMA_messages.strClose] = function () {
$(this).dialog("close");
};
var $dialog = $('<div/>')
.attr('id', 'changeUserGroupDialog')
.append(data.message)
.dialog({
width: 500,
minWidth: 300,
modal: true,
buttons: buttonOptions,
title: $('legend', $(data.message)).text(),
close: function () {
$(this).remove();
}
});
$dialog.find('legend').remove();
} else {
PMA_ajaxShowMessage(data.error, false);
$("#usersForm")
.find('.current_row')
.removeClass('current_row');
}
}
);
});
/**
* AJAX handler for 'Edit User'
*

View File

@ -99,17 +99,64 @@ class PMA_Menu
{
$tabs = array();
$url_params = array('db' => $this->_db);
$level = '';
if (strlen($this->_table)) {
$tabs = $this->_getTableTabs();
$url_params['table'] = $this->_table;
$level = 'table';
} else if (strlen($this->_db)) {
$tabs = $this->_getDbTabs();
$level = 'db';
} else {
$tabs = $this->_getServerTabs();
$level = 'server';
}
$allowedTabs = $this->_getAllowedTabs($level);
foreach ($tabs as $key => $value) {
if (! array_key_exists($key, $allowedTabs)) {
unset($tabs[$key]);
}
}
return PMA_Util::getHtmlTabs($tabs, $url_params, 'topmenu', true);
}
/**
* Returns a list of allowed tabs for the current user for the given level
*
* @param string $level 'server', 'db' or 'table' level
*
* @return array list of allowed tabs
*/
private function _getAllowedTabs($level)
{
$allowedTabs = PMA_Util::getMenuTabList($level);
if ($GLOBALS['cfgRelation']['menuswork']) {
$groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']);
$userTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']);
$sql_query = "SELECT * FROM " . $groupTable
. " WHERE `usergroup` = (SELECT usergroup FROM "
. $userTable . " WHERE `username` = '"
. PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "')";
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
$row = $GLOBALS['dbi']->fetchAssoc($result);
foreach ($allowedTabs as $key => $tab) {
$colName = $level . '_' . $key;
if (isset($row[$colName]) && $row[$colName] == 'N') {
unset($allowedTabs[$key]);
}
}
}
}
return $allowedTabs;
}
/**
* Returns the breadcrumbs as HTML
*
@ -130,21 +177,13 @@ class PMA_Menu
$item = '<a href="%1$s?%2$s" class="item">';
if (in_array(
$GLOBALS['cfg']['TabsMode'],
array('text', 'both')
)
) {
if (in_array($GLOBALS['cfg']['TabsMode'], array('text', 'both'))) {
$item .= '%4$s: ';
}
$item .= '%3$s</a>';
$retval .= "<div id='floating_menubar'></div>";
$retval .= "<div id='serverinfo'>";
if (in_array(
$GLOBALS['cfg']['TabsMode'],
array('icons', 'both')
)
) {
if (in_array($GLOBALS['cfg']['TabsMode'], array('icons', 'both'))) {
$retval .= PMA_Util::getImage(
's_host.png',
'',
@ -161,11 +200,7 @@ class PMA_Menu
if (strlen($this->_db)) {
$retval .= $separator;
if (in_array(
$GLOBALS['cfg']['TabsMode'],
array('icons', 'both')
)
) {
if (in_array($GLOBALS['cfg']['TabsMode'], array('icons', 'both'))) {
$retval .= PMA_Util::getImage(
's_db.png',
'',
@ -187,11 +222,7 @@ class PMA_Menu
include './libraries/tbl_info.inc.php';
$retval .= $separator;
if (in_array(
$GLOBALS['cfg']['TabsMode'],
array('icons', 'both')
)
) {
if (in_array($GLOBALS['cfg']['TabsMode'], array('icons', 'both'))) {
$icon = $tbl_is_view ? 'b_views.png' : 's_tbl.png';
$retval .= PMA_Util::getImage(
$icon,
@ -444,11 +475,9 @@ class PMA_Menu
{
$is_superuser = isset($GLOBALS['dbi']) && $GLOBALS['dbi']->isSuperuser();
$binary_logs = null;
if (isset($GLOBALS['dbi'])
&& (! defined('PMA_DRIZZLE')
|| (defined('PMA_DRIZZLE') && ! PMA_DRIZZLE)
)
) {
$notDrizzle = ! defined('PMA_DRIZZLE')
|| (defined('PMA_DRIZZLE') && ! PMA_DRIZZLE);
if (isset($GLOBALS['dbi']) && $notDrizzle) {
$binary_logs = $GLOBALS['dbi']->fetchResult(
'SHOW MASTER LOGS',
'Log_name',
@ -486,6 +515,10 @@ class PMA_Menu
$tabs['rights']['icon'] = 's_rights.png';
$tabs['rights']['link'] = 'server_privileges.php';
$tabs['rights']['text'] = __('Users');
$tabs['rights']['active'] = in_array(
basename($GLOBALS['PMA_PHP_SELF']),
array('server_privileges.php', 'server_user_groups.php')
);
}
$tabs['export']['icon'] = 'b_export.png';

View File

@ -4153,6 +4153,69 @@ class PMA_Util
return $regex;
}
/**
* Return the list of tabs for the menu with corresponding names
*
* @param string $level 'server', 'db' or 'table' level
*
* @return array list of tabs for the menu
*/
public static function getMenuTabList($level = null)
{
$tabList = array(
'server' => array(
'databases' => __('Databases'),
'sql' => __('SQL'),
'status' => __('Status'),
'rights' => __('Users'),
'export' => __('Export'),
'import' => __('Import'),
'settings' => __('Settings'),
'binlog' => __('Binary log'),
'replication' => __('Replication'),
'vars' => __('Variables'),
'charset' => __('Charsets'),
'plugins' => __('Plugins'),
'engine' => __('Engines')
),
'db' => array(
'structure' => __('Structure'),
'sql' => __('SQL'),
'search' => __('Search'),
'qbe' => __('Query'),
'export' => __('Export'),
'import' => __('Import'),
'operation' => __('Operations'),
'privileges' => __('Privileges'),
'routines' => __('Routines'),
'events' => __('Events'),
'triggers' => __('Triggers'),
'tracking' => __('Tracking'),
'designer' => __('Designer')
),
'table' => array(
'browse' => __('Browse'),
'structure' => __('Structure'),
'sql' => __('SQL'),
'search' => __('Search'),
'insert' => __('Insert'),
'export' => __('Export'),
'import' => __('Import'),
'operation' => __('Operations'),
'tracking' => __('Tracking'),
'triggers' => __('Triggers'),
)
);
if ($level == null) {
return $tabList;
} else if (array_key_exists($level, $tabList)) {
return $tabList[$level];
} else {
return null;
}
}
/**
* Returns information with latest version from phpmyadmin.net
*
@ -4191,9 +4254,8 @@ class PMA_Util
$cfg['VersionCheckProxyUser'] . ':'
. $cfg['VersionCheckProxyPass']
);
$context['http']['header'] =
'Proxy-Authorization: Basic '
. $auth;
$context['http']['header']
= 'Proxy-Authorization: Basic ' . $auth;
}
}
$response = file_get_contents(

View File

@ -402,6 +402,24 @@ $cfg['Servers'][$i]['tracking'] = '';
*/
$cfg['Servers'][$i]['userconfig'] = '';
/**
* table to store users and their assignment to user groups
* - leave blank to disable configurable menus feature
* SUGGESTED: 'pma__users'
*
* @global string $cfg['Servers'][$i]['users']
*/
$cfg['Servers'][$i]['users'] = '';
/**
* table to store allowed menu items for each user group
* - leave blank to disable configurable menus feature
* SUGGESTED: 'pma__usergroups'
*
* @global string $cfg['Servers'][$i]['usergroups']
*/
$cfg['Servers'][$i]['usergroups'] = '';
/**
* Maximum number of records saved in $cfg['Servers'][$i]['table_uiprefs'] table.
*

View File

@ -450,6 +450,10 @@ $strConfigServers_tracking_version_auto_create_desc = __('Whether the tracking m
$strConfigServers_tracking_version_auto_create_name = __('Automatically create versions');
$strConfigServers_userconfig_desc = __('Leave blank for no user preferences storage in database, suggested: [kbd]pma__userconfig[/kbd]');
$strConfigServers_userconfig_name = __('User preferences storage table');
$strConfigServers_users_desc = __('Leave blank to disable configurable menus feature, suggested: [kbd]pma__users[/kbd]');
$strConfigServers_users_name = __('Users table');
$strConfigServers_usergroups_desc = __('Leave blank to disable configurable menus feature, suggested: [kbd]pma__usergroups[/kbd]');
$strConfigServers_usergroups_name = __('User groups table');
$strConfigServers_user_desc = __('Leave empty if not using config auth');
$strConfigServers_user_name = __('User for config auth');
$strConfigServers_verbose_desc = __('A user-friendly description of this server. Leave blank to display the hostname instead.');

View File

@ -70,6 +70,8 @@ $forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array(
'bookmarktable' => 'pma__bookmark',
'relation' => 'pma__relation',
'userconfig' => 'pma__userconfig',
'users' => 'pma__users',
'usergroups' => 'pma__usergroups',
'table_info' => 'pma__table_info',
'column_info' => 'pma__column_info',
'history' => 'pma__history',

View File

@ -377,6 +377,11 @@ function PMA_getSqlQueryAndCreateDbBeforeCopy()
$GLOBALS['dbi']->query($local_query);
$GLOBALS['db'] = $original_db;
// Set the SQL mode to NO_AUTO_VALUE_ON_ZERO to prevent MySQL from creating
// export statements it cannot import
$sql_set_mode = "SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'";
PMA_DBI_query($sql_set_mode);
// rebuild the database list because PMA_Table::moveCopy
// checks in this list if the target db exists
$GLOBALS['pma']->databases->build();

View File

@ -248,6 +248,23 @@ function PMA_getRelationsParamDiagnostic($cfgRelation)
'userconfigwork',
$messages
);
$retval .= PMA_getDiagMessageForParameter(
'users',
isset($cfgRelation['users']),
$messages,
'users'
);
$retval .= PMA_getDiagMessageForParameter(
'usergroups',
isset($cfgRelation['usergroups']),
$messages,
'usergroups'
);
$retval .= PMA_getDiagMessageForFeature(
__('Configurable menus'),
'menuswork',
$messages
);
$retval .= '</table>' . "\n";
$retval .= '<p>' . __('Quick steps to setup advanced features:') . '</p>';
@ -347,22 +364,23 @@ function PMA_getDiagMessageForParameter($parameter,
*/
function PMA_checkRelationsParam()
{
$cfgRelation = array();
$cfgRelation['relwork'] = false;
$cfgRelation['displaywork'] = false;
$cfgRelation['bookmarkwork']= false;
$cfgRelation['pdfwork'] = false;
$cfgRelation['commwork'] = false;
$cfgRelation['mimework'] = false;
$cfgRelation['historywork'] = false;
$cfgRelation['recentwork'] = false;
$cfgRelation['uiprefswork'] = false;
$cfgRelation['trackingwork'] = false;
$cfgRelation['designerwork'] = false;
$cfgRelation = array();
$cfgRelation['relwork'] = false;
$cfgRelation['displaywork'] = false;
$cfgRelation['bookmarkwork'] = false;
$cfgRelation['pdfwork'] = false;
$cfgRelation['commwork'] = false;
$cfgRelation['mimework'] = false;
$cfgRelation['historywork'] = false;
$cfgRelation['recentwork'] = false;
$cfgRelation['uiprefswork'] = false;
$cfgRelation['trackingwork'] = false;
$cfgRelation['designerwork'] = false;
$cfgRelation['userconfigwork'] = false;
$cfgRelation['allworks'] = false;
$cfgRelation['user'] = null;
$cfgRelation['db'] = null;
$cfgRelation['menuswork'] = false;
$cfgRelation['allworks'] = false;
$cfgRelation['user'] = null;
$cfgRelation['db'] = null;
if ($GLOBALS['server'] == 0
|| empty($GLOBALS['cfg']['Server']['pmadb'])
@ -408,21 +426,25 @@ function PMA_checkRelationsParam()
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['table_coords']) {
$cfgRelation['table_coords'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['designer_coords']) {
$cfgRelation['designer_coords'] = $curr_table[0];
$cfgRelation['designer_coords'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['column_info']) {
$cfgRelation['column_info'] = $curr_table[0];
$cfgRelation['column_info'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['pdf_pages']) {
$cfgRelation['pdf_pages'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['history']) {
$cfgRelation['history'] = $curr_table[0];
$cfgRelation['history'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['recent']) {
$cfgRelation['recent'] = $curr_table[0];
$cfgRelation['recent'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['table_uiprefs']) {
$cfgRelation['table_uiprefs'] = $curr_table[0];
$cfgRelation['table_uiprefs'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['tracking']) {
$cfgRelation['tracking'] = $curr_table[0];
$cfgRelation['tracking'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['userconfig']) {
$cfgRelation['userconfig'] = $curr_table[0];
$cfgRelation['userconfig'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['users']) {
$cfgRelation['users'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['usergroups']) {
$cfgRelation['usergroups'] = $curr_table[0];
}
} // end while
$GLOBALS['dbi']->freeResult($tab_rs);
@ -430,7 +452,7 @@ function PMA_checkRelationsParam()
if (isset($cfgRelation['relation'])) {
$cfgRelation['relwork'] = true;
if (isset($cfgRelation['table_info'])) {
$cfgRelation['displaywork'] = true;
$cfgRelation['displaywork'] = true;
}
}
@ -473,12 +495,17 @@ function PMA_checkRelationsParam()
$cfgRelation['bookmarkwork'] = true;
}
if (isset($cfgRelation['users']) && isset($cfgRelation['usergroups'])) {
$cfgRelation['menuswork'] = true;
}
if ($cfgRelation['relwork'] && $cfgRelation['displaywork']
&& $cfgRelation['pdfwork'] && $cfgRelation['commwork']
&& $cfgRelation['mimework'] && $cfgRelation['historywork']
&& $cfgRelation['recentwork'] && $cfgRelation['uiprefswork']
&& $cfgRelation['trackingwork'] && $cfgRelation['userconfigwork']
&& $cfgRelation['bookmarkwork'] && $cfgRelation['designerwork']
&& $cfgRelation['menuswork']
) {
$cfgRelation['allworks'] = true;
}

View File

@ -390,6 +390,103 @@ function PMA_getSqlQueryForDisplayPrivTable($db, $table, $username, $hostname)
." AND `Db` = '" . PMA_Util::unescapeMysqlWildcards($db) . "'"
." AND `Table_name` = '" . PMA_Util::sqlAddSlashes($table) . "';";
}
/**
* Displays a dropdown to select the user group
* with menu items configured to each of them.
*
* @param string $username username
*
* @return string html to select the user group
*/
function PMA_getHtmlToChoseUserGroup($username)
{
$html_output = '<form class="ajax" id="changeUserGroupForm"'
. ' action="server_privileges.php" method="post">';
$params = array('username' => $username);
$html_output .= PMA_generate_common_hidden_inputs($params);
$html_output .= '<fieldset id="fieldset_user_group_selection">';
$html_output .= '<legend>' . __('User group') . '</legend>';
$groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']);
$userTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']);
$userGroups = array();
$sql_query = "SELECT `usergroup` FROM " . $groupTable;
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
$userGroups[] = $row[0];
}
}
$GLOBALS['dbi']->freeResult($result);
$userGroup = '';
if (isset($GLOBALS['username'])) {
$sql_query = "SELECT `usergroup` FROM " . $userTable
. " WHERE `username` = '" . PMA_Util::sqlAddSlashes($username) . "'";
$userGroup = $GLOBALS['dbi']->fetchValue(
$sql_query, 0, 0, $GLOBALS['controllink']
);
}
$html_output .= __('User group') . ': ';
$html_output .= '<select name="userGroup">';
$html_output .= '<option value=""></option>';
foreach ($userGroups as $oneUserGroup) {
$html_output .= '<option value="' . htmlspecialchars($oneUserGroup) . '"'
. ($oneUserGroup == $userGroup ? ' selected="selected"' : '')
. '>'
. htmlspecialchars($oneUserGroup)
. '</option>';
}
$html_output .= '</select>';
$html_output .= '<input type="hidden" name="changeUserGroup" value="1">';
$html_output .= '</fieldset>';
$html_output .= '</form>';
return $html_output;
}
/**
* Sets the user group from request values
*
* @param string $username username
* @param string $userGroup user group to set
*
* @return void
*/
function PMA_setUserGroup($username, $userGroup)
{
$userTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']);
$sql_query = "SELECT `usergroup` FROM " . $userTable
. " WHERE `username` = '" . PMA_Util::sqlAddSlashes($username) . "'";
$oldUserGroup = $GLOBALS['dbi']->fetchValue(
$sql_query, 0, 0, $GLOBALS['controllink']
);
if ($oldUserGroup === false) {
$upd_query = "INSERT INTO " . $userTable . "(`username`, `usergroup`)"
. " VALUES ('" . PMA_Util::sqlAddSlashes($username) . "', "
. "'" . PMA_Util::sqlAddSlashes($userGroup) . "')";
} else {
if (empty($userGroup)) {
$upd_query = "DELETE FROM " . $userTable
. " WHERE `username`='" . PMA_Util::sqlAddSlashes($username) . "'";
} elseif ($oldUserGroup != $userGroup) {
$upd_query = "UPDATE " . $userTable
. " SET `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"
. " WHERE `username`='" . PMA_Util::sqlAddSlashes($username) . "'";
}
}
if (isset($upd_query)) {
PMA_queryAsControlUser($upd_query);
}
}
/**
* Displays the privileges form table
*
@ -591,7 +688,7 @@ function PMA_getHtmlForDisplayResourceLimits($row)
* @param string $db the database
* @param string $table the table
* @param boolean $columns columns array
* @param $row current privileges row
* @param array $row current privileges row
*
* @return string $html_output
*/
@ -2429,9 +2526,12 @@ function PMA_getUsersOverview($result, $db_rights, $link_edit, $pmaThemeImage,
. PMA_Util::showHint(
__('Note: MySQL privilege names are expressed in English')
)
. '</th>' . "\n"
. '<th>' . __('Grant') . '</th>' . "\n"
. '<th colspan="2">' . __('Action') . '</th>' . "\n"
. '</th>' . "\n";
if ($GLOBALS['cfgRelation']['menuswork']) {
$html_output .= '<th>' . __('User group') . '</th>' . "\n";
}
$html_output .= '<th>' . __('Grant') . '</th>' . "\n"
. '<th colspan="3">' . __('Action') . '</th>' . "\n"
. '</tr>' . "\n"
. '</thead>' . "\n";
@ -2479,6 +2579,27 @@ function PMA_getUsersOverview($result, $db_rights, $link_edit, $pmaThemeImage,
*/
function PMA_getTableBodyForUserRightsTable($db_rights, $link_edit, $link_export)
{
if ($GLOBALS['cfgRelation']['menuswork']) {
$usersTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']);
$sqlQuery = "SELECT * FROM " . $usersTable;
$result = PMA_queryAsControlUser($sqlQuery, false);
$groupAssignment = array();
if ($result) {
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
$groupAssignment[$row['username']] = $row['usergroup'];
}
}
$GLOBALS['dbi']->freeResult($result);
$link_edit_user_group = '<a class="edit_user_group_anchor ajax"'
. ' href="server_privileges.php?'
. str_replace('%', '%%', $GLOBALS['url_query'])
. '&amp;username=%s">'
. PMA_Util::getIcon('b_usrlist.png', __('Edit user group'))
. '</a>';
}
$odd_row = true;
$index_checkbox = 0;
$html_output = '';
@ -2521,28 +2642,48 @@ function PMA_getTableBodyForUserRightsTable($db_rights, $link_edit, $link_export
$html_output .= '<td><code>' . "\n"
. '' . implode(',' . "\n" . ' ', $host['privs']) . "\n"
. '</code></td>' . "\n"
. '<td>'
. '</code></td>' . "\n";
if ($GLOBALS['cfgRelation']['menuswork']) {
$html_output .= '<td class="usrGroup">' . "\n"
. (isset($groupAssignment[$host['User']])
? $groupAssignment[$host['User']]
: ''
)
. '</td>' . "\n";
}
$html_output .= '<td>'
. ($host['Grant_priv'] == 'Y' ? __('Yes') : __('No'))
. '</td>' . "\n"
. '<td class="center">'
. '</td>' . "\n";
$html_output .= '<td class="center">'
. sprintf(
$link_edit,
urlencode($host['User']),
urlencode($host['Host']),
'',
''
);
$html_output .= '</td>';
$html_output .= '<td class="center">';
$html_output .= sprintf(
$link_export,
urlencode($host['User']),
urlencode($host['Host']),
(isset($_GET['initial']) ? $_GET['initial'] : '')
);
$html_output .= '</td>';
)
. '</td>';
if ($GLOBALS['cfgRelation']['menuswork']) {
if (empty($host['User'])) {
$html_output .= '<td class="center"></td>';
} else {
$html_output .= '<td class="center">'
. sprintf(
$link_edit_user_group,
urlencode($host['User'])
)
. '</td>';
}
}
$html_output .= '<td class="center">'
. sprintf(
$link_export,
urlencode($host['User']),
urlencode($host['Host']),
(isset($_GET['initial']) ? $_GET['initial'] : '')
)
. '</td>';
$html_output .= '</tr>';
$odd_row = ! $odd_row;
}
@ -3028,8 +3169,324 @@ function PMA_getHtmlForDisplayUserOverviewPage($link_edit, $pmaThemeImage,
$flushnote->addParam('</a>', false);
$html_output .= $flushnote->getDisplay();
}
return $html_output;
}
return $html_output;
}
/**
* Return HTML to list the users belonging to a given user group
*
* @param string $userGroup user group name
*
* @return HTML to list the users belonging to a given user group
*/
function PMA_getHtmlForListingUsersofAGroup($userGroup)
{
$html_output = '<h2>'
. sprintf(__('Users of \'%s\' user group'), htmlspecialchars($userGroup))
. '</h2>';
$usersTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']);
$sql_query = "SELECT `username` FROM " . $usersTable
. " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'";
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
if ($GLOBALS['dbi']->numRows($result) == 0) {
$html_output .= '<p>'
. __('No users were found belonging to this user group')
. '</p>';
} else {
$html_output .= '<table>'
. '<thead><tr><th>#</th><th>' . __('User') . '</th></tr></thead>'
. '<tbody>';
$i = 0;
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
$i++;
$html_output .= '<tr>'
. '<td>' . $i . ' </td>'
. '<td>' . htmlspecialchars($row[0]) . '</td>'
. '</tr>';
}
$html_output .= '</tbody>'
. '</table>';
}
}
$GLOBALS['dbi']->freeResult($result);
return $html_output;
}
/**
* Returns HTML for the 'user groups' table
*
* @return string HTML for the 'user groups' table
*/
function PMA_getHtmlForUserGroupsTable()
{
$tabs = PMA_Util::getMenuTabList();
$html_output = '<h2>' . __('User groups') . '</h2>';
$html_output .= '<form name="userGroupsForm" id="userGroupsForm"'
. ' action="server_privileges.php" method="post">';
$html_output .= PMA_generate_common_hidden_inputs();
$html_output .= '<table id="userGroupsTable">';
$html_output .= '<thead><tr>';
$html_output .= '<th style="white-space: nowrap">' . __('User group') . '</th>';
$html_output .= '<th>' . __('Server level tabs') . '</th>';
$html_output .= '<th>' . __('Database level tabs') . '</th>';
$html_output .= '<th>' . __('Table level tabs') . '</th>';
$html_output .= '<th>' . __('Action') . '</th>';
$html_output .= '</tr></thead>';
$html_output .= '<tbody>';
$groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']);
$sql_query = "SELECT * FROM " . $groupTable;
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
$odd = true;
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
$html_output .= '<tr class="' . ($odd ? 'odd' : 'even') . '">';
$html_output .= '<td>' . htmlspecialchars($row['usergroup']) . '</td>';
$html_output .= '<td>' . _getAllowedTabNames($row, 'server') . '</td>';
$html_output .= '<td>' . _getAllowedTabNames($row, 'db') . '</td>';
$html_output .= '<td>' . _getAllowedTabNames($row, 'table') . '</td>';
$html_output .= '<td>';
$html_output .= '<a class="" href="server_user_groups.php?'
. PMA_generate_common_url() . '&viewUsers=1&userGroup='
. urlencode($row['usergroup']) . '">'
. PMA_Util::getIcon('b_usrlist.png', __('View users')) . '</a>';
$html_output .= '&nbsp;&nbsp;';
$html_output .= '<a class="" href="server_user_groups.php?'
. PMA_generate_common_url() . '&editUserGroup=1&userGroup='
. urlencode($row['usergroup']) . '">'
. PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a>';
$html_output .= '&nbsp;&nbsp;';
$html_output .= '<a class="" href="server_user_groups.php?'
. PMA_generate_common_url() . '&deleteUserGroup=1&userGroup='
. urlencode($row['usergroup']) . '">'
. PMA_Util::getIcon('b_drop.png', __('Delete')) . '</a>';
$html_output .= '</td>';
$html_output .= '</tr>';
$odd = ! $odd;
}
}
$GLOBALS['dbi']->freeResult($result);
$html_output .= '</tbody>';
$html_output .= '</table>';
$html_output .= '</form>';
$html_output .= '<fieldset id="fieldset_add_user_group">';
$html_output .= '<a href="server_user_groups.php?'
. PMA_generate_common_url() . '&addUserGroup=1">'
. PMA_Util::getIcon('b_usradd.png')
. __('Add user group') . '</a>';
$html_output .= '</fieldset>';
return $html_output;
}
/**
* Returns the list of allowed menu tab names
* based on a data row from usergroup table.
*
* @param array $row row of usergroup table
* @param string $level 'server', 'db' or 'table'
*
* @return string comma seperated list of allowed menu tab names
*/
function _getAllowedTabNames($row, $level)
{
$tabNames = array();
$tabs = PMA_Util::getMenuTabList($level);
foreach ($tabs as $tab => $tabName) {
if (! isset($row[$level . '_' . $tab])
|| $row[$level . '_' . $tab] == 'Y'
) {
$tabNames[] = $tabName;
}
}
return implode(', ', $tabNames);
}
/**
* Deletes a user group
*
* @param string $userGroup user group name
*
* @return void
*/
function PMA_deleteUserGroup($userGroup)
{
$groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']);
$sql_query = "DELETE FROM " . $groupTable
. " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'";
PMA_queryAsControlUser($sql_query, true);
}
/**
* Returns HTML for add/edit user group dialog
*
* @param string $userGroup name of the user group in case of editing
*
* @return string HTML for add/edit user group dialog
*/
function PMA_getHtmlToEditUserGroup($userGroup = null)
{
$html_output = '';
if ($userGroup == null) {
$html_output .= '<h2>' . __('Add user group') . '</h2>';
} else {
$html_output .= '<h2>'
. sprintf(__('Edit user group: \'%s\''), htmlspecialchars($userGroup))
. '</h2>';
}
$html_output .= '<form name="userGroupForm" id="userGroupForm"'
. ' action="server_user_groups.php" method="post">';
$urlParams = array();
if ($userGroup != null) {
$urlParams['userGroup'] = $userGroup;
$urlParams['editUserGroupSubmit'] = '1';
} else {
$urlParams['addUserGroupSubmit'] = '1';
}
$html_output .= PMA_generate_common_hidden_inputs($urlParams);
$html_output .= '<fieldset id="fieldset_user_group_rights">';
$html_output .= '<legend>' . __('User group privileges')
. '&nbsp;&nbsp;&nbsp;'
. '<input type="checkbox" class="checkall_box" title="Check All">'
. '<label for="addUsersForm_checkall">' . __('Check All') .'</label>'
. '</legend>';
if ($userGroup == null) {
$html_output .= '<label for="userGroup">' . __('Group name: ') . '</label>';
$html_output .= '<input type="text" name="userGroup" autocomplete="off" />';
$html_output .= '<div class="clearfloat"></div>';
}
$allowedTabs = array(
'server' => array(),
'db' => array(),
'table' => array()
);
if ($userGroup != null) {
$groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']);
$sql_query = "SELECT * FROM " . $groupTable
. " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'";
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
$row = $GLOBALS['dbi']->fetchAssoc($result);
foreach ($row as $key => $value) {
if (substr($key, 0, 7) == 'server_' && $value == 'Y') {
$allowedTabs['server'][] = substr($key, 7);
} elseif (substr($key, 0, 3) == 'db_' && $value == 'Y') {
$allowedTabs['db'][] = substr($key, 3);
} elseif (substr($key, 0, 6) == 'table_' && $value == 'Y') {
$allowedTabs['table'][] = substr($key, 6);
}
}
}
$GLOBALS['dbi']->freeResult($result);
}
$html_output .= _getTabList(
__('Sever level tabs'), 'server', $allowedTabs['server']
);
$html_output .= _getTabList(
__('Database level tabs'), 'db', $allowedTabs['db']
);
$html_output .= _getTabList(
__('Table level tabs'), 'table', $allowedTabs['table']
);
$html_output .= '</fieldset>';
$html_output .= '<fieldset id="fieldset_user_group_rights_footer"'
. ' class="tblFooters">';
$html_output .= '<input type="submit" name="update_privs" value="Go">';
$html_output .= '</fieldset>';
return $html_output;
}
/**
* Returns HTML for checkbox groups to choose
* tabs of 'server', 'db' or 'table' levels.
*
* @param string $title title of the checkbox group
* @param string $level 'server', 'db' or 'table'
* @param array $selected array of selected allowed tabs
*
* @return string HTML for checkbox groups
*/
function _getTabList($title, $level, $selected)
{
$tabs = PMA_Util::getMenuTabList($level);
$html_output = '<fieldset>';
$html_output .= '<legend>' . $title . '</legend>';
foreach ($tabs as $tab => $tabName) {
$html_output .= '<div class="item">';
$html_output .= '<input type="checkbox" class="checkall"'
. (in_array($tab, $selected) ? 'checked="checked"' : '')
. ' name="' . $level . '_' . $tab . '" value="Y" />';
$html_output .= '<label for="' . $level . '_' . $tab . '">'
. '<code>' . $tabName . '</code>'
. '</label>';
$html_output .= '</div>';
}
$html_output .= '</fieldset>';
return $html_output;
}
/**
* Add/update a user group with allowed menu tabs.
*
* @param string $userGroup user group name
* @param boolean $new whether this is a new user group
*
* @return void
*/
function PMA_editUserGroup($userGroup, $new = false)
{
$tabs = PMA_Util::getMenuTabList();
$groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']);
$cols = "";
$vals = "";
$colsNvals = "";
foreach ($tabs as $tabGroupName => $tabGroup) {
foreach ($tabs[$tabGroupName] as $tab => $tabName) {
$colName = $tabGroupName . '_' . $tab;
$cols .= "," . PMA_Util::backquote($colName);
if (isset($_REQUEST[$colName])&& $_REQUEST[$colName] == 'Y') {
$vals .= ",'Y'";
$colsNvals .= "," . PMA_Util::backquote($colName) . "='Y'";
} else {
$vals .= ",'N'";
$colsNvals .= "," . PMA_Util::backquote($colName) . "='N'";
}
}
}
if ($new) {
$sql_query = "INSERT INTO " . $groupTable
. "(`usergroup`" . $cols . ")"
. " VALUES"
. " ('" . PMA_Util::sqlAddSlashes($userGroup) . "'" . $vals . ")";
} else {
$sql_query = "UPDATE " . $groupTable . " SET " . substr($colsNvals, 1)
. " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'";
}
PMA_queryAsControlUser($sql_query, true);
}
/**
@ -3068,9 +3525,6 @@ function PMA_getHtmlForDisplayUserProperties($dbname_is_wildcard,$url_dbname,
}
$class = ' class="ajax"';
$html_output .= '<form' . $class . ' name="usersForm" id="addUsersForm"'
. ' action="server_privileges.php" method="post">' . "\n";
$_params = array(
'username' => $username,
'hostname' => $hostname,
@ -3081,8 +3535,10 @@ function PMA_getHtmlForDisplayUserProperties($dbname_is_wildcard,$url_dbname,
$_params['tablename'] = $tablename;
}
}
$html_output .= PMA_generate_common_hidden_inputs($_params);
$html_output .= '<form' . $class . ' name="usersForm" id="addUsersForm"'
. ' action="server_privileges.php" method="post">' . "\n";
$html_output .= PMA_generate_common_hidden_inputs($_params);
$html_output .= PMA_getHtmlToDisplayPrivilegesTable(
PMA_ifSetOr($dbname, '*', 'length'),
PMA_ifSetOr($tablename, '*', 'length')
@ -3402,4 +3858,44 @@ function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password)
$sql_query
);
}
/**
* Get HTML for secondary level menu tabs on 'Users' page
*
* @param string $selfUrl Url of the file
*
* @return string HTML for secondary level menu tabs on 'Users' page
*/
function PMA_getHtmlForSubMenusOnUsersPage($selfUrl)
{
$url_params = PMA_generate_common_url();
$items = array(
array(
'name' => __('Users overview'),
'url' => 'server_privileges.php'
),
array(
'name' => __('User groups'),
'url' => 'server_user_groups.php'
)
);
$retval = '<ul id="topmenu2">';
foreach ($items as $item) {
$class = '';
if ($item['url'] === $selfUrl) {
$class = ' class="tabactive"';
}
$retval .= '<li>';
$retval .= '<a' . $class;
$retval .= ' href="' . $item['url'] . '?' . $url_params . '">';
$retval .= $item['name'];
$retval .= '</a>';
$retval .= '</li>';
}
$retval .= '</ul>';
$retval .= '<div class="clearfloat"></div>';
return $retval;
}
?>

View File

@ -0,0 +1,554 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* functions for displaying server status
*
* @usedby server_status.php
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Prints server status information: processes, connections and traffic
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function PMA_getHtmlForServerStatus($ServerStatusData)
{
//display the server state General Information
$retval = PMA_getHtmlForServerStateGeneralInfo($ServerStatusData);
//display the server state traffic information
$retval .= PMA_getHtmlForServerStateTraffic($ServerStatusData);
//display the server state connection information
$retval .= PMA_getHtmlForServerStateConnections($ServerStatusData);
//display the server Process List information
$retval .= PMA_getHtmlForServerProcesslist($ServerStatusData);
return $retval;
}
/**
* Prints server state General information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function PMA_getHtmlForServerStateGeneralInfo($ServerStatusData)
{
$start_time = $GLOBALS['dbi']->fetchValue(
'SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime']
);
$retval = '<h3>';
$bytes_received = $ServerStatusData->status['Bytes_received'];
$bytes_sent = $ServerStatusData->status['Bytes_sent'];
$retval .= sprintf(
__('Network traffic since startup: %s'),
implode(
' ',
PMA_Util::formatByteDown(
$bytes_received + $bytes_sent,
3,
1
)
)
);
$retval .= '</h3>';
$retval .= '<p>';
$retval .= sprintf(
__('This MySQL server has been running for %1$s. It started up on %2$s.'),
PMA_Util::timespanFormat($ServerStatusData->status['Uptime']),
PMA_Util::localisedDate($start_time)
) . "\n";
$retval .= '</p>';
if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
$retval .= '<p class="notice">';
if ($GLOBALS['server_master_status'] && $GLOBALS['server_slave_status']) {
$retval .= __(
'This MySQL server works as <b>master</b> and '
. '<b>slave</b> in <b>replication</b> process.'
);
} elseif ($GLOBALS['server_master_status']) {
$retval .= __(
'This MySQL server works as <b>master</b> '
. 'in <b>replication</b> process.'
);
} elseif ($GLOBALS['server_slave_status']) {
$retval .= __(
'This MySQL server works as <b>slave</b> '
. 'in <b>replication</b> process.'
);
}
$retval .= '</p>';
}
/*
* if the server works as master or slave in replication process,
* display useful information
*/
if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
$retval .= '<hr class="clearfloat" />';
$retval .= '<h3><a name="replication">';
$retval .= __('Replication status');
$retval .= '</a></h3>';
foreach ($GLOBALS['replication_types'] as $type) {
if (isset(${"server_{$type}_status"}) && ${"server_{$type}_status"}) {
$retval .= PMA_getHtmlForReplicationStatusTable($type);
}
}
}
return $retval;
}
/**
* Prints server state traffic information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function PMA_getHtmlForServerStateTraffic($ServerStatusData)
{
$hour_factor = 3600 / $ServerStatusData->status['Uptime'];
$retval = '<table id="serverstatustraffic" class="data noclick">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th colspan="2">';
$retval .= __('Traffic') . '&nbsp;';
$retval .= PMA_Util::showHint(
__(
'On a busy server, the byte counters may overrun, so those statistics '
. 'as reported by the MySQL server may be incorrect.'
)
);
$retval .= '</th>';
$retval .= '<th>&oslash; ' . __('per hour') . '</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('Received') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(
' ',
PMA_Util::formatByteDown(
$ServerStatusData->status['Bytes_received'], 3, 1
)
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= implode(
' ',
PMA_Util::formatByteDown(
$ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1
)
);
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="even">';
$retval .= '<th class="name">' . __('Sent') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(
' ',
PMA_Util::formatByteDown(
$ServerStatusData->status['Bytes_sent'], 3, 1
)
);
$retval .= '</td>';
$retval .= '<td class="value"><?php echo';
$retval .= implode(
' ',
PMA_Util::formatByteDown(
$ServerStatusData->status['Bytes_sent'] * $hour_factor, 3, 1
)
);
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('Total') . '</th>';
$retval .= '<td class="value">';
$bytes_received = $ServerStatusData->status['Bytes_received'];
$bytes_sent = $ServerStatusData->status['Bytes_sent'];
$retval .= implode(
' ',
PMA_Util::formatByteDown(
$bytes_received + $bytes_sent, 3, 1
)
);
$retval .= '</td>';
$retval .= '<td class="value">';
$bytes_received = $ServerStatusData->status['Bytes_received'];
$bytes_sent = $ServerStatusData->status['Bytes_sent'];
$retval .= implode(
' ',
PMA_Util::formatByteDown(
($bytes_received + $bytes_sent) * $hour_factor, 3, 1
)
);
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
/**
* Prints server state connections information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function PMA_getHtmlForServerStateConnections($ServerStatusData)
{
$hour_factor = 3600 / $ServerStatusData->status['Uptime'];
$retval = '<table id="serverstatusconnections" class="data noclick">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th colspan="2">' . __('Connections') . '</th>';
$retval .= '<th>&oslash; ' . __('per hour') . '</th>';
$retval .= '<th>%</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('max. concurrent connections') . '</th>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Max_used_connections'], 0
);
$retval .= '</td>';
$retval .= '<td class="value">--- </td>';
$retval .= '<td class="value">--- </td>';
$retval .= '</tr>';
$retval .= '<tr class="even">';
$retval .= '<th class="name">' . __('Failed attempts') . '</th>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Aborted_connects'], 4, 1, true
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Aborted_connects'] * $hour_factor, 4, 2, true
);
$retval .= '</td>';
$retval .= '<td class="value">';
if ($ServerStatusData->status['Connections'] > 0) {
$abortNum = $ServerStatusData->status['Aborted_connects'];
$connectNum = $ServerStatusData->status['Connections'];
$retval .= PMA_Util::formatNumber(
$abortNum * 100 / $connectNum,
0, 2, true
);
$retval .= '%';
} else {
$retval .= '--- ';
}
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('Aborted') . '</th>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Aborted_clients'], 4, 1, true
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Aborted_clients'] * $hour_factor, 4, 2, true
);
$retval .= '</td>';
$retval .= '<td class="value">';
if ($ServerStatusData->status['Connections'] > 0) {
$abortNum = $ServerStatusData->status['Aborted_clients'];
$connectNum = $ServerStatusData->status['Connections'];
$retval .= PMA_Util::formatNumber(
$abortNum * 100 / $connectNum,
0, 2, true
);
$retval .= '%';
} else {
$retval .= '--- ';
}
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="even">';
$retval .= '<th class="name">' . __('Total') . '</th>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Connections'], 4, 0
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Connections'] * $hour_factor, 4, 2
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(100, 0, 2);
$retval .= '%</td>';
$retval .= '</tr>';
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
/**
* Prints Server Process list
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function PMA_getHtmlForServerProcesslist($ServerStatusData)
{
$url_params = array();
$show_full_sql = ! empty($_REQUEST['full']);
if ($show_full_sql) {
$url_params['full'] = 1;
$full_text_link = 'server_status.php' . PMA_generate_common_url(
array(), 'html', '?'
);
} else {
$full_text_link = 'server_status.php' . PMA_generate_common_url(
array('full' => 1)
);
}
// This array contains display name and real column name of each
// sortable column in the table
$sortable_columns = array(
array(
'column_name' => __('ID'),
'order_by_field' => 'Id'
),
array(
'column_name' => __('User'),
'order_by_field' => 'User'
),
array(
'column_name' => __('Host'),
'order_by_field' => 'Host'
),
array(
'column_name' => __('Database'),
'order_by_field' => 'db'
),
array(
'column_name' => __('Command'),
'order_by_field' => 'Command'
),
array(
'column_name' => __('Time'),
'order_by_field' => 'Time'
),
array(
'column_name' => __('Status'),
'order_by_field' => 'State'
),
array(
'column_name' => __('SQL query'),
'order_by_field' => 'Info'
)
);
$sortable_columns_count = count($sortable_columns);
if (PMA_DRIZZLE) {
$left_str = 'left(p.info, '
. (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')';
$sql_query = "SELECT
p.id AS Id,
p.username AS User,
p.host AS Host,
p.db AS db,
p.command AS Command,
p.time AS Time,
p.state AS State,"
. ($show_full_sql ? 's.query' : $left_str )
. " AS Info FROM data_dictionary.PROCESSLIST p "
. ($show_full_sql
? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id'
: '');
if (! empty($_REQUEST['order_by_field'])
&& ! empty($_REQUEST['sort_order'])
) {
$sql_query .= ' ORDER BY p.' . $_REQUEST['order_by_field'] . ' '
. $_REQUEST['sort_order'];
}
} else {
$sql_query = $show_full_sql
? 'SHOW FULL PROCESSLIST'
: 'SHOW PROCESSLIST';
if (! empty($_REQUEST['order_by_field'])
&& ! empty($_REQUEST['sort_order'])
) {
$sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` '
. 'ORDER BY `'
. $_REQUEST['order_by_field'] . '` ' . $_REQUEST['sort_order'];
}
}
$result = $GLOBALS['dbi']->query($sql_query);
$retval = '<table id="tableprocesslist" '
. 'class="data clearfloat noclick sortable">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th>' . __('Processes') . '</th>';
foreach ($sortable_columns as $column) {
$is_sorted = ! empty($_REQUEST['order_by_field'])
&& ! empty($_REQUEST['sort_order'])
&& ($_REQUEST['order_by_field'] == $column['order_by_field']);
$column['sort_order'] = 'ASC';
if ($is_sorted && $_REQUEST['sort_order'] === 'ASC') {
$column['sort_order'] = 'DESC';
}
if ($is_sorted) {
if ($_REQUEST['sort_order'] == 'ASC') {
$asc_display_style = 'inline';
$desc_display_style = 'none';
} elseif ($_REQUEST['sort_order'] == 'DESC') {
$desc_display_style = 'inline';
$asc_display_style = 'none';
}
}
$retval .= '<th>';
$columnUrl = PMA_generate_common_url($column);
$retval .= '<a href="server_status.php' . $columnUrl . '" ';
if ($is_sorted) {
$retval .= 'onmouseout="$(\'.soimg\').toggle()" '
. 'onmouseover="$(\'.soimg\').toggle()"';
}
$retval .= '>';
$retval .= $column['column_name'];
if ($is_sorted) {
$retval .= '<img class="icon ic_s_desc soimg" alt="'
. __('Descending') . '" title="" src="themes/dot.gif" '
. 'style="display: ' . $desc_display_style . '" />';
$retval .= '<img class="icon ic_s_asc soimg hide" alt="'
. __('Ascending') . '" title="" src="themes/dot.gif" '
. 'style="display: ' . $asc_display_style . '" />';
}
$retval .= '</a>';
if (! PMA_DRIZZLE && (0 === --$sortable_columns_count)) {
$retval .= '<a href="' . $full_text_link . '">';
if ($show_full_sql) {
$retval .= PMA_Util::getImage(
's_partialtext.png',
__('Truncate Shown Queries')
);
} else {
$retval .= PMA_Util::getImage(
's_fulltext.png',
__('Show Full Queries')
);
}
$retval .= '</a>';
}
$retval .= '</th>';
}
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$odd_row = true;
while ($process = $GLOBALS['dbi']->fetchAssoc($result)) {
$retval .= PMA_getHtmlForServerProcessItem(
$process,
$odd_row,
$show_full_sql
);
$odd_row = ! $odd_row;
}
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
/**
* Prints Every Item of Server Process
*
* @param Array $process data of Every Item of Server Process
* @param bool $odd_row display odd row or not
* @param bool $show_full_sql show full sql or not
*
* @return string
*/
function PMA_getHtmlForServerProcessItem($process, $odd_row, $show_full_sql)
{
// Array keys need to modify due to the way it has used
// to display column values
if (! empty($_REQUEST['order_by_field']) && ! empty($_REQUEST['sort_order']) ) {
foreach (array_keys($process) as $key) {
$new_key = ucfirst(strtolower($key));
$process[$new_key] = $process[$key];
unset($process[$key]);
}
}
$url_params['kill'] = $process['Id'];
$kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
$retval = '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
$retval .= '<td><a href="' . $kill_process . '">' . __('Kill') . '</a></td>';
$retval .= '<td class="value">' . $process['Id'] . '</td>';
$retval .= '<td>' . $process['User'] . '</td>';
$retval .= '<td>' . $process['Host'] . '</td>';
$retval .= '<td>' . ((! isset($process['db']) || ! strlen($process['db']))
? '<i>' . __('None') . '</i>'
: $process['db']) . '</td>';
$retval .= '<td>' . $process['Command'] . '</td>';
$retval .= '<td class="value">' . $process['Time'] . '</td>';
$processStatusStr = empty($process['State']) ? '---' : $process['State'];
$retval .= '<td>' . $processStatusStr . '</td>';
$retval .= '<td>';
if (empty($process['Info'])) {
$retval .= '---';
} else {
$cfg_maxDisplaySQL = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'];
if (! $show_full_sql && strlen($process['Info']) > $cfg_maxDisplaySQL) {
$info = substr($process['Info'], 0, $cfg_maxDisplaySQL);
$retval .= htmlspecialchars($info) . '[...]';
} else {
$retval .= '<code class="sql"><pre>'
. $process['Info']
. '</pre></code>';
}
}
$retval .= '</td>';
$retval .= '</tr>';
return $retval;
}
?>

View File

@ -0,0 +1,70 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* functions for displaying server status sub item: advisor
*
* @usedby server_status_advisor.php
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Returns html with Advisor
*
* @return string
*/
function PMA_getHtmlForAdvisor()
{
$output = '<a href="#openAdvisorInstructions">';
$output .= PMA_Util::getIcon('b_help.png', __('Instructions'));
$output .= '</a>';
$output .= '<div id="statustabs_advisor"></div>';
$output .= '<div id="advisorInstructionsDialog" style="display:none;">';
$output .= '<p>';
$output .= __(
'The Advisor system can provide recommendations '
. 'on server variables by analyzing the server status variables.'
);
$output .= '</p>';
$output .= '<p>';
$output .= __(
'Do note however that this system provides recommendations '
. 'based on simple calculations and by rule of thumb which may '
. 'not necessarily apply to your system.'
);
$output .= '</p>';
$output .= '<p>';
$output .= __(
'Prior to changing any of the configuration, be sure to know '
. 'what you are changing (by reading the documentation) and how '
. 'to undo the change. Wrong tuning can have a very negative '
. 'effect on performance.'
);
$output .= '</p>';
$output .= '<p>';
$output .= __(
'The best way to tune your system would be to change only one '
. 'setting at a time, observe or benchmark your database, and undo '
. 'the change if there was no clearly measurable improvement.'
);
$output .= '</p>';
$output .= '</div>';
$output .= '<div id="advisorData" style="display:none;">';
$advisor = new Advisor();
$output .= htmlspecialchars(
json_encode(
$advisor->run()
)
);
$output .= '</div>';
return $output;
}
?>

View File

@ -69,7 +69,6 @@ function PMA_getTableNameBySQL($sql, $tables)
* @param array $sql_data information about SQL statement
* @param string $goto URL to go back in case of errors
* @param string $pmaThemeImage path for theme images directory
* @param string $text_dir text direction
* @param string $printview whether printview is enabled
* @param string $url_query URL query
* @param array $disp_mode the display mode
@ -80,7 +79,7 @@ function PMA_getTableNameBySQL($sql, $tables)
*/
function PMA_getTableHtmlForMultipleQueries(
$displayResultsObject, $db, $sql_data, $goto, $pmaThemeImage,
$text_dir, $printview, $url_query, $disp_mode, $sql_limit_to_append,
$printview, $url_query, $disp_mode, $sql_limit_to_append,
$editable
) {
$table_html = '';
@ -187,8 +186,8 @@ function PMA_getTableHtmlForMultipleQueries(
$displayResultsObject->setProperties(
$unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func,
$is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage,
$text_dir, $is_maint, $is_explain, $is_show, $showtable,
$printview, $url_query, $editable
$GLOBALS['text_dir'], $is_maint, $is_explain, $is_show,
$showtable, $printview, $url_query, $editable
);
}
@ -1808,7 +1807,6 @@ function PMA_getBookmarkCreatedMessage()
* @param string $db current database
* @param string $goto goto page url
* @param string $pmaThemeImage theme image uri
* @param string $text_dir text directory
* @param string $url_query url query
* @param string $disp_mode display mode
* @param string $sql_limit_to_append sql limit to append
@ -1819,21 +1817,22 @@ function PMA_getBookmarkCreatedMessage()
* @param object $result result of the executed query
* @param int $querytime query execution time
* @param array $analyzed_sql_results analyzed sql results
* @param bool $is_procedure whether it is a procedure call or not
*
* @return type
*/
function PMA_getHtmlForSqlQueryResultsTable($sql_data, $displayResultsObject, $db,
$goto, $pmaThemeImage, $text_dir, $url_query, $disp_mode, $sql_limit_to_append,
$goto, $pmaThemeImage, $url_query, $disp_mode, $sql_limit_to_append,
$editable, $unlim_num_rows, $num_rows, $showtable, $result, $querytime,
$analyzed_sql_results, $is_procedure
$analyzed_sql_results
) {
$printview = isset($_REQUEST['printview']) ? $_REQUEST['printview'] : null;
if (! empty($sql_data) && ($sql_data['valid_queries'] > 1) || $is_procedure) {
if (! empty($sql_data) && ($sql_data['valid_queries'] > 1)
|| $analyzed_sql_results['is_procedure']
) {
$_SESSION['is_multi_query'] = true;
$table_html = PMA_getTableHtmlForMultipleQueries(
$displayResultsObject, $db, $sql_data, $goto,
$pmaThemeImage, $text_dir, $printview, $url_query,
$pmaThemeImage, $printview, $url_query,
$disp_mode, $sql_limit_to_append, $editable
);
} else {
@ -1846,7 +1845,7 @@ function PMA_getHtmlForSqlQueryResultsTable($sql_data, $displayResultsObject, $d
$unlim_num_rows, $fields_meta, $analyzed_sql_results['is_count'],
$analyzed_sql_results['is_export'], $analyzed_sql_results['is_func'],
$analyzed_sql_results['is_analyse'], $num_rows,
$fields_cnt, $querytime, $pmaThemeImage, $text_dir,
$fields_cnt, $querytime, $pmaThemeImage, $GLOBALS['text_dir'],
$analyzed_sql_results['is_maint'], $analyzed_sql_results['is_explain'],
$analyzed_sql_results['is_show'], $showtable, $printview, $url_query,
$editable
@ -1964,4 +1963,174 @@ function PMA_getHtmlForPrintButton()
return $print_button_html;
}
/**
* Function to display results when the executed query returns non empty results
*
* @param array $result executed query results
* @param bool $justBrowsing whether just browsing or not
* @param array $analyzed_sql_results analysed sql results
* @param string $db current database
* @param string $table current table
* @param string $disp_mode display mode
* @param string $message message to show
* @param array $sql_data sql data
* @param object $displayResultsObject Instance of DisplyResults.class
* @param string $goto goto page url
* @param string $pmaThemeImage uri of the theme image
* @param string $sql_limit_to_append sql limit to append
* @param int $unlim_num_rows unlimited number of rows
* @param int $num_rows number of rows
* @param int $querytime query time
* @param string $full_sql_query full sql query
* @param string $disp_query display query
* @param string $disp_message display message
* @param array $profiling_results profiling results
* @param string $query_type query type
* @param bool $selected selected
* @param string $sql_query sql query
* @param string $complete_query complete sql query
* @param array $cfg configuration
*
* @return void
*/
function PMA_sendResponseForResultsReturned($result, $justBrowsing,
$analyzed_sql_results, $db, $table, $disp_mode, $message, $sql_data,
$displayResultsObject, $goto, $pmaThemeImage, $sql_limit_to_append,
$unlim_num_rows, $num_rows, $querytime, $full_sql_query, $disp_query,
$disp_message, $profiling_results, $query_type, $selected, $sql_query,
$complete_query, $cfg
) {
// If we are retrieving the full value of a truncated field or the original
// value of a transformed field, show it here
if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) {
PMA_sendResponseForGridEdit($result);
}
// Gets the list of fields properties
if (isset($result) && $result) {
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
}
// Should be initialized these parameters before parsing
$showtable = isset($showtable) ? $showtable : null;
$url_query = isset($url_query) ? $url_query : null;
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
// hide edit and delete links:
// - for information_schema
// - if the result set does not contain all the columns of a unique key
// and we are not just browing all the columns of an updatable view
$updatableView
= $justBrowsing
&& trim($analyzed_sql_results['analyzed_sql'][0]['select_expr_clause']) == '*'
&& PMA_Table::isUpdatableView($db, $table);
$has_unique = PMA_resultSetContainsUniqueKey(
$db, $table, $fields_meta
);
$editable = $has_unique || $updatableView;
// Displays the results in a table
if (empty($disp_mode)) {
// see the "PMA_setDisplayMode()" function in
// libraries/DisplayResults.class.php
$disp_mode = 'urdr111101';
}
if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) {
$disp_mode = 'nnnn110111';
}
if ( isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
$disp_mode = 'nnnn000000';
}
if (isset($_REQUEST['table_maintenance'])) {
$scripts->addFile('makegrid.js');
$scripts->addFile('sql.js');
if (isset($message)) {
$message = PMA_Message::success($message);
$table_maintenance_html = PMA_Util::getMessage(
$message, $GLOBALS['sql_query'], 'success'
);
}
$table_maintenance_html .= PMA_getHtmlForSqlQueryResultsTable(
isset($sql_data) ? $sql_data : null, $displayResultsObject, $db, $goto,
$pmaThemeImage, $url_query, $disp_mode, $sql_limit_to_append,
false, $unlim_num_rows, $num_rows, $showtable, $result, $querytime,
$analyzed_sql_results, false
);
if (empty($sql_data) || ($sql_data['valid_queries'] = 1)) {
$response->addHTML($table_maintenance_html);
exit();
}
}
if (!isset($_REQUEST['printview']) || $_REQUEST['printview'] != '1') {
$scripts->addFile('makegrid.js');
$scripts->addFile('sql.js');
unset($message);
//we don't need to buffer the output in getMessage here.
//set a global variable and check against it in the function
$GLOBALS['buffer_message'] = false;
}
$print_view_header_html = PMA_getHtmlForPrintViewHeader(
$db, $full_sql_query, $num_rows
);
$previous_update_query_html = PMA_getHtmlForPreviousUpdateQuery(
isset($disp_query) ? $disp_query : null,
$cfg['ShowSQL'], isset($sql_data) ? $sql_data : null,
isset($disp_message) ? $disp_message : null
);
$profiling_chart_html = PMA_getHtmlForProfilingChart(
$disp_mode, $db, isset($profiling_results) ? $profiling_results : null
);
$missing_unique_column_msg = PMA_getMessageIfMissingColumnIndex(
$table, $db, $editable, $disp_mode
);
$bookmark_created_msg = PMA_getBookmarkCreatedMessage();
$table_html = PMA_getHtmlForSqlQueryResultsTable(
isset($sql_data) ? $sql_data : null, $displayResultsObject, $db, $goto,
$pmaThemeImage, $url_query, $disp_mode, $sql_limit_to_append,
$editable, $unlim_num_rows, $num_rows, $showtable, $result, $querytime,
$analyzed_sql_results
);
$indexes_problems_html = PMA_getHtmlForIndexesProblems(
isset($query_type) ? $query_type : null,
isset($selected) ? $selected : null
);
$bookmark_support_html = PMA_getHtmlForBookmark(
$disp_mode, isset($cfg['Bookmark']) ? $cfg['Bookmark'] : '', $sql_query,
$db, $table, isset($complete_query) ? $complete_query : $sql_query,
$cfg['Bookmark']['user']
);
$print_button_html = PMA_getHtmlForPrintButton();
$html_output = isset($table_maintenance_html) ? $table_maintenance_html : '';
$html_output .= isset($print_view_header_html) ? $print_view_header_html : '';
$html_output .= PMA_getHtmlForSqlQueryResults(
$previous_update_query_html, $profiling_chart_html,
$missing_unique_column_msg, $bookmark_created_msg,
$table_html, $indexes_problems_html, $bookmark_support_html,
$print_button_html
);
$response->addHTML($html_output);
exit();
}
?>

View File

@ -1667,7 +1667,7 @@ function PMA_SQP_analyze($arr)
$in_limit = false;
$after_limit = true;
// for the presnece of PROCEDURE ANALYSE
// for the presence of PROCEDURE ANALYSE
if (isset($subresult['queryflags']['select_from'])
&& $subresult['queryflags']['select_from'] == 1
&& ($i + 1) < $size
@ -1678,7 +1678,7 @@ function PMA_SQP_analyze($arr)
}
}
// for the presnece of INTO OUTFILE
// for the presence of INTO OUTFILE
if ($upper_data == 'INTO'
&& isset($subresult['queryflags']['select_from'])
&& $subresult['queryflags']['select_from'] == 1

View File

@ -271,10 +271,19 @@ class PMA_SysInfoLinux extends PMA_SysInfo
);
$mem = array_combine($matches[1], $matches[2]);
$memTotal = isset($mem['MemTotal']) ? $mem['MemTotal'] : 0;
$memFree = isset($mem['MemFree']) ? $mem['MemFree'] : 0;
$cached = isset($mem['Cached']) ? $mem['Cached'] : 0;
$buffers = isset($mem['Buffers']) ? $mem['Buffers'] : 0;
$swapTotal = isset($mem['SwapTotal']) ? $mem['SwapTotal'] : 0;
$swapFree = isset($mem['SwapFree']) ? $mem['SwapFree'] : 0;
$swapCached = isset($mem['SwapCached']) ? $mem['SwapCached'] : 0;
$mem['MemUsed']
= $mem['MemTotal'] - $mem['MemFree'] - $mem['Cached'] - $mem['Buffers'];
= $memTotal - $memFree - $cached - $buffers;
$mem['SwapUsed']
= $mem['SwapTotal'] - $mem['SwapFree'] - $mem['SwapCached'];
= $swapTotal - $swapFree - $swapCached;
foreach ($mem as $idx => $value) {
$mem[$idx] = intval($value);

View File

@ -4,10 +4,9 @@ msgstr ""
"Project-Id-Version: phpMyAdmin 4.1-dev\n"
"Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n"
"POT-Creation-Date: 2013-07-12 16:06+0200\n"
"PO-Revision-Date: 2013-06-03 10:24+0200\n"
"Last-Translator: Michal Čihař <michal@cihar.com>\n"
"Language-Team: Hebrew <http://l10n.cihar.com/projects/phpmyadmin/master/he/"
">\n"
"PO-Revision-Date: 2013-07-15 21:08+0200\n"
"Last-Translator: Bug Me Not <abcdefg@mailinator.com>\n"
"Language-Team: Hebrew <http://l10n.cihar.com/projects/phpmyadmin/master/he/>\n"
"Language: he\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -829,13 +828,14 @@ msgid ""
"Login cookie store is lower than cookie validity configured in phpMyAdmin, "
"because of this, your login will expire sooner than configured in phpMyAdmin."
msgstr ""
"חנות עוגיית כניסה נמוכה מתוקף עוגייה המוגדר בphpMyAdmin, בגלל זה, הכניסה שלך "
"תפוג מוקדם יותר מאשר מוגדרת בphpMyAdmin."
#: index.php:468
msgid "The configuration file now needs a secret passphrase (blowfish_secret)."
msgstr "קובץ התצורה צריכה ביטוי סיסמה סודית (blowfish_secret)."
#: index.php:479
#, fuzzy
#| msgid ""
#| "Directory [code]config[/code], which is used by the setup script, still "
#| "exists in your phpMyAdmin directory. You should remove it once phpMyAdmin "

View File

@ -16,6 +16,8 @@ require_once 'libraries/common.inc.php';
require_once 'libraries/display_change_password.lib.php';
require_once 'libraries/server_privileges.lib.php';
$cfgRelation = PMA_getRelationsParam();
/**
* Does the common work
*/
@ -24,6 +26,11 @@ $header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('server_privileges.js');
if ($GLOBALS['cfgRelation']['menuswork']) {
$response->addHTML('<div>');
$response->addHTML(PMA_getHtmlForSubMenusOnUsersPage('server_privileges.php'));
}
$_add_user_error = false;
if (isset ($_REQUEST['username'])) {
@ -228,6 +235,9 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
$_error, $real_sql_query, $sql_query, $username, $hostname,
isset($dbname) ? $dbname : null
);
if (! empty($_REQUEST['userGroup']) && $cfgRelation['menuswork']) {
PMA_setUserGroup($GLOBALS['username'], $_REQUEST['userGroup']);
}
} else {
if (isset($create_user_real)) {
@ -268,6 +278,14 @@ if (! empty($_POST['update_privs'])) {
);
}
/**
* Assign users to user groups
*/
if (! empty($_REQUEST['changeUserGroup']) && $cfgRelation['menuswork']) {
PMA_setUserGroup($username, $_REQUEST['userGroup']);
$message = PMA_Message::success();
}
/**
* Revokes Privileges
*/
@ -378,6 +396,7 @@ if ($GLOBALS['is_ajax_request']
&& (! isset($_REQUEST['initial']) || empty($_REQUEST['initial']))
&& ! isset($_REQUEST['showall'])
&& ! isset($_REQUEST['edit_user_dialog'])
&& ! isset($_REQUEST['edit_user_group_dialog'])
&& ! isset($_REQUEST['db_specific'])
) {
$extra_data = PMA_getExtraDataForAjaxBehavior(
@ -424,6 +443,18 @@ if (isset($_REQUEST['viewing_mode']) && $_REQUEST['viewing_mode'] == 'db') {
* Displays the page
*/
if (! empty($_REQUEST['edit_user_group_dialog']) && $cfgRelation['menuswork']) {
$dialog = PMA_getHtmlToChoseUserGroup($username);
$response = PMA_Response::getInstance();
if ($GLOBALS['is_ajax_request']) {
$response->addJSON('message', $dialog);
exit;
} else {
$response->addHTML($dialog);
}
}
// export user definition
if (isset($_REQUEST['export'])
|| (isset($_REQUEST['submit_mult']) && $_REQUEST['submit_mult'] == 'export')
@ -491,4 +522,8 @@ if (empty($_REQUEST['adduser'])
);
} // end if (empty($_REQUEST['adduser']) && empty($checkprivs))... elseif... else...
if ($GLOBALS['cfgRelation']['menuswork']) {
$response->addHTML('</div>');
}
?>

View File

@ -9,6 +9,7 @@
require_once 'libraries/common.inc.php';
require_once 'libraries/server_common.inc.php';
require_once 'libraries/ServerStatusData.class.php';
require_once 'libraries/server_status.lib.php';
/**
* Replication library
@ -46,513 +47,9 @@ if (! empty($_REQUEST['kill'])) {
$response = PMA_Response::getInstance();
$response->addHTML('<div>');
$response->addHTML($ServerStatusData->getMenuHtml());
$response->addHTML(PMA_getServerStatusHtml($ServerStatusData));
$response->addHTML(PMA_getHtmlForServerStatus($ServerStatusData));
$response->addHTML('</div>');
exit;
/**
* Prints server status information: processes, connections and traffic
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function PMA_getServerStatusHtml($ServerStatusData)
{
//display the server state General Information
$retval = PMA_getServerStateGeneralInfoHtml($ServerStatusData);
//display the server state traffic information
$retval .= PMA_getServerStateTrafficHtml($ServerStatusData);
//display the server state connection information
$retval .= PMA_getServerStateConnectionsHtml($ServerStatusData);
//display the server Process List information
$retval .= PMA_getServerProcesslistHtml($ServerStatusData);
return $retval;
}
/**
* Prints server state General information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function PMA_getServerStateGeneralInfoHtml($ServerStatusData)
{
$start_time = $GLOBALS['dbi']->fetchValue(
'SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime']
);
$retval = '<h3>';
$retval .= sprintf(
__('Network traffic since startup: %s'),
implode(
' ',
PMA_Util::formatByteDown(
$ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'],
3,
1
)
)
);
$retval .= '</h3>';
$retval .= '<p>';
$retval .= sprintf(
__('This MySQL server has been running for %1$s. It started up on %2$s.'),
PMA_Util::timespanFormat($ServerStatusData->status['Uptime']),
PMA_Util::localisedDate($start_time)
) . "\n";
$retval .= '</p>';
if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
$retval .= '<p class="notice">';
if ($GLOBALS['server_master_status'] && $GLOBALS['server_slave_status']) {
$retval .= __(
'This MySQL server works as <b>master</b> and '
. '<b>slave</b> in <b>replication</b> process.'
);
} elseif ($GLOBALS['server_master_status']) {
$retval .= __(
'This MySQL server works as <b>master</b> '
. 'in <b>replication</b> process.'
);
} elseif ($GLOBALS['server_slave_status']) {
$retval .= __(
'This MySQL server works as <b>slave</b> '
. 'in <b>replication</b> process.'
);
}
$retval .= '</p>';
}
/*
* if the server works as master or slave in replication process,
* display useful information
*/
if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
$retval .= '<hr class="clearfloat" />';
$retval .= '<h3><a name="replication">';
$retval .= __('Replication status');
$retval .= '</a></h3>';
foreach ($GLOBALS['replication_types'] as $type) {
if (isset(${"server_{$type}_status"}) && ${"server_{$type}_status"}) {
$retval .= PMA_getHtmlForReplicationStatusTable($type);
}
}
}
return $retval;
}
/**
* Prints server state traffic information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function PMA_getServerStateTrafficHtml($ServerStatusData)
{
$hour_factor = 3600 / $ServerStatusData->status['Uptime'];
$retval = '<table id="serverstatustraffic" class="data noclick">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th colspan="2">';
$retval .= __('Traffic') . '&nbsp;';
$retval .= PMA_Util::showHint(
__(
'On a busy server, the byte counters may overrun, so those statistics '
. 'as reported by the MySQL server may be incorrect.'
)
);
$retval .= '</th>';
$retval .= '<th>&oslash; ' . __('per hour') . '</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('Received') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(
' ',
PMA_Util::formatByteDown(
$ServerStatusData->status['Bytes_received'], 3, 1
)
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= implode(
' ',
PMA_Util::formatByteDown(
$ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1
)
);
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="even">';
$retval .= '<th class="name">' . __('Sent') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(
' ',
PMA_Util::formatByteDown(
$ServerStatusData->status['Bytes_sent'], 3, 1
)
);
$retval .= '</td>';
$retval .= '<td class="value"><?php echo';
$retval .= implode(
' ',
PMA_Util::formatByteDown(
$ServerStatusData->status['Bytes_sent'] * $hour_factor, 3, 1
)
);
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('Total') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(
' ',
PMA_Util::formatByteDown(
$ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'], 3, 1
)
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= implode(
' ',
PMA_Util::formatByteDown(
($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'])
* $hour_factor, 3, 1
)
);
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
/**
* Prints server state connections information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function PMA_getServerStateConnectionsHtml($ServerStatusData)
{
$hour_factor = 3600 / $ServerStatusData->status['Uptime'];
$retval = '<table id="serverstatusconnections" class="data noclick">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th colspan="2">' . __('Connections') . '</th>';
$retval .= '<th>&oslash; ' . __('per hour') . '</th>';
$retval .= '<th>%</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('max. concurrent connections') . '</th>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Max_used_connections'], 0
);
$retval .= '</td>';
$retval .= '<td class="value">--- </td>';
$retval .= '<td class="value">--- </td>';
$retval .= '</tr>';
$retval .= '<tr class="even">';
$retval .= '<th class="name">' . __('Failed attempts') . '</th>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Aborted_connects'], 4, 1, true
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Aborted_connects'] * $hour_factor, 4, 2, true
);
$retval .= '</td>';
$retval .= '<td class="value">';
if ($ServerStatusData->status['Connections'] > 0) {
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Aborted_connects'] * 100 / $ServerStatusData->status['Connections'],
0, 2, true
);
$retval .= '%';
} else {
$retval .= '--- ';
}
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('Aborted') . '</th>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Aborted_clients'], 4, 1, true
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Aborted_clients'] * $hour_factor, 4, 2, true
);
$retval .= '</td>';
$retval .= '<td class="value">';
if ($ServerStatusData->status['Connections'] > 0) {
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Aborted_clients'] * 100 / $ServerStatusData->status['Connections'],
0, 2, true
);
$retval .= '%';
} else {
$retval .= '--- ';
}
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="even">';
$retval .= '<th class="name">' . __('Total') . '</th>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Connections'], 4, 0
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(
$ServerStatusData->status['Connections'] * $hour_factor, 4, 2
);
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber(100, 0, 2);
$retval .= '%</td>';
$retval .= '</tr>';
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
/**
* Prints Server Process list
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function PMA_getServerProcesslistHtml($ServerStatusData)
{
$url_params = array();
$show_full_sql = ! empty($_REQUEST['full']);
if ($show_full_sql) {
$url_params['full'] = 1;
$full_text_link = 'server_status.php' . PMA_generate_common_url(
array(), 'html', '?'
);
} else {
$full_text_link = 'server_status.php' . PMA_generate_common_url(
array('full' => 1)
);
}
// This array contains display name and real column name of each
// sortable column in the table
$sortable_columns = array(
array(
'column_name' => __('ID'),
'order_by_field' => 'Id'
),
array(
'column_name' => __('User'),
'order_by_field' => 'User'
),
array(
'column_name' => __('Host'),
'order_by_field' => 'Host'
),
array(
'column_name' => __('Database'),
'order_by_field' => 'db'
),
array(
'column_name' => __('Command'),
'order_by_field' => 'Command'
),
array(
'column_name' => __('Time'),
'order_by_field' => 'Time'
),
array(
'column_name' => __('Status'),
'order_by_field' => 'State'
),
array(
'column_name' => __('SQL query'),
'order_by_field' => 'Info'
)
);
$sortable_columns_count = count($sortable_columns);
if (PMA_DRIZZLE) {
$left_str = 'left(p.info, '
. (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')';
$sql_query = "SELECT
p.id AS Id,
p.username AS User,
p.host AS Host,
p.db AS db,
p.command AS Command,
p.time AS Time,
p.state AS State,"
. ($show_full_sql ? 's.query' : $left_str )
. " AS Info FROM data_dictionary.PROCESSLIST p "
. ($show_full_sql
? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id'
: '');
if (! empty($_REQUEST['order_by_field'])
&& ! empty($_REQUEST['sort_order'])
) {
$sql_query .= ' ORDER BY p.' . $_REQUEST['order_by_field'] . ' '
. $_REQUEST['sort_order'];
}
} else {
$sql_query = $show_full_sql
? 'SHOW FULL PROCESSLIST'
: 'SHOW PROCESSLIST';
if (! empty($_REQUEST['order_by_field'])
&& ! empty($_REQUEST['sort_order'])
) {
$sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `'
. $_REQUEST['order_by_field'] . '` ' . $_REQUEST['sort_order'];
}
}
$result = $GLOBALS['dbi']->query($sql_query);
$retval = '<table id="tableprocesslist" class="data clearfloat noclick sortable">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th>' . __('Processes') . '</th>';
foreach ($sortable_columns as $column) {
$is_sorted = ! empty($_REQUEST['order_by_field'])
&& ! empty($_REQUEST['sort_order'])
&& ($_REQUEST['order_by_field'] == $column['order_by_field']);
$column['sort_order'] = 'ASC';
if ($is_sorted && $_REQUEST['sort_order'] === 'ASC') {
$column['sort_order'] = 'DESC';
}
if ($is_sorted) {
if ($_REQUEST['sort_order'] == 'ASC') {
$asc_display_style = 'inline';
$desc_display_style = 'none';
} elseif ($_REQUEST['sort_order'] == 'DESC') {
$desc_display_style = 'inline';
$asc_display_style = 'none';
}
}
$retval .= '<th>';
$retval .= '<a href="server_status.php' . PMA_generate_common_url($column) . '" ';
if ($is_sorted) {
$retval .= 'onmouseout="$(\'.soimg\').toggle()" '
. 'onmouseover="$(\'.soimg\').toggle()"';
}
$retval .= '>';
$retval .= $column['column_name'];
if ($is_sorted) {
$retval .= '<img class="icon ic_s_desc soimg" alt="'
. __('Descending') . '" title="" src="themes/dot.gif" '
. 'style="display: ' . $desc_display_style . '" />';
$retval .= '<img class="icon ic_s_asc soimg hide" alt="'
. __('Ascending') . '" title="" src="themes/dot.gif" '
. 'style="display: ' . $asc_display_style . '" />';
}
$retval .= '</a>';
if (! PMA_DRIZZLE && (0 === --$sortable_columns_count)) {
$retval .= '<a href="' . $full_text_link . '">';
if ($show_full_sql) {
$retval .= PMA_Util::getImage(
's_partialtext.png',
__('Truncate Shown Queries')
);
} else {
$retval .= PMA_Util::getImage(
's_fulltext.png',
__('Show Full Queries')
);
}
$retval .= '</a>';
}
$retval .= '</th>';
}
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$odd_row = true;
while ($process = $GLOBALS['dbi']->fetchAssoc($result)) {
// Array keys need to modify due to the way it has used
// to display column values
if (! empty($_REQUEST['order_by_field'])
&& ! empty($_REQUEST['sort_order'])
) {
foreach (array_keys($process) as $key) {
$new_key = ucfirst(strtolower($key));
$process[$new_key] = $process[$key];
unset($process[$key]);
}
}
$url_params['kill'] = $process['Id'];
$kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
$retval .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
$retval .= '<td><a href="' . $kill_process . '">' . __('Kill') . '</a></td>';
$retval .= '<td class="value">' . $process['Id'] . '</td>';
$retval .= '<td>' . $process['User'] . '</td>';
$retval .= '<td>' . $process['Host'] . '</td>';
$retval .= '<td>' . ((! isset($process['db']) || ! strlen($process['db']))
? '<i>' . __('None') . '</i>'
: $process['db']) . '</td>';
$retval .= '<td>' . $process['Command'] . '</td>';
$retval .= '<td class="value">' . $process['Time'] . '</td>';
$retval .= '<td>' . (empty($process['State']) ? '---' : $process['State']) . '</td>';
$retval .= '<td>';
if (empty($process['Info'])) {
$retval .= '---';
} else {
if (! $show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
$retval .= htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']))
. '[...]';
} else {
$retval .= '<code class="sql"><pre>'
. $process['Info']
. '</pre></code>';
}
}
$retval .= '</td>';
$retval .= '</tr>';
$odd_row = ! $odd_row;
}
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
?>

View File

@ -9,6 +9,8 @@
require_once 'libraries/common.inc.php';
require_once 'libraries/Advisor.class.php';
require_once 'libraries/ServerStatusData.class.php';
require_once 'libraries/server_status_advisor.lib.php';
if (PMA_DRIZZLE) {
$server_master_status = false;
$server_slave_status = false;
@ -28,62 +30,10 @@ $scripts->addFile('server_status_advisor.js');
*/
$response->addHTML('<div>');
$response->addHTML($ServerStatusData->getMenuHtml());
$response->addHTML(PMA_getAdvisorHtml());
$response->addHTML(PMA_getHtmlForAdvisor());
$response->addHTML('</div>');
exit;
/**
* Returns html with Advisor
*
* @return string
*/
function PMA_getAdvisorHtml()
{
$output = '<a href="#openAdvisorInstructions">';
$output .= PMA_Util::getIcon('b_help.png', __('Instructions'));
$output .= '</a>';
$output .= '<div id="statustabs_advisor"></div>';
$output .= '<div id="advisorInstructionsDialog" style="display:none;">';
$output .= '<p>';
$output .= __(
'The Advisor system can provide recommendations '
. 'on server variables by analyzing the server status variables.'
);
$output .= '</p>';
$output .= '<p>';
$output .= __(
'Do note however that this system provides recommendations '
. 'based on simple calculations and by rule of thumb which may '
. 'not necessarily apply to your system.'
);
$output .= '</p>';
$output .= '<p>';
$output .= __(
'Prior to changing any of the configuration, be sure to know '
. 'what you are changing (by reading the documentation) and how '
. 'to undo the change. Wrong tuning can have a very negative '
. 'effect on performance.'
);
$output .= '</p>';
$output .= '<p>';
$output .= __(
'The best way to tune your system would be to change only one '
. 'setting at a time, observe or benchmark your database, and undo '
. 'the change if there was no clearly measurable improvement.'
);
$output .= '</p>';
$output .= '</div>';
$output .= '<div id="advisorData" style="display:none;">';
$advisor = new Advisor();
$output .= htmlspecialchars(
json_encode(
$advisor->run()
)
);
$output .= '</div>';
return $output;
}
?>

59
server_user_groups.php Normal file
View File

@ -0,0 +1,59 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Displays the 'User groups' sub page under 'Users' page.
*
* @package PhpMyAdmin
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/server_privileges.lib.php';
PMA_getRelationsParam();
if (! $GLOBALS['cfgRelation']['menuswork']) {
exit;
}
$response = PMA_Response::getInstance();
$response->addHTML('<div>');
$response->addHTML(PMA_getHtmlForSubMenusOnUsersPage('server_user_groups.php'));
/**
* Delete user group
*/
if (! empty($_REQUEST['deleteUserGroup'])) {
PMA_deleteUserGroup($_REQUEST['userGroup']);
}
/**
* Add a new user group
*/
if (! empty($_REQUEST['addUserGroupSubmit'])) {
PMA_editUserGroup($_REQUEST['userGroup'], true);
}
/**
* Update a user group
*/
if (! empty($_REQUEST['editUserGroupSubmit'])) {
PMA_editUserGroup($_REQUEST['userGroup']);
}
if (isset($_REQUEST['viewUsers'])) {
// Display users belonging to a user group
$response->addHTML(PMA_getHtmlForListingUsersofAGroup($_REQUEST['userGroup']));
}
if (isset($_REQUEST['addUserGroup'])) {
// Display add user group dialog
$response->addHTML(PMA_getHtmlToEditUserGroup());
} elseif (isset($_REQUEST['editUserGroup'])) {
// Display edit user group dialog
$response->addHTML(PMA_getHtmlToEditUserGroup($_REQUEST['userGroup']));
} else {
// Display user groups table
$response->addHTML(PMA_getHtmlForUserGroupsTable());
}
$response->addHTML('</div>');
?>

138
sql.php
View File

@ -219,135 +219,19 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
);
} else {
// At least one row is returned -> displays a table with results
// If we are retrieving the full value of a truncated field or the original
// value of a transformed field, show it here and exit
if ($_REQUEST['grid_edit'] == true) {
PMA_sendResponseForGridEdit($result);
}
// Gets the list of fields properties
if (isset($result) && $result) {
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
}
// Should be initialized these parameters before parsing
$showtable = isset($showtable) ? $showtable : null;
$url_query = isset($url_query) ? $url_query : null;
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
// hide edit and delete links:
// - for information_schema
// - if the result set does not contain all the columns of a unique key
// and we are not just browing all the columns of an updatable view
$updatableView
= $justBrowsing
&& trim($analyzed_sql[0]['select_expr_clause']) == '*'
&& PMA_Table::isUpdatableView($db, $table);
$has_unique = PMA_resultSetContainsUniqueKey(
$db, $table, $fields_meta
);
$editable = $has_unique || $updatableView;
// Displays the results in a table
if (empty($disp_mode)) {
// see the "PMA_setDisplayMode()" function in
// libraries/DisplayResults.class.php
$disp_mode = 'urdr111101';
}
if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) {
$disp_mode = 'nnnn110111';
}
if ( isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
$disp_mode = 'nnnn000000';
}
if (isset($_REQUEST['table_maintenance'])) {
$scripts->addFile('makegrid.js');
$scripts->addFile('sql.js');
if (isset($message)) {
$message = PMA_Message::success($message);
$table_maintenance_html = PMA_Util::getMessage(
$message, $GLOBALS['sql_query'], 'success'
);
}
$table_maintenance_html .= PMA_getHtmlForSqlQueryResultsTable(
isset($sql_data) ? $sql_data : null, $displayResultsObject, $db, $goto,
$pmaThemeImage, $text_dir, $url_query, $disp_mode, $sql_limit_to_append,
false, $unlim_num_rows, $num_rows, $showtable, $result, $querytime,
$analyzed_sql_results, false
);
if (empty($sql_data) || ($sql_data['valid_queries'] = 1)) {
$response->addHTML($table_maintenance_html);
exit();
}
}
if (!isset($_REQUEST['printview']) || $_REQUEST['printview'] != '1') {
$scripts->addFile('makegrid.js');
$scripts->addFile('sql.js');
unset($message);
//we don't need to buffer the output in getMessage here.
//set a global variable and check against it in the function
$GLOBALS['buffer_message'] = false;
}
$print_view_header_html = PMA_getHtmlForPrintViewHeader(
$db, $full_sql_query, $num_rows
);
$previous_update_query_html = PMA_getHtmlForPreviousUpdateQuery(
// At least one row is returned -> displays a table with results
PMA_sendResponseForResultsReturned(
isset($result) ? $result : null, $justBrowsing, $analyzed_sql_results,
$db, $table, isset($disp_mode) ? $disp_mode : null,
isset($message) ? $message : null, isset($sql_data) ? $sql_data : null,
$displayResultsObject, $goto, $pmaThemeImage,
$sql_limit_to_append, $unlim_num_rows,
$num_rows, $querytime, $full_sql_query,
isset($disp_query) ? $disp_query : null,
$cfg['ShowSQL'], isset($sql_data) ? $sql_data : null,
isset($disp_message) ? $disp_message : null
);
$profiling_chart_html = PMA_getHtmlForProfilingChart(
$disp_mode, $db, isset($profiling_results) ? $profiling_results : null
);
$missing_unique_column_msg = PMA_getMessageIfMissingColumnIndex(
$table, $db, $editable, $disp_mode
);
$bookmark_created_msg = PMA_getBookmarkCreatedMessage();
$table_html = PMA_getHtmlForSqlQueryResultsTable(
isset($sql_data) ? $sql_data : null, $displayResultsObject, $db, $goto,
$pmaThemeImage, $text_dir, $url_query, $disp_mode, $sql_limit_to_append,
$editable, $unlim_num_rows, $num_rows, $showtable, $result, $querytime,
$analyzed_sql_results, $is_procedure
);
$indexes_problems_html = PMA_getHtmlForIndexesProblems(
isset($disp_message) ? $disp_message : null, $profiling_results,
isset($query_type) ? $query_type : null,
isset($selected) ? $selected : null
isset($selected) ? $selected : null, $sql_query,
isset($complete_query) ? $complete_query : null, $cfg
);
$bookmark_support_html = PMA_getHtmlForBookmark(
$disp_mode, isset($cfg['Bookmark']) ? $cfg['Bookmark'] : '', $sql_query,
$db, $table, isset($complete_query) ? $complete_query : $sql_query,
$cfg['Bookmark']['user']
);
$print_button_html = PMA_getHtmlForPrintButton();
$html_output = isset($table_maintenance_html) ? $table_maintenance_html : '';
$html_output .= isset($print_view_header_html) ? $print_view_header_html : '';
$html_output .= PMA_getHtmlForSqlQueryResults(
$previous_update_query_html, $profiling_chart_html,
$missing_unique_column_msg, $bookmark_created_msg,
$table_html, $indexes_problems_html, $bookmark_support_html,
$print_button_html
);
$response->addHTML($html_output);
} // end rows returned
?>

View File

@ -0,0 +1,107 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for PMA_TableSearch
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
require_once 'libraries/TableSearch.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/sqlparser.lib.php';
/**
* Tests for PMA_TableSearch
*
* @package PhpMyAdmin-test
*/
class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase
{
/**
* Setup function for test cases
*
* @access protected
* @return void
*/
protected function setUp()
{
/**
* SET these to avoid undefined index error
*/
$GLOBALS['server'] = 1;
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$columns =array(
array(
'Field' => 'Field1',
'Type' => 'Type1',
'Null' => 'Null1',
'Collation' => 'Collation1',
),
array(
'Field' => 'Field2',
'Type' => 'Type2',
'Null' => 'Null2',
'Collation' => 'Collation2',
)
);
$dbi->expects($this->any())->method('getColumns')
->will($this->returnValue($columns));
$show_create_table = "CREATE TABLE `pma_bookmark` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`dbase` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
`user` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
`label` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '',
`query` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`),
KEY `foreign_field` (`foreign_db`,`foreign_table`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Bookmarks'";
$dbi->expects($this->any())->method('fetchValue')
->will($this->returnValue($show_create_table));
$GLOBALS['dbi'] = $dbi;
}
/**
* tearDown function for test cases
*
* @access protected
* @return void
*/
protected function tearDown()
{
}
/**
* Test for __construct
*
* @return void
*/
public function testConstruct()
{
$tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "normal");
$columNames = $tableSearch->getColumnNames();
$this->assertEquals(
'Field1',
$columNames[0]
);
$this->assertEquals(
'Field2',
$columNames[1]
);
}
}
?>

View File

@ -1,4 +1,5 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for Table.class.php
*
@ -8,7 +9,6 @@
/*
* Include to test.
*/
require_once 'libraries/Table.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/database_interface.inc.php';
@ -18,7 +18,6 @@ require_once 'libraries/Theme.class.php';
require_once 'libraries/Tracker.class.php';
require_once 'libraries/relation.lib.php';
/**
* Tests behaviour of PMA_Table class
*
@ -33,6 +32,9 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
/**
* SET these to avoid undefined index error
*/
$GLOBALS['server'] = 0;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['ServerDefault'] = 1;
@ -43,8 +45,93 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
$GLOBALS['pmaThemeImage'] = 'themes/dot.gif';
$GLOBALS['is_ajax_request'] = false;
$GLOBALS['cfgRelation'] = PMA_getRelationsParam();
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$sql_isView_true = "SELECT TABLE_NAME
FROM information_schema.VIEWS
WHERE TABLE_SCHEMA = 'PMA'
AND TABLE_NAME = 'PMA_BookMark'";
$sql_isView_false = "SELECT TABLE_NAME
FROM information_schema.VIEWS
WHERE TABLE_SCHEMA = 'PMA'
AND TABLE_NAME = 'PMA_BookMark_2'";
$sql_isUpdatableView_true = "SELECT TABLE_NAME
FROM information_schema.VIEWS
WHERE TABLE_SCHEMA = 'PMA'
AND TABLE_NAME = 'PMA_BookMark'
AND IS_UPDATABLE = 'YES'";
$sql_isUpdatableView_false = "SELECT TABLE_NAME
FROM information_schema.VIEWS
WHERE TABLE_SCHEMA = 'PMA'
AND TABLE_NAME = 'PMA_BookMark_2'
AND IS_UPDATABLE = 'YES'";
$sql_analyzeStructure_true = "SELECT COLUMN_NAME, DATA_TYPE
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'PMA'
AND TABLE_NAME = 'PMA_BookMark'";
$fetchResult = array(
array(
$sql_isView_true,
null,
null,
null,
0,
true
),
array(
$sql_isView_false,
null,
null,
null,
0,
false
),
array(
$sql_isUpdatableView_true,
null,
null,
null,
0,
true
),
array(
$sql_isUpdatableView_false,
null,
null,
null,
0,
false
),
array(
$sql_analyzeStructure_true,
null,
null,
null,
0,
array(
array('COLUMN_NAME'=>'COLUMN_NAME', 'DATA_TYPE'=>'DATA_TYPE')
)
),
);
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$dbi->expects($this->any())->method('fetchResult')
->will($this->returnValueMap($fetchResult));
$GLOBALS['dbi'] = $dbi;
}
/**
* Test object creating
*
@ -57,17 +144,37 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
}
/**
* Test renaming
* Test for constructor
*
* @return void
*/
public function testRename()
public function testConstruct()
{
$table = new PMA_Table('table1', 'pma_test');
$table->rename('table3');
$this->assertEquals('table3', $table->getName());
$table = new PMA_Table("PMA_BookMark", "PMA");
$this->assertEquals(
'PMA_BookMark',
$table->__toString()
);
$this->assertEquals(
'PMA_BookMark',
$table->getName()
);
$this->assertEquals(
'PMA',
$table->getDbName()
);
$this->assertEquals(
'PMA.PMA_BookMark',
$table->getFullName()
);
}
/**
* Test object creating
*
* @return void
*/
/**
* Test Set & Get
*
@ -88,34 +195,6 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
);
}
/**
* Test getting columns
*
* @return void
*/
public function testColumns()
{
$table = new PMA_Table('table1', 'pma_test');
$this->assertEquals(
array('`pma_test`.`table1`.`i`', '`pma_test`.`table1`.`o`'),
$table->getColumns()
);
}
/**
* Test getting unique columns
*
* @return void
*/
public function testUniqueColumns()
{
$table = new PMA_Table('table1', 'pma_test');
$this->assertEquals(
array(),
$table->getUniqueColumns()
);
}
/**
* Test name validation
*
@ -148,5 +227,72 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
array('te\\st', false),
);
}
}
/**
* Test for isView
*
* @return void
*/
public function testIsView()
{
$this->assertEquals(
false,
PMA_Table::isView()
);
//validate that it is the same as DBI fetchResult
$this->assertEquals(
true,
PMA_Table::isView('PMA', 'PMA_BookMark')
);
$this->assertEquals(
false,
PMA_Table::isView('PMA', 'PMA_BookMark_2')
);
}
/**
* Test for isUpdatableView
*
* @return void
*/
public function testIsUpdatableView()
{
$this->assertEquals(
false,
PMA_Table::isUpdatableView()
);
//validate that it is the same as DBI fetchResult
$this->assertEquals(
true,
PMA_Table::isUpdatableView('PMA', 'PMA_BookMark')
);
$this->assertEquals(
false,
PMA_Table::isUpdatableView('PMA', 'PMA_BookMark_2')
);
}
/**
* Test for analyzeStructure
*
* @return void
*/
public function testAnalyzeStructure()
{
$this->assertEquals(
false,
PMA_Table::analyzeStructure()
);
//validate that it is the same as DBI fetchResult
$show_create_table = PMA_Table::analyzeStructure('PMA', 'PMA_BookMark');
$this->assertEquals(
array('type'=>'DATA_TYPE'),
$show_create_table[0]['create_table_fields']['COLUMN_NAME']
);
}
}
?>

View File

@ -0,0 +1,187 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for server_status_advisor.lib.php
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
require_once 'libraries/Util.class.php';
require_once 'libraries/Advisor.class.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/ServerStatusData.class.php';
require_once 'libraries/server_status_advisor.lib.php';
require_once 'libraries/Theme.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/Message.class.php';
require_once 'libraries/sanitizing.lib.php';
require_once 'libraries/sqlparser.lib.php';
require_once 'libraries/js_escape.lib.php';
/**
* class PMA_ServerStatusAdvisor_Test
*
* this class is for testing server_status_advisor.lib.php functions
*
* @package PhpMyAdmin-test
*/
class PMA_ServerStatusAdvisor_Test extends PHPUnit_Framework_TestCase
{
/**
* Prepares environment for the test.
*
* @return void
*/
public $ServerStatusData;
/**
* Test for setUp
*
* @return void
*/
public function setUp()
{
//$_REQUEST
$_REQUEST['log'] = "index1";
$_REQUEST['pos'] = 3;
//$GLOBALS
$GLOBALS['cfg']['MaxRows'] = 10;
$GLOBALS['cfg']['ServerDefault'] = "server";
$GLOBALS['cfg']['RememberSorting'] = true;
$GLOBALS['cfg']['SQP'] = array();
$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000;
$GLOBALS['cfg']['ShowSQL'] = true;
$GLOBALS['cfg']['SQP']['fmtType'] = 'none';
$GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons';
$GLOBALS['cfg']['LimitChars'] = 100;
$GLOBALS['cfg']['DBG']['sql'] = false;
$GLOBALS['cfg']['Server']['host'] = "localhost";
$GLOBALS['cfg']['MySQLManualType'] = 'viewable';
$GLOBALS['cfg']['ShowHint'] = true;
$GLOBALS['cfg']['ActionLinksMode'] = 'icons';
$GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF');
$GLOBALS['server_master_status'] = false;
$GLOBALS['server_slave_status'] = false;
$GLOBALS['table'] = "table";
$GLOBALS['pmaThemeImage'] = 'image';
//$_SESSION
$_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme');
$_SESSION['PMA_Theme'] = new PMA_Theme();
//Mock DBI
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
->disableOriginalConstructor()
->getMock();
//this data is needed when PMA_ServerStatusData constructs
$server_status = array(
"Aborted_clients" => "0",
"Aborted_connects" => "0",
"Com_delete_multi" => "0",
"Com_create_function" => "0",
"Com_empty_query" => "0",
);
$server_variables= array(
"auto_increment_increment" => "1",
"auto_increment_offset" => "1",
"automatic_sp_privileges" => "ON",
"back_log" => "50",
"big_tables" => "OFF",
);
$fetchResult = array(
array(
"SHOW GLOBAL STATUS",
0,
1,
null,
0,
$server_status
),
array(
"SHOW GLOBAL VARIABLES",
0,
1,
null,
0,
$server_variables
),
array(
"SELECT concat('Com_', variable_name), variable_value "
. "FROM data_dictionary.GLOBAL_STATEMENTS",
0,
1,
null,
0,
$server_status
),
);
$dbi->expects($this->any())->method('fetchResult')
->will($this->returnValueMap($fetchResult));
$GLOBALS['dbi'] = $dbi;
$this->ServerStatusData = new PMA_ServerStatusData();
}
/**
* Test for PMA_getHTMLForAdvisor
*
* @return void
*/
public function testPMAGetHTMLForAdvisor()
{
//Call the test function
$html = PMA_getHTMLForAdvisor();
//validate 1: Advisor Instructions
$this->assertContains(
'<a href="#openAdvisorInstructions">',
$html
);
$this->assertContains(
'<div id="advisorInstructionsDialog"',
$html
);
//notice
$this->assertContains(
'The Advisor system can provide recommendations',
$html
);
$this->assertContains(
'Do note however that this system provides recommendations',
$html
);
//Advisor datas, we just validate that the Advisor Array is right
//Advisor logic related with OS should be validate on class Advisor
$this->assertContains(
'<div id="advisorData" style="display:none;">',
$html
);
//Advisor data Json encode Items
$this->assertContains(
htmlspecialchars(json_encode("parse")),
$html
);
$this->assertContains(
htmlspecialchars(json_encode("errors")),
$html
);
$this->assertContains(
htmlspecialchars(json_encode("run")),
$html
);
}
}

View File

@ -953,6 +953,10 @@ div#tablestatistics table {
float: <?php echo $left; ?>;
}
#fieldset_user_group_rights fieldset {
float: <?php echo $left; ?>;
}
#fieldset_user_global_rights legend input {
margin-<?php echo $left; ?>: 2em;
}

View File

@ -1207,6 +1207,10 @@ div#tablestatistics table {
float: <?php echo $left; ?>;
}
#fieldset_user_group_rights fieldset {
float: <?php echo $left; ?>;
}
#fieldset_user_global_rights legend input {
margin-<?php echo $left; ?>: 2em;
}