Initial import.
[openemr.git] / interface / main / myadmin / server_privileges.php
blob98919242baaf771965c233579b7d5a5b43556710
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Does the common work
8 */
9 $js_to_run = 'server_privileges.js';
10 require('./server_common.inc.php');
13 /**
14 * Checks if a dropdown box has been used for selecting a database / table
16 if (!empty($pred_dbname)) {
17 $dbname = $pred_dbname;
18 unset($pred_dbname);
20 if (!empty($pred_tablename)) {
21 $tablename = $pred_tablename;
22 unset($pred_tablename);
26 /**
27 * Checks if the user is allowed to do what he tries to...
29 if (!$is_superuser) {
30 require('./server_links.inc.php');
31 echo '<h2>' . "\n"
32 . ' ' . $strPrivileges . "\n"
33 . '</h2>' . "\n"
34 . $strNoPrivileges . "\n";
35 require_once('./footer.inc.php');
39 /**
40 * Extracts the privilege information of a priv table row
42 * @param array the row
43 * @param boolean add <dfn> tag with tooltips
45 * @global ressource the database connection
47 * @return array
49 function PMA_extractPrivInfo($row = '', $enableHTML = FALSE)
51 global $userlink;
53 $grants = array(
54 array('Select_priv', 'SELECT', $GLOBALS['strPrivDescSelect']),
55 array('Insert_priv', 'INSERT', $GLOBALS['strPrivDescInsert']),
56 array('Update_priv', 'UPDATE', $GLOBALS['strPrivDescUpdate']),
57 array('Delete_priv', 'DELETE', $GLOBALS['strPrivDescDelete']),
58 array('Create_priv', 'CREATE', $GLOBALS['strPrivDescCreateDb']),
59 array('Drop_priv', 'DROP', $GLOBALS['strPrivDescDropDb']),
60 array('Reload_priv', 'RELOAD', $GLOBALS['strPrivDescReload']),
61 array('Shutdown_priv', 'SHUTDOWN', $GLOBALS['strPrivDescShutdown']),
62 array('Process_priv', 'PROCESS', $GLOBALS['strPrivDescProcess' . ((!empty($row) && isset($row['Super_priv'])) || (empty($row) && isset($GLOBALS['Super_priv'])) ? '4' : '3')]),
63 array('File_priv', 'FILE', $GLOBALS['strPrivDescFile']),
64 array('References_priv', 'REFERENCES', $GLOBALS['strPrivDescReferences']),
65 array('Index_priv', 'INDEX', $GLOBALS['strPrivDescIndex']),
66 array('Alter_priv', 'ALTER', $GLOBALS['strPrivDescAlter']),
67 array('Show_db_priv', 'SHOW DATABASES', $GLOBALS['strPrivDescShowDb']),
68 array('Super_priv', 'SUPER', $GLOBALS['strPrivDescSuper']),
69 array('Create_tmp_table_priv', 'CREATE TEMPORARY TABLES', $GLOBALS['strPrivDescCreateTmpTable']),
70 array('Lock_tables_priv', 'LOCK TABLES', $GLOBALS['strPrivDescLockTables']),
71 array('Execute_priv', 'EXECUTE', $GLOBALS['strPrivDescExecute']),
72 array('Repl_slave_priv', 'REPLICATION SLAVE', $GLOBALS['strPrivDescReplSlave']),
73 array('Repl_client_priv', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient'])
75 if (!empty($row) && isset($row['Table_priv'])) {
76 $sql_query = 'SHOW COLUMNS FROM `tables_priv` LIKE "Table_priv";';
77 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
78 unset($sql_query);
79 $row1 = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
80 mysql_free_result($res);
81 $av_grants = explode ('\',\'' , substr($row1['Type'], 5, strlen($row1['Type']) - 7));
82 unset($row1);
83 $users_grants = explode(',', $row['Table_priv']);
84 foreach ($av_grants as $current_grant) {
85 $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';
87 unset($current_grant);
88 unset($av_grants);
89 unset($users_grants);
91 $privs = array();
92 $allPrivileges = TRUE;
93 foreach ($grants as $current_grant) {
94 if ((!empty($row) && isset($row[$current_grant[0]])) || (empty($row) && isset($GLOBALS[$current_grant[0]]))) {
95 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']))))) {
96 if ($enableHTML) {
97 $privs[] = '<dfn title="' . $current_grant[2] . '">' . str_replace(' ', '&nbsp;', $current_grant[1]) . '</dfn>';
98 } else {
99 $privs[] = $current_grant[1];
101 } else if (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) {
102 if ($enableHTML) {
103 $priv_string = '<dfn title="' . $current_grant[2] . '">' . str_replace(' ', '&nbsp;', $current_grant[1]) . '</dfn>';
104 } else {
105 $priv_string = $current_grant[1];
107 $privs[] = $priv_string . ' (`' . join('`, `', $GLOBALS[$current_grant[0]]) . '`)';
108 } else {
109 $allPrivileges = FALSE;
113 if (empty($privs)) {
114 if ($enableHTML) {
115 $privs[] = '<dfn title="' . $GLOBALS['strPrivDescUsage'] . '">USAGE</dfn>';
116 } else {
117 $privs[] = 'USAGE';
119 } else if ($allPrivileges && (!isset($GLOBALS['grant_count']) || count($privs) == $GLOBALS['grant_count'])) {
120 if ($enableHTML) {
121 $privs = array('<dfn title="' . $GLOBALS['strPrivDescAllPrivileges'] . '">ALL&nbsp;PRIVILEGES</dfn>');
122 } else {
123 $privs = array('ALL PRIVILEGES');
126 return $privs;
127 } // end of the 'PMA_extractPrivInfo()' function
130 * Displays the privileges form table
132 * @param string the database
133 * @param string the table
134 * @param boolean wheather to display the submit button or not
135 * @param int the indenting level of the code
137 * @global array the phpMyAdmin configuration
138 * @global ressource the database connection
140 * @return void
142 function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = 0)
144 global $cfg, $userlink;
146 if ($db == '*') {
147 $table = '*';
149 $spaces = '';
150 for ($i = 0; $i < $indent; $i++) {
151 $spaces .= ' ';
153 if (isset($GLOBALS['username'])) {
154 $username = $GLOBALS['username'];
155 $hostname = $GLOBALS['hostname'];
156 if ($db == '*') {
157 $sql_query = 'SELECT * FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";';
158 } else if ($table == '*') {
159 $sql_query = 'SELECT * FROM `db` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '";';
160 } else {
161 $sql_query = 'SELECT `Table_priv` FROM `tables_priv` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '" AND `Table_name` = "' . $table . '";';
163 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
164 if ($res) {
165 $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
167 @mysql_free_result($res);
169 if (empty($row)) {
170 if ($table == '*') {
171 if ($db == '*') {
172 $sql_query = 'SHOW COLUMNS FROM `mysql`.`user`;';
173 } else if ($table == '*') {
174 $sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;';
176 $res = PMA_mysql_query($sql_query, $userlink)
177 or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
178 while ($row1 = PMA_mysql_fetch_row($res)) {
179 if (substr($row1[0], 0, 4) == 'max_') {
180 $row[$row1[0]] = 0;
181 } else {
182 $row[$row1[0]] = 'N';
185 mysql_free_result($res);
186 } else {
187 $row = array('Table_priv' => '');
190 if (isset($row['Table_priv'])) {
191 $sql_query = 'SHOW COLUMNS FROM `tables_priv` LIKE "Table_priv";';
192 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
193 unset($sql_query);
194 $row1 = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
195 mysql_free_result($res);
196 $av_grants = explode ('\',\'' , substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3));
197 unset($row1);
198 $users_grants = explode(',', $row['Table_priv']);
199 foreach ($av_grants as $current_grant) {
200 $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';
202 unset($row['Table_priv']);
203 unset($current_grant);
204 unset($av_grants);
205 unset($users_grants);
206 if ($res = PMA_mysql_query('SHOW COLUMNS FROM `' . $db . '`.`' . $table . '`;', $userlink)) {
207 $columns = array();
208 while ($row1 = PMA_mysql_fetch_row($res)) {
209 $columns[$row1[0]] = array(
210 'Select' => FALSE,
211 'Insert' => FALSE,
212 'Update' => FALSE,
213 'References' => FALSE
216 mysql_free_result($res);
217 unset($res);
218 unset($row1);
221 if (!empty($columns)) {
222 $sql_query = 'SELECT `Column_name`, `Column_priv` FROM `columns_priv` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '" AND `Table_name` = "' . $table . '";';
223 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
224 while ($row1 = PMA_mysql_fetch_row($res)) {
225 $row1[1] = explode(',', $row1[1]);
226 foreach ($row1[1] as $current) {
227 $columns[$row1[0]][$current] = TRUE;
230 mysql_free_result($res);
231 unset($res);
232 unset($row1);
233 unset($current);
234 echo $spaces . '<input type="hidden" name="grant_count" value="' . count($row) . '" />' . "\n"
235 . $spaces . '<input type="hidden" name="column_count" value="' . count($columns) . '" />' . "\n"
236 . $spaces . '<table border="0">' . "\n"
237 . $spaces . ' <tr>' . "\n"
238 . $spaces . ' <th colspan="6">&nbsp;' . $GLOBALS['strTblPrivileges'] . '&nbsp;</th>' . "\n"
239 . $spaces . ' </tr>' . "\n"
240 . $spaces . ' <tr>' . "\n"
241 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="6"><small><i>' . $GLOBALS['strEnglishPrivileges'] . '</i></small></td>' . "\n"
242 . $spaces . ' </tr>' . "\n"
243 . $spaces . ' <tr>' . "\n"
244 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescSelect'] . '">SELECT</dfn></tt>&nbsp;</td>' . "\n"
245 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescInsert'] . '">INSERT</dfn></tt>&nbsp;</td>' . "\n"
246 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescUpdate'] . '">UPDATE</dfn></tt>&nbsp;</td>' . "\n"
247 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescReferences'] . '">REFERENCES</dfn></tt>&nbsp;</td>' . "\n";
248 list($current_grant, $current_grant_value) = each($row);
249 while (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) {
250 list($current_grant, $current_grant_value) = each($row);
252 echo $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="checkbox" name="' . $current_grant . '" id="checkbox_' . $current_grant . '" value="Y" ' . ($current_grant_value == 'Y' ? 'checked="checked" ' : '') . 'title="' . (isset($GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))]) ? $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))] : $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5)) . 'Tbl']) . '"/></td>' . "\n"
253 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="checkbox_' . $current_grant . '"><tt><dfn title="' . (isset($GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))]) ? $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))] : $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5)) . 'Tbl']) . '">' . strtoupper(substr($current_grant, 0, strlen($current_grant) - 5)) . '</dfn></tt></label></td>' . "\n"
254 . $spaces . ' </tr>' . "\n"
255 . $spaces . ' <tr>' . "\n";
256 $rowspan = count($row) - 5;
257 echo $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
258 . $spaces . ' <select name="Select_priv[]" multiple="multiple">' . "\n";
259 foreach ($columns as $current_column => $current_column_privileges) {
260 echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"';
261 if ($row['Select_priv'] == 'Y' || $current_column_privileges['Select']) {
262 echo ' selected="selected"';
264 echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
266 echo $spaces . ' </select><br />' . "\n"
267 . $spaces . ' <i>' . $GLOBALS['strOr'] . '</i><br />' . "\n"
268 . $spaces . ' <input type="checkbox" name="Select_priv_none" id="checkbox_Select_priv_none" title="' . $GLOBALS['strNone'] . '" />' . "\n"
269 . $spaces . ' <label for="checkbox_Select_priv_none">' . $GLOBALS['strNone'] . '</label>' . "\n"
270 . $spaces . ' </td>' . "\n"
271 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
272 . $spaces . ' <select name="Insert_priv[]" multiple="multiple">' . "\n";
273 foreach ($columns as $current_column => $current_column_privileges) {
274 echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"';
275 if ($row['Insert_priv'] == 'Y' || $current_column_privileges['Insert']) {
276 echo ' selected="selected"';
278 echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
280 echo $spaces . ' </select><br />' . "\n"
281 . $spaces . ' <i>' . $GLOBALS['strOr'] . '</i><br />' . "\n"
282 . $spaces . ' <input type="checkbox" name="Insert_priv_none" id="checkbox_Insert_priv_none" title="' . $GLOBALS['strNone'] . '" />' . "\n"
283 . $spaces . ' <label for="checkbox_Insert_priv_none">' . $GLOBALS['strNone'] . '</label>' . "\n"
284 . $spaces . ' </td>' . "\n"
285 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
286 . $spaces . ' <select name="Update_priv[]" multiple="multiple">' . "\n";
287 foreach ($columns as $current_column => $current_column_privileges) {
288 echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"';
289 if ($row['Update_priv'] == 'Y' || $current_column_privileges['Update']) {
290 echo ' selected="selected"';
292 echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
294 echo $spaces . ' </select><br />' . "\n"
295 . $spaces . ' <i>' . $GLOBALS['strOr'] . '</i><br />' . "\n"
296 . $spaces . ' <input type="checkbox" name="Update_priv_none" id="checkbox_Update_priv_none" title="' . $GLOBALS['strNone'] . '" />' . "\n"
297 . $spaces . ' <label for="checkbox_Update_priv_none">' . $GLOBALS['strNone'] . '</label>' . "\n"
298 . $spaces . ' </td>' . "\n"
299 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
300 . $spaces . ' <select name="References_priv[]" multiple="multiple">' . "\n";
301 foreach ($columns as $current_column => $current_column_privileges) {
302 echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"';
303 if ($row['References_priv'] == 'Y' || $current_column_privileges['References']) {
304 echo ' selected="selected"';
306 echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
308 echo $spaces . ' </select><br />' . "\n"
309 . $spaces . ' <i>' . $GLOBALS['strOr'] . '</i><br />' . "\n"
310 . $spaces . ' <input type="checkbox" name="References_priv_none" id="checkbox_References_priv_none" title="' . $GLOBALS['strNone'] . '" />' . "\n"
311 . $spaces . ' <label for="checkbox_References_priv_none">' . $GLOBALS['strNone'] . '</label>' . "\n"
312 . $spaces . ' </td>' . "\n";
313 unset($rowspan);
314 list($current_grant, $current_grant_value) = each($row);
315 while (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) {
316 list($current_grant, $current_grant_value) = each($row);
318 echo $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="checkbox" name="' . $current_grant . '" id="checkbox_' . $current_grant . '" value="Y" ' . ($current_grant_value == 'Y' ? 'checked="checked" ' : '') . 'title="' . (isset($GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))]) ? $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))] : $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5)) . 'Tbl']) . '"/></td>' . "\n"
319 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="checkbox_' . $current_grant . '"><tt><dfn title="' . (isset($GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))]) ? $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))] : $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5)) . 'Tbl']) . '">' . strtoupper(substr($current_grant, 0, strlen($current_grant) - 5)) . '</dfn></tt></label></td>' . "\n"
320 . $spaces . ' </tr>' . "\n";
321 while (list($current_grant, $current_grant_value) = each($row)) {
322 if (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) {
323 continue;
325 echo $spaces . ' <tr>' . "\n"
326 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="checkbox" name="' . $current_grant . '" id="checkbox_' . $current_grant . '" value="Y" ' . ($current_grant_value == 'Y' ? 'checked="checked" ' : '') . 'title="' . (isset($GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))]) ? $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))] : $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5)) . 'Tbl']) . '"/></td>' . "\n"
327 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="checkbox_' . $current_grant . '"><tt><dfn title="' . (isset($GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))]) ? $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))] : $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5)) . 'Tbl']) . '">' . strtoupper(substr($current_grant, 0, strlen($current_grant) - 5)) . '</dfn></tt></label></td>' . "\n"
328 . $spaces . ' </tr>' . "\n";
330 } else {
331 $privTable[0] = array(
332 array('Select', 'SELECT', $GLOBALS['strPrivDescSelect']),
333 array('Insert', 'INSERT', $GLOBALS['strPrivDescInsert']),
334 array('Update', 'UPDATE', $GLOBALS['strPrivDescUpdate']),
335 array('Delete', 'DELETE', $GLOBALS['strPrivDescDelete'])
337 if ($db == '*') {
338 $privTable[0][] = array('File', 'FILE', $GLOBALS['strPrivDescFile']);
340 $privTable[1] = array(
341 array('Create', 'CREATE', ($table == '*' ? $GLOBALS['strPrivDescCreateDb'] : $GLOBALS['strPrivDescCreateTbl'])),
342 array('Alter', 'ALTER', $GLOBALS['strPrivDescAlter']),
343 array('Index', 'INDEX', $GLOBALS['strPrivDescIndex']),
344 array('Drop', 'DROP', ($table == '*' ? $GLOBALS['strPrivDescDropDb'] : $GLOBALS['strPrivDescDropTbl']))
346 if (isset($row['Create_tmp_table_priv'])) {
347 $privTable[1][] = array('Create_tmp_table', 'CREATE&nbsp;TEMPORARY&nbsp;TABLES', $GLOBALS['strPrivDescCreateTmpTable']);
349 $privTable[2] = array();
350 if (isset($row['Grant_priv'])) {
351 $privTable[2][] = array('Grant', 'GRANT', $GLOBALS['strPrivDescGrant']);
353 if ($db == '*') {
354 if (isset($row['Super_priv'])) {
355 $privTable[2][] = array('Super', 'SUPER', $GLOBALS['strPrivDescSuper']);
356 $privTable[2][] = array('Process', 'PROCESS', $GLOBALS['strPrivDescProcess4']);
357 } else {
358 $privTable[2][] = array('Process', 'PROCESS', $GLOBALS['strPrivDescProcess3']);
360 $privTable[2][] = array('Reload', 'RELOAD', $GLOBALS['strPrivDescReload']);
361 $privTable[2][] = array('Shutdown', 'SHUTDOWN', $GLOBALS['strPrivDescShutdown']);
362 if (isset($row['Show_db_priv'])) {
363 $privTable[2][] = array('Show_db', 'SHOW&nbsp;DATABASES', $GLOBALS['strPrivDescShowDb']);
366 if (isset($row['Lock_tables_priv'])) {
367 $privTable[2][] = array('Lock_tables', 'LOCK&nbsp;TABLES', $GLOBALS['strPrivDescLockTables']);
369 $privTable[2][] = array('References', 'REFERENCES', $GLOBALS['strPrivDescReferences']);
370 if ($db == '*') {
371 if (isset($row['Execute_priv'])) {
372 $privTable[2][] = array('Execute', 'EXECUTE', $GLOBALS['strPrivDescExecute']);
374 if (isset($row['Repl_client_priv'])) {
375 $privTable[2][] = array('Repl_client', 'REPLICATION&nbsp;CLIENT', $GLOBALS['strPrivDescReplClient']);
377 if (isset($row['Repl_slave_priv'])) {
378 $privTable[2][] = array('Repl_slave', 'REPLICATION&nbsp;SLAVE', $GLOBALS['strPrivDescReplSlave']);
381 echo $spaces . '<input type="hidden" name="grant_count" value="' . (count($privTable[0]) + count($privTable[1]) + count($privTable[2]) - (isset($row['Grant_priv']) ? 1 : 0)) . '" />' . "\n"
382 . $spaces . '<table border="0">' . "\n"
383 . $spaces . ' <tr>' . "\n"
384 . $spaces . ' <th colspan="6">&nbsp;' . ($db == '*' ? $GLOBALS['strGlobalPrivileges'] : ($table == '*' ? $GLOBALS['strDbPrivileges'] : $GLOBALS['strTblPrivileges'])) . '&nbsp;</th>' . "\n"
385 . $spaces . ' </tr>' . "\n"
386 . $spaces . ' <tr>' . "\n"
387 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="6"><small><i>' . $GLOBALS['strEnglishPrivileges'] . '</i></small></td>' . "\n"
388 . $spaces . ' </tr>' . "\n"
389 . $spaces . ' <tr>' . "\n"
390 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2">&nbsp;<b><i>' . $GLOBALS['strData'] . '</i></b>&nbsp;</td>' . "\n"
391 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2">&nbsp;<b><i>' . $GLOBALS['strStructure'] . '</i></b>&nbsp;</td>' . "\n"
392 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2">&nbsp;<b><i>' . $GLOBALS['strAdministration'] . '</i></b>&nbsp;</td>' . "\n"
393 . $spaces . ' </tr>' . "\n";
394 $limitTable = FALSE;
395 for ($i = 0; isset($privTable[0][$i]) || isset($privTable[1][$i]) || isset($privTable[2][$i]); $i++) {
396 echo $spaces . ' <tr>' . "\n";
397 for ($j = 0; $j < 3; $j++) {
398 if (isset($privTable[$j][$i])) {
399 echo $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="checkbox" name="' . $privTable[$j][$i][0] . '_priv" id="checkbox_' . $privTable[$j][$i][0] . '_priv" value="Y" ' . ($row[$privTable[$j][$i][0] . '_priv'] == 'Y' ? 'checked="checked" ' : '') . 'title="' . $privTable[$j][$i][2] . '"/></td>' . "\n"
400 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="checkbox_' . $privTable[$j][$i][0] . '_priv"><tt><dfn title="' . $privTable[$j][$i][2] . '">' . $privTable[$j][$i][1] . '</dfn></tt></label></td>' . "\n";
401 } else if ($db == '*' && !isset($privTable[0][$i]) && !isset($privTable[1][$i])
402 && isset($row['max_questions']) && isset($row['max_updates']) && isset($row['max_connections'])
403 && !$limitTable) {
404 echo $spaces . ' <td colspan="4" rowspan="' . (count($privTable[2]) - $i) . '">' . "\n"
405 . $spaces . ' <table border="0">' . "\n"
406 . $spaces . ' <tr>' . "\n"
407 . $spaces . ' <th colspan="2">&nbsp;' . $GLOBALS['strResourceLimits'] . '&nbsp;</th>' . "\n"
408 . $spaces . ' </tr>' . "\n"
409 . $spaces . ' <tr>' . "\n"
410 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="2"><small><i>' . $GLOBALS['strZeroRemovesTheLimit'] . '</i></small></td>' . "\n"
411 . $spaces . ' </tr>' . "\n"
412 . $spaces . ' <tr>' . "\n"
413 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="text_max_questions"><tt><dfn title="' . $GLOBALS['strPrivDescMaxQuestions'] . '">MAX&nbsp;QUERIES&nbsp;PER&nbsp;HOUR</dfn></tt></label></td>' . "\n"
414 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="text" class="textfield" name="max_questions" id="text_max_questions" value="' . $row['max_questions'] . '" size="11" maxlength="11" title="' . $GLOBALS['strPrivDescMaxQuestions'] . '" /></td>' . "\n"
415 . $spaces . ' </tr>' . "\n"
416 . $spaces . ' <tr>' . "\n"
417 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="text_max_updates"><tt><dfn title="' . $GLOBALS['strPrivDescMaxUpdates'] . '">MAX&nbsp;UPDATES&nbsp;PER&nbsp;HOUR</dfn></tt></label></td>' . "\n"
418 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="text" class="textfield" name="max_updates" id="text_max_updates" value="' . $row['max_updates'] . '" size="11" maxlength="11" title="' . $GLOBALS['strPrivDescMaxUpdates'] . '" /></td>' . "\n"
419 . $spaces . ' </tr>' . "\n"
420 . $spaces . ' <tr>' . "\n"
421 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="text_max_connections"><tt><dfn title="' . $GLOBALS['strPrivDescMaxConnections'] . '">MAX&nbsp;CONNECTIONS&nbsp;PER&nbsp;HOUR</dfn></tt></label></td>' . "\n"
422 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="text" class="textfield" name="max_connections" id="text_max_connections" value="' . $row['max_connections'] . '" size="11" maxlength="11" title="' . $GLOBALS['strPrivDescMaxConnections'] . '" /></td>' . "\n"
423 . $spaces . ' </tr>' . "\n"
424 . $spaces . ' </table>' . "\n"
425 . $spaces . ' </td>' . "\n";
426 $limitTable = TRUE;
427 } else if (!$limitTable) {
428 echo $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="2">&nbsp;</td>' . "\n";
432 echo $spaces . ' </tr>' . "\n";
434 if ($submit) {
435 echo $spaces . ' <tr>' . "\n"
436 . $spaces . ' <td colspan="6" align="center">' . "\n"
437 . $spaces . ' <input type="submit" name="update_privs" value="' . $GLOBALS['strGo'] . '" />' . "\n"
438 . $spaces . ' </td>' . "\n"
439 . $spaces . ' </tr>' . "\n";
441 echo $spaces . '</table>' . "\n";
442 } // end of the 'PMA_displayPrivTable()' function
446 * Displays the fields used by the "new user" form as well as the
447 * "change login information / copy user" form.
449 * @param string are we creating a new user or are we just changing one?
450 * (allowed values: 'new', 'change')
451 * @param int the indenting level of the code
453 * @global array the phpMyAdmin configuration
454 * @global ressource the database connection
456 * @return void
458 function PMA_displayLoginInformationFields($mode = 'new', $indent = 0)
460 global $cfg, $userlink;
461 $spaces = '';
462 for ($i = 0; $i < $indent; $i++) {
463 $spaces .= ' ';
465 echo $spaces . '<tr>' . "\n"
466 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
467 . $spaces . ' <label for="select_pred_username">' . "\n"
468 . $spaces . ' ' . $GLOBALS['strUserName'] . ':' . "\n"
469 . $spaces . ' </label>' . "\n"
470 . $spaces . ' </td>' . "\n"
471 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
472 . $spaces . ' <select name="pred_username" id="select_pred_username" title="' . $GLOBALS['strUserName'] . '"' . "\n"
473 . $spaces . ' onchange="if (this.value == \'any\') { username.value = \'\'; } else if (this.value == \'userdefined\') { username.focus(); username.select(); }">' . "\n"
474 . $spaces . ' <option value="any"' . ((isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any') ? ' selected="selected"' : '') . '>' . $GLOBALS['strAnyUser'] . '</option>' . "\n"
475 . $spaces . ' <option value="userdefined"' . ((!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined') ? ' selected="selected"' : '') . '>' . $GLOBALS['strUseTextField'] . ':</option>' . "\n"
476 . $spaces . ' </select>' . "\n"
477 . $spaces . ' </td>' . "\n"
478 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
479 . $spaces . ' <input type="text" class="textfield" name="username" class="textfield" title="' . $GLOBALS['strUserName'] . '"' . (empty($GLOBALS['username']) ? '' : ' value="' . (isset($GLOBALS['new_username']) ? $GLOBALS['new_username'] : $GLOBALS['username']) . '"') . ' onchange="pred_username.value = \'userdefined\';" />' . "\n"
480 . $spaces . ' </td>' . "\n"
481 . $spaces . '</tr>' . "\n"
482 . $spaces . '<tr>' . "\n"
483 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
484 . $spaces . ' <label for="select_pred_hostname">' . "\n"
485 . $spaces . ' ' . $GLOBALS['strHost'] . ':' . "\n"
486 . $spaces . ' </label>' . "\n"
487 . $spaces . ' </td>' . "\n"
488 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
489 . $spaces . ' <select name="pred_hostname" id="select_pred_hostname" title="' . $GLOBALS['strHost'] . '"' . "\n";
490 $res = PMA_mysql_query('SELECT USER();', $userlink);
491 $row = @PMA_mysql_fetch_row($res);
492 @mysql_free_result($res);
493 unset($res);
494 if (!empty($row[0])) {
495 $thishost = str_replace("'", '', substr($row[0], (strrpos($row[0], '@') + 1)));
496 if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
497 unset($thishost);
500 echo $spaces . ' onchange="if (this.value == \'any\') { hostname.value = \'%\'; } else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } '
501 . (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; } ')
502 . 'else if (this.value == \'hosttable\') { hostname.value = \'\'; } else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n";
503 unset($row);
504 echo $spaces . ' <option value="any"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any') ? ' selected="selected"' : '') . '>' . $GLOBALS['strAnyHost'] . '</option>' . "\n"
505 . $spaces . ' <option value="localhost"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost') ? ' selected="selected"' : '') . '>' . $GLOBALS['strLocalhost'] . '</option>' . "\n";
506 if (!empty($thishost)) {
507 echo $spaces . ' <option value="thishost"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'thishost') ? ' selected="selected"' : '') . '>' . $GLOBALS['strThisHost'] . '</option>' . "\n";
509 unset($thishost);
510 echo $spaces . ' <option value="hosttable"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable') ? ' selected="selected"' : '') . '>' . $GLOBALS['strUseHostTable'] . '</option>' . "\n"
511 . $spaces . ' <option value="userdefined"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined') ? ' selected="selected"' : '') . '>' . $GLOBALS['strUseTextField'] . ':</option>' . "\n"
512 . $spaces . ' </select>' . "\n"
513 . $spaces . ' </td>' . "\n"
514 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
515 . $spaces . ' <input type="text" class="textfield" name="hostname" value="' . ( isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '' ) . '" class="textfield" title="' . $GLOBALS['strHost'] . '" onchange="pred_hostname.value = \'userdefined\';" />' . "\n"
516 . $spaces . ' </td>' . "\n"
517 . $spaces . '</tr>' . "\n"
518 . $spaces . '<tr>' . "\n"
519 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
520 . $spaces . ' <label for="select_pred_password">' . "\n"
521 . $spaces . ' ' . $GLOBALS['strPassword'] . ':' . "\n"
522 . $spaces . ' </label>' . "\n"
523 . $spaces . ' </td>' . "\n"
524 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
525 . $spaces . ' <select name="pred_password" id="select_pred_password" title="' . $GLOBALS['strPassword'] . '"' . "\n"
526 . $spaces . ' onchange="if (this.value == \'none\') { pma_pw.value = \'\'; pma_pw2.value = \'\'; } else if (this.value == \'userdefined\') { pma_pw.focus(); pma_pw.select(); }">' . "\n"
527 . ($mode == 'change' ? $spaces . ' <option value="keep" selected="selected">' . $GLOBALS['strKeepPass'] . '</option>' . "\n" : '')
528 . $spaces . ' <option value="none">' . $GLOBALS['strNoPassword'] . '</option>' . "\n"
529 . $spaces . ' <option value="userdefined"' . ($mode == 'change' ? '' : ' selected="selected"') . '>' . $GLOBALS['strUseTextField'] . ':</option>' . "\n"
530 . $spaces . ' </select>' . "\n"
531 . $spaces . ' </td>' . "\n"
532 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
533 . $spaces . ' <input type="password" name="pma_pw" class="textfield" title="' . $GLOBALS['strPassword'] . '" onchange="pred_password.value = \'userdefined\';" />' . "\n"
534 . $spaces . ' </td>' . "\n"
535 . $spaces . '</tr>' . "\n"
536 . $spaces . '<tr>' . "\n"
537 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
538 . $spaces . ' <label for="text_pma_pw2">' . "\n"
539 . $spaces . ' ' . $GLOBALS['strReType'] . ':' . "\n"
540 . $spaces . ' </label>' . "\n"
541 . $spaces . ' </td>' . "\n"
542 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">&nbsp;</td>' . "\n"
543 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
544 . $spaces . ' <input type="password" name="pma_pw2" id="text_pma_pw2" class="textfield" title="' . $GLOBALS['strReType'] . '" onchange="pred_password.value = \'userdefined\';" />' . "\n"
545 . $spaces . ' </td>' . "\n"
546 . $spaces . '</tr>' . "\n";
547 } // end of the 'PMA_displayUserAndHostFields()' function
551 * Changes / copies a user, part I
553 if (!empty($change_copy)) {
554 $local_query = 'SELECT * FROM `mysql`.`user` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";';
555 $res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
556 if (!$res) {
557 $message = $strNoUsersFound;
558 unset($change_copy);
559 } else {
560 $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
561 extract($row, EXTR_OVERWRITE);
562 mysql_free_result($res);
563 $queries = array();
569 * Adds a user
570 * (Changes / copies a user, part II)
572 if (!empty($adduser_submit) || !empty($change_copy)) {
573 unset($sql_query);
574 if ($pred_username == 'any') {
575 $username = '';
577 switch ($pred_hostname) {
578 case 'any':
579 $hostname = '%';
580 break;
581 case 'localhost':
582 $hostname = 'localhost';
583 break;
584 case 'hosttable':
585 $hostname = '';
586 break;
587 case 'thishost':
588 $res = PMA_mysql_query('SELECT USER();', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SELECT USER();');
589 $row = PMA_mysql_fetch_row($res);
590 mysql_free_result($res);
591 unset($res);
592 $hostname = substr($row[0], (strrpos($row[0], '@') + 1));
593 unset($row);
594 break;
596 $local_query = 'SELECT "foo" FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";';
597 $res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
598 unset($local_query);
599 if (mysql_affected_rows($userlink) == 1) {
600 $message = sprintf($strUserAlreadyExists, '<i>\'' . $username . '\'@\'' . $hostname . '\'</i>');
601 $adduser = 1;
602 } else {
603 $real_sql_query = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON *.* TO "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '"';
604 if ($pred_password != 'none' && $pred_password != 'keep') {
605 $pma_pw_hidden = '';
606 for ($i = 0; $i < strlen($pma_pw); $i++) {
607 $pma_pw_hidden .= '*';
609 $sql_query = $real_sql_query . ' IDENTIFIED BY "' . $pma_pw_hidden . '"';
610 $real_sql_query .= ' IDENTIFIED BY "' . $pma_pw . '"';
611 } else {
612 if ($pred_password == 'keep' && !empty($password)) {
613 $real_sql_query .= ' IDENTIFIED BY PASSWORD "' . $password . '"';
615 $sql_query = $real_sql_query;
617 if ((isset($Grant_priv) && $Grant_priv == 'Y') || (PMA_MYSQL_INT_VERSION >= 40002 && (isset($max_questions) || isset($max_connections) || isset($max_updates)))) {
618 $real_sql_query .= 'WITH';
619 $sql_query .= 'WITH';
620 if (isset($Grant_priv) && $Grant_priv == 'Y') {
621 $real_sql_query .= ' GRANT OPTION';
622 $sql_query .= ' GRANT OPTION';
624 if (PMA_MYSQL_INT_VERSION >= 40002) {
625 if (isset($max_questions)) {
626 $real_sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions;
627 $sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions;
629 if (isset($max_connections)) {
630 $real_sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections;
631 $sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections;
633 if (isset($max_updates)) {
634 $real_sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates;
635 $sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates;
639 $real_sql_query .= ';';
640 $sql_query .= ';';
641 if (empty($change_copy)) {
642 PMA_mysql_query($real_sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
643 $message = $strAddUserMessage;
644 } else {
645 $queries[] = $sql_query;
647 unset($real_sql_query);
648 mysql_free_result($res);
649 unset($res);
655 * Changes / copies a user, part III
657 if (!empty($change_copy)) {
658 $local_query = 'SELECT * FROM `mysql`.`db` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";';
659 $res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
660 while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
661 $queries[] = 'GRANT ' . join(', ', PMA_extractPrivInfo($row)) . ' ON `' . $row['Db'] . '`.* TO "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '"' . ($row['Grant_priv'] == 'Y' ? ' WITH GRANT OPTION' : '') . ';';
663 mysql_free_result($res);
664 $local_query = 'SELECT `Db`, `Table_name`, `Table_priv` FROM `mysql`.`tables_priv` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";';
665 $res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
666 while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
667 $local_query = 'SELECT `Column_name`, `Column_priv` FROM `mysql`.`columns_priv` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '" AND `Db` = "' . $row['Db'] . '";';
668 $res2 = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
669 $tmp_privs1 = PMA_extractPrivInfo($row);
670 $tmp_privs2 = array(
671 'Select' => array(),
672 'Insert' => array(),
673 'Update' => array(),
674 'References' => array()
676 while ($row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC)) {
677 $tmp_array = explode(',', $row2['Column_priv']);
678 if (in_array('Select', $tmp_array)) {
679 $tmp_privs2['Select'][] = $row2['Column_name'];
681 if (in_array('Insert', $tmp_array)) {
682 $tmp_privs2['Insert'][] = $row2['Column_name'];
684 if (in_array('Update', $tmp_array)) {
685 $tmp_privs2['Update'][] = $row2['Column_name'];
687 if (in_array('References', $tmp_array)) {
688 $tmp_privs2['References'][] = $row2['Column_name'];
690 unset($tmp_array);
692 if (count($tmp_privs2['Select']) > 0 && !in_array('SELECT', $tmp_privs1)) {
693 $tmp_privs1[] = 'SELECT (`' . join('`, `', $tmp_privs2['Select']) . '`)';
695 if (count($tmp_privs2['Insert']) > 0 && !in_array('INSERT', $tmp_privs1)) {
696 $tmp_privs1[] = 'INSERT (`' . join(', ', $tmp_privs2['Insert']) . '`)';
698 if (count($tmp_privs2['Update']) > 0 && !in_array('UPDATE', $tmp_privs1)) {
699 $tmp_privs1[] = 'UPDATE (`' . join(', ', $tmp_privs2['Update']) . '`)';
701 if (count($tmp_privs2['References']) > 0 && !in_array('REFERENCES', $tmp_privs1)) {
702 $tmp_privs1[] = 'REFERENCES (`' . join(', ', $tmp_privs2['References']) . '`)';
704 unset($tmp_privs2);
705 $queries[] = 'GRANT ' . join(', ', $tmp_privs1) . ' ON `' . $row['Db'] . '`.`' . $row['Table_name'] . '` TO "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '"' . (in_array('Grant', explode(',', $row['Table_priv'])) ? ' WITH GRANT OPTION' : '') . ';';
711 * Updates privileges
713 if (!empty($update_privs)) {
714 $db_and_table = empty($dbname) ? '*.*' : PMA_backquote($dbname) . '.' . (empty($tablename) ? '*' : PMA_backquote($tablename));
715 $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '";';
716 if (!isset($Grant_priv) || $Grant_priv != 'Y') {
717 $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '";';
719 $sql_query2 = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON ' . $db_and_table . ' TO "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '"';
720 if ((isset($Grant_priv) && $Grant_priv == 'Y') || (empty($dbname) && PMA_MYSQL_INT_VERSION >= 40002 && (isset($max_questions) || isset($max_connections) || isset($max_updates)))) {
721 $sql_query2 .= 'WITH';
722 if (isset($Grant_priv) && $Grant_priv == 'Y') {
723 $sql_query2 .= ' GRANT OPTION';
725 if (PMA_MYSQL_INT_VERSION >= 40002) {
726 if (isset($max_questions)) {
727 $sql_query2 .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions;
729 if (isset($max_connections)) {
730 $sql_query2 .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections;
732 if (isset($max_updates)) {
733 $sql_query2 .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates;
737 $sql_query2 .= ';';
738 PMA_mysql_query($sql_query0, $userlink); // this query may fail, but this does not matter :o)
739 if (isset($sql_query1)) {
740 PMA_mysql_query($sql_query1, $userlink); // this one may fail, too...
742 PMA_mysql_query($sql_query2, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query2);
743 $sql_query = $sql_query0 . ' ' . (isset($sql_query1) ? $sql_query1 . ' ' : '') . $sql_query2;
744 $message = sprintf($strUpdatePrivMessage, '\'' . $username . '\'@\'' . $hostname . '\'');
749 * Revokes Privileges
751 if (!empty($revokeall)) {
752 $db_and_table = PMA_backquote($dbname) . '.' . (empty($tablename) ? '*' : PMA_backquote($tablename));
753 $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";';
754 $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";';
755 PMA_mysql_query($sql_query0, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query0);
756 PMA_mysql_query($sql_query1, $userlink); // this one may fail, too...
757 $sql_query = $sql_query0 . ' ' . $sql_query1;
758 $message = sprintf($strRevokeMessage, '\'' . $username . '\'@\'' . $hostname . '\'');
759 if (empty($tablename)) {
760 unset($dbname);
761 } else {
762 unset($tablename);
768 * Updates the password
770 if (!empty($change_pw)) {
771 if ($nopass == 1) {
772 $sql_query = 'SET PASSWORD FOR "' . $username . '"@"' . $hostname . '" = ""';
773 PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
774 $message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\'');
775 } else if (empty($pma_pw) || empty($pma_pw2)) {
776 $message = $strPasswordEmpty;
777 } else if ($pma_pw != $pma_pw2) {
778 $message = $strPasswordNotSame;
779 } else {
780 $hidden_pw = '';
781 for ($i = 0; $i < strlen($pma_pw); $i++) {
782 $hidden_pw .= '*';
784 $local_query = 'SET PASSWORD FOR "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '" = PASSWORD("' . PMA_sqlAddslashes($pma_pw) . '")';
785 $sql_query = 'SET PASSWORD FOR "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '" = PASSWORD("' . $hidden_pw . '")';
786 PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
787 $message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\'');
793 * Deletes users
794 * (Changes / copies a user, part IV)
796 if (!empty($delete) || (!empty($change_copy) && $mode < 4)) {
797 if (!empty($change_copy)) {
798 $selected_usr = array($old_username . '@' . $old_hostname);
799 } else {
800 $queries = array();
802 for ($i = 0; isset($selected_usr[$i]); $i++) {
803 list($this_user, $this_host) = explode('@', $selected_usr[$i]);
804 $queries[] = '# ' . sprintf($strDeleting, '\'' . $this_user . '\'@\'' . $this_host . '\'') . ' ...';
805 if ($mode == 2) {
806 // The SHOW GRANTS query may fail if the user has not been loaded
807 // into memory
808 $res = PMA_mysql_query('SHOW GRANTS FOR "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";', $userlink);
809 if ($res) {
810 $queries[] = 'REVOKE ALL PRIVILEGES ON *.* FROM "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";';
811 while ($row = PMA_mysql_fetch_row($res)) {
812 $this_table = substr($row[0], (strpos($row[0], 'ON') + 3), (strpos($row[0], ' TO ') - strpos($row[0], 'ON') - 3));
813 if ($this_table != '*.*') {
814 $queries[] = 'REVOKE ALL PRIVILEGES ON ' . $this_table . ' FROM "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";';
816 if (strpos($row[0], 'WITH GRANT OPTION')) {
817 $queries[] = 'REVOKE GRANT OPTION ON ' . $this_table . ' FROM "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";';
820 unset($this_table);
822 mysql_free_result($res);
824 unset($res);
826 $queries[] = 'DELETE FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($this_user) . '" AND `Host` = "' . $this_host . '";';
827 if ($mode != 2) {
828 // If we REVOKE the table grants, we should not need to modify the
829 // `db`, `tables_priv` and `columns_priv` tables manually...
830 $queries[] = 'DELETE FROM `db` WHERE `User` = "' . PMA_sqlAddslashes($this_user) . '" AND `Host` = "' . $this_host . '";';
831 $queries[] = 'DELETE FROM `tables_priv` WHERE `User` = "' . PMA_sqlAddslashes($this_user) . '" AND `Host` = "' . $this_host . '";';
832 $queries[] = 'DELETE FROM `columns_priv` WHERE `User` = "' . PMA_sqlAddslashes($this_user) . '" AND `Host` = "' . $this_host . '";';
834 if (!empty($drop_users_db)) {
835 $queries[] = 'DROP DATABASE IF EXISTS ' . PMA_backquote($this_user) . ';';
838 if (empty($change_copy)) {
839 if (empty($queries)) {
840 $message = $strError . ': ' . $strDeleteNoUsersSelected;
841 } else {
842 if ($mode == 3) {
843 $queries[] = '# ' . $strReloadingThePrivileges . ' ...';
844 $queries[] = 'FLUSH PRIVILEGES;';
846 foreach ($queries as $sql_query) {
847 if ($sql_query{0} != '#') {
848 PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
851 $sql_query = join("\n", $queries);
852 $message = $strUsersDeleted;
854 unset($queries);
860 * Changes / copies a user, part V
862 if (!empty($change_copy)) {
863 foreach ($queries as $sql_query) {
864 if ($sql_query{0} != '#') {
865 PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
868 $message = $strSuccess;
869 $sql_query = join("\n", $queries);
874 * Reloads the privilege tables into memory
876 if (!empty($flush_privileges)) {
877 $sql_query = 'FLUSH PRIVILEGES';
878 if (@PMA_mysql_query($sql_query, $userlink)) {
879 $message = $strPrivilegesReloaded;
880 } else {
881 PMA_mysqlDie(PMA_mysql_error($userlink));
887 * Displays the links
889 require('./server_links.inc.php');
893 * Displays the page
895 if (empty($adduser) && empty($checkprivs)) {
896 if (!isset($username)) {
897 // No username is given --> display the overview
898 echo '<h2>' . "\n"
899 . ' ' . $strUserOverview . "\n"
900 . '</h2>' . "\n";
901 $oldPrivTables = FALSE;
902 if (PMA_MYSQL_INT_VERSION >= 40002) {
903 $res = PMA_mysql_query('SELECT `User`, `Host`, IF(`Password` = "", "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` ORDER BY `User` ASC, `Host` ASC;', $userlink);
904 if (!$res) {
905 // the query failed! This may have two reasons:
906 // - the user has not enough privileges
907 // - the privilege tables use a structure of an earlier version.
908 $oldPrivTables = TRUE;
911 if (empty($res) || PMA_MYSQL_INT_VERSION < 40002) {
912 $res = PMA_mysql_query('SELECT `User`, `Host`, IF(`Password` = "", "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` ORDER BY `User` ASC, `Host` ASC;', $userlink);
913 if (!$res) {
914 // the query failed! This may have two reasons:
915 // - the user has not enough privileges
916 // - the privilege tables use a structure of an earlier version.
917 $oldPrivTables = TRUE;
920 if (!$res) {
921 echo '<i>' . $strNoPrivileges . '</i>' . "\n";
922 @mysql_free_result($res);
923 unset($res);
924 } else {
925 if ($oldPrivTables) {
926 // rabus: This message is hardcoded because I will replace it by
927 // a automatic repair feature soon.
928 echo '<div class="warning">' . "\n"
929 . ' Warning: Your privilege table structure seem to be older than this MySQL version!<br />' . "\n"
930 . ' Please run the script <tt>mysql_fix_privilege_tables</tt> that should be included in your MySQL server distribution to solve this problem!' . "\n"
931 . '</div><br />' . "\n";
933 echo '<form name="usersForm" action="server_privileges.php" method="post" />' . "\n"
934 . PMA_generate_common_hidden_inputs('', '', 1)
935 . ' <table border="0">' . "\n"
936 . ' <tr>' . "\n"
937 . ' <th></th>' . "\n"
938 . ' <th>&nbsp;' . $strUser . '&nbsp;</th>' . "\n"
939 . ' <th>&nbsp;' . $strHost . '&nbsp;</th>' . "\n"
940 . ' <th>&nbsp;' . $strPassword . '&nbsp;</th>' . "\n"
941 . ' <th>&nbsp;' . $strGlobalPrivileges . '&nbsp;</th>' . "\n"
942 . ' <th>&nbsp;' . $strGrantOption . '&nbsp;</th>' . "\n"
943 . ' <th>&nbsp;' . $strAction . '&nbsp;</th>' . "\n";
944 echo ' </tr>' . "\n";
945 $useBgcolorOne = TRUE;
946 for ($i = 0; $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC); $i++) {
947 echo ' <tr>' . "\n"
948 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><input type="checkbox" name="selected_usr[]" id="checkbox_sel_users_' . $i . '" value="' . htmlspecialchars($row['User'] . '@' . $row['Host']) . '"' . (empty($checkall) ? '' : ' checked="checked"') . ' /></td>' . "\n"
949 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><label for="checkbox_sel_users_' . $i . '">' . (empty($row['User']) ? '<span style="color: #FF0000">' . $strAny . '</span>' : htmlspecialchars($row['User'])) . '</label></td>' . "\n"
950 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars($row['Host']) . '</td>' . "\n";
951 $privs = PMA_extractPrivInfo($row, TRUE);
952 echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . ($row['Password'] == 'Y' ? $strYes : '<span style="color: #FF0000">' . $strNo . '</span>') . '</td>' . "\n"
953 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
954 . ' ' . join(',' . "\n" . ' ', $privs) . "\n"
955 . ' </tt></td>' . "\n"
956 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . ($row['Grant_priv'] == 'Y' ? $strYes : $strNo) . '</td>' . "\n"
957 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($row['User']) . '&amp;hostname=' . urlencode($row['Host']) . '">' . $strEdit . '</a></td>' . "\n"
958 . ' </tr>' . "\n";
959 $useBgcolorOne = !$useBgcolorOne;
961 @mysql_free_result($res);
962 unset($res);
963 unset ($row);
964 echo ' <tr>' . "\n"
965 . ' <td></td>' . "\n"
966 . ' <td colspan="5">' . "\n"
967 . ' &nbsp;<i>' . $strEnglishPrivileges . '</i>&nbsp;' . "\n"
968 . ' </td>' . "\n"
969 . ' </tr>' . "\n"
970 . ' <tr>' . "\n"
971 . ' <td colspan="6" valign="bottom">' . "\n"
972 . ' <img src="./images/arrow_' . $text_dir . '.gif" border="0" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n"
973 . ' <a href="./server_privileges.php?' . $url_query . '&amp;checkall=1" onclick="setCheckboxes(\'usersForm\', \'selected_usr\', true); return false;">' . $strCheckAll . '</a>' . "\n"
974 . ' &nbsp;/&nbsp;' . "\n"
975 . ' <a href="server_privileges.php?' . $url_query . '" onclick="setCheckboxes(\'usersForm\', \'selected_usr\', false); return false;">' . $strUncheckAll . '</a>' . "\n"
976 . ' </td>' . "\n"
977 . ' </tr>' . "\n"
978 . ' </table>' . "\n"
979 . ' <ul>' . "\n"
980 . ' <li>' . "\n"
981 . ' <b><a href="server_privileges.php?' . $url_query . '&amp;adduser=1">' . $strAddUser . '</a></b><br />' . "\n"
982 . ' </li><br /><br />' . "\n"
983 . ' <li>' . "\n"
984 . ' <b>' . $strRemoveSelectedUsers . '</b><br />' . "\n"
985 . ' <input type="radio" title="' . $strJustDelete . ' ' . $strJustDeleteDescr . '" name="mode" id="radio_mode_1" value="1" checked="checked" />' . "\n"
986 . ' <label for="radio_mode_1" title="' . $strJustDelete . ' ' . $strJustDeleteDescr . '">' . "\n"
987 . ' ' . $strJustDelete . "\n"
988 . ' </label><br />' . "\n"
989 . ' <input type="radio" title="' . $strRevokeAndDelete . ' ' . $strRevokeAndDeleteDescr . '" name="mode" id="radio_mode_2" value="2" />' . "\n"
990 . ' <label for="radio_mode_2" title="' . $strRevokeAndDelete . ' ' . $strRevokeAndDeleteDescr . '">' . "\n"
991 . ' ' . $strRevokeAndDelete . "\n"
992 . ' </label><br />' . "\n"
993 . ' <input type="radio" title="' . $strDeleteAndFlush . ' ' . $strDeleteAndFlushDescr . '" name="mode" id="radio_mode_3" value="3" />' . "\n"
994 . ' <label for="radio_mode_3" title="' . $strDeleteAndFlush . ' ' . $strDeleteAndFlushDescr . '">' . "\n"
995 . ' ' . $strDeleteAndFlush . "\n"
996 . ' </label><br />' . "\n"
997 . ' <input type="checkbox" title="' . $strDropUsersDb . '" name="drop_users_db" id="checkbox_drop_users_db" />' . "\n"
998 . ' <label for="checkbox_drop_users_db" title="' . $strDropUsersDb . '">' . "\n"
999 . ' ' . $strDropUsersDb . "\n"
1000 . ' </label><br />' . "\n"
1001 . ' <input type="submit" name="delete" value="' . $strGo . '" />' . "\n"
1002 . ' </li>' . "\n"
1003 . ' </ul>' . "\n"
1004 . '</form>' . "\n"
1005 . '<div>' . "\n"
1006 . ' ' . sprintf($strFlushPrivilegesNote, '<a href="server_privileges.php?' . $url_query . '&amp;flush_privileges=1">', '</a>') . "\n"
1007 . '</div>' . "\n";
1009 } else {
1010 // A user was selected -> display the user's properties
1011 echo '<h2>' . "\n"
1012 . ' ' . $strUser . ' <i><a class="h2" href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '">\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'</a></i>' . "\n";
1013 if (!empty($dbname)) {
1014 echo ' - ' . $strDatabase . ' <i><a class="h2" href="' . $cfg['DefaultTabDatabase'] . '?' . $url_query . '&amp;db=' . urlencode($dbname) . '&amp;reload=1">' . htmlspecialchars($dbname) . '</a></i>' . "\n";
1015 if (!empty($tablename)) {
1016 echo ' - ' . $strTable . ' <i><a class="h2" href="' . $cfg['DefaultTabTable'] . '?' . $url_query . '&amp;db=' . urlencode($dbname) . '&amp;table=' . urlencode($tablename) . '&amp;reload=1">' . htmlspecialchars($tablename) . '</a></i>' . "\n";
1019 echo '</h2>' . "\n";
1020 $res = PMA_mysql_query('SELECT "foo" FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";', $userlink);
1021 if (mysql_affected_rows($userlink) <= 0) {
1022 echo $strUserNotFound;
1023 require_once('./footer.inc.php');
1025 mysql_free_result($res);
1026 unset($res);
1027 echo '<ul>' . "\n"
1028 . ' <li>' . "\n"
1029 . ' <form action="server_privileges.php" method="post">' . "\n"
1030 . PMA_generate_common_hidden_inputs('', '', 3)
1031 . ' <input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
1032 . ' <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
1033 if (!empty($dbname)) {
1034 echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '" />' . "\n";
1035 if (!empty($tablename)) {
1036 echo ' <input type="hidden" name="tablename" value="' . htmlspecialchars($tablename) . '" />' . "\n";
1039 echo ' <b>' . $strEditPrivileges . '</b><br />' . "\n";
1040 PMA_displayPrivTable((empty($dbname) ? '*' : $dbname), ((empty($dbname) || empty($tablename)) ? '*' : $tablename), TRUE, 3);
1041 echo ' </form>' . "\n"
1042 . ' </li>' . "\n";
1043 if (empty($tablename)) {
1044 echo ' <li>' . "\n"
1045 . ' <b>' . (empty($dbname) ? $strDbPrivileges : $strTblPrivileges) . '</b><br />' . "\n"
1046 . ' <table border="0">' . "\n"
1047 . ' <tr>' . "\n"
1048 . ' <th>&nbsp;' . (empty($dbname) ? $strDatabase : $strTable) . '&nbsp;</th>' . "\n"
1049 . ' <th>&nbsp;' . $strPrivileges . '&nbsp;</th>' . "\n"
1050 . ' <th>&nbsp;' . $strGrantOption . '&nbsp;</th>' . "\n"
1051 . ' <th>&nbsp;' . (empty($dbname) ? $strTblPrivileges : $strColumnPrivileges) . '&nbsp;</th>' . "\n"
1052 . ' <th colspan="2">&nbsp;' . $strAction . '&nbsp;</th>' . "\n"
1053 . ' </tr>' . "\n";
1054 if (empty($dbname)) {
1055 $sql_query = 'SELECT * FROM `db` WHERE `Host` = "' . $hostname . '" AND `User` = "' . PMA_sqlAddslashes($username) . '" ORDER BY `Db` ASC;';
1056 } else {
1057 $sql_query = 'SELECT `Table_name`, `Table_priv`, IF(`Column_priv` = "", 0, 1) AS "Column_priv" FROM `tables_priv` WHERE `Host` = "' . $hostname . '" AND `User` = "' . PMA_sqlAddslashes($username) . '" AND `Db` = "' . $dbname . '" ORDER BY `Table_name` ASC;';
1059 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
1060 if (mysql_affected_rows($userlink) == 0) {
1061 echo ' <tr>' . "\n"
1062 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="6"><center><i>' . $strNone . '</i></center></td>' . "\n"
1063 . ' </tr>' . "\n";
1064 } else {
1065 $useBgcolorOne = TRUE;
1066 if (empty($dbname)) {
1067 $res2 = PMA_mysql_query('SELECT `Db` FROM `tables_priv` WHERE `Host` = "' . $hostname . '" AND `User` = "' . PMA_sqlAddslashes($username) . '" GROUP BY `Db` ORDER BY `Db` ASC;') or PMA_mysqlDie(PMA_mysql_error($userlink), 'SELECT `Db` FROM `tables_priv` WHERE `Host` = "' . $hostname . '" AND `User` = "' . PMA_sqlAddslashes($username) . '" GROUP BY `Db` ORDER BY `Db` ASC;');
1068 $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
1070 $found_rows = array();
1071 while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
1073 while (empty($dbname) && $row2 && $row['Db'] > $row2['Db']) {
1074 $found_rows[] = $row2['Db'];
1076 echo ' <tr>' . "\n"
1077 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars($row2['Db']) . '</td>' . "\n"
1078 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
1079 . ' <dfn title="' . $strPrivDescUsage . '">USAGE</dfn>' . "\n"
1080 . ' </tt></td>' . "\n"
1081 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strNo . '</td>' . "\n"
1082 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strYes . '</td>' . "\n"
1083 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '">' . $strEdit . '</a></td>' . "\n"
1084 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '&amp;revokeall=1">' . $strRevoke . '</a></td>' . "\n"
1085 . ' </tr>' . "\n";
1086 $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
1087 $useBgcolorOne = !$useBgcolorOne;
1088 } // end while
1089 $found_rows[] = empty($dbname) ? $row['Db'] : $row['Table_name'];
1091 echo ' <tr>' . "\n"
1092 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars(empty($dbname) ? $row['Db'] : $row['Table_name']) . '</td>' . "\n"
1093 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
1094 . ' ' . join(',' . "\n" . ' ', PMA_extractPrivInfo($row, TRUE)) . "\n"
1095 . ' </tt></td>' . "\n"
1096 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . (((empty($dbname) && $row['Grant_priv'] == 'Y') || (!empty($dbname) && in_array('Grant', explode(',', $row['Table_priv'])))) ? $strYes : $strNo) . '</td>' . "\n"
1097 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">';
1098 if ((empty($dbname) && $row2 && $row['Db'] == $row2['Db'])
1099 || (!empty($dbname) && $row['Column_priv'])) {
1100 echo $strYes;
1101 if (empty($dbname)) {
1102 $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
1104 } else {
1105 echo $strNo;
1107 echo '</td>' . "\n"
1108 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . (empty($dbname) ? urlencode($row['Db']) : urlencode($dbname) . '&amp;tablename=' . urlencode($row['Table_name'])) . '">' . $strEdit . '</a></td>' . "\n"
1109 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . (empty($dbname) ? urlencode($row['Db']) : urlencode($dbname) . '&amp;tablename=' . urlencode($row['Table_name'])) . '&amp;revokeall=1">' . $strRevoke . '</a></td>' . "\n"
1110 . ' </tr>' . "\n";
1111 $useBgcolorOne = !$useBgcolorOne;
1112 } // end while
1115 while (empty($dbname) && $row2) {
1117 $found_rows[] = $row2['Db'];
1118 echo ' <tr>' . "\n"
1119 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars($row2['Db']) . '</td>' . "\n"
1120 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
1121 . ' <dfn title="' . $strPrivDescUsage . '">USAGE</dfn>' . "\n"
1122 . ' </tt></td>' . "\n"
1123 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strNo . '</td>' . "\n"
1124 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strYes . '</td>' . "\n"
1125 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '">' . $strEdit . '</a></td>' . "\n"
1126 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php?' . $url_query . '&amp;username=' . urlencode($username) . '&amp;hostname=' . urlencode($hostname) . '&amp;dbname=' . urlencode($row2['Db']) . '&amp;revokeall=1">' . $strRevoke . '</a></td>' . "\n"
1127 . ' </tr>' . "\n";
1128 $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
1130 $useBgcolorOne = !$useBgcolorOne;
1131 } // end while
1132 if (empty($dbname)) {
1133 mysql_free_result($res2);
1134 unset($res2);
1135 unset($row2);
1138 mysql_free_result($res);
1139 unset($res);
1140 unset($row);
1141 echo ' <tr>' . "\n"
1142 . ' <td colspan="5">' . "\n"
1143 . ' <form action="server_privileges.php" method="post">' . "\n"
1144 . PMA_generate_common_hidden_inputs('', '', 6)
1145 . ' <input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
1146 . ' <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
1147 if (empty($dbname)) {
1148 echo ' <label for="text_dbname">' . $strAddPrivilegesOnDb . ':</label>' . "\n";
1149 $res = PMA_mysql_query('SHOW DATABASES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW DATABASES;');
1150 $pred_db_array = array();
1151 while ($row = PMA_mysql_fetch_row($res)) {
1152 if (!isset($found_rows) || !in_array($row[0], $found_rows)) {
1153 $pred_db_array[] = $row[0];
1156 mysql_free_result($res);
1157 unset($res);
1158 unset($row);
1159 if (!empty($pred_db_array)) {
1160 echo ' <select name="pred_dbname" onchange="this.form.submit();">' . "\n"
1161 . ' <option value="" selected="selected">' . $strUseTextField . ':</option>' . "\n";
1162 foreach ($pred_db_array as $current_db) {
1163 echo ' <option value="' . htmlspecialchars($current_db) . '">' . htmlspecialchars($current_db) . '</option>' . "\n";
1165 echo ' </select>' . "\n";
1167 echo ' <input type="text" id="text_dbname" name="dbname" class="textfield" />' . "\n";
1168 } else {
1169 echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\n"
1170 . ' <label for="text_tablename">' . $strAddPrivilegesOnTbl . ':</label>' . "\n";
1171 if ($res = @PMA_mysql_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';', $userlink)) {
1172 $pred_tbl_array = array();
1173 while ($row = PMA_mysql_fetch_row($res)) {
1174 if (!isset($found_rows) || !in_array($row[0], $found_rows)) {
1175 $pred_tbl_array[] = $row[0];
1178 mysql_free_result($res);
1179 unset($res);
1180 unset($row);
1181 if (!empty($pred_tbl_array)) {
1182 echo ' <select name="pred_tablename" onchange="this.form.submit();">' . "\n"
1183 . ' <option value="" selected="selected">' . $strUseTextField . ':</option>' . "\n";
1184 foreach ($pred_tbl_array as $current_table) {
1185 echo ' <option value="' . htmlspecialchars($current_table) . '">' . htmlspecialchars($current_table) . '</option>' . "\n";
1187 echo ' </select>' . "\n";
1189 } else {
1190 unset($res);
1192 echo ' <input type="text" id="text_tablename" name="tablename" class="textfield" />' . "\n";
1194 echo ' <input type="submit" value="' . $strGo . '" />' . "\n"
1195 . ' </form>' . "\n"
1196 . ' </td>' . "\n"
1197 . ' </tr>' . "\n"
1198 . ' </table><br />' . "\n"
1199 . ' </li>' . "\n";
1201 if (empty($dbname)) {
1202 echo ' <li>' . "\n"
1203 . ' <form action="server_privileges.php" method="post" onsubmit="checkPassword(this);">' . "\n"
1204 . PMA_generate_common_hidden_inputs('', '', 3)
1205 . ' <input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
1206 . ' <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
1207 echo ' <b>' . $strChangePassword . '</b><br />' . "\n"
1208 . ' <table border="0">' . "\n"
1209 . ' <tr>' . "\n"
1210 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '"><input type="radio" name="nopass" value="1" id="radio_nopass_1" onclick="pma_pw.value=\'\'; pma_pw2.value=\'\';" /></td>' . "\n"
1211 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2"><label for="radio_nopass_1">' . $strNoPassword . '</label></td>' . "\n"
1212 . ' </tr>' . "\n"
1213 . ' <tr>' . "\n"
1214 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="radio" name="nopass" value="0" id="radio_nopass_0" onclick="document.getElementById(\'pw_pma_pw\').focus();" /></td>' . "\n"
1215 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="radio_nopass_0">' . $strPassword . ':</label></td>' . "\n"
1216 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="password" name="pma_pw" id="pw_pma_pw" class="textfield" onchange="nopass[1].checked = true;" /></td>' . "\n"
1217 . ' </tr>' . "\n"
1218 . ' <tr>' . "\n"
1219 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">&nbsp;</td>' . "\n"
1220 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="pw_pma_pw2">' . $strReType . ':</label></td>' . "\n"
1221 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="password" name="pma_pw2" id="pw_pma_pw2" class="textfield" onchange="nopass[1].checked = true;" /></td>' . "\n"
1222 . ' </tr>' . "\n"
1223 . ' <tr>' . "\n"
1224 . ' <td colspan="3" align="center">' . "\n"
1225 . ' <input type="submit" name="change_pw" value="' . $strGo . '" />' . "\n"
1226 . ' </td>' . "\n"
1227 . ' </tr>' . "\n"
1228 . ' </table>' . "\n"
1229 . ' </form>' . "\n"
1230 . ' </li>' . "\n"
1231 . ' <li>' . "\n"
1232 . ' <form action="server_privileges.php" method="post" onsubmit="checkPassword(this);">' . "\n"
1233 . PMA_generate_common_hidden_inputs('', '', 3)
1234 . ' <input type="hidden" name="old_username" value="' . htmlspecialchars($username) . '" />' . "\n"
1235 . ' <input type="hidden" name="old_hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n"
1236 . ' <b>' . $strChangeCopyUser . '</b><br />' . "\n"
1237 . ' <table border="0">' . "\n";
1238 PMA_displayLoginInformationFields('change', 3);
1239 echo ' </table>' . "\n"
1240 . ' ' . $strChangeCopyMode . '<br />' . "\n"
1241 . ' <input type="radio" name="mode" value="4" id="radio_mode_4" checked="checked" />' . "\n"
1242 . ' <label for="radio_mode_4">' . "\n"
1243 . ' ' . $strChangeCopyModeCopy . "\n"
1244 . ' </label>' . "\n"
1245 . ' <br />' . "\n"
1246 . ' <input type="radio" name="mode" value="1" id="radio_mode_1" />' . "\n"
1247 . ' <label for="radio_mode_1">' . "\n"
1248 . ' ' . $strChangeCopyModeJustDelete . "\n"
1249 . ' </label>' . "\n"
1250 . ' <br />' . "\n"
1251 . ' <input type="radio" name="mode" value="2" id="radio_mode_2" />' . "\n"
1252 . ' <label for="radio_mode_2">' . "\n"
1253 . ' ' . $strChangeCopyModeRevoke . "\n"
1254 . ' </label>' . "\n"
1255 . ' <br />' . "\n"
1256 . ' <input type="radio" name="mode" value="3" id="radio_mode_3" />' . "\n"
1257 . ' <label for="radio_mode_3">' . "\n"
1258 . ' ' . $strChangeCopyModeDeleteAndReload . "\n"
1259 . ' </label>' . "\n"
1260 . ' <br />' . "\n"
1261 . ' <input type="submit" name="change_copy" value="' . $strGo . '" />' . "\n"
1262 . ' </form>' . "\n"
1263 . ' </li>' . "\n";
1265 echo '</ul>' . "\n";
1267 } else if (!empty($adduser)) {
1268 // Add a new user
1269 echo '<h2>' . "\n"
1270 . ' ' . $strAddUser . "\n"
1271 . '</h2>' . "\n"
1272 . '<form action="server_privileges.php" method="post" onsubmit="return checkAddUser(this);">' . "\n"
1273 . PMA_generate_common_hidden_inputs('', '', 1)
1274 . ' <table border="0">' . "\n"
1275 . ' <tr>' . "\n"
1276 . ' <th colspan="3">' . "\n"
1277 . ' ' . $strLoginInformation . "\n"
1278 . ' </th>' . "\n"
1279 . ' </tr>' . "\n";
1280 PMA_displayLoginInformationFields('new', 2);
1281 echo ' </table><br />' . "\n";
1282 PMA_displayPrivTable('*', '*', FALSE, 1);
1283 echo ' <br />' . "\n"
1284 . ' <input type="submit" name="adduser_submit" value="' . $strGo . '" />' . "\n"
1285 . '</form>' . "\n";
1286 } else {
1287 // check the privileges for a particular database.
1288 echo '<h2>' . "\n"
1289 . ' ' . sprintf($strUsersHavingAccessToDb, htmlspecialchars($checkprivs)) . "\n"
1290 . '</h2>' . "\n"
1291 . '<table border="0">' . "\n"
1292 . ' <tr>' . "\n"
1293 . ' <th>' . "\n"
1294 . ' &nbsp;' . $strUser . '&nbsp;' . "\n"
1295 . ' </th>' . "\n"
1296 . ' <th>' . "\n"
1297 . ' &nbsp;' . $strHost . '&nbsp;' . "\n"
1298 . ' </th>' . "\n"
1299 . ' <th>' . "\n"
1300 . ' &nbsp;' . $strType . '&nbsp;' . "\n"
1301 . ' </th>' . "\n"
1302 . ' <th>' . "\n"
1303 . ' &nbsp;' . $strPrivileges . '&nbsp;' . "\n"
1304 . ' </th>' . "\n"
1305 . ' <th>' . "\n"
1306 . ' &nbsp;' . $strGrantOption . '&nbsp;' . "\n"
1307 . ' </th>' . "\n"
1308 . ' <th>' . "\n"
1309 . ' &nbsp;' . $strAction . '&nbsp;' . "\n"
1310 . ' </th>' . "\n"
1311 . ' </tr>' . "\n";
1312 $useBgcolorOne = TRUE;
1313 unset($row);
1314 unset($row1);
1315 unset($row2);
1316 // now, we build the table...
1317 if (PMA_MYSQL_INT_VERSION >= 40000) {
1318 // Starting with MySQL 4.0.0, we may use UNION SELECTs and this makes
1319 // the job much easier here!
1320 $sql_query = '(SELECT `User`, `Host`, `Db`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv` 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")) UNION (SELECT `User`, `Host`, "*" AS "Db", `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv` 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, `Db` ASC;';
1321 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
1322 $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
1323 if ($row) {
1324 $found = TRUE;
1326 } else {
1327 // With MySQL 3, we need 2 seperate queries here.
1328 $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;';
1329 $res1 = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
1330 $row1 = PMA_mysql_fetch_array($res1, MYSQL_ASSOC);
1331 $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;';
1332 $res2 = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
1333 $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
1334 if ($row1 || $row2) {
1335 $found = TRUE;
1337 } // end if (PMA_MYSQL_INT_VERSION >= 40000) ... else ...
1338 if ($found) {
1339 while (TRUE) {
1340 // prepare the current user
1341 if (PMA_MYSQL_INT_VERSION >= 40000) {
1342 $current_privileges = array();
1343 $current_user = $row['User'];
1344 $current_host = $row['Host'];
1345 while ($row && $current_user == $row['User'] && $current_host == $row['Host']) {
1346 $current_privileges[] = $row;
1347 $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
1349 } else {
1350 $current_privileges = array();
1351 if ($row1 && (!$row2 || ($row1['User'] < $row2['User'] || ($row1['User'] == $row2['User'] && $row1['Host'] <= $row2['Host'])))) {
1352 $current_user = $row1['User'];
1353 $current_host = $row1['Host'];
1354 $current_privileges = array($row1);
1355 $row1 = PMA_mysql_fetch_array($res1, MYSQL_ASSOC);
1356 } else {
1357 $current_user = $row2['User'];
1358 $current_host = $row2['Host'];
1359 $current_privileges = array();
1361 while ($row2 && $current_user == $row2['User'] && $current_host == $row2['Host']) {
1362 $current_privileges[] = $row2;
1363 $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
1366 echo ' <tr>' . "\n"
1367 . ' <td';
1368 if (count($current_privileges) > 1) {
1369 echo ' rowspan="' . count($current_privileges) . '"';
1371 echo ' bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
1372 . ' ' . (empty($current_user) ? '<span style="color: #FF0000">' . $strAny . '</span>' : htmlspecialchars($current_user)) . "\n"
1373 . ' </td>' . "\n"
1374 . ' <td';
1375 if (count($current_privileges) > 1) {
1376 echo ' rowspan="' . count($current_privileges) . '"';
1378 echo ' bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
1379 . ' ' . htmlspecialchars($current_host) . "\n"
1380 . ' </td>' . "\n";
1381 foreach ($current_privileges as $current) {
1382 echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
1383 . ' ';
1384 if (!isset($current['Db']) || $current['Db'] == '*') {
1385 echo $strGlobal;
1386 } else if ($current['Db'] == $checkprivs) {
1387 echo $strDbSpecific;
1388 } else {
1389 echo $strWildcard, ': <tt>' . htmlspecialchars($current['Db']) . '</tt>';
1391 echo "\n"
1392 . ' </td>' . "\n"
1393 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
1394 . ' <tt>' . "\n"
1395 . ' ' . join(',' . "\n" . ' ', PMA_extractPrivInfo($current, TRUE)) . "\n"
1396 . ' <tt>' . "\n"
1397 . ' </td>' . "\n"
1398 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
1399 . ' ' . ($current['Grant_priv'] == 'Y' ? $strYes : $strNo) . "\n"
1400 . ' </td>' . "\n"
1401 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
1402 . ' <a href="./server_privileges.php?' . $url_query . '&amp;username=' . urlencode($current_user) . '&amp;hostname=' . urlencode($current_host) . (!isset($current['Db']) || $current['Db'] == '*' ? '' : '&amp;dbname=' . urlencode($current['Db'])) . '">' . "\n"
1403 . ' ' . $strEdit . "\n"
1404 . ' </a>' . "\n"
1405 . ' </td>' . "\n"
1406 . ' </tr>' . "\n";
1408 if (empty($row) && empty($row1) && empty($row2)) {
1409 break;
1411 $useBgcolorOne = !$useBgcolorOne;
1413 } else {
1414 echo ' <tr>' . "\n"
1415 . ' <td colspan="6" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
1416 . ' ' . $strNoUsersFound . "\n"
1417 . ' </td>' . "\n"
1418 . ' </tr>' . "\n";
1420 echo '</table>' . "\n";
1421 } // end if (empty($adduser) && empty($checkprivs)) ... else if ... else ...
1425 * Displays the footer
1427 echo "\n\n";
1428 require_once('./footer.inc.php');