From 64bd56dfba419951886c092c6d0ba6948d05ce95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 26 Sep 2005 19:03:11 +0000 Subject: Support for browsing selected columns (RFE #1275909). --- server_privileges.php | 1199 ++++++++++++++++++++++++------------------------- 1 file changed, 599 insertions(+), 600 deletions(-) (limited to 'server_privileges.php') diff --git a/server_privileges.php b/server_privileges.php index 7884cfc744..82369b6479 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -29,9 +29,9 @@ if (!$is_superuser) { require('./server_links.inc.php'); echo '

' . "\n" . ' ' . ($GLOBALS['cfg']['MainPageIconic'] ? '' : '') - . ' ' . $strPrivileges . "\n" + . ' ' . $GLOBALS['strPrivileges'] . "\n" . '

' . "\n" - . $strNoPrivileges . "\n"; + . $GLOBALS['strNoPrivileges'] . "\n"; require_once('./footer.inc.php'); } @@ -39,17 +39,15 @@ if (!$is_superuser) { /** * Extracts the privilege information of a priv table row * - * @param array the row - * @param boolean add tag with tooltips + * @param array $row the row + * @param boolean $enableHTML add tag with tooltips * - * @global ressource the database connection + * @global ressource $user_link the database connection * * @return array */ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE) { - global $userlink; - $grants = array( array('Select_priv', 'SELECT', $GLOBALS['strPrivDescSelect']), array('Insert_priv', 'INSERT', $GLOBALS['strPrivDescInsert']), @@ -70,10 +68,19 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE) array('Lock_tables_priv', 'LOCK TABLES', $GLOBALS['strPrivDescLockTables']), array('Execute_priv', 'EXECUTE', $GLOBALS['strPrivDescExecute']), array('Repl_slave_priv', 'REPLICATION SLAVE', $GLOBALS['strPrivDescReplSlave']), - array('Repl_client_priv', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient']) + array('Repl_client_priv', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient']), + array('Create_view_priv', 'CREATE VIEW', $GLOBALS['strPrivDescCreateView']), + // for table privs: + array('Create View_priv', 'CREATE VIEW', $GLOBALS['strPrivDescCreateView']), + array('Show_view_priv', 'SHOW VIEW', $GLOBALS['strPrivDescShowView']), + // for table privs: + array('Show view_priv', 'SHOW VIEW', $GLOBALS['strPrivDescShowView']), + array('Create_routine_priv', 'CREATE ROUTINE', $GLOBALS['strPrivDescCreateRoutine']), + array('Alter_routine_priv', 'ALTER ROUTINE', $GLOBALS['strPrivDescAlterRoutine']), + array('Create_user_priv', 'CREATE USER', $GLOBALS['strPrivDescCreateUser']) ); if (!empty($row) && isset($row['Table_priv'])) { - $res = PMA_DBI_query('SHOW COLUMNS FROM `tables_priv` LIKE \'Table_priv\';', $userlink); + $res = PMA_DBI_query('SHOW COLUMNS FROM `mysql`.`tables_priv` LIKE \'Table_priv\';', $GLOBALS['userlink']); $row1 = PMA_DBI_fetch_assoc($res); PMA_DBI_free_result($res); $av_grants = explode ('\',\'' , substr($row1['Type'], 5, strlen($row1['Type']) - 7)); @@ -92,13 +99,13 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE) if ((!empty($row) && isset($row[$current_grant[0]])) || (empty($row) && isset($GLOBALS[$current_grant[0]]))) { if ((!empty($row) && $row[$current_grant[0]] == 'Y') || (empty($row) && ($GLOBALS[$current_grant[0]] == 'Y' || (is_array($GLOBALS[$current_grant[0]]) && count($GLOBALS[$current_grant[0]]) == $GLOBALS['column_count'] && empty($GLOBALS[$current_grant[0] . '_none']))))) { if ($enableHTML) { - $privs[] = '' . str_replace(' ', ' ', $current_grant[1]) . ''; + $privs[] = '' . $current_grant[1] . ''; } else { $privs[] = $current_grant[1]; } } else if (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) { if ($enableHTML) { - $priv_string = '' . str_replace(' ', ' ', $current_grant[1]) . ''; + $priv_string = '' . $current_grant[1] . ''; } else { $priv_string = $current_grant[1]; } @@ -116,7 +123,7 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE) } } else if ($allPrivileges && (!isset($GLOBALS['grant_count']) || count($privs) == $GLOBALS['grant_count'])) { if ($enableHTML) { - $privs = array('ALL PRIVILEGES'); + $privs = array('ALL PRIVILEGES'); } else { $privs = array('ALL PRIVILEGES'); } @@ -124,39 +131,62 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE) return $privs; } // end of the 'PMA_extractPrivInfo()' function + +/** + * Displays on which column(s) a table-specific privilege is granted + */ +function PMA_display_column_privs($spaces, $columns, $row, $name_for_select, $priv_for_header, $name, $name_for_dfn, $name_for_current) { + + echo $spaces . '
' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . $GLOBALS['strOr'] . '' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '
' . "\n"; +} // end function + /** * Displays the privileges form table * - * @param string the database - * @param string the table - * @param boolean wheather to display the submit button or not - * @param int the indenting level of the code + * @param string $db the database + * @param string $table the table + * @param boolean $submit wheather to display the submit button or not + * @param int $indent the indenting level of the code * - * @global array the phpMyAdmin configuration - * @global ressource the database connection + * @global array $cfg the phpMyAdmin configuration + * @global ressource $user_link the database connection * * @return void */ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = 0) { - global $cfg, $userlink, $url_query, $checkall; - if ($db == '*') { $table = '*'; } - $spaces = ''; - for ($i = 0; $i < $indent; $i++) { - $spaces .= ' '; - } + $spaces = str_repeat( ' ', $indent ); + if (isset($GLOBALS['username'])) { $username = $GLOBALS['username']; $hostname = $GLOBALS['hostname']; if ($db == '*') { - $sql_query = 'SELECT * FROM `user` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ';'; + $sql_query = 'SELECT * FROM `mysql`.`user` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ';'; } else if ($table == '*') { - $sql_query = 'SELECT * FROM `db` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($db, 'quoted') . ';'; + $sql_query = 'SELECT * FROM `mysql`.`db` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($db, 'quoted') . ';'; } else { - $sql_query = 'SELECT `Table_priv` FROM `tables_priv` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' .PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($db, 'quoted') . ' AND ' . PMA_convert_using('Table_name') . ' = ' . PMA_convert_using($table, 'quoted') . ';'; + $sql_query = 'SELECT `Table_priv` FROM `mysql`.`tables_priv` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' .PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($db, 'quoted') . ' AND ' . PMA_convert_using('Table_name') . ' = ' . PMA_convert_using($table, 'quoted') . ';'; } $res = PMA_DBI_query($sql_query); $row = PMA_DBI_fetch_assoc($res); @@ -183,12 +213,18 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = } } if (isset($row['Table_priv'])) { - $res = PMA_DBI_query('SHOW COLUMNS FROM `tables_priv` LIKE \'Table_priv\';', $userlink); + $res = PMA_DBI_query('SHOW COLUMNS FROM `mysql`.`tables_priv` LIKE \'Table_priv\';', $GLOBALS['userlink']); + // note: in MySQL 5.0.3 we get "Create View', 'Show view'; + // the View for Create is spelled with uppercase V + // the view for Show is spelled with lowercase v + // and there is a space between the words + $row1 = PMA_DBI_fetch_assoc($res); PMA_DBI_free_result($res); $av_grants = explode ('\',\'' , substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3)); unset($res, $row1); $users_grants = explode(',', $row['Table_priv']); + foreach ($av_grants as $current_grant) { $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N'; } @@ -208,8 +244,10 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = } 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 + if (!empty($columns)) { - $res = PMA_DBI_QUERY('SELECT `Column_name`, `Column_priv` FROM `columns_priv` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($db, 'quoted') . ' AND ' . PMA_convert_using('Table_name') . ' = ' . PMA_convert_using($table, 'quoted') . ';'); + $res = PMA_DBI_QUERY('SELECT `Column_name`, `Column_priv` FROM `mysql`.`columns_priv` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($db, 'quoted') . ' AND ' . PMA_convert_using('Table_name') . ' = ' . PMA_convert_using($table, 'quoted') . ';'); while ($row1 = PMA_DBI_fetch_row($res)) { $row1[1] = explode(',', $row1[1]); @@ -221,99 +259,60 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = unset($res); unset($row1); unset($current); + echo $spaces . '' . "\n" . $spaces . '' . "\n" - . $spaces . '' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n"; - list($current_grant, $current_grant_value) = each($row); - while (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) { - list($current_grant, $current_grant_value) = each($row); - } - echo $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n"; - $rowspan = count($row) - 5; - echo $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n"; - unset($rowspan); - list($current_grant, $current_grant_value) = each($row); - while (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) { - list($current_grant, $current_grant_value) = each($row); - } - echo $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n"; - while (list($current_grant, $current_grant_value) = each($row)) { + . $spaces . '
' . "\n" + . $spaces . ' ' . $GLOBALS['strTblPrivileges'] . '' . "\n" + . $spaces . '

