Documentation TYPO3 par Ameos

server_privileges.php

00001 <?php
00002 /* $Id: server_privileges.php,v 2.4 2003/11/26 22:52:24 rabus Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00005 
00009 $js_to_run = 'server_privileges.js';
00010 require('./server_common.inc.php');
00011 
00012 
00016 if (!empty($pred_dbname)) {
00017     $dbname = $pred_dbname;
00018     unset($pred_dbname);
00019 }
00020 if (!empty($pred_tablename)) {
00021     $tablename = $pred_tablename;
00022     unset($pred_tablename);
00023 }
00024 
00025 
00029 if (!$is_superuser) {
00030     require('./server_links.inc.php');
00031     echo '<h2>' . "\n"
00032        . '    ' . $strPrivileges . "\n"
00033        . '</h2>' . "\n"
00034        . $strNoPrivileges . "\n";
00035     require_once('./footer.inc.php');
00036 }
00037 
00038 
00049 function PMA_extractPrivInfo($row = '', $enableHTML = FALSE)
00050 {
00051     global $userlink;
00052 
00053     $grants = array(
00054         array('Select_priv', 'SELECT', $GLOBALS['strPrivDescSelect']),
00055         array('Insert_priv', 'INSERT', $GLOBALS['strPrivDescInsert']),
00056         array('Update_priv', 'UPDATE', $GLOBALS['strPrivDescUpdate']),
00057         array('Delete_priv', 'DELETE', $GLOBALS['strPrivDescDelete']),
00058         array('Create_priv', 'CREATE', $GLOBALS['strPrivDescCreateDb']),
00059         array('Drop_priv', 'DROP', $GLOBALS['strPrivDescDropDb']),
00060         array('Reload_priv', 'RELOAD', $GLOBALS['strPrivDescReload']),
00061         array('Shutdown_priv', 'SHUTDOWN', $GLOBALS['strPrivDescShutdown']),
00062         array('Process_priv', 'PROCESS', $GLOBALS['strPrivDescProcess' . ((!empty($row) && isset($row['Super_priv'])) || (empty($row) && isset($GLOBALS['Super_priv'])) ? '4' : '3')]),
00063         array('File_priv', 'FILE', $GLOBALS['strPrivDescFile']),
00064         array('References_priv', 'REFERENCES', $GLOBALS['strPrivDescReferences']),
00065         array('Index_priv', 'INDEX', $GLOBALS['strPrivDescIndex']),
00066         array('Alter_priv', 'ALTER', $GLOBALS['strPrivDescAlter']),
00067         array('Show_db_priv', 'SHOW DATABASES', $GLOBALS['strPrivDescShowDb']),
00068         array('Super_priv', 'SUPER', $GLOBALS['strPrivDescSuper']),
00069         array('Create_tmp_table_priv', 'CREATE TEMPORARY TABLES', $GLOBALS['strPrivDescCreateTmpTable']),
00070         array('Lock_tables_priv', 'LOCK TABLES', $GLOBALS['strPrivDescLockTables']),
00071         array('Execute_priv', 'EXECUTE', $GLOBALS['strPrivDescExecute']),
00072         array('Repl_slave_priv', 'REPLICATION SLAVE', $GLOBALS['strPrivDescReplSlave']),
00073         array('Repl_client_priv', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient'])
00074     );
00075     if (!empty($row) && isset($row['Table_priv'])) {
00076         $sql_query = 'SHOW COLUMNS FROM `tables_priv` LIKE "Table_priv";';
00077         $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
00078         unset($sql_query);
00079         $row1 = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
00080         mysql_free_result($res);
00081         $av_grants = explode ('\',\'' , substr($row1['Type'], 5, strlen($row1['Type']) - 7));
00082         unset($row1);
00083         $users_grants = explode(',', $row['Table_priv']);
00084         foreach ($av_grants as $current_grant) {
00085             $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';
00086         }
00087         unset($current_grant);
00088         unset($av_grants);
00089         unset($users_grants);
00090     }
00091     $privs = array();
00092     $allPrivileges = TRUE;
00093     foreach ($grants as $current_grant) {
00094         if ((!empty($row) && isset($row[$current_grant[0]])) || (empty($row) && isset($GLOBALS[$current_grant[0]]))) {
00095             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']))))) {
00096                 if ($enableHTML) {
00097                     $privs[] = '<dfn title="' . $current_grant[2] . '">' . str_replace(' ', '&nbsp;', $current_grant[1]) . '</dfn>';
00098                 } else {
00099                     $privs[] = $current_grant[1];
00100                 }
00101             } else if (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) {
00102                 if ($enableHTML) {
00103                     $priv_string = '<dfn title="' . $current_grant[2] . '">' . str_replace(' ', '&nbsp;', $current_grant[1]) . '</dfn>';
00104                 } else {
00105                     $priv_string = $current_grant[1];
00106                 }
00107                 $privs[] = $priv_string . ' (`' . join('`, `', $GLOBALS[$current_grant[0]]) . '`)';
00108             } else {
00109                 $allPrivileges = FALSE;
00110             }
00111         }
00112     }
00113     if (empty($privs)) {
00114         if ($enableHTML) {
00115             $privs[] = '<dfn title="' . $GLOBALS['strPrivDescUsage'] . '">USAGE</dfn>';
00116         } else {
00117             $privs[] = 'USAGE';
00118         }
00119     } else if ($allPrivileges && (!isset($GLOBALS['grant_count']) || count($privs) == $GLOBALS['grant_count'])) {
00120         if ($enableHTML) {
00121             $privs = array('<dfn title="' . $GLOBALS['strPrivDescAllPrivileges'] . '">ALL&nbsp;PRIVILEGES</dfn>');
00122         } else {
00123             $privs = array('ALL PRIVILEGES');
00124         }
00125     }
00126     return $privs;
00127 } // end of the 'PMA_extractPrivInfo()' function
00128 
00142 function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = 0)
00143 {
00144     global $cfg, $userlink;
00145 
00146     if ($db == '*') {
00147         $table = '*';
00148     }
00149     $spaces = '';
00150     for ($i = 0; $i < $indent; $i++) {
00151         $spaces .= '    ';
00152     }
00153     if (isset($GLOBALS['username'])) {
00154         $username = $GLOBALS['username'];
00155         $hostname = $GLOBALS['hostname'];
00156         if ($db == '*') {
00157             $sql_query = 'SELECT * FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";';
00158         } else if ($table == '*') {
00159             $sql_query = 'SELECT * FROM `db` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '";';
00160         } else {
00161             $sql_query = 'SELECT `Table_priv` FROM `tables_priv` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '" AND `Table_name` = "' . $table . '";';
00162         }
00163         $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
00164         if ($res) {
00165             $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
00166         }
00167         @mysql_free_result($res);
00168     }
00169     if (empty($row)) {
00170         if ($table == '*') {
00171             if ($db == '*') {
00172                 $sql_query = 'SHOW COLUMNS FROM `mysql`.`user`;';
00173             } else if ($table == '*') {
00174                 $sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;';
00175             }
00176             $res = PMA_mysql_query($sql_query, $userlink)
00177                 or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
00178             while ($row1 = PMA_mysql_fetch_row($res)) {
00179                 if (substr($row1[0], 0, 4) == 'max_') {
00180                     $row[$row1[0]] = 0;
00181                 } else {
00182                     $row[$row1[0]] = 'N';
00183                 }
00184             }
00185             mysql_free_result($res);
00186         } else {
00187             $row = array('Table_priv' => '');
00188         }
00189     }
00190     if (isset($row['Table_priv'])) {
00191         $sql_query = 'SHOW COLUMNS FROM `tables_priv` LIKE "Table_priv";';
00192         $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
00193         unset($sql_query);
00194         $row1 = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
00195         mysql_free_result($res);
00196         $av_grants = explode ('\',\'' , substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3));
00197         unset($row1);
00198         $users_grants = explode(',', $row['Table_priv']);
00199         foreach ($av_grants as $current_grant) {
00200             $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';
00201         }
00202         unset($row['Table_priv']);
00203         unset($current_grant);
00204         unset($av_grants);
00205         unset($users_grants);
00206         if ($res = PMA_mysql_query('SHOW COLUMNS FROM `' . $db . '`.`' . $table . '`;', $userlink)) {
00207             $columns = array();
00208             while ($row1 = PMA_mysql_fetch_row($res)) {
00209                 $columns[$row1[0]] = array(
00210                     'Select' => FALSE,
00211                     'Insert' => FALSE,
00212                     'Update' => FALSE,
00213                     'References' => FALSE
00214                 );
00215             }
00216             mysql_free_result($res);
00217             unset($res);
00218             unset($row1);
00219         }
00220     }
00221     if (!empty($columns)) {
00222         $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 . '";';
00223         $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
00224         while ($row1 = PMA_mysql_fetch_row($res)) {
00225             $row1[1] = explode(',', $row1[1]);
00226             foreach ($row1[1] as $current) {
00227                 $columns[$row1[0]][$current] = TRUE;
00228             }
00229         }
00230         mysql_free_result($res);
00231         unset($res);
00232         unset($row1);
00233         unset($current);
00234         echo $spaces . '<input type="hidden" name="grant_count" value="' . count($row) . '" />' . "\n"
00235            . $spaces . '<input type="hidden" name="column_count" value="' . count($columns) . '" />' . "\n"
00236            . $spaces . '<table border="0">' . "\n"
00237            . $spaces . '    <tr>' . "\n"
00238            . $spaces . '        <th colspan="6">&nbsp;' . $GLOBALS['strTblPrivileges'] . '&nbsp;</th>' . "\n"
00239            . $spaces . '    </tr>' . "\n"
00240            . $spaces . '    <tr>' . "\n"
00241            . $spaces . '        <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="6"><small><i>' . $GLOBALS['strEnglishPrivileges'] . '</i></small></td>' . "\n"
00242            . $spaces . '    </tr>' . "\n"
00243            . $spaces . '    <tr>' . "\n"
00244            . $spaces . '        <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescSelect'] . '">SELECT</dfn></tt>&nbsp;</td>' . "\n"
00245            . $spaces . '        <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescInsert'] . '">INSERT</dfn></tt>&nbsp;</td>' . "\n"
00246            . $spaces . '        <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescUpdate'] . '">UPDATE</dfn></tt>&nbsp;</td>' . "\n"
00247            . $spaces . '        <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescReferences'] . '">REFERENCES</dfn></tt>&nbsp;</td>' . "\n";
00248         list($current_grant, $current_grant_value) = each($row);
00249         while (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) {
00250             list($current_grant, $current_grant_value) = each($row);
00251         }
00252         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"
00253            . $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"
00254            . $spaces . '    </tr>' . "\n"
00255            . $spaces . '    <tr>' . "\n";
00256         $rowspan = count($row) - 5;
00257         echo $spaces . '        <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
00258            . $spaces . '            <select name="Select_priv[]" multiple="multiple">' . "\n";
00259         foreach ($columns as $current_column => $current_column_privileges) {
00260             echo $spaces . '                <option value="' . htmlspecialchars($current_column) . '"';
00261             if ($row['Select_priv'] == 'Y' || $current_column_privileges['Select']) {
00262                 echo ' selected="selected"';
00263             }
00264             echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
00265         }
00266         echo $spaces . '            </select><br />' . "\n"
00267            . $spaces . '            <i>' . $GLOBALS['strOr'] . '</i><br />' . "\n"
00268            . $spaces . '            <input type="checkbox" name="Select_priv_none" id="checkbox_Select_priv_none" title="' . $GLOBALS['strNone'] . '" />' . "\n"
00269            . $spaces . '            <label for="checkbox_Select_priv_none">' . $GLOBALS['strNone'] . '</label>' . "\n"
00270            . $spaces . '        </td>' . "\n"
00271            . $spaces . '        <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
00272            . $spaces . '            <select name="Insert_priv[]" multiple="multiple">' . "\n";
00273         foreach ($columns as $current_column => $current_column_privileges) {
00274             echo $spaces . '                <option value="' . htmlspecialchars($current_column) . '"';
00275             if ($row['Insert_priv'] == 'Y' || $current_column_privileges['Insert']) {
00276                 echo ' selected="selected"';
00277             }
00278             echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
00279         }
00280         echo $spaces . '            </select><br />' . "\n"
00281            . $spaces . '            <i>' . $GLOBALS['strOr'] . '</i><br />' . "\n"
00282            . $spaces . '            <input type="checkbox" name="Insert_priv_none" id="checkbox_Insert_priv_none" title="' . $GLOBALS['strNone'] . '" />' . "\n"
00283            . $spaces . '            <label for="checkbox_Insert_priv_none">' . $GLOBALS['strNone'] . '</label>' . "\n"
00284            . $spaces . '        </td>' . "\n"
00285            . $spaces . '        <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
00286            . $spaces . '            <select name="Update_priv[]" multiple="multiple">' . "\n";
00287         foreach ($columns as $current_column => $current_column_privileges) {
00288             echo $spaces . '                <option value="' . htmlspecialchars($current_column) . '"';
00289             if ($row['Update_priv'] == 'Y' || $current_column_privileges['Update']) {
00290                 echo ' selected="selected"';
00291             }
00292             echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
00293         }
00294         echo $spaces . '            </select><br />' . "\n"
00295            . $spaces . '            <i>' . $GLOBALS['strOr'] . '</i><br />' . "\n"
00296            . $spaces . '            <input type="checkbox" name="Update_priv_none" id="checkbox_Update_priv_none" title="' . $GLOBALS['strNone'] . '" />' . "\n"
00297            . $spaces . '            <label for="checkbox_Update_priv_none">' . $GLOBALS['strNone'] . '</label>' . "\n"
00298            . $spaces . '        </td>' . "\n"
00299            . $spaces . '        <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
00300            . $spaces . '            <select name="References_priv[]" multiple="multiple">' . "\n";
00301         foreach ($columns as $current_column => $current_column_privileges) {
00302             echo $spaces . '                <option value="' . htmlspecialchars($current_column) . '"';
00303             if ($row['References_priv'] == 'Y' || $current_column_privileges['References']) {
00304                 echo ' selected="selected"';
00305             }
00306             echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
00307         }
00308         echo $spaces . '            </select><br />' . "\n"
00309            . $spaces . '            <i>' . $GLOBALS['strOr'] . '</i><br />' . "\n"
00310            . $spaces . '            <input type="checkbox" name="References_priv_none" id="checkbox_References_priv_none" title="' . $GLOBALS['strNone'] . '" />' . "\n"
00311            . $spaces . '            <label for="checkbox_References_priv_none">' . $GLOBALS['strNone'] . '</label>' . "\n"
00312            . $spaces . '        </td>' . "\n";
00313         unset($rowspan);
00314         list($current_grant, $current_grant_value) = each($row);
00315         while (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) {
00316             list($current_grant, $current_grant_value) = each($row);
00317         }
00318         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"
00319            . $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"
00320            . $spaces . '    </tr>' . "\n";
00321         while (list($current_grant, $current_grant_value) = each($row)) {
00322             if (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) {
00323                 continue;
00324             }
00325             echo $spaces . '    <tr>' . "\n"
00326                . $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"
00327                . $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"
00328                . $spaces . '    </tr>' . "\n";
00329         }
00330     } else {
00331         $privTable[0] = array(
00332             array('Select', 'SELECT', $GLOBALS['strPrivDescSelect']),
00333             array('Insert', 'INSERT', $GLOBALS['strPrivDescInsert']),
00334             array('Update', 'UPDATE', $GLOBALS['strPrivDescUpdate']),
00335             array('Delete', 'DELETE', $GLOBALS['strPrivDescDelete'])
00336         );
00337         if ($db == '*') {
00338             $privTable[0][] = array('File', 'FILE', $GLOBALS['strPrivDescFile']);
00339         }
00340         $privTable[1] = array(
00341             array('Create', 'CREATE', ($table == '*' ? $GLOBALS['strPrivDescCreateDb'] : $GLOBALS['strPrivDescCreateTbl'])),
00342             array('Alter', 'ALTER', $GLOBALS['strPrivDescAlter']),
00343             array('Index', 'INDEX', $GLOBALS['strPrivDescIndex']),
00344             array('Drop', 'DROP', ($table == '*' ? $GLOBALS['strPrivDescDropDb'] : $GLOBALS['strPrivDescDropTbl']))
00345         );
00346         if (isset($row['Create_tmp_table_priv'])) {
00347             $privTable[1][] = array('Create_tmp_table', 'CREATE&nbsp;TEMPORARY&nbsp;TABLES', $GLOBALS['strPrivDescCreateTmpTable']);
00348         }
00349         $privTable[2] = array();
00350         if (isset($row['Grant_priv'])) {
00351             $privTable[2][] = array('Grant', 'GRANT', $GLOBALS['strPrivDescGrant']);
00352         }
00353         if ($db == '*') {
00354             if (isset($row['Super_priv'])) {
00355                 $privTable[2][] = array('Super', 'SUPER', $GLOBALS['strPrivDescSuper']);
00356                 $privTable[2][] = array('Process', 'PROCESS', $GLOBALS['strPrivDescProcess4']);
00357             } else {
00358                 $privTable[2][] = array('Process', 'PROCESS', $GLOBALS['strPrivDescProcess3']);
00359             }
00360             $privTable[2][] = array('Reload', 'RELOAD', $GLOBALS['strPrivDescReload']);
00361             $privTable[2][] = array('Shutdown', 'SHUTDOWN', $GLOBALS['strPrivDescShutdown']);
00362             if (isset($row['Show_db_priv'])) {
00363                 $privTable[2][] = array('Show_db', 'SHOW&nbsp;DATABASES', $GLOBALS['strPrivDescShowDb']);
00364             }
00365         }
00366         if (isset($row['Lock_tables_priv'])) {
00367             $privTable[2][] = array('Lock_tables', 'LOCK&nbsp;TABLES', $GLOBALS['strPrivDescLockTables']);
00368         }
00369         $privTable[2][] = array('References', 'REFERENCES', $GLOBALS['strPrivDescReferences']);
00370         if ($db == '*') {
00371             if (isset($row['Execute_priv'])) {
00372                 $privTable[2][] = array('Execute', 'EXECUTE', $GLOBALS['strPrivDescExecute']);
00373             }
00374             if (isset($row['Repl_client_priv'])) {
00375                 $privTable[2][] = array('Repl_client', 'REPLICATION&nbsp;CLIENT', $GLOBALS['strPrivDescReplClient']);
00376             }
00377             if (isset($row['Repl_slave_priv'])) {
00378                 $privTable[2][] = array('Repl_slave', 'REPLICATION&nbsp;SLAVE', $GLOBALS['strPrivDescReplSlave']);
00379             }
00380         }
00381         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"
00382            . $spaces . '<table border="0">' . "\n"
00383            . $spaces . '    <tr>' . "\n"
00384            . $spaces . '        <th colspan="6">&nbsp;' . ($db == '*' ? $GLOBALS['strGlobalPrivileges'] : ($table == '*' ? $GLOBALS['strDbPrivileges'] : $GLOBALS['strTblPrivileges'])) . '&nbsp;</th>' . "\n"
00385            . $spaces . '    </tr>' . "\n"
00386            . $spaces . '    <tr>' . "\n"
00387            . $spaces . '        <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="6"><small><i>' . $GLOBALS['strEnglishPrivileges'] . '</i></small></td>' . "\n"
00388            . $spaces . '    </tr>' . "\n"
00389            . $spaces . '    <tr>' . "\n"
00390            . $spaces . '        <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2">&nbsp;<b><i>' . $GLOBALS['strData'] . '</i></b>&nbsp;</td>' . "\n"
00391            . $spaces . '        <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2">&nbsp;<b><i>' . $GLOBALS['strStructure'] . '</i></b>&nbsp;</td>' . "\n"
00392            . $spaces . '        <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2">&nbsp;<b><i>' . $GLOBALS['strAdministration'] . '</i></b>&nbsp;</td>' . "\n"
00393            . $spaces . '    </tr>' . "\n";
00394         $limitTable = FALSE;
00395         for ($i = 0; isset($privTable[0][$i]) || isset($privTable[1][$i]) || isset($privTable[2][$i]); $i++) {
00396             echo $spaces . '    <tr>' . "\n";
00397             for ($j = 0; $j < 3; $j++) {
00398                 if (isset($privTable[$j][$i])) {
00399                     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"
00400                        . $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";
00401                 } else if ($db == '*' && !isset($privTable[0][$i]) && !isset($privTable[1][$i])
00402                     && isset($row['max_questions']) && isset($row['max_updates']) && isset($row['max_connections'])
00403                     && !$limitTable) {
00404                     echo $spaces . '        <td colspan="4" rowspan="' . (count($privTable[2]) - $i) . '">' . "\n"
00405                        . $spaces . '            <table border="0">' . "\n"
00406                        . $spaces . '                <tr>' . "\n"
00407                        . $spaces . '                    <th colspan="2">&nbsp;' . $GLOBALS['strResourceLimits'] . '&nbsp;</th>' . "\n"
00408                        . $spaces . '                </tr>' . "\n"
00409                        . $spaces . '                <tr>' . "\n"
00410                        . $spaces . '                    <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="2"><small><i>' . $GLOBALS['strZeroRemovesTheLimit'] . '</i></small></td>' . "\n"
00411                        . $spaces . '                </tr>' . "\n"
00412                        . $spaces . '                <tr>' . "\n"
00413                        . $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"
00414                        . $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"
00415                        . $spaces . '                </tr>' . "\n"
00416                        . $spaces . '                <tr>' . "\n"
00417                        . $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"
00418                        . $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"
00419                        . $spaces . '                </tr>' . "\n"
00420                        . $spaces . '                <tr>' . "\n"
00421                        . $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"
00422                        . $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"
00423                        . $spaces . '                </tr>' . "\n"
00424                        . $spaces . '            </table>' . "\n"
00425                        . $spaces . '        </td>' . "\n";
00426                     $limitTable = TRUE;
00427                 } else if (!$limitTable) {
00428                     echo $spaces . '        <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="2">&nbsp;</td>' . "\n";
00429                 }
00430             }
00431         }
00432         echo $spaces . '    </tr>' . "\n";
00433     }
00434     if ($submit) {
00435         echo $spaces . '    <tr>' . "\n"
00436            . $spaces . '        <td colspan="6" align="center">' . "\n"
00437            . $spaces . '            <input type="submit" name="update_privs" value="' . $GLOBALS['strGo'] . '" />' . "\n"
00438            . $spaces . '        </td>' . "\n"
00439            . $spaces . '    </tr>' . "\n";
00440     }
00441     echo $spaces . '</table>' . "\n";
00442 } // end of the 'PMA_displayPrivTable()' function
00443 
00444 
00458 function PMA_displayLoginInformationFields($mode = 'new', $indent = 0)
00459 {
00460     global $cfg, $userlink;
00461     $spaces = '';
00462     for ($i = 0; $i < $indent; $i++) {
00463         $spaces .= '    ';
00464     }
00465     echo $spaces . '<tr>' . "\n"
00466        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00467        . $spaces . '        <label for="select_pred_username">' . "\n"
00468        . $spaces . '            ' . $GLOBALS['strUserName'] . ':' . "\n"
00469        . $spaces . '        </label>' . "\n"
00470        . $spaces . '    </td>' . "\n"
00471        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00472        . $spaces . '        <select name="pred_username" id="select_pred_username" title="' . $GLOBALS['strUserName'] . '"' . "\n"
00473        . $spaces . '            onchange="if (this.value == \'any\') { username.value = \'\'; } else if (this.value == \'userdefined\') { username.focus(); username.select(); }">' . "\n"
00474        . $spaces . '            <option value="any"' . ((isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any') ? ' selected="selected"' : '') . '>' . $GLOBALS['strAnyUser'] . '</option>' . "\n"
00475        . $spaces . '            <option value="userdefined"' . ((!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined') ? ' selected="selected"' : '') . '>' . $GLOBALS['strUseTextField'] . ':</option>' . "\n"
00476        . $spaces . '        </select>' . "\n"
00477        . $spaces . '    </td>' . "\n"
00478        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00479        . $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"
00480        . $spaces . '    </td>' . "\n"
00481        . $spaces . '</tr>' . "\n"
00482        . $spaces . '<tr>' . "\n"
00483        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00484        . $spaces . '        <label for="select_pred_hostname">' . "\n"
00485        . $spaces . '            ' . $GLOBALS['strHost'] . ':' . "\n"
00486        . $spaces . '        </label>' . "\n"
00487        . $spaces . '    </td>' . "\n"
00488        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00489        . $spaces . '        <select name="pred_hostname" id="select_pred_hostname" title="' . $GLOBALS['strHost'] . '"' . "\n";
00490     $res = PMA_mysql_query('SELECT USER();', $userlink);
00491     $row = @PMA_mysql_fetch_row($res);
00492     @mysql_free_result($res);
00493     unset($res);
00494     if (!empty($row[0])) {
00495         $thishost = str_replace("'", '', substr($row[0], (strrpos($row[0], '@') + 1)));
00496         if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
00497             unset($thishost);
00498         }
00499     }
00500     echo $spaces . '            onchange="if (this.value == \'any\') { hostname.value = \'%\'; } else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } '
00501        . (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; } ')
00502        . 'else if (this.value == \'hosttable\') { hostname.value = \'\'; } else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n";
00503     unset($row);
00504     echo $spaces . '            <option value="any"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any') ? ' selected="selected"' : '') . '>' . $GLOBALS['strAnyHost'] . '</option>' . "\n"
00505        . $spaces . '            <option value="localhost"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost') ? ' selected="selected"' : '') . '>' . $GLOBALS['strLocalhost'] . '</option>' . "\n";
00506     if (!empty($thishost)) {
00507         echo $spaces . '            <option value="thishost"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'thishost') ? ' selected="selected"' : '') . '>' . $GLOBALS['strThisHost'] . '</option>' . "\n";
00508     }
00509     unset($thishost);
00510     echo $spaces . '            <option value="hosttable"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable') ? ' selected="selected"' : '') . '>' . $GLOBALS['strUseHostTable'] . '</option>' . "\n"
00511        . $spaces . '            <option value="userdefined"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined') ? ' selected="selected"' : '') . '>' . $GLOBALS['strUseTextField'] . ':</option>' . "\n"
00512        . $spaces . '        </select>' . "\n"
00513        . $spaces . '    </td>' . "\n"
00514        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00515        . $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"
00516        . $spaces . '    </td>' . "\n"
00517        . $spaces . '</tr>' . "\n"
00518        . $spaces . '<tr>' . "\n"
00519        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00520        . $spaces . '        <label for="select_pred_password">' . "\n"
00521        . $spaces . '            ' . $GLOBALS['strPassword'] . ':' . "\n"
00522        . $spaces . '        </label>' . "\n"
00523        . $spaces . '    </td>' . "\n"
00524        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00525        . $spaces . '        <select name="pred_password" id="select_pred_password" title="' . $GLOBALS['strPassword'] . '"' . "\n"
00526        . $spaces . '            onchange="if (this.value == \'none\') { pma_pw.value = \'\'; pma_pw2.value = \'\'; } else if (this.value == \'userdefined\') { pma_pw.focus(); pma_pw.select(); }">' . "\n"
00527        . ($mode == 'change' ? $spaces . '            <option value="keep" selected="selected">' . $GLOBALS['strKeepPass'] . '</option>' . "\n" : '')
00528        . $spaces . '            <option value="none">' . $GLOBALS['strNoPassword'] . '</option>' . "\n"
00529        . $spaces . '            <option value="userdefined"' . ($mode == 'change' ? '' : ' selected="selected"') . '>' . $GLOBALS['strUseTextField'] . ':</option>' . "\n"
00530        . $spaces . '        </select>' . "\n"
00531        . $spaces . '    </td>' . "\n"
00532        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00533        . $spaces . '        <input type="password" name="pma_pw" class="textfield" title="' . $GLOBALS['strPassword'] . '" onchange="pred_password.value = \'userdefined\';" />' . "\n"
00534        . $spaces . '    </td>' . "\n"
00535        . $spaces . '</tr>' . "\n"
00536        . $spaces . '<tr>' . "\n"
00537        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00538        . $spaces . '        <label for="text_pma_pw2">' . "\n"
00539        . $spaces . '            ' . $GLOBALS['strReType'] . ':' . "\n"
00540        . $spaces . '        </label>' . "\n"
00541        . $spaces . '    </td>' . "\n"
00542        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">&nbsp;</td>' . "\n"
00543        . $spaces . '    <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
00544        . $spaces . '        <input type="password" name="pma_pw2" id="text_pma_pw2" class="textfield" title="' . $GLOBALS['strReType'] . '" onchange="pred_password.value = \'userdefined\';" />' . "\n"
00545        . $spaces . '    </td>' . "\n"
00546        . $spaces . '</tr>' . "\n";
00547 } // end of the 'PMA_displayUserAndHostFields()' function
00548 
00549 
00553 if (!empty($change_copy)) {
00554     $local_query = 'SELECT * FROM `mysql`.`user` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";';
00555     $res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
00556     if (!$res) {
00557         $message = $strNoUsersFound;
00558         unset($change_copy);
00559     } else {
00560         $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
00561         extract($row, EXTR_OVERWRITE);
00562         mysql_free_result($res);
00563         $queries = array();
00564     }
00565 }
00566 
00567 
00572 if (!empty($adduser_submit) || !empty($change_copy)) {
00573     unset($sql_query);
00574     if ($pred_username == 'any') {
00575         $username = '';
00576     }
00577     switch ($pred_hostname) {
00578         case 'any':
00579             $hostname = '%';
00580             break;
00581         case 'localhost':
00582             $hostname = 'localhost';
00583             break;
00584         case 'hosttable':
00585             $hostname = '';
00586             break;
00587         case 'thishost':
00588             $res = PMA_mysql_query('SELECT USER();', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SELECT USER();');
00589             $row = PMA_mysql_fetch_row($res);
00590             mysql_free_result($res);
00591             unset($res);
00592             $hostname = substr($row[0], (strrpos($row[0], '@') + 1));
00593             unset($row);
00594             break;
00595     }
00596     $local_query = 'SELECT "foo" FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";';
00597     $res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
00598     unset($local_query);
00599     if (mysql_affected_rows($userlink) == 1) {
00600         $message = sprintf($strUserAlreadyExists, '<i>\'' . $username . '\'@\'' . $hostname . '\'</i>');
00601         $adduser = 1;
00602     } else {
00603         $real_sql_query = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON *.* TO "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '"';
00604         if ($pred_password != 'none' && $pred_password != 'keep') {
00605             $pma_pw_hidden = '';
00606             for ($i = 0; $i < strlen($pma_pw); $i++) {
00607                 $pma_pw_hidden .= '*';
00608             }
00609             $sql_query = $real_sql_query . ' IDENTIFIED BY "' . $pma_pw_hidden . '"';
00610             $real_sql_query .= ' IDENTIFIED BY "' . $pma_pw . '"';
00611         } else {
00612             if ($pred_password == 'keep' && !empty($password)) {
00613                 $real_sql_query .= ' IDENTIFIED BY PASSWORD "' . $password . '"';
00614             }
00615             $sql_query = $real_sql_query;
00616         }
00617         if ((isset($Grant_priv) && $Grant_priv == 'Y') || (PMA_MYSQL_INT_VERSION >= 40002 && (isset($max_questions) || isset($max_connections) || isset($max_updates)))) {
00618             $real_sql_query .= 'WITH';
00619             $sql_query .= 'WITH';
00620             if (isset($Grant_priv) && $Grant_priv == 'Y') {
00621                 $real_sql_query .= ' GRANT OPTION';
00622                 $sql_query .= ' GRANT OPTION';
00623             }
00624             if (PMA_MYSQL_INT_VERSION >= 40002) {
00625                 if (isset($max_questions)) {
00626                     $real_sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions;
00627                     $sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions;
00628                 }
00629                 if (isset($max_connections)) {
00630                     $real_sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections;
00631                     $sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections;
00632                 }
00633                 if (isset($max_updates)) {
00634                     $real_sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates;
00635                     $sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates;
00636                 }
00637             }
00638         }
00639         $real_sql_query .= ';';
00640         $sql_query .= ';';
00641         if (empty($change_copy)) {
00642             PMA_mysql_query($real_sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
00643             $message = $strAddUserMessage;
00644         } else {
00645             $queries[] = $sql_query;
00646         }
00647         unset($real_sql_query);
00648         mysql_free_result($res);
00649         unset($res);
00650     }
00651 }
00652 
00653 
00657 if (!empty($change_copy)) {
00658     $local_query = 'SELECT * FROM `mysql`.`db` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";';
00659     $res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
00660     while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
00661         $queries[] = 'GRANT ' . join(', ', PMA_extractPrivInfo($row)) . ' ON `' . $row['Db'] . '`.* TO "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '"' . ($row['Grant_priv'] == 'Y' ? ' WITH GRANT OPTION' : '') . ';';
00662     }
00663     mysql_free_result($res);
00664     $local_query = 'SELECT `Db`, `Table_name`, `Table_priv` FROM `mysql`.`tables_priv` WHERE `User` = "' . PMA_sqlAddslashes($old_username) . '" AND `Host` = "' . $old_hostname . '";';
00665     $res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
00666     while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
00667         $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'] . '";';
00668         $res2 = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
00669         $tmp_privs1 = PMA_extractPrivInfo($row);
00670         $tmp_privs2 = array(
00671             'Select' => array(),
00672             'Insert' => array(),
00673             'Update' => array(),
00674             'References' => array()
00675         );
00676         while ($row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC)) {
00677             $tmp_array = explode(',', $row2['Column_priv']);
00678             if (in_array('Select', $tmp_array)) {
00679                 $tmp_privs2['Select'][] = $row2['Column_name'];
00680             }
00681             if (in_array('Insert', $tmp_array)) {
00682                 $tmp_privs2['Insert'][] = $row2['Column_name'];
00683             }
00684             if (in_array('Update', $tmp_array)) {
00685                 $tmp_privs2['Update'][] = $row2['Column_name'];
00686             }
00687             if (in_array('References', $tmp_array)) {
00688                 $tmp_privs2['References'][] = $row2['Column_name'];
00689             }
00690             unset($tmp_array);
00691         }
00692         if (count($tmp_privs2['Select']) > 0 && !in_array('SELECT', $tmp_privs1)) {
00693             $tmp_privs1[] = 'SELECT (`' . join('`, `', $tmp_privs2['Select']) . '`)';
00694         }
00695         if (count($tmp_privs2['Insert']) > 0 && !in_array('INSERT', $tmp_privs1)) {
00696             $tmp_privs1[] = 'INSERT (`' . join(', ', $tmp_privs2['Insert']) . '`)';
00697         }
00698         if (count($tmp_privs2['Update']) > 0 && !in_array('UPDATE', $tmp_privs1)) {
00699             $tmp_privs1[] = 'UPDATE (`' . join(', ', $tmp_privs2['Update']) . '`)';
00700         }
00701         if (count($tmp_privs2['References']) > 0 && !in_array('REFERENCES', $tmp_privs1)) {
00702             $tmp_privs1[] = 'REFERENCES (`' . join(', ', $tmp_privs2['References']) . '`)';
00703         }
00704         unset($tmp_privs2);
00705         $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' : '') . ';';
00706     }
00707 }
00708 
00709 
00713 if (!empty($update_privs)) {
00714     $db_and_table = empty($dbname) ? '*.*' : PMA_backquote($dbname) . '.' . (empty($tablename) ? '*' : PMA_backquote($tablename));
00715     $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '";';
00716     if (!isset($Grant_priv) || $Grant_priv != 'Y') {
00717         $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '";';
00718     }
00719     $sql_query2 = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON ' . $db_and_table . ' TO "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '"';
00720     if ((isset($Grant_priv) && $Grant_priv == 'Y') || (empty($dbname) && PMA_MYSQL_INT_VERSION >= 40002 && (isset($max_questions) || isset($max_connections) || isset($max_updates)))) {
00721         $sql_query2 .= 'WITH';
00722         if (isset($Grant_priv) && $Grant_priv == 'Y') {
00723             $sql_query2 .= ' GRANT OPTION';
00724         }
00725         if (PMA_MYSQL_INT_VERSION >= 40002) {
00726             if (isset($max_questions)) {
00727                 $sql_query2 .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions;
00728             }
00729             if (isset($max_connections)) {
00730                 $sql_query2 .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections;
00731             }
00732             if (isset($max_updates)) {
00733                 $sql_query2 .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates;
00734             }
00735         }
00736     }
00737     $sql_query2 .= ';';
00738     PMA_mysql_query($sql_query0, $userlink); // this query may fail, but this does not matter :o)
00739     if (isset($sql_query1)) {
00740         PMA_mysql_query($sql_query1, $userlink); // this one may fail, too...
00741     }
00742     PMA_mysql_query($sql_query2, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query2);
00743     $sql_query = $sql_query0 . ' ' . (isset($sql_query1) ? $sql_query1 . ' ' : '') . $sql_query2;
00744     $message = sprintf($strUpdatePrivMessage, '\'' . $username . '\'@\'' . $hostname . '\'');
00745 }
00746 
00747 
00751 if (!empty($revokeall)) {
00752     $db_and_table = PMA_backquote($dbname) . '.' . (empty($tablename) ? '*' : PMA_backquote($tablename));
00753     $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";';
00754     $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";';
00755     PMA_mysql_query($sql_query0, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query0);
00756     PMA_mysql_query($sql_query1, $userlink); // this one may fail, too...
00757     $sql_query = $sql_query0 . ' ' . $sql_query1;
00758     $message = sprintf($strRevokeMessage, '\'' . $username . '\'@\'' . $hostname . '\'');
00759     if (empty($tablename)) {
00760         unset($dbname);
00761     } else {
00762         unset($tablename);
00763     }
00764 }
00765 
00766 
00770 if (!empty($change_pw)) {
00771     if ($nopass == 1) {
00772         $sql_query = 'SET PASSWORD FOR "' . $username . '"@"' . $hostname . '" = ""';
00773         PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
00774         $message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\'');
00775     } else if (empty($pma_pw) || empty($pma_pw2)) {
00776         $message = $strPasswordEmpty;
00777     } else if ($pma_pw != $pma_pw2) {
00778         $message = $strPasswordNotSame;
00779     } else {
00780         $hidden_pw = '';
00781         for ($i = 0; $i < strlen($pma_pw); $i++) {
00782             $hidden_pw .= '*';
00783         }
00784         $local_query = 'SET PASSWORD FOR "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '" = PASSWORD("' . PMA_sqlAddslashes($pma_pw) . '")';
00785         $sql_query = 'SET PASSWORD FOR "' . PMA_sqlAddslashes($username) . '"@"' . $hostname . '" = PASSWORD("' . $hidden_pw . '")';
00786         PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
00787         $message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\'');
00788     }
00789 }
00790 
00791 
00796 if (!empty($delete) || (!empty($change_copy) && $mode < 4)) {
00797     if (!empty($change_copy)) {
00798         $selected_usr = array($old_username . '@' . $old_hostname);
00799     } else {
00800         $queries = array();
00801     }
00802     for ($i = 0; isset($selected_usr[$i]); $i++) {
00803         list($this_user, $this_host) = explode('@', $selected_usr[$i]);
00804         $queries[] = '# ' . sprintf($strDeleting, '\'' . $this_user . '\'@\'' . $this_host . '\'') . ' ...';
00805         if ($mode == 2) {
00806             // The SHOW GRANTS query may fail if the user has not been loaded
00807             // into memory
00808             $res = PMA_mysql_query('SHOW GRANTS FOR "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";', $userlink);
00809             if ($res) {
00810                 $queries[] = 'REVOKE ALL PRIVILEGES ON *.* FROM "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";';
00811                 while ($row = PMA_mysql_fetch_row($res)) {
00812                     $this_table = substr($row[0], (strpos($row[0], 'ON') + 3), (strpos($row[0], ' TO ') - strpos($row[0], 'ON') - 3));
00813                     if ($this_table != '*.*') {
00814                         $queries[] = 'REVOKE ALL PRIVILEGES ON ' . $this_table . ' FROM "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";';
00815 
00816                         if (strpos($row[0], 'WITH GRANT OPTION')) {
00817                             $queries[] = 'REVOKE GRANT OPTION ON ' . $this_table . ' FROM "' . PMA_sqlAddslashes($this_user) . '"@"' . $this_host . '";';
00818                         }
00819                     }
00820                     unset($this_table);
00821                 }
00822                 mysql_free_result($res);
00823             }
00824             unset($res);
00825         }
00826         $queries[] = 'DELETE FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($this_user) . '" AND `Host` = "' . $this_host . '";';
00827         if ($mode != 2) {
00828             // If we REVOKE the table grants, we should not need to modify the
00829             // `db`, `tables_priv` and `columns_priv` tables manually...
00830             $queries[] = 'DELETE FROM `db` WHERE `User` = "' . PMA_sqlAddslashes($this_user) . '" AND `Host` = "' . $this_host . '";';
00831             $queries[] = 'DELETE FROM `tables_priv` WHERE `User` = "' . PMA_sqlAddslashes($this_user) . '" AND `Host` = "' . $this_host . '";';
00832             $queries[] = 'DELETE FROM `columns_priv` WHERE `User` = "' . PMA_sqlAddslashes($this_user) . '" AND `Host` = "' . $this_host . '";';
00833         }
00834         if (!empty($drop_users_db)) {
00835             $queries[] = 'DROP DATABASE IF EXISTS ' . PMA_backquote($this_user) . ';';
00836         }
00837     }
00838     if (empty($change_copy)) {
00839         if (empty($queries)) {
00840             $message = $strError . ': ' . $strDeleteNoUsersSelected;
00841         } else {
00842             if ($mode == 3) {
00843                 $queries[] = '# ' . $strReloadingThePrivileges . ' ...';
00844                 $queries[] = 'FLUSH PRIVILEGES;';
00845             }
00846             foreach ($queries as $sql_query) {
00847                 if ($sql_query{0} != '#') {
00848                     PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
00849                 }
00850             }
00851             $sql_query = join("\n", $queries);
00852             $message = $strUsersDeleted;
00853         }
00854         unset($queries);
00855     }
00856 }
00857 
00858 
00862 if (!empty($change_copy)) {
00863     foreach ($queries as $sql_query) {
00864         if ($sql_query{0} != '#') {
00865             PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
00866         }
00867     }
00868     $message = $strSuccess;
00869     $sql_query = join("\n", $queries);
00870 }
00871 
00872 
00876 if (!empty($flush_privileges)) {
00877     $sql_query = 'FLUSH PRIVILEGES';
00878     if (@PMA_mysql_query($sql_query, $userlink)) {
00879         $message = $strPrivilegesReloaded;
00880     } else {
00881         PMA_mysqlDie(PMA_mysql_error($userlink));
00882     }
00883 }
00884 
00885 
00889 require('./server_links.inc.php');
00890 
00891 
00895 if (empty($adduser) && empty($checkprivs)) {
00896     if (!isset($username)) {
00897         // No username is given --> display the overview
00898         echo '<h2>' . "\n"
00899            . '    ' . $strUserOverview . "\n"
00900            . '</h2>' . "\n";
00901         $oldPrivTables = FALSE;
00902         if (PMA_MYSQL_INT_VERSION >= 40002) {
00903             $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);
00904             if (!$res) {
00905                 // the query failed! This may have two reasons:
00906                 // - the user has not enough privileges
00907                 // - the privilege tables use a structure of an earlier version.
00908                 $oldPrivTables = TRUE;
00909             }
00910         }
00911         if (empty($res) || PMA_MYSQL_INT_VERSION < 40002) {
00912             $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);
00913             if (!$res) {
00914                 // the query failed! This may have two reasons:
00915                 // - the user has not enough privileges
00916                 // - the privilege tables use a structure of an earlier version.
00917                 $oldPrivTables = TRUE;
00918             }
00919         }
00920         if (!$res) {
00921             echo '<i>' . $strNoPrivileges . '</i>' . "\n";
00922             @mysql_free_result($res);
00923             unset($res);
00924         } else {
00925             if ($oldPrivTables) {
00926                 // rabus: This message is hardcoded because I will replace it by
00927                 // a automatic repair feature soon.
00928                 echo '<div class="warning">' . "\n"
00929                    . '    Warning: Your privilege table structure seem to be older than this MySQL version!<br />' . "\n"
00930                    . '    Please run the script <tt>mysql_fix_privilege_tables</tt> that should be included in your MySQL server distribution to solve this problem!' . "\n"
00931                    . '</div><br />' . "\n";
00932             }
00933             echo '<form name="usersForm" action="server_privileges.php" method="post" />' . "\n"
00934                . PMA_generate_common_hidden_inputs('', '', 1)
00935                . '    <table border="0">' . "\n"
00936                . '        <tr>' . "\n"
00937                . '            <th></th>' . "\n"
00938                . '            <th>&nbsp;' . $strUser . '&nbsp;</th>' . "\n"
00939                . '            <th>&nbsp;' . $strHost . '&nbsp;</th>' . "\n"
00940                . '            <th>&nbsp;' . $strPassword . '&nbsp;</th>' . "\n"
00941                . '            <th>&nbsp;' . $strGlobalPrivileges . '&nbsp;</th>' . "\n"
00942                . '            <th>&nbsp;' . $strGrantOption . '&nbsp;</th>' . "\n"
00943                . '            <th>&nbsp;' . $strAction . '&nbsp;</th>' . "\n";
00944             echo '        </tr>' . "\n";
00945             $useBgcolorOne = TRUE;
00946             for ($i = 0; $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC); $i++) {
00947                 echo '        <tr>' . "\n"
00948                    . '            <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"
00949                    . '            <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"
00950                    . '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars($row['Host']) . '</td>' . "\n";
00951                 $privs = PMA_extractPrivInfo($row, TRUE);
00952                 echo '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . ($row['Password'] == 'Y' ? $strYes : '<span style="color: #FF0000">' . $strNo . '</span>') . '</td>' . "\n"
00953                    . '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
00954                    . '                ' . join(',' . "\n" . '            ', $privs) . "\n"
00955                    . '            </tt></td>' . "\n"
00956                    . '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . ($row['Grant_priv'] == 'Y' ? $strYes : $strNo) . '</td>' . "\n"
00957                    . '            <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"
00958                    . '        </tr>' . "\n";
00959                 $useBgcolorOne = !$useBgcolorOne;
00960             }
00961             @mysql_free_result($res);
00962             unset($res);
00963             unset ($row);
00964             echo '        <tr>' . "\n"
00965                . '            <td></td>' . "\n"
00966                . '            <td colspan="5">' . "\n"
00967                . '                &nbsp;<i>' . $strEnglishPrivileges . '</i>&nbsp;' . "\n"
00968                . '            </td>' . "\n"
00969                . '        </tr>' . "\n"
00970                . '        <tr>' . "\n"
00971                . '            <td colspan="6" valign="bottom">' . "\n"
00972                . '                <img src="./images/arrow_' . $text_dir . '.gif" border="0" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n"
00973                . '                <a href="./server_privileges.php?' . $url_query .  '&amp;checkall=1" onclick="setCheckboxes(\'usersForm\', \'selected_usr\', true); return false;">' . $strCheckAll . '</a>' . "\n"
00974                . '                &nbsp;/&nbsp;' . "\n"
00975                . '                <a href="server_privileges.php?' . $url_query .  '" onclick="setCheckboxes(\'usersForm\', \'selected_usr\', false); return false;">' . $strUncheckAll . '</a>' . "\n"
00976                . '            </td>' . "\n"
00977                . '        </tr>' . "\n"
00978                . '    </table>' . "\n"
00979                . '    <ul>' . "\n"
00980                . '        <li>' . "\n"
00981                . '            <b><a href="server_privileges.php?' . $url_query . '&amp;adduser=1">' . $strAddUser . '</a></b><br />' . "\n"
00982                . '        </li><br /><br />' . "\n"
00983                . '        <li>' . "\n"
00984                . '            <b>' . $strRemoveSelectedUsers . '</b><br />' . "\n"
00985                . '            <input type="radio" title="' . $strJustDelete . ' ' . $strJustDeleteDescr . '" name="mode" id="radio_mode_1" value="1" checked="checked" />' . "\n"
00986                . '            <label for="radio_mode_1" title="' . $strJustDelete . ' ' . $strJustDeleteDescr . '">' . "\n"
00987                . '                ' . $strJustDelete . "\n"
00988                . '            </label><br />' . "\n"
00989                . '            <input type="radio" title="' . $strRevokeAndDelete . ' ' . $strRevokeAndDeleteDescr . '" name="mode" id="radio_mode_2" value="2" />' . "\n"
00990                . '            <label for="radio_mode_2" title="' . $strRevokeAndDelete . ' ' . $strRevokeAndDeleteDescr . '">' . "\n"
00991                . '                ' . $strRevokeAndDelete . "\n"
00992                . '            </label><br />' . "\n"
00993                . '            <input type="radio" title="' . $strDeleteAndFlush . ' ' . $strDeleteAndFlushDescr . '" name="mode" id="radio_mode_3" value="3" />' . "\n"
00994                . '            <label for="radio_mode_3" title="' . $strDeleteAndFlush . ' ' . $strDeleteAndFlushDescr . '">' . "\n"
00995                . '                ' . $strDeleteAndFlush . "\n"
00996                . '            </label><br />' . "\n"
00997                . '            <input type="checkbox" title="' . $strDropUsersDb . '" name="drop_users_db" id="checkbox_drop_users_db" />' . "\n"
00998                . '            <label for="checkbox_drop_users_db" title="' . $strDropUsersDb . '">' . "\n"
00999                . '                ' . $strDropUsersDb . "\n"
01000                . '            </label><br />' . "\n"
01001                . '            <input type="submit" name="delete" value="' . $strGo . '" />' . "\n"
01002                . '        </li>' . "\n"
01003                . '    </ul>' . "\n"
01004                . '</form>' . "\n"
01005                . '<div>' . "\n"
01006                . '    ' . sprintf($strFlushPrivilegesNote, '<a href="server_privileges.php?' . $url_query . '&amp;flush_privileges=1">', '</a>') . "\n"
01007                . '</div>' . "\n";
01008         }
01009     } else {
01010         // A user was selected -> display the user's properties
01011         echo '<h2>' . "\n"
01012            . '    ' . $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";
01013         if (!empty($dbname)) {
01014             echo '    - ' . $strDatabase . ' <i><a class="h2" href="' . $cfg['DefaultTabDatabase'] . '?' . $url_query . '&amp;db=' . urlencode($dbname) . '&amp;reload=1">' . htmlspecialchars($dbname) . '</a></i>' . "\n";
01015             if (!empty($tablename)) {
01016                 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";
01017             }
01018         }
01019         echo '</h2>' . "\n";
01020         $res = PMA_mysql_query('SELECT "foo" FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";', $userlink);
01021         if (mysql_affected_rows($userlink) <= 0) {
01022             echo $strUserNotFound;
01023             require_once('./footer.inc.php');
01024         }
01025         mysql_free_result($res);
01026         unset($res);
01027         echo '<ul>' . "\n"
01028            . '    <li>' . "\n"
01029            . '        <form action="server_privileges.php" method="post">' . "\n"
01030            . PMA_generate_common_hidden_inputs('', '', 3)
01031            . '            <input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
01032            . '            <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
01033         if (!empty($dbname)) {
01034             echo '            <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '" />' . "\n";
01035             if (!empty($tablename)) {
01036                 echo '            <input type="hidden" name="tablename" value="' . htmlspecialchars($tablename) . '" />' . "\n";
01037             }
01038         }
01039         echo '            <b>' . $strEditPrivileges . '</b><br />' . "\n";
01040         PMA_displayPrivTable((empty($dbname) ? '*' : $dbname), ((empty($dbname) || empty($tablename)) ? '*' : $tablename), TRUE, 3);
01041         echo '        </form>' . "\n"
01042            . '    </li>' . "\n";
01043         if (empty($tablename)) {
01044             echo '    <li>' . "\n"
01045                . '        <b>' . (empty($dbname) ? $strDbPrivileges : $strTblPrivileges) . '</b><br />' . "\n"
01046                . '        <table border="0">' . "\n"
01047                . '            <tr>' . "\n"
01048                . '                <th>&nbsp;' . (empty($dbname) ? $strDatabase : $strTable) . '&nbsp;</th>' . "\n"
01049                . '                <th>&nbsp;' . $strPrivileges . '&nbsp;</th>' . "\n"
01050                . '                <th>&nbsp;' . $strGrantOption . '&nbsp;</th>' . "\n"
01051                . '                <th>&nbsp;' . (empty($dbname) ? $strTblPrivileges : $strColumnPrivileges) . '&nbsp;</th>' . "\n"
01052                . '                <th colspan="2">&nbsp;' . $strAction . '&nbsp;</th>' . "\n"
01053                . '            </tr>' . "\n";
01054             if (empty($dbname)) {
01055                 $sql_query = 'SELECT * FROM `db` WHERE `Host` = "' . $hostname . '" AND `User` = "' . PMA_sqlAddslashes($username) . '" ORDER BY `Db` ASC;';
01056             } else {
01057                 $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;';
01058             }
01059             $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
01060             if (mysql_affected_rows($userlink) == 0) {
01061                 echo '            <tr>' . "\n"
01062                    . '                <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="6"><center><i>' . $strNone . '</i></center></td>' . "\n"
01063                    . '            </tr>' . "\n";
01064             } else {
01065                 $useBgcolorOne = TRUE;
01066                 if (empty($dbname)) {
01067                     $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;');
01068                     $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
01069                 }
01070                 $found_rows = array();
01071                 while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
01072 
01073                     while (empty($dbname) && $row2 && $row['Db'] > $row2['Db']) {
01074                         $found_rows[] = $row2['Db'];
01075 
01076                         echo '            <tr>' . "\n"
01077                            . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars($row2['Db']) . '</td>' . "\n"
01078                            . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
01079                            . '                    <dfn title="' . $strPrivDescUsage . '">USAGE</dfn>' . "\n"
01080                            . '                </tt></td>' . "\n"
01081                            . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strNo . '</td>' . "\n"
01082                            . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strYes . '</td>' . "\n"
01083                            . '                <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"
01084                            . '                <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"
01085                            . '            </tr>' . "\n";
01086                         $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
01087                         $useBgcolorOne = !$useBgcolorOne;
01088                     } // end while
01089                     $found_rows[] = empty($dbname) ? $row['Db'] : $row['Table_name'];
01090 
01091                     echo '            <tr>' . "\n"
01092                        . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars(empty($dbname) ? $row['Db'] : $row['Table_name']) . '</td>' . "\n"
01093                        . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
01094                        . '                    ' . join(',' . "\n" . '            ', PMA_extractPrivInfo($row, TRUE)) . "\n"
01095                        . '                </tt></td>' . "\n"
01096                        . '                <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"
01097                        . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">';
01098                     if ((empty($dbname) && $row2 && $row['Db'] == $row2['Db'])
01099                         || (!empty($dbname) && $row['Column_priv'])) {
01100                         echo $strYes;
01101                         if (empty($dbname)) {
01102                             $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
01103                         }
01104                     } else {
01105                         echo $strNo;
01106                     }
01107                     echo '</td>' . "\n"
01108                        . '                <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"
01109                        . '                <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"
01110                        . '            </tr>' . "\n";
01111                     $useBgcolorOne = !$useBgcolorOne;
01112                 } // end while
01113 
01114 
01115                 while (empty($dbname) && $row2) {
01116 
01117                     $found_rows[] = $row2['Db'];
01118                     echo '            <tr>' . "\n"
01119                        . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars($row2['Db']) . '</td>' . "\n"
01120                        . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
01121                        . '                    <dfn title="' . $strPrivDescUsage . '">USAGE</dfn>' . "\n"
01122                        . '                </tt></td>' . "\n"
01123                        . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strNo . '</td>' . "\n"
01124                        . '                <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strYes . '</td>' . "\n"
01125                        . '                <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"
01126                        . '                <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"
01127                        . '            </tr>' . "\n";
01128                     $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
01129 
01130                     $useBgcolorOne = !$useBgcolorOne;
01131                 } // end while
01132                 if (empty($dbname)) {
01133                     mysql_free_result($res2);
01134                     unset($res2);
01135                     unset($row2);
01136                 }
01137             }
01138             mysql_free_result($res);
01139             unset($res);
01140             unset($row);
01141             echo '            <tr>' . "\n"
01142                . '                <td colspan="5">' . "\n"
01143                . '                    <form action="server_privileges.php" method="post">' . "\n"
01144                . PMA_generate_common_hidden_inputs('', '', 6)
01145                . '                        <input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
01146                . '                        <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
01147             if (empty($dbname)) {
01148                 echo '                        <label for="text_dbname">' . $strAddPrivilegesOnDb . ':</label>' . "\n";
01149                 $res = PMA_mysql_query('SHOW DATABASES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW DATABASES;');
01150                 $pred_db_array = array();
01151                 while ($row = PMA_mysql_fetch_row($res)) {
01152                     if (!isset($found_rows) || !in_array($row[0], $found_rows)) {
01153                         $pred_db_array[] = $row[0];
01154                     }
01155                 }
01156                 mysql_free_result($res);
01157                 unset($res);
01158                 unset($row);
01159                 if (!empty($pred_db_array)) {
01160                     echo '                        <select name="pred_dbname" onchange="this.form.submit();">' . "\n"
01161                        . '                            <option value="" selected="selected">' . $strUseTextField . ':</option>' . "\n";
01162                     foreach ($pred_db_array as $current_db) {
01163                         echo '                            <option value="' . htmlspecialchars($current_db) . '">' . htmlspecialchars($current_db) . '</option>' . "\n";
01164                     }
01165                     echo '                        </select>' . "\n";
01166                 }
01167                 echo '                        <input type="text" id="text_dbname" name="dbname" class="textfield" />' . "\n";
01168             } else {
01169                 echo '                        <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\n"
01170                    . '                        <label for="text_tablename">' . $strAddPrivilegesOnTbl . ':</label>' . "\n";
01171                 if ($res = @PMA_mysql_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';', $userlink)) {
01172                     $pred_tbl_array = array();
01173                     while ($row = PMA_mysql_fetch_row($res)) {
01174                         if (!isset($found_rows) || !in_array($row[0], $found_rows)) {
01175                             $pred_tbl_array[] = $row[0];
01176                         }
01177                     }
01178                     mysql_free_result($res);
01179                     unset($res);
01180                     unset($row);
01181                     if (!empty($pred_tbl_array)) {
01182                         echo '                        <select name="pred_tablename" onchange="this.form.submit();">' . "\n"
01183                            . '                            <option value="" selected="selected">' . $strUseTextField . ':</option>' . "\n";
01184                         foreach ($pred_tbl_array as $current_table) {
01185                             echo '                            <option value="' . htmlspecialchars($current_table) . '">' . htmlspecialchars($current_table) . '</option>' . "\n";
01186                         }
01187                         echo '                        </select>' . "\n";
01188                     }
01189                 } else {
01190                     unset($res);
01191                 }
01192                 echo '                        <input type="text" id="text_tablename" name="tablename" class="textfield" />' . "\n";
01193             }
01194             echo '                        <input type="submit" value="' . $strGo . '" />' . "\n"
01195                . '                    </form>' . "\n"
01196                . '                </td>' . "\n"
01197                . '            </tr>' . "\n"
01198                . '        </table><br />' . "\n"
01199                . '    </li>' . "\n";
01200         }
01201         if (empty($dbname)) {
01202             echo '    <li>' . "\n"
01203                . '        <form action="server_privileges.php" method="post" onsubmit="checkPassword(this);">' . "\n"
01204                . PMA_generate_common_hidden_inputs('', '', 3)
01205                . '            <input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
01206                . '            <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
01207             echo '            <b>' . $strChangePassword . '</b><br />' . "\n"
01208                . '            <table border="0">' . "\n"
01209                . '                <tr>' . "\n"
01210                . '                    <td bgcolor="' . $cfg['BgcolorOne'] . '"><input type="radio" name="nopass" value="1" id="radio_nopass_1" onclick="pma_pw.value=\'\'; pma_pw2.value=\'\';" /></td>' . "\n"
01211                . '                    <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2"><label for="radio_nopass_1">' . $strNoPassword . '</label></td>' . "\n"
01212                . '                </tr>' . "\n"
01213                . '                <tr>' . "\n"
01214                . '                    <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="radio" name="nopass" value="0" id="radio_nopass_0" onclick="document.getElementById(\'pw_pma_pw\').focus();" /></td>' . "\n"
01215                . '                    <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="radio_nopass_0">' . $strPassword . ':</label></td>' . "\n"
01216                . '                    <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="password" name="pma_pw" id="pw_pma_pw" class="textfield" onchange="nopass[1].checked = true;" /></td>' . "\n"
01217                . '                </tr>' . "\n"
01218                . '                <tr>' . "\n"
01219                . '                    <td bgcolor="' . $cfg['BgcolorTwo'] . '">&nbsp;</td>' . "\n"
01220                . '                    <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="pw_pma_pw2">' . $strReType . ':</label></td>' . "\n"
01221                . '                    <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="password" name="pma_pw2" id="pw_pma_pw2" class="textfield" onchange="nopass[1].checked = true;" /></td>' . "\n"
01222                . '                </tr>' . "\n"
01223                . '                <tr>' . "\n"
01224                . '                    <td colspan="3" align="center">' . "\n"
01225                . '                        <input type="submit" name="change_pw" value="' . $strGo . '" />' . "\n"
01226                . '                    </td>' . "\n"
01227                . '                </tr>' . "\n"
01228                . '            </table>' . "\n"
01229                . '        </form>' . "\n"
01230                . '    </li>' . "\n"
01231                . '    <li>' . "\n"
01232                . '        <form action="server_privileges.php" method="post" onsubmit="checkPassword(this);">' . "\n"
01233                . PMA_generate_common_hidden_inputs('', '', 3)
01234                . '            <input type="hidden" name="old_username" value="' . htmlspecialchars($username) . '" />' . "\n"
01235                . '            <input type="hidden" name="old_hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n"
01236                . '            <b>' . $strChangeCopyUser . '</b><br />' . "\n"
01237                . '            <table border="0">' . "\n";
01238             PMA_displayLoginInformationFields('change', 3);
01239             echo '            </table>' . "\n"
01240                . '            ' . $strChangeCopyMode . '<br />' . "\n"
01241                . '            <input type="radio" name="mode" value="4" id="radio_mode_4" checked="checked" />' . "\n"
01242                . '            <label for="radio_mode_4">' . "\n"
01243                . '                ' . $strChangeCopyModeCopy . "\n"
01244                . '            </label>' . "\n"
01245                . '            <br />' . "\n"
01246                . '            <input type="radio" name="mode" value="1" id="radio_mode_1" />' . "\n"
01247                . '            <label for="radio_mode_1">' . "\n"
01248                . '                ' . $strChangeCopyModeJustDelete . "\n"
01249                . '            </label>' . "\n"
01250                . '            <br />' . "\n"
01251                . '            <input type="radio" name="mode" value="2" id="radio_mode_2" />' . "\n"
01252                . '            <label for="radio_mode_2">' . "\n"
01253                . '                ' . $strChangeCopyModeRevoke . "\n"
01254                . '            </label>' . "\n"
01255                . '            <br />' . "\n"
01256                . '            <input type="radio" name="mode" value="3" id="radio_mode_3" />' . "\n"
01257                . '            <label for="radio_mode_3">' . "\n"
01258                . '                ' . $strChangeCopyModeDeleteAndReload . "\n"
01259                . '            </label>' . "\n"
01260                . '            <br />' . "\n"
01261                . '            <input type="submit" name="change_copy" value="' . $strGo . '" />' . "\n"
01262                . '        </form>' . "\n"
01263                . '    </li>' . "\n";
01264         }
01265         echo '</ul>' . "\n";
01266     }
01267 } else if (!empty($adduser)) {
01268     // Add a new user
01269     echo '<h2>' . "\n"
01270        . '    ' . $strAddUser . "\n"
01271        . '</h2>' . "\n"
01272        . '<form action="server_privileges.php" method="post" onsubmit="return checkAddUser(this);">' . "\n"
01273        . PMA_generate_common_hidden_inputs('', '', 1)
01274        . '    <table border="0">' . "\n"
01275        . '        <tr>' . "\n"
01276        . '            <th colspan="3">' . "\n"
01277        . '                ' . $strLoginInformation . "\n"
01278        . '            </th>' . "\n"
01279        . '        </tr>' . "\n";
01280     PMA_displayLoginInformationFields('new', 2);
01281     echo '    </table><br />' . "\n";
01282     PMA_displayPrivTable('*', '*', FALSE, 1);
01283     echo '    <br />' . "\n"
01284        . '    <input type="submit" name="adduser_submit" value="' . $strGo . '" />' . "\n"
01285        . '</form>' . "\n";
01286 } else {
01287     // check the privileges for a particular database.
01288     echo '<h2>' . "\n"
01289        . '    ' . sprintf($strUsersHavingAccessToDb, htmlspecialchars($checkprivs)) . "\n"
01290        . '</h2>' . "\n"
01291        . '<table border="0">' . "\n"
01292        . '    <tr>' . "\n"
01293        . '        <th>' . "\n"
01294        . '            &nbsp;' . $strUser . '&nbsp;' . "\n"
01295        . '        </th>' . "\n"
01296        . '        <th>' . "\n"
01297        . '            &nbsp;' . $strHost . '&nbsp;' . "\n"
01298        . '        </th>' . "\n"
01299        . '        <th>' . "\n"
01300        . '            &nbsp;' . $strType . '&nbsp;' . "\n"
01301        . '        </th>' . "\n"
01302        . '        <th>' . "\n"
01303        . '            &nbsp;' . $strPrivileges . '&nbsp;' . "\n"
01304        . '        </th>' . "\n"
01305        . '        <th>' . "\n"
01306        . '            &nbsp;' . $strGrantOption . '&nbsp;' . "\n"
01307        . '        </th>' . "\n"
01308        . '        <th>' . "\n"
01309        . '            &nbsp;' . $strAction . '&nbsp;' . "\n"
01310        . '        </th>' . "\n"
01311        . '    </tr>' . "\n";
01312     $useBgcolorOne = TRUE;
01313     unset($row);
01314     unset($row1);
01315     unset($row2);
01316     // now, we build the table...
01317     if (PMA_MYSQL_INT_VERSION >= 40000) {
01318         // Starting with MySQL 4.0.0, we may use UNION SELECTs and this makes
01319         // the job much easier here!
01320         $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;';
01321         $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
01322         $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
01323         if ($row) {
01324             $found = TRUE;
01325         }
01326     } else {
01327         // With MySQL 3, we need 2 seperate queries here.
01328         $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;';
01329         $res1 = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
01330         $row1 = PMA_mysql_fetch_array($res1, MYSQL_ASSOC);
01331         $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;';
01332         $res2 = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
01333         $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
01334         if ($row1 || $row2) {
01335             $found = TRUE;
01336         }
01337     } // end if (PMA_MYSQL_INT_VERSION >= 40000) ... else ...
01338     if ($found) {
01339         while (TRUE) {
01340             // prepare the current user
01341             if (PMA_MYSQL_INT_VERSION >= 40000) {
01342                 $current_privileges = array();
01343                 $current_user = $row['User'];
01344                 $current_host = $row['Host'];
01345                 while ($row && $current_user == $row['User'] && $current_host == $row['Host']) {
01346                     $current_privileges[] = $row;
01347                     $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
01348                 }
01349             } else {
01350                 $current_privileges = array();
01351                 if ($row1 && (!$row2 || ($row1['User'] < $row2['User'] || ($row1['User'] == $row2['User'] && $row1['Host'] <= $row2['Host'])))) {
01352                     $current_user = $row1['User'];
01353                     $current_host = $row1['Host'];
01354                     $current_privileges = array($row1);
01355                     $row1 = PMA_mysql_fetch_array($res1, MYSQL_ASSOC);
01356                 } else {
01357                     $current_user = $row2['User'];
01358                     $current_host = $row2['Host'];
01359                     $current_privileges = array();
01360                 }
01361                 while ($row2 && $current_user == $row2['User'] && $current_host == $row2['Host']) {
01362                     $current_privileges[] = $row2;
01363                     $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
01364                 }
01365             }
01366             echo '    <tr>' . "\n"
01367                . '        <td';
01368             if (count($current_privileges) > 1) {
01369                 echo ' rowspan="' . count($current_privileges) . '"';
01370             }
01371             echo ' bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
01372                . '            ' . (empty($current_user) ? '<span style="color: #FF0000">' . $strAny . '</span>' : htmlspecialchars($current_user)) . "\n"
01373                . '        </td>' . "\n"
01374                . '        <td';
01375             if (count($current_privileges) > 1) {
01376                 echo ' rowspan="' . count($current_privileges) . '"';
01377             }
01378             echo ' bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
01379                . '            ' . htmlspecialchars($current_host) . "\n"
01380                . '        </td>' . "\n";
01381             foreach ($current_privileges as $current) {
01382                 echo '        <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
01383                    . '            ';
01384                 if (!isset($current['Db']) || $current['Db'] == '*') {
01385                     echo $strGlobal;
01386                 } else if ($current['Db'] == $checkprivs) {
01387                     echo $strDbSpecific;
01388                 } else {
01389                     echo $strWildcard, ': <tt>' . htmlspecialchars($current['Db']) . '</tt>';
01390                 }
01391                 echo "\n"
01392                    . '        </td>' . "\n"
01393                    . '        <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
01394                    . '            <tt>' . "\n"
01395                    . '                ' . join(',' . "\n" . '                ', PMA_extractPrivInfo($current, TRUE)) . "\n"
01396                    . '            <tt>' . "\n"
01397                    . '        </td>' . "\n"
01398                    . '        <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
01399                    . '            ' . ($current['Grant_priv'] == 'Y' ? $strYes : $strNo) . "\n"
01400                    . '        </td>' . "\n"
01401                    . '        <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
01402                    . '            <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"
01403                    . '                ' . $strEdit . "\n"
01404                    . '            </a>' . "\n"
01405                    . '        </td>' . "\n"
01406                    . '    </tr>' . "\n";
01407             }
01408             if (empty($row) && empty($row1) && empty($row2)) {
01409                 break;
01410             }
01411             $useBgcolorOne = !$useBgcolorOne;
01412         }
01413     } else {
01414         echo '    <tr>' . "\n"
01415            . '        <td colspan="6" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
01416            . '            ' . $strNoUsersFound . "\n"
01417            . '        </td>' . "\n"
01418            . '    </tr>' . "\n";
01419     }
01420     echo '</table>' . "\n";
01421 } // end if (empty($adduser) && empty($checkprivs)) ... else if ... else ...
01422 
01423 
01427 echo "\n\n";
01428 require_once('./footer.inc.php');
01429 
01430 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6