6 * Gets some core libraries
8 require('./libraries/grab_globals.lib.php3');
9 require('./libraries/common.lib.php3');
13 * Defines the url to return to in case of error in a sql statement
15 $err_url = 'user_details.php3'
17 . '&convcharset=' . $convcharset
18 . '&server=' . $server
24 * Displays the table of grants for an user
26 * @param mixed the id of the query used to get hosts and databases lists
27 * or an arry containing host and user informations
28 * @param mixed the database to check garnts for, FALSE for all databases
30 * @return boolean always true
32 * @global string the current language
33 * @global string the current charset for MySQL
34 * @global integer the server to use (refers to the number in the
39 * @TODO "SHOW GRANTS" statements is available and buggyless since
40 * MySQL 3.23.4 and it seems not to return privileges of the anonymous
41 * user while these privileges applies to all users.
43 function PMA_tableGrants(&$host_db_result, $dbcheck = FALSE) {
44 global $lang, $convcharset, $server;
47 <!-- Table of grants
-->
48 <table border
="<?php echo $GLOBALS['cfg']['Border']; ?>">
54 echo ' <th>' . $GLOBALS['strAction'] . '</th>' . "\n";
55 echo ' <th>' . $GLOBALS['strHost'] . '</th>' . "\n";
56 echo ' <th>' . $GLOBALS['strUser'] . '</th>';
59 echo ' <th colspan="2">' . $GLOBALS['strAction'] . '</th>';
62 echo ' <th>' . $GLOBALS['strDatabase'] . '</th>' . "\n";
63 echo ' <th>' . UCFirst($GLOBALS['strTable']) . '</th>' . "\n";
64 echo ' <th>' . $GLOBALS['strPrivileges'] . '</th>' . "\n";
66 echo ' <th>Grant Option</th>' . "\n";
74 $url_query = 'lang=' . $lang . '&convcharset=' . $convcharset . '&server=' . $server . '&db=mysql&table=user';
76 while ($row = (is_array($host_db_result) ?
$host_db_result : PMA_mysql_fetch_array($host_db_result))) {
77 $local_query = 'SHOW GRANTS FOR \'' . $row['User'] . '\'@\'' . $row['Host'] . '\'';
78 $result = PMA_mysql_query($local_query);
79 $grants_cnt = ($result) ? @mysql_num_rows
($result) : 0;
83 while ($usr_row = PMA_mysql_fetch_row($result)) {
84 if (eregi('GRANT (.*) ON ([^.]+).([^.]+) TO .*$', $usr_row[0], $parts)) {
85 if ($parts[1] == 'USAGE') {
88 // loic1: bug #487673 - revoke 'reference'
89 $priv = ereg_replace('REFERENCE([^S]|$)', 'REFERENCES\\1', trim($parts[1]));
90 // loic1: bug #576896 - No "FILE" privileges on a
91 // database if neither "INSERT" nor "UPDATE" one
92 if (strpos(' ' . $priv, 'FILE')
93 && !(strpos(' ' . $priv, 'INSERT') ||
strpos(' ' . $priv, 'UPDATE'))) {
94 $priv = ereg_replace('(^FILE(, )?)|(, FILE)', '', $priv);
98 $table = trim($parts[3]);
99 $grantopt = eregi('WITH GRANT OPTION$', $usr_row[0]);
109 if ($priv == '' && !$grantopt) {
113 // Checking the database (take into account wildcards)
115 && ($db != '*' && $db != $dbcheck)) {
116 // TODO: db names may contain characters that are regexp
118 $re = '(^|(\\\\\\\\)+|[^\])';
119 $db_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $db));
120 if (!eregi('^' . $db_regex . '$', $dbcheck)) {
125 $bgcolor = ($i %
2) ?
$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
126 $revoke_url = 'sql.php3'
128 . '&sql_query=' . urlencode('REVOKE ' . $priv . ' ON ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' FROM \'' . $row['User'] . '\'@\'' . $row['Host'] . '\'')
129 . '&zero_rows=' . urlencode(sprintf($GLOBALS['strRevokeMessage'], ' <span style="color: #002E80">' . $row['User'] . '@' . $row['Host'] . '</span>') . '<br />' . $GLOBALS['strRememberReload'])
130 . '&goto=user_details.php3';
132 $revoke_grant_url = 'sql.php3'
134 . '&sql_query=' . urlencode('REVOKE GRANT OPTION ON ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' FROM \'' . $row['User'] . '\'@\'' . $row['Host'] . '\'')
135 . '&zero_rows=' . urlencode(sprintf($GLOBALS['strRevokeGrantMessage'], ' <span style="color: #002E80">' . $row['User'] . '@' . $row['Host'] . '</span>') . '<br />' . $GLOBALS['strRememberReload'])
136 . '&goto=user_details.php3';
145 <td
<?php
if (!$grantopt) echo ' colspan="2"'; ?
> bgcolor
="<?php echo $bgcolor; ?>">
146 <a href
="<?php echo $revoke_url; ?>">
147 <?php
echo $GLOBALS['strRevokePriv']; ?
></a
>
154 <td
<?php
if (!$priv) echo ' colspan="2"'; ?
> bgcolor
="<?php echo $bgcolor; ?>">
155 <a href
="<?php echo $revoke_grant_url; ?>">
156 <?php
echo $GLOBALS['strRevokeGrant']; ?
></a
>
164 <td bgcolor
="<?php echo $bgcolor; ?>">
165 <a href
="<?php echo $revoke_url; ?>">
166 <?php
echo $GLOBALS['strRevoke']; ?
></a
>
172 <td bgcolor
="<?php echo $bgcolor; ?>"> 
;</td
>
177 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo $row['Host']; ?
></td
>
178 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($row['User']) ?
$row['User'] : '<span style="color: #FF0000">' . $GLOBALS['strAny'] . '</span>'; ?
></td
>
183 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($db == '*') ?
'<span style="color: #002E80">' . $GLOBALS['strAll'] . '</span>' : $db; ?
></td
>
184 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($table == '*') ?
'<span style="color: #002E80">' . $GLOBALS['strAll'] . '</span>' : $table; ?
></td
>
185 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($priv != '') ?
$priv : '<span style="color: #002E80">' . $GLOBALS['strNoPrivileges'] . '</span>'; ?
></td
>
190 <td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo ($grantopt) ?
$GLOBALS['strYes'] : $GLOBALS['strNo']; ?
></td
>
195 <!-- Debug
<td bgcolor
="<?php echo $bgcolor; ?>"><?php
echo $usr_row[0] ?
></td
> Debug
-->
200 } // end while $usr_row
201 } // end if $grants_cnt >0
202 // $host_db_result is an array containing related to only one user
204 if (is_array($host_db_result)) {
216 } // end of the 'PMA_tableGrants()' function
220 * Displays the list of grants for a/all database/s
222 * @param mixed the database to check garnts for, FALSE for all databases
224 * @return boolean true/false in case of success/failure
226 * @see PMA_tableGrants()
228 function PMA_checkDb($dbcheck)
230 $local_query = 'SELECT Host, User FROM mysql.user ORDER BY Host, User';
231 $result = PMA_mysql_query($local_query);
232 $host_usr_cnt = ($result) ? @mysql_num_rows
($result) : 0;
234 if (!$host_usr_cnt) {
237 PMA_tableGrants($result, $dbcheck);
240 } // end of the 'PMA_checkDb()' function
244 * Displays the privileges part of a page
246 * @param string the name of the form for js validation
247 * @param array the list of the privileges of the user
249 * @return boolean always true
251 * @global integer whether all/none of the privileges have to be checked or
254 * @see PMA_normalOperations()
256 function PMA_tablePrivileges($form, $row = FALSE)
260 $checkpriv_url = $GLOBALS['cfg']['PmaAbsoluteUri']
261 . 'user_details.php3?';
262 if (empty($GLOBALS['QUERY_STRING'])) {
263 $GLOBALS['QUERY_STRING'] = (isset($_SERVER))
264 ?
$_SERVER['QUERY_STRING']
265 : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
267 if (!empty($GLOBALS['QUERY_STRING'])) {
268 $checkpriv_url .= str_replace('&', '&', $GLOBALS['QUERY_STRING']) . '&';
275 $list_priv = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Reload',
276 'Shutdown', 'Process', 'File', 'Grant', 'References', 'Index', 'Alter');
278 while ((list(,$priv) = each($list_priv)) && ++
$item) {
279 $priv_priv = $priv . '_priv';
280 if (isset($checkpriv)) {
281 $checked = ($checkpriv == 'all') ?
' checked="checked"' : '';
283 $checked = ($row && $row[$priv_priv] == 'Y') ?
' checked="checked"' : '';
285 if ($item %
2 == 1) {
288 echo ' <td> </td>' . "\n";
291 echo ' <input type="checkbox" name="' . $priv . '_priv" id="checkbox_priv_' . $priv . '"' . $checked . ' />' . "\n";
292 echo ' </td>' . "\n";
293 echo ' <td><label for="checkbox_priv_' . $priv . '">' . $priv . '</label></td>' . "\n";
294 if ($item %
2 == 0) {
295 echo ' </tr>' . "\n";
298 if ($item %
2 == 1) {
299 echo ' <td colspan="2"> <td>' . "\n";
300 echo ' </tr>' . "\n";
307 <a href
="<?php echo $checkpriv_url; ?>checkpriv=all" onclick
="checkForm('<?php echo $form; ?>', true); return false">
308 <?php
echo $GLOBALS['strCheckAll']; ?
></a
>
312 <a href
="<?php echo $checkpriv_url; ?>checkpriv=none" onclick
="checkForm('<?php echo $form; ?>', false); return false">
313 <?php
echo $GLOBALS['strUncheckAll']; ?
></a
>
321 } // end of the 'PMA_tablePrivileges()' function
325 * Displays the page for "normal" operations
327 * @return boolean always true
329 * @global string the current language
330 * @global string the current charset for MySQL
331 * @global integer the server to use (refers to the number in the
332 * configuration file)
334 * @see PMA_tablePrivileges()
336 function PMA_normalOperations()
338 global $lang, $convcharset, $server;
344 <div style
="margin-bottom: 10px">
345 <a href
="user_details.php3?lang=<?php echo $lang; ?>&convcharset=<?php echo $convcharset; ?>&server=<?php echo $server; ?>&db=mysql&table=user&mode=reload">
346 <?php
echo $GLOBALS['strReloadMySQL']; ?
></a
> 
;
347 <?php
echo PMA_showDocuShort('F/L/FLUSH.html') . "\n"; ?
>
352 <form name
="dbPrivForm" action
="user_details.php3" method
="post">
353 <?php
echo $GLOBALS['strCheckDbPriv'] . "\n"; ?
>
357 <?php
echo $GLOBALS['strDatabase']; ?
> 
;: 
;
361 $result = PMA_mysql_query('SHOW DATABASES');
362 if ($result && @mysql_num_rows
($result)) {
363 while ($row = PMA_mysql_fetch_row($result)) {
365 echo '<option value="' . str_replace('"', '"', $row[0]) . '">' . htmlspecialchars($row[0]) . '</option>' . "\n";
370 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
371 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
372 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
373 <input type
="hidden" name
="check" value
="1" />
374 <input type
="submit" value
="<?php echo $GLOBALS['strGo']; ?>" />
382 <form action
="user_details.php3" method
="post" name
="addUserForm" onsubmit
="return checkAddUser()">
383 <?php
echo $GLOBALS['strAddUser'] . "\n"; ?
>
387 <input type
="radio" name
="anyhost" id
="radio_anyhost0" checked
="checked" />
388 <label
for="radio_anyhost0"><?php
echo $GLOBALS['strAnyHost']; ?
></label
>
392 <input type
="radio" name
="anyhost" id
="radio_anyhost1" />
393 <label
for="radio_anyhost1"><?php
echo $GLOBALS['strHost']; ?
></label
> 
;: 
;
396 <input type
="text" name
="host" size
="10" class="textfield" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="this.form.anyhost[1].checked = true" />
401 <input type
="radio" name
="anyuser" id
="radio_anyuser0" />
402 <label
for="radio_anyuser0"><?php
echo $GLOBALS['strAnyUser']; ?
></label
>
406 <input type
="radio" name
="anyuser" id
="radio_anyuser1" checked
="checked" />
407 <label
for="radio_anyuser1"><?php
echo $GLOBALS['strUserName']; ?
></label
> 
;: 
;
410 <input type
="text" name
="pma_user" size
="10" class="textfield" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="this.form.anyuser[1].checked = true" />
415 <input type
="radio" name
="nopass" value
="1" id
="radio_nopass1" onclick
="pma_pw.value = ''; pma_pw2.value = ''; this.checked = true" />
416 <label
for="radio_nopass1"><?php
echo $GLOBALS['strNoPassword']; ?
></label
>
420 <input type
="radio" name
="nopass" value
="0" id
="radio_nopass0" checked
="checked" />
421 <label
for="radio_nopass0"><?php
echo $GLOBALS['strPassword']; ?
></label
> 
;: 
;
424 <input type
="password" name
="pma_pw" size
="10" class="textfield" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="nopass[1].checked = true" />
426 <?php
echo $GLOBALS['strReType']; ?
> 
;: 
;
427 <input type
="password" name
="pma_pw2" size
="10" class="textfield" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="nopass[1].checked = true" />
433 <?php
echo $GLOBALS['strPrivileges']; ?
> 
;:
440 PMA_tablePrivileges('addUserForm');
442 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
443 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
444 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
445 <input type
="submit" name
="submit_addUser" value
="<?php echo $GLOBALS['strGo']; ?>" />
453 } // end of the 'PMA_normalOperations()' function
457 * Displays the grant operations part of an user properties page
459 * @param array grants of the current user
461 * @return boolean always true
463 * @global string the current language
464 * @global string the current charset for MySQL
465 * @global integer the server to use (refers to the number in the
466 * configuration file)
467 * @global string the host name to check grants for
468 * @global string the username to check grants for
469 * @global string the database to check grants for
470 * @global string the table to check grants for
472 * @see PMA_tablePrivileges()
474 function PMA_grantOperations($grants)
476 global $lang, $convcharset, $server, $host, $pma_user;
477 global $dbgrant, $tablegrant, $newdb;
483 <div style
="margin-bottom: 10px">
484 <a href
="user_details.php3?lang=<?php echo $lang; ?>&convcharset=<?php echo $convcharset; ?>&server=<?php echo $server; ?>&db=mysql&table=user">
485 <?php
echo $GLOBALS['strBack']; ?
></a
>
490 <form action
="user_details.php3" method
="post" name
="userGrants">
491 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
492 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
493 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
494 <input type
="hidden" name
="grants" value
="1" />
495 <input type
="hidden" name
="host" value
="<?php echo str_replace('"', '"
;', $host); ?>" />
496 <input type="hidden" name="pma_user" value="<?php echo str_replace('"', '"', $pma_user); ?>" />
498 <?php
echo $GLOBALS['strAddPriv'] . "\n"; ?
>
502 <input type
="radio" name
="anydb" value
="1" id
="radio_anydb1"<?php
echo ($dbgrant) ?
'' : ' checked="checked"'; ?
> />
503 <label
for="radio_anydb1"><?php
echo $GLOBALS['strAnyDatabase']; ?
></label
>
505 <td
> 
; 
; 
;</td
>
507 <input type
="radio" name
="anydb" value
="0" id
="radio_anydb0"<?php
echo ($dbgrant) ?
' checked="checked"' : ''; ?
> />
508 <label
for="radio_anydb0"><?php
echo $GLOBALS['strDatabase']; ?
></label
><a href
="./Documentation.html#underscore" target
="documentation" title
="<?php echo $GLOBALS['strDocu']; ?>">(*)</a
> 
;: 
;
511 <select name
="dbgrant" onchange
="change(this)">
515 // if (!isset($dbgrant)) {
517 // echo '<option></option>' . "\n";
519 $is_selected_db = FALSE;
520 $result = PMA_mysql_query('SHOW DATABASES');
521 if ($result && @mysql_num_rows
($result)) {
522 while ($row = PMA_mysql_fetch_row($result)) {
523 $selected = (($row[0] == $dbgrant) ?
' selected="selected"' : '');
524 if (!empty($selected)) {
525 $is_selected_db = TRUE;
528 echo '<option' . $selected . '>' . $row[0] . '</option>' . "\n";
536 <input type
="submit" value
="<?php echo $GLOBALS['strShowTables']; ?>" />
541 <input type
="radio" name
="anytable" value
="1" id
="radio_anytable1"<?php
echo ($tablegrant) ?
'' : ' checked="checked"'; ?
> />
542 <label
for="radio_anytable1"><?php
echo $GLOBALS['strAnyTable']; ?
></label
>
544 <td
> 
; 
; 
;</td
>
546 <input type
="radio" name
="anytable" value
="0" id
="radio_anytable0"<?php
echo ($tablegrant) ?
' checked="checked"' : ''; ?
> />
547 <label
for="radio_anytable0"><?php
echo $GLOBALS['strTable']; ?
></label
> 
;: 
;
550 <select name
="tablegrant" onchange
="change(this)">
554 // if (!isset($tablegrant)) {
556 // echo '<option></option>' . "\n";
558 if (isset($dbgrant)) {
559 $result = PMA_mysql_query('SHOW TABLES FROM ' . PMA_backquote($dbgrant));
560 if ($result && @mysql_num_rows
($result)) {
561 while ($row = PMA_mysql_fetch_row($result)) {
562 $selected = ((isset($tablegrant) && $row[0] == $tablegrant) ?
' selected="selected"' : '');
564 echo '<option' . $selected . '>' . $row[0] . '</option>' . "\n";
573 <input type
="submit" value
="<?php echo $GLOBALS['strShowCols']; ?>" />
578 <input type
="radio" name
="anycolumn" value
="1" id
="radio_anycolumn1" checked
="checked" />
579 <label
for="radio_anycolumn1"><?php
echo $GLOBALS['strAnyColumn']; ?
></label
>
581 <td
> 
; 
; 
;</td
>
583 <input type
="radio" name
="anycolumn" value
="0" id
="radio_anycolumn0" />
584 <label
for="radio_anycolumn0"><?php
echo $GLOBALS['strColumn']; ?
></label
> 
;: 
;
589 if (!isset($dbgrant) ||
!isset($tablegrant)) {
590 echo ' ' . '<select name="colgrant[]">' . "\n";
591 echo ' ' . '<option></option>' . "\n";
592 echo ' ' . '</select>' . "\n";
595 $result = PMA_mysql_query('SHOW COLUMNS FROM ' . PMA_backquote($tablegrant) . ' FROM ' . PMA_backquote($dbgrant));
596 if ($result && @mysql_num_rows
($result)) {
598 . '<select name="colgrant[]" multiple="multiple" onchange="anycolumn[1].checked = true">' . "\n";
599 while ($row = PMA_mysql_fetch_row($result)) {
601 echo '<option value="' . str_replace('"', '"', $row[0]) . '">' . $row[0] . '</option>' . "\n";
604 echo ' ' . '<select name="colgrant[]">' . "\n";
605 echo ' ' . '<option></option>' . "\n";
606 } // end if... else...
608 . '</select>' . "\n";
616 <i
><?php
echo $GLOBALS['strOr']; ?
></i
>
621 <?php
echo $GLOBALS['strDatabaseWildcard'] . "\n"; ?
> 
;
622 <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)" />
631 <?php
echo $GLOBALS['strPrivileges']; ?
> 
;: 
;
638 PMA_tablePrivileges('userGrants', $grants);
640 <input type
="submit" name
="upd_grants" value
="<?php echo $GLOBALS['strGo']; ?>" />
649 } // end of the 'PMA_grantOperations()' function
653 * Displays the page to edit operations
655 * @param string the host name to check grants for
656 * @param string the user name to check grants for
658 * @return boolean always true
660 * @global string the current language
661 * @global string the current charset for MySQL
662 * @global integer the server to use (refers to the number in the
663 * configuration file)
665 * @see PMA_tablePrivileges()
667 function PMA_editOperations($host, $user)
669 global $lang, $convcharset, $server;
671 $result = PMA_mysql_query('SELECT * FROM mysql.user WHERE User = \'' . PMA_sqlAddslashes($user) . '\' AND Host = \'' . PMA_sqlAddslashes($host) . '\'');
672 $rows = ($result) ? @mysql_num_rows
($result) : 0;
678 $row = PMA_mysql_fetch_array($result);
684 <div style
="margin-bottom: 10px">
685 <a href
="user_details.php3?lang=<?php echo $lang; ?>&convcharset=<?php echo $convcharset; ?>&server=<?php echo $server; ?>&db=mysql&table=user">
686 <?php
echo $GLOBALS['strBack']; ?
></a
>
691 <form action
="user_details.php3" method
="post" name
="updUserForm" onsubmit
="return checkUpdProfile()">
692 <?php
echo $GLOBALS['strUpdateProfile'] . "\n"; ?
>
696 <input type
="radio" value
="1" name
="anyhost" id
="radio_anyhost1"<?php
if ($host == '' ||
$host == '%') echo ' checked="checked"'; ?
> />
697 <label
for="radio_anyhost1"><?php
echo $GLOBALS['strAnyHost']; ?
></label
>
701 <input type
="radio" value
="0" name
="anyhost" id
="radio_anyhost0"<?php
if ($host != '' && $host != '%') echo ' checked="checked"'; ?
> />
702 <label
for="radio_anyhost0"><?php
echo $GLOBALS['strHost']; ?
></label
> 
;: 
;
705 <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" />
710 <input type="radio" value="1" name="anyuser" id="radio_anyuser1"<?php if ($user == '' || $user == '%
') echo ' checked
="checked"'; ?> />
711 <label for="radio_anyuser1"><?php echo $GLOBALS['strAnyUser
']; ?></label>
715 <input type="radio" value="0" name="anyuser" id="radio_anyuser0"<?php if ($user != '' && $user != '%
') echo ' checked
="checked"'; ?> />
716 <label for="radio_anyuser0"><?php echo $GLOBALS['strUserName
']; ?></label> :
719 <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" />
724 <input type
="radio" name
="nopass" value
="-1" id
="radio_nopass-1" checked
="checked" onclick
="new_pw.value = ''; new_pw2.value = ''; this.checked = true" />
725 <label
for="radio_nopass-1"><?php
echo $GLOBALS['strKeepPass']; ?
></label
>
727 <td colspan
="3"> 
;</td
>
730 <td colspan
="4" align
="<?php echo $GLOBALS['cell_align_left']; ?>"> 
; 
; 
; 
; 
; 
;<?php
echo $GLOBALS['strOr']; ?
></td
>
734 <input type
="radio" name
="nopass" value
="1" id
="radio_nopass1" onclick
="new_pw.value = ''; new_pw2.value = ''; this.checked = true" />
735 <label
for="radio_nopass1"><?php
echo $GLOBALS['strNoPassword']; ?
></label
>
739 <input type
="radio" name
="nopass" value
="0" id
="radio_nopass0" />
740 <label
for="radio_nopass0"><?php
echo $GLOBALS['strPassword']; ?
></label
> 
;: 
;
743 <input type
="password" name
="new_pw" size
="10" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="nopass[2].checked = true" />
745 <?php
echo $GLOBALS['strReType']; ?
> 
;: 
;
746 <input type
="password" name
="new_pw2" size
="10" <?php
echo $GLOBALS['chg_evt_handler']; ?
>="nopass[2].checked = true" />
750 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
751 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
752 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
753 <input type
="hidden" name
="host" value
="<?php echo str_replace('"', '"
;', $host); ?>" />
754 <input type="hidden" name="pma_user" value="<?php echo str_replace('"', '"', $user); ?>" />
755 <input type
="submit" name
="submit_updProfile" value
="<?php echo $GLOBALS['strGo']; ?>" />
760 <form action
="user_details.php3" method
="post" name
="privForm">
761 <?php
echo $GLOBALS['strEditPrivileges'] . "\n"; ?
>
763 PMA_tablePrivileges('privForm', $row);
766 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
767 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
768 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
769 <input type
="hidden" name
="host" value
="<?php echo str_replace('"', '"
;', $host); ?>" />
770 <input type="hidden" name="pma_user" value="<?php echo str_replace('"', '"', $user); ?>" />
771 <input type
="submit" name
="submit_chgPriv" value
="<?php echo $GLOBALS['strGo']; ?>" />
780 } // end of the 'PMA_editOperations()' function
784 * Displays the table of the users
786 * @param string the host name
787 * @param string the user name
789 * @return boolean always true
791 * @global string the current language
792 * @global string the current charset for MySQL
793 * @global integer the server to use (refers to the number in the
794 * configuration file)
796 function PMA_tableUsers($host = FALSE, $user = FALSE)
798 global $lang, $convcharset, $server;
800 $local_query = 'SELECT * FROM mysql.user ';
801 if ($host ||
$user) {
802 $local_query .= ' WHERE 1 ';
805 $local_query .= ' AND Host = \'' . PMA_sqlAddslashes($host) . '\'';
806 $local_query .= ' AND User = \'' . PMA_sqlAddslashes($user) . '\'';
808 $local_query .= ' ORDER BY Host, User';
809 $result = PMA_mysql_query($local_query);
810 $rows = ($result) ? @mysql_num_rows
($result) : 0;
816 echo '<i>' . $GLOBALS['strEnglishPrivileges'] . '</i><br />' . "\n";
817 echo '<table border="' . $GLOBALS['cfg']['Border'] . '">' . "\n";
819 echo ' <th colspan="'. (($user) ?
'2' : '3') . '">' . $GLOBALS['strAction'] . '</th>' . "\n";
820 echo ' <th>' . $GLOBALS['strHost'] . '</th>' . "\n";
821 echo ' <th>' . $GLOBALS['strUser'] . '</th>' . "\n";
822 echo ' <th>' . $GLOBALS['strPassword'] . '</th>' . "\n";
823 echo ' <th>' . $GLOBALS['strPrivileges'] . '</th>' . "\n";
827 while ($row = PMA_mysql_fetch_array($result)) {
829 $bgcolor = ($i %
2) ?
$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
832 if ($row['Select_priv'] == 'Y') {
833 $strPriv .= 'Select ';
835 if ($row['Insert_priv'] == 'Y') {
836 $strPriv .= 'Insert ';
838 if ($row['Update_priv'] == 'Y') {
839 $strPriv .= 'Update ';
841 if ($row['Delete_priv'] == 'Y') {
842 $strPriv .= 'Delete ';
844 if ($row['Create_priv'] == 'Y') {
845 $strPriv .= 'Create ';
847 if ($row['Drop_priv'] == 'Y') {
850 if ($row['Reload_priv'] == 'Y') {
851 $strPriv .= 'Reload ';
853 if ($row['Shutdown_priv'] == 'Y') {
854 $strPriv .= 'Shutdown ';
856 if ($row['Process_priv'] == 'Y') {
857 $strPriv .= 'Process ';
859 if ($row['File_priv'] == 'Y') {
862 if ($row['Grant_priv'] == 'Y') {
863 $strPriv .= 'Grant ';
865 if ($row['References_priv'] == 'Y') {
866 $strPriv .= 'References ';
868 if ($row['Index_priv'] == 'Y') {
869 $strPriv .= 'Index ';
871 if ($row['Alter_priv'] == 'Y') {
872 $strPriv .= 'Alter ';
874 if ($strPriv == '') {
875 $strPriv = '<span style="color: #002E80">' . $GLOBALS['strNoPrivileges'] . '</span>';
878 $query = 'lang=' . $lang . '&server=' . $server . '&db=mysql&table=user&convcharset=' . $convcharset;
880 $edit_url = 'user_details.php3'
881 . '?lang=' . $lang . '&convcharset=' . $convcharset . '&server=' . $server
882 . '&edit=1&host=' . urlencode($row['Host']) . '&pma_user=' . urlencode($row['User']);
884 $delete_url = 'user_details.php3'
886 . '&delete=1&confirm=1&delete_host=' . urlencode($row['Host']) . '&delete_user=' . urlencode($row['User']);
887 $check_url = 'user_details.php3'
888 . '?lang=' . $lang . '&convcharset=' . $convcharset . '&server=' . $server
889 . '&grants=1&host=' . urlencode($row['Host']) . '&pma_user=' . urlencode($row['User']);
897 <td bgcolor
="<?php echo $bgcolor;?>">
898 <a href
="<?php echo $edit_url; ?>">
899 <?php
echo $GLOBALS['strEdit']; ?
></a
>
905 <td bgcolor
="<?php echo $bgcolor;?>">
906 <a href
="<?php echo $delete_url; ?>">
907 <?php
echo $GLOBALS['strDelete']; ?
></a
>
909 <td bgcolor
="<?php echo $bgcolor;?>">
910 <a href
="<?php echo $check_url; ?>">
911 <?php
echo $GLOBALS['strGrants']; ?
></a
>
914 <td bgcolor
="<?php echo $bgcolor;?>">
915 <a href
="<?php echo (($check_url != '') ? $check_url : '#'); ?>">
916 <?php
echo $GLOBALS['strGrants']; ?
></a
>
919 <td bgcolor
="<?php echo $bgcolor;?>">
920 <?php
echo $row['Host'] . "\n"; ?
>
922 <td bgcolor
="<?php echo $bgcolor;?>">
923 <?php
echo (($row['User']) ?
'<b>' . $row['User'] . '</b>' : '<span style="color: #FF0000">' . $GLOBALS['strAny'] . '</span>') . "\n"; ?
>
925 <td bgcolor
="<?php echo $bgcolor;?>">
926 <?php
echo (($row[$GLOBALS['password_field']]) ?
$GLOBALS['strYes'] : '<span style="color: #FF0000">' . $GLOBALS['strNo'] . '</span>') . "\n"; ?
>
928 <td bgcolor
="<?php echo $bgcolor;?>">
929 <?php
echo $strPriv . "\n"; ?
>
945 } // end of the 'PMA_tableUsers()' function
949 * Displays a confirmation form
951 * @param string the host name and...
952 * @param string ... the username to delete
954 * @global string the current language
955 * @global string the current charset for MySQL
956 * @global integer the server to use (refers to the number in the
957 * configuration file)
959 function PMA_confirm($the_host, $the_user) {
960 global $lang, $convcharset, $server;
962 if (get_magic_quotes_gpc() == 1) {
963 $the_host = stripslashes($the_host);
964 $the_user = stripslashes($the_user);
967 echo $GLOBALS['strConfirm'] . ' : <br />' . "\n";
968 echo 'DELETE FROM mysql.user WHERE Host = \'' . $the_host . '\' AND User = \'' . $the_user . '\'' . '<br />' . "\n";
970 <form action
="user_details.php3" method
="post">
971 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
972 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
973 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
974 <input type
="hidden" name
="db" value
="mysql" />
975 <input type
="hidden" name
="table" value
="user" />
976 <input type
="hidden" name
="delete" value
="<?php echo(isset($GLOBALS['delete']) ? '1' : '0'); ?>" />
977 <input type
="hidden" name
="delete_host" value
="<?php echo str_replace('"', '"
;', $the_host); ?>" />
978 <input type="hidden" name="delete_user" value="<?php echo str_replace('"', '"', $the_user); ?>" />
979 <input type
="submit" name
="btnConfirm" value
="<?php echo $GLOBALS['strYes']; ?>" />
980 <input type
="submit" name
="btnConfirm" value
="<?php echo $GLOBALS['strNo']; ?>" />
985 include('./footer.inc.php3');
986 } // end of the 'PMA_confirm()' function
991 * Ensures the user is super-user and gets the case sensitive password field
994 $result = @PMA_mysql_query
('USE mysql');
995 if (PMA_mysql_error()) {
996 include('./header.inc.php3');
997 echo '<p><b>' . $strError . '</b></p>' . "\n";
998 echo '<p> ' . $strNoRights . '</p>' . "\n";
999 include('./footer.inc.php3');
1002 // The previous logic did not work if the password field is named "password":
1003 //$result = @PMA_mysql_query('SELECT COUNT(Password) FROM mysql.user');
1004 //$password_field = (($result && PMA_mysql_result($result, 0)) ? 'Password' : 'password');
1006 // using a syntax that works with older and recent MySQL,
1007 // and assumes that the field name ends with "assword":
1008 $result = @PMA_mysql_query
('SHOW FIELDS FROM user FROM mysql LIKE \'%assword\'');
1010 $password_field = PMA_mysql_result($result, 0);
1014 * Autocomplete feature of IE kills the "onchange" event handler and it must be
1015 * replaced by the "onpropertychange" one in this case
1017 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
>= 5)
1018 ?
'onpropertychange'
1026 $db_bkp = (get_magic_quotes_gpc() ?
stripslashes($db) : $db);
1029 if (isset($table)) {
1030 $table_bkp = (get_magic_quotes_gpc() ?
stripslashes($table) : $table);
1033 if (get_magic_quotes_gpc()) {
1034 if (!empty($host)) {
1035 $host = stripslashes($host);
1037 if (!empty($pma_user)) {
1038 $pma_user = stripslashes($pma_user);
1042 if (!isset($message)) {
1043 $js_to_run = 'user_details.js';
1044 include('./header.inc.php3');
1046 if (!isset($submit_updProfile)) {
1048 echo ' ' . ((!isset($host) ||
$host == '') ?
$strAnyHost : $strHost . ' ' . $host) . ' - ' . ((!isset($pma_user) ||
$pma_user == '') ?
$strAnyUser : $strUser . ' ' . $pma_user) . "\n";
1051 if (isset($message)) {
1053 PMA_showMessage($message);
1056 if (isset($db_bkp)) {
1060 if (isset($table_bkp)) {
1061 $table = $table_bkp;
1067 * Some actions has been submitted
1069 // Confirms an action
1070 if (isset($confirm) && $confirm) {
1071 PMA_confirm($delete_host, $delete_user);
1076 else if (($server > 0) && isset($mode) && ($mode == 'reload')) {
1077 $result = PMA_mysql_query('FLUSH PRIVILEGES');
1079 echo '<p><b>' . $strMySQLReloaded . '</b></p>' . "\n";
1081 echo '<p><b>' . $strReloadFailed . '</b></p>' . "\n";
1086 else if (isset($delete) && $delete
1087 && isset($btnConfirm) && $btnConfirm == $strYes) {
1088 if (get_magic_quotes_gpc()) {
1089 $delete_host = stripslashes($delete_host);
1090 $delete_user = stripslashes($delete_user);
1092 $common_where = ' WHERE Host = \'' . PMA_sqlAddslashes($delete_host) . '\' AND User = \'' . PMA_sqlAddslashes($delete_user) . '\'';
1094 // Delete Grants First!
1095 $sql_query = 'DELETE FROM mysql.db' . $common_where;
1096 $sql_query_cpy = $sql_query;
1097 PMA_mysql_query($sql_query);
1098 $sql_query = 'DELETE FROM mysql.tables_priv' . $common_where;
1099 $sql_query_cpy .= ";\n" . $sql_query;
1100 PMA_mysql_query($sql_query);
1101 $sql_query = 'DELETE FROM mysql.columns_priv' . $common_where;
1102 $sql_query_cpy .= ";\n" . $sql_query;
1103 PMA_mysql_query($sql_query);
1105 $sql_query = 'DELETE FROM mysql.user' . $common_where;
1106 $sql_query_cpy .= ";\n" . $sql_query;
1107 $result = PMA_mysql_query($sql_query);
1109 $sql_query = $sql_query_cpy;
1110 unset($sql_query_cpy);
1112 PMA_showMessage(sprintf($strDeleteUserMessage, '<span style="color: #002E80">' . $delete_user . '@' . $delete_host . '</span>') . '<br />' . $strRememberReload);
1114 PMA_showMessage($strDeleteFailed);
1119 else if (isset($submit_addUser)) {
1121 if (!isset($host) ||
$host == '') {
1124 if (!isset($pma_user) ||
$pma_user == '') {
1128 // Password is not confirmed
1129 if ((!isset($nopass) ||
!$nopass) && $pma_pw == '') {
1130 echo '<p><b>' . $strError . ' : ' . $strPasswordEmpty . '</b></p>' . "\n";
1134 else if ($pma_pw != ''
1135 && (!isset($pma_pw2) ||
$pma_pw != $pma_pw2)) {
1136 echo '<p><b>' . $strError . ' : ' . $strPasswordNotSame . '</b></p>' . "\n";
1141 // Password confirmed
1144 $list_priv = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Reload',
1145 'Shutdown', 'Process', 'File', 'Grant', 'References', 'Index', 'Alter');
1146 for ($i = 0; $i < 14; $i++
) {
1147 $priv_name = $list_priv[$i] . '_priv';
1148 if (isset($
$priv_name)) {
1149 $sql_query .= (empty($sql_query) ?
$priv_name : ', ' . $priv_name) . ' = \'Y\'';
1151 $sql_query .= (empty($sql_query) ?
$priv_name : ', ' . $priv_name) . ' = \'N\'';
1156 if (get_magic_quotes_gpc() && $pma_pw != '') {
1157 $pma_pw = stripslashes($pma_pw);
1160 $local_query = 'INSERT INTO mysql.user '
1161 . 'SET Host = \'' . PMA_sqlAddslashes($host) . '\', User = \'' . PMA_sqlAddslashes($pma_user) . '\', ' . $password_field . ' = ' . (($pma_pw == '') ?
'\'\'' : 'PASSWORD(\'' . PMA_sqlAddslashes($pma_pw) . '\')')
1162 . ', ' . $sql_query;
1163 $sql_query = 'INSERT INTO mysql.user '
1164 . 'SET Host = \'' . PMA_sqlAddslashes($host) . '\', User = \'' . PMA_sqlAddslashes($pma_user) . '\', ' . $password_field . ' = ' . (($pma_pw == '') ?
'\'\'' : 'PASSWORD(\'' . ereg_replace('.', '*', $pma_pw) . '\')')
1165 . ', ' . $sql_query;
1166 $result = @PMA_mysql_query
($local_query) or PMA_mysqlDie('', '', FALSE, $err_url);
1169 PMA_showMessage($strAddUserMessage . '<br />' . $strRememberReload);
1173 // Updates the profile of an user
1174 else if (isset($submit_updProfile)) {
1177 if (!isset($host) ||
$host == '') {
1180 if (!isset($pma_user) ||
$pma_user == '') {
1184 // Builds the sql query
1187 if (isset($anyhost) && $anyhost) {
1189 } else if ($new_server != '' && get_magic_quotes_gpc()) {
1190 $new_server = stripslashes($new_server);
1192 if ($new_server != '' && $new_server != $host) {
1193 $common_upd .= 'Host = \'' . PMA_sqlAddslashes($new_server) . '\'';
1194 } else if (isset($new_server)) {
1198 if (isset($anyuser) && $anyuser) {
1200 } else if ($new_user != '' && get_magic_quotes_gpc()) {
1201 $new_user = stripslashes($new_user);
1203 if ($new_user != '' && $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) . '\'';
1238 $local_query = 'UPDATE user SET ' . $local_query . $common_where;
1239 $sql_query_cpy = 'UPDATE user SET ' . $sql_query . $common_where;
1240 $result = @PMA_mysql_query
($local_query) or PMA_mysqlDie('', '', FALSE, $err_url . '&host=' . urlencode($host) . '&pma_user=' . urlencode($pma_user) . '&edit=1');
1243 if (isset($new_server) ||
isset($new_user)) {
1244 $sql_query = 'UPDATE mysql.db SET ' . $common_upd . $common_where;
1245 $sql_query_cpy .= ";\n" . $sql_query;
1246 PMA_mysql_query($sql_query);
1247 $sql_query = 'UPDATE mysql.tables_priv SET ' . $common_upd . $common_where;
1248 $sql_query_cpy .= ";\n" . $sql_query;
1249 PMA_mysql_query($sql_query);
1250 $sql_query = 'UPDATE mysql.columns_priv SET ' . $common_upd . $common_where;
1251 $sql_query_cpy .= ";\n" . $sql_query;
1252 PMA_mysql_query($sql_query);
1256 $sql_query = $sql_query_cpy;
1257 unset($sql_query_cpy);
1258 if (isset($new_server)) {
1259 $host = $new_server;
1261 if (isset($new_user)) {
1262 $pma_user = $new_user;
1265 echo ' ' . $strHost . ' ' . $host . ' - ' . $strUser . ' ' . (($pma_user != '') ?
$pma_user : $strAny) . "\n";
1266 echo '</h1>' . "\n";
1267 PMA_showMessage($strUpdateProfileMessage . '<br />' . $strRememberReload);
1270 echo ' ' . $strHost . ' ' . $host . ' - ' . $strUser . ' ' . (($pma_user != '') ?
$pma_user : $strAny) . "\n";
1271 echo '</h1>' . "\n";
1272 PMA_showMessage($strNoModification);
1276 // Changes the privileges of an user
1277 else if (isset($submit_chgPriv)) {
1280 if (!isset($host) ||
$host == '') {
1283 if (!isset($pma_user) ||
$pma_user == '') {
1288 $list_priv = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Reload',
1289 'Shutdown', 'Process', 'File', 'Grant', 'References', 'Index', 'Alter');
1290 for ($i = 0; $i < 14; $i++
) {
1291 $priv_name = $list_priv[$i] . '_priv';
1292 if (isset($
$priv_name)) {
1293 $sql_query .= (empty($sql_query) ?
$priv_name : ', ' . $priv_name) . ' = \'Y\'';
1295 $sql_query .= (empty($sql_query) ?
$priv_name : ', ' . $priv_name) . ' = \'N\'';
1300 $sql_query = 'UPDATE user SET '
1302 . ' WHERE Host = \'' . PMA_sqlAddslashes($host) . '\' AND User = \'' . PMA_sqlAddslashes($pma_user) . '\'';
1303 $result = @PMA_mysql_query
($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url . '&host=' . urlencode($host) . '&pma_user=' . urlencode($pma_user) . '&edit=1');
1304 PMA_showMessage(sprintf($strUpdatePrivMessage, '<span style="color: #002E80">' . $pma_user . '@' . $host . '</span>') . '<br />' . $strRememberReload);
1307 // Revoke/Grant privileges
1308 else if (isset($grants) && $grants) {
1310 if (!isset($host) ||
$host == '') {
1313 if (!isset($pma_user) ||
$pma_user == '') {
1317 if (isset($upd_grants)) {
1321 if (isset($colgrant) && !$anycolumn && !$newdb) {
1322 $colgrant_cnt = count($colgrant);
1323 for ($i = 0; $i < $colgrant_cnt; $i++
) {
1324 if (get_magic_quotes_gpc()) {
1325 $colgrant[$i] = stripslashes($colgrant[$i]);
1327 $col_list .= (empty($col_list) ?
PMA_backquote($colgrant[$i]) : ', ' . PMA_backquote($colgrant[$i]));
1330 $col_list = ' (' . $col_list . ')';
1333 $list_priv = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Reload',
1334 'Shutdown', 'Process', 'File', 'References', 'Index', 'Alter');
1335 for ($i = 0; $i < 13; $i++
) {
1336 $priv_name = $list_priv[$i] . '_priv';
1337 if (isset($
$priv_name)) {
1338 $sql_query .= (empty($sql_query) ?
$list_priv[$i] : ', ' . $list_priv[$i]) . $col_list;
1342 if (empty($sql_query)) {
1343 $sql_query = 'USAGE' . $col_list;
1345 $priv_grant = 'Grant_priv';
1346 $priv_grant = (isset($
$priv_grant) ?
' WITH GRANT OPTION' : '');
1348 if (get_magic_quotes_gpc()) {
1350 $newdb = stripslashes($newdb);
1352 if (isset($dbgrant) && !$anydb && !$newdb) {
1353 $dbgrant = stripslashes($dbgrant);
1355 if (isset($tablegrant) && !$anytable && !$newdb) {
1356 $tablegrant = stripslashes($tablegrant);
1361 // Escape wilcard characters if required
1362 if (isset($dbgrant) && !$anydb && !$newdb) {
1363 $re = '(^|(\\\\\\\\)+|[^\])(_|%)'; // non-escaped wildcards
1364 $dbgrant = ereg_replace($re, '\\1\\\\3', $dbgrant);
1368 $sql_query .= ' ON '
1369 . (($anydb ||
$dbgrant == '') ?
'*' : PMA_backquote($dbgrant))
1371 . (($anytable ||
$tablegrant == '') ?
'*' : PMA_backquote($tablegrant));
1373 $sql_query .= ' ON ' . PMA_backquote($newdb) . '.*';
1376 $sql_query .= ' TO ' . '\'' . PMA_sqlAddslashes($pma_user) . '\'' . '@' . '\'' . PMA_sqlAddslashes($host) . '\'';
1378 $sql_query = 'GRANT ' . $sql_query . $priv_grant;
1379 $result = @PMA_mysql_query
($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url . '&host=' . urlencode($host) . '&pma_user=' . urlencode($pma_user) . '&grants=1');
1380 PMA_showMessage($strAddPrivMessage . '.<br />' . $strRememberReload);
1389 // Edit an user properies
1390 if (isset($edit) && $edit) {
1391 PMA_tableUsers($host, $pma_user);
1392 PMA_editOperations($host, $pma_user);
1395 // Revoke/Grant privileges for an user
1396 else if (isset($grants) && $grants) {
1397 // Displays the full list of privileges for this host & user
1398 $infos['Host'] = $host;
1399 $infos['User'] = $pma_user;
1400 PMA_tableGrants($infos);
1402 // Displays the list of privileges for user on the selected db/table/column
1403 $user_priv = array();
1404 $list_priv = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Reload',
1405 'Shutdown', 'Process', 'File', 'Grant', 'References', 'Index',
1407 $list_priv_new = array();
1409 // Gets globals privileges
1410 $result = PMA_mysql_query('SELECT * FROM mysql.user WHERE (Host = \'' . PMA_sqlAddslashes($host) . '\' OR Host = \'%\') AND (User = \'' . PMA_sqlAddslashes($pma_user) . '\' OR User = \'\')');
1411 $row = ($result) ? @PMA_mysql_fetch_array
($result) : FALSE;
1413 while (list(,$priv) = each($list_priv)) {
1414 $priv_priv = $priv . '_priv';
1415 if ($row[$priv_priv] == 'Y') {
1416 $user_priv[$priv_priv] = 'Y';
1418 $user_priv[$priv_priv] = 'N';
1419 $list_priv_new[] = $priv;
1422 mysql_free_result($result);
1423 $list_priv = $list_priv_new;
1424 unset($list_priv_new);
1425 $list_priv_new = array();
1428 // If a target database is set, gets privileges for this database
1429 if (count($list_priv) && isset($dbgrant)) {
1430 if (get_magic_quotes_gpc()) {
1431 $dbgrant = stripslashes($dbgrant);
1433 $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) . '\'');
1434 $row = ($result) ? @PMA_mysql_fetch_array
($result) : FALSE;
1436 while (list(,$priv) = each($list_priv)) {
1437 $priv_priv = $priv . '_priv';
1438 if (isset($row[$priv_priv]) && $row[$priv_priv] == 'Y') {
1439 $user_priv[$priv_priv] = 'Y';
1441 $list_priv_new[] = $priv;
1444 mysql_free_result($result);
1445 $list_priv = $list_priv_new;
1446 unset($list_priv_new);
1447 $list_priv_new = array();
1451 // If a target table is set, gets privileges for this table
1452 if (count($list_priv) && isset($tablegrant)) {
1453 if (get_magic_quotes_gpc()) {
1454 $tablegrant = stripslashes($tablegrant);
1456 $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) . '\'');
1457 $row = ($result) ? @PMA_mysql_fetch_array
($result) : FALSE;
1458 if ($row && $row['Table_priv']) {
1459 while (list(,$priv) = each($list_priv)) {
1460 $priv_priv = $priv . '_priv';
1461 if (eregi('(^|,)' . $priv . '(,|$)', $row['Table_priv'])) {
1462 $user_priv[$priv_priv] = 'Y';
1464 $list_priv_new[] = $priv;
1467 mysql_free_result($result);
1468 $list_priv = $list_priv_new;
1469 unset($list_priv_new);
1470 $list_priv_new = array();
1474 // TODO: column privileges
1476 PMA_grantOperations($user_priv);
1479 // Check database privileges
1480 else if (isset($check) && $check) {
1485 <a href
="user_details.php3?lang=<?php echo $lang;?>&convcharset=<?php echo $convcharset; ?>&server=<?php echo $server; ?>&db=mysql&table=user">
1486 <?php
echo $strBack; ?
></a
>
1493 // Displays all users profiles
1495 if (!isset($host)) {
1498 if (!isset($pma_user)) {
1501 PMA_tableUsers($host, $pma_user) or PMA_mysqlDie($strNoUsersFound, '', FALSE, '');
1502 PMA_normalOperations();
1507 * Displays the footer
1509 require('./footer.inc.php3');