diff --git a/libraries/server_common.lib.php b/libraries/server_common.lib.php index 07f1bb2a1e..d5d174f0fe 100644 --- a/libraries/server_common.lib.php +++ b/libraries/server_common.lib.php @@ -12,44 +12,55 @@ if (! defined('PHPMYADMIN')) { /** * Returns the html for the sub-page heading * - * @param string $type Sub page type - * @param string $link Link to the official MySQL documentation + * @param string $type Sub page type + * @param string $link Link to the official MySQL documentation + * @param bool $is_image Display image or icon, true: image, false: icon * * @return string */ -function PMA_getHtmlForSubPageHeader($type, $link='') +function PMA_getHtmlForSubPageHeader($type, $link='', $is_image=true) { //array contains Sub page icon and text $header = array(); - $header['variables']['icon'] = 's_vars.png'; + $header['variables']['image'] = 's_vars.png'; $header['variables']['text'] = __('Server variables and settings'); - $header['engines']['icon'] = 'b_engine.png'; + $header['engines']['image'] = 'b_engine.png'; $header['engines']['text'] = __('Storage Engines'); - $header['plugins']['icon'] = 'b_engine.png'; + $header['plugins']['image'] = 'b_engine.png'; $header['plugins']['text'] = __('Plugins'); - $header['binlog']['icon'] = 's_tbl.png'; + $header['binlog']['image'] = 's_tbl.png'; $header['binlog']['text'] = __('Binary log'); - $header['collations']['icon'] = 's_asci.png'; + $header['collations']['image'] = 's_asci.png'; $header['collations']['text'] = __('Character Sets and Collations'); - $header['replication']['icon'] = 's_replication.png'; + $header['replication']['image'] = 's_replication.png'; $header['replication']['text'] = __('Replication'); - $header['database_statistics']['icon'] = 's_db.png'; + $header['database_statistics']['image'] = 's_db.png'; $header['database_statistics']['text'] = __('Databases statistics'); - $header['databases']['icon'] = 's_db.png'; + $header['databases']['image'] = 's_db.png'; $header['databases']['text'] = __('Databases'); - $html = '

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

' . "\n"; + $header['privileges']['image'] = 'b_usrlist.png'; + $header['privileges']['text'] = __('Privileges'); + + if ($is_image) { + $html = '

' . "\n" + . PMA_Util::getImage($header[$type]['image']) + . ' ' . $header[$type]['text'] . "\n" + . $link . '

' . "\n"; + } else { + $html = '

' . "\n" + . PMA_Util::getIcon($header[$type]['image']) + . ' ' . $header[$type]['text'] . "\n" + . $link . '

' . "\n"; + } return $html; } diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index c5a69d303d..0ef8679eca 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -9,6 +9,32 @@ if (! defined('PHPMYADMIN')) { exit; } + +/** + * Get Html for User Group Dialog + * + * @param string $username username + * @param bool $is_menuswork Is menuswork set in configuration + * + * @return string html + */ +function PMA_getHtmlForUserGroupDialog($username, $is_menuswork) +{ + $html = ''; + if (! empty($_REQUEST['edit_user_group_dialog']) && $is_menuswork) { + $dialog = PMA_getHtmlToChoseUserGroup($username); + $response = PMA_Response::getInstance(); + if ($GLOBALS['is_ajax_request']) { + $response->addJSON('message', $dialog); + exit; + } else { + $html .= $dialog; + } + } + + return $html; +} + /** * Escapes wildcard in a database+table specification * before using it in a GRANT statement. @@ -234,7 +260,11 @@ function PMA_getGrantsArray() array( 'Super_priv', 'SUPER', - __('Allows connecting, even if maximum number of connections is reached; required for most administrative operations like setting global variables or killing threads of other users.') + __( + 'Allows connecting, even if maximum number of connections ' + . 'is reached; required for most administrative operations ' + . 'like setting global variables or killing threads of other users.' + ) ), array( 'Create_tmp_table_priv', @@ -585,13 +615,13 @@ function PMA_getHtmlToDisplayPrivilegesTable($db = '*', } unset($res, $row1); } - // t a b l e - s p e c i f i c p r i v i l e g e s + // table-specific privileges if (! empty($columns)) { $html_output .= PMA_getHtmlForTableSpecificPrivileges( $username, $hostname, $db, $table, $columns, $row ); } else { - // g l o b a l o r d b - s p e c i f i c + // global or db-specific $html_output .= PMA_getHtmlForGlobalOrDbSpecificPrivs($db, $table, $row); } $html_output .= '' . "\n"; @@ -623,7 +653,9 @@ function PMA_getHtmlForDisplayResourceLimits($row) $html_output .= '
' . "\n" . '' . "\n" @@ -631,32 +663,44 @@ function PMA_getHtmlForDisplayResourceLimits($row) . 'value="' . $row['max_questions'] . '" ' . 'size="11" maxlength="11" ' . 'title="' - . __('Limits the number of queries the user may send to the server per hour.') + . __( + 'Limits the number of queries the user may send to the server per hour.' + ) . '" />' . "\n" . '
' . "\n"; $html_output .= '
' . "\n" . '' . "\n" . '' . "\n" . '
' . "\n"; $html_output .= '
' . "\n" . '' . "\n" . '' . "\n" . '
' . "\n"; @@ -790,7 +834,8 @@ function PMA_getHtmlForNotAttachedPrivilegesToTableSpecificColumn($row) $html_output = ''; foreach ($row as $current_grant => $current_grant_value) { $grant_type = substr($current_grant, 0, (strlen($current_grant) - 5)); - if (in_array($grant_type, array('Select', 'Insert', 'Update', 'References'))) { + if (in_array($grant_type, array('Select', 'Insert', 'Update', 'References')) + ) { continue; } // make a substitution to match the messages variables; @@ -1036,13 +1081,21 @@ function PMA_getAdministrationPrivilegeTable($db) $administration_privTable = array( array('Grant', 'GRANT', - __('Allows adding users and privileges without reloading the privilege tables.') + __( + 'Allows adding users and privileges ' + . 'without reloading the privilege tables.' + ) ), ); if ($db == '*') { $administration_privTable[] = array('Super', 'SUPER', - __('Allows connecting, even if maximum number of connections is reached; required for most administrative operations like setting global variables or killing threads of other users.') + __( + 'Allows connecting, even if maximum number ' + . 'of connections is reached; required for ' + . 'most administrative operations like ' + . 'setting global variables or killing threads of other users.' + ) ); $administration_privTable[] = array('Process', 'PROCESS', @@ -1197,7 +1250,11 @@ function PMA_getHtmlForDisplayLoginInformationFields($mode = 'new') $html_output .= ''; $html_output .= ''; @@ -1308,7 +1365,10 @@ function PMA_getHtmlForDisplayLoginInformationFields($mode = 'new') . '" title="' . __('Host') . '" onchange="pred_hostname.value = \'userdefined\';" />' . "\n" . PMA_Util::showHint( - __('When Host table is used, this field is ignored and values stored in Host table are used instead.') + __( + 'When Host table is used, this field is ignored ' + . 'and values stored in Host table are used instead.' + ) ) . '' . "\n"; @@ -1586,7 +1646,10 @@ function PMA_getHtmlForAddUser($dbname) if (! empty($dbname) ) { $html_output .= PMA_Util::getCheckbox( 'createdb-3', - sprintf(__('Grant all privileges on database "%s"'), htmlspecialchars($dbname)), + sprintf( + __('Grant all privileges on database "%s"'), + htmlspecialchars($dbname) + ), true, false ); @@ -1727,7 +1790,7 @@ function PMA_getHtmlForSpecificDbPrivileges() . '' . '' . "\n"; - if ($GLOBALS['is_ajax_request'] == true + if ($GLOBALS['is_ajax_request'] == true && empty($_REQUEST['ajax_page_request']) ) { $message = PMA_Message::success(__('User has been added.')); @@ -2087,8 +2150,15 @@ function PMA_getChangeLoginInformationHtmlForm($username, $hostname) $choices = array( '4' => __('… keep the old one.'), '1' => __('… delete the old one from the user tables.'), - '2' => __('… revoke all active privileges from the old one and delete it afterwards.'), - '3' => __('… delete the old one from the user tables and reload the privileges afterwards.')); + '2' => __( + '… revoke all active privileges from ' + . 'the old one and delete it afterwards.' + ), + '3' => __( + '… delete the old one from the user tables ' + . 'and reload the privileges afterwards.' + ) + ); $class = ' ajax'; $html_output = '
' . "\n" . '' . ((((! strlen($dbname)) && $row['Grant_priv'] == 'Y') - || (strlen($dbname) && in_array('Grant', explode(',', $row['Table_priv'])))) + || (strlen($dbname) + && in_array('Grant', explode(',', $row['Table_priv'])))) ? __('Yes') : __('No')) . '' . "\n" @@ -2729,7 +2800,10 @@ function PMA_getFieldsetForAddDeleteUser() $html_output .= '' . "\n" . '(' - . __('Revoke all active privileges from the users and delete them afterwards.') + . __( + 'Revoke all active privileges from the users ' + . 'and delete them afterwards.' + ) . ')' . '
' . "\n"; @@ -2836,7 +2910,9 @@ function PMA_getDbRightsForUserOverview() if (in_array($table_search_in, $tables)) { $db_rights_sqls[] = 'SELECT DISTINCT `User`, `Host` FROM `mysql`.`' . $table_search_in . '` ' - . (isset($_GET['initial']) ? PMA_rangeOfUsers($_GET['initial']) : ''); + . (isset($_GET['initial']) + ? PMA_rangeOfUsers($_GET['initial']) + : ''); } } $user_defaults = array( @@ -2942,7 +3018,8 @@ function PMA_updatePrivileges($username, $hostname, $tablename, $dbname) if ((isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y') || (! strlen($dbname) && (isset($_POST['max_questions']) || isset($_POST['max_connections']) - || isset($_POST['max_updates']) || isset($_POST['max_user_connections']))) + || isset($_POST['max_updates']) + || isset($_POST['max_user_connections']))) ) { $sql_query2 .= PMA_getWithClauseForAddUserAndUpdatePrivs(); } @@ -2973,6 +3050,293 @@ function PMA_updatePrivileges($username, $hostname, $tablename, $dbname) return array($sql_query, $message); } +/** + * Get List of information: Changes / copies a user + * + * @return array() + */ +function PMA_getDataForChangeOrCopyUser() +{ + $row = null; + $queries = null; + $password = null; + + if (isset($_REQUEST['change_copy'])) { + $user_host_condition = ' WHERE `User` = ' + . "'". PMA_Util::sqlAddSlashes($_REQUEST['old_username']) . "'" + . ' AND `Host` = ' + . "'" . PMA_Util::sqlAddSlashes($_REQUEST['old_hostname']) . "';"; + $row = $GLOBALS['dbi']->fetchSingleRow( + 'SELECT * FROM `mysql`.`user` ' . $user_host_condition + ); + if (! $row) { + $response = PMA_Response::getInstance(); + $response->addHTML( + PMA_Message::notice(__('No user found.'))->getDisplay() + ); + unset($_REQUEST['change_copy']); + } else { + extract($row, EXTR_OVERWRITE); + // Recent MySQL versions have the field "Password" in mysql.user, + // so the previous extract creates $Password but this script + // uses $password + if (! isset($password) && isset($Password)) { + $password = $Password; + } + $queries = array(); + } + } + + return array($queries, $password); +} + +/** + * Update Data for information: Deletes users + * + * @param array $queries queries array + * + * @return array + */ +function PMA_getDataForDeleteUsers($queries) +{ + if (isset($_REQUEST['change_copy'])) { + $selected_usr = array( + $_REQUEST['old_username'] . '&#27;' . $_REQUEST['old_hostname'] + ); + } else { + $selected_usr = $_REQUEST['selected_usr']; + $queries = array(); + } + foreach ($selected_usr as $each_user) { + list($this_user, $this_host) = explode('&#27;', $each_user); + $queries[] = '# ' + . sprintf( + __('Deleting %s'), + '\'' . $this_user . '\'@\'' . $this_host . '\'' + ) + . ' ...'; + $queries[] = 'DROP USER \'' + . PMA_Util::sqlAddSlashes($this_user) + . '\'@\'' . PMA_Util::sqlAddSlashes($this_host) . '\';'; + + if (isset($_REQUEST['drop_users_db'])) { + $queries[] = 'DROP DATABASE IF EXISTS ' + . PMA_Util::backquote($this_user) . ';'; + $GLOBALS['reload'] = true; + } + } + return $queries; +} + +/** + * update Message For Reload + * + * @return array + */ +function PMA_updateMessageForReload() +{ + $message = null; + if (isset($_REQUEST['flush_privileges'])) { + $sql_query = 'FLUSH PRIVILEGES;'; + $GLOBALS['dbi']->query($sql_query); + $message = PMA_Message::success( + __('The privileges were reloaded successfully.') + ); + } + + if (isset($_REQUEST['validate_username'])) { + $message = PMA_Message::success(); + } + + return $message; +} + +/** + * update Data For Queries from queries_for_display + * + * @param array $queries queries array + * @param array $queries_for_display queries arry for display + * + * @return null + */ +function PMA_getDataForQueries($queries, $queries_for_display) +{ + $tmp_count = 0; + foreach ($queries as $sql_query) { + if ($sql_query{0} != '#') { + $GLOBALS['dbi']->query($sql_query); + } + // when there is a query containing a hidden password, take it + // instead of the real query sent + if (isset($queries_for_display[$tmp_count])) { + $queries[$tmp_count] = $queries_for_display[$tmp_count]; + } + $tmp_count++; + } + + return $queries; +} + +/** + * update Data for information: Adds a user + * + * @param string $dbname db name + * @param string $username user name + * @param string $hostname host name + * @param string $password password + * @param bool $is_menuwork is_menuwork set? + * + * @return array + */ +function PMA_getDataForAddUser( + $dbname, $username, $hostname, + $password, $is_menuwork +) { + $_add_user_error = false; + $message = null; + $queries = null; + $queries_for_display = null; + $sql_query = null; + if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) { + $sql_query = ''; + if ($_POST['pred_username'] == 'any') { + $username = ''; + } + switch ($_POST['pred_hostname']) { + case 'any': + $hostname = '%'; + break; + case 'localhost': + $hostname = 'localhost'; + break; + case 'hosttable': + $hostname = ''; + break; + case 'thishost': + $_user_name = $GLOBALS['dbi']->fetchValue('SELECT USER()'); + $hostname = substr($_user_name, (strrpos($_user_name, '@') + 1)); + unset($_user_name); + break; + } + $sql = "SELECT '1' FROM `mysql`.`user`" + . " WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" + . " AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "';"; + if ($GLOBALS['dbi']->fetchValue($sql) == 1) { + $message = PMA_Message::error(__('The user %s already exists!')); + $message->addParam( + '[em]\'' . $username . '\'@\'' . $hostname . '\'[/em]' + ); + $_REQUEST['adduser'] = true; + $_add_user_error = true; + } else { + list($create_user_real, $create_user_show, $real_sql_query, $sql_query) + = PMA_getSqlQueriesForDisplayAndAddUser( + $username, $hostname, (isset ($password) ? $password : '') + ); + + if (empty($_REQUEST['change_copy'])) { + $_error = false; + + if (isset($create_user_real)) { + if (! $GLOBALS['dbi']->tryQuery($create_user_real)) { + $_error = true; + } + $sql_query = $create_user_show . $sql_query; + } + list($sql_query, $message) = PMA_addUserAndCreateDatabase( + $_error, $real_sql_query, $sql_query, $username, $hostname, + isset($dbname) ? $dbname : null + ); + if (! empty($_REQUEST['userGroup']) && $is_menuwork) { + PMA_setUserGroup($GLOBALS['username'], $_REQUEST['userGroup']); + } + + } else { + if (isset($create_user_real)) { + $queries[] = $create_user_real; + } + $queries[] = $real_sql_query; + // we put the query containing the hidden password in + // $queries_for_display, at the same position occupied + // by the real query in $queries + $tmp_count = count($queries); + if (isset($create_user_real)) { + $queries_for_display[$tmp_count - 2] = $create_user_show; + } + $queries_for_display[$tmp_count - 1] = $sql_query; + } + unset($res, $real_sql_query); + } + } + + return array( + $message, $queries, $queries_for_display, $sql_query, $_add_user_error + ); +} + +/** + * Update DB information: DB, Table, isWildcard + * + * @return array + */ +function PMA_getDataForDBInfo() +{ + $dbname = null; + $tablename = null; + $db_and_table = null; + $dbname_is_wildcard = null; + + /** + * Checks if a dropdown box has been used for selecting a database / table + */ + if (PMA_isValid($_REQUEST['pred_tablename'])) { + $tablename = $_REQUEST['pred_tablename']; + } elseif (PMA_isValid($_REQUEST['tablename'])) { + $tablename = $_REQUEST['tablename']; + } else { + unset($tablename); + } + + if (PMA_isValid($_REQUEST['pred_dbname'])) { + $dbname = $_REQUEST['pred_dbname']; + unset($pred_dbname); + } elseif (PMA_isValid($_REQUEST['dbname'])) { + $dbname = $_REQUEST['dbname']; + } else { + unset($dbname); + unset($tablename); + } + + if (isset($dbname)) { + $unescaped_db = PMA_Util::unescapeMysqlWildcards($dbname); + $db_and_table = PMA_Util::backquote($unescaped_db) . '.'; + if (isset($tablename)) { + $db_and_table .= PMA_Util::backquote($tablename); + } else { + $db_and_table .= '*'; + } + } else { + $db_and_table = '*.*'; + } + + // check if given $dbname is a wildcard or not + if (isset($dbname)) { + //if (preg_match('/\\\\(?:_|%)/i', $dbname)) { + if (preg_match('/(?'; @@ -3179,9 +3543,17 @@ function PMA_getHtmlForDisplayUserOverviewPage($pmaThemeImage, $text_dir) $html_output .= PMA_getAddUserHtmlFieldset(); } // end if (display overview) - if (! $GLOBALS['is_ajax_request'] || ! empty($_REQUEST['ajax_page_request'])) { + if (! $GLOBALS['is_ajax_request'] + || ! empty($_REQUEST['ajax_page_request']) + ) { $flushnote = new PMA_Message( - __('Note: phpMyAdmin gets the users\' privileges directly from MySQL\'s privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should %sreload the privileges%s before you continue.'), + __( + 'Note: phpMyAdmin gets the users\' privileges directly ' + . 'from MySQL\'s privilege tables. The content of these tables ' + . 'may differ from the privileges the server uses, ' + . 'if they have been changed manually. In this case, ' + . 'you should %sreload the privileges%s before you continue.' + ), PMA_Message::NOTICE ); $flushLink = '' . "\n" - ); + $response->addHTML(PMA_getHtmlForSubPageHeader('privileges', '', false)); $response->addHTML(PMA_Message::error(__('No Privileges'))->getDisplay()); exit; } @@ -159,101 +137,28 @@ if (! $is_superuser) { /** * Changes / copies a user, part I */ -if (isset($_REQUEST['change_copy'])) { - $user_host_condition = ' WHERE `User` = ' - . "'". PMA_Util::sqlAddSlashes($_REQUEST['old_username']) . "'" - . ' AND `Host` = ' - . "'" . PMA_Util::sqlAddSlashes($_REQUEST['old_hostname']) . "';"; - $row = $GLOBALS['dbi']->fetchSingleRow( - 'SELECT * FROM `mysql`.`user` ' . $user_host_condition - ); - if (! $row) { - PMA_Message::notice(__('No user found.'))->display(); - unset($_REQUEST['change_copy']); - } else { - extract($row, EXTR_OVERWRITE); - // Recent MySQL versions have the field "Password" in mysql.user, - // so the previous extract creates $Password but this script - // uses $password - if (! isset($password) && isset($Password)) { - $password = $Password; - } - $queries = array(); - } -} - +list($queries, $password) = PMA_getDataForChangeOrCopyUser(); + /** * Adds a user * (Changes / copies a user, part II) - */ -if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) { - $sql_query = ''; - if ($_POST['pred_username'] == 'any') { - $username = ''; - } - switch ($_POST['pred_hostname']) { - case 'any': - $hostname = '%'; - break; - case 'localhost': - $hostname = 'localhost'; - break; - case 'hosttable': - $hostname = ''; - break; - case 'thishost': - $_user_name = $GLOBALS['dbi']->fetchValue('SELECT USER()'); - $hostname = substr($_user_name, (strrpos($_user_name, '@') + 1)); - unset($_user_name); - break; - } - $sql = "SELECT '1' FROM `mysql`.`user`" - . " WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" - . " AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "';"; - if ($GLOBALS['dbi']->fetchValue($sql) == 1) { - $message = PMA_Message::error(__('The user %s already exists!')); - $message->addParam('[em]\'' . $username . '\'@\'' . $hostname . '\'[/em]'); - $_REQUEST['adduser'] = true; - $_add_user_error = true; - } else { - list($create_user_real, $create_user_show, $real_sql_query, $sql_query) - = PMA_getSqlQueriesForDisplayAndAddUser( - $username, $hostname, (isset ($password) ? $password : '') - ); - - if (empty($_REQUEST['change_copy'])) { - $_error = false; - - if (isset($create_user_real)) { - if (! $GLOBALS['dbi']->tryQuery($create_user_real)) { - $_error = true; - } - $sql_query = $create_user_show . $sql_query; - } - list($sql_query, $message) = PMA_addUserAndCreateDatabase( - $_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)) { - $queries[] = $create_user_real; - } - $queries[] = $real_sql_query; - // we put the query containing the hidden password in - // $queries_for_display, at the same position occupied - // by the real query in $queries - $tmp_count = count($queries); - if (isset($create_user_real)) { - $queries_for_display[$tmp_count - 2] = $create_user_show; - } - $queries_for_display[$tmp_count - 1] = $sql_query; - } - unset($res, $real_sql_query); - } + */ +list($ret_message, $ret_queries, $queries_for_display, $sql_query, $_add_user_error) + = PMA_getDataForAddUser( + isset($dbname)? $dbname : null, + isset($username)? $username : null, + isset($hostname)? $hostname : null, + isset($password)? $password : null, + $cfgRelation['menuswork'] + ); +//update the old variables +if (isset($ret_queries)) { + $queries = $ret_queries; + unset($ret_queries); +} +if (isset($ret_message)) { + $message = $ret_message; + unset($ret_message); } /** @@ -270,8 +175,8 @@ if (isset($_REQUEST['change_copy'])) { */ if (! empty($_POST['update_privs'])) { list($sql_query, $message) = PMA_updatePrivileges( - $username, - $hostname, + (isset($username) ? $username : ''), + (isset($hostname) ? $hostname : ''), (isset($tablename) ? $tablename : ''), (isset($dbname) ? $dbname : '') ); @@ -313,32 +218,7 @@ if (isset($_REQUEST['change_pw'])) { if (isset($_REQUEST['delete']) || (isset($_REQUEST['change_copy']) && $_REQUEST['mode'] < 4) ) { - if (isset($_REQUEST['change_copy'])) { - $selected_usr = array( - $_REQUEST['old_username'] . '&#27;' . $_REQUEST['old_hostname'] - ); - } else { - $selected_usr = $_REQUEST['selected_usr']; - $queries = array(); - } - foreach ($selected_usr as $each_user) { - list($this_user, $this_host) = explode('&#27;', $each_user); - $queries[] = '# ' - . sprintf( - __('Deleting %s'), - '\'' . $this_user . '\'@\'' . $this_host . '\'' - ) - . ' ...'; - $queries[] = 'DROP USER \'' - . PMA_Util::sqlAddSlashes($this_user) - . '\'@\'' . PMA_Util::sqlAddSlashes($this_host) . '\';'; - - if (isset($_REQUEST['drop_users_db'])) { - $queries[] = 'DROP DATABASE IF EXISTS ' - . PMA_Util::backquote($this_user) . ';'; - $GLOBALS['reload'] = true; - } - } + $queries = PMA_getDataForDeleteUsers($queries); if (empty($_REQUEST['change_copy'])) { list($sql_query, $message) = PMA_deleteUser($queries); } @@ -348,18 +228,7 @@ if (isset($_REQUEST['delete']) * Changes / copies a user, part V */ if (isset($_REQUEST['change_copy'])) { - $tmp_count = 0; - foreach ($queries as $sql_query) { - if ($sql_query{0} != '#') { - $GLOBALS['dbi']->query($sql_query); - } - // when there is a query containing a hidden password, take it - // instead of the real query sent - if (isset($queries_for_display[$tmp_count])) { - $queries[$tmp_count] = $queries_for_display[$tmp_count]; - } - $tmp_count++; - } + $queries = PMA_getDataForQueries($queries, $queries_for_display); $message = PMA_Message::success(); $sql_query = join("\n", $queries); } @@ -367,14 +236,10 @@ if (isset($_REQUEST['change_copy'])) { /** * Reloads the privilege tables into memory */ -if (isset($_REQUEST['flush_privileges'])) { - $sql_query = 'FLUSH PRIVILEGES;'; - $GLOBALS['dbi']->query($sql_query); - $message = PMA_Message::success(__('The privileges were reloaded successfully.')); -} - -if (isset($_REQUEST['validate_username'])) { - $message = PMA_Message::success(); +$message_ret = PMA_updateMessageForReload(); +if (isset($message_ret)) { + $message = $message_ret; + unset($message_ret); } /** @@ -433,24 +298,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); - } -} +$response->addHTML( + PMA_getHtmlForUserGroupDialog( + isset($username)? $username : null, + $cfgRelation['menuswork'] + ) +); // export user definition if (isset($_REQUEST['export']) || (isset($_REQUEST['submit_mult']) && $_REQUEST['submit_mult'] == 'export') ) { - list($title, $export) = PMA_getHtmlForExportUserDefinition( + list($title, $export) = PMA_getListForExportUserDefinition( isset($username) ? $username : null, isset($hostname) ? $hostname : null ); @@ -478,7 +337,6 @@ if (empty($_REQUEST['adduser']) ); } else { // A user was selected -> display the user's properties - // In an Ajax request, prevent cached values from showing if ($GLOBALS['is_ajax_request'] == true) { header('Cache-Control: no-cache');