3 // vim: expandtab sw=4 ts=4 sts=4:
7 * Gets some core libraries
9 require('./libraries/grab_globals.lib.php3');
10 require('./libraries/common.lib.php3');
14 * Defines the url to return to in case of error in a sql statement
16 $err_url = 'user_details.php3?' . PMA_generate_common_url('mysql', 'user');
19 * Displays the table of grants for an user
21 * @param mixed the id of the query used to get hosts and databases lists
22 * or an arry containing host and user informations
23 * @param mixed the database to check garnts for, FALSE for all databases
25 * @return boolean always true
27 * @global string the current language
28 * @global string the current charset for MySQL
29 * @global integer the server to use (refers to the number in the
34 * @TODO "SHOW GRANTS" statements is available and buggyless since
35 * MySQL 3.23.4 and it seems not to return privileges of the anonymous
36 * user while these privileges applies to all users.
38 function PMA_tableGrants(&$host_db_result, $dbcheck = FALSE) {
39 global $lang, $convcharset, $server;
42 <!-- Table of grants
-->
43 <table border
="<?php echo $GLOBALS['cfg']['Border']; ?>">
49 echo ' <th>' . $GLOBALS['strAction'] . '</th>' . "\n";
50 echo ' <th>' . $GLOBALS['strHost'] . '</th>' . "\n";
51 echo ' <th>' . $GLOBALS['strUser'] . '</th>';
54 echo ' <th colspan="2">' . $GLOBALS['strAction'] . '</th>';
57 echo ' <th>' . $GLOBALS['strDatabase'] . '</th>' . "\n";
58 echo ' <th>' . UCFirst($GLOBALS['strTable']) . '</th>' . "\n";
59 echo ' <th>' . $GLOBALS['strPrivileges'] . '</th>' . "\n";
61 echo ' <th>' . $GLOBALS['strGrantOption'] . '</th>' . "\n";
69 $url_query = PMA_generate_common_url('mysql', 'user');
71 while ($row = (is_array($host_db_result) ?
$host_db_result : PMA_mysql_fetch_array($host_db_result))) {
72 $local_query = 'SHOW GRANTS FOR \'' . $row['User'] . '\'@\'' . $row['Host'] . '\'';
73 $result = PMA_mysql_query($local_query);
74 $grants_cnt = ($result) ? @mysql_num_rows
($result) : 0;
78 while ($usr_row = PMA_mysql_fetch_row($result)) {
79 if (eregi('GRANT (.*) ON ([^.]+).([^.]+) TO .*$', $usr_row[0], $parts)) {
80 if ($parts[1] == 'USAGE') {
83 // loic1: bug #487673 - revoke 'reference'
84 $priv = ereg_replace('REFERENCE([^S]|$)', 'REFERENCES\\1', trim($parts[1]));
85 // loic1: bug #576896 - No "FILE" privileges on a
86 // database if neither "INSERT" nor "UPDATE" one
87 if (strpos(' ' . $priv, 'FILE')
88 && !(strpos(' ' . $priv, 'INSERT') ||
strpos(' ' . $priv, 'UPDATE'))) {
89 $priv = ereg_replace('(^FILE(, )?)|(, FILE)', '', $priv);
93 $table = trim($parts[3]);
94 $grantopt = eregi('WITH GRANT OPTION$', $usr_row[0]);
104 if ($priv == '' && !$grantopt) {
108 // Checking the database (take into account wildcards)
110 && ($db != '*' && $db != $dbcheck)) {
111 // TODO: db names may contain characters that are regexp
113 $re = '(^|(\\\\\\\\)+|[^\])';
114 $db_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $db));
115 if (!eregi('^' . $db_regex . '$', $dbcheck)) {
120 $bgcolor = ($i %
2) ?
$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
121 $revoke_url = 'sql.php3'
123 . '&sql_query=' . urlencode('REVOKE ' . $priv . ' ON ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' FROM \'' . $row['User'] . '\'@\'' . $row['Host'] . '\'')
124 . '&zero_rows=' . urlencode(sprintf($GLOBALS['strRevokeMessage'], ' <span style="color: #002E80">' . $row['User'] . '@' . $row['Host'] . '</span>') . '<br />' . $GLOBALS['strRememberReload'])
125 . '&goto=user_details.php3';
127 $revoke_grant_url = 'sql.php3'
129 . '&sql_query=' . urlencode('REVOKE GRANT OPTION ON ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' FROM \'' . $row['User'] . '\'@\'' . $row['Host'] . '\'')
130 . '&zero_rows=' . urlencode(sprintf($GLOBALS['strRevokeGrantMessage'], ' <span style="color: #002E80">' . $row['User'] . '@' . $row['Host'] . '</span>') . '<br />' . $GLOBALS['strRememberReload'])
131 . '&goto=user_details.php3';
140 <td
<?php
if (!$grantopt) echo ' colspan="2"'; ?
> bgcolor
="<?php echo $bgcolor; ?>">
141 <a href
="<?php echo $revoke_url; ?>">
142 <?php
echo $GLOBALS['strRevokePriv']; ?
></a
>
149 <td
<?php
if (!$priv) echo ' colspan="2"'; ?
> bgcolor
="<?php echo $bgcolor; ?>">
150 <a href
="<?php echo $revoke_grant_url; ?>">
151 <?php
echo $GLOBALS['strRevokeGrant']; ?
></a
>
159 <td bgcolor
="<?php echo $bgcolor; ?>">
160 <a href
="<?php echo $revoke_url; ?>">
161 <?php
echo $GLOBALS['strRevoke']; ?
></a
>
167 <td bgcolor
="<?php echo $bgcolor; ?>"> 
;</td
>
172 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo $row['Host']; ?
></td
>
173 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($row['User']) ?
$row['User'] : '<span style="color: #FF0000">' . $GLOBALS['strAny'] . '</span>'; ?
></td
>
178 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($db == '*') ?
'<span style="color: #002E80">' . $GLOBALS['strAll'] . '</span>' : $db; ?
></td
>
179 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($table == '*') ?
'<span style="color: #002E80">' . $GLOBALS['strAll'] . '</span>' : $table; ?
></td
>
180 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($priv != '') ?
$priv : '<span style="color: #002E80">' . $GLOBALS['strNoPrivileges'] . '</span>'; ?
></td
>
185 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($grantopt) ?
$GLOBALS['strYes'] : $GLOBALS['strNo']; ?
></td
>
190 <!-- Debug
<td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo $usr_row[0] ?
></td
> Debug
-->
195 } // end while $usr_row
196 } // end if $grants_cnt >0
197 // $host_db_result is an array containing related to only one user
199 if (is_array($host_db_result)) {
211 } // end of the 'PMA_tableGrants()' function
215 * Displays the list of grants for a/all database/s
217 * @param mixed the database to check garnts for, FALSE for all databases
219 * @return boolean true/false in case of success/failure
221 * @see PMA_tableGrants()
223 function PMA_checkDb($dbcheck)
225 $local_query = 'SELECT Host, User FROM mysql.user ORDER BY Host, User';
226 $result = PMA_mysql_query($local_query);
227 $host_usr_cnt = ($result) ? @mysql_num_rows
($result) : 0;
229 if (!$host_usr_cnt) {
232 PMA_tableGrants($result, $dbcheck);
235 } // end of the 'PMA_checkDb()' function
239 * Displays the privileges part of a page
241 * @param string the name of the form for js validation
242 * @param array the list of the privileges of the user
244 * @return boolean always true
246 * @global integer whether all/none of the privileges have to be checked or
249 * @see PMA_normalOperations()
251 function PMA_tablePrivileges($form, $row = FALSE)
255 $checkpriv_url = $GLOBALS['cfg']['PmaAbsoluteUri']
256 . 'user_details.php3?';
257 if (empty($GLOBALS['QUERY_STRING'])) {
258 if (isset($_SERVER) && !empty($_SERVER['QUERY_STRING'])) {
259 $GLOBALS['QUERY_STRING'] = $_SERVER['QUERY_STRING'];
261 else if (isset($GLOBALS['HTTP_SERVER_VARS']) && !empty($GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'])) {
262 $GLOBALS['QUERY_STRING'] = $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
265 if (!empty($GLOBALS['QUERY_STRING'])) {
266 $checkpriv_url .= str_replace('&', '&', $GLOBALS['QUERY_STRING']) . '&';
273 $list_priv = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Reload',
274 'Shutdown', 'Process', 'File', 'Grant', 'References', 'Index', 'Alter');
276 while ((list(,$priv) = each($list_priv)) && ++
$item) {
277 $priv_priv = $priv . '_priv';
278 if (isset($checkpriv)) {
279 $checked = ($checkpriv == 'all') ?
' checked="checked"' : '';
281 $checked = ($row && $row[$priv_priv] == 'Y') ?
' checked="checked"' : '';
283 if ($item %
2 == 1) {
286 echo ' <td> </td>' . "\n";
289 echo ' <input type="checkbox" name="' . $priv . '_priv" id="checkbox_priv_' . $priv . '"' . $checked . ' />' . "\n";
290 echo ' </td>' . "\n";
291 echo ' <td><label for="checkbox_priv_' . $priv . '">' . $priv . '</label></td>' . "\n";
292 if ($item %
2 == 0) {
293 echo ' </tr>' . "\n";
296 if ($item %
2 == 1) {
297 echo ' <td colspan="2"> <td>' . "\n";
298 echo ' </tr>' . "\n";
305 <a href
="<?php echo $checkpriv_url; ?>checkpriv=all" onclick
="checkForm('<?php echo $form; ?>', true); return false">
306 <?php
echo $GLOBALS['strCheckAll']; ?
></a
>
310 <a href
="<?php echo $checkpriv_url; ?>checkpriv=none" onclick
="checkForm('<?php echo $form; ?>', false); return false">
311 <?php
echo $GLOBALS['strUncheckAll']; ?
></a
>
319 } // end of the 'PMA_tablePrivileges()' function
323 * Displays the page for "normal" operations
325 * @return boolean always true
327 * @global string the current language
328 * @global string the current charset for MySQL
329 * @global integer the server to use (refers to the number in the
330 * configuration file)
332 * @see PMA_tablePrivileges()
334 function PMA_normalOperations()
336 global $lang, $convcharset, $server;
342 <div style
="margin-bottom: 10px">
343 <a href
="user_details.php3?<?php echo PMA_generate_common_url('mysql', 'user'); ?>&mode=reload">
344 <?php
echo $GLOBALS['strReloadMySQL']; ?
></a
> 
;
345 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration.', 'FLUSH') . "\n"; ?
>
350 <form name
="dbPrivForm" action
="user_details.php3" method
="post">
351 <?php
echo $GLOBALS['strCheckDbPriv'] . "\n"; ?
>
355 <?php
echo $GLOBALS['strDatabase']; ?
> 
;: 
;
359 $result = PMA_mysql_query('SHOW DATABASES');
360 if ($result && @mysql_num_rows
($result)) {
361 while ($row = PMA_mysql_fetch_row($result)) {
363 echo '<option value="' . str_replace('"', '"', $row[0]) . '">' . htmlspecialchars($row[0]) . '</option>' . "\n";
368 <?php
echo PMA_generate_common_hidden_inputs(); ?
>
369 <input type
="hidden" name
="check" value
="1" />
370 <input type
="submit" value
="<?php echo $GLOBALS['strGo']; ?>" />
378 <form action
="user_details.php3" method
="post" name
="addUserForm" onsubmit
="return checkAddUser()">
379 <?php
echo $GLOBALS['strAddUser'] . "\n"; ?
>
383 <input type
="radio" name
="anyhost" id
="radio_anyhost0" checked
="checked" />
384 <label
for="radio_anyhost0"><?php
echo $GLOBALS['strAnyHost']; ?
></label
>
388 <input type
="radio" name
="anyhost" id
="radio_anyhost1" />
389 <label
for="radio_anyhost1"><?php
echo $GLOBALS['strHost']; ?
></label
> 
;: 
;
392 <input type
="text" name
="host" size
="10" class="textfield" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="this.form.anyhost[1].checked = true" />
397 <input type
="radio" name
="anyuser" value
="1" id
="radio_anyuser1" />
398 <label
for="radio_anyuser1"><?php
echo $GLOBALS['strAnyUser']; ?
></label
>
402 <input type
="radio" name
="anyuser" value
="0" id
="radio_anyuser0" checked
="checked" />
403 <label
for="radio_anyuser0"><?php
echo $GLOBALS['strUserName']; ?
></label
> 
;: 
;
406 <input type
="text" name
="pma_user" size
="10" class="textfield" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="this.form.anyuser[1].checked = true" />
411 <input type
="radio" name
="nopass" value
="1" id
="radio_nopass1" onclick
="pma_pw.value = ''; pma_pw2.value = ''; this.checked = true" />
412 <label
for="radio_nopass1"><?php
echo $GLOBALS['strNoPassword']; ?
></label
>
416 <input type
="radio" name
="nopass" value
="0" id
="radio_nopass0" checked
="checked" />
417 <label
for="radio_nopass0"><?php
echo $GLOBALS['strPassword']; ?
></label
> 
;: 
;
420 <input type
="password" name
="pma_pw" size
="10" class="textfield" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="nopass[1].checked = true" />
422 <?php
echo $GLOBALS['strReType']; ?
> 
;: 
;
423 <input type
="password" name
="pma_pw2" size
="10" class="textfield" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="nopass[1].checked = true" />
429 <?php
echo $GLOBALS['strPrivileges']; ?
> 
;:
436 PMA_tablePrivileges('addUserForm');
438 <?php
echo PMA_generate_common_hidden_inputs(); ?
>
439 <input type
="submit" name
="submit_addUser" value
="<?php echo $GLOBALS['strGo']; ?>" />
447 } // end of the 'PMA_normalOperations()' function
451 * Displays the grant operations part of an user properties page
453 * @param array grants of the current user
455 * @return boolean always true
457 * @global string the current language
458 * @global string the current charset for MySQL
459 * @global integer the server to use (refers to the number in the
460 * configuration file)
461 * @global string the host name to check grants for
462 * @global string the username to check grants for
463 * @global string the database to check grants for
464 * @global string the table to check grants for
466 * @see PMA_tablePrivileges()
468 function PMA_grantOperations($grants)
470 global $lang, $convcharset, $server, $host, $pma_user;
471 global $dbgrant, $tablegrant, $newdb;
477 <div style
="margin-bottom: 10px">
478 <a href
="user_details.php3?<?php echo PMA_generate_common_url('mysql', 'user'); ?>">
479 <?php
echo $GLOBALS['strBack']; ?
></a
>
484 <form action
="user_details.php3" method
="post" name
="userGrants">
485 <?php
echo PMA_generate_common_hidden_inputs(); ?
>
486 <input type
="hidden" name
="grants" value
="1" />
487 <input type
="hidden" name
="host" value
="<?php echo str_replace('"', '"
;', $host); ?>" />
488 <input type="hidden" name="pma_user" value="<?php echo str_replace('"', '"', $pma_user); ?>" />
490 <?php
echo $GLOBALS['strAddPriv'] . "\n"; ?
>
494 <input type
="radio" name
="anydb" value
="1" id
="radio_anydb1"<?php
echo ($dbgrant) ?
'' : ' checked="checked"'; ?
> />
495 <label
for="radio_anydb1"><?php
echo $GLOBALS['strAnyDatabase']; ?
></label
>
497 <td
> 
; 
; 
;</td
>
499 <input type
="radio" name
="anydb" value
="0" id
="radio_anydb0"<?php
echo ($dbgrant) ?
' checked="checked"' : ''; ?
> />
500 <label
for="radio_anydb0"><?php
echo $GLOBALS['strDatabase']; ?
></label
><a href
="./Documentation.html#underscore" target
="documentation" title
="<?php echo $GLOBALS['strDocu']; ?>">(*)</a
> 
;: 
;
503 <select name
="dbgrant" onchange
="change(this)">
507 // if (!isset($dbgrant)) {
509 // echo '<option></option>' . "\n";
511 $is_selected_db = FALSE;
512 $result = PMA_mysql_query('SHOW DATABASES');
513 if ($result && @mysql_num_rows
($result)) {
514 while ($row = PMA_mysql_fetch_row($result)) {
515 $selected = (($row[0] == $dbgrant) ?
' selected="selected"' : '');
516 if (!empty($selected)) {
517 $is_selected_db = TRUE;
520 echo '<option' . $selected . '>' . $row[0] . '</option>' . "\n";
528 <input type
="submit" value
="<?php echo $GLOBALS['strShowTables']; ?>" />
533 <input type
="radio" name
="anytable" value
="1" id
="radio_anytable1"<?php
echo ($tablegrant) ?
'' : ' checked="checked"'; ?
> />
534 <label
for="radio_anytable1"><?php
echo $GLOBALS['strAnyTable']; ?
></label
>
536 <td
> 
; 
; 
;</td
>
538 <input type
="radio" name
="anytable" value
="0" id
="radio_anytable0"<?php
echo ($tablegrant) ?
' checked="checked"' : ''; ?
> />
539 <label
for="radio_anytable0"><?php
echo $GLOBALS['strTable']; ?
></label
> 
;: 
;
542 <select name
="tablegrant" onchange
="change(this)">
546 // if (!isset($tablegrant)) {
548 // echo '<option></option>' . "\n";
550 if (isset($dbgrant)) {
551 $result = PMA_mysql_query('SHOW TABLES FROM ' . PMA_backquote($dbgrant));
552 if ($result && @mysql_num_rows
($result)) {
553 while ($row = PMA_mysql_fetch_row($result)) {
554 $selected = ((isset($tablegrant) && $row[0] == $tablegrant) ?
' selected="selected"' : '');
556 echo '<option' . $selected . '>' . $row[0] . '</option>' . "\n";
565 <input type
="submit" value
="<?php echo $GLOBALS['strShowCols']; ?>" />
570 <input type
="radio" name
="anycolumn" value
="1" id
="radio_anycolumn1" checked
="checked" />
571 <label
for="radio_anycolumn1"><?php
echo $GLOBALS['strAnyColumn']; ?
></label
>
573 <td
> 
; 
; 
;</td
>
575 <input type
="radio" name
="anycolumn" value
="0" id
="radio_anycolumn0" />
576 <label
for="radio_anycolumn0"><?php
echo $GLOBALS['strColumn']; ?
></label
> 
;: 
;
581 if (!isset($dbgrant) ||
!isset($tablegrant)) {
582 echo ' ' . '<select name="colgrant[]">' . "\n";
583 echo ' ' . '<option></option>' . "\n";
584 echo ' ' . '</select>' . "\n";
587 $result = PMA_mysql_query('SHOW COLUMNS FROM ' . PMA_backquote($tablegrant) . ' FROM ' . PMA_backquote($dbgrant));
588 if ($result && @mysql_num_rows
($result)) {
590 . '<select name="colgrant[]" multiple="multiple" onchange="anycolumn[1].checked = true">' . "\n";
591 while ($row = PMA_mysql_fetch_row($result)) {
593 echo '<option value="' . str_replace('"', '"', $row[0]) . '">' . $row[0] . '</option>' . "\n";
596 echo ' ' . '<select name="colgrant[]">' . "\n";
597 echo ' ' . '<option></option>' . "\n";
598 } // end if... else...
600 . '</select>' . "\n";
608 <i
><?php
echo $GLOBALS['strOr']; ?
></i
>
613 <?php
echo $GLOBALS['strDatabaseWildcard'] . "\n"; ?
> 
;
614 <input type
="text" name
="newdb" value
="<?php echo ((!$is_selected_db && !empty($pma_user)) ? $pma_user . '%' : ''); ?>" class="textfield" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="change(this)" />
623 <?php
echo $GLOBALS['strPrivileges']; ?
> 
;: 
;
630 PMA_tablePrivileges('userGrants', $grants);
632 <input type
="submit" name
="upd_grants" value
="<?php echo $GLOBALS['strGo']; ?>" />
641 } // end of the 'PMA_grantOperations()' function
645 * Displays the page to edit operations
647 * @param string the host name to check grants for
648 * @param string the user name to check grants for
650 * @return boolean always true
652 * @global string the current language
653 * @global string the current charset for MySQL
654 * @global integer the server to use (refers to the number in the
655 * configuration file)
657 * @see PMA_tablePrivileges()
659 function PMA_editOperations($host, $user)
661 global $lang, $convcharset, $server;
663 $result = PMA_mysql_query('SELECT * FROM mysql.user WHERE User = \'' . PMA_sqlAddslashes($user) . '\' AND Host = \'' . PMA_sqlAddslashes($host) . '\'');
664 $rows = ($result) ? @mysql_num_rows
($result) : 0;
670 $row = PMA_mysql_fetch_array($result);
676 <div style
="margin-bottom: 10px">
677 <a href
="user_details.php3?<?php echo PMA_generate_common_url('mysql', 'user'); ?>">
678 <?php
echo $GLOBALS['strBack']; ?
></a
>
683 <form action
="user_details.php3" method
="post" name
="updUserForm" onsubmit
="return checkUpdProfile()">
684 <?php
echo $GLOBALS['strUpdateProfile'] . "\n"; ?
>
688 <input type
="radio" value
="1" name
="anyhost" id
="radio_anyhost1"<?php
if ($host == '' ||
$host == '%') echo ' checked="checked"'; ?
> />
689 <label
for="radio_anyhost1"><?php
echo $GLOBALS['strAnyHost']; ?
></label
>
693 <input type
="radio" value
="0" name
="anyhost" id
="radio_anyhost0"<?php
if ($host != '' && $host != '%') echo ' checked="checked"'; ?
> />
694 <label
for="radio_anyhost0"><?php
echo $GLOBALS['strHost']; ?
></label
> 
;: 
;
697 <input type
="text" name
="new_server" size
="10" value
="<?php echo str_replace('"', '"
;', $host); ?>" class="textfield" <?php echo $GLOBALS['chg_evt_handler
']; ?>="this.form.anyhost[1].checked = true" />
702 <input type="radio" value="1" name="anyuser" id="radio_anyuser1"<?php if ($user == '') echo ' checked
="checked"'; ?> />
703 <label for="radio_anyuser1"><?php echo $GLOBALS['strAnyUser
']; ?></label>
707 <input type="radio" value="0" name="anyuser" id="radio_anyuser0"<?php if ($user != '') echo ' checked
="checked"'; ?> />
708 <label for="radio_anyuser0"><?php echo $GLOBALS['strUserName
']; ?></label> :
711 <input type="text" name="new_user" size="10" value="<?php echo str_replace('"', '"', $user); ?>" class="textfield" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="this.form.anyuser[1].checked = true" />
716 <input type
="radio" name
="nopass" value
="-1" id
="radio_nopass-1" checked
="checked" onclick
="new_pw.value = ''; new_pw2.value = ''; this.checked = true" />
717 <label
for="radio_nopass-1"><?php
echo $GLOBALS['strKeepPass']; ?
></label
>
719 <td colspan
="3"> 
;</td
>
722 <td colspan
="4" align
="<?php echo $GLOBALS['cell_align_left']; ?>"> 
; 
; 
; 
; 
; 
;<?php
echo $GLOBALS['strOr']; ?
></td
>
726 <input type
="radio" name
="nopass" value
="1" id
="radio_nopass1" onclick
="new_pw.value = ''; new_pw2.value = ''; this.checked = true" />
727 <label
for="radio_nopass1"><?php
echo $GLOBALS['strNoPassword']; ?
></label
>
731 <input type
="radio" name
="nopass" value
="0" id
="radio_nopass0" />
732 <label
for="radio_nopass0"><?php
echo $GLOBALS['strPassword']; ?
></label
> 
;: 
;
735 <input type
="password" name
="new_pw" size
="10" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="nopass[2].checked = true" />
737 <?php
echo $GLOBALS['strReType']; ?
> 
;: 
;
738 <input type
="password" name
="new_pw2" size
="10" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="nopass[2].checked = true" />
742 <?php
echo PMA_generate_common_hidden_inputs(); ?
>
743 <input type
="hidden" name
="host" value
="<?php echo str_replace('"', '"
;', $host); ?>" />
744 <input type="hidden" name="pma_user" value="<?php echo str_replace('"', '"', $user); ?>" />
745 <input type
="submit" name
="submit_updProfile" value
="<?php echo $GLOBALS['strGo']; ?>" />
750 <form action
="user_details.php3" method
="post" name
="privForm">
751 <?php
echo $GLOBALS['strEditPrivileges'] . "\n"; ?
>
753 PMA_tablePrivileges('privForm', $row);
756 <?php
echo PMA_generate_common_hidden_inputs(); ?
>
757 <input type
="hidden" name
="host" value
="<?php echo str_replace('"', '"
;', $host); ?>" />
758 <input type="hidden" name="pma_user" value="<?php echo str_replace('"', '"', $user); ?>" />
759 <input type
="submit" name
="submit_chgPriv" value
="<?php echo $GLOBALS['strGo']; ?>" />
768 } // end of the 'PMA_editOperations()' function
772 * Displays the table of the users
774 * @param string the host name
775 * @param string the user name
777 * @return boolean always true
779 * @global string the current language
780 * @global string the current charset for MySQL
781 * @global integer the server to use (refers to the number in the
782 * configuration file)
784 function PMA_tableUsers($host = FALSE, $user = FALSE)
786 global $lang, $convcharset, $server;
788 $local_query = 'SELECT * FROM mysql.user ';
789 if ($host ||
$user) {
790 $local_query .= ' WHERE 1 ';
793 $local_query .= ' AND Host = \'' . PMA_sqlAddslashes($host) . '\'';
794 $local_query .= ' AND User = \'' . PMA_sqlAddslashes($user) . '\'';
796 $local_query .= ' ORDER BY Host, User';
797 $result = PMA_mysql_query($local_query);
798 $rows = ($result) ? @mysql_num_rows
($result) : 0;
804 echo '<i>' . $GLOBALS['strEnglishPrivileges'] . '</i><br />' . "\n";
805 echo '<table border="' . $GLOBALS['cfg']['Border'] . '">' . "\n";
807 echo ' <th colspan="'. (($user) ?
'2' : '3') . '">' . $GLOBALS['strAction'] . '</th>' . "\n";
808 echo ' <th>' . $GLOBALS['strHost'] . '</th>' . "\n";
809 echo ' <th>' . $GLOBALS['strUser'] . '</th>' . "\n";
810 echo ' <th>' . $GLOBALS['strPassword'] . '</th>' . "\n";
811 echo ' <th>' . $GLOBALS['strPrivileges'] . '</th>' . "\n";
815 while ($row = PMA_mysql_fetch_array($result)) {
817 $bgcolor = ($i %
2) ?
$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
820 if ($row['Select_priv'] == 'Y') {
821 $strPriv .= 'Select ';
823 if ($row['Insert_priv'] == 'Y') {
824 $strPriv .= 'Insert ';
826 if ($row['Update_priv'] == 'Y') {
827 $strPriv .= 'Update ';
829 if ($row['Delete_priv'] == 'Y') {
830 $strPriv .= 'Delete ';
832 if ($row['Create_priv'] == 'Y') {
833 $strPriv .= 'Create ';
835 if ($row['Drop_priv'] == 'Y') {
838 if ($row['Reload_priv'] == 'Y') {
839 $strPriv .= 'Reload ';
841 if ($row['Shutdown_priv'] == 'Y') {
842 $strPriv .= 'Shutdown ';
844 if ($row['Process_priv'] == 'Y') {
845 $strPriv .= 'Process ';
847 if ($row['File_priv'] == 'Y') {
850 if ($row['Grant_priv'] == 'Y') {
851 $strPriv .= 'Grant ';
853 if ($row['References_priv'] == 'Y') {
854 $strPriv .= 'References ';
856 if ($row['Index_priv'] == 'Y') {
857 $strPriv .= 'Index ';
859 if ($row['Alter_priv'] == 'Y') {
860 $strPriv .= 'Alter ';
862 if ($strPriv == '') {
863 $strPriv = '<span style="color: #002E80">' . $GLOBALS['strNoPrivileges'] . '</span>';
866 $query = PMA_generate_common_url('mysql', 'user');
868 $edit_url = 'user_details.php3?'
869 . PMA_generate_common_url()
870 . '&edit=1&host=' . urlencode($row['Host']) . '&pma_user=' . urlencode($row['User']);
872 $delete_url = 'user_details.php3?'
874 . '&delete=1&confirm=1&delete_host=' . urlencode($row['Host']) . '&delete_user=' . urlencode($row['User']);
875 $check_url = 'user_details.php3?'
876 . PMA_generate_common_url()
877 . '&grants=1&host=' . urlencode($row['Host']) . '&pma_user=' . urlencode($row['User']);
885 <td bgcolor
="<?php echo $bgcolor;?>">
886 <a href
="<?php echo $edit_url; ?>">
887 <?php
echo $GLOBALS['strEdit']; ?
></a
>
893 <td bgcolor
="<?php echo $bgcolor;?>">
894 <a href
="<?php echo $delete_url; ?>">
895 <?php
echo $GLOBALS['strDelete']; ?
></a
>
897 <td bgcolor
="<?php echo $bgcolor;?>">
898 <a href
="<?php echo $check_url; ?>">
899 <?php
echo $GLOBALS['strGrants']; ?
></a
>
902 <td bgcolor
="<?php echo $bgcolor;?>">
903 <a href
="<?php echo (($check_url != '') ? $check_url : '#'); ?>">
904 <?php
echo $GLOBALS['strGrants']; ?
></a
>
907 <td bgcolor
="<?php echo $bgcolor;?>">
908 <?php
echo $row['Host'] . "\n"; ?
>
910 <td bgcolor
="<?php echo $bgcolor;?>">
911 <?php
echo (($row['User']) ?
'<b>' . $row['User'] . '</b>' : '<span style="color: #FF0000">' . $GLOBALS['strAny'] . '</span>') . "\n"; ?
>
913 <td bgcolor
="<?php echo $bgcolor;?>">
914 <?php
echo (($row[$GLOBALS['password_field']]) ?
$GLOBALS['strYes'] : '<span style="color: #FF0000">' . $GLOBALS['strNo'] . '</span>') . "\n"; ?
>
916 <td bgcolor
="<?php echo $bgcolor;?>">
917 <?php
echo $strPriv . "\n"; ?
>
933 } // end of the 'PMA_tableUsers()' function
937 * Displays a confirmation form
939 * @param string the host name and...
940 * @param string ... the username to delete
942 * @global string the current language
943 * @global string the current charset for MySQL
944 * @global integer the server to use (refers to the number in the
945 * configuration file)
947 function PMA_confirm($the_host, $the_user) {
948 global $lang, $convcharset, $server;
950 if (get_magic_quotes_gpc() == 1) {
951 $the_host = stripslashes($the_host);
952 $the_user = stripslashes($the_user);
955 echo $GLOBALS['strConfirm'] . ' : <br />' . "\n";
956 echo 'DELETE FROM mysql.user WHERE Host = \'' . $the_host . '\' AND User = \'' . $the_user . '\'' . '<br />' . "\n";
958 <form action
="user_details.php3" method
="post">
959 <?php
echo PMA_generate_common_hidden_inputs('mysql', 'user'); ?
>
960 <input type
="hidden" name
="delete" value
="<?php echo(isset($GLOBALS['delete']) ? '1' : '0'); ?>" />
961 <input type
="hidden" name
="delete_host" value
="<?php echo str_replace('"', '"
;', $the_host); ?>" />
962 <input type="hidden" name="delete_user" value="<?php echo str_replace('"', '"', $the_user); ?>" />
963 <input type
="submit" name
="btnConfirm" value
="<?php echo $GLOBALS['strYes']; ?>" />
964 <input type
="submit" name
="btnConfirm" value
="<?php echo $GLOBALS['strNo']; ?>" />
969 include('./footer.inc.php3');
970 } // end of the 'PMA_confirm()' function
975 * Ensures the user is super-user and gets the case sensitive password field
978 $result = @PMA_mysql_query
('USE mysql');
979 if (PMA_mysql_error()) {
980 include('./header.inc.php3');
981 echo '<p><b>' . $strError . '</b></p>' . "\n";
982 echo '<p> ' . $strNoRights . '</p>' . "\n";
983 include('./footer.inc.php3');
986 // The previous logic did not work if the password field is named "password":
987 //$result = @PMA_mysql_query('SELECT COUNT(Password) FROM mysql.user');
988 //$password_field = (($result && PMA_mysql_result($result, 0)) ? 'Password' : 'password');
990 // using a syntax that works with older and recent MySQL,
991 // and assumes that the field name ends with "assword":
992 $result = @PMA_mysql_query
('SHOW FIELDS FROM user FROM mysql LIKE \'%assword\'');
994 $password_field = PMA_mysql_result($result, 0);
998 * Autocomplete feature of IE kills the "onchange" event handler and it must be
999 * replaced by the "onpropertychange" one in this case
1001 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
>= 5)
1002 ?
'onpropertychange'
1010 $db_bkp = (get_magic_quotes_gpc() ?
stripslashes($db) : $db);
1013 if (isset($table)) {
1014 $table_bkp = (get_magic_quotes_gpc() ?
stripslashes($table) : $table);
1017 if (get_magic_quotes_gpc()) {
1018 if (!empty($host)) {
1019 $host = stripslashes($host);
1021 if (!empty($pma_user)) {
1022 $pma_user = stripslashes($pma_user);
1026 if (!isset($message)) {
1027 $js_to_run = 'user_details.js';
1028 include('./header.inc.php3');
1030 if (!isset($submit_updProfile)) {
1032 echo ' ' . ((!isset($host) ||
$host == '') ?
$strAnyHost : $strHost . ' ' . $host) . ' - ' . ((!isset($pma_user) ||
$pma_user == '') ?
$strAnyUser : $strUser . ' ' . $pma_user) . "\n";
1035 if (isset($message)) {
1037 PMA_showMessage($message);
1040 if (isset($db_bkp)) {
1044 if (isset($table_bkp)) {
1045 $table = $table_bkp;
1051 * Some actions has been submitted
1053 // Confirms an action
1054 if (isset($confirm) && $confirm) {
1055 PMA_confirm($delete_host, $delete_user);
1060 else if (($server > 0) && isset($mode) && ($mode == 'reload')) {
1061 $result = PMA_mysql_query('FLUSH PRIVILEGES');
1063 echo '<p><b>' . $strMySQLReloaded . '</b></p>' . "\n";
1065 echo '<p><b>' . $strReloadFailed . '</b></p>' . "\n";
1070 else if (isset($delete) && $delete
1071 && isset($btnConfirm) && $btnConfirm == $strYes) {
1072 if (get_magic_quotes_gpc()) {
1073 $delete_host = stripslashes($delete_host);
1074 $delete_user = stripslashes($delete_user);
1076 $common_where = ' WHERE Host = \'' . PMA_sqlAddslashes($delete_host) . '\' AND User = \'' . PMA_sqlAddslashes($delete_user) . '\'';
1078 // Delete Grants First!
1079 $sql_query = 'DELETE FROM mysql.db' . $common_where;
1080 $sql_query_cpy = $sql_query;
1081 PMA_mysql_query($sql_query);
1082 $sql_query = 'DELETE FROM mysql.tables_priv' . $common_where;
1083 $sql_query_cpy .= ";\n" . $sql_query;
1084 PMA_mysql_query($sql_query);
1085 $sql_query = 'DELETE FROM mysql.columns_priv' . $common_where;
1086 $sql_query_cpy .= ";\n" . $sql_query;
1087 PMA_mysql_query($sql_query);
1089 $sql_query = 'DELETE FROM mysql.user' . $common_where;
1090 $sql_query_cpy .= ";\n" . $sql_query;
1091 $result = PMA_mysql_query($sql_query);
1093 $sql_query = $sql_query_cpy;
1094 unset($sql_query_cpy);
1096 PMA_showMessage(sprintf($strDeleteUserMessage, '<span style="color: #002E80">' . $delete_user . '@' . $delete_host . '</span>') . '<br />' . $strRememberReload);
1098 PMA_showMessage($strDeleteFailed);
1103 else if (isset($submit_addUser)) {
1105 if (!isset($host) ||
$host == '') {
1108 //if (!isset($pma_user) || $pma_user == '') {
1111 if (isset($anyuser) && $anyuser=="1") {
1114 // this is for the case where js is disabled, so they did not get
1115 // the error before submitting
1116 } else if (isset($pma_user) && empty($pma_user)) {
1117 echo '<p><b>' . $strError . ' : ' . $strUserEmpty . '</b></p>' . "\n";
1120 $forgot_checkbox_any_user = TRUE;
1123 // Password is not confirmed
1124 if ((!isset($nopass) ||
!$nopass) && $pma_pw == '') {
1125 echo '<p><b>' . $strError . ' : ' . $strPasswordEmpty . '</b></p>' . "\n";
1129 else if ($pma_pw != ''
1130 && (!isset($pma_pw2) ||
$pma_pw != $pma_pw2)) {
1131 echo '<p><b>' . $strError . ' : ' . $strPasswordNotSame . '</b></p>' . "\n";
1136 // Password confirmed
1137 else if (!isset($forgot_checkbox_any_user)) {
1139 $list_priv = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Reload',
1140 'Shutdown', 'Process', 'File', 'Grant', 'References', 'Index', 'Alter');
1141 for ($i = 0; $i < 14; $i++
) {
1142 $priv_name = $list_priv[$i] . '_priv';
1143 if (isset($
$priv_name)) {
1144 $sql_query .= (empty($sql_query) ?
$priv_name : ', ' . $priv_name) . ' = \'Y\'';
1146 $sql_query .= (empty($sql_query) ?
$priv_name : ', ' . $priv_name) . ' = \'N\'';
1151 if (get_magic_quotes_gpc() && $pma_pw != '') {
1152 $pma_pw = stripslashes($pma_pw);
1155 $local_query = 'INSERT INTO mysql.user '
1156 . 'SET Host = \'' . PMA_sqlAddslashes($host) . '\', User = \'' . PMA_sqlAddslashes($pma_user) . '\', ' . $password_field . ' = ' . (($pma_pw == '') ?
'\'\'' : 'PASSWORD(\'' . PMA_sqlAddslashes($pma_pw) . '\')')
1157 . ', ' . $sql_query;
1158 $sql_query = 'INSERT INTO mysql.user '
1159 . 'SET Host = \'' . PMA_sqlAddslashes($host) . '\', User = \'' . PMA_sqlAddslashes($pma_user) . '\', ' . $password_field . ' = ' . (($pma_pw == '') ?
'\'\'' : 'PASSWORD(\'' . ereg_replace('.', '*', $pma_pw) . '\')')
1160 . ', ' . $sql_query;
1161 $result = @PMA_mysql_query
($local_query) or PMA_mysqlDie('', '', FALSE, $err_url);
1164 PMA_showMessage($strAddUserMessage . '<br />' . $strRememberReload);
1168 // Updates the profile of an user
1169 else if (isset($submit_updProfile)) {
1172 if (!isset($host) ||
$host == '') {
1175 //if (!isset($pma_user) || $pma_user == '') {
1178 if (!isset($pma_user)) {
1182 // Builds the sql query
1185 if (isset($anyhost) && $anyhost) {
1187 } else if ($new_server != '' && get_magic_quotes_gpc()) {
1188 $new_server = stripslashes($new_server);
1190 if ($new_server != '' && $new_server != $host) {
1191 $common_upd .= 'Host = \'' . PMA_sqlAddslashes($new_server) . '\'';
1192 } else if (isset($new_server)) {
1195 if (isset($anyuser) && $anyuser=="1") {
1197 // anonymous user must be empty, not %
1199 } else if ($new_user != '' && get_magic_quotes_gpc()) {
1200 $new_user = stripslashes($new_user);
1202 //if ($new_user != '' && $new_user != $pma_user) {
1203 if ($new_user != $pma_user) {
1204 $common_upd .= (empty($common_upd) ?
'' : ', ')
1205 . 'User = \'' . PMA_sqlAddslashes($new_user) . '\'';
1206 } else if (isset($new_user)) {
1210 if (isset($nopass) && $nopass == -1) {
1211 $sql_query = $common_upd;
1212 $local_query = $common_upd;
1214 else if ((!isset($nopass) ||
$nopass == 0) && $new_pw == '') {
1216 echo ' ' . $strHost . ' ' . $host . ' - ' . $strUser . ' ' . (($pma_user != '') ?
$pma_user : $strAny) . "\n";
1217 echo '</h1>' . "\n";
1218 echo '<p><b>' . $strError . ' : ' . $strPasswordEmpty . '</b></p>' . "\n";
1220 else if ($new_pw != ''
1221 && (!isset($new_pw2) ||
$new_pw != $new_pw2)) {
1223 echo ' ' . $strHost . ' ' . $host . ' - ' . $strUser . ' ' . (($pma_user != '') ?
$pma_user : $strAny) . "\n";
1224 echo '</h1>' . "\n";
1225 echo '<p><b>' . $strError . ' : ' . $strPasswordNotSame . '</b></p>' . "\n";
1228 $sql_query = (empty($common_upd) ?
'' : $common_upd . ', ')
1229 . $password_field . ' = ' . (($new_pw == '') ?
'\'\'' : 'PASSWORD(\'' . ereg_replace('.', '*', $new_pw) . '\')');
1230 $local_query = (empty($common_upd) ?
'' : $common_upd . ', ')
1231 . $password_field . ' = ' . (($new_pw == '') ?
'\'\'' : 'PASSWORD(\'' . PMA_sqlAddslashes($new_pw) . '\')');
1234 if (!empty($sql_query)) {
1235 $common_where = ' WHERE Host = \'' . PMA_sqlAddslashes($host) . '\' AND User = \'' . PMA_sqlAddslashes($pma_user) . '\'';
1237 $local_query = 'UPDATE user SET ' . $local_query . $common_where;
1238 $sql_query_cpy = 'UPDATE user SET ' . $sql_query . $common_where;
1239 $result = @PMA_mysql_query
($local_query) or PMA_mysqlDie('', '', FALSE, $err_url . '&host=' . urlencode($host) . '&pma_user=' . urlencode($pma_user) . '&edit=1');
1242 if (isset($new_server) ||
isset($new_user)) {
1243 $sql_query = 'UPDATE mysql.db SET ' . $common_upd . $common_where;
1244 $sql_query_cpy .= ";\n" . $sql_query;
1245 PMA_mysql_query($sql_query);
1246 $sql_query = 'UPDATE mysql.tables_priv SET ' . $common_upd . $common_where;
1247 $sql_query_cpy .= ";\n" . $sql_query;
1248 PMA_mysql_query($sql_query);
1249 $sql_query = 'UPDATE mysql.columns_priv SET ' . $common_upd . $common_where;
1250 $sql_query_cpy .= ";\n" . $sql_query;
1251 PMA_mysql_query($sql_query);
1255 $sql_query = $sql_query_cpy;
1256 unset($sql_query_cpy);
1257 if (isset($new_server)) {
1258 $host = $new_server;
1260 if (isset($new_user)) {
1261 $pma_user = $new_user;
1264 echo ' ' . $strHost . ' ' . $host . ' - ' . $strUser . ' ' . (($pma_user != '') ?
$pma_user : $strAny) . "\n";
1265 echo '</h1>' . "\n";
1266 PMA_showMessage($strUpdateProfileMessage . '<br />' . $strRememberReload);
1269 echo ' ' . $strHost . ' ' . $host . ' - ' . $strUser . ' ' . (($pma_user != '') ?
$pma_user : $strAny) . "\n";
1270 echo '</h1>' . "\n";
1271 PMA_showMessage($strNoModification);
1275 // Changes the privileges of an user
1276 else if (isset($submit_chgPriv)) {
1279 if (!isset($host) ||
$host == '') {
1282 if (!isset($pma_user) ||
$pma_user == '') {
1287 $list_priv = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Reload',
1288 'Shutdown', 'Process', 'File', 'Grant', 'References', 'Index', 'Alter');
1289 for ($i = 0; $i < 14; $i++
) {
1290 $priv_name = $list_priv[$i] . '_priv';
1291 if (isset($
$priv_name)) {
1292 $sql_query .= (empty($sql_query) ?
$priv_name : ', ' . $priv_name) . ' = \'Y\'';
1294 $sql_query .= (empty($sql_query) ?
$priv_name : ', ' . $priv_name) . ' = \'N\'';
1299 $sql_query = 'UPDATE user SET '
1301 . ' WHERE Host = \'' . PMA_sqlAddslashes($host) . '\' AND User = \'' . PMA_sqlAddslashes($pma_user) . '\'';
1302 $result = @PMA_mysql_query
($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url . '&host=' . urlencode($host) . '&pma_user=' . urlencode($pma_user) . '&edit=1');
1303 PMA_showMessage(sprintf($strUpdatePrivMessage, '<span style="color: #002E80">' . $pma_user . '@' . $host . '</span>') . '<br />' . $strRememberReload);
1306 // Revoke/Grant privileges
1307 else if (isset($grants) && $grants) {
1309 if (!isset($host) ||
$host == '') {
1312 if (!isset($pma_user) ||
$pma_user == '') {
1316 if (isset($upd_grants)) {
1320 if (isset($colgrant) && !$anycolumn && !$newdb) {
1321 $colgrant_cnt = count($colgrant);
1322 for ($i = 0; $i < $colgrant_cnt; $i++
) {
1323 if (get_magic_quotes_gpc()) {
1324 $colgrant[$i] = stripslashes($colgrant[$i]);
1326 $col_list .= (empty($col_list) ?
PMA_backquote($colgrant[$i]) : ', ' . PMA_backquote($colgrant[$i]));
1329 $col_list = ' (' . $col_list . ')';
1332 $list_priv = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Reload',
1333 'Shutdown', 'Process', 'File', 'References', 'Index', 'Alter');
1334 for ($i = 0; $i < 13; $i++
) {
1335 $priv_name = $list_priv[$i] . '_priv';
1336 if (isset($
$priv_name)) {
1337 $sql_query .= (empty($sql_query) ?
$list_priv[$i] : ', ' . $list_priv[$i]) . $col_list;
1341 if (empty($sql_query)) {
1342 $sql_query = 'USAGE' . $col_list;
1344 $priv_grant = 'Grant_priv';
1345 $priv_grant = (isset($
$priv_grant) ?
' WITH GRANT OPTION' : '');
1347 if (get_magic_quotes_gpc()) {
1349 $newdb = stripslashes($newdb);
1351 if (isset($dbgrant) && !$anydb && !$newdb) {
1352 $dbgrant = stripslashes($dbgrant);
1354 if (isset($tablegrant) && !$anytable && !$newdb) {
1355 $tablegrant = stripslashes($tablegrant);
1360 // Escape wilcard characters if required
1361 if (isset($dbgrant) && !$anydb && !$newdb) {
1362 $re = '(^|(\\\\\\\\)+|[^\])(_|%)'; // non-escaped wildcards
1363 $dbgrant = ereg_replace($re, '\\1\\\\3', $dbgrant);
1367 $sql_query .= ' ON '
1368 . (($anydb ||
$dbgrant == '') ?
'*' : PMA_backquote($dbgrant))
1370 . (($anytable ||
$tablegrant == '') ?
'*' : PMA_backquote($tablegrant));
1372 $sql_query .= ' ON ' . PMA_backquote($newdb) . '.*';
1375 $sql_query .= ' TO ' . '\'' . PMA_sqlAddslashes($pma_user) . '\'' . '@' . '\'' . PMA_sqlAddslashes($host) . '\'';
1377 $sql_query = 'GRANT ' . $sql_query . $priv_grant;
1378 $result = @PMA_mysql_query
($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url . '&host=' . urlencode($host) . '&pma_user=' . urlencode($pma_user) . '&grants=1');
1379 PMA_showMessage($strAddPrivMessage . '.<br />' . $strRememberReload);
1388 // Edit an user properies
1389 if (isset($edit) && $edit) {
1390 PMA_tableUsers($host, $pma_user);
1391 PMA_editOperations($host, $pma_user);
1394 // Revoke/Grant privileges for an user
1395 else if (isset($grants) && $grants) {
1396 // Displays the full list of privileges for this host & user
1397 $infos['Host'] = $host;
1398 $infos['User'] = $pma_user;
1399 PMA_tableGrants($infos);
1401 // Displays the list of privileges for user on the selected db/table/column
1402 $user_priv = array();
1403 $list_priv = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Reload',
1404 'Shutdown', 'Process', 'File', 'Grant', 'References', 'Index',
1406 $list_priv_new = array();
1408 // Gets globals privileges
1409 $result = PMA_mysql_query('SELECT * FROM mysql.user WHERE (Host = \'' . PMA_sqlAddslashes($host) . '\' OR Host = \'%\') AND (User = \'' . PMA_sqlAddslashes($pma_user) . '\' OR User = \'\')');
1410 $row = ($result) ? @PMA_mysql_fetch_array
($result) : FALSE;
1412 while (list(,$priv) = each($list_priv)) {
1413 $priv_priv = $priv . '_priv';
1414 if ($row[$priv_priv] == 'Y') {
1415 $user_priv[$priv_priv] = 'Y';
1417 $user_priv[$priv_priv] = 'N';
1418 $list_priv_new[] = $priv;
1421 mysql_free_result($result);
1422 $list_priv = $list_priv_new;
1423 unset($list_priv_new);
1424 $list_priv_new = array();
1427 // If a target database is set, gets privileges for this database
1428 if (count($list_priv) && isset($dbgrant)) {
1429 if (get_magic_quotes_gpc()) {
1430 $dbgrant = stripslashes($dbgrant);
1432 $result = PMA_mysql_query('SELECT * FROM mysql.db WHERE (Host = \'' . PMA_sqlAddslashes($host) . '\' OR Host = \'%\') AND (User = \'' . PMA_sqlAddslashes($pma_user) . '\' OR User = \'\') AND Db = \'' . PMA_sqlAddslashes($dbgrant) . '\'');
1433 $row = ($result) ? @PMA_mysql_fetch_array
($result) : FALSE;
1435 while (list(,$priv) = each($list_priv)) {
1436 $priv_priv = $priv . '_priv';
1437 if (isset($row[$priv_priv]) && $row[$priv_priv] == 'Y') {
1438 $user_priv[$priv_priv] = 'Y';
1440 $list_priv_new[] = $priv;
1443 mysql_free_result($result);
1444 $list_priv = $list_priv_new;
1445 unset($list_priv_new);
1446 $list_priv_new = array();
1450 // If a target table is set, gets privileges for this table
1451 if (count($list_priv) && isset($tablegrant)) {
1452 if (get_magic_quotes_gpc()) {
1453 $tablegrant = stripslashes($tablegrant);
1455 $result = PMA_mysql_query('SELECT * FROM mysql.tables_priv WHERE (Host = \'' . PMA_sqlAddslashes($host) . '\' OR Host = \'%\') AND (User = \'' . PMA_sqlAddslashes($pma_user) . '\' OR User = \'\') AND Db = \'' . PMA_sqlAddslashes($dbgrant) . '\' AND Table_name = \'' . PMA_sqlAddslashes($tablegrant) . '\'');
1456 $row = ($result) ? @PMA_mysql_fetch_array
($result) : FALSE;
1457 if ($row && $row['Table_priv']) {
1458 while (list(,$priv) = each($list_priv)) {
1459 $priv_priv = $priv . '_priv';
1460 if (eregi('(^|,)' . $priv . '(,|$)', $row['Table_priv'])) {
1461 $user_priv[$priv_priv] = 'Y';
1463 $list_priv_new[] = $priv;
1466 mysql_free_result($result);
1467 $list_priv = $list_priv_new;
1468 unset($list_priv_new);
1469 $list_priv_new = array();
1473 // TODO: column privileges
1475 PMA_grantOperations($user_priv);
1478 // Check database privileges
1479 else if (isset($check) && $check) {
1484 <a href
="user_details.php3?<?php echo PMA_generate_common_url('mysql', 'user'); ?>">
1485 <?php
echo $strBack; ?
></a
>
1492 // Displays all users profiles
1494 if (!isset($host)) {
1497 if (!isset($pma_user)) {
1500 PMA_tableUsers($host, $pma_user) or PMA_mysqlDie($strNoUsersFound, '', FALSE, '');
1501 PMA_normalOperations();
1506 * Displays the footer
1508 require('./footer.inc.php3');