?? server_privileges.php
字號:
unset($sql_query1); } $sql_query = $sql_query0 . (isset($sql_query1) ? ' ' . $sql_query1 : ''); $message = sprintf($GLOBALS['strRevokeMessage'], '\'' . $username . '\'@\'' . $hostname . '\''); if ( ! isset($tablename) || ! strlen($tablename) ) { unset($dbname); } else { unset($tablename); }}/** * Updates the password */if (!empty($change_pw)) { if ($nopass == 1) { $sql_query = 'SET PASSWORD FOR \'' . $username . '\'@\'' . $hostname . '\' = \'\';'; PMA_DBI_query($sql_query); $message = sprintf($GLOBALS['strPasswordChanged'], '\'' . $username . '\'@\'' . $hostname . '\''); } elseif (empty($pma_pw) || empty($pma_pw2)) { $message = $GLOBALS['strPasswordEmpty']; } elseif ($pma_pw != $pma_pw2) { $message = $GLOBALS['strPasswordNotSame']; } else { $hidden_pw = ''; for ($i = 0; $i < strlen($pma_pw); $i++) { $hidden_pw .= '*'; } $local_query = 'SET PASSWORD FOR \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\' = PASSWORD(\'' . PMA_sqlAddslashes($pma_pw) . '\')'; $sql_query = 'SET PASSWORD FOR \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\' = PASSWORD(\'' . $hidden_pw . '\')'; PMA_DBI_try_query($local_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query); $message = sprintf($GLOBALS['strPasswordChanged'], '\'' . $username . '\'@\'' . $hostname . '\''); }}/** * Deletes users * (Changes / copies a user, part IV) */$user_host_separator = chr(27);if (!empty($delete) || (!empty($change_copy) && $mode < 4)) { if (!empty($change_copy)) { $selected_usr = array($old_username . $user_host_separator . $old_hostname); } else { $queries = array(); } for ($i = 0; isset($selected_usr[$i]); $i++) { list($this_user, $this_host) = explode($user_host_separator, $selected_usr[$i]); $queries[] = '# ' . sprintf($GLOBALS['strDeleting'], '\'' . $this_user . '\'@\'' . $this_host . '\'') . ' ...'; if ( PMA_MYSQL_INT_VERSION >= 50002 ) { $queries[] = 'DROP USER \'' . PMA_sqlAddslashes($this_user) . '\'@\'' . $this_host . '\';'; } else { if ($mode == 2) { // The SHOW GRANTS query may fail if the user has not been loaded // into memory $res = PMA_DBI_try_query('SHOW GRANTS FOR \'' . PMA_sqlAddslashes($this_user) . '\'@\'' . $this_host . '\';'); if ($res) { $queries[] = 'REVOKE ALL PRIVILEGES ON *.* FROM \'' . PMA_sqlAddslashes($this_user) . '\'@\'' . $this_host . '\';'; while ($row = PMA_DBI_fetch_row($res)) { $this_table = substr($row[0], (strpos($row[0], 'ON') + 3), (strpos($row[0], ' TO ') - strpos($row[0], 'ON') - 3)); if ($this_table != '*.*') { $queries[] = 'REVOKE ALL PRIVILEGES ON ' . $this_table . ' FROM \'' . PMA_sqlAddslashes($this_user) . '\'@\'' . $this_host . '\';'; if (strpos($row[0], 'WITH GRANT OPTION')) { $queries[] = 'REVOKE GRANT OPTION ON ' . $this_table . ' FROM \'' . PMA_sqlAddslashes($this_user) . '\'@\'' . $this_host . '\';'; } } unset($this_table); } PMA_DBI_free_result($res); } unset($res); } if ( PMA_MYSQL_INT_VERSION >= 40101 ) { if (PMA_MYSQL_INT_VERSION < 50002) { $queries[] = 'REVOKE GRANT OPTION ON *.* FROM \'' . PMA_sqlAddslashes($this_user) . '\'@\'' . $this_host . '\';'; } $queries[] = 'DROP USER \'' . PMA_sqlAddslashes($this_user) . '\'@\'' . $this_host . '\';'; } else { $queries[] = 'DELETE FROM `mysql`.`user` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($this_user), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($this_host, 'quoted') . ';'; } if ($mode != 2) { // If we REVOKE the table grants, we should not need to modify the // `mysql`.`db`, `mysql`.`tables_priv` and `mysql`.`columns_priv` tables manually... $user_host_condition = ' WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($this_user), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($this_host, 'quoted') . ';'; $queries[] = 'DELETE FROM `mysql`.`db`' . $user_host_condition; $queries[] = 'DELETE FROM `mysql`.`tables_priv`' . $user_host_condition; $queries[] = 'DELETE FROM `mysql`.`columns_priv`' . $user_host_condition; } } if (!empty($drop_users_db)) { $queries[] = 'DROP DATABASE IF EXISTS ' . PMA_backquote($this_user) . ';'; $GLOBALS['reload'] = TRUE; PMA_reloadNavigation(); } } if (empty($change_copy)) { if (empty($queries)) { $show_error_header = TRUE; $message = $GLOBALS['strDeleteNoUsersSelected']; } else { if ($mode == 3) { $queries[] = '# ' . $GLOBALS['strReloadingThePrivileges'] . ' ...'; $queries[] = 'FLUSH PRIVILEGES;'; } foreach ($queries as $sql_query) { if ($sql_query{0} != '#') { PMA_DBI_query($sql_query, $GLOBALS['userlink']); } } $sql_query = join("\n", $queries); $message = $GLOBALS['strUsersDeleted']; } unset($queries); }}/** * Changes / copies a user, part V */if (!empty($change_copy)) { $tmp_count = 0; foreach ($queries as $sql_query) { if ($sql_query{0} != '#') { PMA_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++; } $message = $GLOBALS['strSuccess']; $sql_query = join("\n", $queries);}/** * Reloads the privilege tables into memory */if (!empty($flush_privileges)) { $sql_query = 'FLUSH PRIVILEGES;'; PMA_DBI_query($sql_query); $message = $GLOBALS['strPrivilegesReloaded'];}/** * Displays the links */if (isset($viewing_mode) && $viewing_mode == 'db') { $db = $checkprivs; $url_query .= '&goto=db_operations.php'; // Gets the database structure $sub_part = '_structure'; require('./libraries/db_info.inc.php'); echo "\n";} else { require('./libraries/server_links.inc.php');}/** * defines some standard links */$link_edit = '<a href="server_privileges.php?' . $GLOBALS['url_query'] .'&username=%s' .'&hostname=%s' .'&dbname=%s' .'&tablename=%s">';if ( $GLOBALS['cfg']['PropertiesIconic'] ) { $link_edit .= '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_usredit.png" width="16" height="16" alt="' . $GLOBALS['strEditPrivileges'] . '" title="' . $GLOBALS['strEditPrivileges'] . '" />';} else { $link_edit .= $GLOBALS['strEditPrivileges'];}$link_edit .= '</a>';$link_revoke = '<a href="server_privileges.php?' . $GLOBALS['url_query'] .'&username=%s' .'&hostname=%s' .'&dbname=%s' .'&tablename=%s' .'&revokeall=1">';if ( $GLOBALS['cfg']['PropertiesIconic'] ) { $link_revoke .= '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_usrdrop.png" width="16" height="16" alt="' . $GLOBALS['strRevoke'] . '" title="' . $GLOBALS['strRevoke'] . '" />';} else { $link_revoke .= $GLOBALS['strRevoke'];}$link_revoke .= '</a>';/** * Displays the page */if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) ) { if ( ! isset( $username ) ) { // No username is given --> display the overview echo '<h2>' . "\n" . ($GLOBALS['cfg']['MainPageIconic'] ? '<img class="icon" src="'. $GLOBALS['pmaThemeImage'] . 'b_usrlist.png" alt="" />' : '') . $GLOBALS['strUserOverview'] . "\n" . '</h2>' . "\n"; $sql_query = 'SELECT `User`,' . ' `Host`,' . ' IF(`Password` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . '\'\', \'N\', \'Y\') AS \'Password\',' . ' `Select_priv`,' . ' `Insert_priv`,' . ' `Update_priv`,' . ' `Delete_priv`,' . ' `Index_priv`,' . ' `Alter_priv`,' . ' `Create_priv`,' . ' `Drop_priv`,' . ' `Grant_priv`,' . ' `References_priv`,' . ' `Reload_priv`,' . ' `Shutdown_priv`,' . ' `Process_priv`,' . ' `File_priv`'; if (PMA_MYSQL_INT_VERSION >= 40002) { $sql_query .= ', `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv`'; } if (PMA_MYSQL_INT_VERSION >= 50001) { $sql_query .= ', `Create_view_priv`, `Show_view_priv`'; } if (PMA_MYSQL_INT_VERSION >= 50003) { $sql_query .= ', `Create_user_priv`, `Create_routine_priv`, `Alter_routine_priv`'; } $sql_query .= ' FROM `mysql`.`user`'; $sql_query .= (isset($initial) ? PMA_RangeOfUsers($initial) : ''); $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;'; $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE); if (! $res) { // the query failed! This may have two reasons: // - the user does not have enough privileges // - the privilege tables use a structure of an earlier version. // so let's try a more simple query $sql_query = 'SELECT * FROM `mysql`.`user`'; $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE); if (!$res) { echo '<i>' . $GLOBALS['strNoPrivileges'] . '</i>' . "\n"; PMA_DBI_free_result($res); unset($res); } else { // rabus: This message is hardcoded because I will replace
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -