From 320c4d68177726eab7d3f62295ad4a0201f5330e Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 11 Jan 2003 12:52:42 +0000 Subject: [PATCH] bugfixes --- ChangeLog | 7 +++ server_common.inc.php3 | 9 +--- server_links.inc.php3 | 12 +++-- server_privileges.php3 | 107 ++++++++++++++++++++++------------------ server_processlist.php3 | 19 +++---- server_status.php3 | 6 +++ server_variables.php3 | 8 ++- 7 files changed, 97 insertions(+), 71 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3414d1e7b..2e7cfd47a 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,13 @@ phpMyAdmin - Changelog $Id$ $Source$ +2003-01-11 Alexander M. Turek + * server_*.php3: + - The messages are now displayed by server_links.inc.php3, so + server_common.inc.php3 may be included earlier; + - Beautified code. + * server_privileges.php3: Wrong GRANT syntax. + 2003-01-10 Marc Delisle * tbl_change.php3: bug 665885, wrong back link after sql error * lang/spanish: update, thanks to Dr. med. Daniel Hinostroza C. diff --git a/server_common.inc.php3 b/server_common.inc.php3 index cc47cd307..d84f3ad11 100644 --- a/server_common.inc.php3 +++ b/server_common.inc.php3 @@ -37,16 +37,9 @@ $err_url = 'main.php3' . $url_query; */ require('./header.inc.php3'); -/** - * Displays a message - */ -if (!empty($message)) { - PMA_showMessage($message); -} - /** * Checks for superuser privileges */ $is_superuser = @PMA_mysql_query('USE mysql', $userlink); -?> +?> \ No newline at end of file diff --git a/server_links.inc.php3 b/server_links.inc.php3 index 208c2012d..b7f4c940a 100644 --- a/server_links.inc.php3 +++ b/server_links.inc.php3 @@ -10,8 +10,7 @@ $server_links_count_tabs = 0; /** - * If coming from a Show MySQL link on the home page, - * put something in $sub_part + * Put something in $sub_part */ if (!isset($sub_part)) { $sub_part = ''; @@ -27,6 +26,14 @@ if ($is_superuser) { } +/** + * Displays a message + */ +if (!empty($message)) { + PMA_showMessage($message); +} + + /** * Displays tab links */ @@ -50,4 +57,3 @@ echo PMA_printTab($strServerTabProcesslist, 'server_processlist.php3', $url_quer
- diff --git a/server_privileges.php3 b/server_privileges.php3 index 7ddabd0a4..8c03af3f3 100644 --- a/server_privileges.php3 +++ b/server_privileges.php3 @@ -4,15 +4,26 @@ /** - * Gets some core libraries + * Does the common work */ -if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) { - include('./libraries/grab_globals.lib.php3'); -} -if (!defined('PMA_COMMON_LIB_INCLUDED')) { - include('./libraries/common.lib.php3'); +$js_to_run = 'server_privileges.js'; +require('./server_common.inc.php3'); + + +/** + * Checks if the user is allowed to do what he tries to... + */ +if (!$is_superuser) { + include('./server_links.inc.php3'); + echo '

' . "\n" + . ' ' . $strPrivileges . "\n" + . '

' . "\n" + . $strNoPrivileges . "\n"; + include('./footer.inc.php3'); + exit; } + /** * Extracts the privilege information of a priv table row * @@ -289,6 +300,7 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = echo $spaces . '' . "\n"; } // end of the 'PMA_displayPrivTable()' function + /** * Adds a user */ @@ -322,21 +334,6 @@ if (!empty($adduser_submit)) { } else { if (PMA_MYSQL_INT_VERSION >= 32211) { $real_sql_query = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON *.* TO "' . $username . '"@"' . $hostname . '"'; - if ((isset($Grant_priv) && $Grant_priv == 'Y') || isset($max_questions) || isset($max_connections) || isset($max_updates)) { - $real_sql_query .= 'WITH'; - if (isset($Grant_priv) && $Grant_priv == 'Y') { - $real_sql_query .= ' GRANT OPTION'; - } - if (isset($max_questions)) { - $real_sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions; - } - if (isset($max_connections)) { - $real_sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections; - } - if (isset($max_updates)) { - $real_sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates; - } - } if ($pred_password != 'none') { $pma_pw_hidden = ''; for ($i = 0; $i < strlen($pma_pw); $i++) { @@ -347,6 +344,28 @@ if (!empty($adduser_submit)) { } else { $sql_query = $real_sql_query; } + if ((isset($Grant_priv) && $Grant_priv == 'Y') || isset($max_questions) || isset($max_connections) || isset($max_updates)) { + $real_sql_query .= 'WITH'; + $sql_query .= 'WITH'; + if (isset($Grant_priv) && $Grant_priv == 'Y') { + $real_sql_query .= ' GRANT OPTION'; + $sql_query .= ' GRANT OPTION'; + } + if (isset($max_questions)) { + $real_sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions; + $sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions; + } + if (isset($max_connections)) { + $real_sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections; + $sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections; + } + if (isset($max_updates)) { + $real_sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates; + $sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates; + } + } + $real_sql_query .= ';'; + $sql_query .= ';'; PMA_mysql_query($real_sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink)); unset($real_sql_query); $message = $strAddUserMessage; @@ -376,6 +395,7 @@ if (!empty($adduser_submit)) { } } + /** * Updates privileges */ @@ -427,6 +447,7 @@ if (!empty($update_privs)) { } } + /** * Revokes Privileges */ @@ -450,6 +471,7 @@ if (!empty($revokeall)) { } } + /** * Updates the password */ @@ -477,12 +499,11 @@ if (!empty($change_pw)) { } } + /** * Deletes users */ if (!empty($delete)) { - PMA_mysql_query('USE `mysql`;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'USE `mysql`;'); - $is_superuser = TRUE; $queries = array(); for ($i = 0; isset($selected_usr[$i]); $i++) { list($this_user, $this_host) = explode('@', $selected_usr[$i]); @@ -520,7 +541,8 @@ if (!empty($delete)) { $message = $strError . ': ' . $strDeleteNoUsersSelected; } else { if ($mode == 3) { - $queries[] = '# ' . $strReloadingThePrivileges . ' ...' . "\n" . 'FLUSH PRIVILEGES;'; + $queries[] = '# ' . $strReloadingThePrivileges . ' ...'; + $queries[] = 'FLUSH PRIVILEGES;'; } while (list(, $sql_query) = each($queries)) { if (substr($sql_query, 0, 1) != '#') { @@ -533,6 +555,7 @@ if (!empty($delete)) { unset($queries); } + /** * Reloads the privilege tables into memory */ @@ -545,29 +568,16 @@ if (!empty($flush_privileges)) { } } -/** - * Does the common work - */ -$js_to_run = 'server_privileges.js'; -require('./server_common.inc.php3'); /** * Displays the links */ require('./server_links.inc.php3'); -/** - * Checks if the user is allowed to do what he tries to... - */ -if (!$is_superuser) { - echo '

' . "\n" - . ' ' . $strPrivileges . "\n" - . '

' . "\n" - . $strNoPrivileges . "\n"; - include('./footer.inc.php3'); - exit; -} +/** + * Displays the page + */ if (empty($adduser)) { if (!isset($username)) { // No username is given --> display the overview @@ -684,7 +694,8 @@ if (empty($adduser)) { . ' ' . "\n" . '' . "\n" . '
' . "\n" - . ' ' . sprintf($strFlushPrivilegesNote, '', ''); + . ' ' . sprintf($strFlushPrivilegesNote, '', '') . "\n" + . '
' . "\n"; } } else if (isset($username)) { if (!isset($hostname)) { @@ -901,7 +912,7 @@ if (empty($adduser)) { . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" @@ -926,11 +937,9 @@ if (empty($adduser)) { unset($thishost); } } - if (empty($thishost)) { - echo ' onchange="if (this.value == \'any\') { hostname.value = \'%\'; } else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n"; - } else { - echo ' onchange="if (this.value == \'any\') { hostname.value = \'%\'; } else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } else if (this.value == \'thishost\') { hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; } else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n"; - } + echo ' onchange="if (this.value == \'any\') { hostname.value = \'%\'; } else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } ' + . (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; } ') + . 'else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n"; unset($row); echo ' ' . "\n" . ' ' . "\n"; @@ -955,7 +964,7 @@ if (empty($adduser)) { . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" @@ -980,9 +989,11 @@ if (empty($adduser)) { . '' . "\n"; } // end if (empty($adduser)) ... else ... + /** * Displays the footer */ +echo "\n\n"; require('./footer.inc.php3'); ?> \ No newline at end of file diff --git a/server_processlist.php3 b/server_processlist.php3 index 89059432a..3b644a656 100644 --- a/server_processlist.php3 +++ b/server_processlist.php3 @@ -4,14 +4,10 @@ /** - * Gets some core libraries + * Does the common work */ -if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) { - include('./libraries/grab_globals.lib.php3'); -} -if (!defined('PMA_COMMON_LIB_INCLUDED')) { - include('./libraries/common.lib.php3'); -} +require('./server_common.inc.php3'); + /** * Kills a selected process @@ -25,16 +21,13 @@ if (!empty($kill)) { } } -/** - * Does the common work - */ -require('./server_common.inc.php3'); /** * Displays the links */ require('./server_links.inc.php3'); + /** * Displays the sub-page heading */ @@ -42,6 +35,7 @@ echo '

' . "\n" . ' ' . $strProcesslist . "\n" . '

' . "\n"; + /** * Checks if the user is allowed to do what he tries to... */ @@ -51,6 +45,7 @@ if (!$is_superuser && !$cfg['ShowMysqlVars']) { exit; } + /** * Sends the query and buffers the result */ @@ -63,6 +58,7 @@ while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) { unset($res); unset($row); + /** * Displays the page */ @@ -103,6 +99,7 @@ while (list($name, $value) = each($serverProcesses)) { ' . "\n" . ' ' . $strServerStatus . "\n" . '' . "\n"; + /** * Checks if the user is allowed to do what he tries to... */ @@ -29,6 +32,7 @@ if (!$is_superuser && !$cfg['ShowMysqlInfo']) { exit; } + /** * Sends the query and buffers the result */ @@ -40,6 +44,7 @@ while ($row = PMA_mysql_fetch_row($res)) { unset($res); unset($row); + /** * Displays the page */ @@ -235,6 +240,7 @@ unset($useBgcolorOne); ' . "\n" . ' ' . $strServerVars . "\n" . '' . "\n"; + /** * Checks if the user is allowed to do what he tries to... */ @@ -29,8 +32,9 @@ if (!$is_superuser && !$cfg['ShowMysqlVars']) { exit; } + /** - * Sends the queries and buffers the result + * Sends the queries and buffers the results */ if (PMA_MYSQL_INT_VERSION >= 40003) { $res = @PMA_mysql_query('SHOW SESSION VARIABLES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW SESSION VARIABLES;'); @@ -53,6 +57,7 @@ if (PMA_MYSQL_INT_VERSION >= 40003) { unset($res); unset($row); + /** * Displays the page */ @@ -93,6 +98,7 @@ while (list($name, $value) = each($serverVars)) {