diff --git a/libraries/Table.class.php b/libraries/Table.class.php
index ee6ad22d5..686db7221 100644
--- a/libraries/Table.class.php
+++ b/libraries/Table.class.php
@@ -1,25 +1,6 @@
getName();
}
- function getOptions($engine = null)
- {
- if (null === $engine) {
- $engine = $this->getEnginge();
- }
-
- $options = array();
- $all_options = PMA_Table::getAlterOptions();
-
- if (($engine === 'myisam' || $engine === 'isam')) {
- $options['KEYS'] = $all_options['KEYS'];
- }
-
- if (($engine === 'myisam')) {
- $options['checksum'] = $all_options['KEYS'];
- $options['delay_key_write'] = $all_options['KEYS'];
- }
-
- if (($engine === 'myisam' || $engine === 'innodb')) {
- $options['auto_increment'] = $all_options['KEYS'];
- }
- }
-
- /**
- * returns all available options for any table engine
- *
- * @todo update with mysql manual, last: ???
- * @static
- */
- function getAlterOptions()
- {
- static $options = null;
-
- if (null === $options) {
- $options = array(
- // ENABLE/DISABLE KEY
- // skipped, makes no sense here
- 'COMMENT' => array(
- 'type' => 'string',
- 'name' => 'strTableComment',
- ),
- 'TYPE' => array(
- 'type' => 'string',
- 'values' => array('PMA_Table', 'getEngines'),
- 'name' => 'strTableEngine',
- ),
- 'DEFAULT_CHARSET_COLLATION' => array(
- 'type' => 'string',
- 'desc' => 'strTableCharset',
- ),
- 'pack_keys' => array(
- 'type' => 'string',
- 'name' => 'pack_keys',
- 'desc' => '',
- 'engines' => array(
- PMA_DBI_ENGINE_MYISAM,
- PMA_DBI_ENGINE_ISAM,
- ),
- ),
- 'checksum' => array(
- 'type' => 'string',
- 'name' => 'checksum',
- 'engines' => array(
- PMA_DBI_ENGINE_MYISAM,
- ),
- ),
- 'delay_key_write' => array(
- 'type' => 'string',
- 'name' => 'delay_key_write',
- 'engines' => array(
- PMA_DBI_ENGINE_MYISAM,
- ),
- ),
- 'auto_increment' => array(
- 'type' => 'int',
- 'name' => 'auto_increment',
- 'engines' => array(
- PMA_DBI_ENGINE_MYISAM,
- PMA_DBI_ENGINE_INNODB,
- ),
- ),
- );
- }
-
- return $options;
- }
-
- function setEngine($engine)
- {
- $this->set('ENGINE', $engine);
- }
-
- function getEngine()
- {
- return $this->get('ENGINE');
- }
-
- /**
- * @todo update with mysql manual, last: ???
- */
- function getEngineName($engine = null)
- {
- if (null === $engine) {
- $engine = $this->getEngine();
- }
-
- switch ($engine) {
- case PMA_DBI_ENGINE_MYISAM :
- return 'MyISAM';
- break;
- case PMA_DBI_ENGINE_ISAM :
- return 'ISAM';
- break;
- case PMA_DBI_ENGINE_INNODB :
- return 'InnoDB';
- break;
- case PMA_DBI_ENGINE_MERGE :
- return 'Merge';
- break;
- case PMA_DBI_ENGINE_MEMORY :
- return 'MEMORY';
- break;
- case PMA_DBI_ENGINE_HEAP :
- return 'HEAP';
- break;
- case PMA_DBI_ENGINE_BDB :
- return 'BerkeleyDB';
- break;
- default :
- return 'UNKNOWN';
- }
- }
-
function getLastError()
{
return end($this->errors);
@@ -296,203 +144,33 @@ class PMA_Table {
}
/**
- * sets given $value for given $option
+ * sets given $value for given $param
*
- * @uses $this->options to add or change value
- * @param string $option option name
- * @param mixed $value option value
+ * @uses $this->settings to add or change value
+ * @param string param name
+ * @param mixed param value
*/
- function set($option, $value)
+ function set($param, $value)
{
- $this->options[$option]->value = $value;
- }
-
- /**
- * @static
- * @param string $option
- * @param mixed $value
- * @return string
- */
- function getAlterOption($option, $value) {
- switch ($option) {
- case 'KEYS' :
- return ($value ? 'ENABLE' : 'DISABLE') . ' KEYS';
- break;
- case 'TABLESPACE' :
- return ($value ? 'IMPORT' : 'DISCARD') . ' TABLESPACE';
- break;
- case 'RENAME TO' :
- case 'RENAME' :
- case 'CHECK' :
- case 'ORDER BY' :
- return $option . ' ' . $value;
- break;
- case 'PACK_KEYS' :
- //{0 | 1 | DEFAULT}
- case 'CHECKSUM' :
- case 'DELAY_KEY_WRITE' :
- return $option . ' = ' . (int) (bool) $value;
- break;
- case 'CONVERT CHARACTER SET' :
- return 'CONVERT ' . PMA_generateCharsetQueryPart($value);
- break;
- case 'TABLE_COLLATION' :
- case 'DEFAULT CHARACTER SET' :
- return 'DEFAULT ' . PMA_generateCharsetQueryPart($value);
- break;
- case 'CHARACTER SET' :
- return PMA_generateCharsetQueryPart($value);
- break;
- case 'INSERT_METHOD' :
- //{ NO | FIRST | LAST }
- case 'UNION' :
- case 'ROW_FORMAT' :
- //{DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}
- case 'MIN_ROWS' :
- case 'MAX_ROWS' :
- case 'AVG_ROW_LENGTH' :
- case 'ENGINE' :
- case 'TYPE' :
- case 'AUTO_INCREMENT' :
- return $option . ' = ' . $value;
- break;
- case 'CONNECTION' :
- case 'INDEX DIRECTORY' :
- case 'DATA DIRECTORY' :
- case 'CONNECTION' :
- return $option . ' = \'' . PMA_sqlAddslashes($value) . '\'';
- break;
- case 'TABLE_COMMENT' :
- case 'COMMENT' :
- return 'COMMENT = \'' . PMA_sqlAddslashes($value) . '\'';
- break;
- default :
- return '-- UNKNOWN OPTION: ' . $option . ' = \'' . PMA_sqlAddslashes($value) . '\'';
- }
- }
-
- /**
- * set options from given array of options
- *
- * @param array $options
- * @return boolean success
- */
- function setOptions($options, $bc = false)
- {
- if ($bc) {
- // backward compatibility
- $new_engine = strtolower($this->get('ENGINE'));
- $bc_options = $options;
- $options = array();
- if (null !== $this->get('TABLE_COMMENT')
- && isset($bc_options['comment'])) {
- $options['TABLE_COMMENT'] = $bc_options['comment'];
- }
- if (isset($bc_options['new_tbl_type'])
- && ! $this->isEngineOneOf($bc_options['new_tbl_type'])) {
- $options['ENGINE'] = $bc_options['new_tbl_type'];
- $new_engine = strtolower($options['ENGINE']);
- } elseif (null !== $this->get('TYPE')
- && isset($bc_options['new_tbl_type'])) {
- $options['TYPE'] = $bc_options['new_tbl_type'];
- }
- if (null !== $this->get('TABLE_COLLATION')
- && isset($bc_options['tbl_collation'])) {
- $options['TABLE_COLLATION'] = $bc_options['tbl_collation'];
- }
-
- //if (null !== $this->get('PACK_KEYS')) {
- if ($new_engine === 'myisam' || $new_engine === 'isam') {
- $options['PACK_KEYS'] = (int) !empty($bc_options['new_pack_keys']);
- }
- //if (null !== $this->get('CHECKSUM')) {
- if ($new_engine === 'myisam') {
- $options['CHECKSUM'] = (int) !empty($bc_options['new_checksum']);
- }
- //if (null !== $this->get('DELAY_KEY_WRITE')) {
- if ($new_engine === 'myisam') {
- $options['DELAY_KEY_WRITE'] = (int) !empty($bc_options['new_delay_key_write']);
- }
- //if (null !== $this->get('AUTO_INCREMENT')
- // && isset($bc_options['new_auto_increment'])) {
- if (isset($bc_options['new_auto_increment'])
- && ($new_engine === 'myisam'
- // MEMORY in 4.1.0
- || ($new_engine === 'memory' && PMA_MYSQL_INT_VERSION >= 40100)
- // InnoDB in 4.1.2 and 5.0.3
- || ($new_engine === 'innodb' && PMA_MYSQL_INT_VERSION >= 40102))) {
- $options['AUTO_INCREMENT'] = (int) $bc_options['new_auto_increment'];
- }
- }
-
- $table_alters = array();
-
- foreach ($options as $option => $value) {
- if ($this->get($option) != $value) {
- $table_alters[] = PMA_Table::getAlterOption($option, $value);
- }
- }
-
- if (count($table_alters)) {
- $sql_query = '
- ALTER TABLE ' . $this->getFullName(true) . '
- ' . implode("\r\n", $table_alters);
- if (! PMA_DBI_try_query($sql_query)) {
- $this->errors[] = $GLOBALS['strError'];
- return false;
- }
-
- // display executed query in user interface
- if (! isset($GLOBALS['sql_query'])) {
- $GLOBALS['sql_query'] = '';
- }
- $GLOBALS['sql_query'] .= "\r\n" . $sql_query . ';';
- $this->messages[] = $GLOBALS['strSuccess'];
- }
-
- return true;
+ $this->settings[$param] = $value;
}
/**
* returns value for given setting/param
*
- * @uses $this->options to return value
- * @param string $option name for value to return
- * @return mixed value for $option
+ * @uses $this->settings to return value
+ * @param string name for value to return
+ * @return mixed value for $param
*/
- function get($option)
+ function get($param)
{
- if (isset($this->options[$option])) {
- return $this->options[$option]->value;
+ if (isset($this->settings[$param])) {
+ return $this->settings[$param];
}
return null;
}
- /**
- * cleans 'InnoDB free'-string from table comment
- */
- function cleanInnodbComment($comment = null)
- {
- $return = true;
-
- if (null === $comment) {
- if (! $this->isEngineOneOf('innodb')) {
- return;
- }
- $comment = $this->get('TABLE_COMMENT');
- $return = false;
- }
-
- $comment = preg_replace('/(; InnoDB free: .*$)/i', '', $comment);
-
- if ($return) {
- return $comment;
- } else {
- $this->set('TABLE_COMMENT', $comment);
- }
- }
-
/**
* loads structure data
*/
@@ -504,96 +182,25 @@ class PMA_Table {
return false;
}
- foreach ($table_info[$this->getName()] as $key => $value) {
- $this->options[$key]->value = $value;
- }
+ $this->settings = $table_info;
- $this->cleanInnodbComment();
-
- /**
- * init some values, check if they exists, if not create them with
- * standard values
- */
if ($this->get('TABLE_ROWS') === null) {
$this->set('TABLE_ROWS', PMA_Table::countRecords($this->getDbName(),
$this->getName(), true, true));
}
- /*
- if (null === $this->get('AUTO_INCREMENT')
- && ($this->isEngineOneOf('myisam')
- // MEMORY in 4.1.0
- || ($this->isEngineOneOf('memory') && PMA_MYSQL_INT_VERSION >= 40100)
- // InnoDB in 4.1.2 and 5.0.3
- || ($this->isEngineOneOf('innodb') && PMA_MYSQL_INT_VERSION >= 40102))) {
- $this->set('AUTO_INCREMENT', 0);
- } else {
- // do not support this option on others than MyISAM or ISAM
- $this->removeOption('AUTO_INCREMENT');
- }
-
- if (null === $this->get('PACK_KEYS')
- && $this->isEngineOneOf('myisam', 'isam')) {
- $this->set('PACK_KEYS', 'DEFAULT');
- echo __LINE__;
- } elseif (null !== $this->get('PACK_KEYS')) {
- // do not support this option on others than MyISAM or ISAM
- $this->removeOption('PACK_KEYS');
- echo __LINE__;
- }
-
- if (null === $this->get('CHECKSUM')
- && $this->isEngineOneOf('myisam')) {
- $this->set('CHECKSUM', 0);
- } else {
- // do not support this option on others than MyISAM
- $this->removeOption('CHECKSUM');
- }
-
- if (null === $this->get('DELAY_KEY_WRITE')
- && $this->isEngineOneOf('myisam')) {
- $this->set('DELAY_KEY_WRITE', 0);
- } else {
- // do not support this option on others than MyISAM
- $this->removeOption('DELAY_KEY_WRITE');
- }
- */
-
- $create_options = explode(' ', $this->get('CREATE_OPTIONS'));
+ $create_options = explode(' ', $this->get('TABLE_ROWS'));
// export create options by its name as variables into gloabel namespace
// f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
foreach ($create_options as $each_create_option) {
$each_create_option = explode('=', $each_create_option);
if (isset($each_create_option[1])) {
- $this->set(strtoupper($each_create_option[0]), $each_create_option[1]);
+ $this->set($$each_create_option[0], $each_create_option[1]);
}
}
}
- function removeOption($option)
- {
- if (isset($this->options[$option])) {
- unset($this->options[$option]);
- }
- }
-
- /**
- *
- * @param string $engine,... engine
- * @return boolean whether one of the given engines is equal with current engine
- */
- function isEngineOneOf()
- {
- foreach (func_get_args() as $engine) {
- if (strtolower($this->getEngine()) === strtolower($engine)) {
- return true;
- }
- }
-
- return false;
- }
-
/**
* old PHP 4style constructor
*
@@ -889,6 +496,7 @@ class PMA_Table {
return true;
} // end of 'PMA_Table::duplicateInfo()' function
+
/**
* Copies or renames table
* FIXME: use RENAME
@@ -1260,21 +868,15 @@ class PMA_Table {
return false;
}
- $sql_query = '
+ $GLOBALS['sql_query'] = '
RENAME TABLE ' . $this->getFullName(true) . '
TO ' . $new_table->getFullName(true) . ';';
- if (! PMA_DBI_query($sql_query)) {
+ if (! PMA_DBI_query($GLOBALS['sql_query'])) {
// TODO add $GLOBALS['strErrorRenamingTable'];
$this->errors[] = $GLOBALS['strError'] . ': ' . $new_table->getFullName();
return false;
}
- // display executed query in user interface
- if (! isset( $GLOBALS['sql_query'])) {
- $GLOBALS['sql_query'] = '';
- }
- $GLOBALS['sql_query'] .= "\n\n" . $sql_query;
-
$old_name = $this->getName();
$old_db = $this->getDbName();
$this->setName($new_name);
diff --git a/server_privileges.php b/server_privileges.php
index 8f014b42a..443769860 100644
--- a/server_privileges.php
+++ b/server_privileges.php
@@ -2,107 +2,48 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
-if (! defined('PMA_NO_VARIABLES_IMPORT')) {
- define('PMA_NO_VARIABLES_IMPORT', true);
-}
-require_once './libraries/common.lib.php';
+require_once('./libraries/common.lib.php');
/**
* Does the common work
*/
$js_to_run = 'server_privileges.js';
-require './libraries/server_common.inc.php';
-
-
-/**
- * Checks if the user is allowed to do what he tries to...
- */
-if (!$is_superuser) {
- require './libraries/server_links.inc.php';
- echo '
' . "\n"
- . ($GLOBALS['cfg']['MainPageIconic'] ? '
' : '')
- . $GLOBALS['strPrivileges'] . "\n"
- . '
' . "\n"
- . $GLOBALS['strNoPrivileges'] . "\n";
- require_once './libraries/footer.inc.php';
-}
+require('./libraries/server_common.inc.php');
/**
* Checks if a dropdown box has been used for selecting a database / table
*/
-if (isset($_REQUEST['pred_dbname']) && strlen($_REQUEST['pred_dbname'])) {
- $dbname = $_REQUEST['pred_dbname'];
- unset($_REQUEST['pred_dbname']);
-} elseif (isset($_REQUEST['dbname']) && strlen($_REQUEST['dbname'])) {
- $dbname = $_REQUEST['dbname'];
- unset($_REQUEST['dbname']);
-} else {
- $dbname = '';
+if (isset($pred_dbname) && strlen($pred_dbname)) {
+ $dbname = $pred_dbname;
+ unset($pred_dbname);
+}
+if (isset($pred_tablename) && strlen($pred_tablename)) {
+ $tablename = $pred_tablename;
+ unset($pred_tablename);
}
-if (isset($_REQUEST['pred_tablename']) && strlen($_REQUEST['pred_tablename'])) {
- $tablename = $_REQUEST['pred_tablename'];
- unset($_REQUEST['pred_tablename']);
-} else {
- $tablename = '';
-}
-
-/**
- * check if given $dbname is a wildcard or not
- */
-//if (preg_match('/\\\\(?:_|%)/i', $dbname)) {
-//if (preg_match('/(?' . "\n"
+ . ($GLOBALS['cfg']['MainPageIconic'] ? '
' : '')
+ . $GLOBALS['strPrivileges'] . "\n"
+ . '' . "\n"
+ . $GLOBALS['strNoPrivileges'] . "\n";
+ require_once('./libraries/footer.inc.php');
}
/**
@@ -111,10 +52,9 @@ function PMA_addUSerTablePrivs(&$user_privs)
* @param string the user's initial
* @return string the generated condition
*/
-function PMA_RangeOfUsers($initial = '')
-{
- // strtolower() is used because the User field
- // might be BINARY, so LIKE would be case sensitive
+function PMA_RangeOfUsers($initial = '') {
+// strtolower() is used because the User field
+// might be BINARY, so LIKE would be case sensitive
if (!empty($initial)) {
$ret = " WHERE " . PMA_convert_using('User')
. " LIKE " . PMA_convert_using($initial . '%', 'quoted')
@@ -136,7 +76,7 @@ function PMA_RangeOfUsers($initial = '')
*
* @return array
*/
-function PMA_extractPrivInfo($row = '', $enableHTML = false)
+function PMA_extractPrivInfo($row = '', $enableHTML = FALSE)
{
$grants = array(
array('Select_priv', 'SELECT', $GLOBALS['strPrivDescSelect']),
@@ -174,10 +114,24 @@ function PMA_extractPrivInfo($row = '', $enableHTML = false)
$grants[] = array('Execute_priv', 'EXECUTE', $GLOBALS['strPrivDescExecute5']);
}
- PMA_addUSerTablePrivs($row);
-
+ if (!empty($row) && isset($row['Table_priv'])) {
+ $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));
+ unset($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';
+ }
+ unset($current_grant);
+ unset($av_grants);
+ unset($users_grants);
+ }
$privs = array();
- $allPrivileges = true;
+ $allPrivileges = TRUE;
foreach ($grants as $current_grant) {
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']))))) {
@@ -194,7 +148,7 @@ function PMA_extractPrivInfo($row = '', $enableHTML = false)
}
$privs[] = $priv_string . ' (`' . join('`, `', $GLOBALS[$current_grant[0]]) . '`)';
} else {
- $allPrivileges = false;
+ $allPrivileges = FALSE;
}
}
}
@@ -218,36 +172,27 @@ function PMA_extractPrivInfo($row = '', $enableHTML = false)
/**
* 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)
-{
- $spaces .= ' ';
- echo $spaces . '' . "\n"
- . $spaces . ' ' . "\n"
- . $spaces . ' ' . "\n"
- . $spaces . ' ' . $GLOBALS['strOr'] . '' . "\n"
- . $spaces . ' ' . "\n"
- . $spaces . '
' . "\n";
+ echo $spaces . ' ' . "\n"
+ . $spaces . ' ' . $GLOBALS['strOr'] . '' . "\n"
+ . $spaces . ' ' . "\n"
+ . $spaces . ' ' . "\n";
} // end function
/**
@@ -263,50 +208,54 @@ function PMA_display_column_privs($spaces, $columns, $row, $name_for_select,
*
* @return void
*/
-function PMA_displayPrivTable($db = '*', $table = '*', $submit = true, $indent = 0)
+function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = 0)
{
if ($db == '*') {
$table = '*';
}
- $spaces = str_repeat(' ', $indent);
+ $spaces = str_repeat( ' ', $indent );
- if (isset($_REQUEST['username'])) {
+ if (isset($GLOBALS['username'])) {
+ $username = $GLOBALS['username'];
+ $hostname = $GLOBALS['hostname'];
if ($db == '*') {
$sql_query =
'SELECT * FROM `mysql`.`user`'
.' WHERE ' . PMA_convert_using('User')
- .' = ' . PMA_convert_using(PMA_sqlAddslashes($_REQUEST['username']), 'quoted')
+ .' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted')
.' AND ' . PMA_convert_using('Host')
- .' = ' . PMA_convert_using($_REQUEST['hostname'], 'quoted') . ';';
+ .' = ' . PMA_convert_using($hostname, 'quoted') . ';';
} elseif ($table == '*') {
$sql_query =
'SELECT * FROM `mysql`.`db`'
.' WHERE ' . PMA_convert_using('`User`')
- .' = ' . PMA_convert_using(PMA_sqlAddslashes($_REQUEST['username']), 'quoted')
+ .' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted')
.' AND ' . PMA_convert_using('`Host`')
- .' = ' . PMA_convert_using($_REQUEST['hostname'], 'quoted')
- .' AND ' . PMA_convert_using(PMA_unescape_mysql_wildcards($db), 'quoted')
- .' LIKE ' . PMA_convert_using('`Db`') . ';';
+ .' = ' . PMA_convert_using($hostname, 'quoted')
+ .' AND ' . PMA_convert_using( PMA_unescape_mysql_wildcards( $db ), 'quoted' )
+ .' LIKE ' . PMA_convert_using( '`Db`' ) . ';';
} else {
$sql_query =
'SELECT `Table_priv`'
.' FROM `mysql`.`tables_priv`'
.' WHERE ' . PMA_convert_using('`User`')
- .' = ' . PMA_convert_using(PMA_sqlAddslashes($_REQUEST['username']), 'quoted')
+ .' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted')
.' AND ' .PMA_convert_using('`Host`')
- .' = ' . PMA_convert_using($_REQUEST['hostname'], 'quoted')
+ .' = ' . PMA_convert_using( $hostname, 'quoted' )
.' AND ' .PMA_convert_using('`Db`')
- .' = ' . PMA_convert_using(PMA_unescape_mysql_wildcards($db), 'quoted')
+ .' = ' . PMA_convert_using( PMA_unescape_mysql_wildcards( $db ), 'quoted' )
.' AND ' . PMA_convert_using('`Table_name`')
.' = ' . PMA_convert_using($table, 'quoted') . ';';
}
- $row = PMA_DBI_fetch_single_row($sql_query);
+ $res = PMA_DBI_query($sql_query);
+ $row = PMA_DBI_fetch_assoc($res);
+ PMA_DBI_free_result($res);
}
if (empty($row)) {
if ($table == '*') {
if ($db == '*') {
$sql_query = 'SHOW COLUMNS FROM `mysql`.`user`;';
- } else {
+ } elseif ($table == '*') {
$sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;';
}
$res = PMA_DBI_query($sql_query);
@@ -323,18 +272,35 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = true, $indent =
}
}
if (isset($row['Table_priv'])) {
- PMA_addUSerTablePrivs($row);
+ $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';
+ }
+ unset($row['Table_priv'], $current_grant, $av_grants, $users_grants);
// get collumns
- $res = PMA_DBI_try_query('SHOW COLUMNS FROM `' . PMA_unescape_mysql_wildcards($db) . '`.`' . $table . '`;');
+ $res = PMA_DBI_try_query('SHOW COLUMNS FROM `' . PMA_unescape_mysql_wildcards( $db ) . '`.`' . $table . '`;');
$columns = array();
- if ($res) {
+ if ( $res ) {
while ($row1 = PMA_DBI_fetch_row($res)) {
$columns[$row1[0]] = array(
- 'Select' => false,
- 'Insert' => false,
- 'Update' => false,
- 'References' => false
+ 'Select' => FALSE,
+ 'Insert' => FALSE,
+ 'Update' => FALSE,
+ 'References' => FALSE
);
}
PMA_DBI_free_result($res);
@@ -342,27 +308,27 @@ 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)) {
+ if ( ! empty( $columns ) ) {
$res = PMA_DBI_query(
'SELECT `Column_name`, `Column_priv`'
.' FROM `mysql`.`columns_priv`'
.' WHERE ' . PMA_convert_using('`User`')
- .' = ' . PMA_convert_using(PMA_sqlAddslashes($_REQUEST['username']), 'quoted')
+ .' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted')
.' AND ' . PMA_convert_using('`Host`')
- .' = ' . PMA_convert_using($_REQUEST['hostname'], 'quoted')
+ .' = ' . PMA_convert_using($hostname, 'quoted')
.' AND ' . PMA_convert_using('`Db`')
- .' = ' . PMA_convert_using(PMA_unescape_mysql_wildcards($db), 'quoted')
+ .' = ' . PMA_convert_using( PMA_unescape_mysql_wildcards( $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]);
foreach ($row1[1] as $current) {
- $columns[$row1[0]][$current] = true;
+ $columns[$row1[0]][$current] = TRUE;
}
}
PMA_DBI_free_result($res);
- unset($res, $row1, $current);
+ unset( $res, $row1, $current );
echo $spaces . '' . "\n"
. $spaces . '' . "\n"
@@ -510,7 +476,7 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = true, $indent =
. $spaces . ' ' . $GLOBALS['strEnglishPrivileges'] . '
' . "\n"
. $spaces . '