' . $GLOBALS['strEnglishPrivileges'] . '

' . "\n"; + + + // privs that are attached to a specific column + PMA_display_column_privs($spaces, $columns, $row, 'Select_priv', 'SELECT', 'select', $GLOBALS['strPrivDescSelect'], 'Select'); + + PMA_display_column_privs($spaces, $columns, $row, 'Insert_priv', 'INSERT', 'insert', $GLOBALS['strPrivDescInsert'], 'Insert'); + + PMA_display_column_privs($spaces, $columns, $row, 'Update_priv', 'UPDATE', 'update', $GLOBALS['strPrivDescUpdate'], 'Update'); + + PMA_display_column_privs($spaces, $columns, $row, 'References_priv', 'REFERENCES', 'references', $GLOBALS['strPrivDescReferences'], 'References'); + + // privs that are not attached to a specific column + + foreach($row as $current_grant => $current_grant_value) { if (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) { continue; } - echo $spaces . '
' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n"; - } + // make a substitution to match the messages variables; + // also we must substitute the grant we get, because we can't generate + // a form variable containing blanks (those would get changed to + // an underscore when receiving the POST) + if ($current_grant == 'Create View_priv') { + $tmp_current_grant = 'CreateView_priv'; + $current_grant = 'Create_view_priv'; + } elseif ($current_grant == 'Show view_priv') { + $tmp_current_grant = 'ShowView_priv'; + $current_grant = 'Show_view_priv'; + } else { + $tmp_current_grant = $current_grant; + } + + echo $spaces . '
' . "\n" + . $spaces . '
' . "\n" + . $spaces . ' ' . "\n"; + + echo $spaces . ' ' . "\n" + . $spaces . '
' . "\n"; + } // end foreach() + + echo $spaces . '
' . "\n"; + } else { + + // g l o b a l o r d b - s p e c i f i c + // + // d a t a $privTable[0] = array( array('Select', 'SELECT', $GLOBALS['strPrivDescSelect']), array('Insert', 'INSERT', $GLOBALS['strPrivDescInsert']), @@ -323,6 +322,8 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = if ($db == '*') { $privTable[0][] = array('File', 'FILE', $GLOBALS['strPrivDescFile']); } + + // s t r u c t u r e $privTable[1] = array( array('Create', 'CREATE', ($table == '*' ? $GLOBALS['strPrivDescCreateDb'] : $GLOBALS['strPrivDescCreateTbl'])), array('Alter', 'ALTER', $GLOBALS['strPrivDescAlter']), @@ -330,8 +331,27 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = array('Drop', 'DROP', ($table == '*' ? $GLOBALS['strPrivDescDropDb'] : $GLOBALS['strPrivDescDropTbl'])) ); if (isset($row['Create_tmp_table_priv'])) { - $privTable[1][] = array('Create_tmp_table', 'CREATE TEMPORARY TABLES', $GLOBALS['strPrivDescCreateTmpTable']); + $privTable[1][] = array('Create_tmp_table', 'CREATE TEMPORARY TABLES', $GLOBALS['strPrivDescCreateTmpTable']); + } + // this one is for a db-specific priv: Create_view_priv + if (isset($row['Create_view_priv'])) { + $privTable[1][] = array('Create_view', 'CREATE VIEW', $GLOBALS['strPrivDescCreateView']); + } + // this one is for a table-specific priv: Create View_priv + if (isset($row['Create View_priv'])) { + $privTable[1][] = array('Create View', 'CREATE VIEW', $GLOBALS['strPrivDescCreateView']); + } + if (isset($row['Show_view_priv'])) { + $privTable[1][] = array('Show_view', 'SHOW VIEW', $GLOBALS['strPrivDescShowView']); + } + if (isset($row['Create_routine_priv'])) { + $privTable[1][] = array('Create_routine', 'CREATE ROUTINE', $GLOBALS['strPrivDescCreateRoutine']); + } + if (isset($row['Alter_routine_priv'])) { + $privTable[1][] = array('Alter_routine', 'ALTER ROUTINE', $GLOBALS['strPrivDescAlterRoutine']); } + + // a d m i n i s t r a t i o n $privTable[2] = array(); if (isset($row['Grant_priv'])) { $privTable[2][] = array('Grant', 'GRANT', $GLOBALS['strPrivDescGrant']); @@ -346,11 +366,11 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = $privTable[2][] = array('Reload', 'RELOAD', $GLOBALS['strPrivDescReload']); $privTable[2][] = array('Shutdown', 'SHUTDOWN', $GLOBALS['strPrivDescShutdown']); if (isset($row['Show_db_priv'])) { - $privTable[2][] = array('Show_db', 'SHOW DATABASES', $GLOBALS['strPrivDescShowDb']); + $privTable[2][] = array('Show_db', 'SHOW DATABASES', $GLOBALS['strPrivDescShowDb']); } } if (isset($row['Lock_tables_priv'])) { - $privTable[2][] = array('Lock_tables', 'LOCK TABLES', $GLOBALS['strPrivDescLockTables']); + $privTable[2][] = array('Lock_tables', 'LOCK TABLES', $GLOBALS['strPrivDescLockTables']); } $privTable[2][] = array('References', 'REFERENCES', $GLOBALS['strPrivDescReferences']); if ($db == '*') { @@ -358,76 +378,80 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = $privTable[2][] = array('Execute', 'EXECUTE', $GLOBALS['strPrivDescExecute']); } if (isset($row['Repl_client_priv'])) { - $privTable[2][] = array('Repl_client', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient']); + $privTable[2][] = array('Repl_client', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient']); } if (isset($row['Repl_slave_priv'])) { - $privTable[2][] = array('Repl_slave', 'REPLICATION SLAVE', $GLOBALS['strPrivDescReplSlave']); + $privTable[2][] = array('Repl_slave', 'REPLICATION SLAVE', $GLOBALS['strPrivDescReplSlave']); + } + if (isset($row['Create_user_priv'])) { + $privTable[2][] = array('Create_user', 'CREATE USER', $GLOBALS['strPrivDescCreateUser']); } } echo $spaces . '' . "\n" - . $spaces . '
 ' . $GLOBALS['strTblPrivileges'] . ' 
' . $GLOBALS['strEnglishPrivileges'] . '
 SELECT  INSERT  UPDATE  REFERENCES 
' . "\n" - . $spaces . '
' . "\n" - . $spaces . ' ' . $GLOBALS['strOr'] . '
' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '
' . "\n" - . $spaces . '
' . "\n" - . $spaces . ' ' . $GLOBALS['strOr'] . '
' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '
' . "\n" - . $spaces . '
' . "\n" - . $spaces . ' ' . $GLOBALS['strOr'] . '
' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '
' . "\n" - . $spaces . '
' . "\n" - . $spaces . ' ' . $GLOBALS['strOr'] . '
' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '
' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n"; - $limitTable = FALSE; - for ($i = 0; isset($privTable[0][$i]) || isset($privTable[1][$i]) || isset($privTable[2][$i]); $i++) { - echo $spaces . ' ' . "\n"; - for ($j = 0; $j < 3; $j++) { - if (isset($privTable[$j][$i])) { - echo $spaces . ' ' . "\n" - . $spaces . ' ' . "\n"; - } else if ($db == '*' && !isset($privTable[0][$i]) && !isset($privTable[1][$i]) - && isset($row['max_questions']) && isset($row['max_updates']) && isset($row['max_connections']) - && !$limitTable) { - echo $spaces . ' ' . "\n"; - $limitTable = TRUE; - } else if (!$limitTable) { - echo $spaces . ' ' . "\n"; - } - } + . $spaces . '
' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . ($db == '*' ? $GLOBALS['strGlobalPrivileges'] : ($table == '*' ? $GLOBALS['strDbPrivileges'] : $GLOBALS['strTblPrivileges'])) . "\n" + . $spaces . ' ( ' . $GLOBALS['strCheckAll'] . ' /' . "\n" + . $spaces . ' ' . $GLOBALS['strUncheckAll'] . ' )' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '

' . $GLOBALS['strEnglishPrivileges'] . '

' . "\n" + . $spaces . '

' . "\n" + . $spaces . ' ' . $GLOBALS['strData'] . '' . "\n"; + foreach ( $privTable[0] as $priv ) + { + echo $spaces . '
' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '
' . "\n"; + } + echo $spaces . '
' . "\n" + . $spaces . '
' . "\n" + . $spaces . ' ' . $GLOBALS['strStructure'] . '' . "\n"; + foreach ( $privTable[1] as $priv ) + { + echo $spaces . '
' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '
' . "\n"; + } + echo $spaces . '
' . "\n" + . $spaces . '
' . "\n" + . $spaces . ' ' . $GLOBALS['strAdministration'] . '' . "\n"; + foreach ( $privTable[2] as $priv ) + { + echo $spaces . '
' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '
' . "\n"; } - echo $spaces . '
' . "\n"; + + echo $spaces . ' ' . "\n"; + // The "Resource limits" box is not displayed for db-specific privs + if ($db == '*') { + echo $spaces . '
' . "\n" + . $spaces . ' ' . $GLOBALS['strResourceLimits'] . '' . "\n" + . $spaces . '

' . $GLOBALS['strZeroRemovesTheLimit'] . '

' . "\n" + . $spaces . '
' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '
' . "\n" + . $spaces . '
' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '
' . "\n" + . $spaces . '
' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '
' . "\n" + . $spaces . '
' . "\n"; + } } + echo $spaces . '' . "\n"; if ($submit) { - echo $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n"; + echo $spaces . '' . "\n"; } - echo $spaces . '
 ' . ($db == '*' ? $GLOBALS['strGlobalPrivileges'] : ($table == '*' ? $GLOBALS['strDbPrivileges'] : $GLOBALS['strTblPrivileges'])) . ' 
' . $GLOBALS['strEnglishPrivileges'] . '
' . "\n" - . $spaces . ' ' . $GLOBALS['strCheckAll'] . '' . "\n" - . $spaces . '    ' . "\n" - . $spaces . ' ' . $GLOBALS['strUncheckAll'] . '
 ' . $GLOBALS['strData'] . '  ' . $GLOBALS['strStructure'] . '  ' . $GLOBALS['strAdministration'] . ' 
' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '
 ' . $GLOBALS['strResourceLimits'] . ' 
' . $GLOBALS['strZeroRemovesTheLimit'] . '
' . "\n" - . $spaces . '
 
' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '
' . "\n"; } // end of the 'PMA_displayPrivTable()' function @@ -435,47 +459,40 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = * Displays the fields used by the "new user" form as well as the * "change login information / copy user" form. * - * @param string are we creating a new user or are we just changing one? - * (allowed values: 'new', 'change') - * @param int the indenting level of the code + * @param string $mode are we creating a new user or are we just + * changing one? (allowed values: 'new', 'change') + * @param int $indent the indenting level of the code * - * @global array the phpMyAdmin configuration - * @global ressource the database connection + * @global array $cfg the phpMyAdmin configuration + * @global ressource $user_link the database connection * * @return void */ -function PMA_displayLoginInformationFields($mode = 'new', $indent = 0) +function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) { - global $cfg, $userlink; - $spaces = ''; - for ($i = 0; $i < $indent; $i++) { - $spaces .= ' '; - } - echo $spaces . '' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '' . "\n" - . $spaces . '' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '' . "\n" + . $spaces . '' . "\n" + . $spaces . '' . "\n" + . $spaces . '
' . "\n" + . $spaces . '' . "\n" + . $spaces . '' . "\n" + . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '' . "\n" - . $spaces . '' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" + . $spaces . '' . "\n" + . $spaces . '' . "\n" + . $spaces . '
' . "\n" + . $spaces . '
' . "\n" + . $spaces . '' . "\n" + . $spaces . '' . "\n" + . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '' . "\n" - . $spaces . '' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '  ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '' . "\n" - . $spaces . '' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '  ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . ' ' . "\n" - . $spaces . '' . "\n"; + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '' . "\n" + . $spaces . '' . "\n" + . $spaces . '
' . "\n" + . $spaces . '
' . "\n" + . $spaces . '' . "\n" + . $spaces . '' . "\n" + . $spaces . '' . "\n" + . $spaces . '
' . "\n" + . $spaces . '
' . "\n" + . $spaces . '' . "\n" + . $spaces . '' . "\n" + . $spaces . ' ' . "\n" + . $spaces . ' ' . "\n" + . $spaces . '' . "\n" + . $spaces . '' . "\n" + . $spaces . '
' . "\n" + . $spaces . '' . "\n"; } // end of the 'PMA_displayUserAndHostFields()' function @@ -573,7 +577,7 @@ if (!empty($change_copy)) { $user_host_condition = ' WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($old_username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($old_hostname, 'quoted') . ';'; $res = PMA_DBI_query('SELECT * FROM `mysql`.`user` ' . $user_host_condition); if (!$res) { - $message = $strNoUsersFound; + $message = $GLOBALS['strNoUsersFound']; unset($change_copy); } else { $row = PMA_DBI_fetch_assoc($res); @@ -618,10 +622,10 @@ if (!empty($adduser_submit) || !empty($change_copy)) { unset($row); break; } - $res = PMA_DBI_query('SELECT \'foo\' FROM `user` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ';', NULL, PMA_DBI_QUERY_STORE); + $res = PMA_DBI_query('SELECT \'foo\' FROM `mysql`.`user` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ';', NULL, PMA_DBI_QUERY_STORE); if (PMA_DBI_num_rows($res) == 1) { PMA_DBI_free_result($res); - $message = sprintf($strUserAlreadyExists, '[i]\'' . $username . '\'@\'' . $hostname . '\'[/i]'); + $message = sprintf($GLOBALS['strUserAlreadyExists'], '[i]\'' . $username . '\'@\'' . $hostname . '\'[/i]'); $adduser = 1; } else { PMA_DBI_free_result($res); @@ -665,7 +669,7 @@ if (!empty($adduser_submit) || !empty($change_copy)) { $sql_query .= ';'; if (empty($change_copy)) { PMA_DBI_try_query($real_sql_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query); - $message = $strAddUserMessage; + $message = $GLOBALS['strAddUserMessage']; } else { $queries[] = $real_sql_query; // we put the query containing the hidden password in @@ -689,7 +693,7 @@ if (!empty($change_copy)) { $queries[] = 'GRANT ' . join(', ', PMA_extractPrivInfo($row)) . ' ON `' . $row['Db'] . '`.* TO \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\'' . ($row['Grant_priv'] == 'Y' ? ' WITH GRANT OPTION' : '') . ';'; } PMA_DBI_free_result($res); - $res = PMA_DBI_query('SELECT `Db`, `Table_name`, `Table_priv` FROM `mysql`.`tables_priv`' . $user_host_condition, $userlink, PMA_DBI_QUERY_STORE); + $res = PMA_DBI_query('SELECT `Db`, `Table_name`, `Table_priv` FROM `mysql`.`tables_priv`' . $user_host_condition, $GLOBALS['userlink'], PMA_DBI_QUERY_STORE); while ($row = PMA_DBI_fetch_assoc($res)) { $res2 = PMA_DBI_QUERY('SELECT `Column_name`, `Column_priv` FROM `mysql`.`columns_priv` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($old_username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($old_hostname, 'quoted') . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($row['Db'], 'quoted') . ' AND ' . PMA_convert_using('Table_name') . ' = ' . PMA_convert_using($row['Table_name'], 'quoted') . ';', NULL, PMA_DBI_QUERY_STORE); @@ -798,7 +802,7 @@ if (!empty($update_privs)) { $sql_query = (isset($sql_query0) ? $sql_query0 . ' ' : '') . (isset($sql_query1) ? $sql_query1 . ' ' : '') . $sql_query2; - $message = sprintf($strUpdatePrivMessage, '\'' . $username . '\'@\'' . $hostname . '\''); + $message = sprintf($GLOBALS['strUpdatePrivMessage'], '\'' . $username . '\'@\'' . $hostname . '\''); } @@ -814,7 +818,7 @@ if (!empty($revokeall)) { unset($sql_query1); } $sql_query = $sql_query0 . (isset($sql_query1) ? ' ' . $sql_query1 : ''); - $message = sprintf($strRevokeMessage, '\'' . $username . '\'@\'' . $hostname . '\''); + $message = sprintf($GLOBALS['strRevokeMessage'], '\'' . $username . '\'@\'' . $hostname . '\''); if (empty($tablename)) { unset($dbname); } else { @@ -830,11 +834,11 @@ if (!empty($change_pw)) { if ($nopass == 1) { $sql_query = 'SET PASSWORD FOR \'' . $username . '\'@\'' . $hostname . '\' = \'\';'; PMA_DBI_query($sql_query); - $message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\''); + $message = sprintf($GLOBALS['strPasswordChanged'], '\'' . $username . '\'@\'' . $hostname . '\''); } else if (empty($pma_pw) || empty($pma_pw2)) { - $message = $strPasswordEmpty; + $message = $GLOBALS['strPasswordEmpty']; } else if ($pma_pw != $pma_pw2) { - $message = $strPasswordNotSame; + $message = $GLOBALS['strPasswordNotSame']; } else { $hidden_pw = ''; for ($i = 0; $i < strlen($pma_pw); $i++) { @@ -843,7 +847,7 @@ if (!empty($change_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($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\''); + $message = sprintf($GLOBALS['strPasswordChanged'], '\'' . $username . '\'@\'' . $hostname . '\''); } } @@ -862,7 +866,7 @@ if (!empty($delete) || (!empty($change_copy) && $mode < 4)) { } for ($i = 0; isset($selected_usr[$i]); $i++) { list($this_user, $this_host) = explode($user_host_separator, $selected_usr[$i]); - $queries[] = '# ' . sprintf($strDeleting, '\'' . $this_user . '\'@\'' . $this_host . '\'') . ' ...'; + $queries[] = '# ' . sprintf($GLOBALS['strDeleting'], '\'' . $this_user . '\'@\'' . $this_host . '\'') . ' ...'; if ($mode == 2) { // The SHOW GRANTS query may fail if the user has not been loaded // into memory @@ -884,34 +888,36 @@ if (!empty($delete) || (!empty($change_copy) && $mode < 4)) { } unset($res); } - $queries[] = 'DELETE FROM `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') . ';'; + $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 - // `db`, `tables_priv` and `columns_priv` tables manually... + // `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 `db`' . $user_host_condition; - $queries[] = 'DELETE FROM `tables_priv`' . $user_host_condition; - $queries[] = 'DELETE FROM `columns_priv`' . $user_host_condition; + $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)) { - $message = $strError . ': ' . $strDeleteNoUsersSelected; + $message = $GLOBALS['strError'] . ': ' . $GLOBALS['strDeleteNoUsersSelected']; } else { if ($mode == 3) { - $queries[] = '# ' . $strReloadingThePrivileges . ' ...'; + $queries[] = '# ' . $GLOBALS['strReloadingThePrivileges'] . ' ...'; $queries[] = 'FLUSH PRIVILEGES;'; } foreach ($queries as $sql_query) { if ($sql_query{0} != '#') { - PMA_DBI_query($sql_query, $userlink); + PMA_DBI_query($sql_query, $GLOBALS['userlink']); } } $sql_query = join("\n", $queries); - $message = $strUsersDeleted; + $message = $GLOBALS['strUsersDeleted']; } unset($queries); } @@ -934,7 +940,7 @@ if (!empty($change_copy)) { $queries[$tmp_count] = $queries_for_display[$tmp_count]; } } - $message = $strSuccess; + $message = $GLOBALS['strSuccess']; $sql_query = join("\n", $queries); } @@ -945,14 +951,24 @@ if (!empty($change_copy)) { if (!empty($flush_privileges)) { $sql_query = 'FLUSH PRIVILEGES;'; PMA_DBI_query($sql_query); - $message = $strPrivilegesReloaded; + $message = $GLOBALS['strPrivilegesReloaded']; } /** * Displays the links */ -require('./server_links.inc.php'); +if (isset($viewing_mode) && $viewing_mode == 'db') { + $db = $checkprivs; + $url_query .= '&goto=db_operations.php'; + + // Gets the database structure + $sub_part = '_structure'; + require('./db_details_db_info.php'); + echo "\n"; +} else { + require('./server_links.inc.php'); +} /** @@ -963,64 +979,59 @@ if (empty($adduser) && empty($checkprivs)) { // No username is given --> display the overview echo '

' . "\n" . ' ' . ($GLOBALS['cfg']['MainPageIconic'] ? '' : '') - . $strUserOverview . "\n" + . $GLOBALS['strUserOverview'] . "\n" . '

' . "\n"; - $oldPrivTables = FALSE; + + $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 = 'SELECT `User`, `Host`, IF(`Password` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . '\'\', \'N\', \'Y\') AS \'Password\', `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv` FROM `user` '; + $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`'; + } - // the strtolower() is because sometimes the User field - // might be BINARY, so LIKE would be case sensitive - if (isset($initial)) { - $sql_query .= " WHERE " . PMA_convert_using('User') - . " LIKE " . PMA_convert_using($initial . '%', 'quoted') - . " OR ". PMA_convert_using('User') - . " LIKE " . PMA_convert_using(strtolower($initial) . '%', 'quoted'); - } + if (PMA_MYSQL_INT_VERSION >= 50003) { + $sql_query .= ', `Create_user_priv`, `Create_routine_priv`, `Alter_routine_priv`'; + } + + $sql_query .= ' FROM `mysql`.`user`'; + + // the strtolower() is because sometimes the User field + // might be BINARY, so LIKE would be case sensitive + if (isset($initial)) { + $sql_query .= " WHERE " . PMA_convert_using('User') + . " LIKE " . PMA_convert_using($initial . '%', 'quoted') + . " OR ". PMA_convert_using('User') + . " LIKE " . PMA_convert_using(strtolower($initial) . '%', 'quoted'); + } - $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;'; - $res = PMA_DBI_try_query($sql_query, NULL, PMA_DBI_QUERY_STORE); + $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 has not enough privileges - // - the privilege tables use a structure of an earlier version. - $oldPrivTables = TRUE; - } - } - if (empty($res) || PMA_MYSQL_INT_VERSION < 40002) { - $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` FROM `user`'; - - if (isset($initial)) { - $sql_query .= " WHERE " . PMA_convert_using('User') - . " LIKE " . PMA_convert_using($initial . '%', 'quoted') - . " OR ". PMA_convert_using('User') - . " LIKE " . PMA_convert_using(strtolower($initial) . '%', 'quoted'); - } + 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 .= ' ORDER BY `User` ASC, `Host` ASC;'; + $sql_query = 'SELECT * FROM `mysql`.`user`'; $res = PMA_DBI_try_query($sql_query, NULL, PMA_DBI_QUERY_STORE); if (!$res) { - // the query failed! This may have two reasons: - // - the user has not enough privileges - // - the privilege tables use a structure of an earlier version. - $oldPrivTables = TRUE; - } - } - if (!$res) { - echo '' . $strNoPrivileges . '' . "\n"; - PMA_DBI_free_result($res); - unset($res); - } else { - if ($oldPrivTables) { + echo '' . $GLOBALS['strNoPrivileges'] . '' . "\n"; + PMA_DBI_free_result($res); + unset($res); + } else { // rabus: This message is hardcoded because I will replace it by // a automatic repair feature soon. echo '
' . "\n" - . ' Warning: Your privilege table structure seem to be older than this MySQL version!
' . "\n" + . ' Warning: Your privilege table structure seems to be older than this MySQL version!
' . "\n" . ' Please run the script mysql_fix_privilege_tables that should be included in your MySQL server distribution to solve this problem!' . "\n" . '

' . "\n"; } + } else { /** * Displays the initials @@ -1034,7 +1045,7 @@ if (empty($adduser) && empty($checkprivs)) { $array_initials[chr($letter_counter + 64)] = FALSE; } - $initials = PMA_DBI_try_query('SELECT DISTINCT UPPER(LEFT(' . PMA_convert_using('User') . ',1)) FROM `user` ORDER BY `User` ASC', NULL, PMA_DBI_QUERY_STORE); + $initials = PMA_DBI_try_query('SELECT DISTINCT UPPER(LEFT(' . PMA_convert_using('User') . ',1)) FROM `mysql`.`user` ORDER BY `User` ASC', NULL, PMA_DBI_QUERY_STORE); while (list($tmp_initial) = PMA_DBI_fetch_row($initials)) { $array_initials[$tmp_initial] = TRUE; } @@ -1050,16 +1061,17 @@ if (empty($adduser) && empty($checkprivs)) { foreach ($array_initials as $tmp_initial => $initial_was_found) { if ($initial_was_found) { - echo '' . $tmp_initial . '' . "\n"; + echo '' . $tmp_initial . '' . "\n"; } else { echo '' . $tmp_initial . ''; } } - echo '[' . $strShowAll . ']' . "\n"; + echo '[' . $GLOBALS['strShowAll'] . ']' . "\n"; echo ''; /** - * Displays the user overview + * Display the user overview + * (if less than 50 users, display them immediately) */ if (isset($initial) || isset($showall) || PMA_DBI_num_rows($res) < 50) { @@ -1069,30 +1081,30 @@ if (empty($adduser) && empty($checkprivs)) { . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . ($cfg['PropertiesIconic'] ? '' : '') . "\n"; + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . ($GLOBALS['cfg']['PropertiesIconic'] ? '' : '') . "\n"; echo ' ' . "\n"; $useBgcolorOne = TRUE; for ($i = 0; $row = PMA_DBI_fetch_assoc($res); $i++) { echo ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n"; $privs = PMA_extractPrivInfo($row, TRUE); - echo ' ' . "\n" - . ' ' . "\n" + . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" + . ' ' . "\n" . ' ' . "\n"; @@ -1104,68 +1116,63 @@ if (empty($adduser) && empty($checkprivs)) { echo ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" - . '
 ' . $strUser . '  ' . $strHost . '  ' . $strPassword . '  ' . $strGlobalPrivileges . '  ' . $strGrantOption . '  ' . $strAction . '' . $GLOBALS['strUser'] . '' . $GLOBALS['strHost'] . '' . $GLOBALS['strPassword'] . '' . $GLOBALS['strGlobalPrivileges'] . '' . $GLOBALS['strGrantOption'] . '' . $GLOBALS['strAction'] . '
' . htmlspecialchars($row['Host']) . '' . htmlspecialchars($row['Host']) . '' . ($row['Password'] == 'Y' ? $strYes : '' . $strNo . '') . '' . "\n" + echo ' ' . ($row['Password'] == 'Y' ? $GLOBALS['strYes'] : '' . $GLOBALS['strNo'] . '') . '' . "\n" . ' ' . join(',' . "\n" . ' ', $privs) . "\n" . ' ' . ($row['Grant_priv'] == 'Y' ? $strYes : $strNo) . ''; + . ' ' . ($row['Grant_priv'] == 'Y' ? $GLOBALS['strYes'] : $GLOBALS['strNo']) . ''; if ($GLOBALS['cfg']['PropertiesIconic']) { - echo '' . $strEditPrivileges . ''; + echo '' . $GLOBALS['strEditPrivileges'] . ''; } else { - echo $strEditPrivileges; + echo $GLOBALS['strEditPrivileges']; } echo '
' . "\n" - . '  ' . $strEnglishPrivileges . ' ' . "\n" + . ' ' . $GLOBALS['strEnglishPrivileges'] . '' . "\n" . '
' . "\n" - . ' ' . $strWithChecked . '' . "\n" - . ' ' . $strCheckAll . '' . "\n" - . '  / ' . "\n" - . ' ' . $strUncheckAll . '' . "\n" + . ' ' . $GLOBALS['strWithChecked'] . '' . "\n" + . ' ' . $GLOBALS['strCheckAll'] . '' . "\n" + . ' /' . "\n" + . ' ' . $GLOBALS['strUncheckAll'] . '' . "\n" . '
' . "\n" - . '
' . "\n" - . ' ' . "\n" . ' ' - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" . ' ' . "\n" - . '
' : 'width="20" nowrap="nowrap" align="center" valign="top">' ). "\n" - . ' ' . $strAddUser . '' . "\n" - . ' ' . "\n" - . '
' : 'width="20" nowrap="nowrap" align="center" valign="top">' ). "\n" - . ' ' . $strRemoveSelectedUsers . '' . "\n" - . '
 
 
 
 ' . "\n" - . '
' - . ' ' . "\n" - . '
' . "\n" - . '' . "\n" - . '
' . "\n" - . ' ' . sprintf($strFlushPrivilegesNote, '', '') . "\n" - . '
' . "\n"; - } else { + . '
' . "\n"; + + // add/delete user fieldset + echo '
' . "\n" + . ' ' . "\n" + . ($GLOBALS['cfg']['PropertiesIconic'] ? ' ' . "\n" : '' ) + . ' ' . $GLOBALS['strAddUser'] . '' . "\n" + . '
' . "\n" + . '
' + . ' ' . "\n" + . ($GLOBALS['cfg']['PropertiesIconic'] ? ' ' . "\n" : '' ) + . ' ' . $GLOBALS['strRemoveSelectedUsers'] . '' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . '
' . "\n" + . ' ' . "\n" + . '
' . "\n" + . ' ' . "\n" + . '
' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . '
' . "\n" + . ' ' . "\n"; + } else { unset ($row); - echo '
' . "\n" - . ' ' . "\n" . ' ' - . '
' : 'width="20" nowrap="nowrap" align="center" valign="top">' ). "\n" - . ' ' . $strAddUser . '' . "\n" - . ' ' . "\n" - . '
' . "\n" - . '' . "\n" - . '
' . "\n" - . ' ' . sprintf($strFlushPrivilegesNote, '', '') . "\n" - . '
' . "\n"; - } // end if (display overview) - + echo '
' . "\n" + . ' ' . "\n" + . ($GLOBALS['cfg']['PropertiesIconic'] ? ' ' . "\n" : '' ) + . ' ' . $GLOBALS['strAddUser'] . '' . "\n" + . '
' . "\n"; + } // end if (display overview) + echo '' . "\n" + . '
' . "\n" + . ' ' . sprintf($GLOBALS['strFlushPrivilegesNote'], '', '') . "\n" + . '
' . "\n"; } @@ -1174,64 +1181,67 @@ if (empty($adduser) && empty($checkprivs)) { // A user was selected -> display the user's properties echo '

' . "\n" - . ($cfg['PropertiesIconic'] ? '' : '' ) - . ' ' . $strUser . ' \'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'' . "\n"; + . ($GLOBALS['cfg']['PropertiesIconic'] ? '' : '' ) + . ' ' . $GLOBALS['strUser'] . ' \'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'' . "\n"; if (!empty($dbname)) { - echo ' - ' . $strDatabase . ' ' . htmlspecialchars($dbname) . '' . "\n"; + echo ' - ' . $GLOBALS['strDatabase'] . ' ' . htmlspecialchars($dbname) . '' . "\n"; if (!empty($tablename)) { - echo ' - ' . $strTable . ' ' . htmlspecialchars($tablename) . '' . "\n"; + echo ' - ' . $GLOBALS['strTable'] . ' ' . htmlspecialchars($tablename) . '' . "\n"; } } - echo '

' . "\n"; - $res = PMA_DBI_query('SELECT \'foo\' FROM `user` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ';', NULL, PMA_DBI_QUERY_STORE); + echo ' : ' . $GLOBALS['strEditPrivileges'] . '' . "\n"; + $res = PMA_DBI_query('SELECT \'foo\' FROM `mysql`.`user` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ';', NULL, PMA_DBI_QUERY_STORE); if (PMA_DBI_num_rows($res) < 1) { - echo $strUserNotFound; + echo $GLOBALS['strUserNotFound']; require_once('./footer.inc.php'); } PMA_DBI_free_result($res); unset($res); - echo '
    ' . "\n" - . '
  • ' . "\n" - . '
    ' . "\n" + echo '' . "\n" . PMA_generate_common_hidden_inputs('', '', 3) - . ' ' . "\n" - . ' ' . "\n"; + . '' . "\n" + . '' . "\n"; if (!empty($dbname)) { - echo ' ' . "\n"; + echo '' . "\n"; if (!empty($tablename)) { - echo ' ' . "\n"; + echo ' ' . "\n"; } } - echo ' ' . $strEditPrivileges . '
    ' . "\n"; PMA_displayPrivTable((empty($dbname) ? '*' : $dbname), ((empty($dbname) || empty($tablename)) ? '*' : $tablename), TRUE, 3); - echo '
    ' . "\n" - . '
  • ' . "\n"; + echo '' . "\n"; if (empty($tablename)) { - echo '
  • ' . "\n" - . ' ' . (empty($dbname) ? $strDbPrivileges : $strTblPrivileges) . '
    ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; + echo '' . "\n" + . PMA_generate_common_hidden_inputs('', '', 6) + . '' . "\n" + . '' . "\n" + . '
    ' . "\n" + . '' . (empty($dbname) ? $GLOBALS['strDbPrivileges'] : $GLOBALS['strTblPrivileges']) . '' . "\n" + . '
     ' . (empty($dbname) ? $strDatabase : $strTable) . '  ' . $strPrivileges . '  ' . $strGrantOption . '  ' . (empty($dbname) ? $strTblPrivileges : $strColumnPrivileges) . '  ' . $strAction . ' 
    ' . "\n" + . '' . "\n" + . '' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n"; $user_host_condition = ' WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted'); if (empty($dbname)) { - $sql_query = 'SELECT * FROM `db`' . $user_host_condition . ' ORDER BY `Db` ASC;'; + $sql_query = 'SELECT * FROM `mysql`.`db`' . $user_host_condition . ' ORDER BY `Db` ASC;'; } else { - $sql_query = 'SELECT `Table_name`, `Table_priv`, IF(`Column_priv` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . ' \'\', 0, 1) AS \'Column_priv\' FROM `tables_priv`' . $user_host_condition . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($dbname, 'quoted') . ' ORDER BY `Table_name` ASC;'; + $sql_query = 'SELECT `Table_name`, `Table_priv`, IF(`Column_priv` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . ' \'\', 0, 1) AS \'Column_priv\' FROM `mysql`.`tables_priv`' . $user_host_condition . ' AND ' . PMA_convert_using('Db') . ' = ' . PMA_convert_using($dbname, 'quoted') . ' ORDER BY `Table_name` ASC;'; } $res = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_STORE); if (PMA_DBI_affected_rows() == 0) { - echo ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; + echo '' . "\n" + . ' ' . "\n" + . '' . "\n"; } else { $useBgcolorOne = TRUE; if (empty($dbname)) { - $res2 = PMA_DBI_query('SELECT `Db` FROM `tables_priv`' . $user_host_condition . ' GROUP BY `Db` ORDER BY `Db` ASC;'); + $res2 = PMA_DBI_query('SELECT `Db` FROM `mysql`.`tables_priv`' . $user_host_condition . ' GROUP BY `Db` ORDER BY `Db` ASC;'); $row2 = PMA_DBI_fetch_assoc($res2); } $found_rows = array(); @@ -1240,41 +1250,41 @@ if (empty($adduser) && empty($checkprivs)) { while (empty($dbname) && $row2 && $row['Db'] > $row2['Db']) { $found_rows[] = $row2['Db']; - echo ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; + echo '' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . '' . "\n"; $row2 = PMA_DBI_fetch_assoc($res2); $useBgcolorOne = !$useBgcolorOne; } // end while $found_rows[] = empty($dbname) ? $row['Db'] : $row['Table_name']; - echo ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; + . ' ' . "\n" + . ' ' . "\n" + . '' . "\n"; $useBgcolorOne = !$useBgcolorOne; } // end while @@ -1282,16 +1292,16 @@ if (empty($adduser) && empty($checkprivs)) { while (empty($dbname) && $row2) { $found_rows[] = $row2['Db']; - echo ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; + echo '' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . '' . "\n"; $row2 = PMA_DBI_fetch_assoc($res2); $useBgcolorOne = !$useBgcolorOne; @@ -1305,14 +1315,10 @@ if (empty($adduser) && empty($checkprivs)) { PMA_DBI_free_result($res); unset($res); unset($row); - echo ' ' . "\n" - . ' ' . "\n" + . '
    ' . (empty($dbname) ? $GLOBALS['strDatabase'] : $GLOBALS['strTable']) . '' . $GLOBALS['strPrivileges'] . '' . $GLOBALS['strGrantOption'] . '' . (empty($dbname) ? $GLOBALS['strTblPrivileges'] : $GLOBALS['strColumnPrivileges']) . '' . $GLOBALS['strAction'] . '
    ' . $strNone . '
    ' . $GLOBALS['strNone'] . '
    ' . htmlspecialchars($row2['Db']) . '' . "\n" - . ' USAGE' . "\n" - . ' ' . $strNo . '' . $strYes . '' . $strEdit . '' . $strRevoke . '
    ' . htmlspecialchars($row2['Db']) . '' . "\n" + . ' USAGE' . "\n" + . ' ' . $GLOBALS['strNo'] . '' . $GLOBALS['strYes'] . '' . $GLOBALS['strEdit'] . '' . $GLOBALS['strRevoke'] . '
    ' . htmlspecialchars(empty($dbname) ? $row['Db'] : $row['Table_name']) . '' . "\n" - . ' ' . join(',' . "\n" . ' ', PMA_extractPrivInfo($row, TRUE)) . "\n" - . ' ' . (((empty($dbname) && $row['Grant_priv'] == 'Y') || (!empty($dbname) && in_array('Grant', explode(',', $row['Table_priv'])))) ? $strYes : $strNo) . ''; + echo '
    ' . htmlspecialchars(empty($dbname) ? $row['Db'] : $row['Table_name']) . '' . "\n" + . ' ' . join(',' . "\n" . ' ', PMA_extractPrivInfo($row, TRUE)) . "\n" + . ' ' . (((empty($dbname) && $row['Grant_priv'] == 'Y') || (!empty($dbname) && in_array('Grant', explode(',', $row['Table_priv'])))) ? $GLOBALS['strYes'] : $GLOBALS['strNo']) . ''; if ((empty($dbname) && $row2 && $row['Db'] == $row2['Db']) || (!empty($dbname) && $row['Column_priv'])) { - echo $strYes; + echo $GLOBALS['strYes']; if (empty($dbname)) { $row2 = PMA_DBI_fetch_assoc($res2); } } else { - echo $strNo; + echo $GLOBALS['strNo']; } echo '' . $strEdit . '' . $strRevoke . '
    ' . $GLOBALS['strEdit'] . '' . $GLOBALS['strRevoke'] . '
    ' . htmlspecialchars($row2['Db']) . '' . "\n" - . ' USAGE' . "\n" - . ' ' . $strNo . '' . $strYes . '' . $strEdit . '' . $strRevoke . '
    ' . htmlspecialchars($row2['Db']) . '' . "\n" + . ' USAGE' . "\n" + . ' ' . $GLOBALS['strNo'] . '' . $GLOBALS['strYes'] . '' . $GLOBALS['strEdit'] . '' . $GLOBALS['strRevoke'] . '
    ' . "\n" - . ' ' . "\n" - . PMA_generate_common_hidden_inputs('', '', 6) - . ' ' . "\n" - . ' ' . "\n"; + echo '
    ' . "\n"; if (empty($dbname)) { - echo ' ' . "\n"; + echo ' ' . "\n"; $res = PMA_DBI_query('SHOW DATABASES;'); $pred_db_array = array(); while ($row = PMA_DBI_fetch_row($res)) { @@ -1324,17 +1330,17 @@ if (empty($adduser) && empty($checkprivs)) { unset($res); unset($row); if (!empty($pred_db_array)) { - echo ' ' . "\n" + . ' ' . "\n"; foreach ($pred_db_array as $current_db) { - echo ' ' . "\n"; + echo ' ' . "\n"; } - echo ' ' . "\n"; + echo ' ' . "\n"; } - echo ' ' . "\n"; + echo ' ' . "\n"; } else { - echo ' ' . "\n" - . ' ' . "\n"; + echo ' ' . "\n" + . ' ' . "\n"; if ($res = @PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';', NULL, PMA_DBI_QUERY_STORE)) { $pred_tbl_array = array(); while ($row = PMA_DBI_fetch_row($res)) { @@ -1346,135 +1352,127 @@ if (empty($adduser) && empty($checkprivs)) { unset($res); unset($row); if (!empty($pred_tbl_array)) { - echo ' ' . "\n" + . ' ' . "\n"; foreach ($pred_tbl_array as $current_table) { - echo ' ' . "\n"; + echo ' ' . "\n"; } - echo ' ' . "\n"; + echo ' ' . "\n"; } } else { unset($res); } - echo ' ' . "\n"; + echo ' ' . "\n"; } - echo ' ' . PMA_showHint($strEscapeWildcards) . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . '
    ' . "\n" - . '
  • ' . "\n"; + echo ' ' . PMA_showHint($GLOBALS['strEscapeWildcards']) . "\n" + . '' . "\n" + . '' . "\n"; } if (empty($dbname)) { - echo '
  • ' . "\n" - . '
    ' . "\n" + echo '' . "\n" . PMA_generate_common_hidden_inputs('', '', 3) - . ' ' . "\n" - . ' ' . "\n"; - echo ' ' . $strChangePassword . '
    ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . '
     
    ' . "\n" - . ' ' . "\n" - . '
    ' . "\n" - . '
    ' . "\n" - . '
  • ' . "\n" - . '
  • ' . "\n" - . '
    ' . "\n" + . '' . "\n" + . '' . "\n" + . '
    ' . "\n" + . ' ' . $GLOBALS['strChangePassword'] . '' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . '
    ' . "\n" + . '
    ' . "\n" + . '' . "\n" + . '
    ' . "\n" + . '
    ' . "\n" . PMA_generate_common_hidden_inputs('', '', 3) - . ' ' . "\n" - . ' ' . "\n" - . ' ' . $strChangeCopyUser . '
    ' . "\n" - . ' ' . "\n"; - PMA_displayLoginInformationFields('change', 3); - echo '
    ' . "\n" - . ' ' . $strChangeCopyMode . '
    ' . "\n" - . ' ' . "\n" - . '
    ' . "\n" - . ' ' . "\n" - . '
    ' . "\n" - . ' ' . "\n" - . '
    ' . "\n" - . ' ' . "\n" - . '
    ' . "\n" - . ' ' . "\n" - . '
    ' . "\n" - . '
  • ' . "\n"; + . '' . "\n" + . '' . "\n" + . '
    ' . "\n" + . ' ' . $GLOBALS['strChangeCopyUser'] . '' . "\n"; + PMA_displayLoginInformationFields('change', 3 ); + echo '
    ' . "\n" + . ' ' . $GLOBALS['strChangeCopyMode'] . '' . "\n" + . ' ' . "\n" + . '
    ' . "\n" + . ' ' . "\n" + . '
    ' . "\n" + . ' ' . "\n" + . '
    ' . "\n" + . ' ' . "\n" + . '
    ' . "\n" + . '
    ' . "\n" + . '' . "\n" + . '' . "\n"; } - echo '
' . "\n"; } } else if (!empty($adduser)) { // Add a new user - $url_query .= '&adduser=1'; + $GLOBALS['url_query'] .= '&adduser=1'; echo '

' . "\n" - . ($cfg['PropertiesIconic'] ? '' : '' ) - . ' ' . $strAddUser . "\n" + . ($GLOBALS['cfg']['PropertiesIconic'] ? '' : '' ) + . ' ' . $GLOBALS['strAddUser'] . "\n" . '

' . "\n" . '
' . "\n" - . PMA_generate_common_hidden_inputs('', '', 1) - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; + . PMA_generate_common_hidden_inputs('', '', 1); PMA_displayLoginInformationFields('new', 2); - echo '
' . "\n" - . ' ' . $strLoginInformation . "\n" - . '

' . "\n"; PMA_displayPrivTable('*', '*', FALSE, 1); - echo '
' . "\n" - . ' ' . "\n" + echo ' ' . "\n" . '
' . "\n"; } else { // check the privileges for a particular database. - echo '

' . "\n" - . ($cfg['PropertiesIconic'] ? '' : '' ) - . ' ' . sprintf($strUsersHavingAccessToDb, '' . htmlspecialchars($checkprivs) . '') . "\n" - . '

' . "\n" - . '' . "\n" + echo '
' . "\n" + . '' . "\n" + . '' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" - . ' ' . "\n"; + . ' ' . "\n" + . '' . "\n" + . '' . "\n"; $useBgcolorOne = TRUE; unset($row); unset($row1); @@ -1490,7 +1488,7 @@ if (empty($adduser) && empty($checkprivs)) { $list_of_compared_privileges = PMA_convert_using('Select_priv') . ' = ' . $no . ' AND ' . PMA_convert_using('Insert_priv') . ' = ' . $no . ' AND ' . PMA_convert_using('Update_priv') . ' = ' . $no . ' AND ' . PMA_convert_using('Delete_priv') . ' = ' . $no . ' AND ' . PMA_convert_using('Create_priv') . ' = ' . $no . ' AND ' . PMA_convert_using('Drop_priv') . ' = ' . $no . ' AND ' . PMA_convert_using('Grant_priv') . ' = ' . $no . ' AND ' . PMA_convert_using('References_priv') . ' = ' . $no; - $sql_query = '(SELECT ' . PMA_convert_using('User') . ' AS User,' . PMA_convert_using('Host') . ' AS Host,' . PMA_convert_using('Db') . ' AS Db,' . $list_of_privileges . ' FROM `db` WHERE ' . PMA_convert_using($checkprivs, 'quoted') . ' LIKE ' . PMA_convert_using('Db') . ' AND NOT (' . $list_of_compared_privileges. ')) UNION (SELECT ' . PMA_convert_using('User') . ' AS User, ' . PMA_convert_using('Host') . ' AS Host, ' . PMA_convert_using('*', 'quoted') . ' AS Db, ' . $list_of_privileges . ' FROM `user` WHERE NOT (' . $list_of_compared_privileges . ')) ORDER BY User ASC, Host ASC, Db ASC;'; + $sql_query = '(SELECT ' . PMA_convert_using('User') . ' AS User,' . PMA_convert_using('Host') . ' AS Host,' . PMA_convert_using('Db') . ' AS Db,' . $list_of_privileges . ' FROM `mysql`.`db` WHERE ' . PMA_convert_using($checkprivs, 'quoted') . ' LIKE ' . PMA_convert_using('Db') . ' AND NOT (' . $list_of_compared_privileges. ')) UNION (SELECT ' . PMA_convert_using('User') . ' AS User, ' . PMA_convert_using('Host') . ' AS Host, ' . PMA_convert_using('*', 'quoted') . ' AS Db, ' . $list_of_privileges . ' FROM `mysql`.`user` WHERE NOT (' . $list_of_compared_privileges . ')) ORDER BY User ASC, Host ASC, Db ASC;'; $res = PMA_DBI_query($sql_query); $row = PMA_DBI_fetch_assoc($res); @@ -1499,10 +1497,10 @@ if (empty($adduser) && empty($checkprivs)) { } } else { // With MySQL 3, we need 2 seperate queries here. - $sql_query = 'SELECT * FROM `user` WHERE NOT (`Select_priv` = \'N\' AND `Insert_priv` = \'N\' AND `Update_priv` = \'N\' AND `Delete_priv` = \'N\' AND `Create_priv` = \'N\' AND `Drop_priv` = \'N\' AND `Grant_priv` = \'N\' AND `References_priv` = \'N\') ORDER BY `User` ASC, `Host` ASC;'; + $sql_query = 'SELECT * FROM `mysql`.`user` WHERE NOT (`Select_priv` = \'N\' AND `Insert_priv` = \'N\' AND `Update_priv` = \'N\' AND `Delete_priv` = \'N\' AND `Create_priv` = \'N\' AND `Drop_priv` = \'N\' AND `Grant_priv` = \'N\' AND `References_priv` = \'N\') ORDER BY `User` ASC, `Host` ASC;'; $res1 = PMA_DBI_query($sql_query); $row1 = PMA_DBI_fetch_assoc($res1); - $sql_query = 'SELECT * FROM `db` WHERE \'' . $checkprivs . '\' LIKE `Db` AND NOT (`Select_priv` = \'N\' AND `Insert_priv` = \'N\' AND `Update_priv` = \'N\' AND `Delete_priv` = \'N\' AND `Create_priv` = \'N\' AND `Drop_priv` = \'N\' AND `Grant_priv` = \'N\' AND `References_priv` = \'N\') ORDER BY `User` ASC, `Host` ASC;'; + $sql_query = 'SELECT * FROM `mysql`.`db` WHERE \'' . $checkprivs . '\' LIKE `Db` AND NOT (`Select_priv` = \'N\' AND `Insert_priv` = \'N\' AND `Update_priv` = \'N\' AND `Delete_priv` = \'N\' AND `Create_priv` = \'N\' AND `Drop_priv` = \'N\' AND `Grant_priv` = \'N\' AND `References_priv` = \'N\') ORDER BY `User` ASC, `Host` ASC;'; $res2 = PMA_DBI_query($sql_query); $row2 = PMA_DBI_fetch_assoc($res2); if ($row1 || $row2) { @@ -1542,39 +1540,39 @@ if (empty($adduser) && empty($checkprivs)) { if (count($current_privileges) > 1) { echo ' rowspan="' . count($current_privileges) . '"'; } - echo ' bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" - . ' ' . (empty($current_user) ? '' . $strAny . '' : htmlspecialchars($current_user)) . "\n" + echo ' bgcolor="' . ($useBgcolorOne ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']) . '">' . "\n" + . ' ' . (empty($current_user) ? '' . $GLOBALS['strAny'] . '' : htmlspecialchars($current_user)) . "\n" . ' ' . "\n" . ' 1) { echo ' rowspan="' . count($current_privileges) . '"'; } - echo ' bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" + echo ' bgcolor="' . ($useBgcolorOne ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']) . '">' . "\n" . ' ' . htmlspecialchars($current_host) . "\n" . ' ' . "\n"; foreach ($current_privileges as $current) { - echo ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" . ' ' . "\n"; @@ -1586,12 +1584,13 @@ if (empty($adduser) && empty($checkprivs)) { } } else { echo ' ' . "\n" - . ' ' . "\n" . ' ' . "\n"; } - echo '
' . "\n" + . ($GLOBALS['cfg']['PropertiesIconic'] ? ' ' . "\n" : '' ) + . ' ' . sprintf($GLOBALS['strUsersHavingAccessToDb'], '' . htmlspecialchars($checkprivs) . '') . "\n" + . '
' . "\n" - . '  ' . $strUser . ' ' . "\n" + . ' ' . $GLOBALS['strUser'] . '' . "\n" . ' ' . "\n" - . '  ' . $strHost . ' ' . "\n" + . ' ' . $GLOBALS['strHost'] . '' . "\n" . ' ' . "\n" - . '  ' . $strType . ' ' . "\n" + . ' ' . $GLOBALS['strType'] . '' . "\n" . ' ' . "\n" - . '  ' . $strPrivileges . ' ' . "\n" + . ' ' . $GLOBALS['strPrivileges'] . '' . "\n" . ' ' . "\n" - . '  ' . $strGrantOption . ' ' . "\n" + . ' ' . $GLOBALS['strGrantOption'] . '' . "\n" . ' ' . "\n" - . '  ' . $strAction . ' ' . "\n" + . ' ' . $GLOBALS['strAction'] . '' . "\n" . '
' . "\n" + echo ' ' . "\n" . ' '; if (!isset($current['Db']) || $current['Db'] == '*') { - echo $strGlobal; + echo $GLOBALS['strGlobal']; } else if ($current['Db'] == $checkprivs) { - echo $strDbSpecific; + echo $GLOBALS['strDbSpecific']; } else { - echo $strWildcard, ': ' . htmlspecialchars($current['Db']) . ''; + echo $GLOBALS['strWildcard'], ': ' . htmlspecialchars($current['Db']) . ''; } echo "\n" . ' ' . "\n" + . ' ' . "\n" . ' ' . "\n" . ' ' . join(',' . "\n" . ' ', PMA_extractPrivInfo($current, TRUE)) . "\n" . ' ' . "\n" . ' ' . "\n" - . ' ' . ($current['Grant_priv'] == 'Y' ? $strYes : $strNo) . "\n" + . ' ' . "\n" + . ' ' . ($current['Grant_priv'] == 'Y' ? $GLOBALS['strYes'] : $GLOBALS['strNo']) . "\n" . ' ' . "\n" - . ' ' . "\n" - . ' ' . $strEdit . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . $GLOBALS['strEdit'] . "\n" . ' ' . "\n" . '
' . "\n" - . ' ' . $strNoUsersFound . "\n" + . ' ' . "\n" + . ' ' . $GLOBALS['strNoUsersFound'] . "\n" . '
' . "\n"; + echo '' . "\n" + . '' . "\n"; } // end if (empty($adduser) && empty($checkprivs)) ... else if ... else ... -- cgit v1.2.3